diff options
author | David Walter Seikel | 2016-02-05 16:38:58 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-02-05 16:38:58 +1000 |
commit | 76faf8a71ca29aef0de066fb3a31823227b6d95d (patch) | |
tree | e7bd6bf9ddb63569c4b98e1679631fa1103d0300 /src/love/love.c | |
parent | Authors++ (diff) | |
download | SledjHamr-76faf8a71ca29aef0de066fb3a31823227b6d95d.zip SledjHamr-76faf8a71ca29aef0de066fb3a31823227b6d95d.tar.gz SledjHamr-76faf8a71ca29aef0de066fb3a31823227b6d95d.tar.bz2 SledjHamr-76faf8a71ca29aef0de066fb3a31823227b6d95d.tar.xz |
The next step in cleaning up the network Lua messages.
Diffstat (limited to '')
-rw-r--r-- | src/love/love.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/love/love.c b/src/love/love.c index 9ad9842..8d1bcd4 100644 --- a/src/love/love.c +++ b/src/love/love.c | |||
@@ -191,7 +191,7 @@ char *get_rawline(int fd, long *plen, char end) | |||
191 | } | 191 | } |
192 | 192 | ||
193 | 193 | ||
194 | static Eina_Bool LuaSLParser(void *data, Connection *conn, char *SID, char *command, char *arguments) | 194 | static boolean LuaSLParser(void *data, Connection *conn, char *SID, char *command, char *arguments) |
195 | { | 195 | { |
196 | gameGlobals *ourGlobals = data; | 196 | gameGlobals *ourGlobals = data; |
197 | char buf[PATH_MAX]; | 197 | char buf[PATH_MAX]; |
@@ -256,22 +256,20 @@ static Eina_Bool LuaSLParser(void *data, Connection *conn, char *SID, char *comm | |||
256 | struct timeval now; | 256 | struct timeval now; |
257 | 257 | ||
258 | compiledCount++; | 258 | compiledCount++; |
259 | if ('t' == arguments[0]) | ||
260 | send2(ourGlobals->serverLuaSL, SID, "run(%s)", me->fileName); | ||
261 | else | ||
262 | PE("The compile of %s.%s failed!", SID, me->fileName); | ||
263 | |||
259 | if (compiledCount == scriptCount) | 264 | if (compiledCount == scriptCount) |
260 | { | 265 | { |
261 | float total = timeDiff(&now, &startTime); | 266 | float total = timeDiff(&now, &startTime); |
267 | |||
262 | PI("Compile speed scripts: %d time: %fs total: %f scripts per second", compiledCount, total, compiledCount / total); | 268 | PI("Compile speed scripts: %d time: %fs total: %f scripts per second", compiledCount, total, compiledCount / total); |
263 | } | 269 | } |
264 | } | 270 | } |
265 | |||
266 | if ('t' == arguments[0]) | ||
267 | { | ||
268 | //PD("About to run %s", me->fileName); | ||
269 | send2(ourGlobals->serverLuaSL, SID, "run(%s)", me->fileName); | ||
270 | } | ||
271 | else | 271 | else |
272 | { | 272 | PE("We got a compiled() on non existing script - %s?", SID); |
273 | // PE("The compile of %s failed!", SID); | ||
274 | } | ||
275 | } | 273 | } |
276 | else | 274 | else |
277 | { | 275 | { |
@@ -453,10 +451,10 @@ static Eina_Bool LuaSLParser(void *data, Connection *conn, char *SID, char *comm | |||
453 | 451 | ||
454 | } | 452 | } |
455 | else | 453 | else |
456 | PI("Script %s sent command %s(%s", SID, command, arguments); | 454 | return FALSE; |
457 | } | 455 | } |
458 | 456 | ||
459 | return ECORE_CALLBACK_RENEW; | 457 | return TRUE; |
460 | } | 458 | } |
461 | 459 | ||
462 | static Eina_Bool _delLuaSL(void *data, int type, Ecore_Con_Event_Server_Del *ev) | 460 | static Eina_Bool _delLuaSL(void *data, int type, Ecore_Con_Event_Server_Del *ev) |
@@ -489,7 +487,7 @@ static Eina_Bool _addClient(void *data, int type, Ecore_Con_Event_Client_Add *ev | |||
489 | return ECORE_CALLBACK_RENEW; | 487 | return ECORE_CALLBACK_RENEW; |
490 | } | 488 | } |
491 | 489 | ||
492 | static Eina_Bool clientParser(void *data, Connection *conn, char *SID, char *command, char *arguments) | 490 | static boolean clientParser(void *data, Connection *conn, char *SID, char *command, char *arguments) |
493 | { | 491 | { |
494 | gameGlobals *ourGlobals = data; | 492 | gameGlobals *ourGlobals = data; |
495 | 493 | ||
@@ -524,9 +522,9 @@ static Eina_Bool clientParser(void *data, Connection *conn, char *SID, char *com | |||
524 | eina_iterator_free(scripts); | 522 | eina_iterator_free(scripts); |
525 | } | 523 | } |
526 | else | 524 | else |
527 | PW("Unknown command from client - %s(%s", command, arguments); | 525 | return FALSE; |
528 | 526 | ||
529 | return ECORE_CALLBACK_RENEW; | 527 | return TRUE; |
530 | } | 528 | } |
531 | 529 | ||
532 | static Eina_Bool _delClient(void *data, int type, Ecore_Con_Event_Client_Del *ev) | 530 | static Eina_Bool _delClient(void *data, int type, Ecore_Con_Event_Client_Del *ev) |
@@ -670,10 +668,10 @@ int main(int argc, char **argv) | |||
670 | 668 | ||
671 | // PD("About to try connecting to a LuaSL server."); | 669 | // PD("About to try connecting to a LuaSL server."); |
672 | // Try to connect to a local LuaSL server. | 670 | // Try to connect to a local LuaSL server. |
673 | reachOut("LuaSL", "./LuaSL", "127.0.0.1", ourGlobals.port, &ourGlobals, (Ecore_Event_Handler_Cb) _addLuaSL, /*(Ecore_Event_Handler_Cb) _dataLuaSL*/ NULL, (Ecore_Event_Handler_Cb) _delLuaSL, LuaSLParser); | 671 | reachOut("LuaSL", "./LuaSL", "127.0.0.1", ourGlobals.port, &ourGlobals, (Ecore_Event_Handler_Cb) _addLuaSL, /*(Ecore_Event_Handler_Cb) _dataLuaSL*/ NULL, (Ecore_Event_Handler_Cb) _delLuaSL, LuaSLParser, NULL); |
674 | 672 | ||
675 | // PD("Love is about to try creating a love server."); | 673 | // PD("Love is about to try creating a love server."); |
676 | if (openArms("love", ourGlobals.address, ourGlobals.port + 1, &ourGlobals, (Ecore_Event_Handler_Cb) _addClient, NULL, (Ecore_Event_Handler_Cb) _delClient, clientParser)) | 674 | if (openArms("love", ourGlobals.address, ourGlobals.port + 1, &ourGlobals, (Ecore_Event_Handler_Cb) _addClient, NULL, (Ecore_Event_Handler_Cb) _delClient, clientParser, NULL)) |
677 | { | 675 | { |
678 | ecore_main_loop_begin(); | 676 | ecore_main_loop_begin(); |
679 | PD("Fell out of the main loop"); | 677 | PD("Fell out of the main loop"); |