Merge branch 'rework-savecheckpoint-command' into 'master'

savecheckpoint cheat online

See merge request KartKrew/Kart!718
This commit is contained in:
James R 2022-09-30 22:52:05 +00:00
commit f6b4b9213b
7 changed files with 39 additions and 7 deletions

View file

@ -2040,6 +2040,12 @@ void D_Cheat(INT32 playernum, INT32 cheat, ...)
switch (cheat)
{
case CHEAT_SAVECHECKPOINT:
COPY(WRITEFIXED, fixed_t); // x
COPY(WRITEFIXED, fixed_t); // y
COPY(WRITEFIXED, fixed_t); // z
break;
case CHEAT_RINGS:
case CHEAT_LIVES:
// If you're confused why 'int' instead of
@ -5547,6 +5553,21 @@ static void Got_Cheat(UINT8 **cp, INT32 playernum)
break;
}
case CHEAT_SAVECHECKPOINT: {
fixed_t x = READFIXED(*cp);
fixed_t y = READFIXED(*cp);
fixed_t z = READFIXED(*cp);
player->respawn.pointx = x;
player->respawn.pointy = y;
player->respawn.pointz = z;
player->respawn.manual = true;
CV_CheaterWarning(targetPlayer, va("temporary checkpoint created at %d, %d, %d",
x / FRACUNIT, y / FRACUNIT, z / FRACUNIT));
break;
}
case CHEAT_RINGS: {
SINT8 rings = READSINT8(*cp);

View file

@ -300,6 +300,7 @@ typedef struct respawnvars_s
UINT32 distanceleft; // How far along the course to respawn you
tic_t dropdash; // Drop Dash charge timer
boolean truedeath; // Your soul has left your body
boolean manual; // Respawn coords were manually set, please respawn exactly there
} respawnvars_t;
// player_t struct for all bot variables

View file

@ -157,7 +157,13 @@ void K_DoIngameRespawn(player_t *player)
P_ResetPlayer(player);
// Set up respawn position if invalid
if (player->respawn.wp != NULL && leveltime >= starttime)
if (player->respawn.manual == true)
{
player->respawn.distanceleft = 0;
player->respawn.pointz += K_RespawnOffset(player, player->respawn.flip);
player->respawn.manual = false; // one respawn only!
}
else if (player->respawn.wp != NULL && leveltime >= starttime)
{
const UINT32 dist = RESPAWN_DIST + (player->airtime * 48);
player->respawn.distanceleft = (dist * mapobjectscale) / FRACUNIT;

View file

@ -674,15 +674,15 @@ void Command_Dumplua_f(void)
void Command_Savecheckpoint_f(void)
{
mobj_t *thing = players[consoleplayer].mo;
REQUIRE_CHEATS;
REQUIRE_INLEVEL;
REQUIRE_SINGLEPLAYER; // TODO: make multiplayer compatible
players[consoleplayer].respawn.pointx = players[consoleplayer].mo->x;
players[consoleplayer].respawn.pointy = players[consoleplayer].mo->y;
players[consoleplayer].respawn.pointz = players[consoleplayer].mo->floorz;
CONS_Printf(M_GetText("Temporary checkpoint created at %d, %d, %d\n"), players[consoleplayer].respawn.pointx, players[consoleplayer].respawn.pointy, players[consoleplayer].respawn.pointz);
if (!P_MobjWasRemoved(thing))
{
D_Cheat(consoleplayer, CHEAT_SAVECHECKPOINT, thing->x, thing->y, thing->z);
}
}
// Like M_GetAllEmeralds() but for console devmode junkies.

View file

@ -22,6 +22,7 @@
typedef enum {
CHEAT_NOCLIP,
CHEAT_GOD,
CHEAT_SAVECHECKPOINT,
CHEAT_RINGS,
CHEAT_LIVES,
CHEAT_SCALE,

View file

@ -395,6 +395,7 @@ static void P_NetArchivePlayers(void)
WRITEUINT32(save_p, players[i].respawn.distanceleft);
WRITEUINT32(save_p, players[i].respawn.dropdash);
WRITEUINT8(save_p, players[i].respawn.truedeath);
WRITEUINT8(save_p, players[i].respawn.manual);
// botvars_t
WRITEUINT8(save_p, players[i].botvars.difficulty);
@ -693,6 +694,7 @@ static void P_NetUnArchivePlayers(void)
players[i].respawn.distanceleft = READUINT32(save_p);
players[i].respawn.dropdash = READUINT32(save_p);
players[i].respawn.truedeath = READUINT8(save_p);
players[i].respawn.manual = READUINT8(save_p);
// botvars_t
players[i].botvars.difficulty = READUINT8(save_p);

View file

@ -4398,6 +4398,7 @@ void P_ResetPlayerCheats(void)
continue;
player->pflags &= ~(PF_GODMODE);
player->respawn.manual = false;
if (P_MobjWasRemoved(thing))
continue;