From cf548e055e8679816a129afa779f523d7a820bad Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 9 Aug 2020 16:24:48 +1000 Subject: [PATCH] - clamp player sprite's xvel between 0 and 512 to stop it going into the negative with rapid posx/posy changes due to teleporting. * With steroids and a controller (controllers have a slightly higher max fvel/svel than a keyboard), I could not get xvel to exceed 503. * Fixes #123. --- source/games/duke/src/player_d.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 14cc6cb72..4fbfdaefc 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -2742,8 +2742,7 @@ void processinput_d(int snum) playerweaponsway(p, s); - s->xvel = - ksqrt((p->posx - p->bobposx) * (p->posx - p->bobposx) + (p->posy - p->bobposy) * (p->posy - p->bobposy)); + s->xvel = clamp(ksqrt((p->posx - p->bobposx) * (p->posx - p->bobposx) + (p->posy - p->bobposy) * (p->posy - p->bobposy)), 0, 512); if (p->on_ground) p->bobcounter += sprite[p->i].xvel >> 1; backuppos(p, ud.clipping == 0 && (sector[p->cursectnum].floorpicnum == MIRROR || p->cursectnum < 0 || p->cursectnum >= MAXSECTORS));