Skip to content

Commit

Permalink
Fix crash on choosing variant after loading the save
Browse files Browse the repository at this point in the history
Fixes crash when choosing new game variant after loading the save and exiting back to main menu.
  • Loading branch information
Max5377 committed Sep 24, 2023
1 parent 589bc9a commit 6a5daf2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions data/pigui/modules/new-game-window/ship.lua
Original file line number Diff line number Diff line change
Expand Up @@ -427,15 +427,15 @@ local function findEquipmentType(eqTypeID)
assert(false, "Wrong Equipment ID: " .. tostring(eqTypeID))
end

local function findEquipmentPath(eqType)
local function findEquipmentPath(eqKey)
for _, eq_list in pairs({ 'misc', 'laser', 'hyperspace' }) do
for id, obj in pairs(Equipment[eq_list]) do
if obj == eqType then
if obj.l10n_key == eqKey then
return eq_list, id
end
end
end
assert(false, "Wrong Equipment ID: " .. tostring(eqType))
assert(false, "Wrong Equipment ID: " .. tostring(eqKey))
end

local function hasSlotClass(eqTypeID, slotClass)
Expand Down Expand Up @@ -717,7 +717,7 @@ function ShipEquip:fromStartVariant(variant)
eq_value.misc = {}
for _, entry in pairs(variant.equipment) do
local eq, amount = table.unpack(entry)
local eq_list, id = findEquipmentPath(eq)
local eq_list, id = findEquipmentPath(eq.l10n_key)
if eq_list == 'misc' then
self:addMiscEntry(id)
elseif eq_list == 'laser' then
Expand Down

0 comments on commit 6a5daf2

Please sign in to comment.