From 5ff7d45f7f6dd5d75c45db2d9ad77cd6007b4fb0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 5 Jan 2022 00:39:09 +0100 Subject: [PATCH] - Duke/RR: better handling for one random kill scenario in the player movement code. Using the same appoach as EDuke32 - instead of outright killing the player it will first reset its position and retry the pushmove check. --- source/games/duke/src/player_d.cpp | 21 ++++++++++++++------- source/games/duke/src/player_r.cpp | 25 +++++++++++++++---------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 73c0b7a63..e14f8a120 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -2842,6 +2842,7 @@ void processinput_d(int snum) checklook(snum,actions); int ii = 40; + auto oldpos = p->opos; if (p->on_crane != nullptr) goto HORIZONLY; @@ -3072,25 +3073,31 @@ HORIZONLY: if (p->cursector != pact->sector()) ChangeActorSect(pact, p->cursector); - if (ud.clipping == 0) - j = (pushmove(&p->pos, &p->cursector, 164L, (4L << 8), (4L << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512); - else j = 0; - - if (ud.clipping == 0) + int retry = 0; + while (ud.clipping == 0) { - if (abs(pact->floorz - pact->ceilingz) < (48 << 8) || j) + int blocked; + blocked = (pushmove(&p->pos, &p->cursector, 164, (4 << 8), (4 << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512); + + if (abs(pact->floorz - pact->ceilingz) < (48 << 8) || blocked) { if (!(pact->sector()->lotag & 0x8000) && (isanunderoperator(pact->sector()->lotag) || isanearoperator(pact->sector()->lotag))) fi.activatebysector(pact->sector(), pact); - if (j) + if (blocked) { + if (!retry++) + { + p->pos = p->opos = oldpos; + continue; + } quickkill(p); return; } } else if (abs(fz - cz) < (32 << 8) && isanunderoperator(psectp->lotag)) fi.activatebysector(psectp, pact); + break; } // center_view diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index dee0c624f..8b7b569bd 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3558,6 +3558,8 @@ void processinput_r(int snum) checklook(snum, actions); p->apply_seasick(1); + auto oldpos = p->opos; + if (p->on_crane != nullptr) goto HORIZONLY; @@ -3912,31 +3914,34 @@ HORIZONLY: if (p->cursector != pact->sector()) ChangeActorSect(pact, p->cursector); - int j; - if (ud.clipping == 0) + int retry = 0; + while (ud.clipping == 0) { + int blocked; if (pact->spr.clipdist == 64) - j = (pushmove(&p->pos, &p->cursector, 128L, (4L << 8), (4L << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512); + blocked = (pushmove(&p->pos, &p->cursector, 128, (4 << 8), (4 << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512); else - j = (pushmove(&p->pos, &p->cursector, 16L, (4L << 8), (4L << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512); - } - else j = 0; + blocked = (pushmove(&p->pos, &p->cursector, 16, (4 << 8), (4 << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512); - if (ud.clipping == 0) - { - if (abs(pact->floorz - pact->ceilingz) < (48 << 8) || j) + if (abs(pact->floorz - pact->ceilingz) < (48 << 8) || blocked) { if (!(pact->sector()->lotag & 0x8000) && (isanunderoperator(pact->sector()->lotag) || isanearoperator(pact->sector()->lotag))) fi.activatebysector(pact->sector(), pact); - if (j) + if (blocked) { + if (!retry++) + { + p->pos = p->opos = oldpos; + continue; + } quickkill(p); return; } } else if (abs(fz - cz) < (32 << 8) && isanunderoperator(psectp->lotag)) fi.activatebysector(psectp, pact); + break; } if (ud.clipping == 0 && p->cursector->ceilingz > (p->cursector->floorz - (12 << 8)))