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;
|
* fading fix;
|
||||||
* fix in disable autosave;
|
* fix in disable autosave;
|
||||||
* disp fix;
|
* disp fix;
|
||||||
|
* savevars optimization;
|
||||||
|
|
||||||
-- Peter Kosyh <p.kosyh@gmail.com> Sat, 28 Aug 2010 19:47:00 +0300
|
-- 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_music();
|
||||||
set_sound();
|
set_sound();
|
||||||
timer:stop();
|
timer:stop();
|
||||||
|
variables = nil
|
||||||
init = function() -- null init function
|
init = function() -- null init function
|
||||||
end
|
end
|
||||||
for_each_object(function(k, o) -- destroy all objects
|
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
|
function isForSave(k, v, s) -- k - key, v - value, s -- parent table
|
||||||
local i,o
|
local i,o
|
||||||
if type(s.variables) == 'table' then
|
if type(s.variables_save) == 'table' and
|
||||||
for i,o in ipairs(s.variables) do
|
s.variables_save[k] then
|
||||||
if o == k then
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
if type(k) == 'function' then
|
if type(k) == 'function' then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
@ -24,7 +21,7 @@ function __vars_add(s, v, set)
|
||||||
elseif s.variables[k] then
|
elseif s.variables[k] then
|
||||||
error ("Variable overwrites variables object: "..tostring(k))
|
error ("Variable overwrites variables object: "..tostring(k))
|
||||||
elseif k ~= 'variable_type' then
|
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
|
if s[k] then
|
||||||
error ("Global variable conflict: "..tostring(k));
|
error ("Global variable conflict: "..tostring(k));
|
||||||
end
|
end
|
||||||
|
@ -52,6 +49,7 @@ function __vars_fill(v)
|
||||||
if type(v.variables) == 'table' then
|
if type(v.variables) == 'table' then
|
||||||
local k,o
|
local k,o
|
||||||
local vars = {}
|
local vars = {}
|
||||||
|
v.variables_save = {}
|
||||||
for k,o in pairs(v.variables) do
|
for k,o in pairs(v.variables) do
|
||||||
if tonumber(k) and type(o) == 'string' then
|
if tonumber(k) and type(o) == 'string' then
|
||||||
stead.table.insert(vars, o)
|
stead.table.insert(vars, o)
|
||||||
|
@ -63,6 +61,9 @@ function __vars_fill(v)
|
||||||
stead.table.insert(vars, k);
|
stead.table.insert(vars, k);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
for k,o in ipairs(vars) do
|
||||||
|
v.variables_save[o] = true
|
||||||
|
end
|
||||||
v.variables = vars;
|
v.variables = vars;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue