diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 51944c0da..6827d860f 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2129,6 +2129,12 @@ void D_Cheat(INT32 playernum, INT32 cheat, ...) COPY(WRITEINT32, INT32); break; + case CHEAT_RELATIVE_TELEPORT: + COPY(WRITEFIXED, fixed_t); + COPY(WRITEFIXED, fixed_t); + COPY(WRITEFIXED, fixed_t); + break; + case CHEAT_DEVMODE: COPY(WRITEUINT32, UINT32); break; @@ -5776,6 +5782,39 @@ static void Got_Cheat(UINT8 **cp, INT32 playernum) break; } + case CHEAT_RELATIVE_TELEPORT: { + fixed_t x = READFIXED(*cp); + fixed_t y = READFIXED(*cp); + fixed_t z = READFIXED(*cp); + + float f[3] = { + FIXED_TO_FLOAT(x), + FIXED_TO_FLOAT(y), + FIXED_TO_FLOAT(z), + }; + char t[3][9]; + + if (!P_MobjWasRemoved(player->mo)) + { + P_MapStart(); + P_SetOrigin(player->mo, + player->mo->x + x, + player->mo->y + y, + player->mo->z + z); + P_MapEnd(); + + S_StartSound(player->mo, sfx_mixup); + } + + strlcpy(t[0], M_Ftrim(f[0]), sizeof t[0]); + 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", + (int)f[0], t[0], (int)f[1], t[1], (int)f[2], t[2])); + break; + } + case CHEAT_DEVMODE: { UINT32 flags = READUINT32(*cp); cht_debug = flags; diff --git a/src/m_cheat.c b/src/m_cheat.c index dd633cf9e..4888c502c 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -337,64 +337,21 @@ void Command_Hurtme_f(void) void Command_RTeleport_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_DEVMODE; REQUIRE_INLEVEL; - REQUIRE_SINGLEPLAYER; - if (COM_Argc() < 3 || COM_Argc() > 7) + if (COM_Argc() != 4) { - CONS_Printf(M_GetText("rteleport -x -y -z : relative teleport to a location\n")); + CONS_Printf(M_GetText("rteleport : relative teleport to a location\n")); return; } - if (!p->mo) - return; - - i = COM_CheckParm("-x"); - if (i) - intx = atoi(COM_Argv(i + 1)); - else - intx = 0; - - i = COM_CheckParm("-y"); - if (i) - inty = atoi(COM_Argv(i + 1)); - else - inty = 0; - - ss = R_PointInSubsectorOrNull(p->mo->x + intx*FRACUNIT, p->mo->y + inty*FRACUNIT); - 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)); - intz <<= FRACBITS; - intz += p->mo->z; - 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->z; - - CONS_Printf(M_GetText("Teleporting by %d, %d, %d...\n"), intx, inty, FixedInt((intz-p->mo->z))); - - P_MapStart(); - if (!P_SetOrigin(p->mo, p->mo->x+intx*FRACUNIT, p->mo->y+inty*FRACUNIT, 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_RELATIVE_TELEPORT, + FLOAT_TO_FIXED(x), FLOAT_TO_FIXED(y), FLOAT_TO_FIXED(z)); } void Command_Teleport_f(void) diff --git a/src/m_cheat.h b/src/m_cheat.h index 33e80e3b1..7c086da34 100644 --- a/src/m_cheat.h +++ b/src/m_cheat.h @@ -31,6 +31,7 @@ typedef enum { CHEAT_SCALE, CHEAT_FLIP, CHEAT_HURT, + CHEAT_RELATIVE_TELEPORT, CHEAT_DEVMODE, NUMBER_OF_CHEATS