From 0fd42ce589718e6b786cdd5a6731cfe36c6cfb3e Mon Sep 17 00:00:00 2001 From: terencehill Date: Sun, 10 Nov 2024 20:13:31 +0100 Subject: [PATCH] Cleanup: use a more generic field name and improve the comment --- qcsrc/server/client.qc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 74c533aff..d8e236a95 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -248,7 +248,7 @@ entity SelectObservePoint(entity this) return RandomSelection_chosen_ent; } -.entity spot_save; +.entity angles_ent; /** putting a client as observer in the server */ void PutObserverInServer(entity this, bool is_forced, bool use_spawnpoint) { @@ -283,10 +283,10 @@ void PutObserverInServer(entity this, bool is_forced, bool use_spawnpoint) spot = SelectSpawnPoint(this, true); if (!spot) LOG_FATAL("No spawnpoints for observers?!?"); - // in case a spectator becomes observer because the spectated player disconnects - // the engine will revert the angles we set here, so we have to save spot and - // apply angles later in this frame again - this.spot_save = spot; + // angles may be reverted by physics code if this function is called too early in the server + // frame, e.g. by PlayerPreThink when the spectator becomes observer because the spectated + // player disconnects, so we have to apply them back later + this.angles_ent = spot; this.angles = vec2(spot.angles); // offset it so that the spectator spawns higher off the ground, looks better this way setorigin(this, spot.origin + (is_observepoint ? '0 0 0' : autocvar_sv_player_viewoffset)); @@ -3040,11 +3040,11 @@ void PlayerFrame (entity this) WaypointSprite_UpdateHealth(this.waypointsprite_attachedforcarrier, hp); } - if (this.spot_save && IS_OBSERVER(this)) + if (this.angles_ent && IS_OBSERVER(this)) { - this.angles = vec2(this.spot_save.angles); + this.angles = vec2(this.angles_ent.angles); this.fixangle = true; - this.spot_save = NULL; + this.angles_ent = NULL; } } -- 2.39.2