- made sector a TArray.

This commit is contained in:
Christoph Oelckers 2021-11-20 23:20:43 +01:00
parent a21f6b6240
commit 7d2404ce76
33 changed files with 220 additions and 468 deletions

View file

@ -147,7 +147,7 @@ struct usermaphack_t
extern spriteext_t spriteext[MAXSPRITES]; extern spriteext_t spriteext[MAXSPRITES];
extern spritesmooth_t spritesmooth[MAXSPRITES + MAXUNIQHUDID]; extern spritesmooth_t spritesmooth[MAXSPRITES + MAXUNIQHUDID];
extern sectortype sector[MAXSECTORS]; extern TArray<sectortype> sector;
extern walltype wall[MAXWALLS]; extern walltype wall[MAXWALLS];
extern spritetype sprite[MAXSPRITES]; extern spritetype sprite[MAXSPRITES];
EXTERN int leveltimer; EXTERN int leveltimer;
@ -182,11 +182,10 @@ inline walltype* sectortype::firstWall() const
} }
extern sectortype sectorbackup[MAXSECTORS]; extern TArray<sectortype> sectorbackup;
//extern TArray<walltype> wallbackup;
extern walltype wallbackup[MAXWALLS]; extern walltype wallbackup[MAXWALLS];
extern bool inpreparemirror;
inline tspriteptr_t renderAddTSpriteFromSprite(spritetype* tsprite, int& spritesortcnt, uint16_t const spritenum) inline tspriteptr_t renderAddTSpriteFromSprite(spritetype* tsprite, int& spritesortcnt, uint16_t const spritenum)
{ {
auto tspr = &tsprite[spritesortcnt++]; auto tspr = &tsprite[spritesortcnt++];
@ -212,7 +211,7 @@ EXTERN int32_t xdim, ydim;
EXTERN int32_t yxaspect, viewingrange; EXTERN int32_t yxaspect, viewingrange;
EXTERN int32_t Numsprites; EXTERN int32_t Numsprites;
EXTERN int16_t numsectors, numwalls; EXTERN int numsectors, numwalls;
EXTERN int32_t display_mirror; EXTERN int32_t display_mirror;
inline bool validSectorIndex(int sectnum) inline bool validSectorIndex(int sectnum)
@ -442,7 +441,7 @@ int32_t try_facespr_intersect(uspriteptr_t const spr, vec3_t const in,
void updatesector(int const x, int const y, int * const sectnum) ATTRIBUTE((nonnull(3))); void updatesector(int const x, int const y, int * const sectnum) ATTRIBUTE((nonnull(3)));
inline void updatesector(int const x, int const y, sectortype** const sectp) inline void updatesector(int const x, int const y, sectortype** const sectp)
{ {
int sectno = *sectp? (*sectp) - sector : -1; int sectno = *sectp? sector.IndexOf(*sectp) : -1;
updatesector(x, y, &sectno); updatesector(x, y, &sectno);
*sectp = sectno == -1? nullptr : &sector[sectno]; *sectp = sectno == -1? nullptr : &sector[sectno];
} }
@ -496,7 +495,7 @@ inline sectortype* nextsectorneighborzptr(int16_t sectnum, int32_t refz, int16_t
inline sectortype* nextsectorneighborzptr(sectortype* sectp, int32_t refz, int16_t topbottom, int16_t direction) inline sectortype* nextsectorneighborzptr(sectortype* sectp, int32_t refz, int16_t topbottom, int16_t direction)
{ {
auto sect = nextsectorneighborz(int(sectp - sector), refz, topbottom, direction); auto sect = nextsectorneighborz(sector.IndexOf(sectp), refz, topbottom, direction);
return sect == -1? nullptr : &sector[sect]; return sect == -1? nullptr : &sector[sect];
} }

View file

@ -121,7 +121,7 @@ struct sectortype
struct // SW struct // SW
{ {
// No need to allocate this on demand as it is smaller than what Blood needs. // No need to allocate this on demand as it is smaller than what Blood needs.
int dist, flags; int flags;
int depth_fixed; int depth_fixed;
short stag; // ST? tag number - for certain things it helps to know it short stag; // ST? tag number - for certain things it helps to know it
short ang; short ang;
@ -129,7 +129,7 @@ struct sectortype
short speed; short speed;
short damage; short damage;
short number; // usually used for matching number short number; // usually used for matching number
bool defined; bool u_defined;
uint8_t flags2; uint8_t flags2;
}; };
@ -157,8 +157,7 @@ struct sectortype
void allocX(); void allocX();
// same for SW // same for SW
ShadowWarrior::SECT_USER* u() const; bool hasU() const { return u_defined; }
bool hasU() const { return u() != nullptr; }

View file

@ -43,7 +43,7 @@
spriteext_t spriteext[MAXSPRITES]; spriteext_t spriteext[MAXSPRITES];
spritesmooth_t spritesmooth[MAXSPRITES + MAXUNIQHUDID]; spritesmooth_t spritesmooth[MAXSPRITES + MAXUNIQHUDID];
sectortype sector[MAXSECTORS]; TArray<sectortype> sector;
walltype wall[MAXWALLS]; walltype wall[MAXWALLS];
spritetype sprite[MAXSPRITES]; spritetype sprite[MAXSPRITES];

View file

@ -319,6 +319,16 @@ public:
return &Array[0]; return &Array[0];
} }
unsigned IndexOf(const T& elem) const
{
return &elem - Array;
}
unsigned IndexOf(const T* elem) const
{
return elem - Array;
}
unsigned int Find(const T& item) const unsigned int Find(const T& item) const
{ {
unsigned int i; unsigned int i;
@ -1913,202 +1923,3 @@ private:
unsigned int Count; unsigned int Count;
}; };
template<typename T> class TSparseIterator
{
public:
using iterator_category = std::random_access_iterator_tag;
using value_type = T;
using difference_type = ptrdiff_t;
using pointer = value_type*;
using reference = value_type&;
TSparseIterator(unsigned char* ptr = nullptr, unsigned stride = 0) { m_Ptr = ptr; Stride = stride; }
// Comparison operators
bool operator==(const TSparseIterator &other) const { return m_Ptr == other.m_Ptr; }
bool operator!=(const TSparseIterator &other) const { return m_Ptr != other.m_Ptr; }
bool operator< (const TSparseIterator &other) const { return m_Ptr < other.m_Ptr; }
bool operator<=(const TSparseIterator &other) const { return m_Ptr <= other.m_Ptr; }
bool operator> (const TSparseIterator &other) const { return m_Ptr > other.m_Ptr; }
bool operator>=(const TSparseIterator &other) const { return m_Ptr >= other.m_Ptr; }
// Arithmetic operators
TSparseIterator &operator++() { m_Ptr += Stride; return *this; }
TSparseIterator operator++(int) { auto tmp = *this; ++*this; return tmp; }
TSparseIterator &operator--() { m_Ptr -= Stride; return *this; }
TSparseIterator operator--(int) { auto tmp = *this; --*this; return tmp; }
TSparseIterator &operator+=(difference_type offset) { m_Ptr += offset * Stride; return *this; }
TSparseIterator operator+(difference_type offset) const { return TSparseIterator(m_Ptr + offset * Stride, Stride); }
friend TSparseIterator operator+(difference_type offset, const TSparseIterator &other) { return TSparseIterator(offset*other.Stride + other.m_Ptr, other.Stride); }
TSparseIterator &operator-=(difference_type offset) { m_Ptr -= offset * Stride; return *this; }
TSparseIterator operator-(difference_type offset) const { return TSparseIterator(m_Ptr - offset * Stride, Stride); }
difference_type operator-(const TSparseIterator &other) const { return (m_Ptr - other.m_Ptr) / Stride; }
// Random access operators
T& operator[](difference_type i) { return *(T*)(m_Ptr + i * Stride); }
const T& operator[](difference_type i) const { return *(T*)(m_Ptr + i * Stride); }
T &operator*() const { return (T*)m_Ptr; }
T* operator->() { return (T*)m_Ptr; }
protected:
unsigned char* m_Ptr;
unsigned Stride;
};
// A wrapper to externally stored data.
// Like the above but with a customizable stride
template <class T>
class TSparseArrayView
{
public:
typedef TSparseIterator<T> iterator;
typedef TSparseIterator<const T> const_iterator;
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
typedef T value_type;
iterator begin()
{
return iterator(Array, Stride);
}
const_iterator begin() const
{
return const_iterator(Array, Stride);
}
const_iterator cbegin() const
{
return const_iterator(Array, Stride);
}
iterator end()
{
return iterator(Array + Count * Stride, Stride);
}
const_iterator end() const
{
return const_iterator(Array + Count * Stride, Stride);
}
const_iterator cend() const
{
return const_iterator(Array + Count * Stride, Stride);
}
reverse_iterator rbegin()
{
return reverse_iterator(end());
}
const_reverse_iterator rbegin() const
{
return const_reverse_iterator(end());
}
const_reverse_iterator crbegin() const
{
return const_reverse_iterator(cend());
}
reverse_iterator rend()
{
return reverse_iterator(begin());
}
const_reverse_iterator rend() const
{
return const_reverse_iterator(begin());
}
const_reverse_iterator crend() const
{
return const_reverse_iterator(cbegin());
}
////////
TSparseArrayView() = default; // intended to keep this type trivial.
TSparseArrayView(T *data, unsigned stride, unsigned count = 0)
{
Count = count;
Array = data;
Stride = stride;
}
TSparseArrayView(const TSparseArrayView<T> &other) = default;
TSparseArrayView<T> &operator= (const TSparseArrayView<T> &other) = default;
// Check equality of two arrays
bool operator==(const TArrayView<T> &other) const
{
if (Count != other.Count)
{
return false;
}
for (unsigned int i = 0; i < Count; ++i)
{
if (Element(i) != other.Element(i))
{
return false;
}
}
return true;
}
T &Element(size_t index)
{
return (T*)Array[index*Stride];
}
// Return a reference to an element
T &operator[] (size_t index) const
{
return Element(index);
}
// Returns a reference to the last element
T &Last() const
{
return Element(Count - 1);
}
// returns address of first element
T *Data() const
{
return &Element(0);
}
unsigned Size() const
{
return Count;
}
unsigned int Find(const T& item) const
{
unsigned int i;
for (i = 0; i < Count; ++i)
{
if (Element(i) == item)
break;
}
return i;
}
void Set(T *data, unsigned stride, unsigned count)
{
Array = reinterpret_cast<unsigned char*>(data);
Count = count;
Stride = stride;
}
void Set(void *data, unsigned stride, unsigned count)
{
Array = reinterpret_cast<unsigned char*>(data);
Count = count;
Stride = stride;
}
void Clear()
{
Count = 0;
Stride = 0;
Array = nullptr;
}
private:
unsigned char* Array;
unsigned int Count;
unsigned int Stride;
};

View file

@ -270,7 +270,7 @@ inline int wallnum(const walltype* wal)
inline int sectnum(const sectortype* sect) inline int sectnum(const sectortype* sect)
{ {
return int(sect - sector); return sector.IndexOf(sect);
} }
inline double SquareDist(double lx1, double ly1, double lx2, double ly2) inline double SquareDist(double lx1, double ly1, double lx2, double ly2)

View file

@ -55,7 +55,7 @@ public:
SectIterator(sectortype* sect) SectIterator(sectortype* sect)
{ {
assert(sect); assert(sect);
next = headspritesect[sect - sector]; next = headspritesect[sector.IndexOf(sect)];
} }
void Reset(int stat) void Reset(int stat)
@ -67,7 +67,7 @@ public:
void Reset(sectortype* sect) void Reset(sectortype* sect)
{ {
assert(sect); assert(sect);
next = headspritesect[sect - sector]; next = headspritesect[sector.IndexOf(sect)];
} }
int NextIndex() int NextIndex()

View file

@ -410,7 +410,10 @@ void allocateMapArrays(int numsprites)
{ {
ClearInterpolations(); ClearInterpolations();
memset(sector, 0, sizeof(*sector) * MAXSECTORS);
mapDataArena.FreeAll();
sector.Resize(numsectors);
memset(sector.Data(), 0, sizeof(sectortype) * numsectors);
memset(wall, 0, sizeof(*wall) * MAXWALLS); memset(wall, 0, sizeof(*wall) * MAXWALLS);
memset(sprite, 0, sizeof(*sprite) * MAXSPRITES); memset(sprite, 0, sizeof(*sprite) * MAXSPRITES);
memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES); memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES);
@ -519,7 +522,7 @@ void engineLoadBoard(const char* filename, int flags, vec3_t* pos, int16_t* ang,
memcpy(wallbackup, wall, sizeof(wallbackup)); memcpy(wallbackup, wall, sizeof(wallbackup));
memcpy(sectorbackup, sector, sizeof(sectorbackup)); sectorbackup = sector;
} }

View file

@ -65,7 +65,8 @@
#include <zlib.h> #include <zlib.h>
sectortype sectorbackup[MAXSECTORS]; TArray<sectortype> sectorbackup;
//TArray<walltype> wallbackup;
walltype wallbackup[MAXWALLS]; walltype wallbackup[MAXWALLS];
void WriteSavePic(FileWriter* file, int width, int height); void WriteSavePic(FileWriter* file, int width, int height);
@ -539,7 +540,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, sectortype &c, sectort
("portalflags", c.portalflags, def->portalflags) ("portalflags", c.portalflags, def->portalflags)
("portalnum", c.portalnum, def->portalnum); ("portalnum", c.portalnum, def->portalnum);
// Save the blood-specific extensions only when playing Blood // Save the extensions only when playing their respective games.
if (isDukeLike()) if (isDukeLike())
{ {
arc("keyinfo", c.keyinfo, def->keyinfo); arc("keyinfo", c.keyinfo, def->keyinfo);
@ -583,6 +584,19 @@ FSerializer &Serialize(FSerializer &arc, const char *key, sectortype &c, sectort
("Speed", c.Speed, def->Speed); ("Speed", c.Speed, def->Speed);
} }
else if (isSWALL())
{
arc("flags", c.flags, def->flags)
("depth_fixed", c.depth_fixed, def->depth_fixed)
("stag", c.stag, def->stag)
("ang", c.ang, def->ang)
("height", c.height, def->height)
("speed", c.speed, def->speed)
("damage", c.damage, def->damage)
("number", c.number, def->number)
("u_defined", c.u_defined, def->u_defined)
("flags2", c.flags2, def->flags2);
}
arc.EndObject(); arc.EndObject();
} }
@ -676,7 +690,7 @@ void SerializeMap(FSerializer& arc)
.SparseArray("sprites", sprite, MAXSPRITES, activeSprites) .SparseArray("sprites", sprite, MAXSPRITES, activeSprites)
.SparseArray("spriteext", spriteext, MAXSPRITES, activeSprites) .SparseArray("spriteext", spriteext, MAXSPRITES, activeSprites)
("numsectors", numsectors) ("numsectors", numsectors)
.Array("sectors", sector, sectorbackup, numsectors) ("sectors", sector, sectorbackup)
("numwalls", numwalls) ("numwalls", numwalls)
.Array("walls", wall, wallbackup, numwalls) .Array("walls", wall, wallbackup, numwalls)
.Array("headspritestat", headspritestat, MAXSTATUS + 1) .Array("headspritestat", headspritestat, MAXSTATUS + 1)

View file

@ -959,7 +959,7 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, int*
hw_BuildSections(); hw_BuildSections();
sectorGeometry.SetSize(numsections); sectorGeometry.SetSize(numsections);
memcpy(wallbackup, wall, sizeof(wallbackup)); memcpy(wallbackup, wall, sizeof(wallbackup));
memcpy(sectorbackup, sector, sizeof(sectorbackup)); sectorbackup = sector;
} }

View file

@ -296,12 +296,12 @@ void DoDebrisCurrent(DSWActor* actor)
int nx, ny; int nx, ny;
USERp u = actor->u(); USERp u = actor->u();
auto sp = &actor->s(); auto sp = &actor->s();
SECT_USERp sectu = sp->sector()->u(); auto sectp = sp->sector();
//sp->clipdist = (256+128)>>2; //sp->clipdist = (256+128)>>2;
nx = MulScale((sectu->speed >> 2), bcos(sectu->ang), 14); nx = MulScale((sectp->speed >> 2), bcos(sectp->ang), 14);
ny = MulScale((sectu->speed >> 2), bsin(sectu->ang), 14); ny = MulScale((sectp->speed >> 2), bsin(sectp->ang), 14);
Collision ret = move_sprite(actor, nx, ny, 0, u->ceiling_dist, u->floor_dist, 0, ACTORMOVETICS); Collision ret = move_sprite(actor, nx, ny, 0, u->ceiling_dist, u->floor_dist, 0, ACTORMOVETICS);
@ -310,8 +310,8 @@ void DoDebrisCurrent(DSWActor* actor)
{ {
short rang = RANDOM_P2(2048); short rang = RANDOM_P2(2048);
nx = MulScale((sectu->speed >> 2), bcos(sectu->ang + rang), 14); nx = MulScale((sectp->speed >> 2), bcos(sectp->ang + rang), 14);
nx = MulScale((sectu->speed >> 2), bsin(sectu->ang + rang), 14); nx = MulScale((sectp->speed >> 2), bsin(sectp->ang + rang), 14);
move_sprite(actor, nx, ny, 0, u->ceiling_dist, u->floor_dist, 0, ACTORMOVETICS); move_sprite(actor, nx, ny, 0, u->ceiling_dist, u->floor_dist, 0, ACTORMOVETICS);
} }
@ -323,20 +323,19 @@ int DoActorSectorDamage(DSWActor* actor)
{ {
USER* u = actor->u(); USER* u = actor->u();
SPRITEp sp = &actor->s(); SPRITEp sp = &actor->s();
SECT_USERp sectu = sp->sector()->u();
SECTORp sectp = sp->sector(); SECTORp sectp = sp->sector();
if (u->Health <= 0) if (u->Health <= 0)
return false; return false;
if (sectu && sectu->damage) if (sectp->hasU() && sectp->damage)
{ {
if (TEST(sectu->flags, SECTFU_DAMAGE_ABOVE_SECTOR)) if (TEST(sectp->flags, SECTFU_DAMAGE_ABOVE_SECTOR))
{ {
if ((u->DamageTics -= synctics) < 0) if ((u->DamageTics -= synctics) < 0)
{ {
u->DamageTics = 60; u->DamageTics = 60;
u->Health -= sectu->damage; u->Health -= sectp->damage;
if (u->Health <= 0) if (u->Health <= 0)
{ {
@ -351,7 +350,7 @@ int DoActorSectorDamage(DSWActor* actor)
if ((u->DamageTics -= synctics) < 0) if ((u->DamageTics -= synctics) < 0)
{ {
u->DamageTics = 60; u->DamageTics = 60;
u->Health -= sectu->damage; u->Health -= sectp->damage;
if (u->Health <= 0) if (u->Health <= 0)
{ {
@ -446,7 +445,7 @@ int DoActorDebris(DSWActor* actor)
} }
} }
if (sp->sector()->hasU() && FixedToInt(sp->sector()->u()->depth_fixed) > 10) // JBF: added null check if (sp->sector()->hasU() && FixedToInt(sp->sector()->depth_fixed) > 10) // JBF: added null check
{ {
u->WaitTics = (u->WaitTics + (ACTORMOVETICS << 3)) & 1023; u->WaitTics = (u->WaitTics + (ACTORMOVETICS << 3)) & 1023;
//sp->z = Z(2) + u->loz + ((Z(4) * (int) bsin(u->WaitTics)) >> 14); //sp->z = Z(2) + u->loz + ((Z(4) * (int) bsin(u->WaitTics)) >> 14);
@ -527,7 +526,7 @@ void KeepActorOnFloor(DSWActor* actor)
return; return;
if (u->lo_sectp && u->lo_sectp->hasU()) if (u->lo_sectp && u->lo_sectp->hasU())
depth = FixedToInt(u->lo_sectp->u()->depth_fixed); depth = FixedToInt(u->lo_sectp->depth_fixed);
else else
depth = 0; depth = 0;

View file

@ -241,8 +241,8 @@ static void ItemCheat(int player)
for (auto& sect : sectors()) for (auto& sect : sectors())
{ {
if (sect.hasU() && sect.u()->stag == SECT_LOCK_DOOR) if (sect.hasU() && sect.stag == SECT_LOCK_DOOR)
sect.u()->number = 0; // unlock all doors of this type sect.number = 0; // unlock all doors of this type
} }
} }

View file

@ -654,8 +654,8 @@ int DoCoolgMatchPlayerZ(DSWActor* actor)
hiz = u->hiz; hiz = u->hiz;
// adjust loz/hiz for water depth // adjust loz/hiz for water depth
if (u->lo_sectp && u->lo_sectp->hasU() && FixedToInt(u->lo_sectp->u()->depth_fixed)) if (u->lo_sectp && u->lo_sectp->hasU() && FixedToInt(u->lo_sectp->depth_fixed))
loz -= Z(FixedToInt(u->lo_sectp->u()->depth_fixed)) - Z(8); loz -= Z(FixedToInt(u->lo_sectp->depth_fixed)) - Z(8);
// lower bound // lower bound
if (u->lowActor) if (u->lowActor)

View file

@ -476,7 +476,7 @@ void EnemyDefaults(DSWActor* actor, ACTOR_ACTION_SETp action, PERSONALITYp perso
if (u->lo_sectp->hasU() && TEST(u->lo_sectp->extra, SECTFX_SINK)) if (u->lo_sectp->hasU() && TEST(u->lo_sectp->extra, SECTFX_SINK))
{ {
depth = FixedToInt(u->lo_sectp->u()->depth_fixed); depth = FixedToInt(u->lo_sectp->depth_fixed);
} }
else else
{ {

View file

@ -208,13 +208,17 @@ void CopySectorMatch(short match)
} }
// copy sector user if there is one // copy sector user if there is one
if (src_sp->sector()->hasU() || dest_sp->sector()->hasU())
{
SECT_USERp ssectu = GetSectUser(src_sp->sectnum);
SECT_USERp dsectu = GetSectUser(dest_sp->sectnum);
memcpy(dsectu, ssectu, sizeof(SECT_USER)); dsectp->flags = ssectp->flags;
} dsectp->depth_fixed = ssectp->depth_fixed;
dsectp->stag = ssectp->stag;
dsectp->ang = ssectp->ang;
dsectp->height = ssectp->height;
dsectp->speed = ssectp->speed;
dsectp->damage = ssectp->damage;
dsectp->number = ssectp->number;
dsectp->u_defined = ssectp->u_defined;
dsectp->flags2 = ssectp->flags2;
dsectp->hitag = ssectp->hitag; dsectp->hitag = ssectp->hitag;
dsectp->lotag = ssectp->lotag; dsectp->lotag = ssectp->lotag;

View file

@ -572,6 +572,7 @@ void analyzesprites(spritetype* tsprite, int& spritesortcnt, int viewx, int view
auto tActor = &swActors[SpriteNum]; auto tActor = &swActors[SpriteNum];
tspriteptr_t tsp = &tsprite[tSpriteNum]; tspriteptr_t tsp = &tsprite[tSpriteNum];
tu = tActor->hasU()? tActor->u() : nullptr; tu = tActor->hasU()? tActor->u() : nullptr;
auto tsectp = tsp->sector();
#if 0 #if 0
// Brighten up the sprite if set somewhere else to do so // Brighten up the sprite if set somewhere else to do so
@ -665,9 +666,9 @@ void analyzesprites(spritetype* tsprite, int& spritesortcnt, int viewx, int view
} }
// set palette lookup correctly // set palette lookup correctly
if (tsp->pal != tsp->sector()->floorpal) if (tsp->pal != tsectp->floorpal)
{ {
if (tsp->sector()->floorpal == PALETTE_DEFAULT) if (tsectp->floorpal == PALETTE_DEFAULT)
{ {
// default pal for sprite is stored in tu->spal // default pal for sprite is stored in tu->spal
// mostly for players and other monster types // mostly for players and other monster types
@ -676,12 +677,11 @@ void analyzesprites(spritetype* tsprite, int& spritesortcnt, int viewx, int view
else else
{ {
// if sector pal is something other than default // if sector pal is something other than default
SECT_USERp sectu = tsp->sector()->u(); uint8_t pal = tsectp->floorpal;
uint8_t pal = tsp->sector()->floorpal;
bool nosectpal=false; bool nosectpal=false;
// sprite does not take on the new pal if sector flag is set // sprite does not take on the new pal if sector flag is set
if (sectu && TEST(sectu->flags, SECTFU_DONT_COPY_PALETTE)) if (tsectp->hasU() && TEST(tsectp->flags, SECTFU_DONT_COPY_PALETTE))
{ {
pal = PALETTE_DEFAULT; pal = PALETTE_DEFAULT;
nosectpal = true; nosectpal = true;
@ -795,10 +795,10 @@ void analyzesprites(spritetype* tsprite, int& spritesortcnt, int viewx, int view
tsp->shade = int8_t(newshade); tsp->shade = int8_t(newshade);
} }
if (TEST(tsp->sector()->ceilingstat, CEILING_STAT_PLAX)) if (TEST(tsectp->ceilingstat, CEILING_STAT_PLAX))
{ {
newshade = tsp->shade; newshade = tsp->shade;
newshade += tsp->sector()->ceilingshade; newshade += tsectp->ceilingshade;
if (newshade > 127) newshade = 127; if (newshade > 127) newshade = 127;
if (newshade < -128) newshade = -128; if (newshade < -128) newshade = -128;
tsp->shade = int8_t(newshade); tsp->shade = int8_t(newshade);
@ -806,7 +806,7 @@ void analyzesprites(spritetype* tsprite, int& spritesortcnt, int viewx, int view
else else
{ {
newshade = tsp->shade; newshade = tsp->shade;
newshade += tsp->sector()->floorshade; newshade += tsectp->floorshade;
if (newshade > 127) newshade = 127; if (newshade > 127) newshade = 127;
if (newshade < -128) newshade = -128; if (newshade < -128) newshade = -128;
tsp->shade = int8_t(newshade); tsp->shade = int8_t(newshade);

View file

@ -471,8 +471,8 @@ int DoEelMatchPlayerZ(DSWActor* actor)
hiz = u->hiz; hiz = u->hiz;
// adjust loz/hiz for water depth // adjust loz/hiz for water depth
if (u->lo_sectp && u->lo_sectp->hasU() && FixedToInt(u->lo_sectp->u()->depth_fixed)) if (u->lo_sectp && u->lo_sectp->hasU() && FixedToInt(u->lo_sectp->depth_fixed))
loz -= Z(FixedToInt(u->lo_sectp->u()->depth_fixed)) - Z(8); loz -= Z(FixedToInt(u->lo_sectp->depth_fixed)) - Z(8);
// lower bound // lower bound
if (u->lowActor && u->targetActor == u->highActor) // this doesn't look right... if (u->lowActor && u->targetActor == u->highActor) // this doesn't look right...

View file

@ -1483,7 +1483,7 @@ enum ShrapType
typedef struct SECT_USER typedef struct SECT_USER
{ {
int dist, flags; int _flags;
int depth_fixed; int depth_fixed;
short stag, // ST? tag number - for certain things it helps to know it short stag, // ST? tag number - for certain things it helps to know it
ang, ang,
@ -2291,7 +2291,7 @@ struct ANIMstruct
case ANIM_Userz: case ANIM_Userz:
return animactor->u()->sz; return animactor->u()->sz;
case ANIM_SUdepth: case ANIM_SUdepth:
return sector[animindex].u()->depth_fixed; return sector[animindex].depth_fixed;
default: default:
return animindex; return animindex;
} }
@ -2304,10 +2304,5 @@ extern short AnimCnt;
END_SW_NS END_SW_NS
inline ShadowWarrior::SECT_USER* sectortype::u() const
{
return ShadowWarrior::SectUser[sectnum(this)].Data();
}
#endif #endif

View file

@ -377,8 +377,8 @@ int DoHornetMatchPlayerZ(DSWActor* actor)
hiz = u->hiz; hiz = u->hiz;
// adjust loz/hiz for water depth // adjust loz/hiz for water depth
if (u->lo_sectp && u->lo_sectp->hasU() && FixedToInt(u->lo_sectp->u()->depth_fixed)) if (u->lo_sectp && u->lo_sectp->hasU() && FixedToInt(u->lo_sectp->depth_fixed))
loz -= Z(FixedToInt(u->lo_sectp->u()->depth_fixed)) - Z(8); loz -= Z(FixedToInt(u->lo_sectp->depth_fixed)) - Z(8);
// lower bound // lower bound
if (u->lowActor) if (u->lowActor)

View file

@ -194,7 +194,7 @@ void so_addinterpolation(SECTOR_OBJECTp sop)
} }
SWSectIterator it(int(*sectp - sector)); SWSectIterator it(*sectp);
while (auto actor = it.Next()) while (auto actor = it.Next())
if (actor->s().statnum == STAT_VATOR && SP_TAG1(&actor->s()) == SECT_VATOR) if (actor->s().statnum == STAT_VATOR && SP_TAG1(&actor->s()) == SECT_VATOR)
{ {

View file

@ -505,7 +505,7 @@ int DoBloodSpray(DSWActor* actor)
SET(u->Flags, SPR_BOUNCE); // no bouncing SET(u->Flags, SPR_BOUNCE); // no bouncing
// underwater // underwater
if (u->lo_sectp && sp->sector()->hasU() && FixedToInt(sp->sector()->u()->depth_fixed)) if (u->lo_sectp && sp->sector()->hasU() && FixedToInt(sp->sector()->depth_fixed))
SET(u->Flags, SPR_BOUNCE); // no bouncing on SET(u->Flags, SPR_BOUNCE); // no bouncing on
// shallow water // shallow water
@ -723,7 +723,7 @@ int DoPhosphorus(DSWActor* actor)
SET(u->Flags, SPR_BOUNCE); // no bouncing SET(u->Flags, SPR_BOUNCE); // no bouncing
// underwater // underwater
if (u->lo_sectp && sp->sector()->hasU() && FixedToInt(sp->sector()->u()->depth_fixed)) if (u->lo_sectp && sp->sector()->hasU() && FixedToInt(sp->sector()->depth_fixed))
SET(u->Flags, SPR_BOUNCE); // no bouncing on SET(u->Flags, SPR_BOUNCE); // no bouncing on
// shallow water // shallow water
@ -951,7 +951,7 @@ int DoChemBomb(DSWActor* actor)
SET(u->Flags, SPR_BOUNCE); // no bouncing SET(u->Flags, SPR_BOUNCE); // no bouncing
// underwater // underwater
if (u->lo_sectp && sp->sector()->hasU() && FixedToInt(sp->sector()->u()->depth_fixed)) if (u->lo_sectp && sp->sector()->hasU() && FixedToInt(sp->sector()->depth_fixed))
SET(u->Flags, SPR_BOUNCE); // no bouncing on SET(u->Flags, SPR_BOUNCE); // no bouncing on
// shallow water // shallow water
@ -1168,7 +1168,7 @@ int DoCaltrops(DSWActor* actor)
SET(u->Flags, SPR_BOUNCE); // no bouncing SET(u->Flags, SPR_BOUNCE); // no bouncing
// underwater // underwater
if (u->lo_sectp && sp->sector()->hasU() && FixedToInt(sp->sector()->u()->depth_fixed)) if (u->lo_sectp && sp->sector()->hasU() && FixedToInt(sp->sector()->depth_fixed))
SET(u->Flags, SPR_BOUNCE); // no bouncing on SET(u->Flags, SPR_BOUNCE); // no bouncing on
// shallow water // shallow water

View file

@ -358,7 +358,7 @@ MorphTornado(SECTOR_OBJECTp sop)
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++) for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
{ {
if ((*sectp)->hasU() && if ((*sectp)->hasU() &&
TEST((*sectp)->u()->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT)) TEST((*sectp)->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT))
{ {
#define TOR_LOW (floorz) #define TOR_LOW (floorz)
if (sop->morph_z > TOR_LOW) if (sop->morph_z > TOR_LOW)
@ -451,7 +451,7 @@ MorphFloor(SECTOR_OBJECTp sop)
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++) for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
{ {
if ((*sectp)->hasU() && if ((*sectp)->hasU() &&
TEST((*sectp)->u()->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT)) TEST((*sectp)->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT))
{ {
alignflorslope(sectnum(*sectp), mx, my, floorz + sop->morph_z); alignflorslope(sectnum(*sectp), mx, my, floorz + sop->morph_z);
} }
@ -467,7 +467,7 @@ SOBJ_AlignFloorToPoint(SECTOR_OBJECTp sop, int x, int y, int z)
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++) for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
{ {
if ((*sectp)->hasU() && if ((*sectp)->hasU() &&
TEST((*sectp)->u()->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT)) TEST((*sectp)->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT))
{ {
alignflorslope(int16_t(sectnum(*sectp)), x, y, z); alignflorslope(int16_t(sectnum(*sectp)), x, y, z);
} }
@ -483,7 +483,7 @@ SOBJ_AlignCeilingToPoint(SECTOR_OBJECTp sop, int x, int y, int z)
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++) for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
{ {
if ((*sectp)->hasU() && if ((*sectp)->hasU() &&
TEST((*sectp)->u()->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT)) TEST((*sectp)->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT))
{ {
alignceilslope(int16_t(sectnum(*sectp)), x, y, z); alignceilslope(int16_t(sectnum(*sectp)), x, y, z);
} }
@ -499,7 +499,7 @@ SOBJ_AlignFloorCeilingToPoint(SECTOR_OBJECTp sop, int x, int y, int z)
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++) for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
{ {
if ((*sectp)->hasU() && if ((*sectp)->hasU() &&
TEST((*sectp)->u()->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT)) TEST((*sectp)->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT))
{ {
alignflorslope(sectnum(*sectp), x, y, z); alignflorslope(sectnum(*sectp), x, y, z);
alignceilslope(sectnum(*sectp), x, y, z); alignceilslope(sectnum(*sectp), x, y, z);

View file

@ -6715,17 +6715,17 @@ pDisplaySprites(PLAYERp pp, double smoothratio)
// if its a weapon sprite and the view is set to the outside don't draw the sprite // if its a weapon sprite and the view is set to the outside don't draw the sprite
if (TEST(psp->flags, PANF_WEAPON_SPRITE)) if (TEST(psp->flags, PANF_WEAPON_SPRITE))
{ {
SECT_USERp sectu = nullptr; sectortype* sectp = nullptr;
int16_t floorshade = 0; int16_t floorshade = 0;
if (pp->cursectnum >= 0) if (pp->cursectnum >= 0)
{ {
sectu = pp->cursector()->u(); sectp = pp->cursector();
pal = pp->cursector()->floorpal; pal = sectp->floorpal;
floorshade = pp->cursector()->floorshade; floorshade = sectp->floorshade;
if (pal != PALETTE_DEFAULT) if (pal != PALETTE_DEFAULT)
{ {
if (sectu && TEST(sectu->flags, SECTFU_DONT_COPY_PALETTE)) if (sectp->hasU() && TEST(sectp->flags, SECTFU_DONT_COPY_PALETTE))
pal = PALETTE_DEFAULT; pal = PALETTE_DEFAULT;
} }
@ -6754,7 +6754,7 @@ pDisplaySprites(PLAYERp pp, double smoothratio)
// !FRANK - this was moved from BELOW this IF statement // !FRANK - this was moved from BELOW this IF statement
// if it doesn't have a picflag or its in the view // if it doesn't have a picflag or its in the view
if (sectu && TEST(sectu->flags, SECTFU_DONT_COPY_PALETTE)) if (sectp && sectp->hasU() && TEST(sectp->flags, SECTFU_DONT_COPY_PALETTE))
pal = 0; pal = 0;
} }

View file

@ -1442,8 +1442,8 @@ void DoPlayerSetWadeDepth(PLAYERp pp)
if (TEST(sectp->extra, SECTFX_SINK)) if (TEST(sectp->extra, SECTFX_SINK))
{ {
// make sure your even in the water // make sure your even in the water
if (pp->posz + PLAYER_HEIGHT > pp->lo_sectp->floorz - Z(FixedToInt(pp->lo_sectp->u()->depth_fixed))) if (pp->posz + PLAYER_HEIGHT > pp->lo_sectp->floorz - Z(FixedToInt(pp->lo_sectp->depth_fixed)))
pp->WadeDepth = FixedToInt(pp->lo_sectp->u()->depth_fixed); pp->WadeDepth = FixedToInt(pp->lo_sectp->depth_fixed);
} }
} }
@ -1600,7 +1600,7 @@ void SlipSlope(PLAYERp pp)
if (pp->cursectnum < 0 || !pp->cursector()->hasU()) if (pp->cursectnum < 0 || !pp->cursector()->hasU())
return; return;
SECT_USERp sectu = pp->cursector()->u(); auto sectu = pp->cursector();
if (!TEST(sectu->flags, SECTFU_SLIDE_SECTOR) || !TEST(pp->cursector()->floorstat, FLOOR_STAT_SLOPE)) if (!TEST(sectu->flags, SECTFU_SLIDE_SECTOR) || !TEST(pp->cursector()->floorstat, FLOOR_STAT_SLOPE))
return; return;
@ -2302,7 +2302,7 @@ void DoTankTreads(PLAYERp pp)
for (sectp = pp->sop->sectp, j = 0; *sectp; sectp++, j++) for (sectp = pp->sop->sectp, j = 0; *sectp; sectp++, j++)
{ {
SWSectIterator it(int(*sectp - sector)); SWSectIterator it(*sectp);
while (auto actor = it.Next()) while (auto actor = it.Next())
{ {
sp = &actor->s(); sp = &actor->s();
@ -2531,7 +2531,7 @@ void DriveCrush(PLAYERp pp, int *x, int *y)
// if it ends up actually in the drivable sector kill it // if it ends up actually in the drivable sector kill it
for (sectp = sop->sectp; *sectp; sectp++) for (sectp = sop->sectp; *sectp; sectp++)
{ {
SWSectIterator it(int(*sectp - sector)); SWSectIterator it(*sectp);
while (auto actor = it.Next()) while (auto actor = it.Next())
{ {
sp = &actor->s(); sp = &actor->s();
@ -3082,12 +3082,11 @@ void DoPlayerFall(PLAYERp pp)
if (PlayerFloorHit(pp, pp->loz - PLAYER_HEIGHT + recoil_amt)) if (PlayerFloorHit(pp, pp->loz - PLAYER_HEIGHT + recoil_amt))
{ {
SECT_USERp sectu = pp->cursector()->u();
SECTORp sectp = pp->cursector(); SECTORp sectp = pp->cursector();
PlayerSectorBound(pp, Z(1)); PlayerSectorBound(pp, Z(1));
if (sectu && (TEST(sectp->extra, SECTFX_LIQUID_MASK) != SECTFX_LIQUID_NONE)) if (sectp->hasU() && (TEST(sectp->extra, SECTFX_LIQUID_MASK) != SECTFX_LIQUID_NONE))
{ {
PlaySound(DIGI_SPLASH1, pp, v3df_dontpan); PlaySound(DIGI_SPLASH1, pp, v3df_dontpan);
} }
@ -3929,7 +3928,7 @@ int GetOverlapSector(int x, int y, short *over, short *under)
auto secto = &sector[*over]; auto secto = &sector[*over];
auto sectu = &sector[*under]; auto sectu = &sector[*under];
if ((sectu->hasU() && sectu->u()->number >= 30000) || (secto->hasU() && secto->u()->number >= 30000)) if ((sectu->hasU() && sectu->number >= 30000) || (secto->hasU() && secto->number >= 30000))
return GetOverlapSector2(x,y,over,under); return GetOverlapSector2(x,y,over,under);
// instead of check ALL sectors, just check the two most likely first // instead of check ALL sectors, just check the two most likely first
@ -4086,7 +4085,7 @@ int GetOverlapSector2(int x, int y, short *over, short *under)
void DoPlayerWarpToUnderwater(PLAYERp pp) void DoPlayerWarpToUnderwater(PLAYERp pp)
{ {
USERp u = pp->Actor()->u(); USERp u = pp->Actor()->u();
SECT_USERp sectu = pp->cursector()->u(); auto sectu = pp->cursector();
SPRITEp under_sp = nullptr, over_sp = nullptr; SPRITEp under_sp = nullptr, over_sp = nullptr;
bool Found = false; bool Found = false;
short over, under; short over, under;
@ -4103,7 +4102,7 @@ void DoPlayerWarpToUnderwater(PLAYERp pp)
if (TEST(sector[over_sp->sectnum].extra, SECTFX_DIVE_AREA) && if (TEST(sector[over_sp->sectnum].extra, SECTFX_DIVE_AREA) &&
over_sp->sector()->hasU() && over_sp->sector()->hasU() &&
over_sp->sector()->u()->number == sectu->number) over_sp->sector()->number == sectu->number)
{ {
Found = true; Found = true;
break; break;
@ -4121,7 +4120,7 @@ void DoPlayerWarpToUnderwater(PLAYERp pp)
if (TEST(sector[under_sp->sectnum].extra, SECTFX_UNDERWATER) && if (TEST(sector[under_sp->sectnum].extra, SECTFX_UNDERWATER) &&
under_sp->sector()->hasU() && under_sp->sector()->hasU() &&
under_sp->sector()->u()->number == sectu->number) under_sp->sector()->number == sectu->number)
{ {
Found = true; Found = true;
break; break;
@ -4161,7 +4160,7 @@ void DoPlayerWarpToUnderwater(PLAYERp pp)
void DoPlayerWarpToSurface(PLAYERp pp) void DoPlayerWarpToSurface(PLAYERp pp)
{ {
USERp u = pp->Actor()->u(); USERp u = pp->Actor()->u();
SECT_USERp sectu = pp->cursector()->u(); auto sectu = pp->cursector();
short over, under; short over, under;
SPRITEp under_sp = nullptr, over_sp = nullptr; SPRITEp under_sp = nullptr, over_sp = nullptr;
@ -4178,7 +4177,7 @@ void DoPlayerWarpToSurface(PLAYERp pp)
if (TEST(sector[under_sp->sectnum].extra, SECTFX_UNDERWATER) && if (TEST(sector[under_sp->sectnum].extra, SECTFX_UNDERWATER) &&
under_sp->sector()->hasU() && under_sp->sector()->hasU() &&
under_sp->sector()->u()->number == sectu->number) under_sp->sector()->number == sectu->number)
{ {
Found = true; Found = true;
break; break;
@ -4196,7 +4195,7 @@ void DoPlayerWarpToSurface(PLAYERp pp)
if (TEST(sector[over_sp->sectnum].extra, SECTFX_DIVE_AREA) && if (TEST(sector[over_sp->sectnum].extra, SECTFX_DIVE_AREA) &&
over_sp->sector()->hasU() && over_sp->sector()->hasU() &&
over_sp->sector()->u()->number == sectu->number) over_sp->sector()->number == sectu->number)
{ {
Found = true; Found = true;
break; break;
@ -4452,7 +4451,7 @@ void DoPlayerDiveMeter(PLAYERp pp)
void DoPlayerDive(PLAYERp pp) void DoPlayerDive(PLAYERp pp)
{ {
USERp u = pp->Actor()->u(); USERp u = pp->Actor()->u();
SECT_USERp sectu = pp->cursector()->u(); auto sectu = pp->cursector();
// whenever your view is not in a water area // whenever your view is not in a water area
if (pp->cursectnum < 0 || !SectorIsUnderwaterArea(pp->cursectnum)) if (pp->cursectnum < 0 || !SectorIsUnderwaterArea(pp->cursectnum))
@ -4648,7 +4647,7 @@ int DoPlayerTestPlaxDeath(PLAYERp pp)
void DoPlayerCurrent(PLAYERp pp) void DoPlayerCurrent(PLAYERp pp)
{ {
int xvect, yvect; int xvect, yvect;
SECT_USERp sectu = pp->cursector()->u(); auto sectu = pp->cursector();
int push_ret; int push_ret;
if (!sectu) if (!sectu)

View file

@ -491,10 +491,9 @@ void WaterAdjust(const Collision& florhit, int32_t* loz)
{ {
auto sect = &sector[florhit.index]; auto sect = &sector[florhit.index];
if (!sect->hasU()) return; if (!sect->hasU()) return;
SECT_USERp sectu = sect->u();
if (sectu && FixedToInt(sectu->depth_fixed)) if (sect->hasU() && FixedToInt(sect->depth_fixed))
*loz += Z(FixedToInt(sectu->depth_fixed)); *loz += Z(FixedToInt(sect->depth_fixed));
} }
} }

View file

@ -182,9 +182,9 @@ void DoRotatorMatch(PLAYERp pp, short match, bool manual)
auto sect = fsp->sector(); auto sect = fsp->sector();
if (pp && sect->hasU() && sect->u()->stag == SECT_LOCK_DOOR && sect->u()->number) if (pp && sect->hasU() && sect->stag == SECT_LOCK_DOOR && sect->number)
{ {
int key_num = sect->u()->number; int key_num = sect->number;
{ {
PutStringInfo(pp, quoteMgr.GetQuote(QUOTE_DOORMSG + key_num - 1)); PutStringInfo(pp, quoteMgr.GetQuote(QUOTE_DOORMSG + key_num - 1));

View file

@ -754,65 +754,6 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, ROTATOR& w, ROTATO
return arc; return arc;
} }
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
FSerializer& Serialize(FSerializer& arc, const char* keyname, SECT_USER& w, SECT_USER* def)
{
static SECT_USER nul;
if (!def)
{
def = &nul;
if (arc.isReading()) w = {};
}
if (arc.BeginObject(keyname))
{
arc("dist", w.dist, def->dist)
("flags", w.flags, def->flags)
("depth", w.depth_fixed, def->depth_fixed)
("stag", w.stag, def->stag)
("ang", w.ang, def->ang)
("height", w.height, def->height)
("speed", w.speed, def->speed)
("damage", w.damage, def->damage)
("number", w.number, def->number)
("flags2", w.flags2, def->flags2)
.EndObject();
}
return arc;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void SerializeSectUser(FSerializer& arc)
{
BitArray hitlist(numsectors);
if (arc.isWriting())
{
for (int i = 0; i < numsectors; i++)
{
hitlist.Set(i, !!SectUser[i].Data());
}
}
else
{
for (int i = 0; i < numsectors; i++)
{
SectUser[i].Clear();
}
}
arc.SerializeMemory("sectusermap", hitlist.Storage().Data(), hitlist.Storage().Size());
arc.SparseArray("sectuser", SectUser, numsectors, hitlist);
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// //
@ -1200,7 +1141,6 @@ void GameInterface::SerializeGameState(FSerializer& arc)
if (arc.BeginObject("state")) if (arc.BeginObject("state"))
{ {
preSerializePanelSprites(arc); preSerializePanelSprites(arc);
SerializeSectUser(arc);
so_serializeinterpolations(arc); so_serializeinterpolations(arc);
arc .SparseArray("actors", swActors, MAXSPRITES, activeSprites) arc .SparseArray("actors", swActors, MAXSPRITES, activeSprites)
("numplayers", numplayers) ("numplayers", numplayers)

View file

@ -748,7 +748,7 @@ int OperateSector(short sectnum, short player_is_operating)
SPRITEp fsp; SPRITEp fsp;
auto sect = &sector[sectnum]; auto sect = &sector[sectnum];
if (sect->hasU() && sect->u()->stag == SECT_LOCK_DOOR) if (sect->hasU() && sect->stag == SECT_LOCK_DOOR)
return false; return false;
SWSectIterator it(sectnum); SWSectIterator it(sectnum);
@ -757,7 +757,7 @@ int OperateSector(short sectnum, short player_is_operating)
fsp = &actor->s(); fsp = &actor->s();
auto fsect = fsp->sector(); auto fsect = fsp->sector();
if (fsect->hasU() && fsect->u()->stag == SECT_LOCK_DOOR) if (fsect->hasU() && fsect->stag == SECT_LOCK_DOOR)
return false; return false;
if (fsp->statnum == STAT_VATOR && SP_TAG1(fsp) == SECT_VATOR && TEST_BOOL7(fsp)) if (fsp->statnum == STAT_VATOR && SP_TAG1(fsp) == SECT_VATOR && TEST_BOOL7(fsp))
@ -1648,8 +1648,8 @@ int OperateSprite(DSWActor* actor, short player_is_operating)
{ {
for(auto& sect : sectors()) for(auto& sect : sectors())
{ {
if (sect.hasU() && sect.u()->stag == SECT_LOCK_DOOR && sect.u()->number == key_num) if (sect.hasU() && sect.stag == SECT_LOCK_DOOR && sect.number == key_num)
sect.u()->number = 0; // unlock all doors of this type sect.number = 0; // unlock all doors of this type
} }
UnlockKeyLock(key_num, actor); UnlockKeyLock(key_num, actor);
} }
@ -2048,7 +2048,7 @@ void OperateContinuousTrigger(PLAYERp pp)
short PlayerTakeSectorDamage(PLAYERp pp) short PlayerTakeSectorDamage(PLAYERp pp)
{ {
SECT_USERp sectu = pp->cursector()->u(); auto sectu = pp->cursector();
USERp u = pp->Actor()->u(); USERp u = pp->Actor()->u();
// the calling routine must make sure sectu exists // the calling routine must make sure sectu exists
@ -2446,11 +2446,10 @@ void PlayerOperateEnv(PLAYERp pp)
// //
// //////////////////////////// // ////////////////////////////
SECT_USERp sectu;
if (pp->cursectnum >= 0 && (sectu = pp->cursector()->u()) && sectu->damage)
{
SECTORp sectp = pp->cursector(); SECTORp sectp = pp->cursector();
if (TEST(sectu->flags, SECTFU_DAMAGE_ABOVE_SECTOR)) if (pp->cursectnum >= 0 && sectp->hasU() && sectp->damage)
{
if (TEST(sectp->flags, SECTFU_DAMAGE_ABOVE_SECTOR))
{ {
PlayerTakeSectorDamage(pp); PlayerTakeSectorDamage(pp);
} }

View file

@ -174,9 +174,9 @@ void DoSlidorMatch(PLAYERp pp, short match, bool manual)
auto sect = fsp->sector(); auto sect = fsp->sector();
if (pp && sect->hasU() && sect->u()->stag == SECT_LOCK_DOOR && sect->u()->number) if (pp && sect->hasU() && sect->stag == SECT_LOCK_DOOR && sect->number)
{ {
int key_num = sect->u()->number; int key_num = sect->number;
{ {
PutStringInfo(pp, quoteMgr.GetQuote(QUOTE_DOORMSG + key_num - 1)); PutStringInfo(pp, quoteMgr.GetQuote(QUOTE_DOORMSG + key_num - 1));

View file

@ -1854,7 +1854,7 @@ void SpriteSetup(void)
case ST1: case ST1:
{ {
SECT_USERp sectu; sectortype* sectp = sp->sector();
short tag; short tag;
short bit; short bit;
@ -1884,8 +1884,8 @@ void SpriteSetup(void)
if (TEST(bit, SECTFX_SINK)) if (TEST(bit, SECTFX_SINK))
{ {
sectu = GetSectUser(sp->sectnum); sectp->u_defined = true;
sectu->depth_fixed = IntToFixed(sp->lotag); sectp->depth_fixed = IntToFixed(sp->lotag);
KillActor(actor); KillActor(actor);
} }
else if (TEST(bit, SECTFX_OPERATIONAL)) else if (TEST(bit, SECTFX_OPERATIONAL))
@ -1894,9 +1894,9 @@ void SpriteSetup(void)
} }
else if (TEST(bit, SECTFX_CURRENT)) else if (TEST(bit, SECTFX_CURRENT))
{ {
sectu = GetSectUser(sp->sectnum); sectp->u_defined = true;
sectu->speed = sp->lotag; sectp->speed = sp->lotag;
sectu->ang = sp->ang; sectp->ang = sp->ang;
KillActor(actor); KillActor(actor);
} }
else if (TEST(bit, SECTFX_NO_RIDE)) else if (TEST(bit, SECTFX_NO_RIDE))
@ -1905,22 +1905,22 @@ void SpriteSetup(void)
} }
else if (TEST(bit, SECTFX_DIVE_AREA)) else if (TEST(bit, SECTFX_DIVE_AREA))
{ {
sectu = GetSectUser(sp->sectnum); sectp->u_defined = true;
sectu->number = sp->lotag; sectp->number = sp->lotag;
change_actor_stat(actor, STAT_DIVE_AREA); change_actor_stat(actor, STAT_DIVE_AREA);
} }
else if (TEST(bit, SECTFX_UNDERWATER)) else if (TEST(bit, SECTFX_UNDERWATER))
{ {
sectu = GetSectUser(sp->sectnum); sectp->u_defined = true;
sectu->number = sp->lotag; sectp->number = sp->lotag;
change_actor_stat(actor, STAT_UNDERWATER); change_actor_stat(actor, STAT_UNDERWATER);
} }
else if (TEST(bit, SECTFX_UNDERWATER2)) else if (TEST(bit, SECTFX_UNDERWATER2))
{ {
sectu = GetSectUser(sp->sectnum); sectp->u_defined = true;
sectu->number = sp->lotag; sectp->number = sp->lotag;
if (sp->clipdist == 1) if (sp->clipdist == 1)
SET(sectu->flags, SECTFU_CANT_SURFACE); SET(sectp->flags, SECTFU_CANT_SURFACE);
change_actor_stat(actor, STAT_UNDERWATER2); change_actor_stat(actor, STAT_UNDERWATER2);
} }
} }
@ -1938,26 +1938,25 @@ void SpriteSetup(void)
#endif #endif
case SECT_MATCH: case SECT_MATCH:
sectu = GetSectUser(sp->sectnum); sectp->u_defined = true;
sectp->number = sp->lotag;
sectu->number = sp->lotag;
KillActor(actor); KillActor(actor);
break; break;
case SLIDE_SECTOR: case SLIDE_SECTOR:
sectu = GetSectUser(sp->sectnum); sectp->u_defined = true;
SET(sectu->flags, SECTFU_SLIDE_SECTOR); SET(sectp->flags, SECTFU_SLIDE_SECTOR);
sectu->speed = SP_TAG2(sp); sectp->speed = SP_TAG2(sp);
KillActor(actor); KillActor(actor);
break; break;
case SECT_DAMAGE: case SECT_DAMAGE:
{ {
sectu = GetSectUser(sp->sectnum); sectp->u_defined = true;
if (TEST_BOOL1(sp)) if (TEST_BOOL1(sp))
SET(sectu->flags, SECTFU_DAMAGE_ABOVE_SECTOR); SET(sectp->flags, SECTFU_DAMAGE_ABOVE_SECTOR);
sectu->damage = sp->lotag; sectp->damage = sp->lotag;
KillActor(actor); KillActor(actor);
break; break;
} }
@ -1979,9 +1978,8 @@ void SpriteSetup(void)
case SECT_DONT_COPY_PALETTE: case SECT_DONT_COPY_PALETTE:
{ {
sectu = GetSectUser(sp->sectnum); sectp->u_defined = true;
SET(sectp->flags, SECTFU_DONT_COPY_PALETTE);
SET(sectu->flags, SECTFU_DONT_COPY_PALETTE);
KillActor(actor); KillActor(actor);
break; break;
} }
@ -2156,15 +2154,14 @@ void SpriteSetup(void)
case SECT_VATOR: case SECT_VATOR:
{ {
SECTORp sectp = sp->sector(); SECTORp sectp = sp->sector();
SECT_USERp sectu;
short speed,vel,time,type,start_on,floor_vator; short speed,vel,time,type,start_on,floor_vator;
u = SpawnUser(actor, 0, nullptr); u = SpawnUser(actor, 0, nullptr);
// vator already set - ceiling AND floor vator // vator already set - ceiling AND floor vator
if (TEST(sectp->extra, SECTFX_VATOR)) if (TEST(sectp->extra, SECTFX_VATOR))
{ {
sectu = GetSectUser(sp->sectnum); sectp->u_defined = true;
SET(sectu->flags, SECTFU_VATOR_BOTH); SET(sectp->flags, SECTFU_VATOR_BOTH);
} }
SET(sectp->extra, SECTFX_VATOR); SET(sectp->extra, SECTFX_VATOR);
SetSectorWallBits(sp->sectnum, WALLFX_DONT_STICK, true, true); SetSectorWallBits(sp->sectnum, WALLFX_DONT_STICK, true, true);
@ -2883,26 +2880,26 @@ void SpriteSetup(void)
case SECT_SO_DONT_BOB: case SECT_SO_DONT_BOB:
{ {
sectu = GetSectUser(sp->sectnum); sectp->u_defined = true;
SET(sectu->flags, SECTFU_SO_DONT_BOB); SET(sectp->flags, SECTFU_SO_DONT_BOB);
KillActor(actor); KillActor(actor);
break; break;
} }
case SECT_LOCK_DOOR: case SECT_LOCK_DOOR:
{ {
sectu = GetSectUser(sp->sectnum); sectp->u_defined = true;
sectu->number = sp->lotag; sectp->number = sp->lotag;
sectu->stag = SECT_LOCK_DOOR; sectp->stag = SECT_LOCK_DOOR;
KillActor(actor); KillActor(actor);
break; break;
} }
case SECT_SO_SINK_DEST: case SECT_SO_SINK_DEST:
{ {
sectu = GetSectUser(sp->sectnum); sectp->u_defined = true;
SET(sectu->flags, SECTFU_SO_SINK_DEST); SET(sectp->flags, SECTFU_SO_SINK_DEST);
sectu->number = sp->lotag; // acually the offset Z sectp->number = sp->lotag; // acually the offset Z
// value // value
KillActor(actor); KillActor(actor);
break; break;
@ -2910,34 +2907,34 @@ void SpriteSetup(void)
case SECT_SO_DONT_SINK: case SECT_SO_DONT_SINK:
{ {
sectu = GetSectUser(sp->sectnum); sectp->u_defined = true;
SET(sectu->flags, SECTFU_SO_DONT_SINK); SET(sectp->flags, SECTFU_SO_DONT_SINK);
KillActor(actor); KillActor(actor);
break; break;
} }
case SO_SLOPE_FLOOR_TO_POINT: case SO_SLOPE_FLOOR_TO_POINT:
{ {
sectu = GetSectUser(sp->sectnum); sectp->u_defined = true;
SET(sectu->flags, SECTFU_SO_SLOPE_FLOOR_TO_POINT); SET(sectp->flags, SECTFU_SO_SLOPE_FLOOR_TO_POINT);
SET(sp->sector()->extra, SECTFX_DYNAMIC_AREA); SET(sectp->extra, SECTFX_DYNAMIC_AREA);
KillActor(actor); KillActor(actor);
break; break;
} }
case SO_SLOPE_CEILING_TO_POINT: case SO_SLOPE_CEILING_TO_POINT:
{ {
sectu = GetSectUser(sp->sectnum); sectp->u_defined = true;
SET(sectu->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT); SET(sectp->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT);
SET(sp->sector()->extra, SECTFX_DYNAMIC_AREA); SET(sectp->extra, SECTFX_DYNAMIC_AREA);
KillActor(actor); KillActor(actor);
break; break;
} }
case SECT_SO_FORM_WHIRLPOOL: case SECT_SO_FORM_WHIRLPOOL:
{ {
sectu = GetSectUser(sp->sectnum); sectp->u_defined = true;
sectu->stag = SECT_SO_FORM_WHIRLPOOL; sectp->stag = SECT_SO_FORM_WHIRLPOOL;
sectu->height = sp->lotag; sectp->height = sp->lotag;
KillActor(actor); KillActor(actor);
break; break;
} }
@ -6729,11 +6726,11 @@ int MissileWaterAdjust(DSWActor* actor)
{ {
USERp u = actor->u(); USERp u = actor->u();
if (u->lo_sectp) auto sectp = u->lo_sectp;
if (sectp && sectp->hasU())
{ {
SECT_USERp sectu = u->lo_sectp->u(); if (FixedToInt(sectp->depth_fixed))
if (sectu && FixedToInt(sectu->depth_fixed)) u->loz -= Z(FixedToInt(sectp->depth_fixed));
u->loz -= Z(FixedToInt(sectu->depth_fixed));
} }
return 0; return 0;
} }

View file

@ -818,7 +818,7 @@ void SectorObjectSetupBounds(SECTOR_OBJECTp sop)
sop->zorig_ceiling[sop->num_sectors] = sect->ceilingz; sop->zorig_ceiling[sop->num_sectors] = sect->ceilingz;
if (TEST(sect->extra, SECTFX_SINK)) if (TEST(sect->extra, SECTFX_SINK))
sop->zorig_floor[sop->num_sectors] += Z(FixedToInt(sect->u()->depth_fixed)); sop->zorig_floor[sop->num_sectors] += Z(FixedToInt(sect->depth_fixed));
// lowest and highest floorz's // lowest and highest floorz's
if (sect->floorz > sop->floor_loz) if (sect->floorz > sop->floor_loz)
@ -2146,7 +2146,7 @@ void MoveZ(SECTOR_OBJECTp sop)
// for all sectors // for all sectors
for (i = 0, sectp = &sop->sectp[0]; *sectp; sectp++, i++) for (i = 0, sectp = &sop->sectp[0]; *sectp; sectp++, i++)
{ {
if (sop->sectp[i]->hasU() && TEST(sop->sectp[i]->u()->flags, SECTFU_SO_DONT_BOB)) if (sop->sectp[i]->hasU() && TEST(sop->sectp[i]->flags, SECTFU_SO_DONT_BOB))
continue; continue;
(*sectp)->floorz = sop->zorig_floor[i] + sop->bob_diff; (*sectp)->floorz = sop->zorig_floor[i] + sop->bob_diff;
@ -2203,7 +2203,7 @@ void CallbackSOsink(ANIMp ap, void *data)
for (i = 0; sop->sector[i] != -1; i++) for (i = 0; sop->sector[i] != -1; i++)
{ {
if (sop->sectp[i]->hasU() && TEST(sop->sectp[i]->u()->flags, SECTFU_SO_SINK_DEST)) if (sop->sectp[i]->hasU() && TEST(sop->sectp[i]->flags, SECTFU_SO_SINK_DEST))
{ {
src_sector = sop->sector[i]; src_sector = sop->sector[i];
break; break;
@ -2494,7 +2494,7 @@ void DoTrack(SECTOR_OBJECTp sop, short locktics, int *nx, int *ny)
for (i = 0; sop->sector[i] != -1; i++) for (i = 0; sop->sector[i] != -1; i++)
{ {
if (sop->sectp[i]->hasU() && TEST(sop->sectp[i]->u()->flags, SECTFU_SO_SINK_DEST)) if (sop->sectp[i]->hasU() && TEST(sop->sectp[i]->flags, SECTFU_SO_SINK_DEST))
{ {
dest_sector = sop->sector[i]; dest_sector = sop->sector[i];
break; break;
@ -2512,7 +2512,7 @@ void DoTrack(SECTOR_OBJECTp sop, short locktics, int *nx, int *ny)
for (i = 0, sectp = &sop->sectp[0]; *sectp; sectp++, i++) for (i = 0, sectp = &sop->sectp[0]; *sectp; sectp++, i++)
{ {
if (sop->sectp[i]->hasU() && TEST(sop->sectp[i]->u()->flags, SECTFU_SO_DONT_SINK)) if (sop->sectp[i]->hasU() && TEST(sop->sectp[i]->flags, SECTFU_SO_DONT_SINK))
continue; continue;
ndx = AnimSet(ANIM_Floorz, sectnum(*sectp), nullptr, sector[dest_sector].floorz, tpoint->tag_high); ndx = AnimSet(ANIM_Floorz, sectnum(*sectp), nullptr, sector[dest_sector].floorz, tpoint->tag_high);
@ -2534,12 +2534,10 @@ void DoTrack(SECTOR_OBJECTp sop, short locktics, int *nx, int *ny)
{ {
if ((*sectp)->hasU()) if ((*sectp)->hasU())
{ {
sectu = (*sectp)->u(); if ((*sectp) && (*sectp)->stag == SECT_SO_FORM_WHIRLPOOL)
if (sectu && sectu->stag == SECT_SO_FORM_WHIRLPOOL)
{ {
AnimSet(ANIM_Floorz, sectnum(*sectp), nullptr, (*sectp)->floorz + Z(sectu->height), 128); AnimSet(ANIM_Floorz, sectnum(*sectp), nullptr, (*sectp)->floorz + Z((*sectp)->height), 128);
(*sectp)->floorshade += sectu->height / 6; (*sectp)->floorshade += (*sectp)->height / 6;
RESET((*sectp)->extra, SECTFX_NO_RIDE); RESET((*sectp)->extra, SECTFX_NO_RIDE);
} }
@ -2727,7 +2725,7 @@ void OperateSectorObjectForTics(SECTOR_OBJECTp sop, short newang, int newx, int
// for all sectors // for all sectors
for (i = 0, sectp = &sop->sectp[0]; *sectp; sectp++, i++) for (i = 0, sectp = &sop->sectp[0]; *sectp; sectp++, i++)
{ {
if (sop->sectp[i]->hasU() && TEST(sop->sectp[i]->u()->flags, SECTFU_SO_DONT_BOB)) if (sop->sectp[i]->hasU() && TEST(sop->sectp[i]->flags, SECTFU_SO_DONT_BOB))
continue; continue;
(*sectp)->floorz = sop->zorig_floor[i] + sop->bob_diff; (*sectp)->floorz = sop->zorig_floor[i] + sop->bob_diff;

View file

@ -174,11 +174,11 @@ void DoVatorOperate(PLAYERp pp, short sectnum)
return; return;
} }
if (pp && fsect->hasU() && fsect->u()->stag == SECT_LOCK_DOOR && fsect->u()->number) if (pp && fsect->hasU() && fsect->stag == SECT_LOCK_DOOR && fsect->number)
{ {
short key_num; short key_num;
key_num = fsect->u()->number; key_num = fsect->number;
{ {
PutStringInfo(pp, quoteMgr.GetQuote(QUOTE_DOORMSG + key_num - 1)); PutStringInfo(pp, quoteMgr.GetQuote(QUOTE_DOORMSG + key_num - 1));
@ -218,9 +218,9 @@ void DoVatorMatch(PLAYERp pp, short match)
// lock code // lock code
auto fsect = fsp->sector(); auto fsect = fsp->sector();
if (pp && fsect->hasU() && fsect->u()->stag == SECT_LOCK_DOOR && fsect->u()->number) if (pp && fsect->hasU() && fsect->stag == SECT_LOCK_DOOR && fsect->number)
{ {
int key_num = fsect->u()->number; int key_num = fsect->number;
{ {
PutStringInfo(pp, quoteMgr.GetQuote(QUOTE_DOORMSG + key_num - 1)); PutStringInfo(pp, quoteMgr.GetQuote(QUOTE_DOORMSG + key_num - 1));
@ -301,7 +301,7 @@ void MoveSpritesWithSector(int sectnum, int z_amt, bool type)
bool both = false; bool both = false;
auto sect = &sector[sectnum]; auto sect = &sector[sectnum];
if ( sect->hasU()) if ( sect->hasU())
both = !!TEST(sect->u()->flags, SECTFU_VATOR_BOTH); both = !!TEST(sect->flags, SECTFU_VATOR_BOTH);
SWSectIterator it(sectnum); SWSectIterator it(sectnum);
while (auto actor = it.Next()) while (auto actor = it.Next())

View file

@ -4335,7 +4335,7 @@ bool WeaponMoveHit(DSWActor* actor)
return true; return true;
} }
if (sector[hit_sect].hasU() && FixedToInt(sector[hit_sect].u()->depth_fixed) > 0) if (sector[hit_sect].hasU() && FixedToInt(sector[hit_sect].depth_fixed) > 0)
{ {
SpawnSplash(actor); SpawnSplash(actor);
return true; return true;
@ -4590,7 +4590,7 @@ int DoFireballFlames(DSWActor* actor)
} }
else else
{ {
if (sp->sector()->hasU() && FixedToInt(sp->sector()->u()->depth_fixed) > 0) if (sp->sector()->hasU() && FixedToInt(sp->sector()->depth_fixed) > 0)
{ {
if (labs(sp->sector()->floorz - sp->z) <= Z(4)) if (labs(sp->sector()->floorz - sp->z) <= Z(4))
{ {
@ -4665,7 +4665,7 @@ int DoBreakFlames(DSWActor* actor)
} }
else else
{ {
if (sp->sector()->hasU() && FixedToInt(sp->sector()->u()->depth_fixed) > 0) if (sp->sector()->hasU() && FixedToInt(sp->sector()->depth_fixed) > 0)
{ {
if (labs(sp->sector()->floorz - sp->z) <= Z(4)) if (labs(sp->sector()->floorz - sp->z) <= Z(4))
{ {
@ -7678,7 +7678,7 @@ int DoStar(DSWActor* actor)
if (sp->z > ((u->hiz + u->loz) >> 1)) if (sp->z > ((u->hiz + u->loz) >> 1))
{ {
if (sector[hit_sect].hasU() && FixedToInt(sector[hit_sect].u()->depth_fixed) > 0) if (sector[hit_sect].hasU() && FixedToInt(sector[hit_sect].depth_fixed) > 0)
{ {
SpawnSplash(actor); SpawnSplash(actor);
KillActor(actor); KillActor(actor);
@ -8625,7 +8625,7 @@ int DoGrenade(DSWActor* actor)
if (TEST(u->Flags, SPR_UNDERWATER)) if (TEST(u->Flags, SPR_UNDERWATER))
SET(u->Flags, SPR_BOUNCE); // no bouncing underwater SET(u->Flags, SPR_BOUNCE); // no bouncing underwater
if (u->lo_sectp && sp->sector()->hasU() && FixedToInt(sp->sector()->u()->depth_fixed)) if (u->lo_sectp && sp->sector()->hasU() && FixedToInt(sp->sector()->depth_fixed))
SET(u->Flags, SPR_BOUNCE); // no bouncing on shallow water SET(u->Flags, SPR_BOUNCE); // no bouncing on shallow water
if (!TEST(u->Flags, SPR_BOUNCE)) if (!TEST(u->Flags, SPR_BOUNCE))
@ -17901,7 +17901,7 @@ int InitEnemyFireball(DSWActor* actor)
bool WarpToUnderwater(short *sectnum, int *x, int *y, int *z) bool WarpToUnderwater(short *sectnum, int *x, int *y, int *z)
{ {
int i; int i;
SECT_USERp sectu = sector[*sectnum].u(); auto sectu = &sector[*sectnum];
SPRITEp under_sp = nullptr, over_sp = nullptr; SPRITEp under_sp = nullptr, over_sp = nullptr;
bool Found = false; bool Found = false;
short over, under; short over, under;
@ -17918,8 +17918,8 @@ bool WarpToUnderwater(short *sectnum, int *x, int *y, int *z)
over_sp = &itActor->s(); over_sp = &itActor->s();
if (TEST(sector[over_sp->sectnum].extra, SECTFX_DIVE_AREA) && if (TEST(sector[over_sp->sectnum].extra, SECTFX_DIVE_AREA) &&
over_sp->sector()->hasU() && over_sp->sector()->hasU() && sectu->hasU() &&
over_sp->sector()->u()->number == sectu->number) over_sp->sector()->number == sectu->number)
{ {
Found = true; Found = true;
break; break;
@ -17937,7 +17937,7 @@ bool WarpToUnderwater(short *sectnum, int *x, int *y, int *z)
if (TEST(sector[under_sp->sectnum].extra, SECTFX_UNDERWATER) && if (TEST(sector[under_sp->sectnum].extra, SECTFX_UNDERWATER) &&
under_sp->sector()->hasU() && under_sp->sector()->hasU() &&
under_sp->sector()->u()->number == sectu->number) under_sp->sector()->number == sectu->number)
{ {
Found = true; Found = true;
break; break;
@ -17974,7 +17974,7 @@ bool WarpToUnderwater(short *sectnum, int *x, int *y, int *z)
bool WarpToSurface(short *sectnum, int *x, int *y, int *z) bool WarpToSurface(short *sectnum, int *x, int *y, int *z)
{ {
int i; int i;
SECT_USERp sectu = sector[*sectnum].u(); auto sectu = &sector[*sectnum];
short over, under; short over, under;
int sx, sy; int sx, sy;
@ -17992,8 +17992,8 @@ bool WarpToSurface(short *sectnum, int *x, int *y, int *z)
under_sp = &itActor->s(); under_sp = &itActor->s();
if (TEST(sector[under_sp->sectnum].extra, SECTFX_UNDERWATER) && if (TEST(sector[under_sp->sectnum].extra, SECTFX_UNDERWATER) &&
under_sp->sector()->hasU() && under_sp->sector()->hasU() && sectu->hasU() &&
under_sp->sector()->u()->number == sectu->number) under_sp->sector()->number == sectu->number)
{ {
Found = true; Found = true;
break; break;
@ -18011,7 +18011,7 @@ bool WarpToSurface(short *sectnum, int *x, int *y, int *z)
if (TEST(sector[over_sp->sectnum].extra, SECTFX_DIVE_AREA) && if (TEST(sector[over_sp->sectnum].extra, SECTFX_DIVE_AREA) &&
over_sp->sector()->hasU() && over_sp->sector()->hasU() &&
over_sp->sector()->u()->number == sectu->number) over_sp->sector()->number == sectu->number)
{ {
Found = true; Found = true;
break; break;
@ -18047,7 +18047,7 @@ bool SpriteWarpToUnderwater(DSWActor* actor)
USERp u = actor->u(); USERp u = actor->u();
auto sp = &actor->s(); auto sp = &actor->s();
int i; int i;
SECT_USERp sectu = sp->sector()->u(); auto sectu = sp->sector();
SPRITEp under_sp = nullptr, over_sp = nullptr; SPRITEp under_sp = nullptr, over_sp = nullptr;
bool Found = false; bool Found = false;
short over, under; short over, under;
@ -18065,7 +18065,7 @@ bool SpriteWarpToUnderwater(DSWActor* actor)
if (TEST(sector[over_sp->sectnum].extra, SECTFX_DIVE_AREA) && if (TEST(sector[over_sp->sectnum].extra, SECTFX_DIVE_AREA) &&
over_sp->sector()->hasU() && over_sp->sector()->hasU() &&
over_sp->sector()->u()->number == sectu->number) over_sp->sector()->number == sectu->number)
{ {
Found = true; Found = true;
break; break;
@ -18083,7 +18083,7 @@ bool SpriteWarpToUnderwater(DSWActor* actor)
if (TEST(sector[under_sp->sectnum].extra, SECTFX_UNDERWATER) && if (TEST(sector[under_sp->sectnum].extra, SECTFX_UNDERWATER) &&
under_sp->sector()->hasU() && under_sp->sector()->hasU() &&
under_sp->sector()->u()->number == sectu->number) under_sp->sector()->number == sectu->number)
{ {
Found = true; Found = true;
break; break;
@ -18124,7 +18124,7 @@ bool SpriteWarpToSurface(DSWActor* actor)
{ {
USERp u = actor->u(); USERp u = actor->u();
auto sp = &actor->s(); auto sp = &actor->s();
SECT_USERp sectu = sp->sector()->u(); auto sectu = sp->sector();
short over, under; short over, under;
int sx, sy; int sx, sy;
@ -18143,7 +18143,7 @@ bool SpriteWarpToSurface(DSWActor* actor)
if (TEST(sector[under_sp->sectnum].extra, SECTFX_UNDERWATER) && if (TEST(sector[under_sp->sectnum].extra, SECTFX_UNDERWATER) &&
under_sp->sector()->hasU() && under_sp->sector()->hasU() &&
under_sp->sector()->u()->number == sectu->number) under_sp->sector()->number == sectu->number)
{ {
Found = true; Found = true;
break; break;
@ -18165,7 +18165,7 @@ bool SpriteWarpToSurface(DSWActor* actor)
if (TEST(sector[over_sp->sectnum].extra, SECTFX_DIVE_AREA) && if (TEST(sector[over_sp->sectnum].extra, SECTFX_DIVE_AREA) &&
over_sp->sector()->hasU() && over_sp->sector()->hasU() &&
over_sp->sector()->u()->number == sectu->number) over_sp->sector()->number == sectu->number)
{ {
Found = true; Found = true;
break; break;
@ -18208,7 +18208,7 @@ int SpawnSplash(DSWActor* actor)
USERp u = actor->u(), wu; USERp u = actor->u(), wu;
SPRITEp sp = &actor->s(), wp; SPRITEp sp = &actor->s(), wp;
SECT_USERp sectu = sp->sector()->u(); auto sectu = sp->sector();
SECTORp sectp = sp->sector(); SECTORp sectp = sp->sector();
if (Prediction) if (Prediction)
@ -18243,28 +18243,24 @@ int SpawnSplashXY(int hit_x, int hit_y, int hit_z, int sectnum)
{ {
USERp wu; USERp wu;
SPRITEp wp; SPRITEp wp;
//short sectnum=0;
SECT_USERp sectu;
SECTORp sectp; SECTORp sectp;
if (Prediction) if (Prediction)
return 0; return 0;
sectp = &sector[sectnum]; sectp = &sector[sectnum];
sectu = sectp->hasU() ? sectp->u() : nullptr;
if (sectu && (TEST(sectp->extra, SECTFX_LIQUID_MASK) == SECTFX_LIQUID_NONE)) if (sectp->hasU() && (TEST(sectp->extra, SECTFX_LIQUID_MASK) == SECTFX_LIQUID_NONE))
return 0; return 0;
if (sectu && TEST(sectp->floorstat, FLOOR_STAT_PLAX)) if (sectp->hasU() && TEST(sectp->floorstat, FLOOR_STAT_PLAX))
return 0; return 0;
auto actorNew = SpawnActor(STAT_MISSILE, SPLASH, s_Splash, sectnum, hit_x, hit_y, hit_z, 0, 0); auto actorNew = SpawnActor(STAT_MISSILE, SPLASH, s_Splash, sectnum, hit_x, hit_y, hit_z, 0, 0);
wp = &actorNew->s(); wp = &actorNew->s();
wu = actorNew->u(); wu = actorNew->u();
if (sectu && TEST(sectp->extra, SECTFX_LIQUID_MASK) == SECTFX_LIQUID_LAVA) if (sectp->hasU() && TEST(sectp->extra, SECTFX_LIQUID_MASK) == SECTFX_LIQUID_LAVA)
wu->spal = wp->pal = PALETTE_RED_LIGHTING; wu->spal = wp->pal = PALETTE_RED_LIGHTING;
wp->xrepeat = 45; wp->xrepeat = 45;
@ -19337,7 +19333,7 @@ int DoShrapVelocity(DSWActor* actor)
if (TEST(u->Flags, SPR_UNDERWATER)) if (TEST(u->Flags, SPR_UNDERWATER))
SET(u->Flags, SPR_BOUNCE); // no bouncing underwater SET(u->Flags, SPR_BOUNCE); // no bouncing underwater
if (u->lo_sectp && sp->sector()->hasU() && FixedToInt(sp->sector()->u()->depth_fixed)) if (u->lo_sectp && sp->sector()->hasU() && FixedToInt(sp->sector()->depth_fixed))
SET(u->Flags, SPR_BOUNCE); // no bouncing on shallow water SET(u->Flags, SPR_BOUNCE); // no bouncing on shallow water
if (!TEST(u->Flags, SPR_BOUNCE)) if (!TEST(u->Flags, SPR_BOUNCE))

View file

@ -811,7 +811,7 @@ void SpawnZombie2(DSWActor* actor)
SPRITEp sp = &actor->s(); SPRITEp sp = &actor->s();
SPRITEp np; SPRITEp np;
USERp nu; USERp nu;
SECT_USERp sectu = sp->sector()->u(); auto sectu = sp->sector();
SECTORp sectp = sp->sector(); SECTORp sectp = sp->sector();
auto ownerActor = GetOwner(actor); auto ownerActor = GetOwner(actor);