diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index e5aef3887..bfaf29da8 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -153,7 +153,6 @@ int16_t pointhighlight=-1, linehighlight=-1, highlightcnt=0; static int16_t numhits; -bool inpreparemirror = 0; // diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 32167b19d..11a2ee4d6 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -41,6 +41,7 @@ typedef struct { static_assert(sizeof(vec3d_t) == sizeof(double) * 3); int32_t xyaspect = -1; +bool inpreparemirror = 0; diff --git a/source/games/sw/src/game.cpp b/source/games/sw/src/game.cpp index 19d525dc4..b895cebb6 100644 --- a/source/games/sw/src/game.cpp +++ b/source/games/sw/src/game.cpp @@ -419,7 +419,6 @@ void TerminateLevel(void) if (!currentLevel) return; int i, stat, pnum, ndx; - SECT_USERp* sectu; // Free any track points for (ndx = 0; ndx < MAX_TRACKS; ndx++) @@ -456,7 +455,6 @@ void TerminateLevel(void) } // Free SectUser memory - for (auto& su : SectUser) su.Clear(); TRAVERSE_CONNECT(pnum) { diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 25df11821..49f6a3997 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1481,23 +1481,6 @@ enum ShrapType SHRAP_USER_DEFINED = 99 }; -typedef struct SECT_USER -{ - int _flags; - int depth_fixed; - short stag, // ST? tag number - for certain things it helps to know it - ang, - height, - speed, - damage, - number; // usually used for matching number - uint8_t flags2; -} *SECT_USERp; - -extern TPointer SectUser[MAXSECTORS]; -SECT_USERp SpawnSectUser(short sectnum); - - # define CallocMem(size, num) M_Calloc(size, num) # define FreeMem(ptr) M_Free(ptr) @@ -1823,8 +1806,6 @@ USERp SpawnUser(DSWActor* actor, short id, STATEp state); short ActorFindTrack(DSWActor* actor, int8_t player_dir, int track_type, short *track_point_num, short *track_dir); -SECT_USERp GetSectUser(short sectnum); - // Some sounds were checked by storing handles in static local variables. // Problems with this design: // 1. The variables were unmaintained and could refer to handles that had been reused already. diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index 1cc5f4759..905490da6 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -81,8 +81,6 @@ int DoTrapMatch(short match); PLAYERp GlobPlayerP; -TPointer SectUser[MAXSECTORS]; - ANIM Anim[MAXANIM]; short AnimCnt = 0; @@ -328,47 +326,41 @@ void WallSetup(void) } -void SectorLiquidSet(short i) +void SectorLiquidSet(int i) { - SECT_USERp sectu; - + auto sectp = §or[i]; // /////////////////////////////////// // // CHECK for pics that mean something // // /////////////////////////////////// - if (sector[i].floorpicnum >= 300 && sector[i].floorpicnum <= 307) + if (sectp->floorpicnum >= 300 && sectp->floorpicnum <= 307) { - sectu = GetSectUser(i); - - SET(sector[i].extra, SECTFX_LIQUID_WATER); + sectp->u_defined = true; + SET(sectp->extra, SECTFX_LIQUID_WATER); } - else if (sector[i].floorpicnum >= 320 && sector[i].floorpicnum <= 343) + else if (sectp->floorpicnum >= 320 && sectp->floorpicnum <= 343) { - sectu = GetSectUser(i); - - SET(sector[i].extra, SECTFX_LIQUID_WATER); + sectp->u_defined = true; + SET(sectp->extra, SECTFX_LIQUID_WATER); } - else if (sector[i].floorpicnum >= 780 && sector[i].floorpicnum <= 794) + else if (sectp->floorpicnum >= 780 && sectp->floorpicnum <= 794) { - sectu = GetSectUser(i); - - SET(sector[i].extra, SECTFX_LIQUID_WATER); + sectp->u_defined = true; + SET(sectp->extra, SECTFX_LIQUID_WATER); } - else if (sector[i].floorpicnum >= 890 && sector[i].floorpicnum <= 897) + else if (sectp->floorpicnum >= 890 && sectp->floorpicnum <= 897) { - sectu = GetSectUser(i); - - SET(sector[i].extra, SECTFX_LIQUID_WATER); + sectp->u_defined = true; + SET(sectp->extra, SECTFX_LIQUID_WATER); } - else if (sector[i].floorpicnum >= 175 && sector[i].floorpicnum <= 182) + else if (sectp->floorpicnum >= 175 && sectp->floorpicnum <= 182) { - sectu = GetSectUser(i); - - SET(sector[i].extra, SECTFX_LIQUID_LAVA); - if (!sectu->damage) - sectu->damage = 40; + sectp->u_defined = true; + SET(sectp->extra, SECTFX_LIQUID_LAVA); + if (!sectp->damage) + sectp->damage = 40; } } diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index c132f46dc..8e30aee50 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -918,22 +918,6 @@ USERp SpawnUser(DSWActor* actor, short id, STATEp state) return u; } -SECT_USERp GetSectUser(short sectnum) -{ - SECT_USERp sectu; - - if (SectUser[sectnum].Data()) - return SectUser[sectnum].Data(); - - SectUser[sectnum].Alloc(); - sectu = SectUser[sectnum].Data(); - - ASSERT(sectu != nullptr); - - return sectu; -} - - DSWActor* SpawnActor(short stat, short id, STATEp state, short sectnum, int x, int y, int z, int init_ang, int vel) { SPRITEp sp; @@ -1698,7 +1682,6 @@ void SpriteSetup(void) // Clear all extra bits - they are set by sprites for (int i = 0; i < numsectors; i++) { - SectUser[i].Clear(); sector[i].extra = 0; } diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index 5b5307faf..b3a0f5c6c 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -2191,7 +2191,6 @@ void CallbackSOsink(ANIMp ap, void *data) SECTOR_OBJECTp sop; SPRITEp sp; USERp u; - SECT_USERp su; int startwall, endwall, j; int dest_sector = -1; int src_sector = -1; @@ -2230,15 +2229,13 @@ void CallbackSOsink(ANIMp ap, void *data) RESET(sector[dest_sector].floorstat, FLOOR_STAT_RELATIVE); - su = GetSectUser(dest_sector); + auto su = §or[dest_sector]; - ASSERT(su != nullptr); + ASSERT(su->hasU() && sector[src_sector].hasU()); - ASSERT(GetSectUser(src_sector)); - tgt_depth = FixedToInt((GetSectUser(src_sector))->depth_fixed); + tgt_depth = FixedToInt(sector[src_sector].depth_fixed); - short sectnum; - for (sectnum = 0; sectnum < numsectors; sectnum++) + for (int sectnum = 0; sectnum < numsectors; sectnum++) { if (sectnum == dest_sector) { @@ -2527,9 +2524,8 @@ void DoTrack(SECTOR_OBJECTp sop, short locktics, int *nx, int *ny) { // for lowering the whirlpool in level 1 SECTORp *sectp; - short i; - SECT_USERp sectu; - + int i; + for (i = 0, sectp = &sop->sectp[0]; *sectp; sectp++, i++) { if ((*sectp)->hasU())