Lunatic: compile out more code with LUNATIC_ONLY.

git-svn-id: https://svn.eduke32.com/eduke32@3354 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-01-01 15:24:18 +00:00
parent 37d8cda701
commit fd390efe2a
8 changed files with 66 additions and 28 deletions

View file

@ -3912,7 +3912,7 @@ static void G_DumpDebugInfo(void)
}
OSD_Printf("\n");
}
#endif
for (x=0; x<MAXSTATUS; x++)
{
j = headspritestat[x];
@ -3947,6 +3947,7 @@ static void G_DumpDebugInfo(void)
}
Gv_DumpValues();
// fclose(fp);
#endif
saveboard("debug.map", &g_player[myconnectindex].ps->pos, g_player[myconnectindex].ps->ang,
g_player[myconnectindex].ps->cursectnum);
}
@ -4057,9 +4058,9 @@ int32_t A_InsertSprite(int32_t whatsect,int32_t s_x,int32_t s_y,int32_t s_z,int3
Bmemset(&spriteext[i], 0, sizeof(spriteext_t));
Bmemset(&spritesmooth[i], 0, sizeof(spritesmooth_t));
#if !defined LUNATIC_ONLY
A_ResetVars(i);
#endif
if (G_HaveEvent(EVENT_EGS))
{
int32_t pl=A_FindPlayer(s, &p);
@ -9544,7 +9545,9 @@ static void G_CompileScripts(void)
if (g_scriptNamePtr != NULL)
Bcorrectfilename(g_scriptNamePtr,0);
#if !defined LUNATIC_ONLY
#if defined LUNATIC_ONLY
Gv_Init();
#else
// if we compile for a V7 engine wall[] should be used for label names since it's bigger
pathsearchmode = 1;

View file

@ -178,6 +178,7 @@ enum
LABEL_MOVE = 32,
};
#if !defined LUNATIC_ONLY
static const char *C_GetLabelType(int32_t type)
{
int32_t i;
@ -572,6 +573,7 @@ const char *keyw[] =
"showviewunbiased", // 363
"<null>"
};
#endif
// KEEPINSYNC with enum GameEvent_t and lunatic/con_lang.lua
const char *EventNames[MAXEVENTS] =
@ -673,6 +675,7 @@ const char *EventNames[MAXEVENTS] =
"EVENT_CHANGEMENU"
};
#if !defined LUNATIC_ONLY
const memberlabel_t SectorLabels[]=
{
{ "wallptr", SECTOR_WALLPTR, 0, 0 },
@ -1136,12 +1139,16 @@ const memberlabel_t InputLabels[]=
{ "", -1, 0, 0 } // END OF LIST
};
#endif
char *bitptr; // pointer to bitmap of which bytecode positions contain pointers
#define BITPTR_POINTER 1
hashtable_t h_gamevars = { MAXGAMEVARS>>1, NULL };
hashtable_t h_arrays = { MAXGAMEARRAYS>>1, NULL };
hashtable_t h_labels = { 11264>>1, NULL };
#if !defined LUNATIC_ONLY
static hashtable_t h_keywords = { CON_END>>1, NULL };
static hashtable_t sectorH = { SECTOR_END>>1, NULL };
@ -2057,6 +2064,8 @@ static void check_filename_case(const char *fn)
static void check_filename_case(const char *fn) { UNREFERENCED_PARAMETER(fn); }
#endif
#endif // !defined LUNATIC_ONLY
void G_DoGameStartup(const int32_t *params)
{
int32_t j = 0;
@ -2098,6 +2107,7 @@ void G_DoGameStartup(const int32_t *params)
}
}
#if !defined LUNATIC_ONLY
static int32_t C_ParseCommand(int32_t loop)
{
int32_t i, j=0, k=0, tw, otw;
@ -5729,7 +5739,6 @@ repeatcase:
return 0;
}
#if !defined LUNATIC_ONLY
/* Anything added with C_AddDefinition() cannot be overwritten in the CONs */
static void C_AddDefinition(const char *lLabel,int32_t lValue,int32_t lType)
{
@ -5869,14 +5878,12 @@ static void C_InitProjectiles(void)
}
}
#pragma pack(pop)
#endif
extern int32_t g_numObituaries;
extern int32_t g_numSelfObituaries;
void C_Compile(const char *filenam)
{
#if !defined LUNATIC_ONLY
char *mptr;
int32_t i;
int32_t fs,fp;
@ -5888,9 +5895,9 @@ void C_Compile(const char *filenam)
Bmemset(&g_tile[i], 0, sizeof(tiledata_t));
C_InitHashes();
#endif
Gv_Init();
#if !defined LUNATIC_ONLY
C_InitProjectiles();
fp = kopen4loadfrommod((char *)filenam,g_loadFromGroupOnly);
@ -6185,11 +6192,12 @@ void C_Compile(const char *filenam)
}
}
}
#endif // !defined LUNATIC_ONLY
}
#endif // !defined LUNATIC_ONLY
void C_ReportError(int32_t iError)
{
#if !defined LUNATIC_ONLY
if (Bstrcmp(g_szCurrentBlockName,g_szLastBlockName))
{
if (g_parsingEventPtr || g_processingState || g_parsingActorPtr)
@ -6278,4 +6286,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
}

View file

@ -97,7 +97,9 @@ extern const memberlabel_t InputLabels[];
extern const memberlabel_t TsprLabels[];
void C_ReportError(int32_t iError);
#if !defined LUNATIC_ONLY
void C_Compile(const char *filenam);
#endif
/*
extern void VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t lVar2);

View file

@ -61,15 +61,18 @@ int32_t g_tw;
int32_t g_currentEventExec = -1;
#if !defined LUNATIC_ONLY
GAMEEXEC_STATIC void VM_Execute(int32_t loop);
#include "gamestructures.c"
# include "gamestructures.c"
#endif
#define VM_CONDITIONAL(xxx) { if ((xxx) || ((insptr = (intptr_t *)*(insptr+1)) && (((*insptr) & 0xfff) == CON_ELSE))) \
{ insptr += 2; VM_Execute(0); } }
void VM_ScriptInfo(void)
{
#if !defined LUNATIC_ONLY
intptr_t *p;
if (!script)
@ -98,6 +101,7 @@ void VM_ScriptInfo(void)
initprintf_nowarn("current actor: %d (%d)\n",vm.g_i,TrackerCast(vm.g_sp->picnum));
initprintf("g_errorLineNum: %d, g_tw: %d\n",g_errorLineNum,g_tw);
#endif
}
// May recurse, e.g. through EVENT_XXX -> ... -> EVENT_KILLIT
@ -110,6 +114,8 @@ int32_t VM_OnEvent(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lD
if (L_IsInitialized(&g_ElState) && El_HaveEvent(iEventID))
El_CallEvent(&g_ElState, iEventID, iActor, iPlayer, lDist);
#endif
#if !defined LUNATIC_ONLY
if (apScriptGameEvent[iEventID])
{
intptr_t *oinsptr=insptr;
@ -148,6 +154,7 @@ int32_t VM_OnEvent(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lD
iReturn = aGameVars[g_iReturnVarID].val.lValue;
aGameVars[g_iReturnVarID].val.lValue = backupReturnVar;
}
#endif
#ifdef LUNATIC
g_eventTotalMs[iEventID] += gethitickms()-t;
@ -773,6 +780,7 @@ void P_AddWeaponMaybeSwitch(DukePlayer_t *ps, int32_t weap)
P_AddWeaponNoSwitch(ps, weap);
}
#if !defined LUNATIC_ONLY
static void P_AddWeaponAmmoCommon(DukePlayer_t *ps, int32_t weap, int32_t amount)
{
P_AddAmmo(weap, ps, amount);
@ -803,6 +811,7 @@ static int32_t VM_AddWeapon(int32_t weap, int32_t amount, DukePlayer_t *ps)
return 0;
}
#endif
static void VM_Fall(void)
{
@ -956,6 +965,7 @@ static void VM_ResetPlayer(void)
//AddLog("EOF: resetplayer");
}
#if !defined LUNATIC_ONLY
GAMEEXEC_STATIC void VM_Execute(int32_t loop)
{
register int32_t tw = *insptr;
@ -5132,10 +5142,12 @@ nullquote:
}
}
}
#endif
// NORECURSE
void A_LoadActor(int32_t iActor)
{
#if !defined LUNATIC_ONLY
vm.g_i = iActor; // Sprite ID
vm.g_p = -1; // iPlayer; // Player ID
vm.g_x = -1; // lDist; // ?
@ -5161,6 +5173,7 @@ void A_LoadActor(int32_t iActor)
if (vm.g_flags & VM_KILL)
A_DeleteSprite(vm.g_i);
#endif
}
// NORECURSE
@ -5487,7 +5500,7 @@ void G_RestoreMapState(mapstate_t *save)
Bmemcpy(&lockclock,&save->lockclock,sizeof(lockclock));
Bmemcpy(&randomseed,&save->randomseed,sizeof(randomseed));
Bmemcpy(&g_globalRandom,&save->g_globalRandom,sizeof(g_globalRandom));
#if !defined LUNATIC_ONLY
for (i=g_gameVarCount-1; i>=0; i--)
{
if (aGameVars[i].dwFlags & GAMEVAR_NORESET) continue;
@ -5505,7 +5518,7 @@ void G_RestoreMapState(mapstate_t *save)
}
Gv_RefreshPointers();
#endif
for (i=0; i<playerswhenstarted; i++)
sprite[g_player[i].ps->i].extra = phealth[i];

View file

@ -146,7 +146,7 @@ void G_RestoreMapState(mapstate_t *save);
void G_RestoreMapState(mapstate_t *save);
void G_SaveMapState(mapstate_t *save);
void G_SaveMapState(mapstate_t *save);
void Gv_RefreshPointers(void);
//void Gv_RefreshPointers(void);
int32_t VM_OnEvent(int32_t iEventID,int32_t iActor,int32_t iPlayer,int32_t lDist, int32_t iReturn);
void VM_ScriptInfo(void);

View file

@ -28,7 +28,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "savegame.h"
#define _gamevars_c_
#include "gamestructures.c"
#if !defined LUNATIC_ONLY
# include "gamestructures.c"
#endif
extern int32_t OSD_errors;
@ -109,6 +111,7 @@ static void Gv_Clear(void)
int32_t Gv_ReadSave(int32_t fil, int32_t newbehav)
{
#if !defined LUNATIC_ONLY
int32_t i, j;
char savedstate[MAXVOLUMES*MAXLEVELS];
char tbuf[12];
@ -243,11 +246,13 @@ int32_t Gv_ReadSave(int32_t fil, int32_t newbehav)
#endif
return(0);
corrupt:
#endif
return(1);
}
void Gv_WriteSave(FILE *fil, int32_t newbehav)
{
#if !defined LUNATIC_ONLY
int32_t i, j;
char savedstate[MAXVOLUMES*MAXLEVELS];
@ -331,8 +336,10 @@ void Gv_WriteSave(FILE *fil, int32_t newbehav)
}
else
fwrite("EOF: EDuke32", 12, 1, fil);
#endif
}
#if !defined LUNATIC_ONLY
void Gv_DumpValues(void)
{
int32_t i;
@ -453,6 +460,7 @@ int32_t Gv_NewArray(const char *pszLabel, void *arrayptr, intptr_t asize, uint32
g_gameArrayCount++;
hash_add(&h_arrays, aGameArrays[i].szLabel, i, 1);
return 1;
}
@ -560,7 +568,6 @@ void __fastcall A_ResetVars(register int32_t iActor)
while (i--);
}
#if !defined LUNATIC_ONLY
static int32_t Gv_GetVarIndex(const char *szGameLabel)
{
int32_t i = hash_find(&h_gamevars,szGameLabel);
@ -765,7 +772,6 @@ badindex:
aGameVars[id].szLabel,vm.g_i,vm.g_p);
return;
}
#endif
int32_t __fastcall Gv_GetVarX(register int32_t id)
{
@ -977,6 +983,7 @@ int32_t Gv_GetVarByLabel(const char *szGameLabel, int32_t lDefault, int32_t iAct
return Gv_GetVar(i, iActor, iPlayer);
}
#endif
#if !defined LUNATIC
static intptr_t *Gv_GetVarDataPtr(const char *szGameLabel)
@ -1407,9 +1414,9 @@ void Gv_Init(void)
#endif
}
#if !defined LUNATIC
void Gv_InitWeaponPointers(void)
{
#if !defined LUNATIC
int32_t i;
char aszBuf[64];
// called from game Init AND when level is loaded...
@ -1463,12 +1470,10 @@ void Gv_InitWeaponPointers(void)
Bsprintf(aszBuf,"WEAPON%d_FLASHCOLOR",i);
aplWeaponFlashColor[i]=Gv_GetVarDataPtr(aszBuf);
}
#endif
}
void Gv_RefreshPointers(void)
{
#if !defined LUNATIC_ONLY
aGameVars[Gv_GetVarIndex("RESPAWN_MONSTERS")].val.lValue = (intptr_t)&ud.respawn_monsters;
aGameVars[Gv_GetVarIndex("RESPAWN_ITEMS")].val.lValue = (intptr_t)&ud.respawn_items;
aGameVars[Gv_GetVarIndex("RESPAWN_INVENTORY")].val.lValue = (intptr_t)&ud.respawn_inventory;
@ -1551,5 +1556,5 @@ void Gv_RefreshPointers(void)
# ifdef USE_OPENGL
aGameVars[Gv_GetVarIndex("rendmode")].val.lValue = (intptr_t)&rendmode;
# endif
#endif
}
#endif

View file

@ -95,8 +95,8 @@ extern int32_t g_gameVarCount;
extern int32_t g_gameArrayCount;
#if defined LUNATIC_ONLY
# define Gv_GetVar(id, iActor, iPlayer) (OSD_Printf("Gv_GetVar @ %s:%d\n", __FILE__, __LINE__), 0)
# define Gv_SetVar(id, lValue, iActor, iPlayer) OSD_Printf("Gv_SetVar @ %s:%d\n", __FILE__, __LINE__)
# 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);
@ -104,19 +104,22 @@ void __fastcall Gv_SetVar(register int32_t id,register int32_t lValue,register i
int32_t __fastcall Gv_GetVarX(register int32_t id);
void __fastcall Gv_SetVarX(register int32_t id,register int32_t lValue);
#ifdef LUNATIC_ONLY
# define Gv_GetVarByLabel(szGameLabel, lDefault, iActor, iPlayer) (-1)
#else
int32_t Gv_GetVarByLabel(const char *szGameLabel,int32_t lDefault,int32_t iActor,int32_t iPlayer);
int32_t Gv_NewArray(const char *pszLabel,void *arrayptr,intptr_t asize,uint32_t dwFlags);
int32_t Gv_NewVar(const char *pszLabel,intptr_t lValue,uint32_t dwFlags);
int32_t Gv_ReadSave(int32_t fil,int32_t newbehav);
void __fastcall A_ResetVars(register int32_t iActor);
void G_FreeMapState(int32_t mapnum);
void Gv_DumpValues(void);
void Gv_Init(void);
void Gv_InitWeaponPointers(void);
void Gv_RefreshPointers(void);
void Gv_RefreshPointers(void);
void Gv_ResetSystemDefaults(void);
void Gv_ResetVars(void);
#endif
int32_t Gv_ReadSave(int32_t fil,int32_t newbehav);
void Gv_Init(void);
void Gv_WriteSave(FILE *fil,int32_t newbehav);
#define GV_VAROP(func, operator) static inline void __fastcall func(register int32_t id, register int32_t lValue) \

View file

@ -1101,7 +1101,9 @@ static inline void prelevel(char g)
while (i >= 0)
{
nexti = nextspritestat[i];
#if !defined LUNATIC_ONLY
A_ResetVars(i);
#endif
A_LoadActor(i);
VM_OnEvent(EVENT_LOADACTOR, i, -1, -1, 0);
if (sprite[i].lotag == UINT16_MAX && (sprite[i].cstat&16))
@ -1367,7 +1369,7 @@ static inline void prelevel(char g)
}
}
#ifdef LUNATIC
#if 0 //def LUNATIC
if (L_IsInitialized(&g_ElState))
{
i = L_RunOnce(&g_ElState, "test.elua");
@ -1437,6 +1439,7 @@ void G_NewGame(int32_t vn,int32_t ln,int32_t sk)
p->zoom = 768;
p->gm = 0;
#if !defined LUNATIC_ONLY
//AddLog("Newgame");
Gv_ResetVars();
@ -1447,7 +1450,7 @@ void G_NewGame(int32_t vn,int32_t ln,int32_t sk)
Gv_RefreshPointers();
Gv_ResetSystemDefaults();
#endif
for (i=0; i<(MAXVOLUMES*MAXLEVELS); i++)
if (MapInfo[i].savedstate)
{