diff --git a/modules/game_battle/battle.lua b/modules/game_battle/battle.lua index 2f7daddea4..8a11cc1da8 100644 --- a/modules/game_battle/battle.lua +++ b/modules/game_battle/battle.lua @@ -13,24 +13,17 @@ BattleListInstance = nil BattleButtonPool = nil -- Utility functions -function table.copy(t) +function tableCopy(t) if type(t) ~= "table" then return t end local meta = getmetatable(t) local target = {} for k, v in pairs(t) do - target[k] = type(v) == "table" and table.copy(v) or v + target[k] = type(v) == "table" and tableCopy(v) or v end setmetatable(target, meta) return target end -function table.size(t) - if type(t) ~= "table" then return 0 end - local count = 0 - for _ in pairs(t) do count = count + 1 end - return count -end - -- Default filter settings local BATTLE_FILTERS = { ["sortAscByDisplayTime"] = true, @@ -127,7 +120,7 @@ function BattleListManager:restoreInstancesState() if instance and instance.window then if shouldRestoreSettings and oldSettings then local newSettingsKey = instance:getSettingsKey() - local settingsToRestore = table.copy(oldSettings) + local settingsToRestore = tableCopy(oldSettings) settingsToRestore.customName = data.name g_settings.mergeNode(newSettingsKey, settingsToRestore) @@ -456,7 +449,7 @@ function BattleListInstance:new(id, customName) instance.lastAge = 0 instance.name = customName or tr('Battle List') instance.settings = { - filters = table.copy(BATTLE_FILTERS), + filters = tableCopy(BATTLE_FILTERS), sortType = 'name', sortOrder = 'A', hidingFilters = false, @@ -473,7 +466,7 @@ end function BattleListInstance:loadFilters() local settings = g_settings.getNode(self:getSettingsKey()) if not settings or not settings['filters'] then - return table.copy(BATTLE_FILTERS) + return tableCopy(BATTLE_FILTERS) end return settings['filters'] end @@ -682,7 +675,7 @@ function BattleListInstance:clearAllConfigurations() end self.settings = { - filters = table.copy(BATTLE_FILTERS), + filters = tableCopy(BATTLE_FILTERS), sortType = 'name', sortOrder = 'A', hidingFilters = false,