Bug in game_deployment.lua

Commander - The Great War: Tech Support

Moderators: Slitherine Core, The Lordz

Post Reply
KeldorKatarn
Lieutenant Colonel - Panther D
Lieutenant Colonel - Panther D
Posts: 1294
Joined: Fri Jan 13, 2012 2:22 am

Bug in game_deployment.lua

Post by KeldorKatarn »

Recently my game crashed with the following message: Attempt to index a nil value.

The error occured in line 447 which is the first line of this function's body.

function ApplySlotState(unit, slot)
unit.luaData.quality = unit.faction.luaData.slots[slot].quality
unit.efficiency = unit.luaData.quality
UpdateUnit(unit, unit.faction.luaData.slots[slot].techs)

ClearSlot(unit.faction, slot)
end

apparently unit.faction.luaData.slots[slot] is nil.

I could fix my savegame by changing the function like this:

function ApplySlotState(unit, slot)
if unit.faction.luaData.slots[slot] ~= nil then
unit.luaData.quality = unit.faction.luaData.slots[slot].quality
unit.efficiency = unit.luaData.quality
UpdateUnit(unit, unit.faction.luaData.slots[slot].techs)

ClearSlot(unit.faction, slot)
end
end

Savegame to reproduce reliably attached.

Please comment whether this fix is correct to I can apply the correct fix manually until the next patch arrives.
Attachments
AutoSaveEndTurn.zip
Savegame reproducing the bug
(117.04 KiB) Downloaded 116 times
lordzimoa
Lordz Games Studio
Lordz Games Studio
Posts: 2417
Joined: Fri Oct 27, 2006 4:20 pm
Contact:

Re: Bug in game_deployment.lua

Post by lordzimoa »

I have Szymon have a look tomorrow morning when he is back in office, thanks for the report!
KeldorKatarn
Lieutenant Colonel - Panther D
Lieutenant Colonel - Panther D
Posts: 1294
Joined: Fri Jan 13, 2012 2:22 am

Re: Bug in game_deployment.lua

Post by KeldorKatarn »

Well what a gamers that are also fellow developers (and can read LUA) for ;-) The nil check is probably just a work around. The real issue seems to be that the function is called when the value can be nil. (Unless that's completely alright, then the nil check is just missing). Anyway, should be an easy fix with the savegame.
Post Reply

Return to “Commander - The Great War: Tech Support”