diff options
Diffstat (limited to 'LuaSL/src/LuaSL_main.c')
-rw-r--r-- | LuaSL/src/LuaSL_main.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/LuaSL/src/LuaSL_main.c b/LuaSL/src/LuaSL_main.c index 940e201..e56aaf3 100644 --- a/LuaSL/src/LuaSL_main.c +++ b/LuaSL/src/LuaSL_main.c | |||
@@ -15,6 +15,7 @@ static Eina_Bool _add(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Ad | |||
15 | static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Data *ev) | 15 | static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Data *ev) |
16 | { | 16 | { |
17 | gameGlobals *game = data; | 17 | gameGlobals *game = data; |
18 | char buf[PATH_MAX]; | ||
18 | char SID[PATH_MAX]; | 19 | char SID[PATH_MAX]; |
19 | const char *command; | 20 | const char *command; |
20 | char *ext; | 21 | char *ext; |
@@ -28,25 +29,48 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_D | |||
28 | strncpy(SID, command, length + 1); | 29 | strncpy(SID, command, length + 1); |
29 | SID[length] = '\0'; | 30 | SID[length] = '\0'; |
30 | eina_strbuf_remove(clientStream, 0, length + 1); | 31 | eina_strbuf_remove(clientStream, 0, length + 1); |
31 | ext = rindex(SID, '.'); | 32 | ext = index(SID, '.'); |
32 | if (ext) | 33 | if (ext) |
33 | { | 34 | { |
34 | ext[0] = '\0'; | 35 | ext[0] = '\0'; |
35 | command = ext + 1; | 36 | command = ext + 1; |
36 | if (0 == strcmp(command, "compile()")) | 37 | if (0 == strncmp(command, "compile(", 8)) |
37 | { | 38 | { |
38 | PD("Compiling %s.", SID); | 39 | char *temp; |
39 | if (compileLSL(game, ev->client, SID, FALSE)) | 40 | char *file; |
41 | |||
42 | strcpy(buf, &command[8]); | ||
43 | temp = buf; | ||
44 | file = temp; | ||
45 | while (')' != temp[0]) | ||
46 | temp++; | ||
47 | temp[0] = '\0'; | ||
48 | |||
49 | PD("Compiling %s, %s.", SID, file); | ||
50 | if (compileLSL(game, ev->client, SID, file, FALSE)) | ||
51 | { | ||
52 | script *me = calloc(1, sizeof(script)); | ||
53 | |||
54 | gettimeofday(&me->startTime, NULL); | ||
55 | strncpy(me->SID, SID, sizeof(me->SID)); | ||
56 | strncpy(me->fileName, file, sizeof(me->fileName)); | ||
57 | eina_hash_add(game->scripts, me->SID, me); | ||
40 | sendBack(game, ev->client, SID, "compiled(true)"); | 58 | sendBack(game, ev->client, SID, "compiled(true)"); |
59 | } | ||
41 | else | 60 | else |
42 | sendBack(game, ev->client, SID, "compiled(false)"); | 61 | sendBack(game, ev->client, SID, "compiled(false)"); |
43 | } | 62 | } |
44 | else if (0 == strcmp(command, "run()")) | 63 | else if (0 == strcmp(command, "run()")) |
45 | { | 64 | { |
65 | script *me; | ||
46 | char buf[PATH_MAX]; | 66 | char buf[PATH_MAX]; |
47 | 67 | ||
48 | sprintf(buf, "%s.lua.out", SID); | 68 | me = eina_hash_find(game->scripts, SID); |
49 | newProc(buf, TRUE); | 69 | if (me) |
70 | { | ||
71 | sprintf(buf, "%s.lua.out", me->fileName); | ||
72 | newProc(buf, TRUE); | ||
73 | } | ||
50 | } | 74 | } |
51 | else if (0 == strcmp(command, "exit()")) | 75 | else if (0 == strcmp(command, "exit()")) |
52 | { | 76 | { |
@@ -95,6 +119,7 @@ int main(int argc, char **argv) | |||
95 | if (eina_init()) | 119 | if (eina_init()) |
96 | { | 120 | { |
97 | loggingStartup(&game); | 121 | loggingStartup(&game); |
122 | game.scripts = eina_hash_string_superfast_new(NULL); | ||
98 | if (ecore_con_init()) | 123 | if (ecore_con_init()) |
99 | { | 124 | { |
100 | if ((game.server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, game.address, game.port, &game))) | 125 | if ((game.server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, game.address, game.port, &game))) |