From f19c3da957af2f8ce39fad73534348334a964b23 Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Thu, 14 Jun 2012 14:52:10 +0000 Subject: [PATCH] Detect and remove player clones automatically git-svn-id: http://svn.net-core.org/repos/t-engine4@5240 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/modules/tome/class/Game.lua | 13 +++++++++++++ game/modules/tome/class/Player.lua | 1 + 2 files changed, 14 insertions(+) diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua index d1269039b6..9bd5e3b9e3 100644 --- a/game/modules/tome/class/Game.lua +++ b/game/modules/tome/class/Game.lua @@ -879,6 +879,16 @@ function _M:changeLevel(lev, zone, params) end if popup then popup:done() end + + self:dieClonesDie() +end + +function _M:dieClonesDie() + if not self.level then return end + local p = self:getPlayer(true) + for uid, e in pairs(self.level.entities) do + if p.puuid == e.puuid and e ~= p then self.level:removeEntity(e) end + end end function _M:getPlayer(main) @@ -1045,6 +1055,9 @@ function _M:onTurn() self.log(self.calendar:getTimeDate(self.turn)) self.day_of_year = self.calendar:getDayOfYear(self.turn) end + + if self.turn % 500 ~= 0 then return end + self:dieClonesDie() end function _M:updateFOV() diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua index 1134511d38..05a34f529f 100644 --- a/game/modules/tome/class/Player.lua +++ b/game/modules/tome/class/Player.lua @@ -90,6 +90,7 @@ function _M:init(t, no_default) self.descriptor = self.descriptor or {} self.died_times = self.died_times or {} self.last_learnt_talents = self.last_learnt_talents or { class={}, generic={} } + self.puuid = self.puuid or util.uuid() end function _M:onBirth(birther) -- GitLab