Skip to content

Commit

Permalink
Mitigate a crash caused by Skirmish AI host leaving
Browse files Browse the repository at this point in the history
  • Loading branch information
Arch-Shaman authored Oct 12, 2024
1 parent 575b3ce commit fbaa840
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions LuaUI/Widgets/gui_chili_crudeplayerlist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ local fallbackAllyTeamID = Spring.GetMyAllyTeamID()

local Chili

local function GetAIName(teamID)
local _, name = Spring.GetAIInfo(teamID)
local fallbackName = Spring.GetTeamRulesParam(teamID, "initAIName") or "Unknown AI"
return name or "<Broken> " .. fallbackName
end

local function IsTeamAI(teamID) -- Creates a fallback. Probably should be a Utility function
local _, _, _, isAiTeam = Spring.GetTeamInfo(teamID, false)
return isAiTeam or Spring.GetTeamRulesParam(teamID, "initAI")
end


local function GetColorChar(colorTable)
if colorTable == nil then return string.char(255,255,255,255) end
local col = {}
Expand Down Expand Up @@ -280,7 +292,7 @@ local function GetEntryData(playerID, teamID, allyTeamID, isAiTeam, isDead)
end

if isAiTeam then
local _, name = Spring.GetAIInfo(teamID)
name = GetAIName(teamID)
entryData.name = name
end

Expand Down Expand Up @@ -599,7 +611,8 @@ local function InitializePlayerlist()
for i = 1, #teamList do
local teamID = teamList[i]
if teamID ~= gaiaTeamID then
local _, leaderID, isDead, isAiTeam, _, allyTeamID = Spring.GetTeamInfo(teamID, false)
local _, leaderID, isDead, _, _, allyTeamID = Spring.GetTeamInfo(teamID, false)
local isAiTeam = IsTeamAI(teamID)
if leaderID < 0 then
leaderID = Spring.GetTeamRulesParam(teamID, "initLeaderID") or leaderID
end
Expand Down

0 comments on commit fbaa840

Please sign in to comment.