Skip to content

Commit d3a3eed

Browse files
committed
Merge branch 'browncoat-mission' of https://github.com/cortex-command-community/Cortex-Command-Community-Project into browncoat-mission
2 parents 52fa95e + 36453e1 commit d3a3eed

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function SaveLoadHandler:SerializeTable(val, name, skipnewlines, depth)
6666
if type(name) == "number" then
6767
tmp = tmp .. "[" .. name .. "]" .. " = "
6868
else
69-
tmp = tmp .. name .. " = "
69+
tmp = tmp .. "['" .. name .. "']" .. " = "
7070
end
7171
end
7272

@@ -92,6 +92,8 @@ function SaveLoadHandler:SerializeTable(val, name, skipnewlines, depth)
9292
print("ERROR: SaveLoadHandler tried to save a function. This cannot currently be done and the table will not be as expected when loaded.");
9393
elseif val.Magnitude then -- ghetto vector check
9494
tmp = tmp .. string.format("%q", "Vector(" .. val.X .. "," .. val.Y .. ")")
95+
elseif val.Area then -- ghetto box check
96+
tmp = tmp .. string.format("%q", "Box(" .. val.Corner.X .. "," .. val.Corner.Y .. "," .. val.Corner.X + val.Width .. "," .. val.Corner.Y + val.Height .. ")")
9597
elseif val.PresetName and IsMOSRotating(val) then -- IsMOSRotating freaks out if we give it something that isn't a preset at all... ghetto here too
9698
val:SetNumberValue("saveLoadHandlerUniqueID", val.UniqueID);
9799
tmp = tmp .. string.format("%q", "SAVELOADHANDLERUNIQUEID_" .. tostring(val.UniqueID))
@@ -243,6 +245,18 @@ function SaveLoadHandler:ParseTableForVectors(tab)
243245

244246
end
245247

248+
function SaveLoadHandler:ParseTableForBoxes(tab)
249+
for k, v in pairs(tab) do
250+
if type(v) == "string" and string.find(v, "Box%(") then
251+
local vector = loadstring("return " .. v)();
252+
tab[k] = vector;
253+
elseif type(v) == "table" then
254+
self:ParseTableForBoxes(v);
255+
end
256+
end
257+
258+
end
259+
246260
function SaveLoadHandler:ParseTableForAreas(tab)
247261
for k, v in pairs(tab) do
248262
if type(v) == "string" and string.find(v, "SAVELOADHANDLERAREA_") then
@@ -289,6 +303,10 @@ function SaveLoadHandler:DeserializeTable(serializedTable, name)
289303
print("INFO: SaveLoadHandler is parsing this table for Vectors: " .. name);
290304
end
291305
self:ParseTableForVectors(tab);
306+
if name and SaveLoadHandler.verboseLogging then
307+
print("INFO: SaveLoadHandler is parsing this table for Boxes: " .. name);
308+
end
309+
self:ParseTableForBoxes(tab);
292310
if name and SaveLoadHandler.verboseLogging then
293311
print("INFO: SaveLoadHandler is parsing this table for Areas: " .. name);
294312
end

0 commit comments

Comments
 (0)