aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-02-23 20:42:57 +1000
committerDavid Walter Seikel2012-02-23 20:42:57 +1000
commit1c95a0d19012e3624a382dec89a2cb1694fdba69 (patch)
treed70695709984f1d09b20dc81223ccddbc7185735 /LuaSL
parentMore white space, and comment out some implemented functions. (diff)
downloadSledjHamr-1c95a0d19012e3624a382dec89a2cb1694fdba69.zip
SledjHamr-1c95a0d19012e3624a382dec89a2cb1694fdba69.tar.gz
SledjHamr-1c95a0d19012e3624a382dec89a2cb1694fdba69.tar.bz2
SledjHamr-1c95a0d19012e3624a382dec89a2cb1694fdba69.tar.xz
Change the quit timer into a more general purpose timed events timer, for more testing.
Diffstat (limited to 'LuaSL')
-rw-r--r--LuaSL/src/LuaSL_test.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/LuaSL/src/LuaSL_test.c b/LuaSL/src/LuaSL_test.c
index c8512b3..b29d6c3 100644
--- a/LuaSL/src/LuaSL_test.c
+++ b/LuaSL/src/LuaSL_test.c
@@ -7,6 +7,9 @@ static int scriptCount = 0;
7static int compiledCount = 0; 7static int compiledCount = 0;
8static float compileTime = 0.0; 8static float compileTime = 0.0;
9static struct timeval startTime; 9static struct timeval startTime;
10static int timedEvent = 0;
11static char *ownerKey = "12345678-1234-4321-abcd-0123456789ab";
12static char *ownerName = "onefang rejected";
10 13
11static const char *names[] = 14static const char *names[] =
12{ 15{
@@ -95,23 +98,47 @@ static void dirList_compile(const char *name, const char *path, void *data)
95 } 98 }
96} 99}
97 100
98static Eina_Bool _quit_timer_cb(void *data) 101static Eina_Bool _timer_cb(void *data)
99{ 102{
100 gameGlobals *game = data; 103 gameGlobals *game = data;
101 Eina_Iterator *scripts; 104 Eina_Iterator *scripts;
102 script *me; 105 script *me;
106 boolean exit = FALSE;
103 107
104 scripts = eina_hash_iterator_data_new(game->scripts); 108 scripts = eina_hash_iterator_data_new(game->scripts);
105 while(eina_iterator_next(scripts, (void **) &me)) 109 while(eina_iterator_next(scripts, (void **) &me))
106 { 110 {
107 sendForth(game, me->SID, "quit()"); 111 switch (timedEvent)
112 {
113 case 5 :
114 {
115 // TODO - do it as one line, coz sendToChannel() locks up if I do them one at a time too quickly.
116 sendForth(game, me->SID, "events.detectedKeys({\"%s\"}); events.detectedNames({\"%s\"}); events.touch_start(1)", ownerKey, ownerName);
117// sendForth(game, me->SID, "events.detectedNames({\"%s\"})", ownerName);
118// sendForth(game, me->SID, "events.touch_start(1)");
119 break;
120 }
121 case 7 :
122 {
123 sendForth(game, me->SID, "quit()");
124 break;
125 }
126 case 9 :
127 {
128 exit = TRUE;
129 break;
130 }
131 }
108 } 132 }
133 timedEvent++;
109 134
110 ecore_con_server_send(game->server, ".exit()\n", 8); 135 if (exit)
111 ecore_con_server_flush(game->server); 136 {
112 ecore_main_loop_quit(); 137 sendForth(game, ownerKey, "exit()");
113 138 ecore_main_loop_quit();
114 return ECORE_CALLBACK_CANCEL; 139 return ECORE_CALLBACK_CANCEL;
140 }
141 return ECORE_CALLBACK_RENEW;
115} 142}
116 143
117static Eina_Bool _add(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Add *ev) 144static Eina_Bool _add(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Add *ev)
@@ -123,8 +150,8 @@ static Eina_Bool _add(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Ad
123 gettimeofday(&startTime, NULL); 150 gettimeofday(&startTime, NULL);
124 snprintf(buf, sizeof(buf), "%s/Test sim/objects", PACKAGE_DATA_DIR); 151 snprintf(buf, sizeof(buf), "%s/Test sim/objects", PACKAGE_DATA_DIR);
125 eina_file_dir_list(buf, EINA_TRUE, dirList_compile, game); 152 eina_file_dir_list(buf, EINA_TRUE, dirList_compile, game);
126 // Wait awhile, then quit all scripts we started, for testing. 153 // Wait awhile, then start sending events for testing.
127 ecore_timer_add(4.0, _quit_timer_cb, game); 154 ecore_timer_add(0.5, _timer_cb, game);
128 return ECORE_CALLBACK_RENEW; 155 return ECORE_CALLBACK_RENEW;
129} 156}
130 157