mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-02-14 01:26:10 +00:00
Merge branch 'misc-debug' into 'master'
Misc. debug features See merge request KartKrew/Kart!1158
This commit is contained in:
commit
a2362c8bae
9 changed files with 131 additions and 221 deletions
|
|
@ -1100,6 +1100,8 @@ void D_RegisterClientCommands(void)
|
|||
COM_AddCommand("skynum", Command_Skynum_f);
|
||||
COM_AddCommand("weather", Command_Weather_f);
|
||||
COM_AddCommand("grayscale", Command_Grayscale_f);
|
||||
COM_AddCommand("goto", Command_Goto_f);
|
||||
COM_AddCommand("angle", Command_Angle_f);
|
||||
CV_RegisterVar(&cv_renderhitbox);
|
||||
CV_RegisterVar(&cv_devmode_screen);
|
||||
|
||||
|
|
@ -2034,6 +2036,7 @@ void D_Cheat(INT32 playernum, INT32 cheat, ...)
|
|||
break;
|
||||
|
||||
case CHEAT_RELATIVE_TELEPORT:
|
||||
case CHEAT_TELEPORT:
|
||||
COPY(WRITEFIXED, fixed_t);
|
||||
COPY(WRITEFIXED, fixed_t);
|
||||
COPY(WRITEFIXED, fixed_t);
|
||||
|
|
@ -2051,6 +2054,10 @@ void D_Cheat(INT32 playernum, INT32 cheat, ...)
|
|||
case CHEAT_SCORE:
|
||||
COPY(WRITEUINT32, UINT32);
|
||||
break;
|
||||
|
||||
case CHEAT_ANGLE:
|
||||
COPY(WRITEANGLE, angle_t);
|
||||
break;
|
||||
}
|
||||
|
||||
#undef COPY
|
||||
|
|
@ -5745,7 +5752,8 @@ static void Got_Cheat(UINT8 **cp, INT32 playernum)
|
|||
break;
|
||||
}
|
||||
|
||||
case CHEAT_RELATIVE_TELEPORT: {
|
||||
case CHEAT_RELATIVE_TELEPORT:
|
||||
case CHEAT_TELEPORT: {
|
||||
fixed_t x = READFIXED(*cp);
|
||||
fixed_t y = READFIXED(*cp);
|
||||
fixed_t z = READFIXED(*cp);
|
||||
|
|
@ -5760,10 +5768,17 @@ static void Got_Cheat(UINT8 **cp, INT32 playernum)
|
|||
if (!P_MobjWasRemoved(player->mo))
|
||||
{
|
||||
P_MapStart();
|
||||
P_SetOrigin(player->mo,
|
||||
player->mo->x + x,
|
||||
player->mo->y + y,
|
||||
player->mo->z + z);
|
||||
if (cheat == CHEAT_RELATIVE_TELEPORT)
|
||||
{
|
||||
P_SetOrigin(player->mo,
|
||||
player->mo->x + x,
|
||||
player->mo->y + y,
|
||||
player->mo->z + z);
|
||||
}
|
||||
else
|
||||
{
|
||||
P_SetOrigin(player->mo, x, y, z);
|
||||
}
|
||||
P_MapEnd();
|
||||
|
||||
S_StartSound(player->mo, sfx_mixup);
|
||||
|
|
@ -5773,7 +5788,10 @@ static void Got_Cheat(UINT8 **cp, INT32 playernum)
|
|||
strlcpy(t[1], M_Ftrim(f[1]), sizeof t[1]);
|
||||
strlcpy(t[2], M_Ftrim(f[2]), sizeof t[2]);
|
||||
|
||||
CV_CheaterWarning(targetPlayer, va("relative teleport by %d%s, %d%s, %d%s",
|
||||
CV_CheaterWarning(targetPlayer, va("%s %d%s, %d%s, %d%s",
|
||||
cheat == CHEAT_RELATIVE_TELEPORT
|
||||
? "relative teleport by"
|
||||
: "teleport to",
|
||||
(int)f[0], t[0], (int)f[1], t[1], (int)f[2], t[2]));
|
||||
break;
|
||||
}
|
||||
|
|
@ -5823,6 +5841,16 @@ static void Got_Cheat(UINT8 **cp, INT32 playernum)
|
|||
break;
|
||||
}
|
||||
|
||||
case CHEAT_ANGLE: {
|
||||
angle_t angle = READANGLE(*cp);
|
||||
float anglef = FIXED_TO_FLOAT(AngleFixed(angle));
|
||||
|
||||
P_SetPlayerAngle(player, angle);
|
||||
|
||||
CV_CheaterWarning(targetPlayer, va("angle = %d%s", (int)anglef, M_Ftrim(anglef)));
|
||||
break;
|
||||
}
|
||||
|
||||
case NUMBER_OF_CHEATS:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
251
src/m_cheat.c
251
src/m_cheat.c
|
|
@ -327,223 +327,21 @@ void Command_RTeleport_f(void)
|
|||
|
||||
void Command_Teleport_f(void)
|
||||
{
|
||||
fixed_t intx, inty, intz;
|
||||
size_t i;
|
||||
player_t *p = &players[consoleplayer];
|
||||
subsector_t *ss;
|
||||
float x = atof(COM_Argv(1));
|
||||
float y = atof(COM_Argv(2));
|
||||
float z = atof(COM_Argv(3));
|
||||
|
||||
REQUIRE_CHEATS;
|
||||
REQUIRE_INLEVEL;
|
||||
REQUIRE_SINGLEPLAYER; // TODO: make multiplayer compatible
|
||||
|
||||
if (COM_Argc() < 3 || COM_Argc() > 11)
|
||||
if (COM_Argc() != 4)
|
||||
{
|
||||
CONS_Printf(M_GetText("teleport -x <value> -y <value> -z <value> -ang <value> -aim <value>: teleport to a location\nteleport -sp <sequence> <placement>: teleport to specified checkpoint\n"));
|
||||
CONS_Printf(M_GetText("teleport <x> <y> <z>: teleport to a location\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!p->mo)
|
||||
return;
|
||||
|
||||
i = COM_CheckParm("-sp");
|
||||
if (i)
|
||||
{
|
||||
INT32 starpostnum = atoi(COM_Argv(i + 1)); // starpost number
|
||||
INT32 starpostpath = atoi(COM_Argv(i + 2)); // quick, dirty way to distinguish between paths
|
||||
|
||||
if (starpostnum < 0 || starpostpath < 0)
|
||||
{
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("Negative starpost indexing is not valid.\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!starpostnum) // spawnpoints...
|
||||
{
|
||||
mapthing_t *mt;
|
||||
fixed_t offset;
|
||||
|
||||
if (starpostpath >= numcoopstarts)
|
||||
{
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("Player %d spawnpoint not found (%d max).\n"), starpostpath+1, numcoopstarts-1);
|
||||
return;
|
||||
}
|
||||
|
||||
mt = playerstarts[starpostpath]; // Given above check, should never be NULL.
|
||||
intx = mt->x<<FRACBITS;
|
||||
inty = mt->y<<FRACBITS;
|
||||
offset = mt->z<<FRACBITS;
|
||||
|
||||
ss = R_PointInSubsectorOrNull(intx, inty);
|
||||
if (!ss || ss->sector->ceilingheight - ss->sector->floorheight < p->mo->height)
|
||||
{
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("Spawnpoint not in a valid location.\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Flagging a player's ambush will make them start on the ceiling
|
||||
// Objectflip inverts
|
||||
if (!!(mt->args[0]) ^ !!(mt->options & MTF_OBJECTFLIP))
|
||||
intz = ss->sector->ceilingheight - p->mo->height - offset;
|
||||
else
|
||||
intz = ss->sector->floorheight + offset;
|
||||
|
||||
if (mt->options & MTF_OBJECTFLIP) // flip the player!
|
||||
{
|
||||
p->mo->eflags |= MFE_VERTICALFLIP;
|
||||
p->mo->flags2 |= MF2_OBJECTFLIP;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->mo->eflags &= ~MFE_VERTICALFLIP;
|
||||
p->mo->flags2 &= ~MF2_OBJECTFLIP;
|
||||
}
|
||||
|
||||
p->mo->angle = p->drawangle = FixedAngle(mt->angle<<FRACBITS);
|
||||
P_SetPlayerAngle(p, p->mo->angle);
|
||||
}
|
||||
else // scan the thinkers to find starposts...
|
||||
{
|
||||
mobj_t *mo2 = NULL;
|
||||
thinker_t *th;
|
||||
|
||||
INT32 starpostmax = 0;
|
||||
intz = starpostpath; // variable reuse - counting down for selection purposes
|
||||
|
||||
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
|
||||
{
|
||||
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
||||
continue;
|
||||
|
||||
mo2 = (mobj_t *)th;
|
||||
|
||||
if (mo2->type != MT_STARPOST)
|
||||
continue;
|
||||
|
||||
if (mo2->health != starpostnum)
|
||||
{
|
||||
if (mo2->health > starpostmax)
|
||||
starpostmax = mo2->health;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (intz--)
|
||||
continue;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (th == &thlist[THINK_MOBJ])
|
||||
{
|
||||
if (intz == starpostpath)
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("No starpost of position %d found (%d max).\n"), starpostnum, starpostmax);
|
||||
else
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("Starpost of position %d, %d not found (%d, %d max).\n"), starpostnum, starpostpath, starpostmax, (starpostpath-intz)-1);
|
||||
return;
|
||||
}
|
||||
|
||||
ss = R_PointInSubsectorOrNull(mo2->x, mo2->y);
|
||||
if (!ss || ss->sector->ceilingheight - ss->sector->floorheight < p->mo->height)
|
||||
{
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("Starpost not in a valid location.\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
intx = mo2->x;
|
||||
inty = mo2->y;
|
||||
intz = mo2->z;
|
||||
|
||||
if (mo2->flags2 & MF2_OBJECTFLIP) // flip the player!
|
||||
{
|
||||
p->mo->eflags |= MFE_VERTICALFLIP;
|
||||
p->mo->flags2 |= MF2_OBJECTFLIP;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->mo->eflags &= ~MFE_VERTICALFLIP;
|
||||
p->mo->flags2 &= ~MF2_OBJECTFLIP;
|
||||
}
|
||||
|
||||
p->mo->angle = p->drawangle = mo2->angle;
|
||||
P_SetPlayerAngle(p, p->mo->angle);
|
||||
}
|
||||
|
||||
CONS_Printf(M_GetText("Teleporting to checkpoint %d, %d...\n"), starpostnum, starpostpath);
|
||||
}
|
||||
else
|
||||
{
|
||||
i = COM_CheckParm("-nop"); // undocumented stupid addition to allow pivoting on the spot with -ang and -aim
|
||||
if (i)
|
||||
{
|
||||
intx = p->mo->x;
|
||||
inty = p->mo->y;
|
||||
}
|
||||
else
|
||||
{
|
||||
i = COM_CheckParm("-x");
|
||||
if (i)
|
||||
intx = atoi(COM_Argv(i + 1))<<FRACBITS;
|
||||
else
|
||||
{
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("%s value not specified.\n"), "X");
|
||||
return;
|
||||
}
|
||||
|
||||
i = COM_CheckParm("-y");
|
||||
if (i)
|
||||
inty = atoi(COM_Argv(i + 1))<<FRACBITS;
|
||||
else
|
||||
{
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("%s value not specified.\n"), "Y");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ss = R_PointInSubsectorOrNull(intx, inty);
|
||||
if (!ss || ss->sector->ceilingheight - ss->sector->floorheight < p->mo->height)
|
||||
{
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("Not a valid location.\n"));
|
||||
return;
|
||||
}
|
||||
i = COM_CheckParm("-z");
|
||||
if (i)
|
||||
{
|
||||
intz = atoi(COM_Argv(i + 1))<<FRACBITS;
|
||||
if (intz < ss->sector->floorheight)
|
||||
intz = ss->sector->floorheight;
|
||||
if (intz > ss->sector->ceilingheight - p->mo->height)
|
||||
intz = ss->sector->ceilingheight - p->mo->height;
|
||||
}
|
||||
else
|
||||
intz = ((p->mo->eflags & MFE_VERTICALFLIP) ? ss->sector->ceilingheight : ss->sector->floorheight);
|
||||
|
||||
i = COM_CheckParm("-ang");
|
||||
if (i)
|
||||
{
|
||||
p->drawangle = p->mo->angle = FixedAngle(atoi(COM_Argv(i + 1))<<FRACBITS);
|
||||
P_SetPlayerAngle(p, p->mo->angle);
|
||||
}
|
||||
|
||||
i = COM_CheckParm("-aim");
|
||||
if (i)
|
||||
{
|
||||
angle_t aim = FixedAngle(atoi(COM_Argv(i + 1))<<FRACBITS);
|
||||
if (aim >= ANGLE_90 && aim <= ANGLE_270)
|
||||
{
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("Not a valid aiming angle (between +/-90).\n"));
|
||||
return;
|
||||
}
|
||||
localaiming[0] = p->aiming = aim;
|
||||
}
|
||||
|
||||
CONS_Printf(M_GetText("Teleporting to %d, %d, %d...\n"), FixedInt(intx), FixedInt(inty), FixedInt(intz));
|
||||
}
|
||||
|
||||
P_MapStart();
|
||||
if (!P_SetOrigin(p->mo, intx, inty, intz))
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Unable to teleport to that spot!\n"));
|
||||
else
|
||||
S_StartSound(p->mo, sfx_mixup);
|
||||
P_MapEnd();
|
||||
D_Cheat(consoleplayer, CHEAT_TELEPORT,
|
||||
FLOAT_TO_FIXED(x), FLOAT_TO_FIXED(y), FLOAT_TO_FIXED(z));
|
||||
}
|
||||
|
||||
void Command_Skynum_f(void)
|
||||
|
|
@ -781,6 +579,41 @@ void Command_Grayscale_f(void)
|
|||
COM_ImmedExecute("toggle palette \"\" GRAYPAL");
|
||||
}
|
||||
|
||||
void Command_Goto_f(void)
|
||||
{
|
||||
const INT32 id = atoi(COM_Argv(1));
|
||||
const waypoint_t *wayp = K_GetWaypointFromID(id);
|
||||
|
||||
REQUIRE_CHEATS;
|
||||
REQUIRE_INLEVEL;
|
||||
|
||||
if (COM_Argc() != 2)
|
||||
{
|
||||
CONS_Printf(M_GetText("goto <waypoint id>: teleport to a waypoint\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (wayp == NULL)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, "goto %d: no waypoint with that ID\n", id);
|
||||
return;
|
||||
}
|
||||
|
||||
D_Cheat(consoleplayer, CHEAT_TELEPORT,
|
||||
wayp->mobj->x, wayp->mobj->y, wayp->mobj->z);
|
||||
}
|
||||
|
||||
void Command_Angle_f(void)
|
||||
{
|
||||
const float anglef = atof(COM_Argv(1));
|
||||
const angle_t angle = FixedAngle(FLOAT_TO_FIXED(anglef));
|
||||
|
||||
REQUIRE_CHEATS;
|
||||
REQUIRE_INLEVEL;
|
||||
|
||||
D_Cheat(consoleplayer, CHEAT_ANGLE, angle);
|
||||
}
|
||||
|
||||
//
|
||||
// OBJECTPLACE (and related variables)
|
||||
//
|
||||
|
|
|
|||
|
|
@ -33,9 +33,11 @@ typedef enum {
|
|||
CHEAT_FLIP,
|
||||
CHEAT_HURT,
|
||||
CHEAT_RELATIVE_TELEPORT,
|
||||
CHEAT_TELEPORT,
|
||||
CHEAT_DEVMODE,
|
||||
CHEAT_GIVEITEM,
|
||||
CHEAT_SCORE,
|
||||
CHEAT_ANGLE,
|
||||
|
||||
NUMBER_OF_CHEATS
|
||||
} cheat_t;
|
||||
|
|
@ -82,6 +84,8 @@ void Command_RTeleport_f(void);
|
|||
void Command_Skynum_f(void);
|
||||
void Command_Weather_f(void);
|
||||
void Command_Grayscale_f(void);
|
||||
void Command_Goto_f(void);
|
||||
void Command_Angle_f(void);
|
||||
#ifdef _DEBUG
|
||||
void Command_CauseCfail_f(void);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -126,6 +126,8 @@ int ps_numsprites = 0;
|
|||
int ps_numdrawnodes = 0;
|
||||
int ps_numpolyobjects = 0;
|
||||
|
||||
struct RenderStats g_renderstats;
|
||||
|
||||
static CV_PossibleValue_t drawdist_cons_t[] = {
|
||||
/*{256, "256"},*/ {512, "512"}, {768, "768"},
|
||||
{1024, "1024"}, {1536, "1536"}, {2048, "2048"},
|
||||
|
|
@ -1553,6 +1555,8 @@ void R_RenderPlayerView(void)
|
|||
framecount++;
|
||||
validcount++;
|
||||
|
||||
memset(&g_renderstats, 0, sizeof g_renderstats);
|
||||
|
||||
// Clear buffers.
|
||||
R_ClearPlanes();
|
||||
if (viewmorph[viewssnum].use)
|
||||
|
|
|
|||
|
|
@ -108,6 +108,15 @@ extern int ps_numsprites;
|
|||
extern int ps_numdrawnodes;
|
||||
extern int ps_numpolyobjects;
|
||||
|
||||
struct RenderStats
|
||||
{
|
||||
size_t visplanes;
|
||||
size_t drawsegs;
|
||||
size_t skybox_portals;
|
||||
};
|
||||
|
||||
extern struct RenderStats g_renderstats;
|
||||
|
||||
//
|
||||
// REFRESH - the actual rendering functions.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -341,6 +341,9 @@ static visplane_t *new_visplane(unsigned hash)
|
|||
}
|
||||
check->next = visplanes[hash];
|
||||
visplanes[hash] = check;
|
||||
|
||||
g_renderstats.visplanes++;
|
||||
|
||||
return check;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -312,5 +312,5 @@ void Portal_AddSkyboxPortals (const player_t *player)
|
|||
}
|
||||
}
|
||||
|
||||
CONS_Debug(DBG_RENDER, "Skybox portals: %d\n", count);
|
||||
g_renderstats.skybox_portals = count;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2957,4 +2957,6 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
|||
ds_p->bsilheight = twosidedmidtexture ? INT32_MAX: INT32_MIN;
|
||||
}
|
||||
ds_p++;
|
||||
|
||||
g_renderstats.drawsegs++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -434,6 +434,18 @@ static void ST_drawMusicDebug(INT32 *height)
|
|||
}
|
||||
}
|
||||
|
||||
static void ST_drawRenderDebug(INT32 *height)
|
||||
{
|
||||
const struct RenderStats *i = &g_renderstats;
|
||||
|
||||
ST_pushDebugString(height, va(" Visplanes: %4s", sizeu1(i->visplanes)));
|
||||
ST_pushDebugString(height, va(" Drawsegs: %4s", sizeu1(i->drawsegs)));
|
||||
|
||||
ST_pushRow(height);
|
||||
|
||||
ST_pushDebugString(height, va("Skybox Portals: %4s", sizeu1(i->skybox_portals)));
|
||||
}
|
||||
|
||||
void ST_drawDebugInfo(void)
|
||||
{
|
||||
INT32 height = 192;
|
||||
|
|
@ -446,15 +458,25 @@ void ST_drawDebugInfo(void)
|
|||
if (!stplyr->mo)
|
||||
return;
|
||||
|
||||
if (cv_ticrate.value)
|
||||
{
|
||||
height -= 20;
|
||||
}
|
||||
|
||||
if (cv_showping.value)
|
||||
{
|
||||
height -= 20;
|
||||
}
|
||||
|
||||
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));
|
||||
V_DrawRightAlignedString(320, 176, V_MONOSPACE, va("Y: %6d", stplyr->mo->y>>FRACBITS));
|
||||
V_DrawRightAlignedString(320, 184, V_MONOSPACE, va("Z: %6d", stplyr->mo->z>>FRACBITS));
|
||||
V_DrawRightAlignedString(320, 192, V_MONOSPACE, va("A: %6d", FixedInt(d)));
|
||||
V_DrawRightAlignedString(320, height - 24, V_MONOSPACE, va("X: %6d", stplyr->mo->x>>FRACBITS));
|
||||
V_DrawRightAlignedString(320, height - 16, V_MONOSPACE, va("Y: %6d", stplyr->mo->y>>FRACBITS));
|
||||
V_DrawRightAlignedString(320, height - 8, V_MONOSPACE, va("Z: %6d", stplyr->mo->z>>FRACBITS));
|
||||
V_DrawRightAlignedString(320, height, V_MONOSPACE, va("A: %6d", FixedInt(d)));
|
||||
|
||||
height = 152;
|
||||
height -= 40;
|
||||
}
|
||||
|
||||
if (cht_debug & DBG_DETAILED)
|
||||
|
|
@ -506,6 +528,11 @@ void ST_drawDebugInfo(void)
|
|||
ST_drawMusicDebug(&height);
|
||||
}
|
||||
|
||||
if (cht_debug & DBG_RENDER)
|
||||
{
|
||||
ST_drawRenderDebug(&height);
|
||||
}
|
||||
|
||||
if (cht_debug & DBG_MEMORY)
|
||||
V_DrawRightAlignedString(320, height, V_MONOSPACE, va("Heap used: %7sKB", sizeu1(Z_TagsUsage(0, INT32_MAX)>>10)));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue