- 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 "gamestate.h"
#include "screenjob.h"
#include "c_console.h"
#include "cheathandler.h"
#include "core/menu/menu.h"
BEGIN_PS_NS
@ -61,61 +63,6 @@ void InitFonts();
int htimer = 0;
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;
@ -196,7 +143,6 @@ void DoTitle();
// void TestSaveLoad();
void EraseScreen(int nVal);
void LoadStatus();
int FindGString(const char *str);
void MySetView(int x1, int y1, int x2, int y2);
void mysetbrightness(char al);
void FadeIn();
@ -341,127 +287,114 @@ void HandleAsync()
}
void DoPassword(int nPassword)
static bool HollyCheat(cheatseq_t* c)
{
if (nNetPlayerCount) {
return;
// Do the closest thing to this cheat that's available.
C_ToggleConsole();
return true;
}
const char *str = gString[nFirstPassInfo + nPassword];
if (str[0] != '\0') {
StatusMessage(750, str);
}
switch (nPassword)
static bool KimberlyCheat(cheatseq_t* c)
{
case 0:
{
if (!nNetPlayerCount) {
bHolly = true;
}
break;
Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_SWEETIE"));
return true;
}
case 1: // KIMBERLY
{
break;
}
case 2: // LOBOCOP
static bool CopCheat(cheatseq_t* c)
{
lLocalCodes |= kButtonCheatGuns;
break;
return true;
}
case 3: // LOBODEITY
static bool GodCheat(cheatseq_t* c)
{
lLocalCodes |= kButtonCheatGodMode;
break;
return true;
}
case 4: // LOBOLITE
static bool LiteCheat(cheatseq_t* c)
{
if (bDoFlashes == false)
{
bDoFlashes = true;
}
else {
bDoFlashes = false;
}
break;
Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_FLASHES"));
bDoFlashes = !bDoFlashes;
return true;
}
case 5: // LOBOPICK
static bool KeyCheat(cheatseq_t* c)
{
lLocalCodes |= kButtonCheatKeys;
break;
return true;
}
case 6: // LOBOSLIP
bool SlipCheat(cheatseq_t* c)
{
if (!nNetPlayerCount)
{
if (bSlipMode == false)
{
bSlipMode = true;
StatusMessage(300, "Slip mode ON");
Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_SLIPON"));
}
else {
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 (bSnakeCam == false)
{
bSnakeCam = true;
StatusMessage(750, "SNAKE CAM ENABLED");
}
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;
Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_SNAKEON"));
}
else {
bCoordinates = false;
bSnakeCam = false;
Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_SNAKEOFF"));
}
break;
}
return true;
}
default:
return;
static bool SphereCheat(cheatseq_t* c)
{
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)
{
g_visibility = 2048 - (nBrightness << 9);
@ -532,57 +465,6 @@ void CheckKeys()
{
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()
@ -957,18 +839,7 @@ int GameInterface::app_main()
forcelevel = 1;
}
// loc_115F5:
nFirstPassword = FindGString("PASSWORDS");
nFirstPassInfo = FindGString("PASSINFO");
// count the number of passwords available
for (nPasswordCount = 0; strlen(gString[nFirstPassword+nPasswordCount]) != 0; nPasswordCount++)
{
}
ResetPassword();
SetCheats(excheats, countof(excheats));
registerosdcommands();
if (nNetPlayerCount == -1)

View File

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

View File

@ -421,24 +421,6 @@ void DoFailedFinalScene()
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",
SA(nCinemaSeen),
SA(energytile),

View File

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

View File

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