diff --git a/scripts/commandHandler.lua b/scripts/commandHandler.lua index 116f517170..045878b48c 100644 --- a/scripts/commandHandler.lua +++ b/scripts/commandHandler.lua @@ -1316,7 +1316,7 @@ function commandHandler.CreateRecord(pid, cmd) -- We don't want to insert a direct reference to the storedTable in our record data, -- so create a copy of the storedTable and insert that instead - local savedTable = tableHelper.shallowCopy(storedTable) + local savedTable = tableHelper.deepCopy(storedTable) -- The id and the savedTable will form a key-value pair, so there's no need to keep -- the id in the savedTable as well diff --git a/scripts/database.lua b/scripts/database.lua index 8d9579ffb1..53002b08ef 100644 --- a/scripts/database.lua +++ b/scripts/database.lua @@ -147,7 +147,7 @@ function Database:SavePlayer(dbPid, data) self:DeleteRows(tableName, string.format("WHERE dbPid = '%s'", dbPid)) for slot, slotObject in pairs(categoryTable) do - local tempTable = tableHelper.shallowCopy(slotObject) + local tempTable = tableHelper.deepCopy(slotObject) tempTable.dbPid = dbPid tempTable.slot = slot self:InsertRow(tableName, tempTable) @@ -156,7 +156,7 @@ function Database:SavePlayer(dbPid, data) local tableName = "player_" .. category tes3mp.LogMessage(enumerations.log.INFO, "Saving category " .. category) - local tempTable = tableHelper.shallowCopy(categoryTable) + local tempTable = tableHelper.deepCopy(categoryTable) tempTable.dbPid = dbPid self:InsertRow(tableName, tempTable) end @@ -207,7 +207,7 @@ function Database:SaveWorld(data) for category, categoryTable in pairs(data) do local tableName = "world_" .. category - local tempTable = tableHelper.shallowCopy(categoryTable) + local tempTable = tableHelper.deepCopy(categoryTable) tempTable.rowid = 0 self:InsertRow(tableName, tempTable) end diff --git a/scripts/recordstore/base.lua b/scripts/recordstore/base.lua index c20e6e4099..da6747a94a 100644 --- a/scripts/recordstore/base.lua +++ b/scripts/recordstore/base.lua @@ -13,7 +13,7 @@ BaseRecordStore.defaultData = function BaseRecordStore:__init(storeType) - self.data = tableHelper.shallowCopy(self.defaultData) + self.data = tableHelper.deepCopy(self.defaultData) self.storeType = storeType end @@ -25,7 +25,7 @@ function BaseRecordStore:EnsureDataStructure() for key, value in pairs(self.defaultData) do if self.data[key] == nil then - self.data[key] = tableHelper.shallowCopy(value) + self.data[key] = tableHelper.deepCopy(value) end end end @@ -331,7 +331,7 @@ end function BaseRecordStore:SaveGeneratedRecords(recordTable) for recordId, record in pairs(recordTable) do - self.data.generatedRecords[recordId] = tableHelper.shallowCopy(record) + self.data.generatedRecords[recordId] = tableHelper.deepCopy(record) -- Retain the quantity in the input table (when applicable) so we can check it -- elsewhere, but remove it from here