From 2460568b64231a7f1513adc22cf55bb4e934e06d Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 25 Nov 2017 10:21:17 +1000 Subject: [PATCH] Move killindicator_teamchange out of clientstate (potentially called before clientstate is initialised, possible cause of a team change crash) --- qcsrc/server/client.qc | 14 +++++++------- qcsrc/server/client.qh | 1 - qcsrc/server/defs.qh | 2 ++ qcsrc/server/mutators/mutator/gamemode_ca.qc | 2 +- qcsrc/server/player.qc | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 4f7dd14a5..d7b9a7ae0 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -873,19 +873,19 @@ Called when a client types 'kill' in the console .float clientkill_nexttime; void ClientKill_Now_TeamChange(entity this) { - if(CS(this).killindicator_teamchange == -1) + if(this.killindicator_teamchange == -1) { JoinBestTeam( this, false, true ); } - else if(CS(this).killindicator_teamchange == -2) + else if(this.killindicator_teamchange == -2) { if(blockSpectators) Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime); PutObserverInServer(this); } else - SV_ChangeTeam(this, CS(this).killindicator_teamchange - 1); - CS(this).killindicator_teamchange = 0; + SV_ChangeTeam(this, this.killindicator_teamchange - 1); + this.killindicator_teamchange = 0; } void ClientKill_Now(entity this) @@ -893,7 +893,7 @@ void ClientKill_Now(entity this) if(this.vehicle) { vehicles_exit(this.vehicle, VHEF_RELEASE); - if(!CS(this).killindicator_teamchange) + if(!this.killindicator_teamchange) { this.vehicle_health = -1; Damage(this, this, this, 1 , DEATH_KILL.m_id, this.origin, '0 0 0'); @@ -905,7 +905,7 @@ void ClientKill_Now(entity this) this.killindicator = NULL; - if(CS(this).killindicator_teamchange) + if(this.killindicator_teamchange) ClientKill_Now_TeamChange(this); if (!IS_SPEC(this) && !IS_OBSERVER(this) && MUTATOR_CALLHOOK(ClientKill_Now, this) == false) @@ -970,7 +970,7 @@ void ClientKill_TeamChange (entity this, float targetteam) // 0 = don't change, return; killtime = M_ARGV(1, float); - CS(this).killindicator_teamchange = targetteam; + this.killindicator_teamchange = targetteam; if(!this.killindicator) { diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index 2282c09cb..af81535a7 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -73,7 +73,6 @@ CLASS(Client, Object) ATTRIB(Client, parm_idlesince, int, this.parm_idlesince); ATTRIB(Client, muted, bool, this.muted); - ATTRIB(Client, killindicator_teamchange, int, this.killindicator_teamchange); ATTRIB(Client, idlekick_lasttimeleft, float, this.idlekick_lasttimeleft); ATTRIB(Client, pm_frametime, float, this.pm_frametime); ATTRIB(Client, pressedkeys, int, this.pressedkeys); diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 4c3b1d221..89582bb7a 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -376,6 +376,8 @@ const float ACTIVE_TOGGLE = 3; .float stat_respawn_time = _STAT(RESPAWN_TIME); // shows respawn time, and is negative when awaiting respawn +.int killindicator_teamchange; + void PlayerUseKey(entity this); USING(spawn_evalfunc_t, vector(entity this, entity player, entity spot, vector current)); diff --git a/qcsrc/server/mutators/mutator/gamemode_ca.qc b/qcsrc/server/mutators/mutator/gamemode_ca.qc index 73d3825e5..919df4901 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ca.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ca.qc @@ -293,7 +293,7 @@ MUTATOR_HOOKFUNCTION(ca, MakePlayerObserver) if (!IS_DEAD(player)) ca_LastPlayerForTeam_Notify(player); - if (CS(player).killindicator_teamchange == -2) // player wants to spectate + if (player.killindicator_teamchange == -2) // player wants to spectate player.caplayer = 0; if (player.caplayer) player.frags = FRAGS_LMS_LOSER; diff --git a/qcsrc/server/player.qc b/qcsrc/server/player.qc index fc88b69bb..26fc9e659 100644 --- a/qcsrc/server/player.qc +++ b/qcsrc/server/player.qc @@ -538,7 +538,7 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, { delete(this.killindicator); this.killindicator = NULL; - if(CS(this).killindicator_teamchange) + if(this.killindicator_teamchange) defer_ClientKill_Now_TeamChange = true; if(this.classname == "body") -- 2.39.2