diff --git a/polymer/eduke32/source/demo.c b/polymer/eduke32/source/demo.c index 036cfdc5a..c5bb43936 100644 --- a/polymer/eduke32/source/demo.c +++ b/polymer/eduke32/source/demo.c @@ -153,7 +153,7 @@ void G_OpenDemoWrite(void) ud.recstat = ud.m_recstat = 0; return; } - +#if !defined LUNATIC if (demorec_diffs_cvar && !demorec_force_cvar) for (i=1; i>1, NULL }; hashtable_t h_arrays = { MAXGAMEARRAYS>>1, NULL }; hashtable_t h_labels = { 11264>>1, NULL }; -#if !defined LUNATIC static hashtable_t h_keywords = { CON_END>>1, NULL }; static hashtable_t sectorH = { SECTOR_END>>1, NULL }; @@ -6288,11 +6292,9 @@ void C_Compile(const char *filenam) C_InitQuotes(); } } -#endif // !defined LUNATIC void C_ReportError(int32_t iError) { -#if !defined LUNATIC if (Bstrcmp(g_szCurrentBlockName,g_szLastBlockName)) { if (g_parsingEventPtr || g_processingState || g_parsingActorPtr) @@ -6381,5 +6383,5 @@ void C_ReportError(int32_t iError) initprintf("%s:%d: warning: symbol `%s' already used for game variable.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); break; } -#endif } +#endif diff --git a/polymer/eduke32/source/gamedef.h b/polymer/eduke32/source/gamedef.h index ecb27a579..45a1d62ff 100644 --- a/polymer/eduke32/source/gamedef.h +++ b/polymer/eduke32/source/gamedef.h @@ -33,13 +33,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define MAXCHEATLEN 20 #define NUMCHEATCODES (int32_t)(sizeof(CheatStrings)/sizeof(CheatStrings[0])) +extern hashtable_t h_gamefuncs; + +#if !defined LUNATIC extern hashtable_t h_gamevars; extern hashtable_t h_arrays; -//extern hashtable_t h_keywords; -extern hashtable_t h_gamefuncs; extern hashtable_t h_labels; - extern int32_t g_iReturnVarID; // var ID of "RETURN" extern int32_t g_iWeaponVarID; // var ID of "WEAPON" extern int32_t g_iWorksLikeVarID; // var ID of "WORKSLIKE" @@ -57,6 +57,7 @@ extern int32_t g_iPlayerVarID; extern int32_t g_iActorVarID; extern intptr_t *apScriptGameEvent[MAXGAMEEVENTS]; +#endif extern int32_t otherp; extern int32_t lastvisinc; @@ -68,6 +69,9 @@ extern int32_t g_scriptVersion; extern uint32_t g_scriptDateVersion; // YYYYMMDD extern char g_szBuf[1024]; +extern const char *EventNames[]; // MAXEVENTS + +#if !defined LUNATIC extern intptr_t *g_scriptPtr; typedef struct @@ -78,7 +82,6 @@ typedef struct int32_t maxParm2; } memberlabel_t; -extern const char *EventNames[]; // MAXEVENTS extern const memberlabel_t SectorLabels[]; extern const memberlabel_t WallLabels[]; extern const memberlabel_t ActorLabels[]; @@ -87,28 +90,11 @@ extern const memberlabel_t ProjectileLabels[]; extern const memberlabel_t userdeflabels[]; extern const memberlabel_t InputLabels[]; extern const memberlabel_t TsprLabels[]; +#endif int32_t C_AllocQuote(int32_t qnum); void C_InitQuotes(void); -void C_ReportError(int32_t iError); -#if !defined LUNATIC -void C_Compile(const char *filenam); -#endif - -/* -extern void VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t lVar2); -extern void VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, int32_t lLabelID, int32_t lVar2); -extern void VM_AccessPlayer(int32_t iSet, int32_t lVar1, int32_t lLabelID, int32_t lVar2, int32_t lParm2); -extern void VM_AccessPlayerInput(int32_t iSet, int32_t lVar1, int32_t lLabelID, int32_t lVar2); -extern void VM_AccessWall(int32_t iSet, int32_t lVar1, int32_t lLabelID, int32_t lVar2); -extern void VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLabelID, int32_t lVar2); -extern void VM_AccessSprite(int32_t iSet, int32_t lVar1, int32_t lLabelID, int32_t lVar2, int32_t lParm2); -extern void VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLabelID, int32_t lVar2); -extern void VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t lLabelID, int32_t lVar2); -*/ - - typedef struct { int32_t g_i, g_p, g_x; int32_t *g_t; @@ -118,6 +104,10 @@ typedef struct { extern vmstate_t vm; +#if !defined LUNATIC +void C_ReportError(int32_t iError); +void C_Compile(const char *filenam); + extern int32_t g_errorLineNum; extern int32_t g_tw; extern const char *keyw[]; @@ -946,3 +936,6 @@ enum ScriptKeywords_t CON_END }; #endif + + +#endif diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 1d9809cf5..a06e840a6 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -5388,7 +5388,7 @@ void G_SaveMapState(mapstate_t *save) Bmemcpy(&save->lockclock,&lockclock,sizeof(lockclock)); Bmemcpy(&save->randomseed,&randomseed,sizeof(randomseed)); Bmemcpy(&save->g_globalRandom,&g_globalRandom,sizeof(g_globalRandom)); - +#if !defined LUNATIC for (i=g_gameVarCount-1; i>=0; i--) { if (aGameVars[i].dwFlags & GAMEVAR_NORESET) continue; @@ -5406,7 +5406,7 @@ void G_SaveMapState(mapstate_t *save) } else save->vars[i] = (intptr_t *)aGameVars[i].val.lValue; } - +#endif ototalclock = totalclock; } } diff --git a/polymer/eduke32/source/gamevars.c b/polymer/eduke32/source/gamevars.c index 49d9c825f..b976acf5b 100644 --- a/polymer/eduke32/source/gamevars.c +++ b/polymer/eduke32/source/gamevars.c @@ -1069,8 +1069,7 @@ void Gv_ResetSystemDefaults(void) aplWeaponFlashColor[i][j]=Gv_GetVarByLabel(aszBuf,0, -1, j); } } -#endif -#if !defined LUNATIC + g_iReturnVarID=Gv_GetVarIndex("RETURN"); g_iWeaponVarID=Gv_GetVarIndex("WEAPON"); g_iWorksLikeVarID=Gv_GetVarIndex("WORKSLIKE"); diff --git a/polymer/eduke32/source/gamevars.h b/polymer/eduke32/source/gamevars.h index 77217b527..a7ecb56e4 100644 --- a/polymer/eduke32/source/gamevars.h +++ b/polymer/eduke32/source/gamevars.h @@ -48,6 +48,8 @@ enum GamevarFlags_t { GAMEVAR_NOMULTI = 0x00080000, // don't attach to multiplayer packets }; +#if !defined LUNATIC + #define MAXGAMEARRAYS (MAXGAMEVARS>>2) // must be lower than MAXGAMEVARS #define MAXARRAYLABEL MAXVARLABEL @@ -94,15 +96,11 @@ extern gamearray_t aGameArrays[MAXGAMEARRAYS]; extern int32_t g_gameVarCount; extern int32_t g_gameArrayCount; -#if defined LUNATIC -# define Gv_GetVar(id, iActor, iPlayer) 0 // (OSD_Printf("Gv_GetVar @ %s:%d\n", __FILE__, __LINE__), 0) -# define Gv_SetVar(id, lValue, iActor, iPlayer) do{}while(0) //OSD_Printf("Gv_SetVar @ %s:%d\n", __FILE__, __LINE__) -#else int32_t __fastcall Gv_GetVar(register int32_t id,register int32_t iActor,register int32_t iPlayer); void __fastcall Gv_SetVar(register int32_t id,register int32_t lValue,register int32_t iActor,register int32_t iPlayer); -#endif int32_t __fastcall Gv_GetVarX(register int32_t id); void __fastcall Gv_SetVarX(register int32_t id,register int32_t lValue); +#endif #ifdef LUNATIC # define Gv_GetVarByLabel(szGameLabel, lDefault, iActor, iPlayer) (lDefault) @@ -122,6 +120,7 @@ int32_t Gv_ReadSave(int32_t fil,int32_t newbehav); void Gv_Init(void); void Gv_WriteSave(FILE *fil,int32_t newbehav); +#if !defined LUNATIC #define GV_VAROP(func, operator) static inline void __fastcall func(register int32_t id, register int32_t lValue) \ { \ switch (aGameVars[id].dwFlags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK)) \ @@ -157,5 +156,6 @@ GV_VAROP(Gv_ModVar, %=) GV_VAROP(Gv_AndVar, &=) GV_VAROP(Gv_XorVar, ^=) GV_VAROP(Gv_OrVar, |=) +#endif #endif diff --git a/polymer/eduke32/source/lunatic/defs.ilua b/polymer/eduke32/source/lunatic/defs.ilua index 945b0de86..07aa8cfd6 100644 --- a/polymer/eduke32/source/lunatic/defs.ilua +++ b/polymer/eduke32/source/lunatic/defs.ilua @@ -1312,10 +1312,6 @@ setmtonce(gv, tmpmt) -- This will create 'sprite', 'wall', etc. HERE, i.e. in the environment of this chunk defs_c.create_globals(_G) -function TEMP_getvollev() -- REMOVE - return ffiC.ud.volume_number+1, ffiC.ud.level_number+1 -end - ---=== Game variables ===--- diff --git a/polymer/eduke32/source/lunatic/lunacon.lua b/polymer/eduke32/source/lunatic/lunacon.lua index 5c1c73908..222d2ef8d 100644 --- a/polymer/eduke32/source/lunatic/lunacon.lua +++ b/polymer/eduke32/source/lunatic/lunacon.lua @@ -202,6 +202,12 @@ local function new_initial_gvartab() STICKYBOMB_LIFETIME = RW(PLS".tripbombLifetime"), STICKYBOMB_LIFETIME_VAR = RW(PLS".tripbombLifetimeVar"), + -- These are not 100% authentic (they're only updated in certain + -- circumstances, see player.c: P_SetWeaponGamevars()). But IMO it's + -- more useful like this. + WEAPON = RO(PLS".curr_weapon"), + WORKSLIKE = RO(format(PLS".weapon[%s].workslike", PLS".curr_weapon")), + VOLUME = RO "_gv.currentEpisode()", LEVEL = RO "_gv.currentLevel()", } diff --git a/polymer/eduke32/source/lunatic/test.elua b/polymer/eduke32/source/lunatic/test.elua index da9ae6dec..f33eec21d 100644 --- a/polymer/eduke32/source/lunatic/test.elua +++ b/polymer/eduke32/source/lunatic/test.elua @@ -64,9 +64,8 @@ for i = 0, gv.numsectors/2 do sector[i].ceilingpal = 2; end -local vol, lev -vol, lev = TEMP_getvollev() -print('volume='..vol..', level='..lev) +local vol, lev = gv.currentEpisode()+1, gv.currentLevel()+1 +printf('volume=%d, level=%d', vol, lev) if (vol==1 and lev==1) then -- E1L1 print('tweaking some sprites 2') @@ -203,10 +202,14 @@ gameevent(gv.EVENT_JUMP, -- test event chaining gameevent("JUMP", function(actori, playeri, dist) + local ps = player[playeri] print("I'm first!") -- DBG_.oom() - player[playeri].weapon.PISTOL.shoots = 2605 -- RPG - player[playeri].weapon[gv.PISTOL_WEAPON].firesound = 351 -- thunder + ps.weapon.PISTOL.shoots = 2605 -- RPG + ps.weapon[gv.PISTOL_WEAPON].firesound = 351 -- thunder + + ps.pipebombControl = 2 + ps.tripbombControl = 2 end ) diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index 04139b3d3..11daecb26 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -533,6 +533,7 @@ static int32_t osdcmd_spawn(const osdfuncparm_t *parm) return OSDCMD_OK; } +#if !defined LUNATIC static int32_t osdcmd_setvar(const osdfuncparm_t *parm) { int32_t i, varval; @@ -612,6 +613,7 @@ static int32_t osdcmd_setactorvar(const osdfuncparm_t *parm) Gv_SetVar(i, varval, ID, -1); return OSDCMD_OK; } +#endif static int32_t osdcmd_addpath(const osdfuncparm_t *parm) { @@ -1595,11 +1597,12 @@ int32_t registerosdcommands(void) OSD_RegisterFunction("restartsound","restartsound: reinitializes the sound system",osdcmd_restartsound); OSD_RegisterFunction("restartvid","restartvid: reinitializes the video mode",osdcmd_restartvid); - +#if !defined LUNATIC OSD_RegisterFunction("addlogvar","addlogvar : prints the value of a gamevar", osdcmd_addlogvar); OSD_RegisterFunction("setvar","setvar : sets the value of a gamevar", osdcmd_setvar); OSD_RegisterFunction("setvarvar","setvarvar : sets the value of to ", osdcmd_setvar); OSD_RegisterFunction("setactorvar","setactorvar : sets the value of 's to ", osdcmd_setactorvar); +#endif OSD_RegisterFunction("screenshot","screenshot: takes a screenshot. See r_scrcaptureformat.", osdcmd_screenshot); OSD_RegisterFunction("spawn","spawn [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",osdcmd_spawn); diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index 4dc90ecf4..b601c1aea 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -39,6 +39,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifdef LUNATIC # include "lunatic_game.h" + +int32_t g_testLua = 0; #endif static int32_t g_whichPalForPlayer = 9; @@ -1373,17 +1375,20 @@ static inline void prelevel(char g) } } -#if 0 //def LUNATIC - if (L_IsInitialized(&g_ElState)) +#ifdef LUNATIC + if (g_testLua) { - i = L_RunOnce(&g_ElState, "test.elua"); - if (i) - OSD_Printf(OSD_ERROR "Error running the test ELua script (code %d)\n", i); + if (L_IsInitialized(&g_ElState)) + { + i = L_RunOnce(&g_ElState, "test.elua"); + if (i) + OSD_Printf(OSD_ERROR "Error running the test ELua script (code %d)\n", i); + else + initprintf("ELua test script run ok!\n"); + } else - initprintf("ELua test script run ok!\n"); + initprintf("ELua test script: not inited!\n"); } - else - initprintf("ELua test script: not inited!\n"); #endif } @@ -2051,7 +2056,7 @@ int32_t G_EnterLevel(int32_t g) void G_FreeMapState(int32_t mapnum) { int32_t j; - +#if !defined LUNATIC for (j=0; jvars[j]); } } +#endif Bfree(MapInfo[mapnum].savedstate); MapInfo[mapnum].savedstate = NULL; } diff --git a/polymer/eduke32/source/savegame.c b/polymer/eduke32/source/savegame.c index 73d3caa1d..cb06fd0c4 100644 --- a/polymer/eduke32/source/savegame.c +++ b/polymer/eduke32/source/savegame.c @@ -1045,6 +1045,7 @@ static uint8_t *svdiff; // setup gamevar data spec for snapshotting and diffing... gamevars must be loaded when called static void sv_makevarspec() { +#if !defined LUNATIC static char *magic = "blK:vars"; int32_t i, j, numsavedvars=0, per; @@ -1085,6 +1086,7 @@ static void sv_makevarspec() } svgm_vars[j].flags = DS_END; +#endif } void sv_freemem()