From 38d64fc437caa11307fb85c5a11ae65bdc7d577f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 21 Nov 2021 09:15:21 +0100 Subject: [PATCH] spritetype::setsector --- source/build/include/build.h | 6 ++++++ source/build/include/buildtypes.h | 1 + source/games/duke/src/actors.cpp | 4 ++-- source/games/duke/src/player_d.cpp | 4 ++-- source/games/duke/src/premap_d.cpp | 1 - 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index fc7855227..9f38af6a4 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -717,6 +717,12 @@ inline sectortype* spritetype::sector() const return !validSectorIndex(sectnum)? nullptr : &::sector[sectnum]; } +inline void spritetype::setsector(sectortype* sect) +{ + // place for asserts. + sectnum = sect? ::sector.IndexOf(sect) : -1; +} + inline bool spritetype::insector() const { return validSectorIndex(sectnum); diff --git a/source/build/include/buildtypes.h b/source/build/include/buildtypes.h index ebc40312b..8bdf6cf5f 100644 --- a/source/build/include/buildtypes.h +++ b/source/build/include/buildtypes.h @@ -451,6 +451,7 @@ struct spritetype sectortype* sector() const; bool insector() const; + void setsector(sectortype*); }; using tspritetype = spritetype; diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index ebdb5088c..2a4534a2f 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -1504,12 +1504,12 @@ bool queball(DDukeActor *actor, int pocket, int queball, int stripeball) } Collision coll; - int sect = s->sectnum; + auto sect = s->sector(); int j = clipmove_ex(&s->pos, §, (MulScale(s->xvel, bcos(s->ang), 14) * TICSPERFRAME) << 11, (MulScale(s->xvel, bsin(s->ang), 14) * TICSPERFRAME) << 11, 24L, (4 << 8), (4 << 8), CLIPMASK1, coll); - s->sectnum = sect; + s->setsector(sect); if (j == kHitWall) { diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 87b9e69cb..51bedb288 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -204,7 +204,7 @@ static void shootflamethrowerflame(DDukeActor* actor, int p, int sx, int sy, int spawned->s->x = sx + bsin(sa + 630) / 448; spawned->s->y = sy + bsin(sa + 112) / 448; spawned->s->z = sz - 256; - spawned->s->sectnum = s->sectnum; + spawned->s->setsector(s->sector()); spawned->s->cstat = 0x80; spawned->s->ang = sa; spawned->s->xrepeat = 2; @@ -1101,7 +1101,7 @@ void shoot_d(DDukeActor* actor, int atwith) auto k = spawn(actor, atwith); if (k) { - k->s->sectnum = sectnum(sect); + k->s->setsector(sect); k->s->x = sx; k->s->y = sy; k->s->z = sz; diff --git a/source/games/duke/src/premap_d.cpp b/source/games/duke/src/premap_d.cpp index ea7f19e2c..95ee1563a 100644 --- a/source/games/duke/src/premap_d.cpp +++ b/source/games/duke/src/premap_d.cpp @@ -391,7 +391,6 @@ void prelevel_d(int g) I_Error("Too many mirrors (64 max.)"); if (sectp && sectp->ceilingpicnum != MIRROR) { - assert(wallnum(&wal) > 0); sectp->ceilingpicnum = MIRROR; sectp->floorpicnum = MIRROR; mirrorwall[mirrorcnt] = &wal;