From e2f9d1272e77013ff05f4734d0a28ff201e98c56 Mon Sep 17 00:00:00 2001
From: DarkGod <darkgod@net-core.org>
Date: Sun, 22 Sep 2013 22:59:45 +0200
Subject: [PATCH] Wraithform now teleports if you end up in a wall

fix crash
---
 game/modules/tome/data/talents/corruptions/shadowflame.lua | 1 +
 game/modules/tome/data/timed_effects/magical.lua           | 3 +++
 src/particles.c                                            | 1 +
 3 files changed, 5 insertions(+)

diff --git a/game/modules/tome/data/talents/corruptions/shadowflame.lua b/game/modules/tome/data/talents/corruptions/shadowflame.lua
index 61194386df..fcca631e41 100644
--- a/game/modules/tome/data/talents/corruptions/shadowflame.lua
+++ b/game/modules/tome/data/talents/corruptions/shadowflame.lua
@@ -33,6 +33,7 @@ newTalent{
 	info = function(self, t)
 		return ([[Turn into a wraith, allowing you to walk through walls (but not preventing suffocation) for %d turns.
 		Also increases your Defense and Armour by %d and %d, respectively.
+		If you are still in a wall when the effect ends you will randomly teleport.
 		The bonuses will increase with your Spellpower.]]):
 		format(t.getDuration(self, t), self:combatTalentSpellDamage(t, 5, 19), self:combatTalentSpellDamage(t, 5, 15))
 	end,
diff --git a/game/modules/tome/data/timed_effects/magical.lua b/game/modules/tome/data/timed_effects/magical.lua
index 963931d1af..b2563f4ad0 100644
--- a/game/modules/tome/data/timed_effects/magical.lua
+++ b/game/modules/tome/data/timed_effects/magical.lua
@@ -954,6 +954,9 @@ newEffect{
 		self:removeTemporaryValue("can_pass", eff.tmpid)
 		self:removeTemporaryValue("combat_def", eff.defid)
 		self:removeTemporaryValue("combat_armor", eff.armid)
+		if not self:canMove(self.x, self.y) then
+			self:teleportRandom(self.x, self.y, 50)
+		end
 	end,
 }
 
diff --git a/src/particles.c b/src/particles.c
index 3482b2fffe..f84515aff5 100644
--- a/src/particles.c
+++ b/src/particles.c
@@ -204,6 +204,7 @@ static int particles_die(lua_State *L)
 // Runs into main thread
 static void particles_draw(particles_type *ps, float x, float y, float zoom) 
 {
+	if (!ps->alive || !ps->vertices || !ps->colors || !ps->texcoords) return;
 	GLfloat *vertices = ps->vertices;
 	GLfloat *colors = ps->colors;
 	GLshort *texcoords = ps->texcoords;
-- 
GitLab