savevars optimization
This commit is contained in:
parent
34715f4074
commit
9c79407d69
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -4,6 +4,7 @@ instead (1.2.1) unstable; urgency=low
|
|||
* fading fix;
|
||||
* fix in disable autosave;
|
||||
* disp fix;
|
||||
* savevars optimization;
|
||||
|
||||
-- Peter Kosyh <p.kosyh@gmail.com> Sat, 28 Aug 2010 19:47:00 +0300
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
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
|
||||
if type(s.variables_save) == 'table' and
|
||||
s.variables_save[k] then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
if type(k) == 'function' then
|
||||
return false
|
||||
end
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue