diff --git a/debian/changelog b/debian/changelog index 2f8ebfb..e7bce47 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,7 @@ instead (1.2.1) unstable; urgency=low * fading fix; * fix in disable autosave; * disp fix; + * savevars optimization; -- Peter Kosyh Sat, 28 Aug 2010 19:47:00 +0300 diff --git a/stead/stead.lua b/stead/stead.lua index 051d60e..1e26cae 100644 --- a/stead/stead.lua +++ b/stead/stead.lua @@ -1701,6 +1701,7 @@ function gamefile(file, forget) set_music(); set_sound(); timer:stop(); + variables = nil init = function() -- null init function end for_each_object(function(k, o) -- destroy all objects diff --git a/stead/vars.lua b/stead/vars.lua index d240068..8c147f5 100644 --- a/stead/vars.lua +++ b/stead/vars.lua @@ -1,11 +1,8 @@ function isForSave(k, v, s) -- k - key, v - value, s -- parent table local i,o - if type(s.variables) == 'table' then - for i,o in ipairs(s.variables) do - if o == k then - return true - end - end + if type(s.variables_save) == 'table' and + s.variables_save[k] then + return true end if type(k) == 'function' then return false @@ -24,7 +21,7 @@ function __vars_add(s, v, set) elseif s.variables[k] then error ("Variable overwrites variables object: "..tostring(k)) elseif k ~= 'variable_type' then - if set and (type(o) == 'string' or type(o) == 'boolean' or type(o) == 'number') then + if set and not isObject(o) then if s[k] then error ("Global variable conflict: "..tostring(k)); end @@ -52,6 +49,7 @@ function __vars_fill(v) if type(v.variables) == 'table' then local k,o local vars = {} + v.variables_save = {} for k,o in pairs(v.variables) do if tonumber(k) and type(o) == 'string' then stead.table.insert(vars, o) @@ -63,6 +61,9 @@ function __vars_fill(v) stead.table.insert(vars, k); end end + for k,o in ipairs(vars) do + v.variables_save[o] = true + end v.variables = vars; end end