Permalink
Browse files

TTT: New attempt at propspec fix

Seems there were still problematic cases created by 6aaed73 (see #610),
so this replaces it with a different fix.

The original issue was that players who propspec during prep remained
linked to that entity if they became spectator later during the round.
Rather than trying to clear that linkage for all players when the round
starts, we now clear it in a safer way whenever a player spawns.
  • Loading branch information...
1 parent 6aaed73 commit 497a796050939a9248fc66e7dc296d12aa90e72c @svdm svdm committed Feb 23, 2014
@@ -310,17 +310,6 @@ function FixSpectators()
end
end
--- Calls PROPSPEC.End on all players who currently have a propspec
--- Normally this is handled by the gamemode because the entity is no longer valid
--- But in our case the props were not removed
-local function FixPropSpectators()
- for _, ply in pairs(player.GetAll()) do
- if ply.propspec then
- PROPSPEC.End(ply)
- end
- end
-end
-
-- Used to be in think, now a timer
local function WinChecker()
if GetRoundState() == ROUND_ACTIVE then
@@ -656,9 +645,6 @@ function BeginRound()
InitRoundEndTime()
- -- Unspectate players who were spectating during prep
- FixPropSpectators()
-
if CheckForAbort() then return end
-- Respawn dumb people who died during prep
@@ -281,6 +281,9 @@ function plymeta:SpawnForRound(dead_only)
if not self:ShouldSpawn() then return false end
+ -- reset propspec state that they may have gotten during prep
+ PROPSPEC.Clear(self)
+
-- respawn anyone else
if self:Team() == TEAM_SPEC then
self:UnSpectate()
@@ -46,14 +46,20 @@ function PROPSPEC.Target(ply, ent)
PROPSPEC.Start(ply, ent)
end
-function PROPSPEC.End(ply)
- local ent = ply.propspec.ent or ply:GetObserverTarget()
+-- Clear any propspec state a player has. Safe even if player is not currently
+-- spectating.
+function PROPSPEC.Clear(ply)
+ local ent = (ply.propspec and ply.propspec.ent) or ply:GetObserverTarget()
if IsValid(ent) then
ent:SetNWEntity("spec_owner", nil)
end
ply.propspec = nil
ply:SpectateEntity(nil)
+end
+
+function PROPSPEC.End(ply)
+ PROPSPEC.Clear(ply)
ply:Spectate(OBS_MODE_ROAMING)
ply:ResetViewRoll()

0 comments on commit 497a796

Please sign in to comment.