- migrated Exhumed's cheats to the global system.

This also eliminates the last pieces using that global string list. All relevant text is now in the external string table.
This commit is contained in:
Christoph Oelckers 2020-08-22 21:13:11 +02:00
parent 6d852c33dd
commit 8589d43835
5 changed files with 117 additions and 270 deletions

View file

@ -45,6 +45,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "raze_sound.h" #include "raze_sound.h"
#include "gamestate.h" #include "gamestate.h"
#include "screenjob.h" #include "screenjob.h"
#include "c_console.h"
#include "cheathandler.h"
#include "core/menu/menu.h" #include "core/menu/menu.h"
BEGIN_PS_NS BEGIN_PS_NS
@ -61,61 +63,6 @@ void InitFonts();
int htimer = 0; int htimer = 0;
bool EndLevel = false; bool EndLevel = false;
/* these are XORed in the original game executable then XORed back to normal when the game first starts. Here they are normally */
const char *gString[] =
{
"HOLLY",
"KIMBERLY",
"LOBOCOP",
"LOBODEITY",
"LOBOLITE",
"LOBOPICK",
"LOBOSLIP",
"LOBOSNAKE",
"LOBOSPHERE",
"LOBOSWAG",
"LOBOXY",
};
//////////
enum gametokens
{
T_INCLUDE = 0,
T_INTERFACE = 0,
T_LOADGRP = 1,
T_MODE = 1,
T_CACHESIZE = 2,
T_ALLOW = 2,
T_NOAUTOLOAD,
T_INCLUDEDEFAULT,
T_SOUND,
T_FILE,
T_CUTSCENE,
T_ANIMSOUNDS,
T_NOFLOORPALRANGE,
T_ID,
T_MINPITCH,
T_MAXPITCH,
T_PRIORITY,
T_TYPE,
T_DISTANCE,
T_VOLUME,
T_DELAY,
T_RENAMEFILE,
T_GLOBALGAMEFLAGS,
T_ASPECT,
T_FORCEFILTER,
T_FORCENOFILTER,
T_TEXTUREFILTER,
T_NEWGAMECHOICES,
T_CHOICE,
T_NAME,
T_LOCKED,
T_HIDDEN,
T_USERCONTENT,
};
PlayerInput localInput; PlayerInput localInput;
@ -196,7 +143,6 @@ void DoTitle();
// void TestSaveLoad(); // void TestSaveLoad();
void EraseScreen(int nVal); void EraseScreen(int nVal);
void LoadStatus(); void LoadStatus();
int FindGString(const char *str);
void MySetView(int x1, int y1, int x2, int y2); void MySetView(int x1, int y1, int x2, int y2);
void mysetbrightness(char al); void mysetbrightness(char al);
void FadeIn(); void FadeIn();
@ -341,127 +287,114 @@ void HandleAsync()
} }
void DoPassword(int nPassword) static bool HollyCheat(cheatseq_t* c)
{ {
if (nNetPlayerCount) { // Do the closest thing to this cheat that's available.
return; C_ToggleConsole();
return true;
} }
const char *str = gString[nFirstPassInfo + nPassword]; static bool KimberlyCheat(cheatseq_t* c)
if (str[0] != '\0') {
StatusMessage(750, str);
}
switch (nPassword)
{ {
case 0: Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_SWEETIE"));
{ return true;
if (!nNetPlayerCount) {
bHolly = true;
}
break;
} }
case 1: // KIMBERLY static bool CopCheat(cheatseq_t* c)
{
break;
}
case 2: // LOBOCOP
{ {
lLocalCodes |= kButtonCheatGuns; lLocalCodes |= kButtonCheatGuns;
break; return true;
} }
case 3: // LOBODEITY static bool GodCheat(cheatseq_t* c)
{ {
lLocalCodes |= kButtonCheatGodMode; lLocalCodes |= kButtonCheatGodMode;
break; return true;
} }
case 4: // LOBOLITE static bool LiteCheat(cheatseq_t* c)
{ {
if (bDoFlashes == false) Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_FLASHES"));
{ bDoFlashes = !bDoFlashes;
bDoFlashes = true; return true;
}
else {
bDoFlashes = false;
}
break;
} }
case 5: // LOBOPICK static bool KeyCheat(cheatseq_t* c)
{ {
lLocalCodes |= kButtonCheatKeys; lLocalCodes |= kButtonCheatKeys;
break; return true;
} }
case 6: // LOBOSLIP bool SlipCheat(cheatseq_t* c)
{ {
if (!nNetPlayerCount) if (!nNetPlayerCount)
{ {
if (bSlipMode == false) if (bSlipMode == false)
{ {
bSlipMode = true; bSlipMode = true;
StatusMessage(300, "Slip mode ON"); Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_SLIPON"));
} }
else { else {
bSlipMode = false; bSlipMode = false;
StatusMessage(300, "Slip mode OFF"); Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_SLIPOFF"));
} }
} }
break; return true;
} }
case 7: // LOBOSNAKE static bool SnakeCheat(cheatseq_t* c)
{ {
if (!nNetPlayerCount) if (!nNetPlayerCount)
{ {
if (bSnakeCam == false) if (bSnakeCam == false)
{ {
bSnakeCam = true; bSnakeCam = true;
StatusMessage(750, "SNAKE CAM ENABLED"); Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_SNAKEON"));
}
else
{
bSnakeCam = false;
StatusMessage(750, "SNAKE CAM DISABLED");
}
}
break;
}
case 8: // LOBOSPHERE
{
GrabMap();
bShowTowers = true;
break;
}
case 9: // LOBOSWAG
{
lLocalCodes |= kButtonCheatItems;
break;
}
case 10: // LOBOXY
{
if (bCoordinates == false) {
bCoordinates = true;
} }
else { else {
bCoordinates = false; bSnakeCam = false;
Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_SNAKEOFF"));
} }
break; }
return true;
} }
default: static bool SphereCheat(cheatseq_t* c)
return; {
Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_FULLMAP"));
GrabMap();
bShowTowers = true;
return true;
} }
static bool SwagCheat(cheatseq_t* c)
{
lLocalCodes |= kButtonCheatItems;
return true;
} }
static bool CoordCheat(cheatseq_t* c)
{
C_DoCommand("stat printcoords");
return true;
}
static cheatseq_t excheats[] = {
{"holly", HollyCheat, 0},
{"kimberly", KimberlyCheat, 0},
{"lobocop", CopCheat, 0},
{"lobodeity", GodCheat, 0},
{"lobolite", LiteCheat, 0},
{"lobopick", KeyCheat, 0},
{"loboslip", SlipCheat, 0},
{"lobosnake", SnakeCheat, 0},
{"lobosphere", SphereCheat, 0},
{"loboswag", SwagCheat, 0},
{"loboxy", CoordCheat, true},
};
void mysetbrightness(char nBrightness) void mysetbrightness(char nBrightness)
{ {
g_visibility = 2048 - (nBrightness << 9); g_visibility = 2048 - (nBrightness << 9);
@ -532,57 +465,6 @@ void CheckKeys()
{ {
return; return;
} }
// Handle cheat codes
if (!bInDemo && inputState.keyBufferWaiting())
{
char ch = inputState.keyGetChar();
if (isalpha(ch))
{
ch = toupper(ch);
int ecx = nCodeMin;
int ebx = nCodeMin;
int edx = nCodeMin - 1;
while (ebx <= nCodeMax)
{
if (ch == gString[ecx][nCodeIndex])
{
nCodeMin = ebx;
nCodeIndex++;
if (gString[ecx][nCodeIndex] == 0)
{
ebx -= nFirstPassword;
DoPassword(ebx);
}
break;
}
else if (gString[ecx][nCodeIndex] < ch)
{
nCodeMin = ebx + 1;
}
else if (gString[ecx][nCodeIndex] > ch)
{
nCodeMax = edx;
}
ecx++;
edx++;
ebx++;
}
if (nCodeMin > nCodeMax) {
ResetPassword();
}
}
}
} }
void FinishLevel() void FinishLevel()
@ -957,18 +839,7 @@ int GameInterface::app_main()
forcelevel = 1; forcelevel = 1;
} }
SetCheats(excheats, countof(excheats));
// loc_115F5:
nFirstPassword = FindGString("PASSWORDS");
nFirstPassInfo = FindGString("PASSINFO");
// count the number of passwords available
for (nPasswordCount = 0; strlen(gString[nFirstPassword+nPasswordCount]) != 0; nPasswordCount++)
{
}
ResetPassword();
registerosdcommands(); registerosdcommands();
if (nNetPlayerCount == -1) if (nNetPlayerCount == -1)

View file

@ -132,8 +132,6 @@ void EraseScreen(int eax);
void RestorePalette(); void RestorePalette();
int FindGString(const char *str);
void FadeIn(); void FadeIn();
void FadeOut(int bFadeMusic); void FadeOut(int bFadeMusic);
@ -146,7 +144,6 @@ void mysetbrightness(char nBrightness);
void StartFadeIn(); void StartFadeIn();
int DoFadeIn(); int DoFadeIn();
void DoPassword(int nPassword);
void InitSpiritHead(); void InitSpiritHead();
@ -229,10 +226,6 @@ extern int lCountDown;
extern short bSlipMode; extern short bSlipMode;
extern const char* gString[];
extern const char* gPSDemoString[];
extern const char* gEXDemoString[];
extern int bVanilla; extern int bVanilla;
#define POWERSLAVE (g_gameType & GAMEFLAG_POWERSLAVE) #define POWERSLAVE (g_gameType & GAMEFLAG_POWERSLAVE)

View file

@ -421,24 +421,6 @@ void DoFailedFinalScene()
RunCinemaScene(4); RunCinemaScene(4);
} }
int FindGString(const char *str)
{
int i = 0;
while (1)
{
if (!strcmp(gString[i], str))
return i + 1;
if (!strcmp(gString[i], "EOF"))
break;
i++;
}
return -1;
}
static SavegameHelper sgh("menu", static SavegameHelper sgh("menu",
SA(nCinemaSeen), SA(nCinemaSeen),
SA(energytile), SA(energytile),

View file

@ -28,17 +28,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "view.h" #include "view.h"
#include "mapinfo.h" #include "mapinfo.h"
#include "aistuff.h" #include "aistuff.h"
#include "ps_input.h"
#include "cheathandler.h"
BEGIN_PS_NS BEGIN_PS_NS
static int osdcmd_god(CCmdFuncPtr UNUSED(parm)) static int osdcmd_god(CCmdFuncPtr)
{ {
UNREFERENCED_CONST_PARAMETER(parm);
if (!nNetPlayerCount && !bInDemo) if (!nNetPlayerCount && !bInDemo)
{ {
DoPassword(3); lLocalCodes |= kButtonCheatGodMode;
} }
else else
Printf("god: Not in a single-player game.\n"); Printf("god: Not in a single-player game.\n");
@ -46,13 +46,13 @@ static int osdcmd_god(CCmdFuncPtr UNUSED(parm))
return CCMD_OK; return CCMD_OK;
} }
static int osdcmd_noclip(CCmdFuncPtr UNUSED(parm)) bool SlipCheat(cheatseq_t* c);
{
UNREFERENCED_CONST_PARAMETER(parm);
static int osdcmd_noclip(CCmdFuncPtr)
{
if (!nNetPlayerCount && !bInDemo) if (!nNetPlayerCount && !bInDemo)
{ {
DoPassword(6); SlipCheat(nullptr);
} }
else else
{ {

View file

@ -62,6 +62,7 @@ void GetLocalInput();
extern PlayerInput sPlayerInput[]; extern PlayerInput sPlayerInput[];
extern PlayerInput localInput; extern PlayerInput localInput;
extern int nNetMoves; extern int nNetMoves;
extern int lLocalCodes;
END_PS_NS END_PS_NS