Skip to content

Commit

Permalink
Ignore parenthesis arguments passed to setpos
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-drexler committed Oct 12, 2024
1 parent e41b426 commit fc883c0
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions Quake/host_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1773,6 +1773,9 @@ adapted from fteqw, originally by Alex Shadowalker
*/
static void Host_SetPos_f(void)
{
int i, numargs;
float args[6];

if (cmd_source == src_command)
{
Cmd_ForwardToServer ();
Expand All @@ -1782,7 +1785,16 @@ static void Host_SetPos_f(void)
if (pr_global_struct->deathmatch)
return;

if (Cmd_Argc() != 7 && Cmd_Argc() != 4)
for (i = 1, numargs = 0; i < Cmd_Argc (); i++)
{
const char *str = Cmd_Argv (i);
if (strcmp (str, "(") == 0 || strcmp (str, ")") == 0)
continue;
if (++numargs <= 6)
args[numargs - 1] = atof (str);
}

if (numargs != 6 && numargs != 3)
{
SV_ClientPrintf("usage:\n");
SV_ClientPrintf(" setpos <x> <y> <z>\n");
Expand All @@ -1809,19 +1821,19 @@ static void Host_SetPos_f(void)
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.origin[0] = args[0];
sv_player->v.origin[1] = args[1];
sv_player->v.origin[2] = args[2];

if (numargs == 6)
{
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.angles[0] = args[3];
sv_player->v.angles[1] = args[4];
sv_player->v.angles[2] = args[5];
sv_player->v.fixangle = 1;
}

SV_LinkEdict (sv_player, false);
}

Expand Down

0 comments on commit fc883c0

Please sign in to comment.