diff options
author | David Walter Seikel | 2012-02-24 18:53:07 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-02-24 18:53:07 +1000 |
commit | 1064801dc5532fb1075773d1647b667d39532a75 (patch) | |
tree | 1c3bb0f80d7fedc88cda3fa45ef0a54693540b68 /LuaSL/src | |
parent | Update license descriptions. (diff) | |
download | SledjHamr-1064801dc5532fb1075773d1647b667d39532a75.zip SledjHamr-1064801dc5532fb1075773d1647b667d39532a75.tar.gz SledjHamr-1064801dc5532fb1075773d1647b667d39532a75.tar.bz2 SledjHamr-1064801dc5532fb1075773d1647b667d39532a75.tar.xz |
Stub out the script resetting functions, and refactor the script finding code that is common with those and llSetScriptState().
Diffstat (limited to 'LuaSL/src')
-rw-r--r-- | LuaSL/src/LuaSL_main.c | 76 |
1 files changed, 53 insertions, 23 deletions
diff --git a/LuaSL/src/LuaSL_main.c b/LuaSL/src/LuaSL_main.c index 388b151..582ba95 100644 --- a/LuaSL/src/LuaSL_main.c +++ b/LuaSL/src/LuaSL_main.c | |||
@@ -26,6 +26,29 @@ static Eina_Bool _timer_timer_cb(void *data) | |||
26 | return ECORE_CALLBACK_RENEW; | 26 | return ECORE_CALLBACK_RENEW; |
27 | } | 27 | } |
28 | 28 | ||
29 | static script *findThem(gameGlobals *game, const char *base, const char *text) | ||
30 | { | ||
31 | char name[PATH_MAX]; | ||
32 | char *temp; | ||
33 | |||
34 | strncpy(name, base, PATH_MAX); | ||
35 | if ((temp = rindex(name, '/'))) | ||
36 | temp[1] = '\0'; | ||
37 | strcat(name, text); | ||
38 | if ((temp = rindex(name, '"'))) | ||
39 | temp[0] = '\0'; | ||
40 | strcat(name, ".lsl"); | ||
41 | return eina_hash_find(game->names, name); | ||
42 | } | ||
43 | |||
44 | static void resetScript(script *victim) | ||
45 | { | ||
46 | gameGlobals *game = victim->game; | ||
47 | |||
48 | PD("Resetting %s", victim->fileName); | ||
49 | // TODO - now what? | ||
50 | } | ||
51 | |||
29 | static void _sendBack(void * data) | 52 | static void _sendBack(void * data) |
30 | { | 53 | { |
31 | scriptMessage *message = data; | 54 | scriptMessage *message = data; |
@@ -47,37 +70,44 @@ static void _sendBack(void * data) | |||
47 | } | 70 | } |
48 | else if (0 == strncmp(message->message, "llSetScriptState(", 17)) | 71 | else if (0 == strncmp(message->message, "llSetScriptState(", 17)) |
49 | { | 72 | { |
50 | char name[PATH_MAX]; | ||
51 | char *temp; | ||
52 | script *them; | 73 | script *them; |
53 | boolean state = TRUE; | ||
54 | 74 | ||
55 | strncpy(name, message->script->fileName, PATH_MAX); | 75 | if ((them = findThem(game, message->script->fileName, &(message->message[18])))) |
56 | if ((temp = rindex(name, '/'))) | ||
57 | temp[1] = '\0'; | ||
58 | strcat(name, &(message->message[18])); | ||
59 | if ((temp = rindex(name, '""'))) | ||
60 | { | 76 | { |
61 | temp[0] = '\0'; | 77 | char *temp = rindex(&(message->message[18]), ','); |
62 | while (isspace(*temp)) | 78 | |
63 | temp++; | 79 | if (temp) |
64 | if (',' == *temp) | 80 | { |
65 | temp++; | ||
66 | while (isspace(*temp)) | ||
67 | temp++; | 81 | temp++; |
68 | state = '1' == *temp; | 82 | while (isspace(*temp)) |
69 | } | 83 | temp++; |
70 | strcat(name, ".lsl"); | 84 | if ('1' == *temp) |
71 | if ((them = eina_hash_find(game->names, name))) | 85 | sendToChannel(them->SID, "start()", NULL, NULL); |
72 | { | 86 | else |
73 | if (state) | 87 | sendToChannel(them->SID, "stop()", NULL, NULL); |
74 | sendToChannel(them->SID, "start()", NULL, NULL); | 88 | PD("Stopped %s", them->fileName); |
89 | } | ||
75 | else | 90 | else |
76 | sendToChannel(them->SID, "stop()", NULL, NULL); | 91 | PE("Missing script state in llSetScriptState(%s, )", them->fileName); |
77 | } | 92 | } |
78 | else | 93 | else |
79 | PE("Can't stop script %s", name); | 94 | { |
95 | char *temp = rindex(&(message->message[18]), '"'); | ||
96 | |||
97 | if (temp) | ||
98 | *temp = '\0'; | ||
99 | PE("Can't stop script, can't find %s", &(message->message[18])); | ||
100 | } | ||
101 | } | ||
102 | else if (0 == strncmp(message->message, "llResetOtherScript(", 19)) | ||
103 | { | ||
104 | script *them; | ||
105 | |||
106 | if ((them = findThem(game, message->script->fileName, &(message->message[20])))) | ||
107 | resetScript(them); | ||
80 | } | 108 | } |
109 | else if (0 == strncmp(message->message, "llResetScript(", 14)) | ||
110 | resetScript(message->script); | ||
81 | else | 111 | else |
82 | sendBack(game, message->script->client, message->script->SID, message->message); | 112 | sendBack(game, message->script->client, message->script->SID, message->message); |
83 | free(message); | 113 | free(message); |