Skip to content

Commit 46fa0a6

Browse files
committed
bring save/loading up to speed
1 parent f146b13 commit 46fa0a6

File tree

3 files changed

+76
-73
lines changed

3 files changed

+76
-73
lines changed

Data/Base.rte/Activities/Utility/SaveLoadHandler.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ function SaveLoadHandler:SerializeTable(val, name, skipnewlines, depth)
2323
skipnewlines = skipnewlines or false
2424
depth = depth or 0
2525

26-
print("looking at val: ");
27-
print(val)
26+
--print("looking at val: ");
27+
--print(val)
2828
print("with name: ")
2929
print(name)
3030

Data/Browncoats.rte/Activities/RefineryAssault.lua

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function RefineryAssault:SetupBuyDoorAreaTable(self, area)
2121

2222
print("area key: " .. areaKey);
2323

24-
self.buyDoorTables[areaKey] = {};
24+
self.saveTable.buyDoorTables[areaKey] = {};
2525

2626
-- does not work, actors are not added properly yet at this stage
2727

@@ -30,16 +30,16 @@ function RefineryAssault:SetupBuyDoorAreaTable(self, area)
3030
-- for mo in MovableMan:GetMOsInBox(box, -1, false) do
3131
-- print(mo)
3232
-- if mo.PresetName == "Reinforcement Door" then
33-
-- table.insert(self.buyDoorTables.All, mo)
34-
-- self.buyDoorTables[areaKey][tostring(#self.buyDoorTables.All)] = mo;
33+
-- table.insert(self.saveTable.buyDoorTables.All, mo)
34+
-- self.saveTable.buyDoorTables[areaKey][tostring(#self.saveTable.buyDoorTables.All)] = mo;
3535
-- end
3636
-- end
3737
-- end
3838

3939
for mo in MovableMan.AddedActors do
4040
if mo.PresetName == "Reinforcement Door" and area:IsInside(mo.Pos) then
41-
table.insert(self.buyDoorTables.All, mo)
42-
self.buyDoorTables[areaKey][tonumber(#self.buyDoorTables.All)] = mo;
41+
table.insert(self.saveTable.buyDoorTables.All, mo)
42+
self.saveTable.buyDoorTables[areaKey][tonumber(#self.saveTable.buyDoorTables.All)] = mo;
4343
end
4444
end
4545

@@ -187,6 +187,8 @@ function RefineryAssault:StartActivity(newGame)
187187
table.insert(self.stageFunctionTable, self.MonitorStage4);
188188

189189
if newGame then
190+
191+
self.saveTable = {};
190192

191193
-- Always active base task for defenders
192194
self.tacticsHandler:AddTask("Brainhunt", self.aiTeam, Vector(0, 0), "Brainhunt", 2);
@@ -201,8 +203,8 @@ function RefineryAssault:StartActivity(newGame)
201203
-- so each area-specific table will be made up of the actual indexes
202204
-- in the All table which we can SendCustomOrder with.
203205

204-
self.buyDoorTables = {};
205-
self.buyDoorTables.All = {};
206+
self.saveTable.buyDoorTables = {};
207+
self.saveTable.buyDoorTables.All = {};
206208

207209
local area = SceneMan.Scene:GetOptionalArea("BuyDoorArea_LC1");
208210
self:SetupBuyDoorAreaTable(self, area);
@@ -222,13 +224,13 @@ function RefineryAssault:StartActivity(newGame)
222224
area = SceneMan.Scene:GetOptionalArea("BuyDoorArea_S3_4");
223225
self:SetupBuyDoorAreaTable(self, area);
224226

225-
self.buyDoorHandler:ReplaceBuyDoorTable(self.buyDoorTables.All);
227+
self.buyDoorHandler:ReplaceBuyDoorTable(self.saveTable.buyDoorTables.All);
226228

227-
self.buyDoorTables.teamAreas = {};
228-
self.buyDoorTables.teamAreas[self.humanTeam] = {};
229-
self.buyDoorTables.teamAreas[self.aiTeam] = {"LC1", "LC2", "S3_1", "S3_2", "S3_3", "S3_4"};
229+
self.saveTable.buyDoorTables.teamAreas = {};
230+
self.saveTable.buyDoorTables.teamAreas[self.humanTeam] = {};
231+
self.saveTable.buyDoorTables.teamAreas[self.aiTeam] = {"LC1", "LC2", "S3_1", "S3_2", "S3_3", "S3_4"};
230232

231-
for k, v in pairs(self.buyDoorTables.All) do
233+
for k, v in pairs(self.saveTable.buyDoorTables.All) do
232234
print(v)
233235
v.Team = self.aiTeam;
234236
end
@@ -303,9 +305,9 @@ end
303305

304306
function RefineryAssault:ResumeLoadedGame()
305307

306-
print("loading local refineryassault buy door table...");
307-
self.buyDoorTables = self.saveLoadHandler:ReadSavedStringAsTable("buyDoorTables");
308-
print("loaded local refineryassault buy door table!");
308+
print("loading local refineryassault save table...");
309+
self.saveTable = self.saveLoadHandler:ReadSavedStringAsTable("saveTable");
310+
print("loaded local refineryassault save table!");
309311

310312
self.Stage = self:LoadNumber("stage");
311313

@@ -322,13 +324,14 @@ function RefineryAssault:ResumeLoadedGame()
322324
self.buyDoorHandler:OnLoad(self.saveLoadHandler);
323325
self.deliveryCreationHandler:OnLoad(self.saveLoadHandler);
324326

325-
self.buyDoorHandler:ReplaceBuyDoorTable(self.buyDoorTables.All);
327+
self.buyDoorHandler:ReplaceBuyDoorTable(self.saveTable.buyDoorTables.All);
326328

327329
end
328330

329331
function RefineryAssault:OnSave()
330332

331-
self.saveLoadHandler:SaveTableAsString("buyDoorTables", self.buyDoorTables);
333+
self.saveLoadHandler:SaveTableAsString("saveTable", self.saveTable);
334+
332335

333336
self:SaveNumber("stage", self.Stage);
334337

@@ -337,7 +340,7 @@ function RefineryAssault:OnSave()
337340
self:SaveNumber("stage2HoldingBothConsoles", self.stage2HoldingBothConsoles and 1 or 0);
338341
self:SaveNumber("stage2HoldTimer", self.stage2HoldTimer.ElapsedRealTimeMS);
339342

340-
self:SaveNumber("stage3ConsolesBroken", self.stage2ConsolesBroken);
343+
self:SaveNumber("stage3ConsolesBroken", self.stage2ConsolesBroken or 0);
341344

342345
-- Handlers
343346
self.tacticsHandler:OnSave(self.saveLoadHandler);

0 commit comments

Comments
 (0)