- make things compile again.

This commit is contained in:
Christoph Oelckers 2020-02-07 20:57:20 +01:00
parent b9e9b25cc6
commit f3d953513b
9 changed files with 103 additions and 43 deletions

View file

@ -11,6 +11,7 @@ set( PCH_SOURCES
src/game.cpp src/game.cpp
src/gamedef.cpp src/gamedef.cpp
src/gameexec.cpp src/gameexec.cpp
src/gamevars.cpp
src/global.cpp src/global.cpp
src/namesdyn.cpp src/namesdyn.cpp
src/net.cpp src/net.cpp

View file

@ -17,8 +17,8 @@ BEGIN_RR_NS
#define RRRA (g_gameType & GAMEFLAG_RRRA) #define RRRA (g_gameType & GAMEFLAG_RRRA)
#define NAM (g_gameType & GAMEFLAG_NAM) #define NAM (g_gameType & GAMEFLAG_NAM)
#define NAPALM (g_gameType & GAMEFLAG_NAPALM) #define NAPALM (g_gameType & GAMEFLAG_NAPALM)
//#define WW2GI (g_gameType & GAMEFLAG_WW2GI) #define WW2GI (g_gameType & GAMEFLAG_WW2GI)
//#define NAM_WW2GI (g_gameType & (GAMEFLAG_NAM|GAMEFLAG_WW2GI)) #define NAM_WW2GI (g_gameType & (GAMEFLAG_NAM|GAMEFLAG_WW2GI))
#define SHAREWARE (g_gameType & GAMEFLAG_SHAREWARE) #define SHAREWARE (g_gameType & GAMEFLAG_SHAREWARE)
//#define DUKEBETA ((g_gameType & GAMEFLAG_DUKEBETA) == GAMEFLAG_DUKEBETA) //#define DUKEBETA ((g_gameType & GAMEFLAG_DUKEBETA) == GAMEFLAG_DUKEBETA)
//#define IONMAIDEN (g_gameType & GAMEFLAG_IONMAIDEN) //#define IONMAIDEN (g_gameType & GAMEFLAG_IONMAIDEN)

View file

@ -0,0 +1,51 @@
#ifndef EDUKE32_EVENTS_DEFS_H_
#define EDUKE32_EVENTS_DEFS_H_
// the order of these can't be changed or else compatibility with EDuke 2.0 mods will break
// KEEPINSYNC with EventNames[] and lunatic/con_lang.lua
enum GameEvent_t {
EVENT_INIT, // 0
EVENT_ENTERLEVEL,
EVENT_RESETWEAPONS,
EVENT_RESETINVENTORY,
EVENT_HOLSTER,
EVENT_LOOKLEFT, // 5
EVENT_LOOKRIGHT,
EVENT_SOARUP,
EVENT_SOARDOWN,
EVENT_CROUCH,
EVENT_JUMP, // 10
EVENT_RETURNTOCENTER,
EVENT_LOOKUP,
EVENT_LOOKDOWN,
EVENT_AIMUP,
EVENT_FIRE, // 15
EVENT_CHANGEWEAPON,
EVENT_GETSHOTRANGE,
EVENT_GETAUTOAIMANGLE,
EVENT_GETLOADTILE,
EVENT_CHEATGETSTEROIDS, // 20
EVENT_CHEATGETHEAT,
EVENT_CHEATGETBOOT,
EVENT_CHEATGETSHIELD,
EVENT_CHEATGETSCUBA,
EVENT_CHEATGETHOLODUKE, // 25
EVENT_CHEATGETJETPACK,
EVENT_CHEATGETFIRSTAID,
EVENT_QUICKKICK,
EVENT_INVENTORY,
EVENT_USENIGHTVISION, // 30
EVENT_USESTEROIDS,
EVENT_INVENTORYLEFT,
EVENT_INVENTORYRIGHT,
EVENT_HOLODUKEON,
EVENT_HOLODUKEOFF, // 35
EVENT_USEMEDKIT,
EVENT_USEJETPACK,
EVENT_TURNAROUND,
MAXEVENTS,
EVENT_AIMDOWN = EVENT_AIMUP,
};
#endif

View file

@ -277,7 +277,6 @@ void G_HandleLocalKeys(void);
void G_HandleSpecialKeys(void); void G_HandleSpecialKeys(void);
void G_PrintGameQuotes(int32_t snum); void G_PrintGameQuotes(int32_t snum);
//void G_SE40(int32_t smoothratio); //void G_SE40(int32_t smoothratio);
void G_Shutdown(void);
void G_UpdatePlayerFromMenu(void); void G_UpdatePlayerFromMenu(void);
void P_DoQuote(int32_t q,DukePlayer_t *p); void P_DoQuote(int32_t q,DukePlayer_t *p);
void P_SetGamePalette(DukePlayer_t* player, uint32_t palid, ESetPalFlags flags); void P_SetGamePalette(DukePlayer_t* player, uint32_t palid, ESetPalFlags flags);

View file

@ -310,8 +310,6 @@ static hashtable_t * const tables_free [] = {
void C_InitHashes() void C_InitHashes()
{ {
uint32_t i;
for (auto table : tables) for (auto table : tables)
hash_init(table); hash_init(table);
@ -1874,7 +1872,7 @@ setvar:
case CON_ADDVARVAR: case CON_ADDVARVAR:
case CON_SETVARVAR: case CON_SETVARVAR:
{ {
setvarvar: //setvarvar:
auto ins = &g_scriptPtr[-1]; auto ins = &g_scriptPtr[-1];
auto tptr = textptr; auto tptr = textptr;
int const lnum = g_lineNumber; int const lnum = g_lineNumber;

View file

@ -20,11 +20,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
#include "ns.h" // Must come before everything else!
#include "duke3d.h" #include "duke3d.h"
#include "menus.h" #include "menus.h"
#include "savegame.h" #include "savegame.h"
#include "namesdyn.h"
#include "gamevars.h"
#include "vfs.h" //#include "vfs.h"
BEGIN_RR_NS
#define gamevars_c_ #define gamevars_c_
@ -84,38 +90,39 @@ void Gv_Clear(void)
DO_FREE_AND_NULL(gameVar.szLabel); DO_FREE_AND_NULL(gameVar.szLabel);
} }
int Gv_ReadSave(buildvfs_kfd kFile) // Note that this entire function is totally architecture dependent and needs to be fixed (which won't be easy...)
int Gv_ReadSave(FileReader &kFile)
{ {
char tbuf[12]; char tbuf[12];
if (kread(kFile, tbuf, 12)!=12) goto corrupt; if (kFile.Read(tbuf, 12)!=12) goto corrupt;
if (Bmemcmp(tbuf, "BEG: EDuke32", 12)) { OSD_Printf("BEG ERR\n"); return 2; } if (Bmemcmp(tbuf, "BEG: EDuke32", 12)) { OSD_Printf("BEG ERR\n"); return 2; }
Gv_Free(); // nuke 'em from orbit, it's the only way to be sure... Gv_Free(); // nuke 'em from orbit, it's the only way to be sure...
if (kdfread_LZ4(&g_gameVarCount,sizeof(g_gameVarCount),1,kFile) != 1) goto corrupt; if (kFile.Read(&g_gameVarCount,sizeof(g_gameVarCount)) != sizeof(g_gameVarCount)) goto corrupt;
for (bssize_t i=0; i<g_gameVarCount; i++) for (bssize_t i=0; i<g_gameVarCount; i++)
{ {
char *const olabel = aGameVars[i].szLabel; char *const olabel = aGameVars[i].szLabel;
if (kdfread_LZ4(&aGameVars[i], sizeof(gamevar_t), 1, kFile) != 1) if (kFile.Read(&aGameVars[i], sizeof(gamevar_t)) != sizeof(gamevar_t))
goto corrupt; goto corrupt;
aGameVars[i].szLabel = (char *)Xrealloc(olabel, MAXVARLABEL * sizeof(uint8_t)); aGameVars[i].szLabel = (char *)Xrealloc(olabel, MAXVARLABEL * sizeof(uint8_t));
if (kdfread_LZ4(aGameVars[i].szLabel, MAXVARLABEL, 1, kFile) != 1) if (kFile.Read(aGameVars[i].szLabel, MAXVARLABEL) != MAXVARLABEL)
goto corrupt; goto corrupt;
hash_add(&h_gamevars, aGameVars[i].szLabel,i, 1); hash_add(&h_gamevars, aGameVars[i].szLabel,i, 1);
if (aGameVars[i].flags & GAMEVAR_PERPLAYER) if (aGameVars[i].flags & GAMEVAR_PERPLAYER)
{ {
aGameVars[i].pValues = (intptr_t*)Xaligned_alloc(PLAYER_VAR_ALIGNMENT, MAXPLAYERS * sizeof(intptr_t)); aGameVars[i].pValues = (intptr_t*)Xaligned_alloc(PLAYER_VAR_ALIGNMENT, MAXPLAYERS * sizeof(intptr_t));
if (kdfread_LZ4(aGameVars[i].pValues,sizeof(intptr_t) * MAXPLAYERS, 1, kFile) != 1) goto corrupt; if (kFile.Read(aGameVars[i].pValues,sizeof(intptr_t) * MAXPLAYERS) != sizeof(intptr_t) * MAXPLAYERS) goto corrupt;
} }
else if (aGameVars[i].flags & GAMEVAR_PERACTOR) else if (aGameVars[i].flags & GAMEVAR_PERACTOR)
{ {
aGameVars[i].pValues = (intptr_t*)Xaligned_alloc(ACTOR_VAR_ALIGNMENT, MAXSPRITES * sizeof(intptr_t)); aGameVars[i].pValues = (intptr_t*)Xaligned_alloc(ACTOR_VAR_ALIGNMENT, MAXSPRITES * sizeof(intptr_t));
if (kdfread_LZ4(aGameVars[i].pValues,sizeof(intptr_t) * MAXSPRITES, 1, kFile) != 1) goto corrupt; if (kFile.Read(aGameVars[i].pValues,sizeof(intptr_t) * MAXSPRITES) != sizeof(intptr_t) * MAXSPRITES) goto corrupt;
} }
} }
@ -126,7 +133,7 @@ int Gv_ReadSave(buildvfs_kfd kFile)
uint8_t savedstate[MAXVOLUMES*MAXLEVELS]; uint8_t savedstate[MAXVOLUMES*MAXLEVELS];
Bmemset(savedstate, 0, sizeof(savedstate)); Bmemset(savedstate, 0, sizeof(savedstate));
if (kdfread_LZ4(savedstate, sizeof(savedstate), 1, kFile) != 1) goto corrupt; if (kFile.Read(savedstate, sizeof(savedstate)) != sizeof(savedstate)) goto corrupt;
for (bssize_t i = 0; i < (MAXVOLUMES * MAXLEVELS); i++) for (bssize_t i = 0; i < (MAXVOLUMES * MAXLEVELS); i++)
{ {
@ -136,7 +143,7 @@ int Gv_ReadSave(buildvfs_kfd kFile)
continue; continue;
g_mapInfo[i].savedstate = (mapstate_t *)Xaligned_alloc(ACTOR_VAR_ALIGNMENT, sizeof(mapstate_t)); g_mapInfo[i].savedstate = (mapstate_t *)Xaligned_alloc(ACTOR_VAR_ALIGNMENT, sizeof(mapstate_t));
if (kdfread_LZ4(g_mapInfo[i].savedstate, sizeof(mapstate_t), 1, kFile) != 1) return -8; if (kFile.Read(g_mapInfo[i].savedstate, sizeof(mapstate_t)) != sizeof(mapstate_t)) return -8;
mapstate_t &sv = *g_mapInfo[i].savedstate; mapstate_t &sv = *g_mapInfo[i].savedstate;
@ -146,17 +153,17 @@ int Gv_ReadSave(buildvfs_kfd kFile)
if (aGameVars[j].flags & GAMEVAR_PERPLAYER) if (aGameVars[j].flags & GAMEVAR_PERPLAYER)
{ {
sv.vars[j] = (intptr_t *) Xaligned_alloc(PLAYER_VAR_ALIGNMENT, MAXPLAYERS * sizeof(intptr_t)); sv.vars[j] = (intptr_t *) Xaligned_alloc(PLAYER_VAR_ALIGNMENT, MAXPLAYERS * sizeof(intptr_t));
if (kdfread_LZ4(sv.vars[j], sizeof(intptr_t) * MAXPLAYERS, 1, kFile) != 1) return -9; if (kFile.Read(sv.vars[j], sizeof(intptr_t) * MAXPLAYERS) != sizeof(intptr_t) * MAXPLAYERS) return -9;
} }
else if (aGameVars[j].flags & GAMEVAR_PERACTOR) else if (aGameVars[j].flags & GAMEVAR_PERACTOR)
{ {
sv.vars[j] = (intptr_t *) Xaligned_alloc(ACTOR_VAR_ALIGNMENT, MAXSPRITES * sizeof(intptr_t)); sv.vars[j] = (intptr_t *) Xaligned_alloc(ACTOR_VAR_ALIGNMENT, MAXSPRITES * sizeof(intptr_t));
if (kdfread_LZ4(sv.vars[j], sizeof(intptr_t) * MAXSPRITES, 1, kFile) != 1) return -10; if (kFile.Read(sv.vars[j], sizeof(intptr_t) * MAXSPRITES) != sizeof(intptr_t) * MAXSPRITES) return -10;
} }
} }
} }
if (kread(kFile, tbuf, 12) != 12) return -13; if (kFile.Read(tbuf, 12) != 12) return -13;
if (Bmemcmp(tbuf, "EOF: EDuke32", 12)) { OSD_Printf("EOF ERR\n"); return 2; } if (Bmemcmp(tbuf, "EOF: EDuke32", 12)) { OSD_Printf("EOF ERR\n"); return 2; }
return 0; return 0;
@ -165,22 +172,23 @@ corrupt:
return -7; return -7;
} }
void Gv_WriteSave(buildvfs_FILE fil) // Note that this entire function is totally architecture dependent and needs to be fixed (which won't be easy...)
void Gv_WriteSave(FileWriter &fil)
{ {
// AddLog("Saving Game Vars to File"); // AddLog("Saving Game Vars to File");
buildvfs_fwrite("BEG: EDuke32", 12, 1, fil); fil.Write("BEG: EDuke32", 12);
dfwrite_LZ4(&g_gameVarCount,sizeof(g_gameVarCount),1,fil); fil.Write(&g_gameVarCount,sizeof(g_gameVarCount));
for (bssize_t i = 0; i < g_gameVarCount; i++) for (bssize_t i = 0; i < g_gameVarCount; i++)
{ {
dfwrite_LZ4(&(aGameVars[i]), sizeof(gamevar_t), 1, fil); fil.Write(&(aGameVars[i]), sizeof(gamevar_t));
dfwrite_LZ4(aGameVars[i].szLabel, sizeof(uint8_t) * MAXVARLABEL, 1, fil); fil.Write(aGameVars[i].szLabel, sizeof(uint8_t) * MAXVARLABEL);
if (aGameVars[i].flags & GAMEVAR_PERPLAYER) if (aGameVars[i].flags & GAMEVAR_PERPLAYER)
dfwrite_LZ4(aGameVars[i].pValues, sizeof(intptr_t) * MAXPLAYERS, 1, fil); fil.Write(aGameVars[i].pValues, sizeof(intptr_t) * MAXPLAYERS);
else if (aGameVars[i].flags & GAMEVAR_PERACTOR) else if (aGameVars[i].flags & GAMEVAR_PERACTOR)
dfwrite_LZ4(aGameVars[i].pValues, sizeof(intptr_t) * MAXSPRITES, 1, fil); fil.Write(aGameVars[i].pValues, sizeof(intptr_t) * MAXSPRITES);
} }
uint8_t savedstate[MAXVOLUMES * MAXLEVELS]; uint8_t savedstate[MAXVOLUMES * MAXLEVELS];
@ -190,7 +198,7 @@ void Gv_WriteSave(buildvfs_FILE fil)
if (g_mapInfo[i].savedstate != NULL) if (g_mapInfo[i].savedstate != NULL)
savedstate[i] = 1; savedstate[i] = 1;
dfwrite_LZ4(savedstate, sizeof(savedstate), 1, fil); fil.Write(savedstate, sizeof(savedstate));
for (bssize_t i = 0; i < (MAXVOLUMES * MAXLEVELS); i++) for (bssize_t i = 0; i < (MAXVOLUMES * MAXLEVELS); i++)
{ {
@ -198,19 +206,19 @@ void Gv_WriteSave(buildvfs_FILE fil)
mapstate_t &sv = *g_mapInfo[i].savedstate; mapstate_t &sv = *g_mapInfo[i].savedstate;
dfwrite_LZ4(g_mapInfo[i].savedstate, sizeof(mapstate_t), 1, fil); fil.Write(g_mapInfo[i].savedstate, sizeof(mapstate_t));
for (bssize_t j = 0; j < g_gameVarCount; j++) for (bssize_t j = 0; j < g_gameVarCount; j++)
{ {
if (aGameVars[j].flags & GAMEVAR_NORESET) continue; if (aGameVars[j].flags & GAMEVAR_NORESET) continue;
if (aGameVars[j].flags & GAMEVAR_PERPLAYER) if (aGameVars[j].flags & GAMEVAR_PERPLAYER)
dfwrite_LZ4(sv.vars[j], sizeof(intptr_t) * MAXPLAYERS, 1, fil); fil.Write(sv.vars[j], sizeof(intptr_t) * MAXPLAYERS);
else if (aGameVars[j].flags & GAMEVAR_PERACTOR) else if (aGameVars[j].flags & GAMEVAR_PERACTOR)
dfwrite_LZ4(sv.vars[j], sizeof(intptr_t) * MAXSPRITES, 1, fil); fil.Write(sv.vars[j], sizeof(intptr_t) * MAXSPRITES);
} }
} }
buildvfs_fwrite("EOF: EDuke32", 12, 1, fil); fil.Write("EOF: EDuke32", 12);
} }
void Gv_DumpValues(void) void Gv_DumpValues(void)
@ -657,8 +665,8 @@ static int32_t G_StaticToDynamicSound(int32_t const sound)
} while (0) } while (0)
#else #else
# define ADDWEAPONVAR(Weapidx, Membname) do { \ # define ADDWEAPONVAR(Weapidx, Membname) do { \
Bsprintf(aszBuf, "WEAPON%d_" #Membname, Weapidx); \ FStringf aszBuf("WEAPON%d_" #Membname, Weapidx); \
Bstrupr(aszBuf); \ aszBuf.ToUpper(); \
Gv_NewVar(aszBuf, weapondefaults[Weapidx].Membname, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); \ Gv_NewVar(aszBuf, weapondefaults[Weapidx].Membname, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); \
} while (0) } while (0)
#endif #endif
@ -714,8 +722,6 @@ static void Gv_AddSystemVars(void)
{ {
// only call ONCE // only call ONCE
char aszBuf[64];
for (int i=0; i<MAX_WEAPONS; i++) for (int i=0; i<MAX_WEAPONS; i++)
{ {
ADDWEAPONVAR(i, Clip); ADDWEAPONVAR(i, Clip);
@ -798,9 +804,7 @@ void Gv_InitWeaponPointers(void)
if (!aplWeaponClip[i]) if (!aplWeaponClip[i])
{ {
initprintf("ERROR: NULL weapon! WTF?! %s\n", aszBuf); I_Error("ERROR: NULL weapon! WTF?! %s\n", aszBuf);
// Bexit(EXIT_SUCCESS);
G_Shutdown();
} }
Bsprintf(aszBuf, "WEAPON%d_RELOAD", i); Bsprintf(aszBuf, "WEAPON%d_RELOAD", i);
@ -850,3 +854,5 @@ void Gv_RefreshPointers(void)
aGameVars[Gv_GetVarIndex("VOLUME")].global = (intptr_t)&ud.volume_number; aGameVars[Gv_GetVarIndex("VOLUME")].global = (intptr_t)&ud.volume_number;
} }
#endif #endif
END_RR_NS

View file

@ -23,6 +23,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef gamevars_h_ #ifndef gamevars_h_
#define gamevars_h_ #define gamevars_h_
#include "gamedef.h"
BEGIN_RR_NS
#define MAXGAMEVARS 2048 // must be a power of two #define MAXGAMEVARS 2048 // must be a power of two
#define MAXVARLABEL 26 #define MAXVARLABEL 26
@ -103,8 +107,8 @@ void Gv_DumpValues(void);
void Gv_InitWeaponPointers(void); void Gv_InitWeaponPointers(void);
void Gv_RefreshPointers(void); void Gv_RefreshPointers(void);
void Gv_ResetVars(void); void Gv_ResetVars(void);
int Gv_ReadSave(buildvfs_kfd kFile); int Gv_ReadSave(FileReader &kFile);
void Gv_WriteSave(buildvfs_FILE fil); void Gv_WriteSave(FileWriter &fil);
void Gv_Clear(void); void Gv_Clear(void);
void Gv_ResetSystemDefaults(void); void Gv_ResetSystemDefaults(void);
@ -143,4 +147,5 @@ VM_GAMEVAR_OPERATOR(Gv_SubVar, -=)
#undef VM_GAMEVAR_OPERATOR #undef VM_GAMEVAR_OPERATOR
END_RR_NS
#endif #endif

View file

@ -5790,7 +5790,7 @@ static void P_ProcessWeapon(int playerNum)
{ {
pPlayer->ammo_amount[pPlayer->curr_weapon]--; pPlayer->ammo_amount[pPlayer->curr_weapon]--;
int pipeBombType; //int pipeBombType;
int pipeBombZvel; int pipeBombZvel;
int pipeBombFwdVel; int pipeBombFwdVel;

View file

@ -1427,7 +1427,7 @@ static uint8_t *dosaveplayer2(FileWriter *fil, uint8_t *mem)
PRINTSIZE("script"); PRINTSIZE("script");
mem=writespecdata(svgm_anmisc, fil, mem); // animates, quotes & misc. mem=writespecdata(svgm_anmisc, fil, mem); // animates, quotes & misc.
PRINTSIZE("animisc"); PRINTSIZE("animisc");
Gv_WriteSave(fil); // gamevars Gv_WriteSave(*fil); // gamevars
mem=writespecdata((const dataspec_t *)svgm_vars, 0, mem); mem=writespecdata((const dataspec_t *)svgm_vars, 0, mem);
PRINTSIZE("vars"); PRINTSIZE("vars");
@ -1483,7 +1483,7 @@ int32_t sv_updatestate(int32_t frominit)
if (readspecdata(svgm_secwsp, nullptr, &p)) return -4; if (readspecdata(svgm_secwsp, nullptr, &p)) return -4;
if (readspecdata(svgm_script, nullptr, &p)) return -5; if (readspecdata(svgm_script, nullptr, &p)) return -5;
if (readspecdata(svgm_anmisc, nullptr, &p)) return -6; if (readspecdata(svgm_anmisc, nullptr, &p)) return -6;
if (readspecdata((const dataspec_t *)svgm_vars, -1, &p)) return -8; if (readspecdata((const dataspec_t *)svgm_vars, nullptr, &p)) return -8;
if (p != pbeg+svsnapsiz) if (p != pbeg+svsnapsiz)
{ {