From 56abec7ed4139a3fd0023bd3a9b9ce16524cf91e Mon Sep 17 00:00:00 2001 From: sirlemonhead Date: Mon, 6 Jan 2020 21:03:16 +0000 Subject: [PATCH] PCExhumed: Add god, noclip and changelevel console commands. # Conflicts: # source/exhumed/src/osdcmds.cpp --- source/exhumed/src/exhumed.cpp | 8 ++-- source/exhumed/src/exhumed.h | 1 + source/exhumed/src/osdcmds.cpp | 75 +++++++++++++++++++++++++++++++++- source/exhumed/src/player.cpp | 8 ++-- 4 files changed, 82 insertions(+), 10 deletions(-) diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index e7ec2f3da..dba0f4acf 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -887,13 +887,13 @@ void DoPassword(int nPassword) case 2: // LOBOCOP { - lLocalCodes |= 0x20; + lLocalCodes |= kButtonCheatGuns; break; } case 3: // LOBODEITY { - lLocalCodes |= 0x40; + lLocalCodes |= kButtonCheatGodMode; break; } @@ -910,7 +910,7 @@ void DoPassword(int nPassword) case 5: { - lLocalCodes |= 0x80; + lLocalCodes |= kButtonCheatKeys; break; } @@ -954,7 +954,7 @@ void DoPassword(int nPassword) case 9: { - lLocalCodes |= 0x100; // LOBOSWAG? + lLocalCodes |= kButtonCheatItems; // LOBOSWAG break; } diff --git a/source/exhumed/src/exhumed.h b/source/exhumed/src/exhumed.h index 94cf28fe0..1196ad70b 100644 --- a/source/exhumed/src/exhumed.h +++ b/source/exhumed/src/exhumed.h @@ -143,6 +143,7 @@ void mysetbrightness(char nBrightness); void StartFadeIn(); int DoFadeIn(); +void DoPassword(int nPassword); void InitSpiritHead(); diff --git a/source/exhumed/src/osdcmds.cpp b/source/exhumed/src/osdcmds.cpp index e53348876..87811d9bb 100644 --- a/source/exhumed/src/osdcmds.cpp +++ b/source/exhumed/src/osdcmds.cpp @@ -30,11 +30,81 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS +static int osdcmd_god(osdcmdptr_t UNUSED(parm)) +{ + UNREFERENCED_CONST_PARAMETER(parm); + + if (!nNetPlayerCount && !bInDemo) + { + DoPassword(3); + } + else + OSD_Printf("god: Not in a single-player game.\n"); + + return OSDCMD_OK; +} + +static int osdcmd_noclip(osdcmdptr_t UNUSED(parm)) +{ + UNREFERENCED_CONST_PARAMETER(parm); + + if (!nNetPlayerCount && !bInDemo) + { + DoPassword(6); + } + else + { + OSD_Printf("noclip: Not in a single-player game.\n"); + } + + return OSDCMD_OK; +} + +static int osdcmd_changelevel(osdcmdptr_t parm) +{ + char* p; + + if (parm->numparms != 1) return OSDCMD_SHOWHELP; + + int nLevel = strtol(parm->parms[0], &p, 10); + if (p[0]) return OSDCMD_SHOWHELP; + + if (nLevel < 0) return OSDCMD_SHOWHELP; + + int nMaxLevels; + + if (!ISDEMOVER) { + nMaxLevels = 32; + } + else { + nMaxLevels = 4; + } + + if (nLevel > nMaxLevels) + { + OSD_Printf("changelevel: invalid level number\n"); + return OSDCMD_SHOWHELP; + } + + levelnew = nLevel; + levelnum = nLevel; + + return OSDCMD_OK; +} + +static inline int osdcmd_quit(osdcmdptr_t UNUSED(parm)) +{ + UNREFERENCED_CONST_PARAMETER(parm); + OSD_ShowDisplay(0); + ShutDown(); + return OSDCMD_OK; +} + int32_t registerosdcommands(void) { //if (VOLUMEONE) - // OSD_RegisterFunction("changelevel","changelevel : warps to the given level", osdcmd_changelevel); + OSD_RegisterFunction("changelevel","changelevel : warps to the given level", osdcmd_changelevel); //else //{ // OSD_RegisterFunction("changelevel","changelevel : warps to the given level", osdcmd_changelevel); @@ -47,9 +117,10 @@ int32_t registerosdcommands(void) //OSD_RegisterFunction("give","give : gives requested item", osdcmd_give); - //OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god); + OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god); //OSD_RegisterFunction("activatecheat","activatecheat : activates a cheat code", osdcmd_activatecheat); + OSD_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip); //OSD_RegisterFunction("restartmap", "restartmap: restarts the current map", osdcmd_restartmap); //OSD_RegisterFunction("restartsound","restartsound: reinitializes the sound system",osdcmd_restartsound); diff --git a/source/exhumed/src/player.cpp b/source/exhumed/src/player.cpp index 289eed5b2..d1aad85c0 100644 --- a/source/exhumed/src/player.cpp +++ b/source/exhumed/src/player.cpp @@ -1415,7 +1415,7 @@ loc_1AB8E: uint16_t buttons = sPlayerInput[nPlayer].buttons; - if (buttons & 0x40) // LOBODEITY cheat + if (buttons & kButtonCheatGodMode) // LOBODEITY cheat { char strDeity[96]; // TODO - reduce in size? @@ -1437,18 +1437,18 @@ loc_1AB8E: sprintf(strDeity, "Deity mode %s for player", strDMode); StatusMessage(150, strDeity); } - else if (buttons & 0x20) // LOBOCOP cheat + else if (buttons & kButtonCheatGuns) // LOBOCOP cheat { FillWeapons(nPlayer); StatusMessage(150, "All weapons loaded for player"); } - else if (buttons & 0x80) // LOBOPICK cheat + else if (buttons & kButtonCheatKeys) // LOBOPICK cheat { PlayerList[nPlayer].keys = 0xFFFF; StatusMessage(150, "All keys loaded for player"); RefreshStatus(); } - else if (buttons & 0x100) // LOBOSWAG cheat + else if (buttons & kButtonCheatItems) // LOBOSWAG cheat { FillItems(nPlayer); StatusMessage(150, "All items loaded for player");