From 38ee330c93c59947f6a4486f72b30907d472934b Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 17 Mar 2013 18:11:58 +0000 Subject: [PATCH] Lunatic translator embedded: handle command line arguments. Also, fix an error() call in control.lua:gamearray_file_common(). git-svn-id: https://svn.eduke32.com/eduke32@3572 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/game.c | 16 ++++++++++++++++ polymer/eduke32/source/lunatic/control.lua | 2 +- polymer/eduke32/source/lunatic/defs.ilua | 1 + polymer/eduke32/source/lunatic/defs_common.lua | 1 + polymer/eduke32/source/lunatic/dynsymlist | 1 + polymer/eduke32/source/lunatic/lunacon.lua | 6 ++++++ 6 files changed, 26 insertions(+), 1 deletion(-) diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 84b533422..4c4008727 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -8686,12 +8686,20 @@ static int32_t loaddefinitions_game(const char *fn, int32_t preload) return 0; } +#ifdef LUNATIC +// TODO: In Windows, argv[argc] isn't NULL as demanded by C99. (See winlayer.c: +// "carve up..."). +const char **g_argv; +#endif static void G_CheckCommandLine(int32_t argc, const char **argv) { int16_t i = 1, j; const char *c, *k; +#ifdef LUNATIC + g_argv = argv; +#endif ud.fta_on = 1; ud.god = 0; ud.m_respawn_items = 0; @@ -9107,6 +9115,10 @@ static void G_CheckCommandLine(int32_t argc, const char **argv) } break; } +#ifdef LUNATIC + case 'f': + break; +#endif case 'g': c++; if (*c) @@ -9256,6 +9268,10 @@ static void G_CheckCommandLine(int32_t argc, const char **argv) case 'w': ud.coords = 1; break; +#ifdef LUNATIC + case 'W': + break; +#endif case 'x': c++; if (*c) diff --git a/polymer/eduke32/source/lunatic/control.lua b/polymer/eduke32/source/lunatic/control.lua index b92946613..6e916cd71 100644 --- a/polymer/eduke32/source/lunatic/control.lua +++ b/polymer/eduke32/source/lunatic/control.lua @@ -1656,7 +1656,7 @@ local function gamearray_file_common(qnum, writep) local f, errmsg = io.open(fn); if (f == nil) then if (not writep) then - error([[failed opening "%s" for reading: %s]], fn, errmsg, 3) + error(format([[failed opening "%s" for reading: %s]], fn, errmsg), 3) else return nil, nil, true, fn end diff --git a/polymer/eduke32/source/lunatic/defs.ilua b/polymer/eduke32/source/lunatic/defs.ilua index 78133cf20..e3d45a036 100644 --- a/polymer/eduke32/source/lunatic/defs.ilua +++ b/polymer/eduke32/source/lunatic/defs.ilua @@ -524,6 +524,7 @@ const char *g_sizes_of_what[]; int32_t g_sizes_of[]; int32_t g_elCallDepth; int32_t g_elEventRETURN; +const char **g_argv; char g_modDir[]; actor_t actor[MAXSPRITES]; camera_t g_camera; diff --git a/polymer/eduke32/source/lunatic/defs_common.lua b/polymer/eduke32/source/lunatic/defs_common.lua index 024199f07..edcdf2b92 100644 --- a/polymer/eduke32/source/lunatic/defs_common.lua +++ b/polymer/eduke32/source/lunatic/defs_common.lua @@ -498,6 +498,7 @@ local spritetype_mt = { end, _set_owner = function(s, owner) + -- XXX: AMC TC sets owner to -1 in the cutscene. check_sprite_idx(owner) ffi.cast(spritetype_ptr_ct, s).owner = owner end, diff --git a/polymer/eduke32/source/lunatic/dynsymlist b/polymer/eduke32/source/lunatic/dynsymlist index 7a76e9b39..10c040677 100644 --- a/polymer/eduke32/source/lunatic/dynsymlist +++ b/polymer/eduke32/source/lunatic/dynsymlist @@ -74,6 +74,7 @@ g_sizes_of_what; g_sizes_of; g_elCallDepth; g_elEventRETURN; +g_argv; g_modDir; kopen4loadfrommod; diff --git a/polymer/eduke32/source/lunatic/lunacon.lua b/polymer/eduke32/source/lunatic/lunacon.lua index b6adce38b..23c378cd1 100644 --- a/polymer/eduke32/source/lunatic/lunacon.lua +++ b/polymer/eduke32/source/lunatic/lunacon.lua @@ -3278,6 +3278,12 @@ if (string.dump) then end end else + local i=0 + while (ffiC.g_argv[i] ~= nil) do + handle_cmdline_arg(ffi.string(ffiC.g_argv[i])) + i = i+1 + end + -- running from EDuke32 function compile(filenames) -- TODO: pathsearchmode=1 set in G_CompileScripts