diff --git a/source/build/include/buildtypes.h b/source/build/include/buildtypes.h index d973786d6..2c20ec8a1 100644 --- a/source/build/include/buildtypes.h +++ b/source/build/include/buildtypes.h @@ -139,6 +139,9 @@ struct walltype sectortype* nextSector() const; walltype* nextWall() const; walltype* point2Wall() const; + vec2_t delta() const { return point2Wall()->pos - pos; } + int deltax() const { return point2Wall()->x - x; } + int deltay() const { return point2Wall()->y - y; } bool twoSided() const { return nextsector >= 0; } #if 0 diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index e4b354f89..7d1cfffe2 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -1299,10 +1299,10 @@ void bounce(DDukeActor* actor) auto sectp = s->sector(); - int k = sectp->wallptr; - int l = wall[k].point2; - int daang = getangle(wall[l].x - wall[k].x, wall[l].y - wall[k].y); + auto delta = sectp->firstWall()->delta(); + int daang = getangle(delta.x, delta.y); + int k, l; if (s->z < (actor->floorz + actor->ceilingz) >> 1) k = sectp->ceilingheinum; else @@ -1513,12 +1513,10 @@ bool queball(DDukeActor *actor, int pocket, int queball, int stripeball) if (j == kHitWall) { - j = coll.index; - int k = getangle( - wall[wall[j].point2].x - wall[j].x, - wall[wall[j].point2].y - wall[j].y); - s->ang = ((k << 1) - s->ang) & 2047; - } + auto delta = coll.wall()->delta(); + int k = getangle(delta.x, delta.y); + s->ang = ((k << 1) - s->ang) & 2047; + } else if (j == kHitSprite) { fi.checkhitsprite(actor, coll.actor);