From 4506ebd5d7690b8677aaa598c173dcc71f013426 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Fri, 2 Jun 2017 21:07:25 -0500 Subject: [PATCH] Fix joining team when starting local team play server AKA fix joining team in Team Arena single player. Though it also affects starting Q3 skirmish in team dm or ctf modes. --- code/game/g_cmds.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/code/game/g_cmds.c b/code/game/g_cmds.c index 29a1ce1d..df74ef06 100644 --- a/code/game/g_cmds.c +++ b/code/game/g_cmds.c @@ -592,8 +592,8 @@ void SetTeam( gentity_t *ent, char *s ) { // execute the team change // - // if the player was dead leave the body - if ( client->ps.stats[STAT_HEALTH] <= 0 ) { + // if the player was dead leave the body, but only if they're actually in game + if ( client->ps.stats[STAT_HEALTH] <= 0 && client->pers.connected == CON_CONNECTED ) { CopyToBodyQue(ent); } @@ -633,6 +633,11 @@ void SetTeam( gentity_t *ent, char *s ) { // get and distribute relevent paramters ClientUserinfoChanged( clientNum ); + // client hasn't spawned yet, they sent an early team command + if ( client->pers.connected != CON_CONNECTED ) { + return; + } + ClientBegin( clientNum ); } @@ -1659,6 +1664,14 @@ void ClientCommand( int clientNum ) { ent = g_entities + clientNum; if (!ent->client || ent->client->pers.connected != CON_CONNECTED) { + if (ent->client && ent->client->pers.localClient) { + // Handle early team command sent by UI when starting a local + // team play game. + trap_Argv( 0, cmd, sizeof( cmd ) ); + if (Q_stricmp (cmd, "team") == 0) { + Cmd_Team_f (ent); + } + } return; // not fully in game yet }