Skip to content

Commit

Permalink
Don't try to set invalit army color
Browse files Browse the repository at this point in the history
  • Loading branch information
speed2 authored and PhilipJFryFAF committed Oct 20, 2018
1 parent 4533006 commit 6b1aaad
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lua/ui/lobby/lobby.lua
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,17 @@ local function GetSlotMenuTables(stateKey, hostKey, slotNum)
return keys, strings, tooltips
end

--- Get the value of the LastColor, sanitised in case it's an unsafe value.
-- In case a new patch removes a color
function GetSanitisedLastColor()
local lastColor = Prefs.GetFromCurrentProfile('LastColorFAF') or 1
if lastColor > table.getn(gameColors.PlayerColors) or lastColor < 1 then
lastColor = 1
end

return lastColor
end

--- Get the value of the LastFaction, sanitised in case it's an unsafe value.
--
-- This means when some retarded mod (*cough*Nomads*cough*) writes a large number to LastFaction, we
Expand All @@ -388,7 +399,7 @@ function GetLocalPlayerData()
PlayerName = localPlayerName,
OwnerID = localPlayerID,
Human = true,
PlayerColor = Prefs.GetFromCurrentProfile('LastColorFAF'),
PlayerColor = GetSanitisedLastColor(),
Faction = GetSanitisedLastFaction(),
PlayerClan = argv.playerClan,
PL = playerRating,
Expand Down

0 comments on commit 6b1aaad

Please sign in to comment.