aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-02-24 04:40:00 +1000
committerDavid Walter Seikel2012-02-24 04:40:00 +1000
commit693440574b11316222f107743a90cdbf2936eb18 (patch)
treef6cf7938eab35f15988a3f8ccaa8d290a898ff7e /LuaSL
parentImplemented events and detects. (diff)
downloadSledjHamr-693440574b11316222f107743a90cdbf2936eb18.zip
SledjHamr-693440574b11316222f107743a90cdbf2936eb18.tar.gz
SledjHamr-693440574b11316222f107743a90cdbf2936eb18.tar.bz2
SledjHamr-693440574b11316222f107743a90cdbf2936eb18.tar.xz
Implement llSetScriptState().
Diffstat (limited to 'LuaSL')
-rw-r--r--LuaSL/src/LuaSL.h2
-rw-r--r--LuaSL/src/LuaSL_main.c38
2 files changed, 38 insertions, 2 deletions
diff --git a/LuaSL/src/LuaSL.h b/LuaSL/src/LuaSL.h
index ae0c26f..f03b885 100644
--- a/LuaSL/src/LuaSL.h
+++ b/LuaSL/src/LuaSL.h
@@ -54,7 +54,7 @@ typedef struct
54 Evas_Object *bg; // Our background edje, also the game specific stuff. 54 Evas_Object *bg; // Our background edje, also the game specific stuff.
55 Evas_Object *edje; // The edje of the background. 55 Evas_Object *edje; // The edje of the background.
56 Ecore_Con_Server *server; 56 Ecore_Con_Server *server;
57 Eina_Hash *scripts; 57 Eina_Hash *scripts, *names;
58 int logDom; 58 int logDom;
59 const char *address; 59 const char *address;
60 int port; 60 int port;
diff --git a/LuaSL/src/LuaSL_main.c b/LuaSL/src/LuaSL_main.c
index 5a56a88..388b151 100644
--- a/LuaSL/src/LuaSL_main.c
+++ b/LuaSL/src/LuaSL_main.c
@@ -29,6 +29,7 @@ static Eina_Bool _timer_timer_cb(void *data)
29static void _sendBack(void * data) 29static void _sendBack(void * data)
30{ 30{
31 scriptMessage *message = data; 31 scriptMessage *message = data;
32 gameGlobals *game = message->script->game;
32 33
33 if (0 == strncmp(message->message, "llSleep(", 8)) 34 if (0 == strncmp(message->message, "llSleep(", 8))
34 ecore_timer_add(atof(&(message->message)[8]), _sleep_timer_cb, message->script); 35 ecore_timer_add(atof(&(message->message)[8]), _sleep_timer_cb, message->script);
@@ -44,8 +45,41 @@ static void _sendBack(void * data)
44 else 45 else
45 message->script->timer = ecore_timer_add(message->script->timerTime, _timer_timer_cb, message->script); 46 message->script->timer = ecore_timer_add(message->script->timerTime, _timer_timer_cb, message->script);
46 } 47 }
48 else if (0 == strncmp(message->message, "llSetScriptState(", 17))
49 {
50 char name[PATH_MAX];
51 char *temp;
52 script *them;
53 boolean state = TRUE;
54
55 strncpy(name, message->script->fileName, PATH_MAX);
56 if ((temp = rindex(name, '/')))
57 temp[1] = '\0';
58 strcat(name, &(message->message[18]));
59 if ((temp = rindex(name, '""')))
60 {
61 temp[0] = '\0';
62 while (isspace(*temp))
63 temp++;
64 if (',' == *temp)
65 temp++;
66 while (isspace(*temp))
67 temp++;
68 state = '1' == *temp;
69 }
70 strcat(name, ".lsl");
71 if ((them = eina_hash_find(game->names, name)))
72 {
73 if (state)
74 sendToChannel(them->SID, "start()", NULL, NULL);
75 else
76 sendToChannel(them->SID, "stop()", NULL, NULL);
77 }
78 else
79 PE("Can't stop script %s", name);
80 }
47 else 81 else
48 sendBack(message->script->game, message->script->client, message->script->SID, message->message); 82 sendBack(game, message->script->client, message->script->SID, message->message);
49 free(message); 83 free(message);
50} 84}
51 85
@@ -100,6 +134,7 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_D
100 me->game = game; 134 me->game = game;
101 me->client = ev->client; 135 me->client = ev->client;
102 eina_hash_add(game->scripts, me->SID, me); 136 eina_hash_add(game->scripts, me->SID, me);
137 eina_hash_add(game->names, me->fileName, me);
103 sendBack(game, ev->client, SID, "compiled(true)"); 138 sendBack(game, ev->client, SID, "compiled(true)");
104 } 139 }
105 else 140 else
@@ -165,6 +200,7 @@ int main(int argc, char **argv)
165 { 200 {
166 loggingStartup(&game); 201 loggingStartup(&game);
167 game.scripts = eina_hash_string_superfast_new(NULL); 202 game.scripts = eina_hash_string_superfast_new(NULL);
203 game.names = eina_hash_string_superfast_new(NULL);
168 if (ecore_con_init()) 204 if (ecore_con_init())
169 { 205 {
170 if ((game.server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, game.address, game.port, &game))) 206 if ((game.server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, game.address, game.port, &game)))