Page 1 of 1

Reworking ActorProject:project to fix doQuake

Posted: Mon Jan 17, 2011 3:42 am
by yufra
The setting for this little issue is the Wyrmic talent Quake, particularly used when it is near the edges of the map. The issue is that core.fov.calc_circle does not currently check for the dimensions of the map, and so you can end up with coordinates that do not exist (either negative or beyond height/width). As a first pass, here is a Lua patch that should protect from this.

Code: Select all

Index: game/engines/default/engine/interface/ActorProject.lua
===================================================================
--- game/engines/default/engine/interface/ActorProject.lua	(revision 2410)
+++ game/engines/default/engine/interface/ActorProject.lua	(working copy)
@@ -85,6 +85,7 @@
 	end
 	if typ.ball and typ.ball > 0 then
 		core.fov.calc_circle(radius_x, radius_y, typ.ball, function(_, px, py)
+			if not game.level.map(px, py) then return true end
 			-- Deal damage: ball
 			addGrid(px, py)
 			if typ.block_radius and typ:block_radius(px, py) then return true end
@@ -92,6 +93,7 @@
 		addGrid(lx, ly)
 	elseif typ.cone and typ.cone > 0 then
 		core.fov.calc_beam(radius_x, radius_y, typ.cone, initial_dir, typ.cone_angle, function(_, px, py)
+			if not game.level.map(px, py) then return true end
 			-- Deal damage: cone
 			addGrid(px, py)
 			if typ.block_radius and typ:block_radius(px, py) then return true end
@@ -250,6 +252,7 @@
 
 	if typ.ball and typ.ball > 0 then
 		core.fov.calc_circle(rx, ry, typ.ball, function(_, px, py)
+			if not game.level.map(px, py) then return true end
 			-- Deal damage: ball
 			addGrid(px, py)
 			if typ.block_radius and typ:block_radius(px, py) then return true end
@@ -258,6 +261,7 @@
 	elseif typ.cone and typ.cone > 0 then
 		local initial_dir = lx and util.getDir(lx, ly, x, y) or 5
 		core.fov.calc_beam(rx, ry, typ.cone, initial_dir, typ.cone_angle, function(_, px, py)
+			if not game.level.map(px, py) then return true end
 			-- Deal damage: cone
 			addGrid(px, py)
 			if typ.block_radius and typ:block_radius(px, py) then return true end
Now it would be nice if the core.fov calculations were checking this, and am giving that a stab next. Segfaults here I come!

Re: Reworking ActorProject:project to fix doQuake

Posted: Mon Jan 17, 2011 9:52 am
by darkgod
I fixed it C side :)

Re: Reworking ActorProject:project to fix doQuake

Posted: Mon Jan 17, 2011 1:42 pm
by yufra
Great!