diff --git a/game/engines/default/engine/Savefile.lua b/game/engines/default/engine/Savefile.lua index 8a4207f93f01361bb4f091f538366181052a66a6..79f6eecbf7fcee71883ea637c235bc7b5ab36a43 100644 --- a/game/engines/default/engine/Savefile.lua +++ b/game/engines/default/engine/Savefile.lua @@ -101,6 +101,7 @@ function _M:saveObject(obj, zip) local tbl = table.remove(self.process) self.tables[tbl] = self:getFileName(tbl) zip:add(self:getFileName(tbl), tbl:save()) + savefile_pipe.current_nb = savefile_pipe.current_nb + 1 end return self.tables[obj] end diff --git a/game/engines/default/engine/SavefilePipe.lua b/game/engines/default/engine/SavefilePipe.lua index 2dbb9dc3426eeeab9877cacdd6bd382281d30587..5530a76168178e6153c0fd31f73f089735fc0dfe 100644 --- a/game/engines/default/engine/SavefilePipe.lua +++ b/game/engines/default/engine/SavefilePipe.lua @@ -39,6 +39,8 @@ function _M:init(class, max_before_wait) self.pipe = {} self.max_before_wait = max_before_wait or 4 self.co = nil + self.current_nb = 0 + self.total_nb = 1 end --- Push a savefile request @@ -53,7 +55,13 @@ function _M:push(savename, type, object, class) local Savefile = require(class) local id = Savefile["nameSave"..type:lower():capitalize()](Savefile, object) - self.pipe[#self.pipe+1] = {id=id, savename = savename, type=type, object=object:cloneFull(), baseobject=object, class=class, saveversion=game:saveVersion("new")} + if #self.pipe == 0 then savefile_pipe.current_nb = 0 end + + local clone, nb = object:cloneFull() + self.pipe[#self.pipe+1] = {id=id, savename = savename, type=type, object=clone, nb_objects=nb, baseobject=object, class=class, saveversion=game:saveVersion("new")} + local total_nb = 0 + for i, p in ipairs(self.pipe) do total_nb = total_nb + p.nb_objects end + self.total_nb = total_nb if not self.co or coroutine.status(self.co) == "dead" then self.co = coroutine.create(function() return self:doThread() end) game:registerCoroutine("savefilepipe", self.co) @@ -78,7 +86,7 @@ function _M:doThread() local Savefile = require(p.class) local o = p.object - print("[SAVEFILE PIPE] new save running in the pipe:", p.savename, p.type, "::", p.id, "::", p.baseobject, "=>", p.object) + print("[SAVEFILE PIPE] new save running in the pipe:", p.savename, p.type, "::", p.id, "::", p.baseobject, "=>", p.object, "("..p.nb_objects..")") local save = Savefile.new(p.savename, true) o.__saved_saveversion = p.saveversion @@ -101,7 +109,10 @@ function _M:forceWait() popup.__showup = nil core.display.forceRedraw() + local cnt = 0 while coroutine.status(self.co) ~= "dead" do + cnt = cnt + 1 + if cnt == 1000 then core.display.forceRedraw() if game:getPlayer() then game:getPlayer().changed = true end cnt = 0 end coroutine.resume(self.co) end diff --git a/game/engines/default/engine/class.lua b/game/engines/default/engine/class.lua index adb6ba7a415c44619d76a9887d41fd174798a61c..4a257e501d82dac2b8dc0e47d95f21c63c3d5ae1 100644 --- a/game/engines/default/engine/class.lua +++ b/game/engines/default/engine/class.lua @@ -113,31 +113,34 @@ function _M:clone(t) end -local function clonerecursfull(clonetable, d, allow_cloned) +local function clonerecursfull(clonetable, d) + local nb = 0 + local add local n = {} clonetable[d] = n for k, e in pairs(d) do local nk, ne = k, e if clonetable[k] then nk = clonetable[k] - elseif type(k) == "table" then nk = clonerecursfull(clonetable, k) + elseif type(k) == "table" then nk, add = clonerecursfull(clonetable, k) nb = nb + add end if clonetable[e] then ne = clonetable[e] - elseif type(e) == "table" and (type(k) ~= "string" or k ~= "__threads") then ne = clonerecursfull(clonetable, e) + elseif type(e) == "table" and (type(k) ~= "string" or k ~= "__threads") then ne, add = clonerecursfull(clonetable, e) nb = nb + add end n[nk] = ne end setmetatable(n, getmetatable(d)) if n.cloned and n.__CLASSNAME then n:cloned(d) end - return n + if n.__CLASSNAME then nb = nb + 1 end + return n, nb end --- Clones the object, all subobjects without cloning twice a subobject -function _M:cloneFull(allow_cloned) +-- @return the clone and the number of cloned objects +function _M:cloneFull() local clonetable = {} - local n = clonerecursfull(clonetable, self, allow_cloned) - return n + return clonerecursfull(clonetable, self) end --- Replaces the object with an other, by copying (not deeply) diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua index 21c2f7585a33787eafb98d881985d2aef535a0c9..71f78732d24d573d0971db9298185de7e5d6b335 100644 --- a/game/modules/tome/class/Game.lua +++ b/game/modules/tome/class/Game.lua @@ -462,6 +462,7 @@ function _M:tick() -- (since display is on a set FPS while tick() ticks as much as possible -- engine.GameEnergyBased.tick(self) end + if savefile_pipe.saving then self.player.changed = true end if self.paused and not savefile_pipe.saving then return true end end diff --git a/game/modules/tome/class/PlayerDisplay.lua b/game/modules/tome/class/PlayerDisplay.lua index fdc31f2e45b5ab1d558338b72943e667ac722de0..ca932cf2aeebcd2d92a76f51a69e97f9eaded4cc 100644 --- a/game/modules/tome/class/PlayerDisplay.lua +++ b/game/modules/tome/class/PlayerDisplay.lua @@ -152,7 +152,13 @@ function _M:display() self:mouseTooltip(self.TOOLTIP_HATE, s:drawColorStringBlended(self.font, ("#F53CBE#Hate: #ffffff#%.1f/%d"):format(player:getHate(), 10), x, h, 255, 255, 255)) h = h + self.font_h end - if savefile_pipe.saving then h = h + self.font_h s:drawColorStringBlended(self.font, "#YELLOW#Saving...", x, h, 255, 255, 255) h = h + self.font_h end + if savefile_pipe.saving then + h = h + self.font_h + s:erase(0x68 / 6, 0x72 / 6, 0x00 / 6, 255, self.bars_x, h, self.bars_w, self.font_h) + s:erase(0x95 / 3, 0xa2 / 3, 0x80 / 3, 255, self.bars_x, h, self.bars_w * savefile_pipe.current_nb / savefile_pipe.total_nb, self.font_h) + s:drawColorStringBlended(self.font, ("#YELLOW#Saving...: %d%%"):format(100 * savefile_pipe.current_nb / savefile_pipe.total_nb), x, h, 255, 255, 255) + h = h + self.font_h + end h = h + self.font_h for tid, act in pairs(player.sustain_talents) do diff --git a/game/modules/tome/data/talents/spells/stone.lua b/game/modules/tome/data/talents/spells/stone.lua index c35060950821b4359fe99d94a70a074726592a0f..ce4130de90c5489c7917cc76815d05bd420e568c 100644 --- a/game/modules/tome/data/talents/spells/stone.lua +++ b/game/modules/tome/data/talents/spells/stone.lua @@ -82,8 +82,6 @@ newTalent{ particle = self:addParticles(Particles.new("stone_skin", 1)), move = self:addTemporaryValue("never_move", 1), knock = self:addTemporaryValue("knockback_immune", kb), - detect = self:addTemporaryValue("detect_range", rad), - tremor = self:addTemporaryValue("detect_actor", 1), cdred = self:addTemporaryValue("talent_cd_reduction", { [self.T_STALACTITIC_MISSILES] = cdr, [self.T_STRIKE] = cdr, @@ -100,8 +98,6 @@ newTalent{ self:removeParticles(p.particle) self:removeTemporaryValue("never_move", p.move) self:removeTemporaryValue("knockback_immune", p.knock) - self:removeTemporaryValue("detect_actor", p.tremor) - self:removeTemporaryValue("detect_range", p.detect) self:removeTemporaryValue("talent_cd_reduction", p.cdred) self:removeTemporaryValue("resists", p.res) return true @@ -111,9 +107,8 @@ newTalent{ Your stoned form and your affinity with the earth while the spell is active has the following effects: * Reduces the cooldown of Stalactitic Missiles, Earthquake, and Strike by %d * Grants %d%% Fire Resistance, %d%% Lightning Resistance, %d%% Physical Resistance, and %d%% Knockback Resistance - * Sense foes around you in a radius of %d. Resistances and Sense radius scale with the Magic Stat.]]) - :format((self:getTalentLevel(t)/2), self:combatTalentSpellDamage(t, 5, 80), self:combatTalentSpellDamage(t, 5, 50), self:combatTalentSpellDamage(t, 5, 20), (self:getTalentLevel(t)*10), (5 + self:combatSpellpower(0.1) * self:getTalentLevel(t))) + :format((self:getTalentLevel(t)/2), self:combatTalentSpellDamage(t, 5, 80), self:combatTalentSpellDamage(t, 5, 50), self:combatTalentSpellDamage(t, 5, 20), (self:getTalentLevel(t)*10)) end, }