From aa5e79f86aaaf749df200b60d02a8a9b80a48213 Mon Sep 17 00:00:00 2001 From: ewasylishen Date: Tue, 7 Jun 2016 07:08:23 +0000 Subject: [PATCH] host_cmd.c: add new "setpos" command. developer cheat to teleport to a given origin, optionally looking in a given direction. git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@1308 af15c1b1-3010-417e-b628-4374ebc0bcbd --- quakespasm/Quake/host_cmd.c | 62 +++++++++++++++++++++++++++++++++++++ quakespasm/Quake/sv_user.c | 2 ++ 2 files changed, 64 insertions(+) diff --git a/quakespasm/Quake/host_cmd.c b/quakespasm/Quake/host_cmd.c index a43e37d3..f8adfbf3 100644 --- a/quakespasm/Quake/host_cmd.c +++ b/quakespasm/Quake/host_cmd.c @@ -640,6 +640,67 @@ void Host_Noclip_f (void) //johnfitz } +/* +==================== +Host_SetPos_f + +adapted from fteqw, originally by Alex Shadowalker +==================== +*/ +void Host_SetPos_f(void) +{ + if (cmd_source == src_command) + { + Cmd_ForwardToServer (); + return; + } + + if (pr_global_struct->deathmatch) + return; + + if (Cmd_Argc() != 7 && Cmd_Argc() != 4) + { + SV_ClientPrintf("usage:\n"); + SV_ClientPrintf(" setpos \n"); + SV_ClientPrintf(" setpos \n"); + SV_ClientPrintf("current values:\n"); + SV_ClientPrintf(" %i %i %i %i %i %i\n", + (int)sv_player->v.origin[0], + (int)sv_player->v.origin[1], + (int)sv_player->v.origin[2], + (int)sv_player->v.v_angle[0], + (int)sv_player->v.v_angle[1], + (int)sv_player->v.v_angle[2]); + return; + } + + if (sv_player->v.movetype != MOVETYPE_NOCLIP) + { + noclip_anglehack = true; + sv_player->v.movetype = MOVETYPE_NOCLIP; + SV_ClientPrintf ("noclip ON\n"); + } + + //make sure they're not going to whizz away from it + sv_player->v.velocity[0] = 0; + sv_player->v.velocity[1] = 0; + sv_player->v.velocity[2] = 0; + + sv_player->v.origin[0] = atof(Cmd_Argv(1)); + sv_player->v.origin[1] = atof(Cmd_Argv(2)); + sv_player->v.origin[2] = atof(Cmd_Argv(3)); + + if (Cmd_Argc() == 7) + { + sv_player->v.angles[0] = atof(Cmd_Argv(4)); + sv_player->v.angles[1] = atof(Cmd_Argv(5)); + sv_player->v.angles[2] = atof(Cmd_Argv(6)); + sv_player->v.fixangle = 1; + } + + SV_LinkEdict (sv_player, false); +} + /* ================== Host_Fly_f @@ -2236,6 +2297,7 @@ void Host_InitCommands (void) Cmd_AddCommand ("reconnect", Host_Reconnect_f); Cmd_AddCommand ("name", Host_Name_f); Cmd_AddCommand ("noclip", Host_Noclip_f); + Cmd_AddCommand ("setpos", Host_SetPos_f); //QuakeSpasm Cmd_AddCommand ("say", Host_Say_f); Cmd_AddCommand ("say_team", Host_Say_Team_f); diff --git a/quakespasm/Quake/sv_user.c b/quakespasm/Quake/sv_user.c index abb72eb0..5096b936 100644 --- a/quakespasm/Quake/sv_user.c +++ b/quakespasm/Quake/sv_user.c @@ -543,6 +543,8 @@ nextmsg: ret = 1; else if (q_strncasecmp(s, "noclip", 6) == 0) ret = 1; + else if (q_strncasecmp(s, "setpos", 6) == 0) + ret = 1; else if (q_strncasecmp(s, "say", 3) == 0) ret = 1; else if (q_strncasecmp(s, "say_team", 8) == 0)