void G_ChangeTeam( gentity_t *ent, team_t newTeam ) { team_t oldTeam = (team_t) ent->client->pers.team; if ( oldTeam == newTeam ) { return; } G_LeaveTeam( ent ); ent->client->pers.teamChangeTime = level.time; ent->client->pers.team = newTeam; ent->client->pers.teamInfo = level.startTime - 1; ent->client->pers.classSelection = PCL_NONE; ClientSpawn( ent, nullptr, nullptr, nullptr ); if ( oldTeam == TEAM_HUMANS && newTeam == TEAM_ALIENS ) { // Convert from human to alien credits ent->client->pers.credit = ( int )( ent->client->pers.credit * ALIEN_MAX_CREDITS / HUMAN_MAX_CREDITS + 0.5f ); } else if ( oldTeam == TEAM_ALIENS && newTeam == TEAM_HUMANS ) { // Convert from alien to human credits ent->client->pers.credit = ( int )( ent->client->pers.credit * HUMAN_MAX_CREDITS / ALIEN_MAX_CREDITS + 0.5f ); } if ( !g_cheats.integer ) { if ( ent->client->noclip ) { ent->client->noclip = false; ent->r.contents = ent->client->cliprcontents; } ent->flags &= ~( FL_GODMODE | FL_NOTARGET ); } // Copy credits to ps for the client ent->client->ps.persistant[ PERS_CREDIT ] = ent->client->pers.credit; // Update PERS_UNLOCKABLES in the same frame as PERS_TEAM to prevent bad status change notifications ent->client->ps.persistant[ PERS_UNLOCKABLES ] = BG_UnlockablesMask( newTeam ); ClientUserinfoChanged( ent->client->ps.clientNum, false ); G_UpdateTeamConfigStrings(); Beacon::PropagateAll( ); G_LogPrintf( "ChangeTeam: %d %s: %s^* switched teams", ( int )( ent - g_entities ), BG_TeamName( newTeam ), ent->client->pers.netname ); G_namelog_update_score( ent->client ); TeamplayInfoMessage( ent ); }
/* ================= G_ChangeTeam ================= */ void G_ChangeTeam( gentity_t *ent, team_t newTeam ) { team_t oldTeam = ent->client->pers.teamSelection; if ( oldTeam == newTeam ) { return; } G_LeaveTeam( ent ); ent->client->pers.teamChangeTime = level.time; ent->client->pers.teamSelection = newTeam; ent->client->pers.classSelection = PCL_NONE; ClientSpawn( ent, NULL, NULL, NULL ); if ( oldTeam == TEAM_HUMANS && newTeam == TEAM_ALIENS ) { // Convert from human to alien credits ent->client->pers.credit = ( int )( ent->client->pers.credit * ALIEN_MAX_CREDITS / HUMAN_MAX_CREDITS + 0.5f ); } else if ( oldTeam == TEAM_ALIENS && newTeam == TEAM_HUMANS ) { // Convert from alien to human credits ent->client->pers.credit = ( int )( ent->client->pers.credit * HUMAN_MAX_CREDITS / ALIEN_MAX_CREDITS + 0.5f ); } if ( !g_cheats.integer ) { if ( ent->client->noclip ) { ent->client->noclip = qfalse; ent->r.contents = ent->client->cliprcontents; } ent->flags &= ~( FL_GODMODE | FL_NOTARGET ); } // Copy credits to ps for the client ent->client->ps.persistant[ PERS_CREDIT ] = ent->client->pers.credit; ClientUserinfoChanged( ent->client->ps.clientNum, qfalse ); G_UpdateTeamConfigStrings(); G_LogPrintf( "ChangeTeam: %d %s: %s" S_COLOR_WHITE " switched teams\n", ( int )( ent - g_entities ), BG_TeamName( newTeam ), ent->client->pers.netname ); G_namelog_update_score( ent->client ); TeamplayInfoMessage( ent ); }