From 8badb7f9f4c9a057c4d70ba330a8a034c2d53afe Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Thu, 16 Sep 2010 14:15:00 +0000
Subject: [PATCH] Can not teleport forward in Mount Doom

git-svn-id: http://svn.net-core.org/repos/t-engine4@1231 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/engines/default/engine/Entity.lua        |  2 ++
 game/engines/default/engine/utils.lua         | 20 +++++++++++--------
 game/modules/tome/class/Actor.lua             |  4 +++-
 .../tome/data/zones/mount-doom/zone.lua       |  3 ++-
 4 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/game/engines/default/engine/Entity.lua b/game/engines/default/engine/Entity.lua
index 0d1a702f87..5c2ed05d8a 100644
--- a/game/engines/default/engine/Entity.lua
+++ b/game/engines/default/engine/Entity.lua
@@ -1,3 +1,4 @@
+
 -- TE4 - T-Engine 4
 -- Copyright (C) 2009, 2010 Nicolas Casalini
 --
@@ -240,6 +241,7 @@ function _M:getEntityFinalSurface(tiles, w, h)
 		if mos[i] then list[#list+1] = mos[i] end
 	end
 	local tex = core.map.mapObjectsToTexture(w, h, unpack(list))
+	if not tex then return nil end
 	_M.__mo_final_repo[self] = _M.__mo_final_repo[self] or {}
 	_M.__mo_final_repo[self][id] = {surface=tex:toSurface(), tex=tex}
 	return _M.__mo_final_repo[self][id].surface, _M.__mo_final_repo[self][id].tex
diff --git a/game/engines/default/engine/utils.lua b/game/engines/default/engine/utils.lua
index 047210ac7c..e32f89d4da 100644
--- a/game/engines/default/engine/utils.lua
+++ b/game/engines/default/engine/utils.lua
@@ -276,10 +276,12 @@ getmetatable(tmps).__index.drawColorString = function(s, font, str, x, y, r, g,
 			local e = __uids[uid]
 			if e then
 				local surf = e:getEntityFinalSurface(game.level.map.tiles, font:lineSkip(), font:lineSkip())
-				local w, h = surf:getSize()
-				s:merge(surf, x, y)
-				if h > max_h then max_h = h end
-				x = x + (w or 0)
+				if surf then
+					local w, h = surf:getSize()
+					s:merge(surf, x, y)
+					if h > max_h then max_h = h end
+					x = x + (w or 0)
+				end
 			end
 		elseif fontstyle then
 			font:setStyle(fontstyle)
@@ -328,10 +330,12 @@ getmetatable(tmps).__index.drawColorStringBlended = function(s, font, str, x, y,
 			local e = __uids[uid]
 			if e then
 				local surf = e:getEntityFinalSurface(game.level.map.tiles, font:lineSkip(), font:lineSkip())
-				local w, h = surf:getSize()
-				s:merge(surf, x, y)
-				if h > max_h then max_h = h end
-				x = x + (w or 0)
+				if surf then
+					local w, h = surf:getSize()
+					s:merge(surf, x, y)
+					if h > max_h then max_h = h end
+					x = x + (w or 0)
+				end
 			end
 		elseif fontstyle then
 			font:setStyle(fontstyle)
diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua
index 9c60d59da9..ab0b23b38a 100644
--- a/game/modules/tome/class/Actor.lua
+++ b/game/modules/tome/class/Actor.lua
@@ -322,7 +322,9 @@ end
 -- @param min_dist the minimun radius of of the effect, will never teleport closer. Defaults to 0 if not set
 -- @return true if the teleport worked
 function _M:teleportRandom(x, y, dist, min_dist)
-
+	if game.level.data.no_teleport_south and y + dist > self.y then
+		y = self.y - dist
+	end
 	return engine.Actor.teleportRandom(self, x, y, dist, min_dist)
 end
 
diff --git a/game/modules/tome/data/zones/mount-doom/zone.lua b/game/modules/tome/data/zones/mount-doom/zone.lua
index b94b9deb4f..7b787b986d 100644
--- a/game/modules/tome/data/zones/mount-doom/zone.lua
+++ b/game/modules/tome/data/zones/mount-doom/zone.lua
@@ -30,6 +30,7 @@ return {
 	persistant = "zone",
 	no_level_connectivity = true,
 	no_worldport = true,
+	no_teleport_south = true,
 	ambiant_music = "Hold the Line.ogg",
 	generator =  {
 		map = {
@@ -54,7 +55,7 @@ return {
 	},
 
 	post_process = function(level)
-		level.turn_counter = 700 * 10
+		level.turn_counter = 640 * 10
 	end,
 
 	on_enter = function(lev, old_lev, newzone)
-- 
GitLab