diff options
author | David Walter Seikel | 2014-05-18 13:27:05 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-05-18 13:27:05 +1000 |
commit | 5b3f4f59112aeb4c91806103c487ca3148b63486 (patch) | |
tree | 15f234b9ab9551b8129465a136430d16a4eff3b9 /src/love | |
parent | No need to say this is where the history is show now that it's actually being... (diff) | |
download | SledjHamr-5b3f4f59112aeb4c91806103c487ca3148b63486.zip SledjHamr-5b3f4f59112aeb4c91806103c487ca3148b63486.tar.gz SledjHamr-5b3f4f59112aeb4c91806103c487ca3148b63486.tar.bz2 SledjHamr-5b3f4f59112aeb4c91806103c487ca3148b63486.tar.xz |
Clean up the server startup and connection a bit.
Diffstat (limited to 'src/love')
-rw-r--r-- | src/love/love.c | 46 |
1 files changed, 19 insertions, 27 deletions
diff --git a/src/love/love.c b/src/love/love.c index 257d957..91c9d95 100644 --- a/src/love/love.c +++ b/src/love/love.c | |||
@@ -472,37 +472,33 @@ static Eina_Bool _dataLuaSL(void *data, int type, Ecore_Con_Event_Server_Data *e | |||
472 | return ECORE_CALLBACK_RENEW; | 472 | return ECORE_CALLBACK_RENEW; |
473 | } | 473 | } |
474 | 474 | ||
475 | // Forward declare a circular reference. | 475 | static Eina_Bool _delLuaSL(void *data, int type, Ecore_Con_Event_Server_Del *ev) |
476 | static Eina_Bool _delLuaSL(void *data, int type, Ecore_Con_Event_Server_Del *ev); | ||
477 | |||
478 | static Eina_Bool _serverDelTimer(void *data) | ||
479 | { | 476 | { |
480 | gameGlobals *ourGlobals = data; | 477 | gameGlobals *ourGlobals = data; |
478 | static int count = 0; | ||
481 | 479 | ||
482 | ourGlobals->serverLuaSL = reachOut("127.0.0.1", 8211, ourGlobals, (Ecore_Event_Handler_Cb) _addLuaSL, (Ecore_Event_Handler_Cb) _dataLuaSL, (Ecore_Event_Handler_Cb) _delLuaSL); | 480 | ourGlobals->serverLuaSL = NULL; |
483 | return ECORE_CALLBACK_CANCEL; | ||
484 | } | ||
485 | 481 | ||
486 | static Eina_Bool _delLuaSL(void *data, int type, Ecore_Con_Event_Server_Del *ev) | 482 | // Let it fail a couple of times during startup, then try to start our own script server. |
487 | { | 483 | count++; |
488 | gameGlobals *ourGlobals = data; | 484 | if (1 < count) |
485 | { | ||
486 | char buf[PATH_MAX]; | ||
489 | 487 | ||
490 | if (ev->server) | 488 | PW("Failed to connect to a script server, starting our own."); |
491 | { | 489 | sprintf(buf, "%s/LuaSL &", PACKAGE_BIN_DIR); |
492 | ecore_con_server_del(ev->server); | 490 | system(buf); |
493 | ourGlobals->serverLuaSL = NULL; | 491 | count = 0; |
494 | if (!ourGlobals->ui) | 492 | } |
495 | ecore_main_loop_quit(); | ||
496 | else | ||
497 | { | ||
498 | PW("Server dropped out, trying to reconnect."); | ||
499 | ecore_timer_add(1.0, _serverDelTimer, ourGlobals); | ||
500 | } | ||
501 | } | ||
502 | 493 | ||
494 | // TODO - May want to renew even if it's not running the GUI, but then we still need some sort of "shut down" signal, which we don't need during testing. | ||
495 | // if (ourGlobals->ui) | ||
503 | return ECORE_CALLBACK_RENEW; | 496 | return ECORE_CALLBACK_RENEW; |
504 | } | ||
505 | 497 | ||
498 | // ecore_main_loop_quit(); | ||
499 | |||
500 | // return ECORE_CALLBACK_CANCEL; | ||
501 | } | ||
506 | 502 | ||
507 | static Eina_Bool _addClient(void *data, int type, Ecore_Con_Event_Client_Add *ev) | 503 | static Eina_Bool _addClient(void *data, int type, Ecore_Con_Event_Client_Add *ev) |
508 | { | 504 | { |
@@ -606,10 +602,6 @@ int main(int argc, char **argv) | |||
606 | char *programName = argv[0]; | 602 | char *programName = argv[0]; |
607 | boolean badArgs = FALSE; | 603 | boolean badArgs = FALSE; |
608 | int result = EXIT_FAILURE; | 604 | int result = EXIT_FAILURE; |
609 | char buf[PATH_MAX]; | ||
610 | |||
611 | sprintf(buf, "%s/LuaSL &", PACKAGE_BIN_DIR); | ||
612 | system(buf); | ||
613 | 605 | ||
614 | memset(&ourGlobals, 0, sizeof(gameGlobals)); | 606 | memset(&ourGlobals, 0, sizeof(gameGlobals)); |
615 | ourGlobals.address = "127.0.0.1"; | 607 | ourGlobals.address = "127.0.0.1"; |