diff options
author | David Walter Seikel | 2014-05-20 23:34:25 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-05-20 23:34:25 +1000 |
commit | 909fd6e2c4369020707782e20656069fbb3030d1 (patch) | |
tree | 15590f94950be42916fff1b3ba00124bce157751 /src/LuaSL/LuaSL_main.c | |
parent | The results of a session with valgrind. (diff) | |
download | SledjHamr-909fd6e2c4369020707782e20656069fbb3030d1.zip SledjHamr-909fd6e2c4369020707782e20656069fbb3030d1.tar.gz SledjHamr-909fd6e2c4369020707782e20656069fbb3030d1.tar.bz2 SledjHamr-909fd6e2c4369020707782e20656069fbb3030d1.tar.xz |
Found a way to deal with the PACKAGE_* stuff outside of Elm. It's undocumented.
Diffstat (limited to '')
-rw-r--r-- | src/LuaSL/LuaSL_main.c | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/src/LuaSL/LuaSL_main.c b/src/LuaSL/LuaSL_main.c index 32ed090..2c40348 100644 --- a/src/LuaSL/LuaSL_main.c +++ b/src/LuaSL/LuaSL_main.c | |||
@@ -4,7 +4,7 @@ | |||
4 | #include "SledjHamr.h" | 4 | #include "SledjHamr.h" |
5 | 5 | ||
6 | 6 | ||
7 | int logDom; // Our logging domain. | 7 | int logDom = -1; // Our logging domain. |
8 | static int CPUs = 4; | 8 | static int CPUs = 4; |
9 | static Eina_Strbuf *clientStream; | 9 | static Eina_Strbuf *clientStream; |
10 | 10 | ||
@@ -61,7 +61,7 @@ static void resetScript(script *victim) | |||
61 | gettimeofday(&me->startTime, NULL); | 61 | gettimeofday(&me->startTime, NULL); |
62 | strncpy(me->SID, victim->SID, sizeof(me->SID)); | 62 | strncpy(me->SID, victim->SID, sizeof(me->SID)); |
63 | strncpy(me->fileName, victim->fileName, sizeof(me->fileName)); | 63 | strncpy(me->fileName, victim->fileName, sizeof(me->fileName)); |
64 | me->name = &me->fileName[sizeof(PACKAGE_DATA_DIR)]; | 64 | me->name = &me->fileName[strlen(prefix_data_get())]; |
65 | me->game = ourGlobals; | 65 | me->game = ourGlobals; |
66 | me->client = victim->client; | 66 | me->client = victim->client; |
67 | eina_hash_add(ourGlobals->scripts, me->SID, me); | 67 | eina_hash_add(ourGlobals->scripts, me->SID, me); |
@@ -205,7 +205,7 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_D | |||
205 | temp++; | 205 | temp++; |
206 | temp[0] = '\0'; | 206 | temp[0] = '\0'; |
207 | 207 | ||
208 | name = &file[sizeof(PACKAGE_DATA_DIR)]; | 208 | name = &file[strlen(prefix_data_get())]; |
209 | PD("Compiling %s, %s.", SID, name); | 209 | PD("Compiling %s, %s.", SID, name); |
210 | if (compileLSL(ourGlobals, ev->client, SID, file, FALSE)) | 210 | if (compileLSL(ourGlobals, ev->client, SID, file, FALSE)) |
211 | { | 211 | { |
@@ -214,7 +214,7 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_D | |||
214 | gettimeofday(&me->startTime, NULL); | 214 | gettimeofday(&me->startTime, NULL); |
215 | strncpy(me->SID, SID, sizeof(me->SID)); | 215 | strncpy(me->SID, SID, sizeof(me->SID)); |
216 | strncpy(me->fileName, file, sizeof(me->fileName)); | 216 | strncpy(me->fileName, file, sizeof(me->fileName)); |
217 | me->name = &me->fileName[sizeof(PACKAGE_DATA_DIR)]; | 217 | me->name = &me->fileName[strlen(prefix_data_get())]; |
218 | me->game = ourGlobals; | 218 | me->game = ourGlobals; |
219 | me->client = ev->client; | 219 | me->client = ev->client; |
220 | eina_hash_add(ourGlobals->scripts, me->SID, me); | 220 | eina_hash_add(ourGlobals->scripts, me->SID, me); |
@@ -275,30 +275,15 @@ static Eina_Bool _del(void *data, int type __UNUSED__, Ecore_Con_Event_Client_De | |||
275 | int main(int argc, char **argv) | 275 | int main(int argc, char **argv) |
276 | { | 276 | { |
277 | gameGlobals ourGlobals; | 277 | gameGlobals ourGlobals; |
278 | char *env, cwd[PATH_MAX], temp[PATH_MAX * 2]; | ||
279 | int result = EXIT_FAILURE; | 278 | int result = EXIT_FAILURE; |
280 | 279 | ||
281 | // Sigh, Elm has this great thing for dealing with bin, lib, and data directories, but this is not an Elm app, | ||
282 | // And Elm is too heavy for just that little bit. | ||
283 | // So just duplicate a bit of what we need here. Sorta. | ||
284 | getcwd(cwd, PATH_MAX); | ||
285 | env = getenv("LUA_CPATH"); | ||
286 | if (!env) env = ""; | ||
287 | sprintf(temp, "%s;%s/lib?.so;%s/?.so;%s/?.so", env, PACKAGE_LIB_DIR, PACKAGE_LIB_DIR, cwd); | ||
288 | setenv("LUA_CPATH", temp, 1); | ||
289 | |||
290 | env = getenv("LUA_PATH"); | ||
291 | if (!env) env = ""; | ||
292 | sprintf(temp, "%s;%s/?.lua;%s/?.lua", env, PACKAGE_LIB_DIR, cwd); | ||
293 | setenv("LUA_PATH", temp, 1); | ||
294 | |||
295 | memset(&ourGlobals, 0, sizeof(gameGlobals)); | 280 | memset(&ourGlobals, 0, sizeof(gameGlobals)); |
296 | ourGlobals.address = "127.0.0.1"; | 281 | ourGlobals.address = "127.0.0.1"; |
297 | ourGlobals.port = 8211; | 282 | ourGlobals.port = 8211; |
298 | 283 | ||
299 | if (eina_init()) | 284 | if (eina_init()) |
300 | { | 285 | { |
301 | logDom = loggingStartup("LuaSL", logDom); | 286 | logDom = HamrTime(argv[0], main, logDom); |
302 | ourGlobals.scripts = eina_hash_string_superfast_new(NULL); | 287 | ourGlobals.scripts = eina_hash_string_superfast_new(NULL); |
303 | ourGlobals.names = eina_hash_string_superfast_new(NULL); | 288 | ourGlobals.names = eina_hash_string_superfast_new(NULL); |
304 | if (ecore_init()) | 289 | if (ecore_init()) |
@@ -356,6 +341,7 @@ int main(int argc, char **argv) | |||
356 | } | 341 | } |
357 | else | 342 | else |
358 | PC("Failed to init ecore!"); | 343 | PC("Failed to init ecore!"); |
344 | pantsOff(logDom); | ||
359 | } | 345 | } |
360 | else | 346 | else |
361 | fprintf(stderr, "Failed to init eina!"); | 347 | fprintf(stderr, "Failed to init eina!"); |