- SW: save SectUser as JSON, also store in a managed array.

This commit is contained in:
Christoph Oelckers 2021-04-02 12:55:58 +02:00
parent 06b03f7301
commit 66e5b9ada7
25 changed files with 180 additions and 128 deletions

34
l Normal file
View file

@ -0,0 +1,34 @@
- added a fallback generic record to grpinfo.txt for identifying Blood.rff based on content.
- gave key 7 a proper spawn record using the blue outline as image. A proper definition here is needed to allow dropping this item. The original code had a picnum of -1 here which caused crashes.
- cleanup of movie player code, migration to event interface.
- Screen Job refactoring to fix the volatile timer in there causing problems with the menu.
- split out the movie player into its own file.
- Duke: Clamp RRRA vehicle input in `processVehicleInput()`.
- Duke: Add `resurrected` flag to handle resurrection via cheating or when pissing in RR.
- added a filter to the directory loader to remove EDuke32's texture cache files. These cause problems with the texture manager.
- make map art work.
- allow specifying startup .con files via GAMEINFO.
- used the newly added game ID as reference for GAMEINFO to autoselect which game to start a mod with.
- added GameID field to GrpInfo. This is for allowing new features easier referencing of the various records.
- Exhumed: Redo player panning code, but guard it with cl_slopetilting as it does not work that well with mouselook.
- Exhumed: fix for moving on sloped floors
- added widescreen graphics credits to the Engine Credits menu.
- Blood: default skill is 3, not 2.
- fixed some bogus range checks in automap code.
- fixed the vertical offsets of the World Tour skies. They were rendered too low.
- added native support for Nightfright's Alien World Order" GRP generator.
- enable embedding of blood.rff and sounds.rff in mod archives when playing Blood Some mods provide pregenerated resources, this allows loading them without picking them apart first.
- Blood: add a dummy sound entry at index 0 so that no valid sound gets placed in this slot.
- Blood: fixed issue with INI detection when having content added by RFS files.
- added PlaySound CCNDs.
- Blood: fixed mixup of values 0 and -1 in sound code.
- added CHANF_FORCE flag for forcing non-looped sounds to start, even when sound is paused.
- make sure voxels are being precached.
- disabled the QAV preload calls in Blood. This is ultimately more harmful than useful as it forces loading of a large number of textures at the same time during gameplay instead of spreading them out.
- fixed texture precaching. After the migration to GZDoom's full backend this never created any textures when precaching things.
- fixed: alpha was never set for voxels.
- fixed palette setup for duplicate base palettes. Fixes #301 - Blood's invulnerability palette is identical to the base.
- activate the progress bar on the startup screen.
- make the startup banner in the initial console window work.
- Blood: undid restriction for original QAV for Guns Akimbo shotgun fix.

View file

@ -300,7 +300,7 @@ DoDebrisCurrent(SPRITEp sp)
int nx, ny;
int ret=0;
USERp u = User[sp - sprite].Data();
SECT_USERp sectu = SectUser[sp->sectnum];
SECT_USERp sectu = SectUser[sp->sectnum].Data();
//sp->clipdist = (256+128)>>2;
@ -330,7 +330,7 @@ DoActorSectorDamage(short SpriteNum)
{
SPRITEp sp = &sprite[SpriteNum];
USERp u = User[SpriteNum].Data();
SECT_USERp sectu = SectUser[sp->sectnum];
SECT_USERp sectu = SectUser[sp->sectnum].Data();
SECTORp sectp = &sector[sp->sectnum];
if (u->Health <= 0)
@ -455,7 +455,7 @@ DoActorDebris(short SpriteNum)
}
}
if (SectUser[sp->sectnum] && SectUser[sp->sectnum]->depth > 10) // JBF: added null check
if (SectUser[sp->sectnum].Data() && SectUser[sp->sectnum]->depth > 10) // JBF: added null check
{
u->WaitTics = (u->WaitTics + (ACTORMOVETICS << 3)) & 1023;
//sp->z = Z(2) + u->loz + ((Z(4) * (int) bsin(u->WaitTics)) >> 14);
@ -539,7 +539,7 @@ KeepActorOnFloor(short SpriteNum)
if (TEST(u->Flags, SPR_JUMPING | SPR_FALLING))
return;
if (u->lo_sectp && SectUser[u->lo_sectp - sector])
if (u->lo_sectp && SectUser[u->lo_sectp - sector].Data())
depth = SectUser[u->lo_sectp - sector]->depth;
else
depth = 0;

View file

@ -241,7 +241,7 @@ static void ItemCheat(int player)
for (int i = 0; i < numsectors; i++)
{
if (SectUser[i] && SectUser[i]->stag == SECT_LOCK_DOOR)
if (SectUser[i].Data() && SectUser[i]->stag == SECT_LOCK_DOOR)
SectUser[i]->number = 0; // unlock all doors of this type
}
}

View file

@ -668,7 +668,7 @@ int DoCoolgMatchPlayerZ(short SpriteNum)
hiz = u->hiz;
// adjust loz/hiz for water depth
if (u->lo_sectp && SectUser[u->lo_sectp - sector] && SectUser[u->lo_sectp - sector]->depth)
if (u->lo_sectp && SectUser[u->lo_sectp - sector].Data() && SectUser[u->lo_sectp - sector]->depth)
loz -= Z(SectUser[u->lo_sectp - sector]->depth) - Z(8);
// lower bound

View file

@ -476,7 +476,7 @@ void EnemyDefaults(short SpriteNum, ACTOR_ACTION_SETp action, PERSONALITYp perso
int i;
short sectnum = u->lo_sectp - sector;
if (SectUser[sectnum] && TEST(u->lo_sectp->extra, SECTFX_SINK))
if (SectUser[sectnum].Data() && TEST(u->lo_sectp->extra, SECTFX_SINK))
{
depth = SectUser[sectnum]->depth;
}

View file

@ -207,7 +207,7 @@ void CopySectorMatch(short match)
}
// copy sector user if there is one
if (SectUser[src_sp->sectnum] || SectUser[dest_sp->sectnum])
if (SectUser[src_sp->sectnum].Data() || SectUser[dest_sp->sectnum].Data())
{
SECT_USERp ssectu = GetSectUser(src_sp->sectnum);
SECT_USERp dsectu = GetSectUser(dest_sp->sectnum);

View file

@ -676,7 +676,7 @@ analyzesprites(int viewx, int viewy, int viewz, bool mirror)
else
{
// if sector pal is something other than default
SECT_USERp sectu = SectUser[tsp->sectnum];
SECT_USERp sectu = SectUser[tsp->sectnum].Data();
uint8_t pal = sector[tsp->sectnum].floorpal;
bool nosectpal=false;

View file

@ -504,7 +504,7 @@ int DoEelMatchPlayerZ(short SpriteNum)
hiz = u->hiz;
// adjust loz/hiz for water depth
if (u->lo_sectp && SectUser[u->lo_sectp - sector] && SectUser[u->lo_sectp - sector]->depth)
if (u->lo_sectp && SectUser[u->lo_sectp - sector].Data() && SectUser[u->lo_sectp - sector]->depth)
loz -= Z(SectUser[u->lo_sectp - sector]->depth) - Z(8);
// lower bound

View file

@ -492,19 +492,7 @@ void TerminateLevel(void)
}
// Free SectUser memory
for (sectu = &SectUser[0];
sectu < &SectUser[MAXSECTORS];
sectu++)
{
if (*sectu)
{
FreeMem(*sectu);
*sectu = NULL;
}
}
//memset(&User[0], 0, sizeof(User));
memset(&SectUser[0], 0, sizeof(SectUser));
for (auto& su : SectUser) su.Clear();
TRAVERSE_CONNECT(pnum)
{

View file

@ -1548,8 +1548,9 @@ enum ShrapType
SHRAP_USER_DEFINED = 99
};
typedef struct
typedef struct SECT_USER
{
SECT_USER() { memset(this, 0, sizeof(*this)); }
int dist, flags;
short depth_fract, depth; // do NOT change this, doubles as a long FIXED point number
short stag, // ST? tag number - for certain things it helps to know it
@ -1559,9 +1560,9 @@ typedef struct
damage,
number; // usually used for matching number
uint8_t flags2;
} SECT_USER, *SECT_USERp;
} *SECT_USERp;
extern SECT_USERp SectUser[MAXSECTORS];
extern TPointer<SECT_USER> SectUser[MAXSECTORS];
SECT_USERp SpawnSectUser(short sectnum);

View file

@ -380,7 +380,7 @@ int DoHornetMatchPlayerZ(short SpriteNum)
hiz = u->hiz;
// adjust loz/hiz for water depth
if (u->lo_sectp && SectUser[u->lo_sectp - sector] && SectUser[u->lo_sectp - sector]->depth)
if (u->lo_sectp && SectUser[u->lo_sectp - sector].Data() && SectUser[u->lo_sectp - sector]->depth)
loz -= Z(SectUser[u->lo_sectp - sector]->depth) - Z(8);
// lower bound

View file

@ -515,7 +515,7 @@ DoBloodSpray(int16_t Weapon)
SET(u->Flags, SPR_BOUNCE); // no bouncing
// underwater
if (u->lo_sectp && SectUser[sp->sectnum] && SectUser[sp->sectnum]->depth)
if (u->lo_sectp && SectUser[sp->sectnum].Data() && SectUser[sp->sectnum]->depth)
SET(u->Flags, SPR_BOUNCE); // no bouncing on
// shallow water
@ -739,7 +739,7 @@ DoPhosphorus(int16_t Weapon)
SET(u->Flags, SPR_BOUNCE); // no bouncing
// underwater
if (u->lo_sectp && SectUser[sp->sectnum] && SectUser[sp->sectnum]->depth)
if (u->lo_sectp && SectUser[sp->sectnum].Data() && SectUser[sp->sectnum]->depth)
SET(u->Flags, SPR_BOUNCE); // no bouncing on
// shallow water
@ -976,7 +976,7 @@ DoChemBomb(int16_t Weapon)
SET(u->Flags, SPR_BOUNCE); // no bouncing
// underwater
if (u->lo_sectp && SectUser[sp->sectnum] && SectUser[sp->sectnum]->depth)
if (u->lo_sectp && SectUser[sp->sectnum].Data() && SectUser[sp->sectnum]->depth)
SET(u->Flags, SPR_BOUNCE); // no bouncing on
// shallow water
@ -1210,7 +1210,7 @@ DoCaltrops(int16_t Weapon)
SET(u->Flags, SPR_BOUNCE); // no bouncing
// underwater
if (u->lo_sectp && SectUser[sp->sectnum] && SectUser[sp->sectnum]->depth)
if (u->lo_sectp && SectUser[sp->sectnum].Data() && SectUser[sp->sectnum]->depth)
SET(u->Flags, SPR_BOUNCE); // no bouncing on
// shallow water

View file

@ -357,7 +357,7 @@ MorphTornado(SECTOR_OBJECTp sop)
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
{
if (SectUser[*sectp - sector] &&
if (SectUser[*sectp - sector].Data() &&
TEST(SectUser[*sectp - sector]->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT))
{
#define TOR_LOW (floorz)
@ -450,7 +450,7 @@ MorphFloor(SECTOR_OBJECTp sop)
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
{
if (SectUser[*sectp - sector] &&
if (SectUser[*sectp - sector].Data() &&
TEST(SectUser[*sectp - sector]->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT))
{
alignflorslope(*sectp - sector, mx, my, floorz + sop->morph_z);
@ -466,7 +466,7 @@ SOBJ_AlignFloorToPoint(SECTOR_OBJECTp sop, int x, int y, int z)
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
{
if (SectUser[*sectp - sector] &&
if (SectUser[*sectp - sector].Data() &&
TEST(SectUser[*sectp - sector]->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT))
{
alignflorslope(*sectp - sector, x, y, z);
@ -482,7 +482,7 @@ SOBJ_AlignCeilingToPoint(SECTOR_OBJECTp sop, int x, int y, int z)
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
{
if (SectUser[*sectp - sector] &&
if (SectUser[*sectp - sector].Data() &&
TEST(SectUser[*sectp - sector]->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT))
{
alignceilslope(*sectp - sector, x, y, z);
@ -498,7 +498,7 @@ SOBJ_AlignFloorCeilingToPoint(SECTOR_OBJECTp sop, int x, int y, int z)
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
{
if (SectUser[*sectp - sector] &&
if (SectUser[*sectp - sector].Data() &&
TEST(SectUser[*sectp - sector]->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT))
{
alignflorslope(*sectp - sector, x, y, z);

View file

@ -7030,7 +7030,7 @@ pDisplaySprites(PLAYERp pp, double smoothratio)
int16_t floorshade = 0;
if (pp->cursectnum >= 0)
{
sectu = SectUser[pp->cursectnum];
sectu = SectUser[pp->cursectnum].Data();
pal = sector[pp->cursectnum].floorpal;
floorshade = sector[pp->cursectnum].floorshade;

View file

@ -1651,7 +1651,7 @@ void SlipSlope(PLAYERp pp)
short ang;
SECT_USERp sectu;
if (pp->cursectnum < 0 || !(sectu = SectUser[pp->cursectnum]) || !TEST(sectu->flags, SECTFU_SLIDE_SECTOR) || !TEST(sector[pp->cursectnum].floorstat, FLOOR_STAT_SLOPE))
if (pp->cursectnum < 0 || !(sectu = SectUser[pp->cursectnum].Data()) || !TEST(sectu->flags, SECTFU_SLIDE_SECTOR) || !TEST(sector[pp->cursectnum].floorstat, FLOOR_STAT_SLOPE))
return;
short wallptr = sector[pp->cursectnum].wallptr;
@ -3251,7 +3251,7 @@ DoPlayerFall(PLAYERp pp)
if (PlayerFloorHit(pp, pp->loz - PLAYER_HEIGHT + recoil_amt))
{
SECT_USERp sectu = SectUser[pp->cursectnum];
SECT_USERp sectu = SectUser[pp->cursectnum].Data();
SECTORp sectp = &sector[pp->cursectnum];
PlayerSectorBound(pp, Z(1));
@ -4111,7 +4111,7 @@ GetOverlapSector(int x, int y, short *over, short *under)
int i, found = 0;
short sf[2]= {0,0}; // sectors found
if ((SectUser[*under] && SectUser[*under]->number >= 30000) || (SectUser[*over] && SectUser[*over]->number >= 30000))
if ((SectUser[*under].Data() && SectUser[*under]->number >= 30000) || (SectUser[*over].Data() && SectUser[*over]->number >= 30000))
return GetOverlapSector2(x,y,over,under);
// instead of check ALL sectors, just check the two most likely first
@ -4269,7 +4269,7 @@ DoPlayerWarpToUnderwater(PLAYERp pp)
{
USERp u = User[pp->PlayerSprite].Data();
int i;
SECT_USERp sectu = SectUser[pp->cursectnum];
SECT_USERp sectu = SectUser[pp->cursectnum].Data();
SPRITEp under_sp = NULL, over_sp = NULL;
bool Found = false;
short over, under;
@ -4285,7 +4285,7 @@ DoPlayerWarpToUnderwater(PLAYERp pp)
over_sp = &sprite[i];
if (TEST(sector[over_sp->sectnum].extra, SECTFX_DIVE_AREA) &&
SectUser[over_sp->sectnum] &&
SectUser[over_sp->sectnum].Data() &&
SectUser[over_sp->sectnum]->number == sectu->number)
{
Found = true;
@ -4303,7 +4303,7 @@ DoPlayerWarpToUnderwater(PLAYERp pp)
under_sp = &sprite[i];
if (TEST(sector[under_sp->sectnum].extra, SECTFX_UNDERWATER) &&
SectUser[under_sp->sectnum] &&
SectUser[under_sp->sectnum].Data() &&
SectUser[under_sp->sectnum]->number == sectu->number)
{
Found = true;
@ -4346,7 +4346,7 @@ DoPlayerWarpToSurface(PLAYERp pp)
{
USERp u = User[pp->PlayerSprite].Data();
int i;
SECT_USERp sectu = SectUser[pp->cursectnum];
SECT_USERp sectu = SectUser[pp->cursectnum].Data();
short over, under;
SPRITEp under_sp = NULL, over_sp = NULL;
@ -4362,7 +4362,7 @@ DoPlayerWarpToSurface(PLAYERp pp)
under_sp = &sprite[i];
if (TEST(sector[under_sp->sectnum].extra, SECTFX_UNDERWATER) &&
SectUser[under_sp->sectnum] &&
SectUser[under_sp->sectnum].Data() &&
SectUser[under_sp->sectnum]->number == sectu->number)
{
Found = true;
@ -4380,7 +4380,7 @@ DoPlayerWarpToSurface(PLAYERp pp)
over_sp = &sprite[i];
if (TEST(sector[over_sp->sectnum].extra, SECTFX_DIVE_AREA) &&
SectUser[over_sp->sectnum] &&
SectUser[over_sp->sectnum].Data() &&
SectUser[over_sp->sectnum]->number == sectu->number)
{
Found = true;
@ -4645,7 +4645,7 @@ void
DoPlayerDive(PLAYERp pp)
{
USERp u = User[pp->PlayerSprite].Data();
SECT_USERp sectu = SectUser[pp->cursectnum];
SECT_USERp sectu = SectUser[pp->cursectnum].Data();
// whenever your view is not in a water area
if (pp->cursectnum < 0 || !SectorIsUnderwaterArea(pp->cursectnum))
@ -4844,7 +4844,7 @@ void
DoPlayerCurrent(PLAYERp pp)
{
int xvect, yvect;
SECT_USERp sectu = SectUser[pp->cursectnum];
SECT_USERp sectu = SectUser[pp->cursectnum].Data();
int push_ret;
if (!sectu)

View file

@ -490,7 +490,7 @@ void WaterAdjust(short florhit, int32_t* loz)
{
case HIT_SECTOR:
{
SECT_USERp sectu = SectUser[NORM_SECTOR(florhit)];
SECT_USERp sectu = SectUser[NORM_SECTOR(florhit)].Data();
if (sectu && sectu->depth)
*loz += Z(sectu->depth);

View file

@ -193,7 +193,7 @@ DoRotatorMatch(PLAYERp pp, short match, bool manual)
sectnum = fsp->sectnum;
if (pp && SectUser[sectnum] && SectUser[sectnum]->stag == SECT_LOCK_DOOR && SectUser[sectnum]->number)
if (pp && SectUser[sectnum].Data() && SectUser[sectnum]->stag == SECT_LOCK_DOOR && SectUser[sectnum]->number)
{
short key_num;

View file

@ -658,6 +658,65 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, ROTATOR& w, ROTATO
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_fract", w.depth_fract, def->depth_fract)
("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)
{
FixedBitArray<MAXSECTORS> hitlist;
if (arc.isWriting())
{
for (int i = 0; i < MAXSECTORS; i++)
{
hitlist.Set(i, !!SectUser[i].Data());
}
}
else
{
for (int i = 0; i < MAXSECTORS; i++)
{
SectUser[i].Clear();
}
}
arc("sectusermap", hitlist);
arc.SparseArray("sectuser", SectUser, MAXSECTORS, hitlist);
}
//---------------------------------------------------------------------------
//
//
@ -819,7 +878,8 @@ void GameInterface::SerializeGameState(FSerializer& arc)
{
preSerializePanelSprites(arc);
SerializeUser(arc);
arc("numplayers", numplayers)
SerializeSectUser(arc);
arc("numplayers", numplayers)
.Array("players", Player, numplayers)
;
postSerializePanelSprites(arc);
@ -924,26 +984,6 @@ bool GameInterface::SaveGame()
MWRITE(&Skill,sizeof(Skill),1,fil);
//Sector User information
for (i = 0; i < numsectors; i++)
{
sectu = SectUser[i];
ndx = i;
if (sectu)
{
// write header
MWRITE(&ndx,sizeof(ndx),1,fil);
MWRITE(sectu,sizeof(SECT_USER),1,fil);
}
else
{
// write trailer
ndx = -1;
MWRITE(&ndx,sizeof(ndx),1,fil);
}
}
//
// Sector object
//
@ -1017,9 +1057,9 @@ bool GameInterface::SaveGame()
{
for (j=0; j<numsectors; j++)
{
if (SectUser[j])
if (SectUser[j].Data())
{
uint8_t* bp = (uint8_t*)SectUser[j];
uint8_t* bp = (uint8_t*)SectUser[j].Data();
if ((uint8_t*)a->ptr >= bp && (uint8_t*)a->ptr < bp + sizeof(SECT_USER))
{
@ -1148,18 +1188,6 @@ bool GameInterface::LoadGame()
MREAD(&Skill,sizeof(Skill),1,fil);
//Sector User information
for (i = 0; i < numsectors; i++)
{
MREAD(&sectnum,sizeof(sectnum),1,fil);
if (sectnum != -1)
{
SectUser[sectnum] = sectu = (SECT_USERp)CallocMem(sizeof(SECT_USER), 1);
MREAD(sectu,sizeof(SECT_USER),1,fil);
}
}
MREAD(SectorObject, sizeof(SectorObject),1,fil);
for (ndx = 0; ndx < (short)SIZ(SectorObject); ndx++)
@ -1223,7 +1251,7 @@ bool GameInterface::LoadGame()
int offset;
MREAD(&j, sizeof(j),1,fil);
MREAD(&offset, sizeof(offset),1,fil);
a->ptr = (int *)(((char *)SectUser[j]) + offset);
a->ptr = (int *)(((char *)SectUser[j].Data()) + offset);
}
else
{

View file

@ -82,7 +82,7 @@ int lavadropsiz[LAVAMAXDROPS], lavadropsizlookup[LAVAMAXDROPS];
int lavaradx[32][128], lavarady[32][128], lavaradcnt[32];
#endif
SECT_USERp SectUser[MAXSECTORS];
TPointer<SECT_USER> SectUser[MAXSECTORS];
TPointer<USER> User[MAXSPRITES];
ANIM Anim[MAXANIM];
@ -868,7 +868,7 @@ OperateSector(short sectnum, short player_is_operating)
SPRITEp fsp;
int i;
if (SectUser[sectnum] && SectUser[sectnum]->stag == SECT_LOCK_DOOR)
if (SectUser[sectnum].Data() && SectUser[sectnum]->stag == SECT_LOCK_DOOR)
return false;
SectIterator it(sectnum);
@ -876,7 +876,7 @@ OperateSector(short sectnum, short player_is_operating)
{
fsp = &sprite[i];
if (SectUser[fsp->sectnum] && SectUser[fsp->sectnum]->stag == SECT_LOCK_DOOR)
if (SectUser[fsp->sectnum].Data() && SectUser[fsp->sectnum]->stag == SECT_LOCK_DOOR)
return false;
if (fsp->statnum == STAT_VATOR && SP_TAG1(fsp) == SECT_VATOR && TEST_BOOL7(fsp))
@ -1830,7 +1830,7 @@ OperateSprite(short SpriteNum, short player_is_operating)
int i;
for (i=0; i<numsectors; i++)
{
if (SectUser[i] && SectUser[i]->stag == SECT_LOCK_DOOR && SectUser[i]->number == key_num)
if (SectUser[i].Data() && SectUser[i]->stag == SECT_LOCK_DOOR && SectUser[i]->number == key_num)
SectUser[i]->number = 0; // unlock all doors of this type
}
UnlockKeyLock(key_num, SpriteNum);
@ -2283,7 +2283,7 @@ OperateContinuousTrigger(PLAYERp pp)
short PlayerTakeSectorDamage(PLAYERp pp)
{
SECT_USERp sectu = SectUser[pp->cursectnum];
SECT_USERp sectu = SectUser[pp->cursectnum].Data();
USERp u = User[pp->PlayerSprite].Data();
// the calling routine must make sure sectu exists
@ -2697,7 +2697,7 @@ PlayerOperateEnv(PLAYERp pp)
// ////////////////////////////
SECT_USERp sectu;
if (pp->cursectnum >= 0 && (sectu = SectUser[pp->cursectnum]) && sectu->damage)
if (pp->cursectnum >= 0 && (sectu = SectUser[pp->cursectnum].Data()) && sectu->damage)
{
SECTORp sectp = &sector[pp->cursectnum];
if (TEST(sectu->flags, SECTFU_DAMAGE_ABOVE_SECTOR))

View file

@ -189,7 +189,7 @@ DoSlidorMatch(PLAYERp pp, short match, bool manual)
sectnum = fsp->sectnum;
if (pp && SectUser[sectnum] && SectUser[sectnum]->stag == SECT_LOCK_DOOR && SectUser[sectnum]->number)
if (pp && SectUser[sectnum].Data() && SectUser[sectnum]->stag == SECT_LOCK_DOOR && SectUser[sectnum]->number)
{
short key_num;

View file

@ -931,10 +931,11 @@ GetSectUser(short sectnum)
{
SECT_USERp sectu;
if (SectUser[sectnum])
return SectUser[sectnum];
if (SectUser[sectnum].Data())
return SectUser[sectnum].Data();
sectu = SectUser[sectnum] = (SECT_USERp) CallocMem(sizeof(SECT_USER), 1);
SectUser[sectnum].Alloc();
sectu = SectUser[sectnum].Data();
ASSERT(sectu != NULL);
@ -7153,7 +7154,7 @@ MissileWaterAdjust(short SpriteNum)
if (u->lo_sectp)
{
SECT_USERp sectu = SectUser[u->lo_sectp - sector];
SECT_USERp sectu = SectUser[u->lo_sectp - sector].Data();
if (sectu && sectu->depth)
u->loz -= Z(sectu->depth);
}

View file

@ -2180,7 +2180,7 @@ MoveZ(SECTOR_OBJECTp sop)
// for all sectors
for (i = 0, sectp = &sop->sectp[0]; *sectp; sectp++, i++)
{
if (SectUser[sop->sector[i]] && TEST(SectUser[sop->sector[i]]->flags, SECTFU_SO_DONT_BOB))
if (SectUser[sop->sector[i]].Data() && TEST(SectUser[sop->sector[i]]->flags, SECTFU_SO_DONT_BOB))
continue;
(*sectp)->floorz = sop->zorig_floor[i] + sop->bob_diff;
@ -2237,7 +2237,7 @@ void CallbackSOsink(ANIMp ap, void *data)
for (i = 0; sop->sector[i] != -1; i++)
{
if (SectUser[sop->sector[i]] && TEST(SectUser[sop->sector[i]]->flags, SECTFU_SO_SINK_DEST))
if (SectUser[sop->sector[i]].Data() && TEST(SectUser[sop->sector[i]]->flags, SECTFU_SO_SINK_DEST))
{
src_sector = sop->sector[i];
break;
@ -2558,7 +2558,7 @@ void DoTrack(SECTOR_OBJECTp sop, short locktics, int *nx, int *ny)
for (i = 0; sop->sector[i] != -1; i++)
{
if (SectUser[sop->sector[i]] && TEST(SectUser[sop->sector[i]]->flags, SECTFU_SO_SINK_DEST))
if (SectUser[sop->sector[i]].Data() && TEST(SectUser[sop->sector[i]]->flags, SECTFU_SO_SINK_DEST))
{
dest_sector = sop->sector[i];
break;
@ -2576,7 +2576,7 @@ void DoTrack(SECTOR_OBJECTp sop, short locktics, int *nx, int *ny)
for (i = 0, sectp = &sop->sectp[0]; *sectp; sectp++, i++)
{
if (SectUser[sop->sector[i]] && TEST(SectUser[sop->sector[i]]->flags, SECTFU_SO_DONT_SINK))
if (SectUser[sop->sector[i]].Data() && TEST(SectUser[sop->sector[i]]->flags, SECTFU_SO_DONT_SINK))
continue;
ndx = AnimSet(&(*sectp)->floorz, sector[dest_sector].floorz, tpoint->tag_high);
@ -2596,7 +2596,7 @@ void DoTrack(SECTOR_OBJECTp sop, short locktics, int *nx, int *ny)
for (i = 0, sectp = &sop->sectp[0]; *sectp; sectp++, i++)
{
sectu = SectUser[*sectp - sector];
sectu = SectUser[*sectp - sector].Data();
if (sectu && sectu->stag == SECT_SO_FORM_WHIRLPOOL)
{
@ -2789,7 +2789,7 @@ OperateSectorObjectForTics(SECTOR_OBJECTp sop, short newang, int newx, int newy,
// for all sectors
for (i = 0, sectp = &sop->sectp[0]; *sectp; sectp++, i++)
{
if (SectUser[sop->sector[i]] && TEST(SectUser[sop->sector[i]]->flags, SECTFU_SO_DONT_BOB))
if (SectUser[sop->sector[i]].Data() && TEST(SectUser[sop->sector[i]]->flags, SECTFU_SO_DONT_BOB))
continue;
(*sectp)->floorz = sop->zorig_floor[i] + sop->bob_diff;

View file

@ -179,7 +179,7 @@ short DoVatorOperate(PLAYERp pp, short sectnum)
return DoVatorMatch(pp, match);
}
if (pp && SectUser[sectnum] && SectUser[sectnum]->stag == SECT_LOCK_DOOR && SectUser[sectnum]->number)
if (pp && SectUser[sectnum].Data() && SectUser[sectnum]->stag == SECT_LOCK_DOOR && SectUser[sectnum]->number)
{
short key_num;
@ -248,7 +248,7 @@ DoVatorMatch(PLAYERp pp, short match)
// lock code
sectnum = fsp->sectnum;
if (pp && SectUser[sectnum] && SectUser[sectnum]->stag == SECT_LOCK_DOOR && SectUser[sectnum]->number)
if (pp && SectUser[sectnum].Data() && SectUser[sectnum]->stag == SECT_LOCK_DOOR && SectUser[sectnum]->number)
{
short key_num;
@ -351,7 +351,7 @@ void MoveSpritesWithSector(short sectnum, int z_amt, bool type)
int i;
bool both = false;
if (SectUser[sectnum])
if (SectUser[sectnum].Data())
both = !!TEST(SectUser[sectnum]->flags, SECTFU_VATOR_BOTH);
SectIterator it(sectnum);

View file

@ -4516,7 +4516,7 @@ WeaponMoveHit(short SpriteNum)
return true;
}
if (SectUser[hit_sect] && SectUser[hit_sect]->depth > 0)
if (SectUser[hit_sect].Data() && SectUser[hit_sect]->depth > 0)
{
SpawnSplash(SpriteNum);
//SetSuicide(SpriteNum);
@ -4798,7 +4798,7 @@ DoFireballFlames(short SpriteNum)
}
else
{
if (SectUser[sp->sectnum] && SectUser[sp->sectnum]->depth > 0)
if (SectUser[sp->sectnum].Data() && SectUser[sp->sectnum]->depth > 0)
{
if (labs(sector[sp->sectnum].floorz - sp->z) <= Z(4))
{
@ -4871,7 +4871,7 @@ DoBreakFlames(short SpriteNum)
}
else
{
if (SectUser[sp->sectnum] && SectUser[sp->sectnum]->depth > 0)
if (SectUser[sp->sectnum].Data() && SectUser[sp->sectnum]->depth > 0)
{
if (labs(sector[sp->sectnum].floorz - sp->z) <= Z(4))
{
@ -8077,7 +8077,7 @@ DoStar(int16_t Weapon)
if (sp->z > DIV2(u->hiz + u->loz))
{
if (SectUser[hit_sect] && SectUser[hit_sect]->depth > 0)
if (SectUser[hit_sect].Data() && SectUser[hit_sect]->depth > 0)
{
SpawnSplash(Weapon);
KillSprite(Weapon);
@ -9078,7 +9078,7 @@ DoGrenade(int16_t Weapon)
if (TEST(u->Flags, SPR_UNDERWATER))
SET(u->Flags, SPR_BOUNCE); // no bouncing underwater
if (u->lo_sectp && SectUser[sp->sectnum] && SectUser[sp->sectnum]->depth)
if (u->lo_sectp && SectUser[sp->sectnum].Data() && SectUser[sp->sectnum]->depth)
SET(u->Flags, SPR_BOUNCE); // no bouncing on shallow water
if (!TEST(u->Flags, SPR_BOUNCE))
@ -19738,7 +19738,7 @@ bool
WarpToUnderwater(short *sectnum, int *x, int *y, int *z)
{
int i;
SECT_USERp sectu = SectUser[*sectnum];
SECT_USERp sectu = SectUser[*sectnum].Data();
SPRITEp under_sp = NULL, over_sp = NULL;
bool Found = false;
short over, under;
@ -19755,7 +19755,7 @@ WarpToUnderwater(short *sectnum, int *x, int *y, int *z)
over_sp = &sprite[i];
if (TEST(sector[over_sp->sectnum].extra, SECTFX_DIVE_AREA) &&
SectUser[over_sp->sectnum] &&
SectUser[over_sp->sectnum].Data() &&
SectUser[over_sp->sectnum]->number == sectu->number)
{
Found = true;
@ -19773,7 +19773,7 @@ WarpToUnderwater(short *sectnum, int *x, int *y, int *z)
under_sp = &sprite[i];
if (TEST(sector[under_sp->sectnum].extra, SECTFX_UNDERWATER) &&
SectUser[under_sp->sectnum] &&
SectUser[under_sp->sectnum].Data() &&
SectUser[under_sp->sectnum]->number == sectu->number)
{
Found = true;
@ -19812,7 +19812,7 @@ bool
WarpToSurface(short *sectnum, int *x, int *y, int *z)
{
int i;
SECT_USERp sectu = SectUser[*sectnum];
SECT_USERp sectu = SectUser[*sectnum].Data();
short over, under;
int sx, sy;
@ -19830,7 +19830,7 @@ WarpToSurface(short *sectnum, int *x, int *y, int *z)
under_sp = &sprite[i];
if (TEST(sector[under_sp->sectnum].extra, SECTFX_UNDERWATER) &&
SectUser[under_sp->sectnum] &&
SectUser[under_sp->sectnum].Data() &&
SectUser[under_sp->sectnum]->number == sectu->number)
{
Found = true;
@ -19848,7 +19848,7 @@ WarpToSurface(short *sectnum, int *x, int *y, int *z)
over_sp = &sprite[i];
if (TEST(sector[over_sp->sectnum].extra, SECTFX_DIVE_AREA) &&
SectUser[over_sp->sectnum] &&
SectUser[over_sp->sectnum].Data() &&
SectUser[over_sp->sectnum]->number == sectu->number)
{
Found = true;
@ -19887,7 +19887,7 @@ SpriteWarpToUnderwater(SPRITEp sp)
{
USERp u = User[sp - sprite].Data();
int i;
SECT_USERp sectu = SectUser[sp->sectnum];
SECT_USERp sectu = SectUser[sp->sectnum].Data();
SPRITEp under_sp = NULL, over_sp = NULL;
bool Found = false;
short over, under;
@ -19904,7 +19904,7 @@ SpriteWarpToUnderwater(SPRITEp sp)
over_sp = &sprite[i];
if (TEST(sector[over_sp->sectnum].extra, SECTFX_DIVE_AREA) &&
SectUser[over_sp->sectnum] &&
SectUser[over_sp->sectnum].Data() &&
SectUser[over_sp->sectnum]->number == sectu->number)
{
Found = true;
@ -19922,7 +19922,7 @@ SpriteWarpToUnderwater(SPRITEp sp)
under_sp = &sprite[i];
if (TEST(sector[under_sp->sectnum].extra, SECTFX_UNDERWATER) &&
SectUser[under_sp->sectnum] &&
SectUser[under_sp->sectnum].Data() &&
SectUser[under_sp->sectnum]->number == sectu->number)
{
Found = true;
@ -19965,7 +19965,7 @@ SpriteWarpToSurface(SPRITEp sp)
{
USERp u = User[sp - sprite].Data();
int i;
SECT_USERp sectu = SectUser[sp->sectnum];
SECT_USERp sectu = SectUser[sp->sectnum].Data();
short over, under;
int sx, sy;
@ -19983,7 +19983,7 @@ SpriteWarpToSurface(SPRITEp sp)
under_sp = &sprite[i];
if (TEST(sector[under_sp->sectnum].extra, SECTFX_UNDERWATER) &&
SectUser[under_sp->sectnum] &&
SectUser[under_sp->sectnum].Data() &&
SectUser[under_sp->sectnum]->number == sectu->number)
{
Found = true;
@ -20005,7 +20005,7 @@ SpriteWarpToSurface(SPRITEp sp)
over_sp = &sprite[i];
if (TEST(sector[over_sp->sectnum].extra, SECTFX_DIVE_AREA) &&
SectUser[over_sp->sectnum] &&
SectUser[over_sp->sectnum].Data() &&
SectUser[over_sp->sectnum]->number == sectu->number)
{
Found = true;
@ -20051,7 +20051,7 @@ SpawnSplash(short SpriteNum)
SPRITEp sp = User[SpriteNum]->SpriteP, wp;
short w;
SECT_USERp sectu = SectUser[sp->sectnum];
SECT_USERp sectu = SectUser[sp->sectnum].Data();
SECTORp sectp = &sector[sp->sectnum];
if (Prediction)
@ -20096,7 +20096,7 @@ SpawnSplashXY(int hit_x, int hit_y, int hit_z, short sectnum)
if (Prediction)
return 0;
sectu = SectUser[sectnum];
sectu = SectUser[sectnum].Data();
sectp = &sector[sectnum];
if (sectu && (TEST(sectp->extra, SECTFX_LIQUID_MASK) == SECTFX_LIQUID_NONE))
@ -20126,7 +20126,7 @@ SpawnUnderSplash(short SpriteNum)
SPRITEp sp = User[SpriteNum]->SpriteP, wp;
short w;
SECT_USERp sectu = SectUser[sp->sectnum];
SECT_USERp sectu = SectUser[sp->sectnum].Data();
SECTORp sectp = &sector[sp->sectnum];
return 0;
@ -21257,7 +21257,7 @@ DoShrapVelocity(int16_t SpriteNum)
if (TEST(u->Flags, SPR_UNDERWATER))
SET(u->Flags, SPR_BOUNCE); // no bouncing underwater
if (u->lo_sectp && SectUser[sp->sectnum] && SectUser[sp->sectnum]->depth)
if (u->lo_sectp && SectUser[sp->sectnum].Data() && SectUser[sp->sectnum]->depth)
SET(u->Flags, SPR_BOUNCE); // no bouncing on shallow water
if (!TEST(u->Flags, SPR_BOUNCE))

View file

@ -824,7 +824,7 @@ SpawnZombie2(short Weapon)
SPRITEp np;
USERp nu;
short owner;
SECT_USERp sectu = SectUser[sp->sectnum];
SECT_USERp sectu = SectUser[sp->sectnum].Data();
SECTORp sectp = &sector[sp->sectnum];
owner = sprite[Weapon].owner;