diff --git a/scripts/specializations/CpAIFieldWorker.lua b/scripts/specializations/CpAIFieldWorker.lua index 131499828..96e7cdf58 100644 --- a/scripts/specializations/CpAIFieldWorker.lua +++ b/scripts/specializations/CpAIFieldWorker.lua @@ -307,4 +307,15 @@ local function onUpdate(vehicle, superFunc, ...) CpUtil.try(superFunc, vehicle, ...) end -AIFieldWorker.onUpdate = Utils.overwrittenFunction(AIFieldWorker.onUpdate, onUpdate) \ No newline at end of file +AIFieldWorker.onUpdate = Utils.overwrittenFunction(AIFieldWorker.onUpdate, onUpdate) + +--- Ugly hack to avoid restarting the giants helper after loading a savegame, +--- if cp was active prior to saving the game ... +local function saveToXMLFile(vehicle, superFunc, xmlFile, key, ...) + superFunc(vehicle, xmlFile, key, ...) + if vehicle.getIsCpActive and vehicle:getIsCpActive() then + xmlFile:setValue(key .. "#isActive", false) + end +end + +AIFieldWorker.saveToXMLFile = Utils.overwrittenFunction(AIFieldWorker.saveToXMLFile, saveToXMLFile) \ No newline at end of file