devmode cheat online

This commit is contained in:
Sally Coolatta 2022-09-29 12:19:45 -04:00
parent 63af088231
commit 80d9637dda
19 changed files with 156 additions and 98 deletions

View file

@ -454,7 +454,7 @@ boolean AM_Responder(event_t *ev)
{
INT32 rc = false;
if (devparm || cv_debug) // only automap in Debug Tails 01-19-2001
if (devparm || cht_debug) // only automap in Debug Tails 01-19-2001
{
if (!automapactive)
{
@ -625,7 +625,7 @@ static inline void AM_doFollowPlayer(void)
*/
void AM_Ticker(void)
{
if (!cv_debug)
if (!cht_debug)
AM_Stop();
if (dedicated || !automapactive)

View file

@ -1899,7 +1899,7 @@ void CV_CheatsChanged(void)
CV_SetCVar(cvar, cvar->defaultvalue, false);
// Reset any other cheat command effects here, as well.
cv_debug = 0;
cht_debug = 0;
P_ResetPlayerCheats();
}

View file

@ -1521,12 +1521,12 @@ void CONS_Alert(alerttype_t level, const char *fmt, ...)
CONS_Printf("%s", txt);
}
void CONS_Debug(INT32 debugflags, const char *fmt, ...)
void CONS_Debug(UINT32 debugflags, const char *fmt, ...)
{
va_list argptr;
static char *txt = NULL;
if ((cv_debug & debugflags) != debugflags)
if ((cht_debug & debugflags) != debugflags)
return;
if (txt == NULL)

View file

@ -266,7 +266,7 @@ void SendNetXCmdForPlayer(UINT8 playerid, netxcmd_t id, const void *param, size_
{
if (localtextcmd[playerid][0]+2+nparam > MAXTEXTCMD)
{
// for future reference: if (cv_debug) != debug disabled.
// for future reference: if (cht_debug) != debug disabled.
CONS_Alert(CONS_ERROR, M_GetText("NetXCmd buffer full, cannot add netcmd %d! (size: %d, needed: %s)\n"), id, localtextcmd[playerid][0], sizeu1(nparam));
return;
}

View file

@ -962,7 +962,7 @@ void D_StartTitle(void)
splitscreen = 0;
SplitScreen_OnChange();
cv_debug = 0;
cht_debug = 0;
emeralds = 0;
memset(&luabanks, 0, sizeof(luabanks));
lastmaploaded = 0;

View file

@ -326,8 +326,6 @@ consvar_t cv_splitdevice = CVAR_INIT ("splitdevice", "Off", CV_SAVE, CV_OnOff, N
consvar_t cv_skipmapcheck = CVAR_INIT ("skipmapcheck", "Off", CV_SAVE, CV_OnOff, NULL);
INT32 cv_debug;
consvar_t cv_usemouse = CVAR_INIT ("use_mouse", "Off", CV_SAVE|CV_CALL,usemouse_cons_t, I_StartupMouse);
consvar_t cv_usejoystick[MAXSPLITSCREENPLAYERS] = {
@ -2009,6 +2007,10 @@ void D_Cheat(INT32 playernum, INT32 cheat, ...)
case CHEAT_HURT:
COPY(WRITEINT32, INT32);
break;
case CHEAT_DEVMODE:
COPY(WRITEUINT32, UINT32);
break;
}
#undef COPY
@ -2852,7 +2854,7 @@ static void Command_Map_f(void)
newresetplayers = false; // if not forcing and gametypes is the same
// don't use a gametype the map doesn't support
if (cv_debug || option_force || cv_skipmapcheck.value)
if (cht_debug || option_force || cv_skipmapcheck.value)
{
fromlevelselect = false; // The player wants us to trek on anyway. Do so.
}
@ -5565,6 +5567,13 @@ static void Got_Cheat(UINT8 **cp, INT32 playernum)
break;
}
case CHEAT_DEVMODE: {
UINT32 flags = READUINT32(*cp);
cht_debug = flags;
CV_CheaterWarning(targetPlayer, va("devmode %08x", flags));
break;
}
case NUMBER_OF_CHEATS:
break;
}
@ -5625,7 +5634,7 @@ void Command_ExitGame_f(void)
splitscreen = 0;
SplitScreen_OnChange();
cv_debug = 0;
cht_debug = 0;
emeralds = 0;
memset(&luabanks, 0, sizeof(luabanks));

View file

@ -480,7 +480,7 @@ typedef enum
void CONS_Printf(const char *fmt, ...) FUNCPRINTF;
void CONS_Alert(alerttype_t level, const char *fmt, ...) FUNCDEBUG;
void CONS_Debug(INT32 debugflags, const char *fmt, ...) FUNCDEBUG;
void CONS_Debug(UINT32 debugflags, const char *fmt, ...) FUNCDEBUG;
// For help debugging functions.
#define POTENTIALLYUNUSED CONS_Alert(CONS_WARNING, "(%s:%d) Unused code appears to be used.\n", __FILE__, __LINE__)
@ -517,23 +517,35 @@ char *sizeu5(size_t num);
extern int VERSION;
extern int SUBVERSION;
extern boolean devparm; // development mode (-debug)
// d_netcmd.c
extern INT32 cv_debug;
#define DBG_BASIC 0x0001
#define DBG_DETAILED 0x0002
#define DBG_PLAYER 0x0004
#define DBG_RENDER 0x0008
#define DBG_NIGHTSBASIC 0x0010
#define DBG_NIGHTS 0x0020
#define DBG_POLYOBJ 0x0040
#define DBG_GAMELOGIC 0x0080
#define DBG_NETPLAY 0x0100
#define DBG_MEMORY 0x0200
#define DBG_SETUP 0x0400
#define DBG_LUA 0x0800
#define DBG_RANDOMIZER 0x1000
#define DBG_VIEWMORPH 0x2000
// m_cheat.c
extern UINT32 cht_debug;
typedef enum
{
DBG_NONE = 0x00000000,
DBG_BASIC = 0x00000001,
DBG_DETAILED = 0x00000002,
DBG_PLAYER = 0x00000004,
DBG_RENDER = 0x00000008,
//DBG_NIGHTSBASIC = 0x00000010, // free
//DBG_NIGHTS = 0x00000020, // free
DBG_POLYOBJ = 0x00000040,
DBG_GAMELOGIC = 0x00000080,
DBG_NETPLAY = 0x00000100,
DBG_MEMORY = 0x00000200,
DBG_SETUP = 0x00000400,
DBG_LUA = 0x00000800,
DBG_RNG = 0x00001000,
} debugFlags_t;
struct debugFlagNames_s
{
const char *str;
debugFlags_t flag;
};
extern struct debugFlagNames_s const debug_flag_names[];
// =======================
// Misc stuff for later...

View file

@ -866,7 +866,7 @@ boolean F_CreditResponder(event_t *event)
return false;
}
/*if (!(timesBeaten) && !(netgame || multiplayer) && !cv_debug)
/*if (!(timesBeaten) && !(netgame || multiplayer) && !cht_debug)
return false;*/
if (key != KEY_ESCAPE && key != KEY_ENTER && key != KEY_BACKSPACE)

View file

@ -4589,7 +4589,7 @@ void G_SaveGame(UINT32 slot, INT16 mapnum)
gameaction = ga_nothing;
if (cv_debug && saved)
if (cht_debug && saved)
CONS_Printf(M_GetText("Game saved.\n"));
else if (!saved)
CONS_Alert(CONS_ERROR, M_GetText("Error while writing to %s for save slot %u, base: %s\n"), backup, slot, (marathonmode ? liveeventbackup : savegamename));
@ -4691,7 +4691,7 @@ void G_SaveGameOver(UINT32 slot, boolean modifylives)
}
cleanup:
if (cv_debug && saved)
if (cht_debug && saved)
CONS_Printf(M_GetText("Game saved.\n"));
else if (!saved)
CONS_Alert(CONS_ERROR, M_GetText("Error while writing to %s for save slot %u, base: %s\n"), backup, slot, (marathonmode ? liveeventbackup : savegamename));

View file

@ -2016,7 +2016,7 @@ void M_QuitResponse(INT32 ch)
if (ch == MA_YES)
{
if (!(netgame || cv_debug))
if (!(netgame || cht_debug))
{
mrand = M_RandomKey(sizeof(quitsounds) / sizeof(INT32));
if (quitsounds[mrand])
@ -3577,7 +3577,7 @@ void M_LevelSelectHandler(INT32 choice)
strncpy(connectedservername, cv_servername.string, MAXSERVERNAME);
// Still need to reset devmode
cv_debug = 0;
cht_debug = 0;
if (demo.playback)
G_StopDemo();
@ -3686,7 +3686,7 @@ void M_StartTimeAttack(INT32 choice)
}
// Still need to reset devmode
cv_debug = 0;
cht_debug = 0;
emeralds = 0;
if (demo.playback)

View file

@ -51,7 +51,7 @@ static UINT8 lib_searchBlockmap_Objects(lua_State *L, INT32 x, INT32 y, mobj_t *
LUA_PushUserdata(L, thing, META_MOBJ);
LUA_PushUserdata(L, mobj, META_MOBJ);
if (lua_pcall(gL, 2, 1, 0)) {
if (!blockfuncerror || cv_debug & DBG_LUA)
if (!blockfuncerror || cht_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
blockfuncerror = true;
@ -112,7 +112,7 @@ static UINT8 lib_searchBlockmap_Lines(lua_State *L, INT32 x, INT32 y, mobj_t *th
LUA_PushUserdata(L, thing, META_MOBJ);
LUA_PushUserdata(L, po->lines[i], META_LINE);
if (lua_pcall(gL, 2, 1, 0)) {
if (!blockfuncerror || cv_debug & DBG_LUA)
if (!blockfuncerror || cht_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
blockfuncerror = true;
@ -149,7 +149,7 @@ static UINT8 lib_searchBlockmap_Lines(lua_State *L, INT32 x, INT32 y, mobj_t *th
LUA_PushUserdata(L, thing, META_MOBJ);
LUA_PushUserdata(L, ld, META_LINE);
if (lua_pcall(gL, 2, 1, 0)) {
if (!blockfuncerror || cv_debug & DBG_LUA)
if (!blockfuncerror || cht_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
blockfuncerror = true;
@ -195,7 +195,7 @@ static UINT8 lib_searchBlockmap_PolyObjs(lua_State *L, INT32 x, INT32 y, mobj_t
LUA_PushUserdata(L, thing, META_MOBJ);
LUA_PushUserdata(L, po, META_POLYOBJ);
if (lua_pcall(gL, 2, 1, 0)) {
if (!blockfuncerror || cv_debug & DBG_LUA)
if (!blockfuncerror || cht_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
blockfuncerror = true;

View file

@ -411,7 +411,7 @@ static int call_single_hook_no_copy(Hook_State *hook)
else
{
/* print the error message once */
if (cv_debug & DBG_LUA || !in_bit_array(hooksErrored, hook->id))
if (cht_debug & DBG_LUA || !in_bit_array(hooksErrored, hook->id))
{
CONS_Alert(CONS_WARNING, "%s\n", lua_tostring(gL, -1));
set_bit_array(hooksErrored, hook->id);

View file

@ -38,6 +38,8 @@
#include "lua_script.h"
#include "lua_hook.h"
#include "fastcmp.h"
//
// CHEAT SEQUENCE PACKAGE
//
@ -111,7 +113,7 @@ static UINT8 cheatf_devmode(void)
for (i = 0; i < MAXUNLOCKABLES; i++)
unlockables[i].unlocked = true;
devparm = true;
cv_debug |= 0x8000;
cht_debug |= 0x8000;
// Refresh secrets menu existing.
M_ClearMenus(true);
@ -720,24 +722,81 @@ void Command_Resetemeralds_f(void)
}
*/
//
// Devmode
//
UINT32 cht_debug;
struct debugFlagNames_s const debug_flag_names[] =
{
{"None", DBG_NONE},
{"Basic", DBG_BASIC},
{"Detailed", DBG_DETAILED},
{"Player", DBG_PLAYER},
{"Render", DBG_RENDER},
{"Renderer", DBG_RENDER}, // alt name
{"Polyobj", DBG_POLYOBJ},
{"GameLogic", DBG_GAMELOGIC},
{"Game", DBG_GAMELOGIC}, // alt name
{"Netplay", DBG_NETPLAY},
{"Memory", DBG_MEMORY},
{"Setup", DBG_SETUP},
{"Lua", DBG_LUA},
{"RNG", DBG_RNG},
{"Randomizer", DBG_RNG}, // alt name
{NULL, 0}
};
void Command_Devmode_f(void)
{
size_t argc = 0;
REQUIRE_CHEATS;
REQUIRE_SINGLEPLAYER; // TODO: make multiplayer compatible
if (COM_Argc() > 1)
argc = COM_Argc();
if (argc > 1)
{
const char *arg = COM_Argv(1);
UINT32 flags = 0;
size_t i;
if (arg[0] && arg[0] == '0' &&
arg[1] && arg[1] == 'x') // Use hexadecimal!
cv_debug = axtoi(arg+2);
else
cv_debug = atoi(arg);
for (i = 1; i < argc; i++)
{
const char *arg = COM_Argv(i);
size_t j;
// Try it as a string
for (j = 0; debug_flag_names[j].str; j++)
{
if (stricmp(arg, debug_flag_names[j].str) == 0)
{
break;
}
}
if (debug_flag_names[j].str)
{
flags |= debug_flag_names[j].flag;
continue;
}
// Try it as a number
if (arg[0] && arg[0] == '0' &&
arg[1] && arg[1] == 'x') // Use hexadecimal!
{
flags |= axtoi(arg+2);
}
else
{
flags |= atoi(arg);
}
}
D_Cheat(consoleplayer, CHEAT_DEVMODE, flags);
}
else
{
CONS_Printf(M_GetText("devmode <flags>: enable debugging tools and info, prepend with 0x to use hexadecimal\n"));
CONS_Printf(M_GetText("devmode <flags>: Enable debugging info. Prepend with 0x to use hexadecimal\n"));
return;
}
}

View file

@ -27,10 +27,14 @@ typedef enum {
CHEAT_SCALE,
CHEAT_FLIP,
CHEAT_HURT,
CHEAT_DEVMODE,
NUMBER_OF_CHEATS
} cheat_t;
//
// Cheat sequences
//
boolean cht_Responder(event_t *ev);
void cht_Init(void);

View file

@ -8216,7 +8216,7 @@ void A_OrbitNights(mobj_t* actor)
if (!actor->target)
{
if (cv_debug && !(actor->target && actor->target->player))
if (cht_debug && !(actor->target && actor->target->player))
CONS_Printf("ERROR: Powerup has no target!\n");
return;
}
@ -8286,7 +8286,7 @@ void A_SetObjectState(mobj_t *actor)
if ((!locvar2 && !actor->target) || (locvar2 && !actor->tracer))
{
if (cv_debug)
if (cht_debug)
CONS_Printf("A_SetObjectState: No target to change state!\n");
return;
}
@ -8377,7 +8377,7 @@ void A_KnockBack(mobj_t *actor)
if (!target)
{
if(cv_debug)
if(cht_debug)
CONS_Printf("A_KnockBack: No target!\n");
return;
}
@ -8441,7 +8441,7 @@ void A_RingDrain(mobj_t *actor)
if (!actor->target || !actor->target->player)
{
if(cv_debug)
if(cht_debug)
CONS_Printf("A_RingDrain: No player targeted!\n");
return;
}
@ -8645,7 +8645,7 @@ void A_Custom3DRotate(mobj_t *actor)
if (hspeed==0 && vspeed==0)
{
if (cv_debug)
if (cht_debug)
CONS_Printf("Error: A_Custom3DRotate: Object has no speed.\n");
return;
}
@ -9080,7 +9080,7 @@ void A_SetCustomValue(mobj_t *actor)
if (LUA_CallAction(A_SETCUSTOMVALUE, actor))
return;
if (cv_debug)
if (cht_debug)
CONS_Printf("Init custom value is %d\n", actor->cusval);
if (locvar1 == 0 && locvar2 == 4)
@ -9100,7 +9100,7 @@ void A_SetCustomValue(mobj_t *actor)
else // replace
actor->cusval = locvar1;
if(cv_debug)
if(cht_debug)
CONS_Printf("New custom value is %d\n", actor->cusval);
}
@ -9467,7 +9467,7 @@ void A_SetScale(mobj_t *actor)
if (locvar1 <= 0)
{
if(cv_debug)
if(cht_debug)
CONS_Printf("A_SetScale: Valid scale not specified!\n");
return;
}
@ -9481,7 +9481,7 @@ void A_SetScale(mobj_t *actor)
if (!target)
{
if(cv_debug)
if(cht_debug)
CONS_Printf("A_SetScale: No target!\n");
return;
}
@ -9522,7 +9522,7 @@ void A_RemoteDamage(mobj_t *actor)
if (!target)
{
if(cv_debug)
if(cht_debug)
CONS_Printf("A_RemoteDamage: No target!\n");
return;
}
@ -13149,7 +13149,7 @@ void A_ItemPop(mobj_t *actor)
if (!(actor->target && actor->target->player))
{
if (cv_debug && !(actor->target && actor->target->player))
if (cht_debug && !(actor->target && actor->target->player))
CONS_Printf("ERROR: Powerup has no target!\n");
return;
}

View file

@ -4464,7 +4464,7 @@ mobj_t *P_GetClosestAxis(mobj_t *source)
}
if (closestaxis == NULL)
CONS_Debug(DBG_NIGHTS, "ERROR: No axis points found!\n");
CONS_Alert(CONS_ERROR, "No axis points found!\n");
return closestaxis;
}
@ -4536,7 +4536,7 @@ void P_SpawnHoopOfSomething(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT
if (!axis)
{
CONS_Debug(DBG_NIGHTS, "You forgot to put axis points in the map!\n");
CONS_Alert(CONS_WARNING, "You forgot to put axis points in the map!\n");
return;
}

View file

@ -4599,6 +4599,8 @@ static void P_NetArchiveMisc(boolean resending)
WRITEINT16(save_p, task->timer);
WRITESTRING(save_p, task->command);
}
WRITEUINT32(save_p, cht_debug);
}
static inline boolean P_NetUnArchiveMisc(boolean reloading)
@ -4762,6 +4764,8 @@ static inline boolean P_NetUnArchiveMisc(boolean reloading)
Schedule_Add(basetime, timer, command);
}
cht_debug = READUINT32(save_p);
return true;
}

View file

@ -915,39 +915,9 @@ void R_ApplyViewMorph(int s)
end = width * height;
#if 0
if (cv_debug & DBG_VIEWMORPH)
for (p = 0; p < end; p++)
{
UINT8 border = 32;
UINT8 grid = 160;
INT32 ws = vid.width / 4;
INT32 hs = vid.width * (vid.height / 4);
memcpy(tmpscr, srcscr, vid.width*vid.height);
for (p = 0; p < vid.width; p++)
{
tmpscr[viewmorph.scrmap[p]] = border;
tmpscr[viewmorph.scrmap[p + hs]] = grid;
tmpscr[viewmorph.scrmap[p + hs*2]] = grid;
tmpscr[viewmorph.scrmap[p + hs*3]] = grid;
tmpscr[viewmorph.scrmap[end - 1 - p]] = border;
}
for (p = vid.width; p < end; p += vid.width)
{
tmpscr[viewmorph.scrmap[p]] = border;
tmpscr[viewmorph.scrmap[p + ws]] = grid;
tmpscr[viewmorph.scrmap[p + ws*2]] = grid;
tmpscr[viewmorph.scrmap[p + ws*3]] = grid;
tmpscr[viewmorph.scrmap[end - 1 - p]] = border;
}
}
else
#endif
{
for (p = 0; p < end; p++)
{
tmpscr[p] = srcscr[viewmorph[s].scrmap[p]];
}
tmpscr[p] = srcscr[viewmorph[s].scrmap[p]];
}
VID_BlitLinearScreen(tmpscr, srcscr,

View file

@ -364,7 +364,7 @@ static void ST_drawDebugInfo(void)
if (!stplyr->mo)
return;
if (cv_debug & DBG_BASIC)
if (cht_debug & DBG_BASIC)
{
const fixed_t d = AngleFixed(stplyr->mo->angle);
V_DrawRightAlignedString(320, 168, V_MONOSPACE, va("X: %6d", stplyr->mo->x>>FRACBITS));
@ -375,7 +375,7 @@ static void ST_drawDebugInfo(void)
height = 152;
}
if (cv_debug & DBG_DETAILED)
if (cht_debug & DBG_DETAILED)
{
//V_DrawRightAlignedString(320, height - 104, V_MONOSPACE, va("SHIELD: %5x", stplyr->powers[pw_shield]));
V_DrawRightAlignedString(320, height - 96, V_MONOSPACE, va("SCALE: %5d%%", (stplyr->mo->scale*100)/FRACUNIT));
@ -404,7 +404,7 @@ static void ST_drawDebugInfo(void)
height -= 120;
}
if (cv_debug & DBG_RANDOMIZER) // randomizer testing
if (cht_debug & DBG_RNG) // randomizer testing
{
// TODO: this only accounts for the undefined class,
// which should be phased out as much as possible anyway.
@ -421,7 +421,7 @@ static void ST_drawDebugInfo(void)
height -= 32;
}
if (cv_debug & DBG_MEMORY)
if (cht_debug & DBG_MEMORY)
V_DrawRightAlignedString(320, height, V_MONOSPACE, va("Heap used: %7sKB", sizeu1(Z_TagsUsage(0, INT32_MAX)>>10)));
}