From 0aba25d6f8a2247fd3cd247571dbf9147764f0a0 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Fri, 26 Dec 2008 16:25:49 +0000 Subject: [PATCH] clamp player push to non-zero range git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4070 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/physics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 98f1e519..29730415 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -513,7 +513,7 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) if(pl->type==ENT_PLAYER && hitplayer) { float dx = hitplayer->o.x-pl->o.x, dy = hitplayer->o.y-pl->o.y, - push = dx*d.x + dy*d.y, + push = (dx*d.x + dy*d.y)/max(dx*dx + dy*dy, 1e-3f), px = push*dx, py = push*dy; pl->o.x -= f*px; pl->o.y -= f*py;