From ce323e4ba3b350b00981248f146acff103488f75 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Thu, 11 Aug 2011 14:35:01 +0000
Subject: [PATCH] Dying while recalling will cancel the recall

git-svn-id: http://svn.net-core.org/repos/t-engine4@4106 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/class/Player.lua        |  5 ++++-
 game/modules/tome/data/timed_effects.lua  | 16 ++++++++++++----
 game/modules/tome/dialogs/DeathDialog.lua |  4 ++--
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua
index 8b5e52bda1..9981341f42 100644
--- a/game/modules/tome/class/Player.lua
+++ b/game/modules/tome/class/Player.lua
@@ -116,7 +116,10 @@ function _M:onEnterLevel(zone, level)
 	-- Cancel effects
 	local effs = {}
 	for eff_id, p in pairs(self.tmp) do
-		if self.tempeffect_def[eff_id].cancel_on_level_change then effs[#effs+1] = eff_id end
+		if self.tempeffect_def[eff_id].cancel_on_level_change then
+			effs[#effs+1] = eff_id
+			if type(self.tempeffect_def[eff_id].cancel_on_level_change) == "function" then self.tempeffect_def[eff_id].cancel_on_level_change(self, p)  end
+		end
 	end
 	for i, eff_id in ipairs(effs) do self:removeEffect(eff_id) end
 end
diff --git a/game/modules/tome/data/timed_effects.lua b/game/modules/tome/data/timed_effects.lua
index f6417eb199..8559071630 100644
--- a/game/modules/tome/data/timed_effects.lua
+++ b/game/modules/tome/data/timed_effects.lua
@@ -2396,14 +2396,18 @@ newEffect{
 	long_desc = function(self, eff) return "The target is waiting to be recalled back to the worldmap." end,
 	type = "magical",
 	status = "beneficial",
+	cancel_on_level_change = true,
 	parameters = { },
 	activate = function(self, eff)
+		eff.leveid = game.zone.short_name.."-"..game.level.level
 	end,
 	deactivate = function(self, eff)
 		if eff.allow_override or (self:canBe("worldport") and not self:attr("never_move")) then
 			game:onTickEnd(function()
-				game.logPlayer(self, "You are yanked out of this place!")
-				game:changeLevel(1, eff.where or game.player.last_wilderness)
+				if eff.leveid == game.zone.short_name.."-"..game.level.level then
+					game.logPlayer(self, "You are yanked out of this place!")
+					game:changeLevel(1, eff.where or game.player.last_wilderness)
+				end
 			end)
 		else
 			game.logPlayer(self, "Space restabilizes around you.")
@@ -2417,8 +2421,10 @@ newEffect{
 	long_desc = function(self, eff) return "The target is waiting to be recalled back to Angolwen." end,
 	type = "magical",
 	status = "beneficial",
+	cancel_on_level_change = true,
 	parameters = { },
 	activate = function(self, eff)
+		eff.leveid = game.zone.short_name.."-"..game.level.level
 	end,
 	deactivate = function(self, eff)
 		local seen = false
@@ -2434,8 +2440,10 @@ newEffect{
 
 		if self:canBe("worldport") and not self:attr("never_move") then
 			game:onTickEnd(function()
-				game.logPlayer(self, "You are yanked out of this place!")
-				game:changeLevel(1, "town-angolwen")
+				if eff.leveid == game.zone.short_name.."-"..game.level.level then
+					game.logPlayer(self, "You are yanked out of this place!")
+					game:changeLevel(1, "town-angolwen")
+				end
 			end)
 		else
 			game.logPlayer(self, "Space restabilizes around you.")
diff --git a/game/modules/tome/dialogs/DeathDialog.lua b/game/modules/tome/dialogs/DeathDialog.lua
index bed66ee135..dafec81129 100644
--- a/game/modules/tome/dialogs/DeathDialog.lua
+++ b/game/modules/tome/dialogs/DeathDialog.lua
@@ -35,7 +35,7 @@ function _M:init(actor)
 
 	self:generateList()
 	if self.dont_show then return end
-	game:saveGame()
+	if not config.settings.cheat then game:saveGame() end
 
 	self.c_desc = Textzone.new{width=self.iw, auto_height=true, text=[[You have #LIGHT_RED#died#LAST#!
 Death in ToME is usually permanent, but if you have a means of resurrection it will be proposed in the menu below.
@@ -161,7 +161,7 @@ function _M:eidolonPlane()
 
 		game.log("#LIGHT_RED#From the brink of death you seem to be yanked to another plane.")
 		game.player:updateMainShader()
-		game:saveGame()
+		if not config.settings.cheat then game:saveGame() end
 	end)
 	return true
 end
-- 
GitLab