Permalink
Browse files

TTT: fixed colour issues if not all players have same model

If the random model for a round was a colourable model, any players with
their own custom special rainbow seahorse models would also get a colour
applied.

Fixed by applying colour to a player only if their specific model is
allowed to have it. To prevent overrides of PlayerSetModel from
overriding this colouring behaviour, it has been moved to a
TTTPlayerSetColor hook, which is always called after PlayerSetModel.
  • Loading branch information...
1 parent f889c07 commit 8e2dd3a5c0effb0c7c64e4773a4b6b16f5eda0bf @svdm svdm committed Feb 26, 2014
@@ -84,6 +84,7 @@ function GM:PlayerSpawn(ply)
-- ye olde hooks
hook.Call("PlayerLoadout", GAMEMODE, ply)
hook.Call("PlayerSetModel", GAMEMODE, ply)
+ hook.Call("TTTPlayerSetColor", GAMEMODE, ply)
local oldhands = ply:GetHands()
if IsValid(oldhands) then oldhands:Remove() end
@@ -253,9 +254,24 @@ function GM:PlayerSetModel(ply)
util.PrecacheModel(mdl)
ply:SetModel(mdl)
- ply:SetColor(GAMEMODE.playercolor or COLOR_WHITE)
+ -- Always clear color state, may later be changed in TTTPlayerSetColor
+ ply:SetColor(COLOR_WHITE)
end
+
+function GM:TTTPlayerSetColor(ply)
+ local clr = COLOR_WHITE
+ local should_color = hook.Call("TTTShouldColorModel", GAMEMODE, ply:GetModel())
+ if GAMEMODE.playercolor and should_color then
+ -- If this player has a colorable model, always use the same color as all
+ -- other colorable players, so color will never be the factor that lets
+ -- you tell players apart.
+ clr = GAMEMODE.playercolor
+ end
+ ply:SetColor(clr)
+end
+
+
-- Only active players can use kill cmd
function GM:CanPlayerSuicide(ply)
return ply:IsTerror()
@@ -270,6 +270,7 @@ end
-- true, only spawns if player is dead, else just makes sure he is healed.
function plymeta:SpawnForRound(dead_only)
hook.Call("PlayerSetModel", GAMEMODE, self)
+ hook.Call("TTTPlayerSetColor", GAMEMODE, self)
-- wrong alive status and not a willing spec who unforced after prep started
-- (and will therefore be "alive")
@@ -3,7 +3,7 @@ GM.Author = "Bad King Urgrain"
GM.Email = "thegreenbunny@gmail.com"
GM.Website = "ttt.badking.net"
-- Date of latest changes (YYYY-MM-DD)
-GM.Version = "2014-02-23"
+GM.Version = "2014-02-26"
GM.Customized = false

0 comments on commit 8e2dd3a

Please sign in to comment.