aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/LuaSL/LuaSL.h23
-rw-r--r--src/LuaSL/LuaSL_compile.c15
-rw-r--r--src/LuaSL/LuaSL_main.c37
-rw-r--r--src/LuaSL/LuaSL_utilities.c60
-rwxr-xr-xsrc/LuaSL/build.lua2
-rwxr-xr-xsrc/extantz/build.lua2
-rw-r--r--src/libraries/Runnr.c34
-rw-r--r--src/libraries/Runnr.h4
-rw-r--r--src/love/love.c110
9 files changed, 150 insertions, 137 deletions
diff --git a/src/LuaSL/LuaSL.h b/src/LuaSL/LuaSL.h
index d1f448e..175cebf 100644
--- a/src/LuaSL/LuaSL.h
+++ b/src/LuaSL/LuaSL.h
@@ -8,9 +8,7 @@
8#include <Eet.h> 8#include <Eet.h>
9#include <Ecore.h> 9#include <Ecore.h>
10#include <Ecore_Con.h> 10#include <Ecore_Con.h>
11#include <Ecore_Evas.h>
12#include <Ecore_File.h> 11#include <Ecore_File.h>
13#include <Edje.h>
14#include <stdio.h> 12#include <stdio.h>
15#include <ctype.h> 13#include <ctype.h>
16 14
@@ -26,26 +24,12 @@ typedef struct _gameGlobals gameGlobals; // Define this here, so LuaSL_threads.h
26#include "LumbrJack.h" 24#include "LumbrJack.h"
27 25
28 26
29#define WIDTH (512)
30#define HEIGHT (384)
31
32
33#define TABLE_WIDTH 7
34#define TABLE_HEIGHT 42
35
36
37struct _gameGlobals 27struct _gameGlobals
38{ 28{
39 Ecore_Evas *ee; // Our window.
40 Evas *canvas; // The canvas for drawing directly onto.
41 Evas_Object *bg; // Our background edje, also the game specific stuff.
42 Evas_Object *edje; // The edje of the background.
43 Ecore_Con_Server *server; 29 Ecore_Con_Server *server;
44 Eina_Hash *scripts, *names; 30 Eina_Hash *scripts, *names;
45 int logDom;
46 const char *address; 31 const char *address;
47 int port; 32 int port;
48 boolean ui; // Wether we actually start up the UI.
49}; 33};
50 34
51struct _script 35struct _script
@@ -56,9 +40,7 @@ struct _script
56 char fileName[PATH_MAX]; 40 char fileName[PATH_MAX];
57 lua_State *L; 41 lua_State *L;
58 struct timeval startTime; 42 struct timeval startTime;
59 float compileTime, timerTime; 43 float timerTime;
60 int bugs, warnings;
61 boolean running;
62 int status; 44 int status;
63 int args; 45 int args;
64 Eina_Clist messages; 46 Eina_Clist messages;
@@ -75,8 +57,5 @@ typedef struct
75 57
76 58
77void scriptSendBack(void * data); 59void scriptSendBack(void * data);
78void sendBack(gameGlobals *ourGlobals, Ecore_Con_Client *client, const char *SID, const char *message, ...);
79void sendForth(gameGlobals *ourGlobals, const char *SID, const char *message, ...);
80float timeDiff(struct timeval *now, struct timeval *then);
81 60
82#include "LuaSL_LSL_tree.h" 61#include "LuaSL_LSL_tree.h"
diff --git a/src/LuaSL/LuaSL_compile.c b/src/LuaSL/LuaSL_compile.c
index 3265acf..0c398b9 100644
--- a/src/LuaSL/LuaSL_compile.c
+++ b/src/LuaSL/LuaSL_compile.c
@@ -1,5 +1,6 @@
1 1
2#include "LuaSL.h" 2#include "LuaSL.h"
3#include "Runnr.h"
3 4
4/* TODO - problem de jour 5/* TODO - problem de jour
5*/ 6*/
@@ -316,7 +317,6 @@ static LSL_Leaf *findVariable(LuaSL_compiler *compiler, const char *name)
316 317
317LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf *dot, LSL_Leaf *sub) 318LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf *dot, LSL_Leaf *sub)
318{ 319{
319 gameGlobals *ourGlobals = compiler->game;
320 const char *search; 320 const char *search;
321 321
322 if (dot) 322 if (dot)
@@ -358,7 +358,7 @@ LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf
358 else 358 else
359 { 359 {
360 compiler->script.bugCount++; 360 compiler->script.bugCount++;
361 sendBack(ourGlobals, compiler->client, compiler->SID, "compilerError(%d,%d,NOT found %s)", identifier->line, identifier->column, identifier->value.stringValue); 361 sendBack(compiler->client, compiler->SID, "compilerError(%d,%d,NOT found %s)", identifier->line, identifier->column, identifier->value.stringValue);
362 } 362 }
363 } 363 }
364 364
@@ -367,8 +367,6 @@ LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf
367 367
368LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right) 368LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right)
369{ 369{
370 gameGlobals *ourGlobals = compiler->game;
371
372 if (lval) 370 if (lval)
373 { 371 {
374 opType lType, rType; 372 opType lType, rType;
@@ -402,7 +400,7 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval,
402 if (OT_undeclared == lType) 400 if (OT_undeclared == lType)
403 { 401 {
404 compiler->script.warningCount++; 402 compiler->script.warningCount++;
405 sendBack(ourGlobals, compiler->client, compiler->SID, "compilerWarning(%d,%d,Undeclared identifier issue, deferring this until the second pass)", lval->line, lval->column); 403 sendBack(compiler->client, compiler->SID, "compilerWarning(%d,%d,Undeclared identifier issue, deferring this until the second pass)", lval->line, lval->column);
406 lval->basicType = OT_undeclared; 404 lval->basicType = OT_undeclared;
407 return lval; 405 return lval;
408 } 406 }
@@ -430,7 +428,7 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval,
430 if (OT_undeclared == rType) 428 if (OT_undeclared == rType)
431 { 429 {
432 compiler->script.warningCount++; 430 compiler->script.warningCount++;
433 sendBack(ourGlobals, compiler->client, compiler->SID, "compilerWarning(%d,%d,Undeclared identifier issue, deferring this until the second pass)", lval->line, lval->column); 431 sendBack(compiler->client, compiler->SID, "compilerWarning(%d,%d,Undeclared identifier issue, deferring this until the second pass)", lval->line, lval->column);
434 lval->basicType = OT_undeclared; 432 lval->basicType = OT_undeclared;
435 return lval; 433 return lval;
436 } 434 }
@@ -587,7 +585,7 @@ else
587 } 585 }
588 586
589 compiler->script.bugCount++; 587 compiler->script.bugCount++;
590 sendBack(ourGlobals, compiler->client, compiler->SID, "compilerError(%d,%d,Invalid operation [%s(%s) %s %s(%s)])", lval->line, lval->column, leftType, leftToken, lval->toKen->toKen, rightType, rightToken); 588 sendBack(compiler->client, compiler->SID, "compilerError(%d,%d,Invalid operation [%s(%s) %s %s(%s)])", lval->line, lval->column, leftType, leftToken, lval->toKen->toKen, rightType, rightToken);
591 } 589 }
592 } 590 }
593 591
@@ -991,7 +989,6 @@ LSL_Leaf *addFor(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow, LSL_L
991 989
992LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow, LSL_Leaf *left, LSL_Leaf *expr, LSL_Leaf *right, LSL_Leaf *block, LSL_Leaf *identifier) 990LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow, LSL_Leaf *left, LSL_Leaf *expr, LSL_Leaf *right, LSL_Leaf *block, LSL_Leaf *identifier)
993{ 991{
994// gameGlobals *ourGlobals = compiler->game;
995 LSL_Statement *stat = calloc(1, sizeof(LSL_Statement)); 992 LSL_Statement *stat = calloc(1, sizeof(LSL_Statement));
996 boolean justOne = FALSE; 993 boolean justOne = FALSE;
997 994
@@ -2220,7 +2217,7 @@ boolean compileLSL(gameGlobals *ourGlobals, Ecore_Con_Client *client, char *SID,
2220 call->call->basicType = func->basicType; 2217 call->call->basicType = func->basicType;
2221 } 2218 }
2222 else 2219 else
2223 sendBack(ourGlobals, compiler.client, compiler.SID, "compilerError(%d,%d,Undeclared function %s called)", call->call->line, call->call->column, call->call->value.stringValue); 2220 sendBack(compiler.client, compiler.SID, "compilerError(%d,%d,Undeclared function %s called)", call->call->line, call->call->column, call->call->value.stringValue);
2224 } 2221 }
2225 } 2222 }
2226 secondPass(&compiler, compiler.ast); 2223 secondPass(&compiler, compiler.ast);
diff --git a/src/LuaSL/LuaSL_main.c b/src/LuaSL/LuaSL_main.c
index f4c94ac..0d8a6db 100644
--- a/src/LuaSL/LuaSL_main.c
+++ b/src/LuaSL/LuaSL_main.c
@@ -1,5 +1,6 @@
1 1
2#include "LuaSL.h" 2#include "LuaSL.h"
3#include "Runnr.h"
3 4
4 5
5int logDom; // Our logging domain. 6int logDom; // Our logging domain.
@@ -110,7 +111,7 @@ void scriptSendBack(void * data)
110 else if (0 == strncmp(message->message, "llResetScript(", 14)) 111 else if (0 == strncmp(message->message, "llResetScript(", 14))
111 resetScript(message->script); 112 resetScript(message->script);
112 else 113 else
113 sendBack(ourGlobals, message->script->client, message->script->SID, message->message); 114 sendBack(message->script->client, message->script->SID, message->message);
114 free(message); 115 free(message);
115} 116}
116 117
@@ -166,10 +167,10 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_D
166 me->client = ev->client; 167 me->client = ev->client;
167 eina_hash_add(ourGlobals->scripts, me->SID, me); 168 eina_hash_add(ourGlobals->scripts, me->SID, me);
168 eina_hash_add(ourGlobals->names, me->fileName, me); 169 eina_hash_add(ourGlobals->names, me->fileName, me);
169 sendBack(ourGlobals, ev->client, SID, "compiled(true)"); 170 sendBack(ev->client, SID, "compiled(true)");
170 } 171 }
171 else 172 else
172 sendBack(ourGlobals, ev->client, SID, "compiled(false)"); 173 sendBack(ev->client, SID, "compiled(false)");
173 } 174 }
174 else if (0 == strcmp(command, "run()")) 175 else if (0 == strcmp(command, "run()"))
175 { 176 {
@@ -238,6 +239,8 @@ int main(int argc, char **argv)
238 { 239 {
239 if ((ourGlobals.server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, ourGlobals.address, ourGlobals.port, &ourGlobals))) 240 if ((ourGlobals.server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, ourGlobals.address, ourGlobals.port, &ourGlobals)))
240 { 241 {
242 int i;
243
241 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb) _add, &ourGlobals); 244 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb) _add, &ourGlobals);
242 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb) _data, &ourGlobals); 245 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb) _data, &ourGlobals);
243 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb) _del, &ourGlobals); 246 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb) _del, &ourGlobals);
@@ -247,26 +250,18 @@ int main(int argc, char **argv)
247 ecore_con_server_client_limit_set(ourGlobals.server, 3, 0); 250 ecore_con_server_client_limit_set(ourGlobals.server, 3, 0);
248 clientStream = eina_strbuf_new(); 251 clientStream = eina_strbuf_new();
249 252
250 if (edje_init()) 253 result = 0;
254 compilerSetup(&ourGlobals);
255 luaprocInit();
256 for (i = 0; i < CPUs; i++)
251 { 257 {
252 int i; 258 if ( sched_create_worker( ) != LUAPROC_SCHED_OK )
253 259 PE("Error creating luaproc worker thread.");
254 result = 0;
255 compilerSetup(&ourGlobals);
256 luaprocInit();
257 for (i = 0; i < CPUs; i++)
258 {
259 if ( sched_create_worker( ) != LUAPROC_SCHED_OK )
260 PE("Error creating luaproc worker thread.");
261 }
262 ecore_main_loop_begin();
263
264 // TODO - this is what hangs the system, should change from raw pthreads to ecore threads.
265 sched_join_workerthreads();
266 edje_shutdown();
267 } 260 }
268 else 261 ecore_main_loop_begin();
269 PC("Failed to init edje!"); 262
263 // TODO - this is what hangs the system, should change from raw pthreads to ecore threads.
264 sched_join_workerthreads();
270 } 265 }
271 else 266 else
272 PC("Failed to add server!"); 267 PC("Failed to add server!");
diff --git a/src/LuaSL/LuaSL_utilities.c b/src/LuaSL/LuaSL_utilities.c
deleted file mode 100644
index 40263df..0000000
--- a/src/LuaSL/LuaSL_utilities.c
+++ /dev/null
@@ -1,60 +0,0 @@
1#include "LuaSL.h"
2
3
4void sendBack(gameGlobals *ourGlobals, Ecore_Con_Client *client, const char *SID, const char *message, ...)
5{
6 va_list args;
7 char buf[PATH_MAX];
8 int length = strlen(SID);
9
10 strncpy(buf, SID, length);
11 buf[length++] = '.';
12 va_start(args, message);
13 length += vsprintf(&buf[length], message, args);
14 va_end(args);
15 buf[length++] = '\n';
16 buf[length++] = '\0';
17 ecore_con_client_send(client, buf, strlen(buf));
18 ecore_con_client_flush(client);
19}
20
21void sendForth(gameGlobals *ourGlobals, const char *SID, const char *message, ...)
22{
23 va_list args;
24 char buf[PATH_MAX];
25 int length = strlen(SID);
26
27 strncpy(buf, SID, length);
28 buf[length++] = '.';
29 va_start(args, message);
30 length += vsprintf(&buf[length], message, args);
31 va_end(args);
32 buf[length++] = '\n';
33 buf[length++] = '\0';
34 ecore_con_server_send(ourGlobals->server, buf, strlen(buf));
35 ecore_con_server_flush(ourGlobals->server);
36}
37
38float timeDiff(struct timeval *now, struct timeval *then)
39{
40 if (0 == gettimeofday(now, 0))
41 {
42 struct timeval thisTime = { 0, 0 };
43 double result = 0.0;
44
45 thisTime.tv_sec = now->tv_sec;
46 thisTime.tv_usec = now->tv_usec;
47 if (thisTime.tv_usec < then->tv_usec)
48 {
49 thisTime.tv_sec--;
50 thisTime.tv_usec += 1000000;
51 }
52 thisTime.tv_usec -= then->tv_usec;
53 thisTime.tv_sec -= then->tv_sec;
54 result = ((double) thisTime.tv_usec) / ((double) 1000000.0);
55 result += thisTime.tv_sec;
56 return result;
57 }
58 else
59 return 0.0;
60}
diff --git a/src/LuaSL/build.lua b/src/LuaSL/build.lua
index 0efcca3..084a39c 100755
--- a/src/LuaSL/build.lua
+++ b/src/LuaSL/build.lua
@@ -26,4 +26,4 @@ CFLAGS = CFLAGS .. ' -DPACKAGE_LIB_DIR=\\"' .. lib_d .. '\\"'
26CFLAGS = CFLAGS .. ' -DPACKAGE_DATA_DIR=\\"' .. data_d .. '\\"' 26CFLAGS = CFLAGS .. ' -DPACKAGE_DATA_DIR=\\"' .. data_d .. '\\"'
27CFLAGS = CFLAGS .. ' -DPACKAGE_LOCALE_DIR=\\"' .. locale_d .. '\\"' 27CFLAGS = CFLAGS .. ' -DPACKAGE_LOCALE_DIR=\\"' .. locale_d .. '\\"'
28 28
29compileFiles('../../LuaSL', dir, {'LuaSL_main', 'LuaSL_compile', 'LuaSL_threads', 'LuaSL_utilities', 'LuaSL_lexer', 'LuaSL_lemon_yaccer'}, '') 29compileFiles('../../LuaSL', dir, {'LuaSL_main', 'LuaSL_compile', 'LuaSL_threads', 'LuaSL_lexer', 'LuaSL_lemon_yaccer'}, '')
diff --git a/src/extantz/build.lua b/src/extantz/build.lua
index 1591e8a..caca02f 100755
--- a/src/extantz/build.lua
+++ b/src/extantz/build.lua
@@ -15,7 +15,7 @@ end
15 15
16CFLAGS = CFLAGS .. ' -I../../libraries/irrlicht-1.8.1/include -I/usr/X11R6/include -I../GuiLua' 16CFLAGS = CFLAGS .. ' -I../../libraries/irrlicht-1.8.1/include -I/usr/X11R6/include -I../GuiLua'
17LDFLAGS = LDFLAGS .. ' -L../../libraries/irrlicht-1.8.1/lib/Linux' 17LDFLAGS = LDFLAGS .. ' -L../../libraries/irrlicht-1.8.1/lib/Linux'
18libs = libs .. ' -lIrrlicht -lGL -lbz2 -lGuiLua -lwinFang -lRunnr' 18libs = libs .. ' -lIrrlicht -lGL -lbz2 -lGuiLua -lwinFang'
19 19
20removeFiles(dir, {'crappisspuke.o', 'CDemo.o', 'extantzCamera.o', 'gears.o', 'ephysics_demo.o', 'Evas_3D_demo.o', '../../media/extantz.edj'}) 20removeFiles(dir, {'crappisspuke.o', 'CDemo.o', 'extantzCamera.o', 'gears.o', 'ephysics_demo.o', 'Evas_3D_demo.o', '../../media/extantz.edj'})
21removeFiles(dir, {'../../extantz', 'camera.o', 'files.o', 'scenri.o', 'woMan.o'}) 21removeFiles(dir, {'../../extantz', 'camera.o', 'files.o', 'scenri.o', 'woMan.o'})
diff --git a/src/libraries/Runnr.c b/src/libraries/Runnr.c
index f316755..8109dd8 100644
--- a/src/libraries/Runnr.c
+++ b/src/libraries/Runnr.c
@@ -333,3 +333,37 @@ int push_lua(lua_State *L, char *params, ...) // Stack usage [-0, +n, em]
333 free(f); 333 free(f);
334 return n; 334 return n;
335} 335}
336
337void sendBack(Ecore_Con_Client *client, const char *SID, const char *message, ...)
338{
339 va_list args;
340 char buf[PATH_MAX];
341 int length = strlen(SID);
342
343 strncpy(buf, SID, length);
344 buf[length++] = '.';
345 va_start(args, message);
346 length += vsprintf(&buf[length], message, args);
347 va_end(args);
348 buf[length++] = '\n';
349 buf[length++] = '\0';
350 ecore_con_client_send(client, buf, strlen(buf));
351 ecore_con_client_flush(client);
352}
353
354void sendForth(Ecore_Con_Server *server, const char *SID, const char *message, ...)
355{
356 va_list args;
357 char buf[PATH_MAX];
358 int length = strlen(SID);
359
360 strncpy(buf, SID, length);
361 buf[length++] = '.';
362 va_start(args, message);
363 length += vsprintf(&buf[length], message, args);
364 va_end(args);
365 buf[length++] = '\n';
366 buf[length++] = '\0';
367 ecore_con_server_send(server, buf, strlen(buf));
368 ecore_con_server_flush(server);
369}
diff --git a/src/libraries/Runnr.h b/src/libraries/Runnr.h
index ac22039..d7386f6 100644
--- a/src/libraries/Runnr.h
+++ b/src/libraries/Runnr.h
@@ -4,6 +4,7 @@
4#include <ctype.h> 4#include <ctype.h>
5 5
6#include <Eina.h> 6#include <Eina.h>
7#include <Ecore_Con.h>
7 8
8#include <lua.h> 9#include <lua.h>
9#include <luajit.h> 10#include <luajit.h>
@@ -15,4 +16,7 @@ void dumpStack(lua_State *L, int i);
15int pull_lua(lua_State *L, int i, char *params, ...); 16int pull_lua(lua_State *L, int i, char *params, ...);
16int push_lua(lua_State *L, char *params, ...); 17int push_lua(lua_State *L, char *params, ...);
17 18
19void sendBack(Ecore_Con_Client *client, const char *SID, const char *message, ...);
20void sendForth(Ecore_Con_Server *server, const char *SID, const char *message, ...);
21
18#endif 22#endif
diff --git a/src/love/love.c b/src/love/love.c
index f3137b5..b0d1c05 100644
--- a/src/love/love.c
+++ b/src/love/love.c
@@ -4,8 +4,47 @@ Dedicated to my girl Boots, coz she means the world to me.
4 4
5*/ 5*/
6 6
7#include <Eet.h>
8#include <Ecore.h>
9#include <Ecore_Con.h>
10#include <Ecore_Evas.h>
11#include <Ecore_File.h>
12#include <Edje.h>
7 13
8#include "../LuaSL/LuaSL.h" 14#include "LumbrJack.h"
15#include "Runnr.h"
16
17
18#define WIDTH (512)
19#define HEIGHT (384)
20
21
22#define TABLE_WIDTH 7
23#define TABLE_HEIGHT 42
24
25
26typedef struct _gameGlobals
27{
28 Ecore_Evas *ee; // Our window.
29 Evas *canvas; // The canvas for drawing directly onto.
30 Evas_Object *bg; // Our background edje, also the game specific stuff.
31 Evas_Object *edje; // The edje of the background.
32 Ecore_Con_Server *server;
33 Eina_Hash *scripts;
34 const char *address;
35 int port;
36 boolean ui; // Wether we actually start up the UI.
37} gameGlobals;
38
39typedef struct _script
40{
41 char SID[PATH_MAX];
42 char fileName[PATH_MAX];
43 struct timeval startTime;
44 float compileTime;
45 int bugs, warnings;
46 boolean running;
47} script;
9 48
10 49
11int logDom; // Our logging domain. 50int logDom; // Our logging domain.
@@ -26,8 +65,33 @@ static const char *names[] =
26}; 65};
27 66
28 67
68static float timeDiff(struct timeval *now, struct timeval *then)
69{
70 if (0 == gettimeofday(now, 0))
71 {
72 struct timeval thisTime = { 0, 0 };
73 double result = 0.0;
74
75 thisTime.tv_sec = now->tv_sec;
76 thisTime.tv_usec = now->tv_usec;
77 if (thisTime.tv_usec < then->tv_usec)
78 {
79 thisTime.tv_sec--;
80 thisTime.tv_usec += 1000000;
81 }
82 thisTime.tv_usec -= then->tv_usec;
83 thisTime.tv_sec -= then->tv_sec;
84 result = ((double) thisTime.tv_usec) / ((double) 1000000.0);
85 result += thisTime.tv_sec;
86 return result;
87 }
88 else
89 return 0.0;
90}
91
92
29static void 93static void
30_edje_signal_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source) 94_edje_signal_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
31{ 95{
32// gameGlobals *ourGlobals = data; 96// gameGlobals *ourGlobals = data;
33} 97}
@@ -78,7 +142,7 @@ Eina_Bool anim(void *data)
78} 142}
79 143
80static void 144static void
81_on_delete(Ecore_Evas *ee __UNUSED__) 145_on_delete(Ecore_Evas *ee)
82{ 146{
83 ecore_main_loop_quit(); 147 ecore_main_loop_quit();
84} 148}
@@ -100,7 +164,7 @@ static void dirList_compile(const char *name, const char *path, void *data)
100 snprintf(me->SID, sizeof(me->SID), "%08lx-%04lx-%04lx-%04lx-%012lx", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random()); 164 snprintf(me->SID, sizeof(me->SID), "%08lx-%04lx-%04lx-%04lx-%012lx", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random());
101 snprintf(me->fileName, sizeof(me->fileName), "%s/%s", path, name); 165 snprintf(me->fileName, sizeof(me->fileName), "%s/%s", path, name);
102 eina_hash_add(ourGlobals->scripts, me->SID, me); 166 eina_hash_add(ourGlobals->scripts, me->SID, me);
103 sendForth(ourGlobals, me->SID, "compile(%s)", me->fileName); 167 sendForth(ourGlobals->server, me->SID, "compile(%s)", me->fileName);
104 } 168 }
105 } 169 }
106} 170}
@@ -119,14 +183,14 @@ static Eina_Bool _timer_cb(void *data)
119 { 183 {
120 case 5 : 184 case 5 :
121 { 185 {
122 sendForth(ourGlobals, me->SID, "events.detectedKeys({\"%s\"})", ownerKey); 186 sendForth(ourGlobals->server, me->SID, "events.detectedKeys({\"%s\"})", ownerKey);
123 sendForth(ourGlobals, me->SID, "events.detectedNames({\"%s\"})", ownerName); 187 sendForth(ourGlobals->server, me->SID, "events.detectedNames({\"%s\"})", ownerName);
124 sendForth(ourGlobals, me->SID, "events.touch_start(1)"); 188 sendForth(ourGlobals->server, me->SID, "events.touch_start(1)");
125 break; 189 break;
126 } 190 }
127 case 9 : 191 case 9 :
128 { 192 {
129 sendForth(ourGlobals, me->SID, "quit()"); 193 sendForth(ourGlobals->server, me->SID, "quit()");
130 break; 194 break;
131 } 195 }
132 case 11 : 196 case 11 :
@@ -140,14 +204,14 @@ static Eina_Bool _timer_cb(void *data)
140 204
141 if (exit) 205 if (exit)
142 { 206 {
143 sendForth(ourGlobals, ownerKey, "exit()"); 207 sendForth(ourGlobals->server, ownerKey, "exit()");
144 ecore_main_loop_quit(); 208 ecore_main_loop_quit();
145 return ECORE_CALLBACK_CANCEL; 209 return ECORE_CALLBACK_CANCEL;
146 } 210 }
147 return ECORE_CALLBACK_RENEW; 211 return ECORE_CALLBACK_RENEW;
148} 212}
149 213
150static Eina_Bool _add(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Add *ev) 214static Eina_Bool _add(void *data, int type, Ecore_Con_Event_Server_Add *ev)
151{ 215{
152 gameGlobals *ourGlobals = data; 216 gameGlobals *ourGlobals = data;
153 char buf[PATH_MAX]; 217 char buf[PATH_MAX];
@@ -161,7 +225,7 @@ static Eina_Bool _add(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Ad
161 return ECORE_CALLBACK_RENEW; 225 return ECORE_CALLBACK_RENEW;
162} 226}
163 227
164static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Data *ev) 228static Eina_Bool _data(void *data, int type, Ecore_Con_Event_Server_Data *ev)
165{ 229{
166 gameGlobals *ourGlobals = data; 230 gameGlobals *ourGlobals = data;
167 231
@@ -254,31 +318,31 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Server_D
254 PD("TOTAL compile speed is %f scripts per second", compiledCount / timeDiff(&now, &startTime)); 318 PD("TOTAL compile speed is %f scripts per second", compiledCount / timeDiff(&now, &startTime));
255 } 319 }
256// PD("The compile of %s worked, running it now.", SID); 320// PD("The compile of %s worked, running it now.", SID);
257 sendForth(ourGlobals, SID, "run()"); 321 sendForth(ourGlobals->server, SID, "run()");
258 } 322 }
259 else 323 else
260 { 324 {
261 // Send back some random or fixed values for testing. 325 // Send back some random or fixed values for testing.
262 if (0 == strcmp(command, "llGetKey()")) 326 if (0 == strcmp(command, "llGetKey()"))
263 sendForth(ourGlobals, SID, "return \"%08lx-%04lx-%04lx-%04lx-%012lx\"", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random()); 327 sendForth(ourGlobals->server, SID, "return \"%08lx-%04lx-%04lx-%04lx-%012lx\"", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random());
264 else if (0 == strcmp(command, "llGetOwner()")) 328 else if (0 == strcmp(command, "llGetOwner()"))
265 sendForth(ourGlobals, SID, "return \"%s\"", ownerKey); 329 sendForth(ourGlobals->server, SID, "return \"%s\"", ownerKey);
266 else if (0 == strcmp(command, "llGetPos()")) 330 else if (0 == strcmp(command, "llGetPos()"))
267 sendForth(ourGlobals, SID, "return {x=128.0, y=128.0, z=128.0}"); 331 sendForth(ourGlobals->server, SID, "return {x=128.0, y=128.0, z=128.0}");
268 else if (0 == strcmp(command, "llGetRot()")) 332 else if (0 == strcmp(command, "llGetRot()"))
269 sendForth(ourGlobals, SID, "return {x=0.0, y=0.0, z=0.0, s=1.0}"); 333 sendForth(ourGlobals->server, SID, "return {x=0.0, y=0.0, z=0.0, s=1.0}");
270 else if (0 == strcmp(command, "llGetObjectDesc()")) 334 else if (0 == strcmp(command, "llGetObjectDesc()"))
271 sendForth(ourGlobals, SID, "return \"\""); 335 sendForth(ourGlobals->server, SID, "return \"\"");
272 else if (0 == strncmp(command, "llGetAlpha(", 11)) 336 else if (0 == strncmp(command, "llGetAlpha(", 11))
273 sendForth(ourGlobals, SID, "return 1.0"); 337 sendForth(ourGlobals->server, SID, "return 1.0");
274 else if (0 == strcmp(command, "llGetInventoryNumber(7)")) 338 else if (0 == strcmp(command, "llGetInventoryNumber(7)"))
275 sendForth(ourGlobals, SID, "return 3"); 339 sendForth(ourGlobals->server, SID, "return 3");
276 else if (0 == strcmp(command, "llGetInventoryName(7, 2)")) 340 else if (0 == strcmp(command, "llGetInventoryName(7, 2)"))
277 sendForth(ourGlobals, SID, "return \".readme\""); 341 sendForth(ourGlobals->server, SID, "return \".readme\"");
278 else if (0 == strcmp(command, "llGetInventoryName(7, 1)")) 342 else if (0 == strcmp(command, "llGetInventoryName(7, 1)"))
279 sendForth(ourGlobals, SID, "return \".POSITIONS\""); 343 sendForth(ourGlobals->server, SID, "return \".POSITIONS\"");
280 else if (0 == strcmp(command, "llGetInventoryName(7, 0)")) 344 else if (0 == strcmp(command, "llGetInventoryName(7, 0)"))
281 sendForth(ourGlobals, SID, "return \".MENUITEMS\""); 345 sendForth(ourGlobals->server, SID, "return \".MENUITEMS\"");
282 else 346 else
283 PI("Script %s sent command %s", SID, command); 347 PI("Script %s sent command %s", SID, command);
284 } 348 }
@@ -291,7 +355,7 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Server_D
291 return ECORE_CALLBACK_RENEW; 355 return ECORE_CALLBACK_RENEW;
292} 356}
293 357
294static Eina_Bool _del(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Del *ev) 358static Eina_Bool _del(void *data, int type, Ecore_Con_Event_Server_Del *ev)
295{ 359{
296 gameGlobals *ourGlobals = data; 360 gameGlobals *ourGlobals = data;
297 361