From dcb393bc440cb612fff2ba8652bcb557606e7759 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 2 Apr 2021 10:28:18 +0200 Subject: [PATCH 01/18] - started reorganizing SW's memory management. Need to get rid of all those unmanaged allocations and present game data in an easily serializable form. This adds a managed TPointer class that replicates the useful parts of std::unique_pointer but steers clear of its properties that often render it useless. --- source/common/engine/serializer.h | 26 +++++++ source/common/utility/tarray.h | 122 ++++++++++++++++++++++++++++++ source/games/sw/src/game.h | 30 +++++--- source/games/sw/src/save.cpp | 6 +- source/games/sw/src/sprite.cpp | 8 +- 5 files changed, 175 insertions(+), 17 deletions(-) diff --git a/source/common/engine/serializer.h b/source/common/engine/serializer.h index 22f32f73c..b22d0e11b 100644 --- a/source/common/engine/serializer.h +++ b/source/common/engine/serializer.h @@ -269,6 +269,32 @@ FSerializer &Serialize(FSerializer &arc, const char *key, TArray &value, return arc; } +template +FSerializer& Serialize(FSerializer& arc, const char* key, TPointer& value, TPointer* def) +{ + if (arc.isWriting()) + { + if (value.Data() == nullptr && key) return arc; + } + bool res = arc.BeginArray(key); + if (arc.isReading()) + { + if (!res || arc.ArraySize() == 0) + { + value.Clear(); + return arc; + } + value.Alloc(); + } + if (value.Data()) + { + Serialize(arc, nullptr, *value, def ? def->Data() : nullptr); + } + arc.EndArray(); + return arc; +} + + template FSerializer& Serialize(FSerializer& arc, const char* key, FixedBitArray& value, FixedBitArray* def) { diff --git a/source/common/utility/tarray.h b/source/common/utility/tarray.h index c44e06c43..c8508a022 100644 --- a/source/common/utility/tarray.h +++ b/source/common/utility/tarray.h @@ -1368,6 +1368,128 @@ protected: }; +// Pointer wrapper without the unpleasant side effects of std::unique_ptr, mainly the inability to copy it. +// This class owns the object with no means to release it, and copying the pointer copies the object. +template +class TPointer +{ +public: + + //////// + TPointer() + { + Ptr = nullptr; + } + TPointer(const T& other) + { + Alloc(); + *Ptr = other; + } + TPointer(T&& other) + { + Alloc(); + *Ptr = other; + } + TPointer(const TPointer& other) + { + DoCopy(other); + } + TPointer(TPointer&& other) + { + Ptr = other.Ptr; + other.Ptr = nullptr; + } + TPointer& operator= (const T& other) + { + if (&other != this) + { + Alloc(); + *Ptr = other; + } + return *this; + } + TPointer& operator= (const TPointer& other) + { + if (&other != this) + { + DoCopy(other); + } + return *this; + } + TPointer& operator= (TPointer&& other) + { + if (&other != this) + { + if (Ptr) delete Ptr; + Ptr = other.Ptr; + other.Ptr = nullptr; + } + return *this; + } + ~TPointer() + { + if (Ptr) delete Ptr; + Ptr = nullptr; + } + // Check equality of two pointers + bool operator==(const TPointer& other) const + { + return *Ptr == *other.Ptr; + } + + T& operator* () const + { + assert(Ptr); + return *Ptr; + } + + T* operator->() { return Ptr; } + + // returns raw pointer + T* Data() const + { + return Ptr; + } + + operator T* () const + { + return Ptr; + } + + void Alloc() + { + if (!Ptr) Ptr = new T; + } + + void Clear() + { + if (Ptr) delete Ptr; + Ptr = nullptr; + } + + void Swap(TPointer& other) + { + std::swap(Ptr, other.Ptr); + } + +private: + T* Ptr; + + void DoCopy(const TPointer& other) + { + if (other.Ptr == nullptr) + { + Clear(); + } + else + { + Alloc(); + *Ptr = *other.Ptr; + } + } +}; + + //========================================================================== // diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index c7dda49e2..5452cc9c1 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1115,12 +1115,22 @@ typedef struct // User Extension record // -typedef struct +struct USER { + // These are for easy zero-init of USERs without having to be on the lookout for non-trivial members. + void* operator new(size_t alloc) + { + return M_Calloc(alloc, 1); + } + void operator delete (void* mem) + { + M_Free(mem); + } + // // Variables that can be used by actors and Player // - ROTATORp rotator; + TPointer rotator; // wall vars for lighting int WallCount; @@ -1269,7 +1279,9 @@ typedef struct int16_t oangdiff; // Used for interpolating sprite angles uint8_t filler; -} USER,*USERp; +}; + +using USERp = USER*; struct USERSAVE { @@ -1440,21 +1452,15 @@ typedef struct } RANGE,*RANGEp; -inline void ClearUser(USER* user) -{ - *user = {}; -} - +#pragma message ("Remove NewUser/FreeUser!") inline USER* NewUser() { - auto u = (USER*)M_Calloc(sizeof(USER), 1);// new USER; - ClearUser(u); - return u; + return new USER; } inline void FreeUser(int num) { - if (User[num]) M_Free(User[num]);// delete User[num]; + if (User[num]) delete User[num]; User[num] = nullptr; } diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index 6feeff775..ae452686e 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -747,7 +747,11 @@ bool GameInterface::LoadGame() while (SpriteNum != -1) { User[SpriteNum] = u = NewUser(); + // We need to be careful with allocated content in User when loading a binary save state. + // This needs to be refactored out ASAP. + u->rotator.Clear(); MREAD(u,sizeof(USER),1,fil); + memset((void*)&u->rotator, 0, sizeof(u->rotator)); if (u->WallShade) { @@ -757,7 +761,7 @@ bool GameInterface::LoadGame() if (u->rotator) { - u->rotator = (ROTATORp)CallocMem(sizeof(*u->rotator), 1); + u->rotator.Alloc(); MREAD(u->rotator,sizeof(*u->rotator),1,fil); if (u->rotator->origx) diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 3eb4309e3..5caa2b056 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -790,7 +790,8 @@ KillSprite(int16_t SpriteNum) FreeMem(u->rotator->origx); if (u->rotator->origy) FreeMem(u->rotator->origy); - FreeMem(u->rotator); + + u->rotator.Clear(); } FreeUser(SpriteNum); @@ -909,7 +910,6 @@ SpawnUser(short SpriteNum, short id, STATEp state) u->WaitTics = 0; u->OverlapZ = Z(4); u->WallShade = NULL; - u->rotator = NULL; u->bounce = 0; u->motion_blur_num = 0; @@ -2404,7 +2404,7 @@ SpriteSetup(void) for (w = startwall, wallcount = 0; w <= endwall; w++) wallcount++; - u->rotator = (ROTATORp)CallocMem(sizeof(ROTATOR), 1); + u->rotator.Alloc(); u->rotator->num_walls = wallcount; u->rotator->open_dest = SP_TAG5(sp); u->rotator->speed = SP_TAG7(sp); @@ -2460,7 +2460,7 @@ SpriteSetup(void) u->WaitTics = time*15; // 1/8 of a sec u->Tics = 0; - u->rotator = (ROTATORp)CallocMem(sizeof(ROTATOR), 1); + u->rotator.Alloc(); u->rotator->open_dest = SP_TAG5(sp); u->rotator->speed = SP_TAG7(sp); u->rotator->vel = SP_TAG8(sp); From cd45a1f03509770c133dc5c57f013781f864f068 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 2 Apr 2021 10:44:41 +0200 Subject: [PATCH 02/18] - made more parts of USER serialization friendly. --- source/common/utility/tarray.h | 2 ++ source/games/sw/src/game.h | 30 +++++++++++++++++++------- source/games/sw/src/light.cpp | 4 ++-- source/games/sw/src/rotator.cpp | 8 +++---- source/games/sw/src/save.cpp | 8 +++++-- source/games/sw/src/slidor.cpp | 6 +++--- source/games/sw/src/sprite.cpp | 37 +++++++++------------------------ 7 files changed, 50 insertions(+), 45 deletions(-) diff --git a/source/common/utility/tarray.h b/source/common/utility/tarray.h index c8508a022..d10c3224f 100644 --- a/source/common/utility/tarray.h +++ b/source/common/utility/tarray.h @@ -1451,10 +1451,12 @@ public: return Ptr; } +#if 0 // this is too dangerous. operator T* () const { return Ptr; } +#endif void Alloc() { diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 5452cc9c1..79a9691f5 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1098,7 +1098,7 @@ typedef struct STATEp *Dive; } ACTOR_ACTION_SET,*ACTOR_ACTION_SETp; -typedef struct +struct ROTATOR { int pos; // current position - always moves toward tgt int open_dest; // destination of open position @@ -1106,10 +1106,27 @@ typedef struct int speed; // speed of movement int orig_speed; // original speed - vel jacks with speed int vel; // velocity adjuments - int num_walls; // save off positions of walls for rotator - int *origx; - int *origy; -} ROTATOR, *ROTATORp; + + TArray origX; + TArray origY; + + void SetNumWalls(int num) + { + origX.Resize(num); + origY.Resize(num); + memset(origX.Data(), 0, num * sizeof(int)); + memset(origY.Data(), 0, num * sizeof(int)); + } + + void ClearWalls() + { + origX.Reset(); + origY.Reset(); + } + +}; + +using ROTATORp = ROTATOR*; // // User Extension record @@ -1133,8 +1150,7 @@ struct USER TPointer rotator; // wall vars for lighting - int WallCount; - int8_t* WallShade; // malloced - save off wall shades for lighting + TArray WallShade; WALLp WallP; // operate on wall instead of sprite STATEp State; diff --git a/source/games/sw/src/light.cpp b/source/games/sw/src/light.cpp index 22537de2d..4d19decda 100644 --- a/source/games/sw/src/light.cpp +++ b/source/games/sw/src/light.cpp @@ -78,8 +78,8 @@ void SectorLightShade(SPRITEp sp, short intensity) // change wall if (!TEST_BOOL4(sp)) { - ASSERT(User[sp - sprite] && User[sp - sprite]->WallShade); - wall_shade = User[sp - sprite]->WallShade; + ASSERT(User[sp - sprite] && User[sp - sprite]->WallShade.Data()); + wall_shade = User[sp - sprite]->WallShade.Data(); startwall = sector[sp->sectnum].wallptr; endwall = startwall + sector[sp->sectnum].wallnum - 1; diff --git a/source/games/sw/src/rotator.cpp b/source/games/sw/src/rotator.cpp index f506db318..6478545ad 100644 --- a/source/games/sw/src/rotator.cpp +++ b/source/games/sw/src/rotator.cpp @@ -50,7 +50,7 @@ void ReverseRotator(short SpriteNum) USERp u = User[SpriteNum]; ROTATORp r; - r = u->rotator; + r = u->rotator.Data(); // if paused go ahead and start it up again if (u->Tics) @@ -101,7 +101,7 @@ void SetRotatorActive(short SpriteNum) SPRITEp sp = u->SpriteP; ROTATORp r; - r = u->rotator; + r = u->rotator.Data(); DoRotatorSetInterp(SpriteNum); @@ -320,7 +320,7 @@ int DoRotatorMove(short SpriteNum) int dist,closest; bool kill = false; - r = u->rotator; + r = u->rotator.Data(); // Example - ang pos moves from 0 to 512 <> from 0 to -512 @@ -416,7 +416,7 @@ int DoRotatorMove(short SpriteNum) // move points for (w = startwall, ndx = 0; w <= endwall; w++) { - vec2_t const orig = { r->origx[ndx], r->origy[ndx] }; + vec2_t const orig = { r->origX[ndx], r->origY[ndx] }; rotatepoint(pivot->pos.vec2, orig, r->pos, &nxy); dragpoint(w, nxy.x, nxy.y, 0); diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index ae452686e..e1c060db5 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -371,9 +371,10 @@ bool GameInterface::SaveGame() MWRITE(u,sizeof(USER),1,fil); +#if 0 if (u->WallShade) { - MWRITE(u->WallShade,sizeof(*u->WallShade)*u->WallCount,1,fil); + MWRITE(u->WallShade, sizeof(*u->WallShade) * u->WallCount, 1, fil); } if (u->rotator) @@ -384,6 +385,7 @@ bool GameInterface::SaveGame() if (u->rotator->origy) MWRITE(u->rotator->origy,sizeof(*u->rotator->origy)*u->rotator->num_walls,1,fil); } +#endif saveisshot |= SaveSymDataInfo(fil, u->WallP); assert(!saveisshot); @@ -753,10 +755,11 @@ bool GameInterface::LoadGame() MREAD(u,sizeof(USER),1,fil); memset((void*)&u->rotator, 0, sizeof(u->rotator)); +#if 0 if (u->WallShade) { u->WallShade = (int8_t*)CallocMem(u->WallCount * sizeof(*u->WallShade), 1); - MREAD(u->WallShade,sizeof(*u->WallShade)*u->WallCount,1,fil); + MREAD(u->WallShade, sizeof(*u->WallShade) * u->WallCount, 1, fil); } if (u->rotator) @@ -775,6 +778,7 @@ bool GameInterface::LoadGame() MREAD(u->rotator->origy,sizeof(*u->rotator->origy)*u->rotator->num_walls,1,fil); } } +#endif saveisshot |= LoadSymDataInfo(fil, (void **)&u->WallP); saveisshot |= LoadSymDataInfo(fil, (void **)&u->State); diff --git a/source/games/sw/src/slidor.cpp b/source/games/sw/src/slidor.cpp index b94a24413..4650bda82 100644 --- a/source/games/sw/src/slidor.cpp +++ b/source/games/sw/src/slidor.cpp @@ -44,7 +44,7 @@ void ReverseSlidor(short SpriteNum) USERp u = User[SpriteNum]; ROTATORp r; - r = u->rotator; + r = u->rotator.Data(); // if paused go ahead and start it up again if (u->Tics) @@ -96,7 +96,7 @@ void SetSlidorActive(short SpriteNum) SPRITEp sp = u->SpriteP; ROTATORp r; - r = u->rotator; + r = u->rotator.Data(); DoSlidorInterp(SpriteNum, StartInterpolation); @@ -543,7 +543,7 @@ int DoSlidorMove(short SpriteNum) int old_pos; bool kill = false; - r = u->rotator; + r = u->rotator.Data(); // Example - ang pos moves from 0 to 512 <> from 0 to -512 diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 5caa2b056..ebbae6c36 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -642,12 +642,6 @@ KillSprite(int16_t SpriteNum) PLAYERp pp; short pnum; - if (u->WallShade) - { - FreeMem(u->WallShade); - u->WallShade = NULL; - } - // doing a MissileSetPos - don't allow killing if (TEST(u->Flags, SPR_SET_POS_DONT_KILL)) return; @@ -784,15 +778,7 @@ KillSprite(int16_t SpriteNum) SetSuicide(u->flame); } - if (u->rotator) - { - if (u->rotator->origx) - FreeMem(u->rotator->origx); - if (u->rotator->origy) - FreeMem(u->rotator->origy); - - u->rotator.Clear(); - } + u->rotator.Clear(); FreeUser(SpriteNum); } @@ -909,7 +895,6 @@ SpawnUser(short SpriteNum, short id, STATEp state) u->SpriteNum = SpriteNum; u->WaitTics = 0; u->OverlapZ = Z(4); - u->WallShade = NULL; u->bounce = 0; u->motion_blur_num = 0; @@ -2405,21 +2390,19 @@ SpriteSetup(void) wallcount++; u->rotator.Alloc(); - u->rotator->num_walls = wallcount; u->rotator->open_dest = SP_TAG5(sp); u->rotator->speed = SP_TAG7(sp); u->rotator->vel = SP_TAG8(sp); u->rotator->pos = 0; // closed u->rotator->tgt = u->rotator->open_dest; // closed - u->rotator->origx = (int*)CallocMem(sizeof(u->rotator->origx) * wallcount, 1); - u->rotator->origy = (int*)CallocMem(sizeof(u->rotator->origy) * wallcount, 1); + u->rotator->SetNumWalls(wallcount); u->rotator->orig_speed = u->rotator->speed; for (w = startwall, wallcount = 0; w <= endwall; w++) { - u->rotator->origx[wallcount] = wall[w].x; - u->rotator->origy[wallcount] = wall[w].y; + u->rotator->origX[wallcount] = wall[w].x; + u->rotator->origY[wallcount] = wall[w].y; wallcount++; } @@ -2466,7 +2449,7 @@ SpriteSetup(void) u->rotator->vel = SP_TAG8(sp); u->rotator->pos = 0; // closed u->rotator->tgt = u->rotator->open_dest; // closed - u->rotator->num_walls = 0; + u->rotator->ClearWalls(); u->rotator->orig_speed = u->rotator->speed; SET(u->Flags, SPR_ACTIVE); @@ -2611,13 +2594,13 @@ SpriteSetup(void) } User[SpriteNum] = u = SpawnUser(SpriteNum, 0, NULL); - u->WallCount = wallcount; - wall_shade = u->WallShade = (int8_t*)CallocMem(u->WallCount * sizeof(*u->WallShade), 1); + u->WallShade.Resize(wallcount); + wall_shade = u->WallShade.Data(); // save off original wall shades for (w = startwall, wallcount = 0; w <= endwall; w++) { - wall_shade[wallcount] = wall[w].shade; + wall_shade[wallcount] = wall[w].shade; wallcount++; if (TEST_BOOL5(sp)) { @@ -2667,8 +2650,8 @@ SpriteSetup(void) // !LIGHT // make an wall_shade array and put it in User User[SpriteNum] = u = SpawnUser(SpriteNum, 0, NULL); - u->WallCount = wallcount; - wall_shade = u->WallShade = (int8_t*)CallocMem(u->WallCount * sizeof(*u->WallShade), 1); + u->WallShade.Resize(wallcount); + wall_shade = u->WallShade.Data(); // save off original wall shades for (w = startwall, wallcount = 0; w <= endwall; w++) From bbb53bc717718a7f5b60fbaca6e1aaf764bae8bc Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 2 Apr 2021 11:13:33 +0200 Subject: [PATCH 03/18] - refactored the main User array into something that's automatically managed. --- source/games/sw/src/actor.cpp | 44 +- source/games/sw/src/ai.cpp | 104 ++--- source/games/sw/src/break.cpp | 4 +- source/games/sw/src/bunny.cpp | 42 +- source/games/sw/src/cache.cpp | 2 +- source/games/sw/src/coolg.cpp | 26 +- source/games/sw/src/coolie.cpp | 14 +- source/games/sw/src/copysect.cpp | 2 +- source/games/sw/src/draw.cpp | 27 +- source/games/sw/src/eel.cpp | 18 +- source/games/sw/src/game.cpp | 2 +- source/games/sw/src/game.h | 16 +- source/games/sw/src/girlninj.cpp | 14 +- source/games/sw/src/goro.cpp | 12 +- source/games/sw/src/hornet.cpp | 20 +- source/games/sw/src/input.cpp | 6 +- source/games/sw/src/interpso.cpp | 6 +- source/games/sw/src/inv.cpp | 2 +- source/games/sw/src/jweapon.cpp | 92 ++-- source/games/sw/src/lava.cpp | 8 +- source/games/sw/src/light.cpp | 2 +- source/games/sw/src/miscactr.cpp | 106 ++--- source/games/sw/src/ninja.cpp | 38 +- source/games/sw/src/panel.cpp | 12 +- source/games/sw/src/player.cpp | 108 ++--- source/games/sw/src/ripper.cpp | 34 +- source/games/sw/src/ripper2.cpp | 30 +- source/games/sw/src/rotator.cpp | 14 +- source/games/sw/src/save.cpp | 13 +- source/games/sw/src/sbar.cpp | 8 +- source/games/sw/src/sector.cpp | 30 +- source/games/sw/src/serp.cpp | 8 +- source/games/sw/src/skel.cpp | 10 +- source/games/sw/src/skull.cpp | 28 +- source/games/sw/src/slidor.cpp | 16 +- source/games/sw/src/sounds.cpp | 2 +- source/games/sw/src/spike.cpp | 22 +- source/games/sw/src/sprite.cpp | 172 ++++--- source/games/sw/src/sumo.cpp | 20 +- source/games/sw/src/track.cpp | 34 +- source/games/sw/src/vator.cpp | 22 +- source/games/sw/src/vis.cpp | 4 +- source/games/sw/src/wallmove.cpp | 2 +- source/games/sw/src/weapon.cpp | 758 +++++++++++++++---------------- source/games/sw/src/zilla.cpp | 10 +- source/games/sw/src/zombie.cpp | 16 +- 46 files changed, 977 insertions(+), 1003 deletions(-) diff --git a/source/games/sw/src/actor.cpp b/source/games/sw/src/actor.cpp index 586bcf9ed..d40885300 100644 --- a/source/games/sw/src/actor.cpp +++ b/source/games/sw/src/actor.cpp @@ -60,7 +60,7 @@ int DoScaleSprite(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int scale_value; if (u->scale_speed) @@ -92,7 +92,7 @@ DoScaleSprite(short SpriteNum) int DoActorDie(short SpriteNum, short weapon) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = &sprite[SpriteNum]; @@ -299,7 +299,7 @@ DoDebrisCurrent(SPRITEp sp) { int nx, ny; int ret=0; - USERp u = User[sp - sprite]; + USERp u = User[sp - sprite].Data(); SECT_USERp sectu = SectUser[sp->sectnum]; //sp->clipdist = (256+128)>>2; @@ -329,7 +329,7 @@ int DoActorSectorDamage(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SECT_USERp sectu = SectUser[sp->sectnum]; SECTORp sectp = §or[sp->sectnum]; @@ -396,7 +396,7 @@ DoActorSectorDamage(short SpriteNum) int move_debris(short SpriteNum, int xchange, int ychange, int zchange) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); u->ret = move_sprite(SpriteNum, xchange, ychange, zchange, u->ceiling_dist, u->floor_dist, 0, ACTORMOVETICS); @@ -411,7 +411,7 @@ int DoActorDebris(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SECTORp sectp = §or[sp->sectnum]; int nx, ny; @@ -475,7 +475,7 @@ int DoFireFly(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int nx, ny; nx = 4 * ACTORMOVETICS * bcos(sp->ang) >> 14; @@ -497,7 +497,7 @@ int DoGenerateSewerDebris(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); short n; static STATEp Debris[] = @@ -527,7 +527,7 @@ DoGenerateSewerDebris(short SpriteNum) void KeepActorOnFloor(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; SECTORp sectp; int depth; @@ -619,7 +619,7 @@ KeepActorOnFloor(short SpriteNum) int DoActorBeginSlide(short SpriteNum, short ang, short vel, short dec) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SET(u->Flags, SPR_SLIDING); @@ -638,7 +638,7 @@ DoActorBeginSlide(short SpriteNum, short ang, short vel, short dec) int DoActorSlide(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int nx, ny; nx = MulScale(u->slide_vel, bcos(u->slide_ang), 14); @@ -665,7 +665,7 @@ DoActorSlide(short SpriteNum) int DoActorBeginJump(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SET(u->Flags, SPR_JUMPING); RESET(u->Flags, SPR_FALLING); @@ -695,7 +695,7 @@ DoActorBeginJump(short SpriteNum) int DoActorJump(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; int jump_adj; @@ -741,7 +741,7 @@ DoActorJump(short SpriteNum) int DoActorBeginFall(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SET(u->Flags, SPR_FALLING); RESET(u->Flags, SPR_JUMPING); @@ -773,7 +773,7 @@ DoActorBeginFall(short SpriteNum) int DoActorFall(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; // adjust jump speed by gravity @@ -794,7 +794,7 @@ DoActorFall(short SpriteNum) int DoActorStopFall(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; sp->z = u->loz; @@ -847,7 +847,7 @@ DoActorDeathMove(short SpriteNum) { ANIMATOR DoFindGround; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; int nx, ny; @@ -876,7 +876,7 @@ DoActorDeathMove(short SpriteNum) int DoBeginJump(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SET(u->Flags, SPR_JUMPING); RESET(u->Flags, SPR_FALLING); @@ -892,7 +892,7 @@ DoBeginJump(short SpriteNum) int DoJump(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; int jump_adj; @@ -932,7 +932,7 @@ DoJump(short SpriteNum) int DoBeginFall(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SET(u->Flags, SPR_FALLING); RESET(u->Flags, SPR_JUMPING); @@ -948,7 +948,7 @@ DoBeginFall(short SpriteNum) int DoFall(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; // adjust jump speed by gravity @@ -970,7 +970,7 @@ DoFall(short SpriteNum) int DoFall(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; // adjust jump speed by gravity diff --git a/source/games/sw/src/ai.cpp b/source/games/sw/src/ai.cpp index d295bd9f0..525969698 100644 --- a/source/games/sw/src/ai.cpp +++ b/source/games/sw/src/ai.cpp @@ -79,7 +79,7 @@ Distance(int x1, int y1, int x2, int y2) void DebugMoveHit(short SpriteNum) { SPRITEp sp; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); return; @@ -116,7 +116,7 @@ void DebugMoveHit(short SpriteNum) bool ActorMoveHitReact(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); // Should only return true if there is a reaction to what was hit that // would cause the calling function to abort @@ -129,7 +129,7 @@ bool ActorMoveHitReact(short SpriteNum) USERp hu; ANIMATORp action; - hu = User[HitSprite]; + hu = User[HitSprite].Data(); // if you ran into a player - call close range functions @@ -163,7 +163,7 @@ bool ActorMoveHitReact(short SpriteNum) bool ActorFlaming(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; if (u->flame >= 0) @@ -186,7 +186,7 @@ bool ActorFlaming(short SpriteNum) void DoActorSetSpeed(short SpriteNum, uint8_t speed) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) @@ -252,7 +252,7 @@ ChooseActionNumber(short decision[]) int DoActorNoise(ANIMATORp Action, short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (Action == InitActorAmbientNoise) { @@ -310,7 +310,7 @@ DoActorNoise(ANIMATORp Action, short SpriteNum) bool CanSeePlayer(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; // if actor can still see the player @@ -328,7 +328,7 @@ bool CanSeePlayer(short SpriteNum) int CanHitPlayer(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP, hp; hitdata_t hitinfo; int xvect,yvect,zvect; @@ -391,7 +391,7 @@ int DoActorPickClosePlayer(short SpriteNum) { //extern short Zombies; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; int dist, near_dist = MAX_ACTIVE_RANGE, a,b,c; short pnum; @@ -515,7 +515,7 @@ TARGETACTOR: int GetPlayerSpriteNum(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); short pnum; PLAYERp pp; @@ -546,7 +546,7 @@ CloseRangeDist(SPRITEp sp1, SPRITEp sp2) int DoActorOperate(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); short nearsector, nearwall, nearsprite; int nearhitdist; int z[2]; @@ -634,7 +634,7 @@ DECISION GenericFlaming[] = ANIMATORp DoActorActionDecide(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; int dist; ANIMATORp action; @@ -706,7 +706,7 @@ DoActorActionDecide(short SpriteNum) } - pu = User[GetPlayerSpriteNum(SpriteNum)]; + pu = User[GetPlayerSpriteNum(SpriteNum)].Data(); // check for short range attack possibility if ((dist < CloseRangeDist(sp, u->tgt_sp) && ICanSee) || (pu && pu->WeaponNum == WPN_FIST && u->ID != RIPPER2_RUN_R0 && u->ID != RIPPER_RUN_R0)) @@ -822,7 +822,7 @@ DoActorActionDecide(short SpriteNum) int InitActorDecide(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); // NOTE: It is possible to overflow the stack with too many calls to this // routine @@ -842,7 +842,7 @@ InitActorDecide(short SpriteNum) int DoActorDecide(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; ANIMATORp actor_action; @@ -898,7 +898,7 @@ int sw_snd_scratch = 0; int InitActorAlertNoise(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); sw_snd_scratch = 1; // MONO_PRINT(strcpy(ds,"Init Actor Threat Noise")); @@ -914,7 +914,7 @@ InitActorAlertNoise(short SpriteNum) int InitActorAmbientNoise(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); sw_snd_scratch = 2; // MONO_PRINT(strcpy(ds,"Init Actor Move Noise")); @@ -930,7 +930,7 @@ InitActorAmbientNoise(short SpriteNum) int InitActorAttackNoise(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); sw_snd_scratch = 3; // MONO_PRINT(strcpy(ds,"Init Actor Move Noise")); @@ -946,7 +946,7 @@ InitActorAttackNoise(short SpriteNum) int InitActorPainNoise(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); sw_snd_scratch = 4; // MONO_PRINT(strcpy(ds,"Init Actor Move Noise")); @@ -962,7 +962,7 @@ InitActorPainNoise(short SpriteNum) int InitActorDieNoise(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); sw_snd_scratch = 5; // MONO_PRINT(strcpy(ds,"Init Actor Move Noise")); @@ -978,7 +978,7 @@ InitActorDieNoise(short SpriteNum) int InitActorExtra1Noise(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); sw_snd_scratch = 6; // MONO_PRINT(strcpy(ds,"Init Actor Move Noise")); @@ -993,7 +993,7 @@ InitActorExtra1Noise(short SpriteNum) int InitActorExtra2Noise(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); sw_snd_scratch = 7; // MONO_PRINT(strcpy(ds,"Init Actor Move Noise")); @@ -1008,7 +1008,7 @@ InitActorExtra2Noise(short SpriteNum) int InitActorExtra3Noise(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); sw_snd_scratch = 8; // MONO_PRINT(strcpy(ds,"Init Actor Move Noise")); @@ -1023,7 +1023,7 @@ InitActorExtra3Noise(short SpriteNum) int InitActorExtra4Noise(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); sw_snd_scratch = 9; // MONO_PRINT(strcpy(ds,"Init Actor Move Noise")); @@ -1038,7 +1038,7 @@ InitActorExtra4Noise(short SpriteNum) int InitActorExtra5Noise(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); sw_snd_scratch = 10; // MONO_PRINT(strcpy(ds,"Init Actor Move Noise")); @@ -1053,7 +1053,7 @@ InitActorExtra5Noise(short SpriteNum) int InitActorExtra6Noise(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); sw_snd_scratch = 11; // MONO_PRINT(strcpy(ds,"Init Actor Move Noise")); @@ -1073,7 +1073,7 @@ InitActorExtra6Noise(short SpriteNum) int InitActorMoveCloser(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); //MONO_PRINT("Init Actor Move Closer\n"); @@ -1090,7 +1090,7 @@ InitActorMoveCloser(short SpriteNum) int DoActorCantMoveCloser(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; //MONO_PRINT("Can't move closer\n"); @@ -1123,7 +1123,7 @@ DoActorCantMoveCloser(short SpriteNum) int DoActorMoveCloser(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; int nx, ny; @@ -1367,7 +1367,7 @@ FindWanderTrack(USERp u) int InitActorRunAway(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; //MONO_PRINT("Init Actor RunAway\n"); @@ -1398,7 +1398,7 @@ InitActorRunAway(short SpriteNum) int InitActorRunToward(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); //MONO_PRINT("InitActorRunToward\n"); @@ -1421,7 +1421,7 @@ InitActorRunToward(short SpriteNum) int InitActorAttack(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; // zombie is attacking a player @@ -1442,7 +1442,7 @@ InitActorAttack(short SpriteNum) return 0; } - if (User[u->tgt_sp-sprite] && + if (User[u->tgt_sp-sprite].Data() && User[u->tgt_sp-sprite]->Health <= 0) { DoActorPickClosePlayer(SpriteNum); @@ -1458,7 +1458,7 @@ InitActorAttack(short SpriteNum) // if the guy you are after is dead, look for another and // reposition - if (User[u->tgt_sp-sprite] && + if (User[u->tgt_sp-sprite].Data() && User[u->tgt_sp-sprite]->PlayerP && TEST(User[u->tgt_sp-sprite]->PlayerP->Flags, PF_DEAD)) { @@ -1526,7 +1526,7 @@ InitActorAttack(short SpriteNum) int DoActorAttack(short SpriteNum) { - USERp u = User[SpriteNum],pu; + USERp u = User[SpriteNum].Data(),pu; SPRITEp sp = User[SpriteNum]->SpriteP; short rand_num; int dist,a,b,c; @@ -1535,7 +1535,7 @@ DoActorAttack(short SpriteNum) DISTANCE(sp->x, sp->y, u->tgt_sp->x, u->tgt_sp->y, dist, a, b, c); - pu = User[GetPlayerSpriteNum(SpriteNum)]; + pu = User[GetPlayerSpriteNum(SpriteNum)].Data(); if ((u->ActorActionSet->CloseAttack[0] && dist < CloseRangeDist(sp, u->tgt_sp)) || (pu && pu->WeaponNum == WPN_FIST)) // JBF: added null check { @@ -1563,7 +1563,7 @@ DoActorAttack(short SpriteNum) int InitActorEvade(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; //MONO_PRINT("Init Actor Evade\n"); @@ -1591,7 +1591,7 @@ InitActorEvade(short SpriteNum) int InitActorWanderAround(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; //DSPRINTF(ds, "InitActorWanderAround\n"); @@ -1616,7 +1616,7 @@ InitActorWanderAround(short SpriteNum) int InitActorFindPlayer(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; int DoActorFindPlayer(short SpriteNum); @@ -1649,7 +1649,7 @@ InitActorFindPlayer(short SpriteNum) int InitActorDuck(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; short dist; @@ -1685,7 +1685,7 @@ InitActorDuck(short SpriteNum) int DoActorDuck(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if ((u->WaitTics -= ACTORMOVETICS) < 0) { @@ -1701,7 +1701,7 @@ DoActorDuck(short SpriteNum) int DoActorMoveJump(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; int nx, ny; @@ -1723,7 +1723,7 @@ DoActorMoveJump(short SpriteNum) int move_scan(short SpriteNum, short ang, int dist, int *stopx, int *stopy, int *stopz, short *stopsect) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; int nx,ny; @@ -1789,7 +1789,7 @@ int move_scan(short SpriteNum, short ang, int dist, int *stopx, int *stopy, int int FindNewAngle(short SpriteNum, signed char dir, int DistToMove) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; static short toward_angle_delta[4][9] = @@ -1932,7 +1932,7 @@ int InitActorReposition(short SpriteNum) { int DoActorReposition(short SpriteNum); - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; short ang; int rnum; @@ -2038,7 +2038,7 @@ InitActorReposition(short SpriteNum) int DoActorReposition(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; int nx, ny; @@ -2069,7 +2069,7 @@ DoActorReposition(short SpriteNum) int InitActorPause(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); u->ActorActionFunc = DoActorPause; @@ -2085,7 +2085,7 @@ InitActorPause(short SpriteNum) int DoActorPause(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); // Using Vis instead of WaitTics, var name sucks, but it's the same type // WaitTics is used by too much other actor code and causes problems here @@ -2106,7 +2106,7 @@ int InitActorReposition(short SpriteNum) { int DoActorReposition(short SpriteNum); - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; //MONO_PRINT("InitActorReposition\n"); @@ -2125,7 +2125,7 @@ InitActorReposition(short SpriteNum) int DoActorReposition(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; int nx, ny; @@ -2148,7 +2148,7 @@ DoActorReposition(short SpriteNum) int InitActorPause(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; //MONO_PRINT("InitActorPause\n"); @@ -2165,7 +2165,7 @@ InitActorPause(short SpriteNum) int DoActorPause(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; if ((u->WaitTics -= ACTORMOVETICS) < 0) diff --git a/source/games/sw/src/break.cpp b/source/games/sw/src/break.cpp index 115c82d51..b8403d267 100644 --- a/source/games/sw/src/break.cpp +++ b/source/games/sw/src/break.cpp @@ -845,7 +845,7 @@ bool HitBreakWall(WALLp wp, int hit_x, int hit_y, int hit_z, short ang, short ty int KillBreakSprite(short BreakSprite) { SPRITEp bp = &sprite[BreakSprite]; - USERp bu = User[BreakSprite]; + USERp bu = User[BreakSprite].Data(); // Does not actually kill the sprite so it will be valid for the rest // of the loop traversal. @@ -1047,7 +1047,7 @@ bool NullActor(USERp u) int HitBreakSprite(short BreakSprite, short type) { SPRITEp bp = &sprite[BreakSprite]; - USERp bu = User[BreakSprite]; + USERp bu = User[BreakSprite].Data(); //SPRITEp sp; // ignore as a breakable if true diff --git a/source/games/sw/src/bunny.cpp b/source/games/sw/src/bunny.cpp index 27eedf564..9ddf29879 100644 --- a/source/games/sw/src/bunny.cpp +++ b/source/games/sw/src/bunny.cpp @@ -731,12 +731,12 @@ SetupBunny(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum, BUNNY_RUN_R0, s_BunnyRun[0]); + u = SpawnUser(SpriteNum, BUNNY_RUN_R0, s_BunnyRun[0]); u->Health = 10; } @@ -825,7 +825,7 @@ GetBunnyJumpHeight(short jump_speed, short jump_grav) int PickBunnyJumpSpeed(short SpriteNum, int pix_height) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); ASSERT(pix_height < 128); @@ -853,7 +853,7 @@ int DoBunnyBeginJumpAttack(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp psp = User[SpriteNum]->tgt_sp; short tang; @@ -888,7 +888,7 @@ int DoBunnyMoveJump(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags, SPR_JUMPING | SPR_FALLING)) { @@ -922,7 +922,7 @@ DoBunnyMoveJump(short SpriteNum) int DoPickCloseBunny(short SpriteNum) { - USERp u = User[SpriteNum],tu; + USERp u = User[SpriteNum].Data(), tu; SPRITEp sp = &sprite[SpriteNum],tsp; int dist, near_dist = 1000, a,b,c; int i; @@ -936,7 +936,7 @@ DoPickCloseBunny(short SpriteNum) while ((i = it.NextIndex()) >= 0) { tsp = &sprite[i]; - tu = User[i]; + tu = User[i].Data(); if (sp == tsp) continue; @@ -963,7 +963,7 @@ int DoBunnyQuickJump(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (u->spal != PALETTE_PLAYER8) return false; @@ -975,7 +975,7 @@ DoBunnyQuickJump(short SpriteNum) { short hit_sprite = u->lo_sp - sprite; SPRITEp tsp = u->lo_sp; - USERp tu = User[hit_sprite]; + USERp tu = User[hit_sprite].Data(); if (!tu || tu->ID != BUNNY_RUN_R0) return false; @@ -1017,7 +1017,7 @@ DoBunnyQuickJump(short SpriteNum) { short hit_sprite = u->lo_sp - sprite; SPRITEp tsp = u->lo_sp; - USERp tu = User[hit_sprite]; + USERp tu = User[hit_sprite].Data(); if (!tu || tu->ID != BUNNY_RUN_R0) return false; @@ -1103,7 +1103,7 @@ DoBunnyQuickJump(short SpriteNum) int NullBunny(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags, SPR_JUMPING | SPR_FALLING)) @@ -1129,7 +1129,7 @@ NullBunny(short SpriteNum) int DoBunnyPain(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); NullBunny(SpriteNum); @@ -1141,7 +1141,7 @@ int DoBunnyPain(short SpriteNum) int DoBunnyRipHeart(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp tsp = u->tgt_sp; @@ -1156,7 +1156,7 @@ int DoBunnyRipHeart(short SpriteNum) int DoBunnyStandKill(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); NullBunny(SpriteNum); @@ -1172,7 +1172,7 @@ int DoBunnyStandKill(short SpriteNum) void BunnyHatch(short Weapon) { SPRITEp wp = &sprite[Weapon]; - USERp wu = User[Weapon]; + USERp wu = User[Weapon].Data(); short New,i; SPRITEp np; @@ -1198,7 +1198,7 @@ void BunnyHatch(short Weapon) np->ang = rip_ang[i]; np->pal = 0; SetupBunny(New); - nu = User[New]; + nu = User[New].Data(); np->shade = wp->shade; // make immediately active @@ -1267,7 +1267,7 @@ int BunnyHatch2(short Weapon) np->ang = RANDOM_P2(2048); np->pal = 0; SetupBunny(New); - nu = User[New]; + nu = User[New].Data(); np->shade = wp->shade; // make immediately active @@ -1320,7 +1320,7 @@ int DoBunnyMove(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); // Parental lock crap if (TEST(sp->cstat, CSTAT_SPRITE_INVISIBLE)) @@ -1403,7 +1403,7 @@ int DoBunnyEat(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags, SPR_JUMPING | SPR_FALLING)) @@ -1455,7 +1455,7 @@ int DoBunnyScrew(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags, SPR_JUMPING | SPR_FALLING)) { @@ -1505,7 +1505,7 @@ int DoBunnyGrowUp(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (sp->pal == PALETTE_PLAYER1) return 0; // Don't bother white bunnies diff --git a/source/games/sw/src/cache.cpp b/source/games/sw/src/cache.cpp index 0f290f9f1..6a7601123 100644 --- a/source/games/sw/src/cache.cpp +++ b/source/games/sw/src/cache.cpp @@ -356,7 +356,7 @@ PreCacheActor(void) if (sprite[i].statnum >= MAXSTATUS) continue; - if (User[i]) + if (User[i].Data()) pic = User[i]->ID; else pic = sprite[i].picnum; diff --git a/source/games/sw/src/coolg.cpp b/source/games/sw/src/coolg.cpp index 0bc59215d..53e7254b7 100644 --- a/source/games/sw/src/coolg.cpp +++ b/source/games/sw/src/coolg.cpp @@ -501,7 +501,7 @@ void CoolgCommon(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); sp->clipdist = (200) >> 2; //u->floor_dist = Z(5); @@ -524,12 +524,12 @@ SetupCoolg(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,COOLG_RUN_R0,s_CoolgRun[0]); + u = SpawnUser(SpriteNum,COOLG_RUN_R0,s_CoolgRun[0]); u->Health = HEALTH_COOLIE_GHOST; } @@ -553,7 +553,7 @@ extern short TotalKillable; int NewCoolg(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; USERp nu; SPRITEp np; @@ -562,7 +562,7 @@ NewCoolg(short SpriteNum) New = SpawnSprite(STAT_ENEMY, COOLG_RUN_R0, &s_CoolgBirth[0], sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 50); - nu = User[New]; + nu = User[New].Data(); np = &sprite[New]; ChangeState(New, &s_CoolgBirth[0]); @@ -590,7 +590,7 @@ DoCoolgBirth(short New) USERp u; ANIMATOR DoActorDecide; - u = User[New]; + u = User[New].Data(); u->Health = HEALTH_COOLIE_GHOST; u->Attrib = &CoolgAttrib; @@ -612,7 +612,7 @@ DoCoolgBirth(short New) int NullCoolg(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); u->ShellNum -= ACTORMOVETICS; @@ -630,7 +630,7 @@ int NullCoolg(short SpriteNum) int DoCoolgMatchPlayerZ(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp tsp = User[SpriteNum]->tgt_sp; int zdiff,zdist; int loz,hiz; @@ -712,7 +712,7 @@ int DoCoolgMatchPlayerZ(short SpriteNum) int InitCoolgCircle(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); u->ActorActionFunc = DoCoolgCircle; @@ -745,7 +745,7 @@ int InitCoolgCircle(short SpriteNum) int DoCoolgCircle(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int nx,ny,bound; @@ -788,7 +788,7 @@ int DoCoolgDeath(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int nx, ny; @@ -833,7 +833,7 @@ DoCoolgDeath(short SpriteNum) int DoCoolgMove(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if ((u->ShellNum -= ACTORMOVETICS) <= 0) { @@ -918,7 +918,7 @@ int DoCoolgMove(short SpriteNum) int DoCoolgPain(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); NullCoolg(SpriteNum); diff --git a/source/games/sw/src/coolie.cpp b/source/games/sw/src/coolie.cpp index d433cbc9a..17eaf864b 100644 --- a/source/games/sw/src/coolie.cpp +++ b/source/games/sw/src/coolie.cpp @@ -406,7 +406,7 @@ ACTOR_ACTION_SET CoolieActionSet = void EnemyDefaults(short SpriteNum, ACTOR_ACTION_SETp action, PERSONALITYp person) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = &sprite[SpriteNum]; unsigned int wpn; short wpn_cnt; @@ -531,12 +531,12 @@ SetupCoolie(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,COOLIE_RUN_R0,s_CoolieRun[0]); + u = SpawnUser(SpriteNum,COOLIE_RUN_R0,s_CoolieRun[0]); u->Health = HEALTH_COOLIE; } @@ -576,7 +576,7 @@ int SpawnCoolg(short SpriteNum) int CooliePain(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags,SPR_SLIDING)) DoActorSlide(SpriteNum); @@ -594,7 +594,7 @@ int CooliePain(short SpriteNum) int NullCoolie(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags,SPR_SLIDING)) DoActorSlide(SpriteNum); @@ -610,7 +610,7 @@ int NullCoolie(short SpriteNum) int DoCoolieMove(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags,SPR_SLIDING)) DoActorSlide(SpriteNum); @@ -660,7 +660,7 @@ DoCoolieWaitBirth(short SpriteNum) { USERp u; - u = User[SpriteNum]; + u = User[SpriteNum].Data(); if ((u->Counter -= ACTORMOVETICS) <= 0) { diff --git a/source/games/sw/src/copysect.cpp b/source/games/sw/src/copysect.cpp index 48b36edfb..0da16c661 100644 --- a/source/games/sw/src/copysect.cpp +++ b/source/games/sw/src/copysect.cpp @@ -148,7 +148,7 @@ void CopySectorMatch(short match) // kill anything not invisible if (!TEST(k->cstat, CSTAT_SPRITE_INVISIBLE)) { - if (User[kill]) + if (User[kill].Data()) { // be safe with the killing //SetSuicide(kill); diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index 74e3cc003..50a7054f4 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -104,7 +104,7 @@ GetRotation(short tSpriteNum, int viewx, int viewy) short rotation; tspriteptr_t tsp = &tsprite[tSpriteNum]; - USERp tu = User[tsp->owner]; + USERp tu = User[tsp->owner].Data(); short angle2; if (tu->RotNum == 0) @@ -171,7 +171,7 @@ int SetActorRotation(short tSpriteNum, int viewx, int viewy) { tspriteptr_t tsp = &tsprite[tSpriteNum]; - USERp tu = User[tsp->owner]; + USERp tu = User[tsp->owner].Data(); short StateOffset, Rotation; // don't modify ANY tu vars - back them up! @@ -206,7 +206,7 @@ int DoShadowFindGroundPoint(tspriteptr_t sp) { // USES TSPRITE !!!!! - USERp u = User[sp->owner]; + USERp u = User[sp->owner].Data(); SPRITEp hsp; int ceilhit, florhit; int hiz, loz = u->loz; @@ -264,7 +264,7 @@ void DoShadows(tspriteptr_t tsp, int viewz, bool mirror) { tspriteptr_t New = &tsprite[spritesortcnt]; - USERp tu = User[tsp->owner]; + USERp tu = User[tsp->owner].Data(); int ground_dist = 0; int view_dist = 0; int loz; @@ -364,7 +364,7 @@ DoShadows(tspriteptr_t tsp, int viewz, bool mirror) void DoMotionBlur(tspritetype const * const tsp) { - USERp tu = User[tsp->owner]; + USERp tu = User[tsp->owner].Data(); int nx,ny,nz = 0,dx,dy,dz; short i, ang; short xrepeat, yrepeat, repeat_adj = 0; @@ -571,7 +571,7 @@ analyzesprites(int viewx, int viewy, int viewz, bool mirror) { SpriteNum = tsprite[tSpriteNum].owner; tspriteptr_t tsp = &tsprite[tSpriteNum]; - tu = User[SpriteNum]; + tu = User[SpriteNum].Data(); #if 0 // Brighten up the sprite if set somewhere else to do so @@ -892,7 +892,7 @@ post_analyzesprites(void) SpriteNum = tsprite[tSpriteNum].owner; if (SpriteNum < 0) continue; // JBF: verify this is safe tspriteptr_t tsp = &tsprite[tSpriteNum]; - tu = User[SpriteNum]; + tu = User[SpriteNum].Data(); if (tu) { @@ -1060,7 +1060,7 @@ void PrintSpriteInfo(PLAYERp pp) short hit_sprite = DoPickTarget(pp->SpriteP, 32, 2); sp = &sprite[hit_sprite]; - u = User[hit_sprite]; + u = User[hit_sprite].Data(); sp->hitag = 9997; // Special tag to make the actor glow red for one frame @@ -1126,7 +1126,7 @@ void DrawCrosshair(PLAYERp pp) if (!(CameraTestMode)) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); ::DrawCrosshair(2326, u->Health, -pp->angle.look_anghalf(smoothratio), TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE) ? 5 : 0, 2, shadeToLight(10)); } } @@ -1272,7 +1272,7 @@ PostDraw(void) it.Reset(STAT_FAF_COPY); while ((i = it.NextIndex()) >= 0) { - FreeUser(i); + User[i].Clear(); deletesprite(i); } } @@ -1356,7 +1356,7 @@ void PreDrawStackedWater(void) SectIterator it(sprite[si].sectnum); while ((i = it.NextIndex()) >= 0) { - if (User[i]) + if (User[i].Data()) { if (sprite[i].statnum == STAT_ITEM) continue; @@ -1369,13 +1369,14 @@ void PreDrawStackedWater(void) continue; sp = &sprite[i]; - u = User[i]; + u = User[i].Data(); New = ConnectCopySprite((uspritetype const *)sp); if (New >= 0) { // spawn a user - User[New] = nu = NewUser(); + User[New].Alloc(); + nu = User[New].Data(); ASSERT(nu != NULL); nu->xchange = -989898; diff --git a/source/games/sw/src/eel.cpp b/source/games/sw/src/eel.cpp index 33ddf6ac6..c450c379d 100644 --- a/source/games/sw/src/eel.cpp +++ b/source/games/sw/src/eel.cpp @@ -361,7 +361,7 @@ void EelCommon(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); sp->clipdist = (100) >> 2; u->floor_dist = Z(16); @@ -384,12 +384,12 @@ SetupEel(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,EEL_RUN_R0,s_EelRun[0]); + u = SpawnUser(SpriteNum,EEL_RUN_R0,s_EelRun[0]); u->Health = 40; } @@ -415,7 +415,7 @@ SetupEel(short SpriteNum) int NewEel(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; USERp nu; SPRITEp np; @@ -425,7 +425,7 @@ NewEel(short SpriteNum) New = SpawnSprite(STAT_ENEMY, EEL_RUN_R0, &s_EelBirth, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 50); - nu = User[New]; + nu = User[New].Data(); np = &sprite[New]; ChangeState(New, &s_EelBirth); @@ -445,7 +445,7 @@ NewEel(short SpriteNum) int NullEel(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags,SPR_SLIDING)) DoActorSlide(SpriteNum); @@ -460,7 +460,7 @@ int NullEel(short SpriteNum) int DoEelMatchPlayerZ(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp tsp = User[SpriteNum]->tgt_sp; int zdiff,zdist; int loz,hiz; @@ -561,7 +561,7 @@ int DoEelDeath(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int nx, ny; if (TEST(u->Flags, SPR_FALLING)) { @@ -601,7 +601,7 @@ DoEelDeath(short SpriteNum) int DoEelMove(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); ASSERT(u->Rot != NULL); diff --git a/source/games/sw/src/game.cpp b/source/games/sw/src/game.cpp index eea3e0f38..c52b74690 100644 --- a/source/games/sw/src/game.cpp +++ b/source/games/sw/src/game.cpp @@ -480,7 +480,7 @@ void TerminateLevel(void) StatIterator it(stat); if ((i = it.NextIndex()) >= 0) { - if (User[i]) puser[pnum].CopyFromUser(User[i]); + if (User[i].Data()) puser[pnum].CopyFromUser(User[i].Data()); } } diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 79a9691f5..bf48332ae 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1460,7 +1460,7 @@ struct USERSAVE #define SPR2_DONT_TARGET_OWNER (BIT(24)) -extern USERp User[MAXSPRITES]; +extern TPointer User[MAXSPRITES]; typedef struct { @@ -1468,20 +1468,6 @@ typedef struct } RANGE,*RANGEp; -#pragma message ("Remove NewUser/FreeUser!") -inline USER* NewUser() -{ - return new USER; -} - -inline void FreeUser(int num) -{ - if (User[num]) delete User[num]; - User[num] = nullptr; -} - - - /////////////////////////////////////////////////////////////////////////////////////////// // // Sector Stuff - Sector Objects and Tracks diff --git a/source/games/sw/src/girlninj.cpp b/source/games/sw/src/girlninj.cpp index ab7b4d901..582e96f56 100644 --- a/source/games/sw/src/girlninj.cpp +++ b/source/games/sw/src/girlninj.cpp @@ -722,12 +722,12 @@ SetupGirlNinja(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum, GIRLNINJA_RUN_R0, s_GirlNinjaRun[0]); + u = SpawnUser(SpriteNum, GIRLNINJA_RUN_R0, s_GirlNinjaRun[0]); u->Health = 100; } @@ -753,7 +753,7 @@ SetupGirlNinja(short SpriteNum) int DoGirlNinjaMove(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); // jumping and falling if (TEST(u->Flags, SPR_JUMPING | SPR_FALLING) && !TEST(u->Flags, SPR_CLIMBING)) @@ -791,7 +791,7 @@ DoGirlNinjaMove(short SpriteNum) int GirlNinjaJumpActionFunc(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; int nx, ny; @@ -816,7 +816,7 @@ GirlNinjaJumpActionFunc(short SpriteNum) int NullGirlNinja(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (u->WaitTics > 0) u->WaitTics -= ACTORMOVETICS; @@ -834,7 +834,7 @@ NullGirlNinja(short SpriteNum) int DoGirlNinjaPain(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); NullGirlNinja(SpriteNum); @@ -847,7 +847,7 @@ int DoGirlNinjaPain(short SpriteNum) int DoGirlNinjaSpecial(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (u->spal == PALETTE_PLAYER5) { diff --git a/source/games/sw/src/goro.cpp b/source/games/sw/src/goro.cpp index 7dffea481..106ec7c9f 100644 --- a/source/games/sw/src/goro.cpp +++ b/source/games/sw/src/goro.cpp @@ -490,12 +490,12 @@ SetupGoro(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,GORO_RUN_R0,s_GoroRun[0]); + u = SpawnUser(SpriteNum,GORO_RUN_R0,s_GoroRun[0]); u->Health = HEALTH_GORO; } @@ -515,7 +515,7 @@ SetupGoro(short SpriteNum) int NullGoro(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); ASSERT(SpriteNum >= 0); @@ -530,7 +530,7 @@ int NullGoro(short SpriteNum) int DoGoroPain(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); ASSERT(SpriteNum >= 0); @@ -543,7 +543,7 @@ int DoGoroPain(short SpriteNum) int DoGoroMove(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); ASSERT(SpriteNum >= 0); @@ -555,7 +555,7 @@ int DoGoroMove(short SpriteNum) else (*u->ActorActionFunc)(SpriteNum); - ASSERT(User[SpriteNum]); + ASSERT(User[SpriteNum].Data()); KeepActorOnFloor(SpriteNum); diff --git a/source/games/sw/src/hornet.cpp b/source/games/sw/src/hornet.cpp index ae6e9c9d4..ac4036f26 100644 --- a/source/games/sw/src/hornet.cpp +++ b/source/games/sw/src/hornet.cpp @@ -296,12 +296,12 @@ SetupHornet(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,HORNET_RUN_R0,s_HornetRun[0]); + u = SpawnUser(SpriteNum,HORNET_RUN_R0,s_HornetRun[0]); u->Health = HEALTH_HORNET; } @@ -334,7 +334,7 @@ SetupHornet(short SpriteNum) int NullHornet(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags,SPR_SLIDING)) DoActorSlide(SpriteNum); @@ -349,7 +349,7 @@ int NullHornet(short SpriteNum) int DoHornetMatchPlayerZ(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp tsp = User[SpriteNum]->tgt_sp; int zdiff,zdist; int loz,hiz; @@ -424,7 +424,7 @@ int DoHornetMatchPlayerZ(short SpriteNum) int InitHornetCircle(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); u->ActorActionFunc = DoHornetCircle; @@ -456,7 +456,7 @@ int InitHornetCircle(short SpriteNum) int DoHornetCircle(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int nx,ny,bound; sp->ang = NORM_ANGLE(sp->ang + u->Counter2); @@ -509,7 +509,7 @@ int DoHornetDeath(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int nx, ny; if (TEST(u->Flags, SPR_FALLING)) @@ -554,7 +554,7 @@ int DoCheckSwarm(short SpriteNum) { int i; SPRITEp sp = &sprite[SpriteNum], tsp; - USERp u = User[SpriteNum], tu; + USERp u = User[SpriteNum].Data(), tu; int dist, pdist, a,b,c; PLAYERp pp; @@ -578,7 +578,7 @@ int DoCheckSwarm(short SpriteNum) while ((i = it.NextIndex()) >= 0) { tsp = &sprite[i]; - tu = User[i]; + tu = User[i].Data(); if (!tu) continue; @@ -599,7 +599,7 @@ int DoCheckSwarm(short SpriteNum) int DoHornetMove(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); // Check for swarming // lotag of 1 = Swarm around lotags of 2 diff --git a/source/games/sw/src/input.cpp b/source/games/sw/src/input.cpp index 21dce2c70..a3c3a72b7 100644 --- a/source/games/sw/src/input.cpp +++ b/source/games/sw/src/input.cpp @@ -80,7 +80,7 @@ enum static void processWeapon(PLAYERp const pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); int i; if (loc.getNewWeapon() == WeaponSel_Next) @@ -120,7 +120,7 @@ static void processWeapon(PLAYERp const pp) } else if (loc.getNewWeapon() == WeaponSel_Prev) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); short prev_weapon = u->WeaponNum - 1; short start_weapon; @@ -153,7 +153,7 @@ static void processWeapon(PLAYERp const pp) } else if (loc.getNewWeapon() == WeaponSel_Alt) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); short const which_weapon = u->WeaponNum + 1; loc.setNewWeapon(which_weapon); } diff --git a/source/games/sw/src/interpso.cpp b/source/games/sw/src/interpso.cpp index bcb2c9612..744d2ba6a 100644 --- a/source/games/sw/src/interpso.cpp +++ b/source/games/sw/src/interpso.cpp @@ -269,7 +269,7 @@ void so_updateinterpolations(void) // Stick at beginning of domovethings { if (data->spriteofang >= 0) { - USERp u = User[data->spriteofang]; + USERp u = User[data->spriteofang].Data(); if (u) u->oangdiff = 0; if (!interpolating) @@ -316,7 +316,7 @@ void so_dointerpolations(int32_t smoothratio) // Stick at b data->lastoldipos = data->oldipos; if (data->spriteofang >= 0) { - USERp u = User[data->spriteofang]; + USERp u = User[data->spriteofang].Data(); data->lastangdiff = u ? u->oangdiff : 0; } } @@ -358,7 +358,7 @@ void so_dointerpolations(int32_t smoothratio) // Stick at b if (data->curelement >= soi_sprx) { int32_t sprnum = data->curelement & soi_base; - USERp u = User[sprnum]; + USERp u = User[sprnum].Data(); if (u && (sprite[sprnum].statnum != STAT_DEFAULT) && ((TEST(u->Flags, SPR_SKIP4) && (sprite[sprnum].statnum <= STAT_SKIP4_INTERP_END)) || (TEST(u->Flags, SPR_SKIP2) && (sprite[sprnum].statnum <= STAT_SKIP2_INTERP_END)))) diff --git a/source/games/sw/src/inv.cpp b/source/games/sw/src/inv.cpp index f2ac14bad..79d6de4b5 100644 --- a/source/games/sw/src/inv.cpp +++ b/source/games/sw/src/inv.cpp @@ -139,7 +139,7 @@ void AutoPickInventory(PLAYERp pp) void UseInventoryMedkit(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); short diff; short inv = INVENTORY_MEDKIT; short amt; diff --git a/source/games/sw/src/jweapon.cpp b/source/games/sw/src/jweapon.cpp index 8dba529c2..32575053b 100644 --- a/source/games/sw/src/jweapon.cpp +++ b/source/games/sw/src/jweapon.cpp @@ -260,7 +260,7 @@ int DoWallBloodDrip(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); //sp->z += (300+RANDOM_RANGE(2300)) >> 1; @@ -300,7 +300,7 @@ void SpawnMidSplash(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp np; USERp nu; short New; @@ -309,7 +309,7 @@ SpawnMidSplash(short SpriteNum) sp->x, sp->y, SPRITEp_MID(sp), sp->ang, 0); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); //SetOwner(Weapon, New); np->shade = -12; @@ -334,7 +334,7 @@ void SpawnFloorSplash(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp np; USERp nu; short New; @@ -343,7 +343,7 @@ SpawnFloorSplash(short SpriteNum) sp->x, sp->y, sp->z, sp->ang, 0); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); //SetOwner(Weapon, New); np->shade = -12; @@ -369,7 +369,7 @@ int DoBloodSpray(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); int cz,fz; if (TEST(u->Flags, SPR_UNDERWATER)) @@ -563,7 +563,7 @@ DoBloodSpray(int16_t Weapon) sp->x, sp->y, sp->z, sp->ang, 100); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); SetOwner(Weapon, New); np->shade = -12; @@ -596,7 +596,7 @@ int DoPhosphorus(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); if (TEST(u->Flags, SPR_UNDERWATER)) { @@ -636,7 +636,7 @@ DoPhosphorus(int16_t Weapon) hit_sprite = NORM_SPRITE(u->ret); hsp = &sprite[hit_sprite]; - hu = User[hit_sprite]; + hu = User[hit_sprite].Data(); if (TEST(hsp->cstat, CSTAT_SPRITE_ALIGNMENT_WALL)) { @@ -785,7 +785,7 @@ DoPhosphorus(int16_t Weapon) sp->x, sp->y, sp->z, sp->ang, 100); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); np->hitag = LUMINOUS; // Always full brightness SetOwner(Weapon, New); @@ -820,7 +820,7 @@ int DoChemBomb(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); if (TEST(u->Flags, SPR_UNDERWATER)) { @@ -1035,7 +1035,7 @@ DoChemBomb(int16_t Weapon) sp->x, sp->y, sp->z, sp->ang, 100); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); SetOwner(Weapon, New); np->shade = -40; @@ -1065,7 +1065,7 @@ DoChemBomb(int16_t Weapon) int DoCaltropsStick(int16_t Weapon) { - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); u->Counter = !u->Counter; @@ -1079,7 +1079,7 @@ int DoCaltrops(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); if (TEST(u->Flags, SPR_UNDERWATER)) { @@ -1257,7 +1257,7 @@ int SpawnRadiationCloud(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum], np; - USERp u = User[SpriteNum], nu; + USERp u = User[SpriteNum].Data(), nu; short New; @@ -1288,7 +1288,7 @@ SpawnRadiationCloud(short SpriteNum) sp->x, sp->y, sp->z - RANDOM_P2(Z(8)), sp->ang, 0); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); SetOwner(sp->owner, New); nu->WaitTics = 1 * 120; @@ -1335,7 +1335,7 @@ int DoRadiationCloud(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); sp->z -= sp->zvel; @@ -1358,7 +1358,7 @@ DoRadiationCloud(short SpriteNum) int PlayerInitChemBomb(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); USERp wu; SPRITEp wp; int nx, ny, nz; @@ -1381,7 +1381,7 @@ PlayerInitChemBomb(PLAYERp pp) nx, ny, nz, pp->angle.ang.asbuild(), CHEMBOMB_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); // don't throw it as far if crawling if (TEST(pp->Flags, PF_CRAWLING)) @@ -1444,7 +1444,7 @@ PlayerInitChemBomb(PLAYERp pp) int InitSpriteChemBomb(int16_t SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); USERp wu; SPRITEp sp = &sprite[SpriteNum], wp; int nx, ny, nz; @@ -1463,7 +1463,7 @@ InitSpriteChemBomb(int16_t SpriteNum) nx, ny, nz, sp->ang, CHEMBOMB_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); SET(wu->Flags, SPR_XFLIP_TOGGLE); @@ -1498,7 +1498,7 @@ int InitChemBomb(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); USERp wu; SPRITEp wp; int nx, ny, nz; @@ -1518,7 +1518,7 @@ InitChemBomb(short SpriteNum) nx, ny, nz, sp->ang, CHEMBOMB_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); // wu->RotNum = 5; // NewStateGroup(w, &sg_ChemBomb); @@ -1592,7 +1592,7 @@ PlayerInitFlashBomb(PLAYERp pp) while ((i = it.NextIndex()) >= 0) { hp = &sprite[i]; - hu = User[i]; + hu = User[i].Data(); if (i == pp->PlayerSprite) break; @@ -1660,7 +1660,7 @@ InitFlashBomb(int16_t SpriteNum) while ((i = it.NextIndex()) >= 0) { hp = &sprite[i]; - hu = User[i]; + hu = User[i].Data(); DISTANCE(hp->x, hp->y, sp->x, sp->y, dist, tx, ty, tmin); if (dist > 16384) // Flash radius @@ -1710,7 +1710,7 @@ int SpawnFlashBombOnActor(int16_t enemy) { SPRITEp ep = &sprite[enemy]; - USERp eu = User[enemy]; + USERp eu = User[enemy].Data(); SPRITEp np; USERp nu; short New; @@ -1733,7 +1733,7 @@ SpawnFlashBombOnActor(int16_t enemy) int sizez = SPRITEp_SIZE_Z(ep) + DIV4(SPRITEp_SIZE_Z(ep)); np = &sprite[eu->flame]; - nu = User[eu->flame]; + nu = User[eu->flame].Data(); if (nu->Counter >= SPRITEp_SIZE_Z_2_YREPEAT(np, sizez)) @@ -1764,7 +1764,7 @@ SpawnFlashBombOnActor(int16_t enemy) New = SpawnSprite(STAT_MISSILE, FIREBALL_FLAMES, s_FireballFlames, ep->sectnum, ep->x, ep->y, ep->z, ep->ang, 0); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); if (enemy >= 0) eu->flame = New; @@ -1801,7 +1801,7 @@ SpawnFlashBombOnActor(int16_t enemy) int PlayerInitCaltrops(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); USERp wu; SPRITEp wp; int nx, ny, nz; @@ -1827,7 +1827,7 @@ PlayerInitCaltrops(PLAYERp pp) nx, ny, nz, pp->angle.ang.asbuild(), (CHEMBOMB_VELOCITY + RANDOM_RANGE(CHEMBOMB_VELOCITY)) / 2); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); // don't throw it as far if crawling if (TEST(pp->Flags, PF_CRAWLING)) @@ -1885,7 +1885,7 @@ int InitCaltrops(int16_t SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); USERp wu; SPRITEp wp; int nx, ny, nz; @@ -1904,7 +1904,7 @@ InitCaltrops(int16_t SpriteNum) nx, ny, nz, sp->ang, CHEMBOMB_VELOCITY / 2); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); SET(wu->Flags, SPR_XFLIP_TOGGLE); @@ -1936,7 +1936,7 @@ int InitPhosphorus(int16_t SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); USERp wu; SPRITEp wp; int nx, ny, nz; @@ -1958,7 +1958,7 @@ InitPhosphorus(int16_t SpriteNum) nx, ny, nz, daang, CHEMBOMB_VELOCITY/3); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); wp->hitag = LUMINOUS; // Always full brightness SET(wu->Flags, SPR_XFLIP_TOGGLE); @@ -1995,7 +1995,7 @@ int InitBloodSpray(int16_t SpriteNum, bool dogib, short velocity) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); USERp wu; SPRITEp wp; int nx, ny, nz; @@ -2047,7 +2047,7 @@ InitBloodSpray(int16_t SpriteNum, bool dogib, short velocity) nx, ny, nz, ang, vel*2); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); SET(wu->Flags, SPR_XFLIP_TOGGLE); if (dogib) @@ -2174,11 +2174,11 @@ int DoCarryFlag(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); #define FLAG_DETONATE_STATE 99 SPRITEp fp = &sprite[u->FlagOwner]; - USERp fu = User[u->FlagOwner]; + USERp fu = User[u->FlagOwner].Data(); // if no owner then die @@ -2214,7 +2214,7 @@ DoCarryFlag(int16_t Weapon) if (u->Counter2 < FLAG_DETONATE_STATE) { SPRITEp ap = &sprite[u->Attach]; - USERp au = User[u->Attach]; + USERp au = User[u->Attach].Data(); if (!au || au->Health <= 0) { @@ -2329,11 +2329,11 @@ int DoCarryFlagNoDet(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); SPRITEp ap = &sprite[u->Attach]; - USERp au = User[u->Attach]; + USERp au = User[u->Attach].Data(); SPRITEp fp = &sprite[u->FlagOwner]; - USERp fu = User[u->FlagOwner]; + USERp fu = User[u->FlagOwner].Data(); if (u->FlagOwner >= 0) @@ -2397,7 +2397,7 @@ int SetCarryFlag(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); // stuck SET(u->Flags, SPR_BOUNCE); @@ -2419,7 +2419,7 @@ int DoFlag(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); int16_t hit_sprite = -1; hit_sprite = DoFlagRangeTest(Weapon, 1000); @@ -2448,7 +2448,7 @@ DoFlag(int16_t Weapon) int InitShell(int16_t SpriteNum, int16_t ShellNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); USERp wu; SPRITEp sp = &sprite[SpriteNum], wp; int nx, ny, nz; @@ -2484,7 +2484,7 @@ InitShell(int16_t SpriteNum, int16_t ShellNum) nx, ny, nz, sp->ang, 64); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); wp->zvel = -(velocity); diff --git a/source/games/sw/src/lava.cpp b/source/games/sw/src/lava.cpp index ac1003f0d..93980b4a0 100644 --- a/source/games/sw/src/lava.cpp +++ b/source/games/sw/src/lava.cpp @@ -460,12 +460,12 @@ SetupLava(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,LAVA_RUN_R0,s_LavaRun[0]); + u = SpawnUser(SpriteNum,LAVA_RUN_R0,s_LavaRun[0]); u->Health = 100; } @@ -487,7 +487,7 @@ SetupLava(short SpriteNum) int NullLava(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags,SPR_SLIDING)) DoActorSlide(SpriteNum); @@ -500,7 +500,7 @@ int NullLava(short SpriteNum) int DoLavaMove(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags,SPR_SLIDING)) DoActorSlide(SpriteNum); diff --git a/source/games/sw/src/light.cpp b/source/games/sw/src/light.cpp index 4d19decda..64ca1bfcd 100644 --- a/source/games/sw/src/light.cpp +++ b/source/games/sw/src/light.cpp @@ -78,7 +78,7 @@ void SectorLightShade(SPRITEp sp, short intensity) // change wall if (!TEST_BOOL4(sp)) { - ASSERT(User[sp - sprite] && User[sp - sprite]->WallShade.Data()); + ASSERT(User[sp - sprite].Data() && User[sp - sprite]->WallShade.Data()); wall_shade = User[sp - sprite]->WallShade.Data(); startwall = sector[sp->sectnum].wallptr; diff --git a/source/games/sw/src/miscactr.cpp b/source/games/sw/src/miscactr.cpp index 9bff44fcc..dc2d6174c 100644 --- a/source/games/sw/src/miscactr.cpp +++ b/source/games/sw/src/miscactr.cpp @@ -119,12 +119,12 @@ SetupToiletGirl(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,TOILETGIRL_R0,s_ToiletGirlStand); + u = SpawnUser(SpriteNum,TOILETGIRL_R0,s_ToiletGirlStand); u->Health = 60; } @@ -151,7 +151,7 @@ SetupToiletGirl(short SpriteNum) int DoToiletGirl(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; bool ICanSee = false; @@ -209,7 +209,7 @@ int DoToiletGirl(short SpriteNum) int NullToiletGirl(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; bool ICanSee = false; @@ -241,7 +241,7 @@ int NullToiletGirl(short SpriteNum) int ToiletGirlUzi(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (!TEST(u->Flags,SPR_CLIMBING)) KeepActorOnFloor(SpriteNum); @@ -258,7 +258,7 @@ int ToiletGirlUzi(short SpriteNum) int ToiletGirlPain(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); NullToiletGirl(SpriteNum); @@ -359,12 +359,12 @@ SetupWashGirl(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,WASHGIRL_R0,s_WashGirlStand); + u = SpawnUser(SpriteNum,WASHGIRL_R0,s_WashGirlStand); u->Health = 60; } @@ -390,7 +390,7 @@ SetupWashGirl(short SpriteNum) int DoWashGirl(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; bool ICanSee = false; @@ -454,7 +454,7 @@ int DoWashGirl(short SpriteNum) int NullWashGirl(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; bool ICanSee = false; @@ -486,7 +486,7 @@ int NullWashGirl(short SpriteNum) int WashGirlUzi(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (!TEST(u->Flags,SPR_CLIMBING)) KeepActorOnFloor(SpriteNum); @@ -503,7 +503,7 @@ int WashGirlUzi(short SpriteNum) int WashGirlPain(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); NullWashGirl(SpriteNum); @@ -568,12 +568,12 @@ SetupTrashCan(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,TRASHCAN,s_TrashCanStand); + u = SpawnUser(SpriteNum,TRASHCAN,s_TrashCanStand); u->Health = 60; } @@ -599,7 +599,7 @@ SetupTrashCan(short SpriteNum) int DoTrashCan(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; //(*u->ActorActionFunc) (SpriteNum); @@ -620,7 +620,7 @@ int DoTrashCan(short SpriteNum) int TrashCanPain(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags,SPR_SLIDING)) DoActorSlide(SpriteNum); @@ -676,12 +676,12 @@ SetupPachinkoLight(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,PACHINKOLIGHT_R0,s_PachinkoLightStand); + u = SpawnUser(SpriteNum,PACHINKOLIGHT_R0,s_PachinkoLightStand); u->Health = 1; } @@ -708,7 +708,7 @@ SetupPachinkoLight(short SpriteNum) int PachinkoLightOperate(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if ((u->WaitTics -= ACTORMOVETICS) <= 0) { @@ -777,12 +777,12 @@ SetupPachinko1(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,PACHINKO1,s_Pachinko1Stand); + u = SpawnUser(SpriteNum,PACHINKO1,s_Pachinko1Stand); u->Health = 1; } @@ -807,7 +807,7 @@ SetupPachinko1(short SpriteNum) int PachinkoCheckWin(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); u->WaitTics = 0; // Can operate it again now @@ -840,7 +840,7 @@ int PachinkoCheckWin(short SpriteNum) while ((i = it.NextIndex()) >= 0) { tsp = &sprite[i]; - tu = User[i]; + tu = User[i].Data(); if (tsp->lotag == TAG_PACHINKOLIGHT) { @@ -947,12 +947,12 @@ SetupPachinko2(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,PACHINKO2,s_Pachinko2Stand); + u = SpawnUser(SpriteNum,PACHINKO2,s_Pachinko2Stand); u->Health = 1; } @@ -1031,12 +1031,12 @@ SetupPachinko3(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,PACHINKO3,s_Pachinko3Stand); + u = SpawnUser(SpriteNum,PACHINKO3,s_Pachinko3Stand); u->Health = 1; } @@ -1116,12 +1116,12 @@ SetupPachinko4(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,PACHINKO4,s_Pachinko4Stand); + u = SpawnUser(SpriteNum,PACHINKO4,s_Pachinko4Stand); u->Health = 1; } @@ -1229,12 +1229,12 @@ SetupCarGirl(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,CARGIRL_R0,s_CarGirlStand); + u = SpawnUser(SpriteNum,CARGIRL_R0,s_CarGirlStand); u->Health = 60; } @@ -1262,7 +1262,7 @@ SetupCarGirl(short SpriteNum) int DoCarGirl(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; bool ICanSee = false; @@ -1311,7 +1311,7 @@ int DoCarGirl(short SpriteNum) int NullCarGirl(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; bool ICanSee = false; @@ -1350,7 +1350,7 @@ int NullCarGirl(short SpriteNum) int CarGirlUzi(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (!TEST(u->Flags,SPR_CLIMBING)) KeepActorOnFloor(SpriteNum); @@ -1367,7 +1367,7 @@ int CarGirlUzi(short SpriteNum) int CarGirlPain(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); NullCarGirl(SpriteNum); @@ -1449,12 +1449,12 @@ SetupMechanicGirl(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,MECHANICGIRL_R0,s_MechanicGirlStand); + u = SpawnUser(SpriteNum,MECHANICGIRL_R0,s_MechanicGirlStand); u->Health = 60; } @@ -1481,7 +1481,7 @@ SetupMechanicGirl(short SpriteNum) int DoMechanicGirl(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; bool ICanSee = false; @@ -1530,7 +1530,7 @@ int DoMechanicGirl(short SpriteNum) int NullMechanicGirl(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; bool ICanSee = false; @@ -1569,7 +1569,7 @@ int NullMechanicGirl(short SpriteNum) int MechanicGirlDrill(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (!TEST(u->Flags,SPR_CLIMBING)) KeepActorOnFloor(SpriteNum); @@ -1586,7 +1586,7 @@ int MechanicGirlDrill(short SpriteNum) int MechanicGirlPain(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); NullMechanicGirl(SpriteNum); @@ -1668,12 +1668,12 @@ SetupSailorGirl(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,SAILORGIRL_R0,s_SailorGirlStand); + u = SpawnUser(SpriteNum,SAILORGIRL_R0,s_SailorGirlStand); u->Health = 60; } @@ -1701,7 +1701,7 @@ SetupSailorGirl(short SpriteNum) int DoSailorGirl(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; bool ICanSee = false; @@ -1754,7 +1754,7 @@ int DoSailorGirl(short SpriteNum) int NullSailorGirl(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; bool ICanSee = false; static short alreadythrew = 0; @@ -1798,7 +1798,7 @@ int NullSailorGirl(short SpriteNum) int SailorGirlThrow(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (!TEST(u->Flags,SPR_CLIMBING)) KeepActorOnFloor(SpriteNum); @@ -1815,7 +1815,7 @@ int SailorGirlThrow(short SpriteNum) int SailorGirlPain(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); NullSailorGirl(SpriteNum); @@ -1881,12 +1881,12 @@ SetupPruneGirl(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,PRUNEGIRL_R0,s_PruneGirlStand); + u = SpawnUser(SpriteNum,PRUNEGIRL_R0,s_PruneGirlStand); u->Health = 60; } @@ -1913,7 +1913,7 @@ SetupPruneGirl(short SpriteNum) int DoPruneGirl(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; bool ICanSee = false; @@ -1978,7 +1978,7 @@ int DoPruneGirl(short SpriteNum) int NullPruneGirl(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; bool ICanSee = false; @@ -2016,7 +2016,7 @@ int NullPruneGirl(short SpriteNum) int PruneGirlUzi(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (!TEST(u->Flags,SPR_CLIMBING)) KeepActorOnFloor(SpriteNum); @@ -2033,7 +2033,7 @@ int PruneGirlUzi(short SpriteNum) int PruneGirlPain(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); NullPruneGirl(SpriteNum); diff --git a/source/games/sw/src/ninja.cpp b/source/games/sw/src/ninja.cpp index ab4a395eb..217f0c0ac 100644 --- a/source/games/sw/src/ninja.cpp +++ b/source/games/sw/src/ninja.cpp @@ -1814,7 +1814,7 @@ int DoHariKariBlood(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); return 0; } @@ -1834,12 +1834,12 @@ SetupNinja(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum, NINJA_RUN_R0, s_NinjaRun[0]); + u = SpawnUser(SpriteNum, NINJA_RUN_R0, s_NinjaRun[0]); u->Health = HEALTH_NINJA; } @@ -1945,7 +1945,7 @@ SetupNinja(short SpriteNum) int DoNinjaHariKari(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; short cnt,i; @@ -1975,7 +1975,7 @@ DoNinjaHariKari(short SpriteNum) int DoNinjaGrabThroat(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; if ((u->WaitTics -= ACTORMOVETICS) <= 0) @@ -2015,7 +2015,7 @@ DoNinjaGrabThroat(short SpriteNum) int DoNinjaMove(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags2, SPR2_DYING)) { @@ -2062,7 +2062,7 @@ DoNinjaMove(short SpriteNum) int NinjaJumpActionFunc(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; int nx, ny; @@ -2094,7 +2094,7 @@ NinjaJumpActionFunc(short SpriteNum) int NullNinja(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (u->WaitTics > 0) u->WaitTics -= ACTORMOVETICS; @@ -2112,7 +2112,7 @@ NullNinja(short SpriteNum) int DoNinjaPain(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); NullNinja(SpriteNum); @@ -2134,7 +2134,7 @@ int DoNinjaPain(short SpriteNum) int DoNinjaSpecial(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (u->spal == PALETTE_PLAYER5) { @@ -2156,7 +2156,7 @@ int CheckFire(short SpriteNum) int DoNinjaCeiling(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; DoActorSectorDamage(SpriteNum); @@ -2186,7 +2186,7 @@ void PlayerLevelReset(PLAYERp pp) { SPRITEp sp = &sprite[pp->PlayerSprite]; - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); if (gNet.MultiGameType == MULTI_GAME_COMMBAT) { @@ -2227,7 +2227,7 @@ void PlayerDeathReset(PLAYERp pp) { SPRITEp sp = &sprite[pp->PlayerSprite]; - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); if (TEST(pp->Flags, PF_DIVING)) DoPlayerStopDiveNoWarp(pp); @@ -2304,7 +2304,7 @@ PlayerPanelSetup(void) { pp = Player + pnum; - u = User[pp->PlayerSprite]; + u = User[pp->PlayerSprite].Data(); ASSERT(u != NULL); @@ -2319,7 +2319,7 @@ void PlayerGameReset(PLAYERp pp) { SPRITEp sp = &sprite[pp->PlayerSprite]; - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); COVER_SetReverb(0); // Turn off any echoing that may have been going before pp->Reverb = 0; @@ -2379,7 +2379,7 @@ extern ACTOR_ACTION_SET PlayerNinjaActionSet; void PlayerSpriteLoadLevel(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); ChangeState(SpriteNum, s_NinjaRun[0]); u->Rot = sg_NinjaRun; @@ -2407,7 +2407,7 @@ InitPlayerSprite(PLAYERp pp) SET(sp->extra, SPRX_PLAYER_OR_ENEMY); RESET(sp->cstat, CSTAT_SPRITE_TRANSLUCENT); - u = User[sp_num]; + u = User[sp_num].Data(); // Grouping items that need to be reset after a LoadLevel ChangeState(sp_num, s_NinjaRun[0]); @@ -2465,7 +2465,7 @@ InitPlayerSprite(PLAYERp pp) void SpawnPlayerUnderSprite(PLAYERp pp) { - USERp pu = User[pp->PlayerSprite], u; + USERp pu = User[pp->PlayerSprite].Data(), u; SPRITEp psp = &sprite[pp->PlayerSprite]; SPRITEp sp; int pnum = pp - Player, sp_num; @@ -2474,7 +2474,7 @@ SpawnPlayerUnderSprite(PLAYERp pp) NINJA_RUN_R0, NULL, pp->cursectnum, pp->posx, pp->posy, pp->posz, pp->angle.ang.asbuild(), 0); sp = &sprite[sp_num]; - u = User[sp_num]; + u = User[sp_num].Data(); pp->UnderSpriteP = sp; diff --git a/source/games/sw/src/panel.cpp b/source/games/sw/src/panel.cpp index 5494576b0..54c825e8b 100644 --- a/source/games/sw/src/panel.cpp +++ b/source/games/sw/src/panel.cpp @@ -221,7 +221,7 @@ void ArmorCalc(int damage_amt, int *armor_damage, int *player_damage) void PlayerUpdateHealth(PLAYERp pp, short value) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); short x,y; if (Prediction) @@ -328,7 +328,7 @@ void PlayerUpdateHealth(PLAYERp pp, short value) void PlayerUpdateAmmo(PLAYERp pp, short UpdateWeaponNum, short value) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); short x,y; short WeaponNum; @@ -367,7 +367,7 @@ void PlayerUpdateAmmo(PLAYERp pp, short UpdateWeaponNum, short value) void PlayerUpdateWeapon(PLAYERp pp, short WeaponNum) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); // Weapon Change if (Prediction) @@ -434,7 +434,7 @@ int WeaponOperate(PLAYERp pp) { short weapon; int DoPlayerSpriteReset(short SpriteNum); - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); InventoryKeys(pp); @@ -661,7 +661,7 @@ WeaponOK(PLAYERp pp) if ((unsigned)pp->PlayerSprite >= MAXSPRITES) return(false); - u = User[pp->PlayerSprite]; + u = User[pp->PlayerSprite].Data(); if (u == NULL) return(false); @@ -6887,7 +6887,7 @@ bool DrawBeforeView = false; void pDisplaySprites(PLAYERp pp, double smoothratio) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); PANEL_SPRITEp psp=NULL, next=NULL; short shade, picnum, overlay_shade = 0; double x, y; diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 37c80e1a9..eeb4dc683 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1078,7 +1078,7 @@ DoPlayerSpriteThrow(PLAYERp pp) int DoPlayerSpriteReset(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); PLAYERp pp; if (!u->PlayerP) @@ -1146,7 +1146,7 @@ DoPickTarget(SPRITEp sp, uint32_t max_delta_ang, int skip_targets) SPRITEp ep; USERp eu; int16_t* shp; - USERp u = User[sp - sprite]; + USERp u = User[sp - sprite].Data(); int ezh, ezhl, ezhm; unsigned ndx; TARGET_SORTp ts; @@ -1164,7 +1164,7 @@ DoPickTarget(SPRITEp sp, uint32_t max_delta_ang, int skip_targets) while ((i = it.NextIndex()) >= 0) { ep = &sprite[i]; - eu = User[i]; + eu = User[i].Data(); // don't pick yourself if (i == (sp - sprite)) @@ -1274,7 +1274,7 @@ DoPlayerResetMovement(PLAYERp pp) void DoPlayerTeleportPause(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); // SPRITEp sp = pp->SpriteP; // set this so we don't get stuck in teleporting loop @@ -1381,7 +1381,7 @@ DoSpawnTeleporterEffectPlace(SPRITEp sp) void DoPlayerWarpTeleporter(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); SPRITEp sp = pp->SpriteP; short pnum; SPRITEp sp_warp; @@ -1758,7 +1758,7 @@ void UpdatePlayerUnderSprite(PLAYERp pp) { SPRITEp over_sp = pp->SpriteP; - USERp over_u = User[pp->PlayerSprite]; + USERp over_u = User[pp->PlayerSprite].Data(); SPRITEp sp; USERp u; @@ -1804,7 +1804,7 @@ UpdatePlayerUnderSprite(PLAYERp pp) } sp = pp->UnderSpriteP; - u = User[pp->PlayerUnderSprite]; + u = User[pp->PlayerUnderSprite].Data(); SpriteNum = pp->PlayerUnderSprite; @@ -1974,7 +1974,7 @@ DoPlayerZrange(PLAYERp pp) void DoPlayerSlide(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); int push_ret; if ((pp->slide_xvect|pp->slide_yvect) == 0) @@ -2067,7 +2067,7 @@ void PlayerSectorBound(PLAYERp pp, int amt) void DoPlayerMove(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); int friction; int save_cstat; int push_ret = 0; @@ -2583,7 +2583,7 @@ DriveCrush(PLAYERp pp, int *x, int *y) while ((i = it.NextIndex()) >= 0) { sp = &sprite[i]; - u = User[i]; + u = User[i].Data(); if (testpointinquad(sp->x, sp->y, x, y)) { @@ -2670,7 +2670,7 @@ DriveCrush(PLAYERp pp, int *x, int *y) continue; sp = &sprite[i]; - u = User[i]; + u = User[i].Data(); if (u->PlayerP == pp) continue; @@ -2699,7 +2699,7 @@ DriveCrush(PLAYERp pp, int *x, int *y) while ((i = it.NextIndex()) >= 0) { sp = &sprite[i]; - u = User[i]; + u = User[i].Data(); // give some extra buffer if (sp->z < sop->crush_z + Z(40)) @@ -2726,7 +2726,7 @@ DoPlayerMoveVehicle(PLAYERp pp) int floor_dist; short save_sectnum; SPRITEp sp = pp->sop->sp_child; - USERp u = User[sp - sprite]; + USERp u = User[sp - sprite].Data(); int save_cstat; int x[4], y[4], ox[4], oy[4]; int wallcount; @@ -2974,7 +2974,7 @@ DoPlayerMoveTurret(PLAYERp pp) void DoPlayerBeginJump(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); SET(pp->Flags, PF_JUMPING); RESET(pp->Flags, PF_FALLING); @@ -3005,7 +3005,7 @@ DoPlayerBeginJump(PLAYERp pp) void DoPlayerBeginForceJump(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); SET(pp->Flags, PF_JUMPING); RESET(pp->Flags, PF_FALLING|PF_CRAWLING|PF_CLIMBING|PF_LOCK_CRAWL); @@ -3153,7 +3153,7 @@ DoPlayerForceJump(PLAYERp pp) void DoPlayerBeginFall(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); SET(pp->Flags, PF_FALLING); RESET(pp->Flags, PF_JUMPING); @@ -3299,7 +3299,7 @@ DoPlayerFall(PLAYERp pp) } else if (pp->jump_speed >= 4000) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); PlayerUpdateHealth(pp, -u->Health); // Make sure he dies! u->Health = 0; } @@ -3348,7 +3348,7 @@ DoPlayerFall(PLAYERp pp) void DoPlayerBeginClimb(PLAYERp pp) { -// USERp u = User[pp->PlayerSprite]; +// USERp u = User[pp->PlayerSprite].Data(); SPRITEp sp = pp->SpriteP; RESET(pp->Flags, PF_JUMPING|PF_FALLING); @@ -3370,7 +3370,7 @@ DoPlayerBeginClimb(PLAYERp pp) void DoPlayerClimb(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); int climb_amt; char i; SPRITEp sp = pp->SpriteP; @@ -3647,7 +3647,7 @@ bool PlayerFlyKey(void) void DoPlayerBeginCrawl(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); RESET(pp->Flags, PF_FALLING | PF_JUMPING); SET(pp->Flags, PF_CRAWLING); @@ -3687,7 +3687,7 @@ bool PlayerFallTest(PLAYERp pp, int player_height) void DoPlayerCrawl(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); if (pp->cursectnum >= 0 && SectorIsUnderwaterArea(pp->cursectnum)) { @@ -3763,7 +3763,7 @@ DoPlayerCrawl(PLAYERp pp) void DoPlayerBeginFly(PLAYERp pp) { -// USERp u = User[pp->PlayerSprite]; +// USERp u = User[pp->PlayerSprite].Data(); RESET(pp->Flags, PF_FALLING | PF_JUMPING | PF_CRAWLING); SET(pp->Flags, PF_FLYING); @@ -4267,7 +4267,7 @@ GetOverlapSector2(int x, int y, short *over, short *under) void DoPlayerWarpToUnderwater(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); int i; SECT_USERp sectu = SectUser[pp->cursectnum]; SPRITEp under_sp = NULL, over_sp = NULL; @@ -4344,7 +4344,7 @@ DoPlayerWarpToUnderwater(PLAYERp pp) void DoPlayerWarpToSurface(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); int i; SECT_USERp sectu = SectUser[pp->cursectnum]; short over, under; @@ -4449,7 +4449,7 @@ void DoPlayerBeginDive(PLAYERp pp) { SPRITEp sp = &sprite[pp->PlayerSprite]; - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); if (Prediction) return; @@ -4497,7 +4497,7 @@ DoPlayerBeginDive(PLAYERp pp) void DoPlayerBeginDiveNoWarp(PLAYERp pp) { SPRITEp sp = &sprite[pp->PlayerSprite]; - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); if (Prediction) return; @@ -4644,7 +4644,7 @@ DoPlayerDiveMeter(PLAYERp pp) void DoPlayerDive(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); SECT_USERp sectu = SectUser[pp->cursectnum]; // whenever your view is not in a water area @@ -4827,7 +4827,7 @@ DoPlayerDive(PLAYERp pp) int DoPlayerTestPlaxDeath(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); // landed on a paralax floor if (pp->lo_sectp && TEST(pp->lo_sectp->floorstat, FLOOR_STAT_PLAX)) @@ -4858,7 +4858,7 @@ DoPlayerCurrent(PLAYERp pp) { if (!TEST(pp->Flags, PF_DEAD)) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); PlayerUpdateHealth(pp, -u->Health); // Make sure he dies! PlayerCheckDeath(pp, -1); @@ -4875,7 +4875,7 @@ DoPlayerCurrent(PLAYERp pp) { if (!TEST(pp->Flags, PF_DEAD)) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); PlayerUpdateHealth(pp, -u->Health); // Make sure he dies! PlayerCheckDeath(pp, -1); @@ -4890,7 +4890,7 @@ DoPlayerCurrent(PLAYERp pp) void DoPlayerFireOutWater(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); if (Prediction) return; @@ -4906,7 +4906,7 @@ DoPlayerFireOutWater(PLAYERp pp) void DoPlayerFireOutDeath(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); if (Prediction) return; @@ -4920,7 +4920,7 @@ DoPlayerFireOutDeath(PLAYERp pp) void DoPlayerBeginWade(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); // landed on a paralax floor? if (DoPlayerTestPlaxDeath(pp)) @@ -4953,7 +4953,7 @@ DoPlayerBeginWade(PLAYERp pp) void DoPlayerWade(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); DoPlayerFireOutWater(pp); @@ -5094,7 +5094,7 @@ DoPlayerWade(PLAYERp pp) void DoPlayerBeginOperateBoat(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); pp->floor_dist = PLAYER_RUN_FLOOR_DIST; pp->ceiling_dist = PLAYER_RUN_CEILING_DIST; @@ -5115,7 +5115,7 @@ DoPlayerBeginOperateBoat(PLAYERp pp) void DoPlayerBeginOperateVehicle(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); pp->floor_dist = PLAYER_RUN_FLOOR_DIST; pp->ceiling_dist = PLAYER_RUN_CEILING_DIST; @@ -5135,7 +5135,7 @@ DoPlayerBeginOperateVehicle(PLAYERp pp) void DoPlayerBeginOperateTurret(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); pp->floor_dist = PLAYER_RUN_FLOOR_DIST; pp->ceiling_dist = PLAYER_RUN_CEILING_DIST; @@ -5816,7 +5816,7 @@ DoPlayerBeginDie(PLAYERp pp) short bak; int choosesnd = 0; - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); static void (*PlayerDeathFunc[MAX_PLAYER_DEATHS]) (PLAYERp) = { @@ -5861,7 +5861,7 @@ DoPlayerBeginDie(PLAYERp pp) // Give kill credit to player if necessary if (pp->Killer >= 0) { - USERp ku = User[pp->Killer]; + USERp ku = User[pp->Killer].Data(); ASSERT(ku); @@ -6057,7 +6057,7 @@ DoPlayerDeathTilt(PLAYERp pp, short target, short speed) void DoPlayerDeathZrange(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); // make sure we don't land on a regular sprite DoFindGround(pp->PlayerSprite); @@ -6134,7 +6134,7 @@ void DoPlayerDeathFollowKiller(PLAYERp pp) void DoPlayerDeathCheckKeys(PLAYERp pp) { SPRITEp sp = pp->SpriteP; - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); if (pp->input.actions & SB_OPEN) { @@ -6230,7 +6230,7 @@ DoPlayerHeadDebris(PLAYERp pp) SPRITEp DoPlayerDeathCheckKick(PLAYERp pp) { SPRITEp sp = pp->SpriteP, hp; - USERp u = User[pp->PlayerSprite], hu; + USERp u = User[pp->PlayerSprite].Data(), hu; int i; unsigned stat; int dist; @@ -6242,7 +6242,7 @@ SPRITEp DoPlayerDeathCheckKick(PLAYERp pp) while ((i = it.NextIndex()) >= 0) { hp = &sprite[i]; - hu = User[i]; + hu = User[i].Data(); if (i == pp->PlayerSprite) break; @@ -6293,7 +6293,7 @@ SPRITEp DoPlayerDeathCheckKick(PLAYERp pp) void DoPlayerDeathMoveHead(PLAYERp pp) { SPRITEp sp = pp->SpriteP; - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); int dax,day; short sectnum; @@ -6445,7 +6445,7 @@ void DoPlayerDeathDrown(PLAYERp pp) void DoPlayerDeathBounce(PLAYERp pp) { SPRITEp sp = pp->SpriteP; - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); if (Prediction) return; @@ -6475,7 +6475,7 @@ void DoPlayerDeathBounce(PLAYERp pp) void DoPlayerDeathCrumble(PLAYERp pp) { SPRITEp sp = pp->SpriteP; - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); if (Prediction) return; @@ -6528,7 +6528,7 @@ void DoPlayerDeathCrumble(PLAYERp pp) void DoPlayerDeathExplode(PLAYERp pp) { SPRITEp sp = pp->SpriteP; - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); if (Prediction) return; @@ -6584,7 +6584,7 @@ void DoPlayerDeathExplode(PLAYERp pp) void DoPlayerBeginRun(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); // Crawl if in small aread automatically if (DoPlayerTestCrawl(pp)) @@ -6619,7 +6619,7 @@ DoPlayerBeginRun(PLAYERp pp) void DoPlayerRun(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); if (pp->cursectnum >= 0 && SectorIsUnderwaterArea(pp->cursectnum)) { @@ -6768,7 +6768,7 @@ PlayerStateControl(int16_t SpriteNum) return; // Convienience var - u = User[SpriteNum]; + u = User[SpriteNum].Data(); if (u == NULL) return; @@ -6859,7 +6859,7 @@ MoveSkipSavePos(void) continue; sp = &sprite[i]; - u = User[i]; + u = User[i].Data(); if (sp == NULL || u == NULL) continue; @@ -6883,7 +6883,7 @@ MoveSkipSavePos(void) if ((unsigned)i >= MAXSPRITES) continue; sp = &sprite[i]; - u = User[i]; + u = User[i].Data(); if (sp == NULL || u == NULL) continue; @@ -7438,7 +7438,7 @@ InitMultiPlayerInfo(void) start0 = SpawnSprite(MultiStatList[stat], ST1, NULL, pp->cursectnum, pp->posx, pp->posy, pp->posz, pp->angle.ang.asbuild(), 0); ASSERT(start0 >= 0); - FreeUser(start0); + User[start0].Clear(); sprite[start0].picnum = ST1; } @@ -7473,7 +7473,7 @@ InitMultiPlayerInfo(void) int DoFootPrints(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (u->PlayerP) { diff --git a/source/games/sw/src/ripper.cpp b/source/games/sw/src/ripper.cpp index 168ec57ba..6c56ec857 100644 --- a/source/games/sw/src/ripper.cpp +++ b/source/games/sw/src/ripper.cpp @@ -824,12 +824,12 @@ SetupRipper(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum, RIPPER_RUN_R0, s_RipperRun[0]); + u = SpawnUser(SpriteNum, RIPPER_RUN_R0, s_RipperRun[0]); u->Health = HEALTH_RIPPER/2; // Baby rippers are weaker } @@ -882,7 +882,7 @@ GetJumpHeight(short jump_speed, short jump_grav) int PickJumpSpeed(short SpriteNum, int pix_height) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); //ASSERT(pix_height < 128); @@ -907,7 +907,7 @@ int PickJumpMaxSpeed(short SpriteNum, short max_speed) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int zh; ASSERT(max_speed < 0); @@ -940,7 +940,7 @@ int InitRipperHang(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int dist; hitdata_t hitinfo = { { 0, 0, 0 }, -2, 0, -2 }; @@ -1001,7 +1001,7 @@ InitRipperHang(short SpriteNum) int DoRipperHang(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if ((u->WaitTics -= ACTORMOVETICS) > 0) return 0; @@ -1016,7 +1016,7 @@ int DoRipperMoveHang(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int nx, ny; // Move while jumping @@ -1055,7 +1055,7 @@ DoRipperMoveHang(short SpriteNum) int DoRipperHangJF(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags, SPR_JUMPING | SPR_FALLING)) { @@ -1087,7 +1087,7 @@ int DoRipperBeginJumpAttack(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp psp = User[SpriteNum]->tgt_sp; short tang; @@ -1121,7 +1121,7 @@ DoRipperBeginJumpAttack(short SpriteNum) int DoRipperMoveJump(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags, SPR_JUMPING | SPR_FALLING)) { @@ -1150,7 +1150,7 @@ DoRipperMoveJump(short SpriteNum) int DoRipperQuickJump(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); // Tests to see if ripper is on top of a player/enemy and then immediatly // does another jump @@ -1175,7 +1175,7 @@ DoRipperQuickJump(short SpriteNum) int NullRipper(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags,SPR_SLIDING)) DoActorSlide(SpriteNum); @@ -1188,7 +1188,7 @@ NullRipper(short SpriteNum) int DoRipperPain(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); NullRipper(SpriteNum); @@ -1204,7 +1204,7 @@ int DoRipperRipHeart(short SpriteNum) // CTW MODIFICATION END { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp tsp = u->tgt_sp; @@ -1221,7 +1221,7 @@ int DoRipperRipHeart(short SpriteNum) int DoRipperStandHeart(short SpriteNum) // CTW MODIFICATION END { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); NullRipper(SpriteNum); @@ -1259,7 +1259,7 @@ void RipperHatch(short Weapon) np->ang = rip_ang[i]; np->pal = 0; SetupRipper(New); - nu = User[New]; + nu = User[New].Data(); // make immediately active SET(nu->Flags, SPR_ACTIVE); @@ -1284,7 +1284,7 @@ void RipperHatch(short Weapon) int DoRipperMove(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (u->scale_speed) { diff --git a/source/games/sw/src/ripper2.cpp b/source/games/sw/src/ripper2.cpp index 2b7e563b5..ebd2d7867 100644 --- a/source/games/sw/src/ripper2.cpp +++ b/source/games/sw/src/ripper2.cpp @@ -894,12 +894,12 @@ SetupRipper2(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum, RIPPER2_RUN_R0, s_Ripper2Run[0]); + u = SpawnUser(SpriteNum, RIPPER2_RUN_R0, s_Ripper2Run[0]); u->Health = HEALTH_RIPPER2; } @@ -940,7 +940,7 @@ int InitRipper2Hang(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int dist; hitdata_t hitinfo = { { 0, 0, 0 }, -2, 0, -2 }; @@ -1000,7 +1000,7 @@ InitRipper2Hang(short SpriteNum) int DoRipper2Hang(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if ((u->WaitTics -= ACTORMOVETICS) > 0) return 0; @@ -1016,7 +1016,7 @@ int DoRipper2MoveHang(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int nx, ny; // Move while jumping @@ -1062,7 +1062,7 @@ DoRipper2MoveHang(short SpriteNum) int DoRipper2HangJF(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags, SPR_JUMPING | SPR_FALLING)) { @@ -1094,7 +1094,7 @@ int DoRipper2BeginJumpAttack(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp psp = User[SpriteNum]->tgt_sp; short tang; @@ -1135,7 +1135,7 @@ DoRipper2BeginJumpAttack(short SpriteNum) int DoRipper2MoveJump(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags, SPR_JUMPING | SPR_FALLING)) { @@ -1164,7 +1164,7 @@ DoRipper2MoveJump(short SpriteNum) int DoRipper2QuickJump(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); // Tests to see if ripper2 is on top of a player/enemy and then immediatly // does another jump @@ -1189,7 +1189,7 @@ DoRipper2QuickJump(short SpriteNum) int NullRipper2(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags,SPR_SLIDING)) DoActorSlide(SpriteNum); @@ -1202,7 +1202,7 @@ NullRipper2(short SpriteNum) int DoRipper2Pain(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); NullRipper2(SpriteNum); @@ -1215,7 +1215,7 @@ int DoRipper2Pain(short SpriteNum) int DoRipper2RipHeart(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp tsp = u->tgt_sp; @@ -1230,7 +1230,7 @@ int DoRipper2RipHeart(short SpriteNum) int DoRipper2StandHeart(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); NullRipper2(SpriteNum); @@ -1274,7 +1274,7 @@ void Ripper2Hatch(short Weapon) np->pal = 0; np->shade = -10; SetupRipper2(New); - nu = User[New]; + nu = User[New].Data(); // make immediately active SET(nu->Flags, SPR_ACTIVE); @@ -1300,7 +1300,7 @@ int DoRipper2Move(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (sp->hitag == TAG_SWARMSPOT && sp->lotag == 1) DoCheckSwarm(SpriteNum); diff --git a/source/games/sw/src/rotator.cpp b/source/games/sw/src/rotator.cpp index 6478545ad..8f05a6e37 100644 --- a/source/games/sw/src/rotator.cpp +++ b/source/games/sw/src/rotator.cpp @@ -47,7 +47,7 @@ void DoRotatorStopInterp(short SpriteNum); void ReverseRotator(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); ROTATORp r; r = u->rotator.Data(); @@ -97,7 +97,7 @@ RotatorSwitch(short match, short setting) void SetRotatorActive(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; ROTATORp r; @@ -120,7 +120,7 @@ void SetRotatorActive(short SpriteNum) void SetRotatorInactive(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; DoRotatorStopInterp(SpriteNum); @@ -170,7 +170,7 @@ DoRotatorMatch(PLAYERp pp, short match, bool manual) if (SP_TAG1(fsp) == SECT_ROTATOR && SP_TAG2(fsp) == match) { - fu = User[i]; + fu = User[i].Data(); // single play only vator // bool 8 must be set for message to display @@ -247,7 +247,7 @@ TestRotatorMatchActive(short match) if (SP_TAG1(fsp) == SECT_ROTATOR && SP_TAG2(fsp) == match) { - fu = User[i]; + fu = User[i].Data(); // Does not have to be inactive to be operated if (TEST_BOOL6(fsp)) @@ -310,7 +310,7 @@ void DoRotatorStopInterp(short SpriteNum) int DoRotatorMove(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; ROTATORp r; short ndx,w,startwall,endwall; @@ -435,7 +435,7 @@ int DoRotatorMove(short SpriteNum) int DoRotator(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; // could move this inside sprite control diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index e1c060db5..61a66e134 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -361,17 +361,17 @@ bool GameInterface::SaveGame() for (i = 0; i < MAXSPRITES; i++) { ndx = i; - if (User[i]) + if (User[i].Data()) { // write header MWRITE(&ndx,sizeof(ndx),1,fil); +#if 0 memcpy(&tu, User[i], sizeof(USER)); u = &tu; MWRITE(u,sizeof(USER),1,fil); -#if 0 if (u->WallShade) { MWRITE(u->WallShade, sizeof(*u->WallShade) * u->WallCount, 1, fil); @@ -484,9 +484,9 @@ bool GameInterface::SaveGame() // maintain compatibility with sinking boat which points to user data for (j=0; jptr >= bp && (uint8_t*)a->ptr < bp + sizeof(USER)) { @@ -748,7 +748,8 @@ bool GameInterface::LoadGame() MREAD(&SpriteNum, sizeof(SpriteNum),1,fil); while (SpriteNum != -1) { - User[SpriteNum] = u = NewUser(); + User[SpriteNum].Alloc(); + u = User[SpriteNum].Data(); // We need to be careful with allocated content in User when loading a binary save state. // This needs to be refactored out ASAP. u->rotator.Clear(); @@ -858,7 +859,7 @@ bool GameInterface::LoadGame() int offset; MREAD(&j, sizeof(j),1,fil); MREAD(&offset, sizeof(offset),1,fil); - a->ptr = (int *)(((char *)User[j]) + offset); + a->ptr = (int *)(((char *)User[j].Data()) + offset); } else if ((intptr_t)a->ptr == -3) { diff --git a/source/games/sw/src/sbar.cpp b/source/games/sw/src/sbar.cpp index 51a380646..4da1d6bd0 100644 --- a/source/games/sw/src/sbar.cpp +++ b/source/games/sw/src/sbar.cpp @@ -367,7 +367,7 @@ private: void PlayerUpdateWeaponSummary(PLAYERp pp, int UpdateWeaponNum) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); int x, y; int pos; int column; @@ -665,7 +665,7 @@ private: void DrawStatusBar() { auto pp = Player + screenpeek; - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); BeginStatusBar(320, 200, tileHeight(STATUS_BAR)); if (hud_size == Hud_StbarOverlay) Set43ClipRect(); @@ -742,7 +742,7 @@ private: { BeginHUD(320, 200, 1); auto pp = Player + screenpeek; - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); int x, y; INVENTORY_DATAp id; @@ -785,7 +785,7 @@ private: BeginHUD(320, 200, 1); auto pp = Player + screenpeek; - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); FString format; FGameTexture* img; diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index 03876c2a1..8e9c1494c 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -83,7 +83,7 @@ int lavaradx[32][128], lavarady[32][128], lavaradcnt[32]; #endif SECT_USERp SectUser[MAXSECTORS]; -USERp User[MAXSPRITES]; +TPointer User[MAXSPRITES]; ANIM Anim[MAXANIM]; short AnimCnt = 0; @@ -1025,7 +1025,7 @@ void SectorExp(short SpriteNum, short sectnum, short orig_ang, int zh) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); short explosion; SPRITEp exp; USERp eu; @@ -1053,7 +1053,7 @@ SectorExp(short SpriteNum, short sectnum, short orig_ang, int zh) explosion = SpawnSectorExp(SpriteNum); ASSERT(explosion >= 0); exp = &sprite[explosion]; - eu = User[explosion]; + eu = User[explosion].Data(); exp->xrepeat += (RANDOM_P2(32<<8)>>8) - 16; exp->yrepeat += (RANDOM_P2(32<<8)>>8) - 16; @@ -1082,7 +1082,7 @@ DoExplodeSector(short match) if (match != esp->lotag) continue; - if (!User[cf]) + if (!User[cf].Data()) /*u = */SpawnUser(cf, 0, NULL); sectp = §or[esp->sectnum]; @@ -1114,7 +1114,7 @@ DoExplodeSector(short match) int DoSpawnSpot(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if ((u->WaitTics -= synctics) < 0) { @@ -1150,7 +1150,7 @@ DoSpawnSpotsForKill(short match) // change the stat num and set the delay correctly to call SpawnShrap if (sp->hitag == SPAWN_SPOT && sp->lotag == match) { - u = User[sn]; + u = User[sn].Data(); change_sprite_stat(sn, STAT_NO_STATE); u->ActorActionFunc = DoSpawnSpot; u->WaitTics = SP_TAG5(sp) * 15; @@ -1181,7 +1181,7 @@ DoSpawnSpotsForDamage(short match) if (sp->hitag == SPAWN_SPOT && sp->lotag == match) { - u = User[sn]; + u = User[sn].Data(); change_sprite_stat(sn, STAT_NO_STATE); u->ActorActionFunc = DoSpawnSpot; u->WaitTics = SP_TAG7(sp) * 15; @@ -1398,7 +1398,7 @@ WeaponExplodeSectorInRange(short weapon) { int i; SPRITEp wp = &sprite[weapon]; - USERp wu = User[weapon]; + USERp wu = User[weapon].Data(); SPRITEp sp; int dist; int radius; @@ -1668,7 +1668,7 @@ int OperateSprite(short SpriteNum, short player_is_operating) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); PLAYERp pp = NULL; short state; short key_num=0; @@ -1997,7 +1997,7 @@ int DoTrapReset(short match) while ((i = it.NextIndex()) >= 0) { sp = &sprite[i]; - u = User[i]; + u = User[i].Data(); if (sp->lotag != match) continue; @@ -2029,7 +2029,7 @@ int DoTrapMatch(short match) while ((i = it.NextIndex()) >= 0) { sp = &sprite[i]; - u = User[i]; + u = User[i].Data(); if (sp->lotag != match) continue; @@ -2161,7 +2161,7 @@ OperateTripTrigger(PLAYERp pp) while ((i = it.NextIndex()) >= 0) { sp = &sprite[i]; - u = User[i]; + u = User[i].Data(); if (TEST(u->Flags, SPR_WAIT_FOR_TRIGGER)) { @@ -2235,7 +2235,7 @@ OperateContinuousTrigger(PLAYERp pp) while ((i = it.NextIndex()) >= 0) { sp = &sprite[i]; - u = User[i]; + u = User[i].Data(); // if correct type and matches if (sp->hitag == FIREBALL_TRAP && sp->lotag == sector[pp->cursectnum].hitag) @@ -2284,7 +2284,7 @@ OperateContinuousTrigger(PLAYERp pp) short PlayerTakeSectorDamage(PLAYERp pp) { SECT_USERp sectu = SectUser[pp->cursectnum]; - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); // the calling routine must make sure sectu exists if ((u->DamageTics -= synctics) < 0) @@ -2711,7 +2711,7 @@ PlayerOperateEnv(PLAYERp pp) } else { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); u->DamageTics = 0; } diff --git a/source/games/sw/src/serp.cpp b/source/games/sw/src/serp.cpp index bba1e6395..911a29605 100644 --- a/source/games/sw/src/serp.cpp +++ b/source/games/sw/src/serp.cpp @@ -704,12 +704,12 @@ SetupSerp(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,SERP_RUN_R0,s_SerpRun[0]); + u = SpawnUser(SpriteNum,SERP_RUN_R0,s_SerpRun[0]); u->Health = HEALTH_SERP_GOD; } @@ -755,7 +755,7 @@ SetupSerp(short SpriteNum) int NullSerp(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags,SPR_SLIDING)) DoActorSlide(SpriteNum); @@ -769,7 +769,7 @@ int NullSerp(short SpriteNum) int DoSerpMove(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags,SPR_SLIDING)) DoActorSlide(SpriteNum); diff --git a/source/games/sw/src/skel.cpp b/source/games/sw/src/skel.cpp index a47971f8e..114f1a774 100644 --- a/source/games/sw/src/skel.cpp +++ b/source/games/sw/src/skel.cpp @@ -509,12 +509,12 @@ SetupSkel(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,SKEL_RUN_R0,s_SkelRun[0]); + u = SpawnUser(SpriteNum,SKEL_RUN_R0,s_SkelRun[0]); u->Health = HEALTH_SKEL_PRIEST; } @@ -588,7 +588,7 @@ int DoSkelTermTeleport(short SpriteNum) int NullSkel(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags,SPR_SLIDING)) DoActorSlide(SpriteNum); @@ -601,7 +601,7 @@ int NullSkel(short SpriteNum) int DoSkelPain(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); NullSkel(SpriteNum); @@ -613,7 +613,7 @@ int DoSkelPain(short SpriteNum) int DoSkelMove(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags,SPR_SLIDING)) DoActorSlide(SpriteNum); diff --git a/source/games/sw/src/skull.cpp b/source/games/sw/src/skull.cpp index 68bd25c5e..bb343a84c 100644 --- a/source/games/sw/src/skull.cpp +++ b/source/games/sw/src/skull.cpp @@ -219,12 +219,12 @@ SetupSkull(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,SKULL_R0,s_SkullWait[0]); + u = SpawnUser(SpriteNum,SKULL_R0,s_SkullWait[0]); u->Health = HEALTH_SKULL; } @@ -265,7 +265,7 @@ int DoSkullMove(int16_t SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int32_t dax, day, daz; dax = MOVEx(sp->xvel, sp->ang); @@ -282,7 +282,7 @@ int DoSkullBeginDeath(int16_t SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int16_t i,num_ord=0; //extern short *DamageRadiusSkull; @@ -369,7 +369,7 @@ DoSkullBeginDeath(int16_t SpriteNum) int DoSkullJump(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (sp->xvel) @@ -432,7 +432,7 @@ int DoSkullJump(short SpriteNum) int DoSkullBob(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); // actor does a sine wave about u->sz - this is the z mid point #define SKULL_BOB_AMT (Z(16)) @@ -457,7 +457,7 @@ int DoSkullSpawnShrap(short SpriteNum) int DoSkullWait(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int a,b,c,dist; DISTANCE(sp->x, sp->y, u->tgt_sp->x, u->tgt_sp->y, dist, a, b, c); @@ -637,12 +637,12 @@ SetupBetty(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,BETTY_R0,s_BettyWait[0]); + u = SpawnUser(SpriteNum,BETTY_R0,s_BettyWait[0]); u->Health = HEALTH_SKULL; } @@ -683,7 +683,7 @@ int DoBettyMove(int16_t SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int32_t dax, day, daz; dax = MOVEx(sp->xvel, sp->ang); @@ -700,7 +700,7 @@ int DoBettyBeginDeath(int16_t SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int16_t i,num_ord=0; //extern short *DamageRadiusBetty; @@ -782,7 +782,7 @@ DoBettyBeginDeath(int16_t SpriteNum) int DoBettyJump(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (sp->xvel) @@ -843,7 +843,7 @@ int DoBettyJump(short SpriteNum) int DoBettyBob(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); // actor does a sine wave about u->sz - this is the z mid point #define BETTY_BOB_AMT (Z(16)) @@ -866,7 +866,7 @@ int DoBettySpawnShrap(short SpriteNum) int DoBettyWait(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int a,b,c,dist; DISTANCE(sp->x, sp->y, u->tgt_sp->x, u->tgt_sp->y, dist, a, b, c); diff --git a/source/games/sw/src/slidor.cpp b/source/games/sw/src/slidor.cpp index 4650bda82..b86f62e83 100644 --- a/source/games/sw/src/slidor.cpp +++ b/source/games/sw/src/slidor.cpp @@ -41,7 +41,7 @@ BEGIN_SW_NS void ReverseSlidor(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); ROTATORp r; r = u->rotator.Data(); @@ -92,7 +92,7 @@ SlidorSwitch(short match, short setting) void SetSlidorActive(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; ROTATORp r; @@ -115,7 +115,7 @@ void SetSlidorActive(short SpriteNum) void SetSlidorInactive(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; DoSlidorInterp(SpriteNum, StopInterpolation); @@ -166,7 +166,7 @@ DoSlidorMatch(PLAYERp pp, short match, bool manual) if (SP_TAG1(fsp) == SECT_SLIDOR && SP_TAG2(fsp) == match) { - fu = User[i]; + fu = User[i].Data(); // single play only vator // bool 8 must be set for message to display @@ -243,7 +243,7 @@ TestSlidorMatchActive(short match) if (SP_TAG1(fsp) == SECT_SLIDOR && SP_TAG2(fsp) == match) { - fu = User[i]; + fu = User[i].Data(); // Does not have to be inactive to be operated if (TEST_BOOL6(fsp)) @@ -537,7 +537,7 @@ int DoSlidorInstantClose(short SpriteNum) int DoSlidorMove(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; ROTATORp r; int old_pos; @@ -632,7 +632,7 @@ int DoSlidorMove(short SpriteNum) while ((i = it.NextIndex()) >= 0) { bsp = &sprite[i]; - bu = User[i]; + bu = User[i].Data(); if (bu && TEST(bsp->cstat, CSTAT_SPRITE_BLOCK) && TEST(bsp->extra, SPRX_PLAYER_OR_ENEMY)) { @@ -681,7 +681,7 @@ int DoSlidorMove(short SpriteNum) int DoSlidor(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; SECTORp sectp = §or[sp->sectnum]; diff --git a/source/games/sw/src/sounds.cpp b/source/games/sw/src/sounds.cpp index bb645b2bd..4733a2dc0 100644 --- a/source/games/sw/src/sounds.cpp +++ b/source/games/sw/src/sounds.cpp @@ -788,7 +788,7 @@ void Set3DSoundOwner(short spritenum) void PlaySpriteSound(short spritenum, int attrib_ndx, Voc3D_Flags flags) { SPRITEp sp = &sprite[spritenum]; - USERp u = User[spritenum]; + USERp u = User[spritenum].Data(); ASSERT(u); diff --git a/source/games/sw/src/spike.cpp b/source/games/sw/src/spike.cpp index e14235fa9..68cdc8bd0 100644 --- a/source/games/sw/src/spike.cpp +++ b/source/games/sw/src/spike.cpp @@ -43,7 +43,7 @@ void InterpSectorSprites(short sectnum, bool state); void ReverseSpike(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; // if paused go ahead and start it up again @@ -97,7 +97,7 @@ SpikeSwitch(short match, short setting) void SetSpikeActive(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; SECTORp sectp = §or[sp->sectnum]; @@ -125,7 +125,7 @@ void SetSpikeActive(short SpriteNum) void SetSpikeInactive(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; SECTORp sectp = §or[sp->sectnum]; @@ -195,7 +195,7 @@ DoSpikeMatch(short match) if (SP_TAG1(fsp) == SECT_SPIKE && SP_TAG2(fsp) == match) { - fu = User[i]; + fu = User[i].Data(); if (first_spike == -1) first_spike = i; @@ -229,7 +229,7 @@ TestSpikeMatchActive(short match) if (SP_TAG1(fsp) == SECT_SPIKE && SP_TAG2(fsp) == match) { - fu = User[i]; + fu = User[i].Data(); // door war if (TEST_BOOL6(fsp)) @@ -245,7 +245,7 @@ TestSpikeMatchActive(short match) int DoSpikeMove(short SpriteNum, int *lptr) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int zval; zval = *lptr; @@ -282,7 +282,7 @@ int DoSpikeMove(short SpriteNum, int *lptr) void SpikeAlign(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; // either work on single sector or all tagged in SOBJ @@ -313,7 +313,7 @@ void MoveSpritesWithSpike(short sectnum) { sp = &sprite[i]; - if (User[i]) + if (User[i].Data()) continue; if (TEST(sp->extra, SPRX_STAY_PUT_VATOR)) @@ -326,7 +326,7 @@ void MoveSpritesWithSpike(short sectnum) int DoSpike(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; int *lptr; @@ -409,7 +409,7 @@ int DoSpike(short SpriteNum) while ((i = it.NextIndex()) >= 0) { bsp = &sprite[i]; - bu = User[i]; + bu = User[i].Data(); if (bu && TEST(bsp->cstat, CSTAT_SPRITE_BLOCK) && TEST(bsp->extra, SPRX_PLAYER_OR_ENEMY)) { @@ -444,7 +444,7 @@ int DoSpike(short SpriteNum) int DoSpikeAuto(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; int *lptr; diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index ebbae6c36..7c7488e7f 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -593,7 +593,7 @@ SetOwner(short owner, short child) if (owner >= 0) { - ASSERT(User[owner]); + ASSERT(User[owner].Data()); SET(User[owner]->Flags2, SPR2_CHILDREN); } else @@ -608,11 +608,11 @@ SetOwner(short owner, short child) void SetAttach(short owner, short child) { - USERp cu = User[child]; + USERp cu = User[child].Data(); ASSERT(cu); - ASSERT(User[owner]); + ASSERT(User[owner].Data()); SET(User[owner]->Flags2, SPR2_CHILDREN); cu->Attach = owner; } @@ -621,7 +621,7 @@ void KillSprite(int16_t SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int i; unsigned stat; short statnum,sectnum; @@ -727,7 +727,7 @@ KillSprite(int16_t SpriteNum) StatIterator it(MissileStats[stat]); while ((i = it.NextIndex()) >= 0) { - mu = User[i]; + mu = User[i].Data(); if (mu && mu->WpnGoal == SpriteNum) { @@ -753,7 +753,7 @@ KillSprite(int16_t SpriteNum) sprite[i].owner = -1; } - if (User[i] && User[i]->Attach == SpriteNum) + if (User[i].Data() && User[i]->Attach == SpriteNum) { User[i]->Attach = -1; } @@ -766,7 +766,7 @@ KillSprite(int16_t SpriteNum) StatIterator it(STAT_ENEMY); while ((i = it.NextIndex()) >= 0) { - if ((unsigned)i < MAXSPRITES && User[i] != NULL && User[i]->tgt_sp == sp) + if ((unsigned)i < MAXSPRITES && User[i].Data() != NULL && User[i]->tgt_sp == sp) { DoActorPickClosePlayer(i); } @@ -777,10 +777,7 @@ KillSprite(int16_t SpriteNum) { SetSuicide(u->flame); } - - u->rotator.Clear(); - - FreeUser(SpriteNum); + User[SpriteNum].Clear(); } FVector3 pos = GetSoundPos(&sprite[SpriteNum].pos); @@ -795,9 +792,9 @@ KillSprite(int16_t SpriteNum) sp->sectnum = sectnum; // Kill references in all users - slow but unavoidable if we don't want the game to crash on stale pointers. - for (auto u : User) + for (auto& u : User) { - if (u) + if (u.Data()) { if (u->hi_sp == sp) u->hi_sp = nullptr; if (u->lo_sp == sp) u->lo_sp = nullptr; @@ -808,7 +805,7 @@ KillSprite(int16_t SpriteNum) void ChangeState(short SpriteNum, STATEp statep) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (u == nullptr) return; @@ -821,7 +818,7 @@ void ChangeState(short SpriteNum, STATEp statep) void change_sprite_stat(short SpriteNum, short stat) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); changespritestat(SpriteNum, stat); @@ -873,7 +870,8 @@ SpawnUser(short SpriteNum, short id, STATEp state) ASSERT(!Prediction); - User[SpriteNum] = u = NewUser(); + User[SpriteNum].Alloc(); + u = User[SpriteNum].Data(); PRODUCTION_ASSERT(u != NULL); @@ -970,7 +968,7 @@ SpawnSprite(short stat, short id, STATEp state, short sectnum, int x, int y, int sp->z = z; sp->cstat = 0; - User[SpriteNum] = u = SpawnUser(SpriteNum, id, state); + u = SpawnUser(SpriteNum, id, state); // be careful State can be NULL if (u->State) @@ -1560,7 +1558,7 @@ void IconDefault(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); //if (sp->statnum == STAT_ITEM) change_sprite_stat(SpriteNum, STAT_ITEM); @@ -1761,7 +1759,7 @@ SpriteSetupPost(void) if (TEST(ds->cstat, CSTAT_SPRITE_ALIGNMENT_WALL|CSTAT_SPRITE_ALIGNMENT_FLOOR)) continue; - if (User[i]) + if (User[i].Data()) continue; getzsofslope(ds->sectnum, ds->x, ds->y, &cz, &fz); @@ -2593,7 +2591,7 @@ SpriteSetup(void) } } - User[SpriteNum] = u = SpawnUser(SpriteNum, 0, NULL); + u = SpawnUser(SpriteNum, 0, NULL); u->WallShade.Resize(wallcount); wall_shade = u->WallShade.Data(); @@ -2649,7 +2647,7 @@ SpriteSetup(void) // !LIGHT // make an wall_shade array and put it in User - User[SpriteNum] = u = SpawnUser(SpriteNum, 0, NULL); + u = SpawnUser(SpriteNum, 0, NULL); u->WallShade.Resize(wallcount); wall_shade = u->WallShade.Data(); @@ -2857,7 +2855,7 @@ SpriteSetup(void) break; case SPAWN_SPOT: - if (!User[SpriteNum]) + if (!User[SpriteNum].Data()) u = SpawnUser(SpriteNum, ST1, NULL); if (SP_TAG14(sp) == ((64<<8)|64)) @@ -3828,7 +3826,7 @@ bool ItemSpotClear(SPRITEp sip, short statnum, short id) void SetupItemForJump(SPRITEp sip, short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); // setup item for jumping if (SP_TAG7(sip)) @@ -3850,7 +3848,7 @@ void SetupItemForJump(SPRITEp sip, short SpriteNum) int ActorCoughItem(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); short New,choose; SPRITEp np; @@ -4357,7 +4355,7 @@ int SpawnItemsMatch(short match) SpriteNum = SpawnSprite(STAT_ITEM, ICON_ARMOR, s_IconArmor, sip->sectnum, sip->x, sip->y, sip->z, sip->ang, 0); sp = &sprite[SpriteNum]; - u = User[SpriteNum]; + u = User[SpriteNum].Data(); SET(u->Flags2, SPR2_NEVER_RESPAWN); IconDefault(SpriteNum); @@ -4581,7 +4579,7 @@ int SpawnItemsMatch(short match) break; SpriteNum = SpawnSprite(STAT_ITEM, s_Key[num]->Pic, s_Key[num], sip->sectnum, sip->x, sip->y, sip->z, sip->ang, 0); - u = User[SpriteNum]; + u = User[SpriteNum].Data(); sp = &sprite[SpriteNum]; @@ -4617,7 +4615,7 @@ int // CTW MODIFICATION END NewStateGroup(short SpriteNum, STATEp StateGroup[]) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); //if (Prediction) // return; @@ -4650,8 +4648,8 @@ SpriteOverlap(int16_t spritenum_a, int16_t spritenum_b) { SPRITEp spa = &sprite[spritenum_a], spb = &sprite[spritenum_b]; - USERp ua = User[spritenum_a]; - USERp ub = User[spritenum_b]; + USERp ua = User[spritenum_a].Data(); + USERp ub = User[spritenum_b].Data(); int spa_tos, spa_bos, spb_tos, spb_bos, overlap_z; @@ -4846,7 +4844,7 @@ void DoActorZrange(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int ceilhit, florhit; short save_cstat; @@ -4891,7 +4889,7 @@ DoActorZrange(short SpriteNum) int DoActorGlobZ(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); u->loz = globloz; u->hiz = globhiz; @@ -5017,7 +5015,7 @@ DropAhead(short SpriteNum, short min_height) int move_actor(short SpriteNum, int xchange, int ychange, int zchange) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; int x, y, z, loz, hiz; @@ -5151,10 +5149,7 @@ DoGrating(short SpriteNum) if (sp->hitag <= 0) { change_sprite_stat(SpriteNum, STAT_DEFAULT); - if (User[SpriteNum]) - { - FreeUser(SpriteNum); - } + User[SpriteNum].Clear(); } setspritez(SpriteNum, &sp->pos); @@ -5166,7 +5161,7 @@ DoGrating(short SpriteNum) int DoSpriteFade(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; short i; @@ -5196,7 +5191,7 @@ DoSpriteFade(short SpriteNum) int SpearOnFloor(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; if (!TEST(u->Flags, SPR_SO_ATTACHED)) @@ -5214,7 +5209,7 @@ SpearOnFloor(short SpriteNum) int SpearOnCeiling(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; if (!TEST(u->Flags, SPR_SO_ATTACHED)) @@ -5245,7 +5240,7 @@ DoKey(short SpriteNum) int DoCoin(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int offset; u->WaitTics -= ACTORMOVETICS * 2; @@ -5281,7 +5276,7 @@ DoCoin(short SpriteNum) int KillGet(short SpriteNum) { - USERp u = User[SpriteNum],nu; + USERp u = User[SpriteNum].Data(),nu; SPRITEp sp = User[SpriteNum]->SpriteP,np; short New; @@ -5312,7 +5307,7 @@ KillGet(short SpriteNum) sp->x, sp->y, sp->z, 0, 0); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); np->shade = -20; nu->WaitTics = u->WaitTics - 12; @@ -5325,7 +5320,7 @@ KillGet(short SpriteNum) int KillGetAmmo(short SpriteNum) { - USERp u = User[SpriteNum],nu; + USERp u = User[SpriteNum].Data(),nu; SPRITEp sp = User[SpriteNum]->SpriteP,np; short New; @@ -5364,7 +5359,7 @@ KillGetAmmo(short SpriteNum) sp->x, sp->y, sp->z, 0, 0); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); np->shade = -20; nu->WaitTics = u->WaitTics - 12; @@ -5377,7 +5372,7 @@ KillGetAmmo(short SpriteNum) int KillGetWeapon(short SpriteNum) { - USERp u = User[SpriteNum],nu; + USERp u = User[SpriteNum].Data(),nu; SPRITEp sp = User[SpriteNum]->SpriteP,np; short New; @@ -5424,7 +5419,7 @@ KillGetWeapon(short SpriteNum) sp->x, sp->y, sp->z, 0, 0); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); np->shade = -20; nu->WaitTics = u->WaitTics - 12; @@ -5467,7 +5462,7 @@ void ChoosePlayerGetSound(PLAYERp pp) bool CanGetWeapon(PLAYERp pp, short SpriteNum, int WPN) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); switch (gNet.MultiGameType) { @@ -5519,8 +5514,8 @@ struct InventoryDecl_t InventoryDecls[InvDecl_TOTAL] = int DoGet(short SpriteNum) { - USERp u = User[SpriteNum], pu; - SPRITEp sp = User[SpriteNum]->SpriteP; + USERp u = User[SpriteNum].Data(), pu; + SPRITEp sp = u->SpriteP; PLAYERp pp; short pnum, key_num; int dist, a,b,c; @@ -5561,8 +5556,8 @@ DoGet(short SpriteNum) TRAVERSE_CONNECT(pnum) { pp = &Player[pnum]; - //pu = User[pp->PlayerSprite]; - pu = User[pp->SpriteP - sprite]; + //pu = User[pp->PlayerSprite].Data(); + pu = User[pp->SpriteP - sprite].Data(); if (TEST(pp->Flags, PF_DEAD)) continue; @@ -6374,7 +6369,7 @@ KeyMain: sp->x, sp->y, sp->z, 0, 0); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); np->shade = -20; // Attach flag to player @@ -6410,7 +6405,7 @@ KeyMain: void SetEnemyActive(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SET(u->Flags, SPR_ACTIVE); u->inactive_time = 0; @@ -6419,7 +6414,7 @@ SetEnemyActive(short SpriteNum) void SetEnemyInactive(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); RESET(u->Flags, SPR_ACTIVE); } @@ -6430,7 +6425,7 @@ SetEnemyInactive(short SpriteNum) void ProcessActiveVars(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); #define TIME_TILL_INACTIVE (4*120) if (!TEST(u->Flags, SPR_ACTIVE)) @@ -6452,7 +6447,7 @@ ProcessActiveVars(short SpriteNum) void AdjustActiveRange(PLAYERp pp, short SpriteNum, int dist) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; SPRITEp psp = pp->SpriteP; int look_height; @@ -6589,7 +6584,7 @@ AdjustActiveRange(PLAYERp pp, short SpriteNum, int dist) int StateControl(int16_t SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = &sprite[SpriteNum]; short StateTics; @@ -6694,8 +6689,8 @@ SpriteControl(void) while ((i = it.NextIndex()) >= 0) { #if INLINE_STATE - ASSERT(User[i]); - u = User[i]; + ASSERT(User[i].Data()); + u = User[i].Data(); sp = User[i]->SpriteP; STATE_CONTROL(i, sp, u, StateTics) // ASSERT(it.PeekIndex() >= 0 ? User[it.PeekIndex()] != NULL : true); @@ -6715,11 +6710,11 @@ SpriteControl(void) while ((i = it.NextIndex()) >= 0) { #if INLINE_STATE - ASSERT(User[i]); - u = User[i]; + ASSERT(User[i].Data()); + u = User[i].Data(); sp = User[i]->SpriteP; STATE_CONTROL(i, sp, u, StateTics) - ASSERT(it.PeekIndex() >= 0 ? User[it.PeekIndex()] != NULL : true); + ASSERT(it.PeekIndex() >= 0 ? User[it.PeekIndex()].Data() != NULL : true); #else ASSERT(User[i]); StateControl(i); @@ -6735,12 +6730,11 @@ SpriteControl(void) StatIterator it(STAT_ENEMY); while ((i = it.NextIndex()) >= 0) { - ASSERT(User[i]); + ASSERT(User[i].Data()); - u = User[i]; + u = User[i].Data(); sp = u->SpriteP; - CloseToPlayer = false; ProcessActiveVars(i); @@ -6766,15 +6760,13 @@ SpriteControl(void) if (CloseToPlayer) { #if INLINE_STATE - u = User[i]; + u = User[i].Data(); sp = User[i]->SpriteP; STATE_CONTROL(i, sp, u, StateTics) - ASSERT(it.PeekIndex() >= 0 ? User[it.PeekIndex()] != NULL : true); #else StateControl(i); - ASSERT(it.PeekIndex() >= 0 ? User[it.PeekIndex()] != NULL : true); #endif - ASSERT(it.PeekIndex() >= 0 ? User[it.PeekIndex()] != NULL : true); + ASSERT(it.PeekIndex() >= 0 ? User[it.PeekIndex()].Data() != NULL : true); } else { @@ -6793,15 +6785,15 @@ SpriteControl(void) while ((i = it.NextIndex()) >= 0) { #if INLINE_STATE - ASSERT(User[i]); - u = User[i]; + ASSERT(User[i].Data()); + u = User[i].Data(); sp = User[i]->SpriteP; STATE_CONTROL(i, sp, u, StateTics) - ASSERT(it.PeekIndex() >= 0 ? User[it.PeekIndex()] != NULL : true); + ASSERT(it.PeekIndex() >= 0 ? User[it.PeekIndex()].Data() != NULL : true); #else ASSERT(User[i]); StateControl(i); - ASSERT(it.PeekIndex() >= 0 ? User[it.PeekIndex()] != NULL : true); + ASSERT(it.PeekIndex() >= 0 ? User[it.PeekIndex()].Data() != NULL : true); #endif } } @@ -6810,7 +6802,7 @@ SpriteControl(void) it.Reset(STAT_NO_STATE); while ((i = it.NextIndex()) >= 0) { - if (User[i] && User[i]->ActorActionFunc) + if (User[i].Data() && User[i]->ActorActionFunc) (*User[i]->ActorActionFunc)(i); ASSERT(it.PeekIndex() >= 0 ? sprite[it.PeekIndex()].statnum != MAXSTATUS : true); } @@ -6821,7 +6813,7 @@ SpriteControl(void) while ((i = it.NextIndex()) >= 0) { extern int DoStaticFlamesDamage(short SpriteNum); - ASSERT(User[i]); + ASSERT(User[i].Data()); DoStaticFlamesDamage(i); } } @@ -6831,11 +6823,11 @@ SpriteControl(void) it.Reset(STAT_WALLBLOOD_QUEUE); while ((i = it.NextIndex()) >= 0) { - ASSERT(User[i]); - u = User[i]; + ASSERT(User[i].Data()); + u = User[i].Data(); sp = User[i]->SpriteP; STATE_CONTROL(i, sp, u, StateTics) - ASSERT(it.PeekIndex() >= 0 ? User[it.PeekIndex()] != NULL : true); + ASSERT(it.PeekIndex() >= 0 ? User[it.PeekIndex()].Data() != NULL : true); } } @@ -6845,7 +6837,7 @@ SpriteControl(void) it.Reset(STAT_VATOR); while ((i = it.NextIndex()) >= 0) { - u = User[i]; + u = User[i].Data(); if (u == 0) continue; @@ -6866,7 +6858,7 @@ SpriteControl(void) it.Reset(STAT_SPIKE); while ((i = it.NextIndex()) >= 0) { - u = User[i]; + u = User[i].Data(); if (u->Tics) { @@ -6888,7 +6880,7 @@ SpriteControl(void) it.Reset(STAT_ROTATOR); while ((i = it.NextIndex()) >= 0) { - u = User[i]; + u = User[i].Data(); if (u->Tics) { @@ -6907,7 +6899,7 @@ SpriteControl(void) it.Reset(STAT_SLIDOR); while ((i = it.NextIndex()) >= 0) { - u = User[i]; + u = User[i].Data(); if (u->Tics) { @@ -6949,7 +6941,7 @@ move_sprite(short spritenum, int xchange, int ychange, int zchange, int ceildist int retval=0, zh; short dasectnum, tempshort; SPRITEp spr; - USERp u = User[spritenum]; + USERp u = User[spritenum].Data(); short lastsectnum; spr = &sprite[spritenum]; @@ -7074,7 +7066,7 @@ move_sprite(short spritenum, int xchange, int ychange, int zchange, int ceildist int pushmove_sprite(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); short sectnum, ret; int daz; @@ -7098,7 +7090,7 @@ int pushmove_sprite(short SpriteNum) void MissileWarpUpdatePos(short SpriteNum, short sectnum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; sp->backuppos(); u->oz = sp->oz; @@ -7108,7 +7100,7 @@ void MissileWarpUpdatePos(short SpriteNum, short sectnum) void ActorWarpUpdatePos(short SpriteNum, short sectnum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; sp->backuppos(); u->oz = sp->oz; @@ -7157,7 +7149,7 @@ void ActorWarpType(SPRITEp sp, SPRITEp sp_warp) int MissileWaterAdjust(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (u->lo_sectp) { @@ -7171,7 +7163,7 @@ MissileWaterAdjust(short SpriteNum) int MissileZrange(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; short tempshort; @@ -7197,7 +7189,7 @@ move_missile(short spritenum, int xchange, int ychange, int zchange, int ceildis int retval, zh; short dasectnum, tempshort; SPRITEp sp; - USERp u = User[spritenum]; + USERp u = User[spritenum].Data(); short lastsectnum; sp = &sprite[spritenum]; @@ -7336,7 +7328,7 @@ move_ground_missile(short spritenum, int xchange, int ychange, int ceildist, int int retval=0; short dasectnum; SPRITEp sp; - USERp u = User[spritenum]; + USERp u = User[spritenum].Data(); short lastsectnum; int ox,oy; diff --git a/source/games/sw/src/sumo.cpp b/source/games/sw/src/sumo.cpp index bdcc4e9d3..df5ed88e6 100644 --- a/source/games/sw/src/sumo.cpp +++ b/source/games/sw/src/sumo.cpp @@ -638,12 +638,12 @@ SetupSumo(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,SUMO_RUN_R0,s_SumoRun[0]); + u = SpawnUser(SpriteNum,SUMO_RUN_R0,s_SumoRun[0]); u->Health = 6000; } @@ -680,7 +680,7 @@ SetupSumo(short SpriteNum) int NullSumo(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); //if (TEST(u->Flags,SPR_SLIDING)) //DoActorSlide(SpriteNum); @@ -695,7 +695,7 @@ int NullSumo(short SpriteNum) int DoSumoMove(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); //if (TEST(u->Flags,SPR_SLIDING)) //DoActorSlide(SpriteNum); @@ -719,7 +719,7 @@ int DoSumoMove(short SpriteNum) int InitSumoCharge(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (RANDOM_P2(1024) > 950) PlaySound(DIGI_SUMOALERT, sp, v3df_follow); @@ -737,7 +737,7 @@ int InitSumoCharge(short SpriteNum) int DoSumoRumble(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SetSumoQuake(SpriteNum); @@ -787,7 +787,7 @@ int InitSumoClap(short SpriteNum) int DoSumoDeathMelt(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); PlaySound(DIGI_SUMOFART, sp, v3df_follow); @@ -840,7 +840,7 @@ BossHealthMeter(void) while ((i = it.NextIndex()) >= 0) { sp = &sprite[i]; - u = User[i]; + u = User[i].Data(); if ((u->ID == SERP_RUN_R0 || u->ID == SUMO_RUN_R0 || u->ID == ZILLA_RUN_R0) && sp->pal != 16) { @@ -869,7 +869,7 @@ BossHealthMeter(void) if (BossSpriteNum[i] >= 0) { sp = &sprite[BossSpriteNum[i]]; - u = User[BossSpriteNum[i]]; + u = User[BossSpriteNum[i]].Data(); if (cansee(sp->x, sp->y, SPRITEp_TOS(sp), sp->sectnum, pp->posx, pp->posy, pp->posz - Z(40), pp->cursectnum)) { @@ -914,7 +914,7 @@ BossHealthMeter(void) continue; sp = &sprite[BossSpriteNum[i]]; - u = User[BossSpriteNum[i]]; + u = User[BossSpriteNum[i]].Data(); if (u->ID == SERP_RUN_R0 && serpwasseen) { diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index 8f911fdb8..44d0de861 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -126,7 +126,7 @@ point to the sprite. short ActorFindTrack(short SpriteNum, int8_t player_dir, int track_type, short *track_point_num, short *track_dir) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; int dist, near_dist = 999999, zdiff; @@ -294,7 +294,7 @@ NextTrackPoint(SECTOR_OBJECTp sop) void NextActorTrackPoint(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); u->point += u->track_dir; @@ -732,7 +732,7 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop) bool FoundOutsideLoop = false; bool SectorInBounds; SECTORp *sectp; - USERp u = User[sop->sp_child - sprite]; + USERp u = User[sop->sp_child - sprite].Data(); static unsigned char StatList[] = { @@ -904,10 +904,10 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop) continue; } - if (User[sp_num] == NULL) + if (User[sp_num].Data() == NULL) u = SpawnUser(sp_num, 0, NULL); else - u = User[sp_num]; + u = User[sp_num].Data(); u->RotNum = 0; @@ -1013,7 +1013,7 @@ cont: for (i = 0; sop->sp_num[i] != -1; i++) { sp = &sprite[sop->sp_num[i]]; - u = User[sop->sp_num[i]]; + u = User[sop->sp_num[i]].Data(); if (sp->z > zmid) zmid = sp->z; @@ -1026,7 +1026,7 @@ cont: for (i = 0; sop->sp_num[i] != -1; i++) { sp = &sprite[sop->sp_num[i]]; - u = User[sop->sp_num[i]]; + u = User[sop->sp_num[i]].Data(); u->sz = sop->zmid - sp->z; } @@ -1129,7 +1129,7 @@ SetupSectorObject(short sectnum, short tag) New = SpawnSprite(STAT_SO_SP_CHILD, 0, NULL, sectnum, sop->xmid, sop->ymid, sop->zmid, 0, 0); sop->sp_child = &sprite[New]; - u = User[New]; + u = User[New].Data(); u->sop_parent = sop; SET(u->Flags2, SPR2_SPRITE_FAKE_BLOCK); // for damage test @@ -1560,7 +1560,7 @@ PlaceActorsOnTracks(void) int low_dist = 999999, dist; sp = User[i]->SpriteP; - u = User[i]; + u = User[i].Data(); tag = LOW_TAG_SPRITE(i); @@ -1801,7 +1801,7 @@ PlayerPart: for (i = 0; sop->sp_num[i] != -1; i++) { sp = &sprite[sop->sp_num[i]]; - u = User[sop->sp_num[i]]; + u = User[sop->sp_num[i]].Data(); // if its a player sprite || NOT attached if (!u || u->PlayerP || !TEST(u->Flags, SPR_SO_ATTACHED)) @@ -2032,7 +2032,7 @@ void KillSectorObjectSprites(SECTOR_OBJECTp sop) for (i = 0; sop->sp_num[i] != -1; i++) { sp = &sprite[sop->sp_num[i]]; - u = User[sop->sp_num[i]]; + u = User[sop->sp_num[i]].Data(); // not a part of the so anymore RESET(u->Flags, SPR_SO_ATTACHED); @@ -2316,7 +2316,7 @@ void CallbackSOsink(ANIMp ap, void *data) while ((i = it.NextIndex()) >= 0) { sp = &sprite[i]; - u = User[i]; + u = User[i].Data(); if (!u || u->PlayerP || !TEST(u->Flags, SPR_SO_ATTACHED)) continue; @@ -2833,7 +2833,7 @@ void VehicleSetSmoke(SECTOR_OBJECTp sop, ANIMATORp animator) while ((SpriteNum = it.NextIndex()) >= 0) { sp = &sprite[SpriteNum]; - u = User[SpriteNum]; + u = User[SpriteNum].Data(); switch (sp->hitag) { @@ -2954,7 +2954,7 @@ DoAutoTurretObject(SECTOR_OBJECTp sop) { short SpriteNum = sop->sp_child - sprite; SPRITEp shootp; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); short delta_ang; int diff; short i; @@ -3110,7 +3110,7 @@ DoActorHitTrackEndPoint(USERp u) void ActorLeaveTrack(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (u->track == -1) return; @@ -3134,7 +3134,7 @@ bool ActorTrackDecide(TRACK_POINTp tpoint, short SpriteNum) { SPRITEp sp; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); sp = u->SpriteP; @@ -3682,7 +3682,7 @@ present time. int ActorFollowTrack(short SpriteNum, short locktics) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; PLAYERp pp; diff --git a/source/games/sw/src/vator.cpp b/source/games/sw/src/vator.cpp index a03da8124..e0cfb2eb4 100644 --- a/source/games/sw/src/vator.cpp +++ b/source/games/sw/src/vator.cpp @@ -47,7 +47,7 @@ int InitBloodSpray(short, bool, short); void ReverseVator(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; // if paused go ahead and start it up again @@ -101,7 +101,7 @@ VatorSwitch(short match, short setting) void SetVatorActive(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; SECTORp sectp = §or[sp->sectnum]; @@ -129,7 +129,7 @@ void SetVatorActive(short SpriteNum) void SetVatorInactive(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; SECTORp sectp = §or[sp->sectnum]; @@ -233,7 +233,7 @@ DoVatorMatch(PLAYERp pp, short match) if (SP_TAG1(fsp) == SECT_VATOR && SP_TAG2(fsp) == match) { - fu = User[i]; + fu = User[i].Data(); if (first_vator == -1) first_vator = i; @@ -305,7 +305,7 @@ TestVatorMatchActive(short match) if (SP_TAG1(fsp) == SECT_VATOR && SP_TAG2(fsp) == match) { - fu = User[i]; + fu = User[i].Data(); // Does not have to be inactive to be operated if (TEST_BOOL6(fsp)) @@ -329,7 +329,7 @@ void InterpSectorSprites(short sectnum, bool state) { sp = &sprite[i]; - if (User[i]) + if (User[i].Data()) { if (TEST(User[i]->Flags, SPR_SKIP4) && sp->statnum <= STAT_SKIP4_INTERP_END) continue; @@ -359,7 +359,7 @@ void MoveSpritesWithSector(short sectnum, int z_amt, bool type) { sp = &sprite[i]; - if (User[i]) + if (User[i].Data()) { switch (sp->statnum) { @@ -415,7 +415,7 @@ cont: int DoVatorMove(short SpriteNum, int *lptr) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int zval; int move_amt; @@ -455,7 +455,7 @@ int DoVatorMove(short SpriteNum, int *lptr) int DoVator(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; SECTORp sectp = §or[sp->sectnum]; int *lptr; @@ -550,7 +550,7 @@ int DoVator(short SpriteNum) while ((i = it.NextIndex()) >= 0) { bsp = &sprite[i]; - bu = User[i]; + bu = User[i].Data(); if (bsp->statnum == STAT_ENEMY) { @@ -624,7 +624,7 @@ int DoVator(short SpriteNum) int DoVatorAuto(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; SECTORp sectp = §or[sp->sectnum]; int *lptr; diff --git a/source/games/sw/src/vis.cpp b/source/games/sw/src/vis.cpp index 7055a9e61..179426eb3 100644 --- a/source/games/sw/src/vis.cpp +++ b/source/games/sw/src/vis.cpp @@ -75,7 +75,7 @@ void ProcessVisOn(void) VIS_VisCur(sp) = NormalVisibility; if (sp->owner >= 0) { - ASSERT(User[sp->owner]); + ASSERT(User[sp->owner].Data()); RESET(User[sp->owner]->Flags2, SPR2_VIS_SHADING); } KillSprite(i); @@ -157,7 +157,7 @@ int SpawnVis(short Parent, short sectnum, int x, int y, int z, int amt) sp->owner = Parent; - ASSERT(User[Parent]); + ASSERT(User[Parent].Data()); SET(User[Parent]->Flags2, SPR2_CHILDREN); sp->x = sprite[Parent].x; diff --git a/source/games/sw/src/wallmove.cpp b/source/games/sw/src/wallmove.cpp index c776db66a..7da5ff07b 100644 --- a/source/games/sw/src/wallmove.cpp +++ b/source/games/sw/src/wallmove.cpp @@ -62,7 +62,7 @@ void SOwallmove(SECTOR_OBJECTp sop, SPRITEp sp, WALLp find_wallp, int dist, int { short ang; // move orig x and y in saved angle - ASSERT(User[sp - sprite]); + ASSERT(User[sp - sprite].Data()); ang = User[sp - sprite]->sang; *nx = MulScale(dist, bcos(ang), 14); diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index ff6176255..d294fbb29 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -2650,7 +2650,7 @@ bool MissileHitMatch(short Weapon, short WeaponNum, short hit_sprite) if (WeaponNum <= -1) { ASSERT(Weapon >= 0); - USERp wu = User[Weapon]; + USERp wu = User[Weapon].Data(); WeaponNum = wu->WeaponNum; // can be hit by SO only @@ -2758,7 +2758,7 @@ int SpawnShrapX(short SpriteNum) int DoLavaErupt(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); short i,pnum; PLAYERp pp; SPRITEp tsp; @@ -2875,7 +2875,7 @@ SpawnShrap(short ParentNum, short Secondary) { SPRITEp parent = &sprite[ParentNum]; SPRITEp sp; - USERp u, pu = User[ParentNum]; + USERp u, pu = User[ParentNum].Data(); short SpriteNum; short i; @@ -3236,7 +3236,7 @@ SpawnShrap(short ParentNum, short Secondary) else if (TEST(parent->extra, SPRX_BREAKABLE)) { // if no user - if (!User[parent - sprite]) + if (!User[parent - sprite].Data()) { // Jump to shrap type shrap_type = SP_TAG8(parent); @@ -3733,7 +3733,7 @@ AutoShrap: // most of the time is is the weapon if (Secondary >= 0) { - USERp wu = User[Secondary]; + USERp wu = User[Secondary].Data(); if (wu->PlayerP && wu->PlayerP->sop_control) { @@ -3767,7 +3767,7 @@ AutoShrap: parent->x, parent->y, hz[p->zlevel], shrap_ang, 512); sp = &sprite[SpriteNum]; - u = User[SpriteNum]; + u = User[SpriteNum].Data(); if (p->random_disperse) { @@ -3881,7 +3881,7 @@ AutoShrap: int DoShrapMove(int16_t SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); u->ret = move_missile(SpriteNum, u->xchange, u->ychange, 0, u->ceiling_dist, u->floor_dist, CLIPMASK_MISSILE, MISSILEMOVETICS*2); @@ -3893,7 +3893,7 @@ int DoVomit(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); u->Counter = NORM_ANGLE(u->Counter + (30*MISSILEMOVETICS)); sp->xrepeat = u->sx + MulScale(12, bcos(u->Counter), 14); @@ -3943,7 +3943,7 @@ int DoVomit(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); u->Counter = NORM_ANGLE(u->Counter + (30*MISSILEMOVETICS)); sp->xrepeat = u->sx + MulScale(12, bcos(u->Counter), 14); @@ -3988,7 +3988,7 @@ DoVomit(short SpriteNum) int DoVomitSplash(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if ((u->WaitTics-=MISSILEMOVETICS) < 0) { @@ -4003,7 +4003,7 @@ int DoFastShrapJumpFall(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); sp->x += u->xchange*2; sp->y += u->ychange*2; @@ -4020,7 +4020,7 @@ int DoTracerShrap(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); sp->x += u->xchange; sp->y += u->ychange; @@ -4038,7 +4038,7 @@ DoTracerShrap(short SpriteNum) int DoShrapJumpFall(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags, SPR_JUMPING)) { @@ -4070,7 +4070,7 @@ int DoShrapDamage(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags, SPR_JUMPING)) { @@ -4187,7 +4187,7 @@ SpawnBlood(short SpriteNum, short Weapon, short hit_ang, int hit_x, int hit_y, i short shrap_pal = PALETTE_DEFAULT; short start_ang = 0; - u = User[SpriteNum]; + u = User[SpriteNum].Data(); switch (u->ID) { @@ -4206,7 +4206,7 @@ SpawnBlood(short SpriteNum, short Weapon, short hit_ang, int hit_x, int hit_y, i if (Weapon >= 0) { SPRITEp wp = &sprite[Weapon]; - USERp wu = User[Weapon]; + USERp wu = User[Weapon].Data(); switch (wu->ID) { @@ -4290,7 +4290,7 @@ SpawnBlood(short SpriteNum, short Weapon, short hit_ang, int hit_x, int hit_y, i New = SpawnSprite(STAT_SKIP4, p->id, p->state, sp->sectnum, hit_x, hit_y, hit_z, hit_ang, 0); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); switch (nu->ID) { @@ -4367,7 +4367,7 @@ SpawnBlood(short SpriteNum, short Weapon, short hit_ang, int hit_x, int hit_y, i bool VehicleMoveHit(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp cp; SECTOR_OBJECTp sop; SECTOR_OBJECTp hsop; @@ -4474,7 +4474,7 @@ VehicleMoveHit(short SpriteNum) bool WeaponMoveHit(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; @@ -4571,7 +4571,7 @@ WeaponMoveHit(short SpriteNum) hit_sprite = NORM_SPRITE(u->ret); hsp = &sprite[hit_sprite]; - hu = User[hit_sprite]; + hu = User[hit_sprite].Data(); if (hsp->statnum == STAT_ENEMY) { @@ -4759,7 +4759,7 @@ int DoFireballFlames(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum],ap; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); bool jumping = false; // if no owner then stay where you are @@ -4856,7 +4856,7 @@ int DoBreakFlames(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); bool jumping = false; if (TEST(u->Flags, SPR_JUMPING)) @@ -4932,7 +4932,7 @@ DoBreakFlames(short SpriteNum) int SetSuicide(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (u != nullptr) { @@ -4946,7 +4946,7 @@ SetSuicide(short SpriteNum) int DoActorScale(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = &sprite[SpriteNum]; u->scale_speed = 70; @@ -4965,7 +4965,7 @@ DoActorScale(short SpriteNum) int DoRipperGrow(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = &sprite[SpriteNum]; u->scale_speed = 70; @@ -4986,7 +4986,7 @@ void UpdateSinglePlayKills(short SpriteNum) // single play and coop kill count if (gNet.MultiGameType != MULTI_GAME_COMMBAT) { - ASSERT(User[SpriteNum]); + ASSERT(User[SpriteNum].Data()); if (TEST(User[SpriteNum]->Flags, SPR_SUICIDE)) { @@ -5028,9 +5028,9 @@ int ActorChooseDeath(short SpriteNum, short Weapon) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp wp = &sprite[Weapon]; - USERp wu = User[Weapon]; + USERp wu = User[Weapon].Data(); ASSERT(u); @@ -5309,7 +5309,7 @@ int ActorHealth(short SpriteNum, short amt) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); extern int FinishAnim; if (u->ID == TRASHCAN && amt > -75) @@ -5411,7 +5411,7 @@ int SopDamage(SECTOR_OBJECTp sop, short amt) { SPRITEp sp = sop->sp_child; - USERp u = User[sp - sprite]; + USERp u = User[sp - sprite].Data(); // does not have damage if (sop->max_damage == -9999) @@ -5455,7 +5455,7 @@ SopCheckKill(SECTOR_OBJECTp sop) int ActorPain(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); //if (u->LastDamage < u->PainThreshold) // This doesn't work well at all because of // uzi/shotgun damages @@ -5491,7 +5491,7 @@ ActorPain(short SpriteNum) int ActorPainPlasma(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (!TEST(u->Flags, SPR_JUMPING | SPR_FALLING | SPR_ELECTRO_TOLERANT)) { @@ -5515,9 +5515,9 @@ int ActorStdMissile(short SpriteNum, short Weapon) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp wp = &sprite[Weapon]; - USERp wu = User[Weapon]; + USERp wu = User[Weapon].Data(); ASSERT(Weapon >= 0); @@ -5538,7 +5538,7 @@ ActorStdMissile(short SpriteNum, short Weapon) { // attempt to see if it was killed ASSERT(sprite[wu->WpnGoal].sectnum >= 0); - ASSERT(User[Weapon]); + ASSERT(User[Weapon].Data()); // what if the target has been killed? This will crash! RESET(User[wu->WpnGoal]->Flags, SPR_TARGETED); } @@ -5548,7 +5548,7 @@ ActorStdMissile(short SpriteNum, short Weapon) int ActorDamageSlide(short SpriteNum, short damage, short ang) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int slide_vel,slide_dec; if (TEST(u->Flags, SPR_CLIMBING)) @@ -5679,7 +5679,7 @@ RadiusGetDamage(short SpriteNum, short Weapon, int max_damage) { SPRITEp sp = &sprite[SpriteNum]; SPRITEp wp = &sprite[Weapon]; - USERp wu = User[Weapon]; + USERp wu = User[Weapon].Data(); int dist,a,b,c; int damage_per_pixel, damage_force, damage_amt; @@ -5717,7 +5717,7 @@ int PlayerCheckDeath(PLAYERp pp, short Weapon) { SPRITEp sp = pp->SpriteP; - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); int SpawnZombie(PLAYERp pp, short); @@ -5743,7 +5743,7 @@ PlayerCheckDeath(PLAYERp pp, short Weapon) } SPRITEp wp = &sprite[Weapon]; - USERp wu = User[Weapon]; + USERp wu = User[Weapon].Data(); if (Weapon > -1 && (wu->ID == RIPPER_RUN_R0 || wu->ID == RIPPER2_RUN_R0)) pp->DeathType = PLAYER_DEATH_RIPPER; @@ -5788,9 +5788,9 @@ PlayerTakeDamage(PLAYERp pp, short Weapon) if (Weapon < 0) return true; - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); SPRITEp wp = &sprite[Weapon]; - USERp wu = User[Weapon]; + USERp wu = User[Weapon].Data(); if (gNet.MultiGameType == MULTI_GAME_NONE) { @@ -5816,7 +5816,7 @@ PlayerTakeDamage(PLAYERp pp, short Weapon) return true; // if the weapons owner is YOURSELF take damage - if (wp->owner >= 0 && User[wp->owner] && User[wp->owner]->PlayerP && User[wp->owner]->PlayerP == pp) + if (wp->owner >= 0 && User[wp->owner].Data() && User[wp->owner]->PlayerP && User[wp->owner]->PlayerP == pp) return true; // if weapon IS the player no damage @@ -5824,7 +5824,7 @@ PlayerTakeDamage(PLAYERp pp, short Weapon) return false; // if the weapons owner is a player - if (wp->owner >= 0 && User[wp->owner] && User[wp->owner]->PlayerP) + if (wp->owner >= 0 && User[wp->owner].Data() && User[wp->owner]->PlayerP) return false; } else if (gNet.MultiGameType == MULTI_GAME_COMMBAT && gNet.TeamPlay) @@ -5838,7 +5838,7 @@ PlayerTakeDamage(PLAYERp pp, short Weapon) return true; // if the weapons owner is YOURSELF take damage - if (wp->owner >= 0 && User[wp->owner] && User[wp->owner]->PlayerP && User[wp->owner]->PlayerP == pp) + if (wp->owner >= 0 && User[wp->owner].Data() && User[wp->owner]->PlayerP && User[wp->owner]->PlayerP == pp) return true; if (wu->PlayerP) @@ -5849,7 +5849,7 @@ PlayerTakeDamage(PLAYERp pp, short Weapon) } // if the weapons owner is a player - if (wp->owner >= 0 && User[wp->owner] && User[wp->owner]->PlayerP) + if (wp->owner >= 0 && User[wp->owner].Data() && User[wp->owner]->PlayerP) { // if both on the same team then no damage if (User[wp->owner]->spal == u->spal) @@ -5864,7 +5864,7 @@ PlayerTakeDamage(PLAYERp pp, short Weapon) int StarBlood(short SpriteNum, short Weapon) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); short blood_num = 1; short i; @@ -5888,7 +5888,7 @@ int DoDamage(short SpriteNum, short Weapon) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp wp; USERp wu; int damage=0; @@ -5906,7 +5906,7 @@ DoDamage(short SpriteNum, short Weapon) return 0; wp = &sprite[Weapon]; - wu = User[Weapon]; + wu = User[Weapon].Data(); ASSERT(wu); @@ -6681,7 +6681,7 @@ DoDamage(short SpriteNum, short Weapon) { // this is special code to prevent the Zombie from taking out the Bosses to quick // if rail gun weapon owner is not player - if (wp->owner >= 0 && User[wp->owner] && !User[wp->owner]->PlayerP) + if (wp->owner >= 0 && User[wp->owner].Data() && !User[wp->owner]->PlayerP) { // if actor is a boss if (u->ID == ZILLA_RUN_R0 || u->ID == SERP_RUN_R0 || u->ID == SUMO_RUN_R0) @@ -6920,7 +6920,7 @@ DoDamage(short SpriteNum, short Weapon) else { // Don't let it hurt the SUMO - if (wp->owner >=0 && User[wp->owner] && User[wp->owner]->ID == SUMO_RUN_R0) break; // JBF: added sanity check for wp->owner and User[wp->owner] + if (wp->owner >=0 && User[wp->owner].Data() && User[wp->owner]->ID == SUMO_RUN_R0) break; // JBF: added sanity check for wp->owner and User[wp->owner] ActorHealth(SpriteNum, damage); ActorPain(SpriteNum); ActorDamageSlide(SpriteNum, damage, ANG2SPRITE(sp, wp)); @@ -6964,7 +6964,7 @@ DoDamage(short SpriteNum, short Weapon) case MINE_EXP: damage = GetDamage(SpriteNum, Weapon, DMG_MINE_EXP); - if (wp->owner >= 0 && User[wp->owner] && User[wp->owner]->ID == SERP_RUN_R0) + if (wp->owner >= 0 && User[wp->owner].Data() && User[wp->owner]->ID == SERP_RUN_R0) { damage /= 6; } @@ -7044,7 +7044,7 @@ DoDamage(short SpriteNum, short Weapon) damage = GetDamage(SpriteNum, Weapon, DMG_NAPALM_EXP); // Sumo Nap does less - if (wp->owner >= 0 && User[wp->owner] && User[wp->owner]->ID == SUMO_RUN_R0) + if (wp->owner >= 0 && User[wp->owner].Data() && User[wp->owner]->ID == SUMO_RUN_R0) damage /= 4; if (u->sop_parent) @@ -7412,7 +7412,7 @@ DoDamage(short SpriteNum, short Weapon) // Select death text based on ID const char *DeathString(short SpriteNum) { - USERp ku = User[SpriteNum]; + USERp ku = User[SpriteNum].Data(); switch (ku->ID) { @@ -7516,7 +7516,7 @@ int DoDamageTest(short Weapon) { SPRITEp wp = &sprite[Weapon]; - USERp wu = User[Weapon]; + USERp wu = User[Weapon].Data(); USERp u; SPRITEp sp; @@ -7531,7 +7531,7 @@ DoDamageTest(short Weapon) while ((i = it.NextIndex()) >= 0) { sp = &sprite[i]; - u = User[i]; + u = User[i].Data(); DISTANCE(sp->x, sp->y, wp->x, wp->y, dist, tx, ty, tmin); @@ -7588,7 +7588,7 @@ int DoFlamesDamageTest(short Weapon) { SPRITEp wp = &sprite[Weapon]; - USERp wu = User[Weapon]; + USERp wu = User[Weapon].Data(); USERp u; SPRITEp sp; @@ -7603,7 +7603,7 @@ DoFlamesDamageTest(short Weapon) while ((i = it.NextIndex()) >= 0) { sp = &sprite[i]; - u = User[i]; + u = User[i].Data(); switch (u->ID) { @@ -7762,7 +7762,7 @@ void TraverseBreakableWalls(short start_sect, int x, int y, int z, short ang, in int DoExpDamageTest(short Weapon) { SPRITEp wp = &sprite[Weapon]; - USERp wu = User[Weapon]; + USERp wu = User[Weapon].Data(); USERp u; SPRITEp sp; @@ -7793,7 +7793,7 @@ int DoExpDamageTest(short Weapon) while ((i = it.NextIndex()) >= 0) { sp = &sprite[i]; - u = User[i]; + u = User[i].Data(); DISTANCE(sp->x, sp->y, wp->x, wp->y, dist, tx, ty, tmin); @@ -7841,7 +7841,7 @@ int DoExpDamageTest(short Weapon) while ((i = it.NextIndex()) >= 0) { sp = &sprite[i]; - u = User[i]; + u = User[i].Data(); DISTANCE(sp->x, sp->y, wp->x, wp->y, dist, tx, ty, tmin); if ((unsigned)dist > wu->Radius) @@ -7915,7 +7915,7 @@ int DoExpDamageTest(short Weapon) int DoMineExpMine(short Weapon) { SPRITEp wp = &sprite[Weapon]; - USERp wu = User[Weapon]; + USERp wu = User[Weapon].Data(); USERp u; SPRITEp sp; @@ -7928,7 +7928,7 @@ int DoMineExpMine(short Weapon) while ((i = it.NextIndex()) >= 0) { sp = &sprite[i]; - u = User[i]; + u = User[i].Data(); DISTANCE(sp->x, sp->y, wp->x, wp->y, dist, tx, ty, tmin); if ((unsigned)dist > wu->Radius + u->Radius) @@ -7959,7 +7959,7 @@ int DoStar(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); USERp su; int vel; @@ -8162,7 +8162,7 @@ DoStar(int16_t Weapon) short hit_sprite = NORM_SPRITE(u->ret); if (hit_sprite != -1) { - su = User[hit_sprite]; + su = User[hit_sprite].Data(); if (su && (su->ID == TRASHCAN || su->ID == ZILLA_RUN_R0)) // JBF: added null test PlaySound(DIGI_STARCLINK, sp, v3df_none); } @@ -8185,9 +8185,9 @@ DoStar(int16_t Weapon) int DoCrossBolt(int16_t Weapon) { - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); - u = User[Weapon]; + u = User[Weapon].Data(); ASSERT(Weapon >= 0); @@ -8224,7 +8224,7 @@ int DoPlasmaDone(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); sp->xrepeat += u->Counter; sp->yrepeat -= 4; @@ -8263,7 +8263,7 @@ int MissileSeek(int16_t Weapon, int16_t delay_tics, int16_t aware_range/*, int16_t dang_shift, int16_t turn_limit, int16_t z_limit*/) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); int zh; short ang2tgt, delta_ang; @@ -8283,7 +8283,7 @@ MissileSeek(int16_t Weapon, int16_t delay_tics, int16_t aware_range/*, int16_t d { if ((hit_sprite = PickEnemyTarget(sp, aware_range)) != -1) { - USERp hu = User[hit_sprite]; + USERp hu = User[hit_sprite].Data(); u->WpnGoal = hit_sprite; SET(hu->Flags, SPR_TARGETED); @@ -8292,7 +8292,7 @@ MissileSeek(int16_t Weapon, int16_t delay_tics, int16_t aware_range/*, int16_t d } else if ((hit_sprite = DoPickTarget(sp, aware_range, false)) != -1) { - USERp hu = User[hit_sprite]; + USERp hu = User[hit_sprite].Data(); u->WpnGoal = hit_sprite; SET(hu->Flags, SPR_TARGETED); @@ -8346,7 +8346,7 @@ int ComboMissileSeek(int16_t Weapon, int16_t delay_tics, int16_t aware_range/*, int16_t dang_shift, int16_t turn_limit, int16_t z_limit*/) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); int dist; int zh; @@ -8365,7 +8365,7 @@ ComboMissileSeek(int16_t Weapon, int16_t delay_tics, int16_t aware_range/*, int1 if ((hit_sprite = DoPickTarget(sp, aware_range, false)) != -1) { - USERp hu = User[hit_sprite]; + USERp hu = User[hit_sprite].Data(); u->WpnGoal = hit_sprite; SET(hu->Flags, SPR_TARGETED); @@ -8414,7 +8414,7 @@ int VectorMissileSeek(int16_t Weapon, int16_t delay_tics, int16_t turn_speed, int16_t aware_range1, int16_t aware_range2) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); int dist; int zh; @@ -8434,7 +8434,7 @@ VectorMissileSeek(int16_t Weapon, int16_t delay_tics, int16_t turn_speed, int16_ { if ((hit_sprite = PickEnemyTarget(sp, aware_range1)) != -1) { - USERp hu = User[hit_sprite]; + USERp hu = User[hit_sprite].Data(); u->WpnGoal = hit_sprite; SET(hu->Flags, SPR_TARGETED); @@ -8442,7 +8442,7 @@ VectorMissileSeek(int16_t Weapon, int16_t delay_tics, int16_t turn_speed, int16_ } else if ((hit_sprite = PickEnemyTarget(sp, aware_range2)) != -1) { - USERp hu = User[hit_sprite]; + USERp hu = User[hit_sprite].Data(); u->WpnGoal = hit_sprite; SET(hu->Flags, SPR_TARGETED); @@ -8453,7 +8453,7 @@ VectorMissileSeek(int16_t Weapon, int16_t delay_tics, int16_t turn_speed, int16_ { if ((hit_sprite = DoPickTarget(sp, aware_range1, false)) != -1) { - USERp hu = User[hit_sprite]; + USERp hu = User[hit_sprite].Data(); u->WpnGoal = hit_sprite; SET(hu->Flags, SPR_TARGETED); @@ -8461,7 +8461,7 @@ VectorMissileSeek(int16_t Weapon, int16_t delay_tics, int16_t turn_speed, int16_ } else if ((hit_sprite = DoPickTarget(sp, aware_range2, false)) != -1) { - USERp hu = User[hit_sprite]; + USERp hu = User[hit_sprite].Data(); u->WpnGoal = hit_sprite; SET(hu->Flags, SPR_TARGETED); @@ -8507,7 +8507,7 @@ int VectorWormSeek(int16_t Weapon, int16_t delay_tics, int16_t aware_range1, int16_t aware_range2) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); int dist; int zh; @@ -8525,7 +8525,7 @@ VectorWormSeek(int16_t Weapon, int16_t delay_tics, int16_t aware_range1, int16_t if ((hit_sprite = DoPickTarget(sp, aware_range1, false)) != -1) { - USERp hu = User[hit_sprite]; + USERp hu = User[hit_sprite].Data(); u->WpnGoal = hit_sprite; SET(hu->Flags, SPR_TARGETED); @@ -8533,7 +8533,7 @@ VectorWormSeek(int16_t Weapon, int16_t delay_tics, int16_t aware_range1, int16_t } else if ((hit_sprite = DoPickTarget(sp, aware_range2, false)) != -1) { - USERp hu = User[hit_sprite]; + USERp hu = User[hit_sprite].Data(); u->WpnGoal = hit_sprite; SET(hu->Flags, SPR_TARGETED); @@ -8572,7 +8572,7 @@ VectorWormSeek(int16_t Weapon, int16_t delay_tics, int16_t aware_range1, int16_t int DoBlurExtend(int16_t Weapon, int16_t interval, int16_t blur_num) { - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); if (u->motion_blur_num >= blur_num) return 0; @@ -8602,7 +8602,7 @@ InitPlasmaFountain(SPRITEp wp, SPRITEp sp) sp->x, sp->y, SPRITEp_BOS(sp), sp->ang, 0); np = &sprite[SpriteNum]; - nu = User[SpriteNum]; + nu = User[SpriteNum].Data(); np->shade = -40; if (wp) @@ -8623,7 +8623,7 @@ DoPlasmaFountain(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; SPRITEp ap; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); short bak_cstat; // if no owner then die @@ -8671,7 +8671,7 @@ int DoPlasma(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); int32_t dax, day, daz; int ox,oy,oz; @@ -8697,7 +8697,7 @@ DoPlasma(int16_t Weapon) { short hit_sprite = NORM_SPRITE(u->ret); SPRITEp hsp = &sprite[hit_sprite]; - USERp hu = User[hit_sprite]; + USERp hu = User[hit_sprite].Data(); if (TEST(hsp->cstat, CSTAT_SPRITE_BLOCK) && !TEST(hsp->cstat, CSTAT_SPRITE_ALIGNMENT_WALL)) { @@ -8750,7 +8750,7 @@ int DoCoolgFire(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); u->ret = move_missile(Weapon, u->xchange, u->ychange, u->zchange, u->ceiling_dist, u->floor_dist, CLIPMASK_MISSILE, MISSILEMOVETICS); @@ -8767,7 +8767,7 @@ DoCoolgFire(int16_t Weapon) { PlaySound(DIGI_CGMAGICHIT, sp, v3df_follow); ChangeState(Weapon, s_CoolgFireDone); - if (sp->owner >= 0 && User[sp->owner] && User[sp->owner]->ID != RIPPER_RUN_R0) // JBF: added range check + if (sp->owner >= 0 && User[sp->owner].Data() && User[sp->owner]->ID != RIPPER_RUN_R0) // JBF: added range check SpawnDemonFist(Weapon); // Just a red magic circle flash return true; } @@ -8779,7 +8779,7 @@ DoCoolgFire(int16_t Weapon) int DoEelFire(short Weapon) { - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); if (TEST(u->Flags, SPR_UNDERWATER) && (RANDOM_P2(1024 << 4) >> 4) < 256) SpawnBubble(Weapon); @@ -8792,7 +8792,7 @@ DoEelFire(short Weapon) void ScaleSpriteVector(short SpriteNum, int scale) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); u->xchange = MulScale(u->xchange, scale, 16); u->ychange = MulScale(u->ychange, scale, 16); @@ -8801,7 +8801,7 @@ void ScaleSpriteVector(short SpriteNum, int scale) void WallBounce(short SpriteNum, short ang) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; int old_ang; //short hit_wall; @@ -8844,7 +8844,7 @@ void WallBounce(short SpriteNum, short ang) bool SlopeBounce(short SpriteNum, bool *hit_wall) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; int k,l; int hiz,loz; @@ -8918,7 +8918,7 @@ int DoGrenade(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); short i; if (TEST(u->Flags, SPR_UNDERWATER)) @@ -9138,7 +9138,7 @@ DoGrenade(int16_t Weapon) sp->x, sp->y, sp->z, sp->ang, 100); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); SetOwner(Weapon, New); np->shade = -40; @@ -9165,7 +9165,7 @@ int DoVulcanBoulder(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); u->Counter += 40; u->zchange += u->Counter; @@ -9320,10 +9320,10 @@ bool OwnerIsPlayer(short Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon],uo; + USERp u = User[Weapon].Data(),uo; if (!u || !sp || (unsigned)sp->owner >= (unsigned)MAXSPRITES) return false; - uo = User[sp->owner]; + uo = User[sp->owner].Data(); if (uo && uo->PlayerP) return true; return false; @@ -9350,7 +9350,7 @@ DoMineRangeTest(short Weapon, short range) while ((i = it.NextIndex()) >= 0) { sp = &sprite[i]; - u = User[i]; + u = User[i].Data(); // don't detect the owner or the owners bottom half //if (wp->owner == i || (u->PlayerP && (wp->owner == u->PlayerP->PlayerSprite))) @@ -9391,14 +9391,14 @@ int DoMineStuck(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); #define MINE_DETONATE_STATE 99 // if no owner then die if (u->Attach >= 0) { SPRITEp ap = &sprite[u->Attach]; - USERp au = User[u->Attach]; + USERp au = User[u->Attach].Data(); ASSERT(au); @@ -9554,7 +9554,7 @@ int SetMineStuck(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); // stuck SET(u->Flags, SPR_BOUNCE); @@ -9573,7 +9573,7 @@ int DoMine(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); if (TEST(u->Flags, SPR_UNDERWATER)) { @@ -9610,7 +9610,7 @@ DoMine(int16_t Weapon) { short hit_sprite = NORM_SPRITE(u->ret); SPRITEp hsp = &sprite[hit_sprite]; - USERp hu = User[hit_sprite]; + USERp hu = User[hit_sprite].Data(); SetMineStuck(Weapon); // Set the Z position @@ -9631,7 +9631,7 @@ DoMine(int16_t Weapon) if (sp->owner >= 0) { - uo = User[sp->owner]; + uo = User[sp->owner].Data(); if (uo && uo->PlayerP) { @@ -9736,7 +9736,7 @@ int DoPuff(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); sp->x += u->xchange; sp->y += u->ychange; @@ -9760,7 +9760,7 @@ int DoBoltThinMan(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); int32_t dax, day, daz; DoBlurExtend(Weapon, 0, 4); @@ -9799,7 +9799,7 @@ int DoTracer(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); short i; for (i = 0; i < 4; i++) @@ -9827,7 +9827,7 @@ int DoEMP(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); short i; for (i = 0; i < 4; i++) @@ -9866,12 +9866,12 @@ int DoEMPBurst(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); if (u->Attach >= 0) { SPRITEp ap = &sprite[u->Attach]; - USERp au = User[u->Attach]; + USERp au = User[u->Attach].Data(); ASSERT(au); @@ -9919,7 +9919,7 @@ DoEMPBurst(int16_t Weapon) int DoTankShell(int16_t Weapon) { - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); short i; for (i = 0; i < 4; i++) @@ -9946,7 +9946,7 @@ DoTankShell(int16_t Weapon) int DoTracerStart(int16_t Weapon) { - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); u->ret = move_missile(Weapon, u->xchange, u->ychange, u->zchange, u->ceiling_dist, u->floor_dist, CLIPMASK_MISSILE, MISSILEMOVETICS); @@ -9969,7 +9969,7 @@ int DoLaser(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); SPRITEp np; USERp nu; short New; @@ -9999,7 +9999,7 @@ DoLaser(int16_t Weapon) New = SpawnSprite(STAT_MISSILE, PUFF, s_LaserPuff, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); np->shade = -40; np->xrepeat = 16; @@ -10017,7 +10017,7 @@ DoLaser(int16_t Weapon) int DoLaserStart(int16_t Weapon) { - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); if (SW_SHAREWARE) return false; // JBF: verify @@ -10042,7 +10042,7 @@ int DoRail(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); SPRITEp np; USERp nu; short New; @@ -10099,7 +10099,7 @@ DoRail(int16_t Weapon) sp->x, sp->y, sp->z, sp->ang, 20); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); np->xvel += (RANDOM_RANGE(140)-RANDOM_RANGE(140)); np->yvel += (RANDOM_RANGE(140)-RANDOM_RANGE(140)); @@ -10130,7 +10130,7 @@ DoRail(int16_t Weapon) int DoRailStart(int16_t Weapon) { - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); if (SW_SHAREWARE) return false; // JBF: verify @@ -10156,7 +10156,7 @@ int DoRocket(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); int dist,a,b,c; auto pos = sp->pos; @@ -10215,7 +10215,7 @@ DoRocket(int16_t Weapon) pos.x, pos.y, pos.z, sp->ang, 100); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); SetOwner(Weapon, New); np->shade = -40; @@ -10243,7 +10243,7 @@ DoRocket(int16_t Weapon) int DoMicroMini(int16_t Weapon) { - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); short i; for (i = 0; i < 3; i++) @@ -10270,7 +10270,7 @@ int SpawnExtraMicroMini(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); SPRITEp wp; USERp wu; short w; @@ -10279,7 +10279,7 @@ SpawnExtraMicroMini(int16_t Weapon) sp->x, sp->y, sp->z, sp->ang, sp->xvel); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); SetOwner(sp->owner, w); wp->yrepeat = wp->xrepeat = sp->xrepeat; @@ -10309,7 +10309,7 @@ int DoMicro(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); short New; if (SW_SHAREWARE) return false; // JBF: verify @@ -10333,7 +10333,7 @@ DoMicro(int16_t Weapon) sp->x, sp->y, sp->z, sp->ang, 100); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); SetOwner(sp->owner, New); np->shade = -40; @@ -10384,7 +10384,7 @@ int DoUziBullet(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); int32_t dax, day, daz; int sx,sy; short i; @@ -10456,7 +10456,7 @@ int DoBoltSeeker(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); int32_t dax, day, daz; MissileSeek(Weapon, 30, 768/*, 4, 48, 6*/); @@ -10503,7 +10503,7 @@ int DoElectro(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); int32_t dax, day, daz; DoBlurExtend(Weapon, 0, 4); @@ -10535,7 +10535,7 @@ DoElectro(int16_t Weapon) case HIT_SPRITE: { SPRITEp hsp = &sprite[NORM_SPRITE(u->ret)]; - USERp hu = User[NORM_SPRITE(u->ret)]; + USERp hu = User[NORM_SPRITE(u->ret)].Data(); if (!TEST(hsp->extra, SPRX_PLAYER_OR_ENEMY) || hu->ID == SKULL_R0 || hu->ID == BETTY_R0) SpawnShrap(Weapon, -1); @@ -10559,7 +10559,7 @@ DoElectro(int16_t Weapon) int DoLavaBoulder(int16_t Weapon) { - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); u->ret = move_missile(Weapon, u->xchange, u->ychange, u->zchange, u->ceiling_dist, u->floor_dist, CLIPMASK_MISSILE, MISSILEMOVETICS); @@ -10588,7 +10588,7 @@ DoLavaBoulder(int16_t Weapon) int DoSpear(int16_t Weapon) { - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); u->ret = move_missile(Weapon, u->xchange, u->ychange, u->zchange, u->ceiling_dist, u->floor_dist, CLIPMASK_MISSILE, MISSILEMOVETICS); @@ -10618,7 +10618,7 @@ DoSpear(int16_t Weapon) int SpawnCoolieExp(short SpriteNum) { - USERp u = User[SpriteNum], eu; + USERp u = User[SpriteNum].Data(), eu; SPRITEp sp = &sprite[SpriteNum]; short explosion; @@ -10638,7 +10638,7 @@ int SpawnCoolieExp(short SpriteNum) explosion = SpawnSprite(STAT_MISSILE, BOLT_EXP, s_BoltExp, sp->sectnum, nx, ny, zh, sp->ang, 0); exp = &sprite[explosion]; - eu = User[explosion]; + eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness SetOwner(SpriteNum, explosion); @@ -10659,7 +10659,7 @@ int SpawnBasicExp(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); SPRITEp exp; USERp eu; short explosion; @@ -10674,7 +10674,7 @@ SpawnBasicExp(int16_t Weapon) explosion = SpawnSprite(STAT_MISSILE, BASIC_EXP, s_BasicExp, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0); exp = &sprite[explosion]; - eu = User[explosion]; + eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness exp->xrepeat = 24; @@ -10702,7 +10702,7 @@ int SpawnFireballFlames(int16_t SpriteNum, int16_t enemy) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp ep; USERp eu; SPRITEp np; @@ -10715,7 +10715,7 @@ SpawnFireballFlames(int16_t SpriteNum, int16_t enemy) if (enemy >= 0) { ep = &sprite[enemy]; - eu = User[enemy]; + eu = User[enemy].Data(); // test for already burned if (TEST(ep->extra, SPRX_BURNABLE) && ep->shade > 40) @@ -10730,7 +10730,7 @@ SpawnFireballFlames(int16_t SpriteNum, int16_t enemy) { int sizez = SPRITEp_SIZE_Z(ep) + DIV4(SPRITEp_SIZE_Z(ep)); np = &sprite[eu->flame]; - nu = User[eu->flame]; + nu = User[eu->flame].Data(); if (TEST(ep->extra, SPRX_BURNABLE)) return eu->flame; @@ -10771,7 +10771,7 @@ SpawnFireballFlames(int16_t SpriteNum, int16_t enemy) New = SpawnSprite(STAT_MISSILE, FIREBALL_FLAMES, s_FireballFlames, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); np->hitag = LUMINOUS; //Always full brightness @@ -10837,7 +10837,7 @@ int SpawnBreakFlames(int16_t SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp np; USERp nu; short New; @@ -10845,7 +10845,7 @@ SpawnBreakFlames(int16_t SpriteNum) New = SpawnSprite(STAT_MISSILE, FIREBALL_FLAMES+1, s_BreakFlames, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); np->hitag = LUMINOUS; //Always full brightness @@ -10879,7 +10879,7 @@ int SpawnBreakStaticFlames(int16_t SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp np; USERp nu; short New; @@ -10887,7 +10887,7 @@ SpawnBreakStaticFlames(int16_t SpriteNum) New = SpawnSprite(STAT_STATIC_FIRE, FIREBALL_FLAMES, NULL, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); if (RANDOM_RANGE(1000) > 500) np->picnum = 3143; @@ -10929,7 +10929,7 @@ int SpawnFireballExp(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); SPRITEp exp; USERp eu; short explosion; @@ -10944,7 +10944,7 @@ SpawnFireballExp(int16_t Weapon) explosion = SpawnSprite(STAT_MISSILE, FIREBALL_EXP, s_FireballExp, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0); exp = &sprite[explosion]; - eu = User[explosion]; + eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness exp->xrepeat = 52; @@ -10972,7 +10972,7 @@ int SpawnGoroFireballExp(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); SPRITEp exp; USERp eu; short explosion; @@ -10987,7 +10987,7 @@ SpawnGoroFireballExp(int16_t Weapon) explosion = SpawnSprite(STAT_MISSILE, 0, s_FireballExp, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0); exp = &sprite[explosion]; - eu = User[explosion]; + eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness exp->xrepeat = 16; @@ -11011,7 +11011,7 @@ int SpawnBoltExp(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); SPRITEp exp; USERp eu; short explosion; @@ -11026,7 +11026,7 @@ SpawnBoltExp(int16_t Weapon) explosion = SpawnSprite(STAT_MISSILE, BOLT_EXP, s_BoltExp, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0); exp = &sprite[explosion]; - eu = User[explosion]; + eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness SetOwner(sp->owner, explosion); @@ -11053,7 +11053,7 @@ int SpawnBunnyExp(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); ASSERT(u); @@ -11075,7 +11075,7 @@ int SpawnTankShellExp(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); SPRITEp exp; USERp eu; short explosion; @@ -11090,7 +11090,7 @@ SpawnTankShellExp(int16_t Weapon) explosion = SpawnSprite(STAT_MISSILE, TANK_SHELL_EXP, s_TankShellExp, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0); exp = &sprite[explosion]; - eu = User[explosion]; + eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness SetOwner(sp->owner, explosion); @@ -11115,7 +11115,7 @@ int SpawnNuclearSecondaryExp(int16_t Weapon, short ang) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); SPRITEp exp; USERp eu; short explosion; @@ -11125,7 +11125,7 @@ SpawnNuclearSecondaryExp(int16_t Weapon, short ang) explosion = SpawnSprite(STAT_MISSILE, GRENADE_EXP, s_GrenadeExp, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 512); exp = &sprite[explosion]; - eu = User[explosion]; + eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness SetOwner(sp->owner, explosion); @@ -11163,7 +11163,7 @@ int SpawnNuclearExp(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); SPRITEp exp; USERp eu; short explosion,ang=0; @@ -11193,7 +11193,7 @@ SpawnNuclearExp(int16_t Weapon) explosion = SpawnSprite(STAT_MISSILE, MUSHROOM_CLOUD, s_NukeMushroom, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0); exp = &sprite[explosion]; - eu = User[explosion]; + eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness SetOwner(sp->owner, explosion); @@ -11212,7 +11212,7 @@ SpawnNuclearExp(int16_t Weapon) explosion = SpawnSprite(STAT_MISSILE, MUSHROOM_CLOUD, s_GrenadeExp, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0); exp = &sprite[explosion]; - eu = User[explosion]; + eu = User[explosion].Data(); SetOwner(sp->owner, explosion); exp->shade = -128; @@ -11257,7 +11257,7 @@ int SpawnTracerExp(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); SPRITEp exp; USERp eu; short explosion; @@ -11274,7 +11274,7 @@ SpawnTracerExp(int16_t Weapon) sp->x, sp->y, sp->z, sp->ang, 0); exp = &sprite[explosion]; - eu = User[explosion]; + eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness SetOwner(sp->owner, explosion); @@ -11303,7 +11303,7 @@ int SpawnMicroExp(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); SPRITEp exp; USERp eu; short explosion; @@ -11317,7 +11317,7 @@ SpawnMicroExp(int16_t Weapon) explosion = SpawnSprite(STAT_MISSILE, MICRO_EXP, s_MicroExp, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0); exp = &sprite[explosion]; - eu = User[explosion]; + eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness SetOwner(sp->owner, explosion); @@ -11347,7 +11347,7 @@ int AddSpriteToSectorObject(short SpriteNum, SECTOR_OBJECTp sop) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); unsigned sn; // make sure it has a user @@ -11395,12 +11395,12 @@ SpawnBigGunFlames(int16_t Weapon, int16_t Operator, SECTOR_OBJECTp sop) } sp = &sprite[Weapon]; - u = User[Weapon]; + u = User[Weapon].Data(); explosion = SpawnSprite(STAT_MISSILE, MICRO_EXP, s_BigGunFlame, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0); exp = &sprite[explosion]; - eu = User[explosion]; + eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness SetOwner(Operator, explosion); @@ -11460,7 +11460,7 @@ int SpawnGrenadeSecondaryExp(int16_t Weapon, short ang) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); SPRITEp exp; USERp eu; short explosion; @@ -11471,7 +11471,7 @@ SpawnGrenadeSecondaryExp(int16_t Weapon, short ang) explosion = SpawnSprite(STAT_MISSILE, GRENADE_EXP, s_GrenadeSmallExp, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 1024); exp = &sprite[explosion]; - eu = User[explosion]; + eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness SetOwner(sp->owner, explosion); @@ -11519,7 +11519,7 @@ int SpawnGrenadeExp(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); SPRITEp exp; USERp eu; short explosion; @@ -11533,7 +11533,7 @@ SpawnGrenadeExp(int16_t Weapon) if (RANDOM_RANGE(1000) > 990) { - if (sp->owner >= 0 && User[sp->owner] && User[sp->owner]->PlayerP) + if (sp->owner >= 0 && User[sp->owner].Data() && User[sp->owner]->PlayerP) { PLAYERp pp = User[sp->owner]->PlayerP; PlayerSound(DIGI_LIKEFIREWORKS, v3df_follow|v3df_dontpan,pp); @@ -11554,7 +11554,7 @@ SpawnGrenadeExp(int16_t Weapon) explosion = SpawnSprite(STAT_MISSILE, GRENADE_EXP, s_GrenadeExp, sp->sectnum, dx, dy, dz, sp->ang, 0); exp = &sprite[explosion]; - eu = User[explosion]; + eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness SetOwner(sp->owner, explosion); @@ -11596,8 +11596,8 @@ SpawnGrenadeExp(int16_t Weapon) void SpawnExpZadjust(short Weapon, SPRITEp exp, int upper_zsize, int lower_zsize) { - USERp u = User[Weapon]; - USERp eu = User[exp - sprite]; + USERp u = User[Weapon].Data(); + USERp eu = User[exp - sprite].Data(); int tos_z, bos_z; ASSERT(eu); @@ -11643,7 +11643,7 @@ int SpawnMineExp(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); SPRITEp exp; USERp eu; short explosion; @@ -11659,7 +11659,7 @@ SpawnMineExp(int16_t Weapon) explosion = SpawnSprite(STAT_MISSILE, MINE_EXP, s_MineExp, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0); exp = &sprite[explosion]; - eu = User[explosion]; + eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness SetOwner(sp->owner, explosion); @@ -11738,7 +11738,7 @@ InitMineShrap(short SpriteNum) int DoMineExp(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); DoExpDamageTest(SpriteNum); //InitMineShrap(SpriteNum); @@ -11750,7 +11750,7 @@ int DoSectorExp(int16_t SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); sp->x += u->xchange; sp->y += u->ychange; @@ -11762,7 +11762,7 @@ int SpawnSectorExp(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); SPRITEp exp; USERp eu; short explosion; @@ -11776,7 +11776,7 @@ SpawnSectorExp(int16_t Weapon) explosion = SpawnSprite(STAT_MISSILE, GRENADE_EXP, s_SectorExp, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0); exp = &sprite[explosion]; - eu = User[explosion]; + eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness exp->owner = -1; @@ -11808,7 +11808,7 @@ SpawnLargeExp(int16_t Weapon) explosion = SpawnSprite(STAT_MISSILE, GRENADE_EXP, s_SectorExp, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0); exp = &sprite[explosion]; - eu = User[explosion]; + eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness exp->owner = -1; @@ -11833,7 +11833,7 @@ int SpawnMeteorExp(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); SPRITEp exp; USERp eu; short explosion; @@ -11855,7 +11855,7 @@ SpawnMeteorExp(int16_t Weapon) } exp = &sprite[explosion]; - eu = User[explosion]; + eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness exp->owner = -1; @@ -11892,7 +11892,7 @@ SpawnLittleExp(int16_t Weapon) explosion = SpawnSprite(STAT_MISSILE, BOLT_EXP, s_SectorExp, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0); exp = &sprite[explosion]; - eu = User[explosion]; + eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness exp->owner = -1; @@ -11911,9 +11911,9 @@ int DoFireball(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); - u = User[Weapon]; + u = User[Weapon].Data(); ASSERT(Weapon >= 0); @@ -11965,7 +11965,7 @@ DoFireball(int16_t Weapon) USERp hu; hsp = &sprite[NORM_SPRITE(u->ret)]; - hu = User[NORM_SPRITE(u->ret)]; + hu = User[NORM_SPRITE(u->ret)].Data(); if (TEST(hsp->extra, SPRX_BURNABLE)) { @@ -12001,7 +12001,7 @@ int DoFindGround(int16_t SpriteNum) { SPRITEp sp = &sprite[SpriteNum], hsp; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int ceilhit, florhit; short save_cstat; short bak_cstat; @@ -12060,7 +12060,7 @@ int DoFindGroundPoint(int16_t SpriteNum) { SPRITEp sp = &sprite[SpriteNum], hsp; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int ceilhit, florhit; short save_cstat; short bak_cstat; @@ -12119,13 +12119,13 @@ int DoNapalm(int16_t Weapon) { SPRITEp sp = &sprite[Weapon], exp; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); short explosion; int ox, oy, oz; DoBlurExtend(Weapon, 1, 7); - u = User[Weapon]; + u = User[Weapon].Data(); if (TEST(u->Flags, SPR_UNDERWATER)) { @@ -12186,7 +12186,7 @@ DoNapalm(int16_t Weapon) sp->x, sp->y, sp->z, sp->ang, 0); exp = &sprite[explosion]; - eu = User[explosion]; + eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness //exp->owner = sp->owner; @@ -12235,14 +12235,14 @@ int DoBloodWorm(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); short ang; int xvect,yvect; int bx,by; int amt; short sectnum; - u = User[Weapon]; + u = User[Weapon].Data(); u->ret = move_ground_missile(Weapon, u->xchange, u->ychange, u->ceiling_dist, u->floor_dist, CLIPMASK_MISSILE, MISSILEMOVETICS); @@ -12275,7 +12275,7 @@ DoBloodWorm(int16_t Weapon) while ((i = it.NextIndex()) >= 0) { tsp = &sprite[i]; - tu = User[i]; + tu = User[i].Data(); ASSERT(tu); @@ -12327,7 +12327,7 @@ int DoBloodWorm(int16_t Weapon) { SPRITEp sp = &sprite[Weapon], exp; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); int offset; short ang; int x,y,z,xvect,yvect; @@ -12335,7 +12335,7 @@ DoBloodWorm(int16_t Weapon) int amt; short sectnum; - u = User[Weapon]; + u = User[Weapon].Data(); u->ret = move_missile(Weapon, u->xchange, u->ychange, u->zchange, u->ceiling_dist, u->floor_dist, CLIPMASK_MISSILE, MISSILEMOVETICS); @@ -12389,7 +12389,7 @@ DoBloodWorm(int16_t Weapon) while ((i = it.NextIndex()) >= 0) { tsp = &sprite[i]; - tu = User[i]; + tu = User[i].Data(); ASSERT(tu); @@ -12464,7 +12464,7 @@ int DoSerpMeteor(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); int ox, oy, oz; ox = sp->x; @@ -12484,7 +12484,7 @@ DoSerpMeteor(int16_t Weapon) if (TEST(u->ret, HIT_MASK) == HIT_SPRITE) { SPRITEp hsp = &sprite[NORM_SPRITE(u->ret)]; - USERp hu = User[NORM_SPRITE(u->ret)]; + USERp hu = User[NORM_SPRITE(u->ret)].Data(); if (hu && hu->ID >= SKULL_R0 && hu->ID <= SKULL_SERP) { @@ -12522,9 +12522,9 @@ int DoMirvMissile(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); - u = User[Weapon]; + u = User[Weapon].Data(); sp->xrepeat += MISSILEMOVETICS * 2; if (sp->xrepeat > 80) @@ -12555,11 +12555,11 @@ int DoMirv(int16_t Weapon) { SPRITEp sp = &sprite[Weapon], np; - USERp u = User[Weapon], nu; + USERp u = User[Weapon].Data(), nu; short New; // int ox, oy, oz; - u = User[Weapon]; + u = User[Weapon].Data(); // ox = sp->x; // oy = sp->y; @@ -12615,7 +12615,7 @@ DoMirv(int16_t Weapon) sp->x, sp->y, sp->z, NORM_ANGLE(sp->ang + angs[i]), 800); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); nu->RotNum = 5; NewStateGroup(New, &sg_MirvMeteor[0]); @@ -12660,7 +12660,7 @@ bool MissileSetPos(short Weapon, ANIMATORp DoWeapon, int dist) { SPRITEp wp = &sprite[Weapon]; - USERp wu = User[Weapon]; + USERp wu = User[Weapon].Data(); int oldvel, oldzvel; int oldxc, oldyc, oldzc; bool retval = false; @@ -12704,7 +12704,7 @@ bool TestMissileSetPos(short Weapon, ANIMATORp DoWeapon, int dist, int zvel) { SPRITEp wp = &sprite[Weapon]; - USERp wu = User[Weapon]; + USERp wu = User[Weapon].Data(); int oldvel, oldzvel; int oldxc, oldyc, oldzc; bool retval = false; @@ -12748,7 +12748,7 @@ int DoRing(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); PLAYERp pp = User[sp->owner]->PlayerP; SPRITEp so = &sprite[sp->owner]; int cz,fz; @@ -12881,7 +12881,7 @@ InitSpellRing(PLAYERp pp) sp->yrepeat = 32; sp->zvel = 0; - u = User[SpriteNum]; + u = User[SpriteNum].Data(); u->sz = Z(20); u->Dist = RING_INNER_DIST; @@ -12912,8 +12912,8 @@ int DoSerpRing(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; - USERp ou = User[sp->owner]; + USERp u = User[Weapon].Data(); + USERp ou = User[sp->owner].Data(); int dist,a,b,c; int cz,fz; @@ -12977,7 +12977,7 @@ DoSerpRing(int16_t Weapon) if (u->Counter2 > 0) { - if (!User[ou->tgt_sp-sprite] || + if (!User[ou->tgt_sp-sprite].Data() || !User[ou->tgt_sp-sprite]->PlayerP || !TEST(User[ou->tgt_sp-sprite]->PlayerP->Flags, PF_DEAD)) { @@ -13036,7 +13036,7 @@ int InitLavaThrow(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum], wp; - USERp u = User[SpriteNum], wu; + USERp u = User[SpriteNum].Data(), wu; int nx, ny, nz, dist, nang; short w; @@ -13054,7 +13054,7 @@ InitLavaThrow(short SpriteNum) nx, ny, nz, nang, NINJA_BOLT_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); SetOwner(SpriteNum, w); wp->hitag = LUMINOUS; //Always full brightness @@ -13127,7 +13127,7 @@ InitVulcanBoulder(short SpriteNum) nx, ny, nz, nang, (vel/2 + vel/4) + RANDOM_RANGE(vel/4)); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); SetOwner(SpriteNum, w); wp->xrepeat = wp->yrepeat = 8 + RANDOM_RANGE(72); @@ -13170,7 +13170,7 @@ int InitSerpRing(short SpriteNum) { SPRITEp sp = User[SpriteNum]->SpriteP, np; - USERp u = User[SpriteNum], nu; + USERp u = User[SpriteNum].Data(), nu; short ang, ang_diff, ang_start, ang_finish, missiles, NewSprite; short max_missiles = 16; @@ -13225,7 +13225,7 @@ int InitSerpRing(short SpriteNum) { SPRITEp sp = User[SpriteNum]->SpriteP, np; - USERp u = User[SpriteNum], nu; + USERp u = User[SpriteNum].Data(), nu; short ang, ang_diff, ang_start, missiles, New; short max_missiles; @@ -13250,7 +13250,7 @@ InitSerpRing(short SpriteNum) New = SpawnSprite(STAT_SKIP4, SKULL_SERP, &s_SkullRing[0][0], sp->sectnum, sp->x, sp->y, sp->z, ang, 0); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); np->xvel = 500; //np->owner = SpriteNum; @@ -13301,7 +13301,7 @@ int InitSerpRing2(short SpriteNum) { SPRITEp sp = User[SpriteNum]->SpriteP, np; - USERp u = User[SpriteNum], nu; + USERp u = User[SpriteNum].Data(), nu; short ang, ang_diff, ang_start, ang_finish, missiles, New; short max_missiles; short i; @@ -13329,7 +13329,7 @@ InitSerpRing2(short SpriteNum) New = SpawnSprite(STAT_MISSILE_SKIP4, SKULL_SERP, &s_SkullRing[0][0], sp->sectnum, sp->x, sp->y, sp->z, ang, 0); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); //np->owner = SpriteNum; SetOwner(SpriteNum, New); @@ -13416,7 +13416,7 @@ InitSpellNapalm(PLAYERp pp) pp->posx, pp->posy, pp->posz + Z(12), pp->angle.ang.asbuild(), NAPALM_VELOCITY*2); sp = &sprite[SpriteNum]; - u = User[SpriteNum]; + u = User[SpriteNum].Data(); sp->hitag = LUMINOUS; //Always full brightness @@ -13477,7 +13477,7 @@ InitEnemyNapalm(short SpriteNum) { short w; SPRITEp sp = &sprite[SpriteNum], wp; - USERp u = User[SpriteNum], wu; + USERp u = User[SpriteNum].Data(), wu; short dist; unsigned i; short oclipdist; @@ -13503,7 +13503,7 @@ InitEnemyNapalm(short SpriteNum) sp->x, sp->y, SPRITEp_TOS(sp) + DIV4(SPRITEp_SIZE_Z(sp)), sp->ang, NAPALM_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); wp->hitag = LUMINOUS; //Always full brightness if (i==0) // Only attach sound to first projectile @@ -13576,7 +13576,7 @@ InitSpellMirv(PLAYERp pp) pp->posx, pp->posy, pp->posz + Z(12), pp->angle.ang.asbuild(), MIRV_VELOCITY); sp = &sprite[SpriteNum]; - u = User[SpriteNum]; + u = User[SpriteNum].Data(); PlaySound(DIGI_MIRVWIZ, sp, v3df_follow); Set3DSoundOwner(SpriteNum); @@ -13613,7 +13613,7 @@ int InitEnemyMirv(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum], wp; - USERp u = User[SpriteNum], wu; + USERp u = User[SpriteNum].Data(), wu; short w; int dist; @@ -13623,7 +13623,7 @@ InitEnemyMirv(short SpriteNum) sp->x, sp->y, SPRITEp_TOS(sp) + DIV4(SPRITEp_SIZE_Z(sp)), sp->ang, MIRV_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); PlaySound(DIGI_MIRVWIZ, wp, v3df_follow); Set3DSoundOwner(w); @@ -13659,7 +13659,7 @@ InitEnemyMirv(short SpriteNum) int InitSwordAttack(PLAYERp pp) { - USERp u = User[pp->PlayerSprite],tu; + USERp u = User[pp->PlayerSprite].Data(),tu; SPRITEp sp = NULL; int i; unsigned stat; @@ -13757,7 +13757,7 @@ InitSwordAttack(PLAYERp pp) { extern STATE s_TrashCanPain[]; SPRITEp hsp = &sprite[hitinfo.sprite]; - tu = User[hitinfo.sprite]; + tu = User[hitinfo.sprite].Data(); if (tu) // JBF: added null check switch (tu->ID) @@ -13838,7 +13838,7 @@ InitSwordAttack(PLAYERp pp) int InitFistAttack(PLAYERp pp) { - USERp u = User[pp->PlayerSprite],tu; + USERp u = User[pp->PlayerSprite].Data(),tu; SPRITEp sp = NULL; int i; unsigned stat; @@ -13948,7 +13948,7 @@ InitFistAttack(PLAYERp pp) { extern STATE s_TrashCanPain[]; SPRITEp hsp = &sprite[hitinfo.sprite]; - tu = User[hitinfo.sprite]; + tu = User[hitinfo.sprite].Data(); if (tu) // JBF: added null check switch (tu->ID) @@ -14049,7 +14049,7 @@ InitSumoNapalm(short SpriteNum) { short w; SPRITEp sp = &sprite[SpriteNum], wp; - USERp u = User[SpriteNum], wu; + USERp u = User[SpriteNum].Data(), wu; short dist; short i,j,ang; short oclipdist; @@ -14076,7 +14076,7 @@ InitSumoNapalm(short SpriteNum) sp->x, sp->y, SPRITEp_TOS(sp), ang, NAPALM_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); wp->hitag = LUMINOUS; //Always full brightness if (i==0) // Only attach sound to first projectile @@ -14134,7 +14134,7 @@ int InitSumoSkull(short SpriteNum) { SPRITEp sp = User[SpriteNum]->SpriteP, np; - USERp u = User[SpriteNum], nu; + USERp u = User[SpriteNum].Data(), nu; short New; extern STATE s_SkullExplode[]; @@ -14148,7 +14148,7 @@ InitSumoSkull(short SpriteNum) New = SpawnSprite(STAT_ENEMY, SKULL_R0, &s_SkullWait[0][0], sp->sectnum, sp->x, sp->y, SPRITEp_MID(sp), sp->ang, 0); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); np->xvel = 500; SetOwner(SpriteNum, New); @@ -14189,7 +14189,7 @@ InitSumoSkull(short SpriteNum) int InitSumoStompAttack(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = &sprite[SpriteNum],tsp; int i; unsigned stat; @@ -14232,7 +14232,7 @@ int InitMiniSumoClap(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); int dist; short reach; @@ -14269,8 +14269,8 @@ InitMiniSumoClap(short SpriteNum) int WeaponAutoAim(SPRITEp sp, short Missile, short ang, bool test) { - USERp wu = User[Missile]; - USERp u = User[sp - sprite]; + USERp wu = User[Missile].Data(); + USERp u = User[sp - sprite].Data(); SPRITEp wp = &sprite[Missile]; short hit_sprite = -1; int dist; @@ -14296,7 +14296,7 @@ WeaponAutoAim(SPRITEp sp, short Missile, short ang, bool test) if ((hit_sprite = DoPickTarget(sp, ang, test)) != -1) { SPRITEp hp = &sprite[hit_sprite]; - USERp hu = User[hit_sprite]; + USERp hu = User[hit_sprite].Data(); wu->WpnGoal = hit_sprite; SET(hu->Flags, SPR_TARGETED); @@ -14339,8 +14339,8 @@ WeaponAutoAim(SPRITEp sp, short Missile, short ang, bool test) int WeaponAutoAimZvel(SPRITEp sp, short Missile, int *zvel, short ang, bool test) { - USERp wu = User[Missile]; - USERp u = User[sp - sprite]; + USERp wu = User[Missile].Data(); + USERp u = User[sp - sprite].Data(); SPRITEp wp = &sprite[Missile]; short hit_sprite = -1; int dist; @@ -14366,7 +14366,7 @@ WeaponAutoAimZvel(SPRITEp sp, short Missile, int *zvel, short ang, bool test) if ((hit_sprite = DoPickTarget(sp, ang, test)) != -1) { SPRITEp hp = &sprite[hit_sprite]; - USERp hu = User[hit_sprite]; + USERp hu = User[hit_sprite].Data(); wu->WpnGoal = hit_sprite; SET(hu->Flags, SPR_TARGETED); @@ -14410,7 +14410,7 @@ WeaponAutoAimZvel(SPRITEp sp, short Missile, int *zvel, short ang, bool test) int AimHitscanToTarget(SPRITEp sp, int *z, short *ang, int z_ratio) { - USERp u = User[sp - sprite]; + USERp u = User[sp - sprite].Data(); short hit_sprite = -1; int dist; int zh; @@ -14424,7 +14424,7 @@ AimHitscanToTarget(SPRITEp sp, int *z, short *ang, int z_ratio) hit_sprite = u->tgt_sp - sprite; hp = &sprite[hit_sprite]; - hu = User[hit_sprite]; + hu = User[hit_sprite].Data(); SET(hu->Flags, SPR_TARGETED); SET(hu->Flags, SPR_ATTACKED); @@ -14467,7 +14467,7 @@ AimHitscanToTarget(SPRITEp sp, int *z, short *ang, int z_ratio) int WeaponAutoAimHitscan(SPRITEp sp, int *z, short *ang, bool test) { - USERp u = User[sp - sprite]; + USERp u = User[sp - sprite].Data(); short hit_sprite = -1; int dist; int zh; @@ -14485,7 +14485,7 @@ WeaponAutoAimHitscan(SPRITEp sp, int *z, short *ang, bool test) if ((hit_sprite = DoPickTarget(sp, *ang, test)) != -1) { SPRITEp hp = &sprite[hit_sprite]; - USERp hu = User[hit_sprite]; + USERp hu = User[hit_sprite].Data(); SET(hu->Flags, SPR_TARGETED); SET(hu->Flags, SPR_ATTACKED); @@ -14557,7 +14557,7 @@ WeaponHitscanShootFeet(SPRITEp sp, SPRITEp hp, int *zvect) int InitStar(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); USERp wu; SPRITEp wp; int nx, ny, nz; @@ -14591,7 +14591,7 @@ InitStar(PLAYERp pp) w = SpawnSprite(STAT_MISSILE, STAR1, s_Star, pp->cursectnum, nx, ny, nz, pp->angle.ang.asbuild(), STAR_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); //SET(wp->cstat, CSTAT_SPRITE_ALIGNMENT_WALL); SetOwner(pp->PlayerSprite, w); @@ -14638,7 +14638,7 @@ InitStar(PLAYERp pp) { nw = SpawnSprite(STAT_MISSILE, STAR1, s_Star, pp->cursectnum, nx, ny, nz, NORM_ANGLE(wp->ang + dang[i]), wp->xvel); np = &sprite[nw]; - nu = User[nw]; + nu = User[nw].Data(); SetOwner(wp->owner, nw); np->yrepeat = np->xrepeat = STAR_REPEAT; @@ -14707,7 +14707,7 @@ InitHeartAttack(PLAYERp pp) pp->posx, pp->posy, pp->posz + Z(12), pp->angle.ang.asbuild(), BLOOD_WORM_VELOCITY*2); sp = &sprite[SpriteNum]; - u = User[SpriteNum]; + u = User[SpriteNum].Data(); sp->hitag = LUMINOUS; //Always full brightness @@ -14761,7 +14761,7 @@ InitHeartAttack(PLAYERp pp) USERp u; short i = 0; short oclipdist; - USERp pu = User[pp->PlayerSprite]; + USERp pu = User[pp->PlayerSprite].Data(); typedef struct { @@ -14783,7 +14783,7 @@ InitHeartAttack(PLAYERp pp) pp->posx, pp->posy, pp->posz + Z(12), pp->angle.ang.asbuild(), BLOOD_WORM_VELOCITY*2); sp = &sprite[SpriteNum]; - u = User[SpriteNum]; + u = User[SpriteNum].Data(); sp->hitag = LUMINOUS; //Always full brightness @@ -14823,7 +14823,7 @@ int ContinueHitscan(PLAYERp pp, short sectnum, int x, int y, int z, short ang, i { short j; hitdata_t hitinfo; - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); FAFhitscan(x, y, z, sectnum, xvect, yvect, zvect, @@ -14903,7 +14903,7 @@ int ContinueHitscan(PLAYERp pp, short sectnum, int x, int y, int z, short ang, i int InitShotgun(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); short daang,ndaang, i, j; hitdata_t hitinfo; short nsect; @@ -15032,7 +15032,7 @@ InitShotgun(PLAYERp pp) if (hitinfo.sprite >= 0) { SPRITEp hsp = &sprite[hitinfo.sprite]; - USERp hu = User[hitinfo.sprite]; + USERp hu = User[hitinfo.sprite].Data(); if (hu && hu->ID == TRASHCAN) // JBF: added null check { @@ -15079,7 +15079,7 @@ InitShotgun(PLAYERp pp) int InitLaser(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); USERp wu; SPRITEp wp; int nx, ny, nz; @@ -15107,7 +15107,7 @@ InitLaser(PLAYERp pp) nx, ny, nz, pp->angle.ang.asbuild(), 300); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); wp->hitag = LUMINOUS; //Always full brightness SetOwner(pp->PlayerSprite, w); @@ -15184,7 +15184,7 @@ InitLaser(PLAYERp pp) int InitRail(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); USERp wu; SPRITEp wp; int nx, ny, nz; @@ -15218,7 +15218,7 @@ InitRail(PLAYERp pp) nx, ny, nz, pp->angle.ang.asbuild(), 1200); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); SetOwner(pp->PlayerSprite, w); wp->yrepeat = 52; @@ -15277,7 +15277,7 @@ int InitZillaRail(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); USERp wu; SPRITEp wp; int nx, ny, nz; @@ -15304,7 +15304,7 @@ InitZillaRail(short SpriteNum) nx, ny, nz, sp->ang, 1200); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); SetOwner(SpriteNum, w); wp->yrepeat = 52; @@ -15362,7 +15362,7 @@ InitZillaRail(short SpriteNum) int InitRocket(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); USERp wu; SPRITEp wp; int nx, ny, nz; @@ -15418,7 +15418,7 @@ InitRocket(PLAYERp pp) nx, ny, nz, pp->angle.ang.asbuild(), ROCKET_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); //wp->owner = pp->PlayerSprite; SetOwner(pp->PlayerSprite, w); @@ -15496,7 +15496,7 @@ InitRocket(PLAYERp pp) int InitBunnyRocket(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); USERp wu; SPRITEp wp; int nx, ny, nz; @@ -15549,7 +15549,7 @@ InitBunnyRocket(PLAYERp pp) nx, ny, nz, pp->angle.ang.asbuild(), ROCKET_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); //wp->owner = pp->PlayerSprite; SetOwner(pp->PlayerSprite, w); @@ -15625,7 +15625,7 @@ InitBunnyRocket(PLAYERp pp) int InitNuke(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); USERp wu; SPRITEp wp; int nx, ny, nz; @@ -15663,7 +15663,7 @@ InitNuke(PLAYERp pp) nx, ny, nz, pp->angle.ang.asbuild(), 700); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); //wp->owner = pp->PlayerSprite; SetOwner(pp->PlayerSprite, w); @@ -15732,7 +15732,7 @@ int InitEnemyNuke(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); USERp wu; SPRITEp wp; int nx, ny, nz; @@ -15756,7 +15756,7 @@ InitEnemyNuke(short SpriteNum) nx, ny, nz, sp->ang, 700); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); if (u->ID == ZOMBIE_RUN_R0) SetOwner(sp->owner, w); @@ -15818,7 +15818,7 @@ InitEnemyNuke(short SpriteNum) int InitMicro(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); USERp wu,hu; SPRITEp wp,hp; int nx, ny, nz, dist; @@ -15848,7 +15848,7 @@ InitMicro(PLAYERp pp) if (ts < &TargetSort[TargetSortCount] && ts->sprite_num >= 0) { hp = &sprite[ts->sprite_num]; - hu = User[ts->sprite_num]; + hu = User[ts->sprite_num].Data(); ang = getangle(hp->x - nx, hp->y - ny); @@ -15871,7 +15871,7 @@ InitMicro(PLAYERp pp) nx, ny, nz, ang, 1200); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); SetOwner(pp->PlayerSprite, w); wp->yrepeat = 24; @@ -15954,7 +15954,7 @@ InitMicro(PLAYERp pp) int InitRipperSlash(short SpriteNum) { - USERp u = User[SpriteNum], hu; + USERp u = User[SpriteNum].Data(), hu; SPRITEp sp = User[SpriteNum]->SpriteP; SPRITEp hp; int i; @@ -15969,7 +15969,7 @@ InitRipperSlash(short SpriteNum) while ((i = it.NextIndex()) >= 0) { hp = &sprite[i]; - hu = User[i]; + hu = User[i].Data(); if (i == SpriteNum) break; @@ -16140,7 +16140,7 @@ DoBladeDamage(short SpriteNum) int DoStaticFlamesDamage(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; SPRITEp hp; int i; @@ -16292,7 +16292,7 @@ InitGoroChop(short SpriteNum) int InitHornetSting(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); short HitSprite = NORM_SPRITE(u->ret); DoDamage(HitSprite, SpriteNum); @@ -16305,7 +16305,7 @@ int InitSerpSpell(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum], np; - USERp u = User[SpriteNum], nu; + USERp u = User[SpriteNum].Data(), nu; int dist; short New, i; short oclipdist; @@ -16328,7 +16328,7 @@ InitSerpSpell(short SpriteNum) sp->x, sp->y, sp->z, sp->ang, 1500); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); np->z = SPRITEp_TOS(sp); @@ -16383,7 +16383,7 @@ int SpawnDemonFist(int16_t Weapon) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); SPRITEp exp; USERp eu; short explosion; @@ -16397,7 +16397,7 @@ SpawnDemonFist(int16_t Weapon) sp->x, sp->y, SPRITEp_MID(sp), sp->ang, 0); exp = &sprite[explosion]; - eu = User[explosion]; + eu = User[explosion].Data(); exp->hitag = LUMINOUS; //Always full brightness exp->owner = -1; @@ -16422,7 +16422,7 @@ int InitSerpMonstSpell(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum], np; - USERp u = User[SpriteNum], nu; + USERp u = User[SpriteNum].Data(), nu; int dist; short New, i; short oclipdist; @@ -16447,7 +16447,7 @@ InitSerpMonstSpell(short SpriteNum) sp->x, sp->y, sp->z, sp->ang, 500); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); nu->spal = np->pal = 25; // Bright Red np->z = SPRITEp_TOS(sp); @@ -16515,7 +16515,7 @@ int InitEnemyRocket(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum], wp; - USERp u = User[SpriteNum], wu; + USERp u = User[SpriteNum].Data(), wu; int nx, ny, nz, dist, nang; short w; @@ -16535,7 +16535,7 @@ InitEnemyRocket(short SpriteNum) w = SpawnSprite(STAT_MISSILE, BOLT_THINMAN_R2, &s_Rocket[0][0], sp->sectnum, nx, ny, nz-Z(8), u->tgt_sp->ang, NINJA_BOLT_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); // Set default palette wp->pal = wu->spal = 17; // White @@ -16580,7 +16580,7 @@ InitEnemyRocket(short SpriteNum) int InitEnemyRail(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; USERp wu; SPRITEp wp; @@ -16628,7 +16628,7 @@ InitEnemyRail(short SpriteNum) nx, ny, nz, sp->ang, 1200); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); if (u->ID == ZOMBIE_RUN_R0) SetOwner(sp->owner, w); @@ -16677,7 +16677,7 @@ int InitZillaRocket(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum], wp; - USERp u = User[SpriteNum], wu; + USERp u = User[SpriteNum].Data(), wu; int nx, ny, nz, dist, nang; short w, i; @@ -16714,7 +16714,7 @@ InitZillaRocket(short SpriteNum) w = SpawnSprite(STAT_MISSILE, BOLT_THINMAN_R2, &s_Rocket[0][0], sp->sectnum, nx, ny, nz-Z(8), u->tgt_sp->ang, NINJA_BOLT_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); SetOwner(SpriteNum, w); wp->yrepeat = 28; @@ -16765,7 +16765,7 @@ int InitEnemyStar(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum], wp; - USERp u = User[SpriteNum], wu; + USERp u = User[SpriteNum].Data(), wu; int nx, ny, nz, dist, nang; short w; @@ -16780,7 +16780,7 @@ InitEnemyStar(short SpriteNum) wp = &sprite[w = SpawnSprite(STAT_MISSILE, STAR1, s_Star, sp->sectnum, nx, ny, nz, u->tgt_sp->ang, NINJA_STAR_VELOCITY)]; - wu = User[w]; + wu = User[w].Data(); //wp->owner = SpriteNum; SetOwner(SpriteNum, w); @@ -16854,7 +16854,7 @@ int InitEnemyCrossbow(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum], wp; - USERp u = User[SpriteNum], wu; + USERp u = User[SpriteNum].Data(), wu; int nx, ny, nz, dist, nang; short w; @@ -16869,7 +16869,7 @@ InitEnemyCrossbow(short SpriteNum) wp = &sprite[w = SpawnSprite(STAT_MISSILE, CROSSBOLT, &s_CrossBolt[0][0], sp->sectnum, nx, ny, nz, u->tgt_sp->ang, 800)]; - wu = User[w]; + wu = User[w].Data(); //wp->owner = SpriteNum; SetOwner(SpriteNum, w); @@ -16949,7 +16949,7 @@ int InitSkelSpell(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum], wp; - USERp u = User[SpriteNum], wu; + USERp u = User[SpriteNum].Data(), wu; int nx, ny, nz, dist, nang; short w; @@ -16966,7 +16966,7 @@ InitSkelSpell(short SpriteNum) w = SpawnSprite(STAT_MISSILE, ELECTRO_ENEMY, s_Electro, sp->sectnum, nx, ny, nz, u->tgt_sp->ang, SKEL_ELECTRO_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); //wp->owner = SpriteNum; SetOwner(SpriteNum, w); @@ -16998,7 +16998,7 @@ int InitCoolgFire(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum], wp; - USERp u = User[SpriteNum], wu; + USERp u = User[SpriteNum].Data(), wu; int nx, ny, nz, dist, nang; short w; @@ -17019,7 +17019,7 @@ InitCoolgFire(short SpriteNum) nx, ny, nz, u->tgt_sp->ang, COOLG_FIRE_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); //wp->owner = SpriteNum; SetOwner(SpriteNum, w); @@ -17062,7 +17062,7 @@ InitCoolgFire(short SpriteNum) int DoCoolgDrip(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); u->Counter += 220; sp->z += u->Counter; @@ -17094,7 +17094,7 @@ InitCoolgDrip(short SpriteNum) nx, ny, nz, sp->ang, 0); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); //wp->owner = SpriteNum; SetOwner(SpriteNum, w); @@ -17115,7 +17115,7 @@ int GenerateDrips(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum], wp; - USERp u = User[SpriteNum], wu; + USERp u = User[SpriteNum].Data(), wu; int nx, ny, nz; short w = 0; @@ -17140,7 +17140,7 @@ GenerateDrips(short SpriteNum) nx, ny, nz, sp->ang, 0); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); //wp->owner = SpriteNum; SetOwner(SpriteNum, w); @@ -17162,7 +17162,7 @@ GenerateDrips(short SpriteNum) int InitEelFire(short SpriteNum) { - USERp u = User[SpriteNum], hu; + USERp u = User[SpriteNum].Data(), hu; SPRITEp sp = User[SpriteNum]->SpriteP; SPRITEp hp; int i; @@ -17175,7 +17175,7 @@ InitEelFire(short SpriteNum) while ((i = it.NextIndex()) >= 0) { hp = &sprite[i]; - hu = User[i]; + hu = User[i].Data(); if (i == SpriteNum) continue; @@ -17219,7 +17219,7 @@ InitFireballTrap(short SpriteNum) w = SpawnSprite(STAT_MISSILE, FIREBALL, s_Fireball, sp->sectnum, nx, ny, nz, sp->ang, FIREBALL_TRAP_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); //wp->owner = SpriteNum; wp->hitag = LUMINOUS; //Always full brightness @@ -17257,7 +17257,7 @@ InitBoltTrap(short SpriteNum) w = SpawnSprite(STAT_MISSILE, BOLT_THINMAN_R0, &s_Rocket[0][0], sp->sectnum, nx, ny, nz, sp->ang, BOLT_TRAP_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); //wp->owner = SpriteNum; SetOwner(SpriteNum, w); @@ -17283,7 +17283,7 @@ int InitEnemyCrossbow(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum], wp; - USERp u = User[SpriteNum], wu; + USERp u = User[SpriteNum].Data(), wu; int nx, ny, nz, dist, nang; short w; @@ -17298,7 +17298,7 @@ InitEnemyCrossbow(short SpriteNum) wp = &sprite[w = SpawnSprite(STAT_MISSILE, CROSSBOLT, s_CrossBolt, sp->sectnum, nx, ny, nz, u->tgt_sp->ang, 800)]; - wu = User[w]; + wu = User[w].Data(); //wp->owner = SpriteNum; SetOwner(SpriteNum, w); @@ -17337,7 +17337,7 @@ InitSpearTrap(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum], wp; USERp wu; - //USERp u = User[SpriteNum]; + //USERp u = User[SpriteNum].Data(); int nx, ny, nz; short w; //short nang; @@ -17350,7 +17350,7 @@ InitSpearTrap(short SpriteNum) w = SpawnSprite(STAT_MISSILE, CROSSBOLT, &s_CrossBolt[0][0], sp->sectnum, nx, ny, nz, sp->ang, 750); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); //wp->owner = SpriteNum; SetOwner(SpriteNum, w); @@ -17403,7 +17403,7 @@ InitTracerUzi(PLAYERp pp) if (pp->cursectnum < 0) return 0; - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); SPRITEp wp; USERp wu; @@ -17426,7 +17426,7 @@ InitTracerUzi(PLAYERp pp) nx, ny, nz, pp->angle.ang.asbuild(), TRACER_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); wp->hitag = LUMINOUS; //Always full brightness //wp->owner = pp->PlayerSprite; @@ -17484,7 +17484,7 @@ InitTracerUzi(PLAYERp pp) int InitTracerTurret(short SpriteNum, short Operator, fixed_t q16horiz) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; SPRITEp wp; USERp wu; @@ -17503,7 +17503,7 @@ InitTracerTurret(short SpriteNum, short Operator, fixed_t q16horiz) nx, ny, nz, sp->ang, TRACER_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); wp->hitag = LUMINOUS; //Always full brightness if (Operator >= 0) @@ -17542,7 +17542,7 @@ InitTracerTurret(short SpriteNum, short Operator, fixed_t q16horiz) int InitTracerAutoTurret(short SpriteNum, short Operator, int xchange, int ychange, int zchange) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; SPRITEp wp; USERp wu; @@ -17561,7 +17561,7 @@ InitTracerAutoTurret(short SpriteNum, short Operator, int xchange, int ychange, nx, ny, nz, sp->ang, TRACER_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); wp->hitag = LUMINOUS; //Always full brightness if (Operator >= 0) @@ -17595,7 +17595,7 @@ BulletHitSprite(SPRITEp sp, short hit_sprite, int hit_x, int hit_y, int hit_z, s { vec3_t hit_pos = { hit_x, hit_y, hit_z }; SPRITEp hsp = &sprite[hit_sprite]; - USERp hu = User[hit_sprite]; + USERp hu = User[hit_sprite].Data(); SPRITEp wp; // USERp wu; short New; @@ -17758,7 +17758,7 @@ HitscanSpriteAdjust(short SpriteNum, short hit_wall) int InitUzi(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); SPRITEp wp, hsp; USERp wu; short daang, j; @@ -17893,7 +17893,7 @@ InitUzi(PLAYERp pp) // hit a sprite? if (hitinfo.sprite >= 0) { - USERp hu = User[hitinfo.sprite]; + USERp hu = User[hitinfo.sprite].Data(); hsp = &sprite[hitinfo.sprite]; if (hu) // JBF: added null check @@ -17946,7 +17946,7 @@ InitUzi(PLAYERp pp) j = SpawnSprite(STAT_MISSILE, UZI_SPARK, s_UziSpark, hitinfo.sect, hitinfo.pos.x, hitinfo.pos.y, hitinfo.pos.z, daang, 0); wp = &sprite[j]; - wu = User[j]; + wu = User[j].Data(); wp->shade = -40; wp->xrepeat = UZI_SPARK_REPEAT; wp->yrepeat = UZI_SPARK_REPEAT; @@ -17971,7 +17971,7 @@ InitUzi(PLAYERp pp) int InitEMP(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); SPRITEp wp, hsp=NULL; USERp wu; short daang, j; @@ -18011,7 +18011,7 @@ InitEMP(PLAYERp pp) j = SpawnSprite(STAT_MISSILE, EMP, s_EMPBurst, hitinfo.sect, hitinfo.pos.x, hitinfo.pos.y, hitinfo.pos.z, daang, 0); wp = &sprite[j]; - wu = User[j]; + wu = User[j].Data(); wu->WaitTics = SEC(7); wp->shade = -127; @@ -18142,7 +18142,7 @@ InitEMP(PLAYERp pp) int InitTankShell(short SpriteNum, PLAYERp pp) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; SPRITEp wp; USERp wu; @@ -18155,7 +18155,7 @@ InitTankShell(short SpriteNum, PLAYERp pp) sp->x, sp->y, sp->z, sp->ang, TANK_SHELL_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); SetOwner(pp->PlayerSprite, w); wp->yrepeat = 8; @@ -18193,10 +18193,10 @@ InitTankShell(short SpriteNum, PLAYERp pp) int InitTurretMicro(short SpriteNum, PLAYERp pp) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; - USERp pu = User[pp->PlayerSprite]; + USERp pu = User[pp->PlayerSprite].Data(); USERp wu,hu; SPRITEp wp,hp; int nx, ny, nz, dist; @@ -18222,7 +18222,7 @@ InitTurretMicro(short SpriteNum, PLAYERp pp) if (ts < &TargetSort[TargetSortCount] && ts->sprite_num >= 0) { hp = &sprite[ts->sprite_num]; - hu = User[ts->sprite_num]; + hu = User[ts->sprite_num].Data(); ang = getangle(hp->x - nx, hp->y - ny); @@ -18245,7 +18245,7 @@ InitTurretMicro(short SpriteNum, PLAYERp pp) nx, ny, nz, ang, 1200); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); SetOwner(pp->PlayerSprite, w); wp->yrepeat = 24; @@ -18303,7 +18303,7 @@ InitTurretMicro(short SpriteNum, PLAYERp pp) int InitTurretRocket(short SpriteNum, PLAYERp pp) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; SPRITEp wp; USERp wu; @@ -18316,7 +18316,7 @@ InitTurretRocket(short SpriteNum, PLAYERp pp) sp->x, sp->y, sp->z, sp->ang, ROCKET_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); SetOwner(pp->PlayerSprite, w); wp->yrepeat = 40; @@ -18351,7 +18351,7 @@ InitTurretRocket(short SpriteNum, PLAYERp pp) int InitTurretFireball(short SpriteNum, PLAYERp pp) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; SPRITEp wp; USERp wu; @@ -18363,7 +18363,7 @@ InitTurretFireball(short SpriteNum, PLAYERp pp) sp->x, sp->y, sp->z, sp->ang, FIREBALL_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); SetOwner(pp->PlayerSprite, w); wp->yrepeat = 40; @@ -18399,7 +18399,7 @@ InitTurretFireball(short SpriteNum, PLAYERp pp) int InitTurretRail(short SpriteNum, PLAYERp pp) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; USERp wu; SPRITEp wp; @@ -18422,7 +18422,7 @@ InitTurretRail(short SpriteNum, PLAYERp pp) nx, ny, nz, sp->ang, 1200); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); SetOwner(pp->PlayerSprite, w); wp->yrepeat = 52; @@ -18457,7 +18457,7 @@ InitTurretRail(short SpriteNum, PLAYERp pp) int InitTurretLaser(short SpriteNum, PLAYERp pp) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; USERp wu; SPRITEp wp; @@ -18480,7 +18480,7 @@ InitTurretLaser(short SpriteNum, PLAYERp pp) nx, ny, nz, sp->ang, 300); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); SetOwner(pp->PlayerSprite, w); wp->yrepeat = 52; @@ -18513,7 +18513,7 @@ InitTurretLaser(short SpriteNum, PLAYERp pp) int InitSobjMachineGun(short SpriteNum, PLAYERp pp) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = u->SpriteP; short daang; hitdata_t hitinfo; @@ -18757,7 +18757,7 @@ SpawnBoatSparks(PLAYERp pp, short hit_sect, short hit_wall, int hit_x, int hit_y j = SpawnSprite(STAT_MISSILE, UZI_SPARK, s_UziSpark, hit_sect, hit_x, hit_y, hit_z, hit_ang, 0); wp = &sprite[j]; - wu = User[j]; + wu = User[j].Data(); wp->shade = -40; wp->xrepeat = UZI_SPARK_REPEAT + 10; wp->yrepeat = UZI_SPARK_REPEAT + 10; @@ -18778,7 +18778,7 @@ SpawnBoatSparks(PLAYERp pp, short hit_sect, short hit_wall, int hit_x, int hit_y int SpawnSwordSparks(PLAYERp pp, short hit_sect, short hit_wall, int hit_x, int hit_y, int hit_z, short hit_ang) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); short j; SPRITEp wp; USERp wu; @@ -18801,7 +18801,7 @@ SpawnSwordSparks(PLAYERp pp, short hit_sect, short hit_wall, int hit_x, int hit_ j = SpawnSprite(STAT_MISSILE, UZI_SPARK, s_UziSpark, hit_sect, hit_x, hit_y, hit_z, hit_ang, 0); wp = &sprite[j]; - wu = User[j]; + wu = User[j].Data(); wp->shade = -40; wp->xrepeat = wp->yrepeat = 20; SetOwner(pp->PlayerSprite, j); @@ -18842,7 +18842,7 @@ SpawnTurretSparks(/*SPRITEp sp, */short hit_sect, short hit_wall, int hit_x, int j = SpawnSprite(STAT_MISSILE, UZI_SPARK, s_UziSpark, hit_sect, hit_x, hit_y, hit_z, hit_ang, 0); wp = &sprite[j]; - wu = User[j]; + wu = User[j].Data(); wp->shade = -40; wp->xrepeat = UZI_SPARK_REPEAT + 10; wp->yrepeat = UZI_SPARK_REPEAT + 10; @@ -18867,7 +18867,7 @@ SpawnShotgunSparks(PLAYERp pp, short hit_sect, short hit_wall, int hit_x, int hi j = SpawnSprite(STAT_MISSILE, UZI_SPARK, s_UziSpark, hit_sect, hit_x, hit_y, hit_z, hit_ang, 0); wp = &sprite[j]; - wu = User[j]; + wu = User[j].Data(); wp->shade = -40; wp->xrepeat = UZI_SPARK_REPEAT; wp->yrepeat = UZI_SPARK_REPEAT; @@ -19067,7 +19067,7 @@ int InitEnemyUzi(short SpriteNum) { SPRITEp sp = User[SpriteNum]->SpriteP,wp; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); USERp wu; short daang, j; hitdata_t hitinfo = { { -2, -2, -2 }, -2, -2, -2 }; @@ -19201,7 +19201,7 @@ InitEnemyUzi(short SpriteNum) j = SpawnSprite(STAT_MISSILE, UZI_SPARK, s_UziSpark, hitinfo.sect, hitinfo.pos.x, hitinfo.pos.y, hitinfo.pos.z, daang, 0); wp = &sprite[j]; - wu = User[j]; + wu = User[j].Data(); wp->shade = -40; wp->xrepeat = UZI_SPARK_REPEAT; wp->yrepeat = UZI_SPARK_REPEAT; @@ -19226,7 +19226,7 @@ InitEnemyUzi(short SpriteNum) int InitGrenade(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); USERp wu; SPRITEp wp; int nx, ny, nz; @@ -19258,7 +19258,7 @@ InitGrenade(PLAYERp pp) nx, ny, nz, pp->angle.ang.asbuild(), GRENADE_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); // don't throw it as far if crawling if (TEST(pp->Flags, PF_CRAWLING)) @@ -19337,7 +19337,7 @@ int InitSpriteGrenade(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); USERp wu; SPRITEp wp; int nx, ny, nz; @@ -19356,7 +19356,7 @@ InitSpriteGrenade(short SpriteNum) nx, ny, nz, sp->ang, GRENADE_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); wu->RotNum = 5; NewStateGroup(w, &sg_Grenade[0]); @@ -19402,7 +19402,7 @@ InitSpriteGrenade(short SpriteNum) int InitMine(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); USERp wu; SPRITEp wp; int nx, ny, nz; @@ -19427,7 +19427,7 @@ InitMine(PLAYERp pp) nx, ny, nz, pp->angle.ang.asbuild(), MINE_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); SetOwner(pp->PlayerSprite, w); wp->yrepeat = 32; @@ -19472,7 +19472,7 @@ int InitEnemyMine(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); USERp wu; SPRITEp wp; int nx, ny, nz; @@ -19491,7 +19491,7 @@ InitEnemyMine(short SpriteNum) nx, ny, nz, sp->ang, MINE_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); SetOwner(SpriteNum, w); wp->yrepeat = 32; @@ -19528,7 +19528,7 @@ int HelpMissileLateral(int16_t Weapon, int dist) { SPRITEp sp = &sprite[Weapon]; - USERp u = User[Weapon]; + USERp u = User[Weapon].Data(); int xchange, ychange; short old_xvel; short old_clipdist; @@ -19560,7 +19560,7 @@ HelpMissileLateral(int16_t Weapon, int dist) int InitFireball(PLAYERp pp) { - USERp u = User[pp->PlayerSprite]; + USERp u = User[pp->PlayerSprite].Data(); SPRITEp wp; int nx = 0, ny = 0, nz; short w; @@ -19585,7 +19585,7 @@ InitFireball(PLAYERp pp) w = SpawnSprite(STAT_MISSILE, FIREBALL1, s_Fireball, pp->cursectnum, nx, ny, nz, pp->angle.ang.asbuild(), FIREBALL_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); wp->hitag = LUMINOUS; //Always full brightness wp->xrepeat = 40; @@ -19643,7 +19643,7 @@ int InitEnemyFireball(short SpriteNum) { SPRITEp sp = User[SpriteNum]->SpriteP, fp = NULL; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp wp; int nz, dist; int size_z; @@ -19679,7 +19679,7 @@ InitEnemyFireball(short SpriteNum) sp->x, sp->y, nz, sp->ang, GORO_FIREBALL_VELOCITY); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); wp->hitag = LUMINOUS; //Always full brightness wp->xrepeat = 20; @@ -19885,7 +19885,7 @@ WarpToSurface(short *sectnum, int *x, int *y, int *z) bool SpriteWarpToUnderwater(SPRITEp sp) { - USERp u = User[sp - sprite]; + USERp u = User[sp - sprite].Data(); int i; SECT_USERp sectu = SectUser[sp->sectnum]; SPRITEp under_sp = NULL, over_sp = NULL; @@ -19963,7 +19963,7 @@ SpriteWarpToUnderwater(SPRITEp sp) bool SpriteWarpToSurface(SPRITEp sp) { - USERp u = User[sp - sprite]; + USERp u = User[sp - sprite].Data(); int i; SECT_USERp sectu = SectUser[sp->sectnum]; short over, under; @@ -20047,7 +20047,7 @@ SpriteWarpToSurface(SPRITEp sp) int SpawnSplash(short SpriteNum) { - USERp u = User[SpriteNum], wu; + USERp u = User[SpriteNum].Data(), wu; SPRITEp sp = User[SpriteNum]->SpriteP, wp; short w; @@ -20070,7 +20070,7 @@ SpawnSplash(short SpriteNum) w = SpawnSprite(STAT_MISSILE, SPLASH, s_Splash, sp->sectnum, sp->x, sp->y, u->loz, sp->ang, 0); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); if (sectu && TEST(sectp->extra, SECTFX_LIQUID_MASK) == SECTFX_LIQUID_LAVA) wu->spal = wp->pal = PALETTE_RED_LIGHTING; @@ -20107,7 +20107,7 @@ SpawnSplashXY(int hit_x, int hit_y, int hit_z, short sectnum) w = SpawnSprite(STAT_MISSILE, SPLASH, s_Splash, sectnum, hit_x, hit_y, hit_z, 0, 0); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); if (sectu && TEST(sectp->extra, SECTFX_LIQUID_MASK) == SECTFX_LIQUID_LAVA) wu->spal = wp->pal = PALETTE_RED_LIGHTING; @@ -20122,7 +20122,7 @@ SpawnSplashXY(int hit_x, int hit_y, int hit_z, short sectnum) int SpawnUnderSplash(short SpriteNum) { - USERp u = User[SpriteNum], wu; + USERp u = User[SpriteNum].Data(), wu; SPRITEp sp = User[SpriteNum]->SpriteP, wp; short w; @@ -20142,7 +20142,7 @@ SpawnUnderSplash(short SpriteNum) w = SpawnSprite(STAT_MISSILE, SPLASH, s_Splash, sp->sectnum, sp->x, sp->y, u->hiz, sp->ang, 0); wp = &sprite[w]; - wu = User[w]; + wu = User[w].Data(); if (sectu && TEST(sectp->extra, SECTFX_LIQUID_MASK) == SECTFX_LIQUID_LAVA) wu->spal = wp->pal = PALETTE_RED_LIGHTING; @@ -20158,7 +20158,7 @@ SpawnUnderSplash(short SpriteNum) bool MissileHitDiveArea(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; // correctly set underwater bit for missiles @@ -20233,7 +20233,7 @@ SpawnBubble(short SpriteNum) b = SpawnSprite(STAT_MISSILE, BUBBLE, s_Bubble, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0); bp = &sprite[b]; - bu = User[b]; + bu = User[b].Data(); //PlaySound(DIGI_BUBBLES, sp, v3df_none); @@ -20258,7 +20258,7 @@ int DoVehicleSmoke(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); sp->z -= sp->zvel; @@ -20293,7 +20293,7 @@ SpawnVehicleSmoke(short SpriteNum) sp->x, sp->y, sp->z - RANDOM_P2(Z(8)), sp->ang, 0); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); nu->WaitTics = 1*120; np->shade = -40; @@ -20327,7 +20327,7 @@ SpawnSmokePuff(short SpriteNum) sp->x, sp->y, sp->z - RANDOM_P2(Z(8)), sp->ang, 0); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); nu->WaitTics = 1*120; np->shade = -40; @@ -20356,7 +20356,7 @@ int DoBubble(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); sp->z -= sp->zvel; sp->zvel += 32; @@ -20489,7 +20489,7 @@ bool TestDontStick(short SpriteNum, short hit_wall) if (hit_wall < 0) { ASSERT(SpriteNum>=0); - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); hit_wall = NORM_WALL(u->ret); } @@ -20528,10 +20528,7 @@ int QueueStar(short SpriteNum) if (StarQueue[StarQueueHead] == -1) { // new star - if (User[SpriteNum]) - { - FreeUser(SpriteNum); - } + User[SpriteNum].Clear(); change_sprite_stat(SpriteNum, STAT_STAR_QUEUE); StarQueue[StarQueueHead] = SpriteNum; } @@ -20622,7 +20619,7 @@ int QueueFloorBlood(short hit_sprite) SPRITEp hsp = &sprite[hit_sprite]; short SpriteNum; SPRITEp sp; - USERp u = User[hit_sprite]; + USERp u = User[hit_sprite].Data(); SECTORp sectp = §or[hsp->sectnum]; @@ -20696,7 +20693,7 @@ int QueueFootPrint(short hit_sprite) SPRITEp hsp = &sprite[hit_sprite]; short SpriteNum; SPRITEp sp; - USERp u = User[hit_sprite]; + USERp u = User[hit_sprite].Data(); USERp nu; short rnd_num=0; bool Found=false; @@ -20754,7 +20751,7 @@ int QueueFootPrint(short hit_sprite) sp = &sprite[SpriteNum]; - nu = User[SpriteNum]; + nu = User[SpriteNum].Data(); sp->hitag = 0; sp->owner = -1; sp->xrepeat = 48; @@ -20826,7 +20823,7 @@ int QueueWallBlood(short hit_sprite, short ang) short rndnum; int daz; hitdata_t hitinfo; - USERp u = User[hit_sprite]; + USERp u = User[hit_sprite].Data(); if (TEST(u->Flags, SPR_UNDERWATER) || SpriteInUnderwaterArea(hsp) || SpriteInDiveArea(hsp)) @@ -21044,10 +21041,7 @@ int QueueGeneric(short SpriteNum, short pic) // can and should kill the user portion if (GenericQueue[GenericQueueHead] == -1) { - if (User[SpriteNum]) - { - FreeUser(SpriteNum); - } + User[SpriteNum].Clear(); change_sprite_stat(SpriteNum, STAT_GENERIC_QUEUE); GenericQueue[GenericQueueHead] = SpriteNum; } @@ -21103,7 +21097,7 @@ int DoShellShrap(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); // If the shell doesn't fall in the allowable range, kill it. if (u->ShellNum < (ShellCount-MAXSHELLS)) @@ -21148,7 +21142,7 @@ int DoShrapVelocity(int16_t SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags, SPR_UNDERWATER) || SpriteInUnderwaterArea(sp)) { @@ -21319,7 +21313,7 @@ int ShrapKillSprite(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); short rnd_num; rnd_num = RANDOM_RANGE(1024); @@ -21487,7 +21481,7 @@ int DoItemFly(int16_t SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (TEST(u->Flags, SPR_UNDERWATER)) { @@ -21616,7 +21610,7 @@ int QueueLoWangs(short SpriteNum) // Point passed in sprite to ps ps = sp; sp = &sprite[NewSprite]; - u = User[NewSprite]; + u = User[NewSprite].Data(); ASSERT(sp); sp->owner = -1; sp->cstat = 0; diff --git a/source/games/sw/src/zilla.cpp b/source/games/sw/src/zilla.cpp index 65d12a03b..37e234bb0 100644 --- a/source/games/sw/src/zilla.cpp +++ b/source/games/sw/src/zilla.cpp @@ -649,12 +649,12 @@ SetupZilla(short SpriteNum) if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum]; + u = User[SpriteNum].Data(); ASSERT(u); } else { - User[SpriteNum] = u = SpawnUser(SpriteNum,ZILLA_RUN_R0,s_ZillaRun[0]); + u = SpawnUser(SpriteNum,ZILLA_RUN_R0,s_ZillaRun[0]); u->Health = 6000; } @@ -680,7 +680,7 @@ SetupZilla(short SpriteNum) int NullZilla(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); SPRITEp sp = User[SpriteNum]->SpriteP; //if (TEST(u->Flags,SPR_SLIDING)) @@ -713,7 +713,7 @@ int NullZilla(short SpriteNum) int DoZillaMove(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); short choose; //if (TEST(u->Flags,SPR_SLIDING)) @@ -763,7 +763,7 @@ extern int SpawnGrenadeExp(int16_t Weapon); int DoZillaDeathMelt(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (RANDOM_RANGE(1000) > 800) SpawnGrenadeExp(SpriteNum); diff --git a/source/games/sw/src/zombie.cpp b/source/games/sw/src/zombie.cpp index 454e3e5b5..ca003308b 100644 --- a/source/games/sw/src/zombie.cpp +++ b/source/games/sw/src/zombie.cpp @@ -752,7 +752,7 @@ int SetupZombie(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); ANIMATOR DoActorDecide; u->Health = 100; @@ -790,7 +790,7 @@ SpawnZombie(PLAYERp pp, short Weapon) New = SpawnSprite(STAT_ENEMY, ZOMBIE_RUN_R0, s_ZombieRun[0], pp->cursectnum, pp->posx, pp->posy, pp->posz, pp->angle.ang.asbuild(), 0); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); np->sectnum = pp->cursectnum; np->owner = owner; np->pal = nu->spal = User[owner]->spal; @@ -853,7 +853,7 @@ SpawnZombie2(short Weapon) //Zombies++; New = SpawnSprite(STAT_ENEMY, ZOMBIE_RUN_R0, s_ZombieRun[0], sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0); np = &sprite[New]; - nu = User[New]; + nu = User[New].Data(); nu->Counter3 = 0; np->owner = owner; np->pal = nu->spal = User[owner]->spal; @@ -882,7 +882,7 @@ SpawnZombie2(short Weapon) int DoZombieMove(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (u->Counter3++ >= ZOMBIE_TIME_LIMIT) { @@ -893,7 +893,7 @@ DoZombieMove(short SpriteNum) return 0; } - if (u->tgt_sp && User[u->tgt_sp-sprite] && TEST(User[u->tgt_sp-sprite]->Flags, PF_DEAD)) // JBF: added User[] null check + if (u->tgt_sp && User[u->tgt_sp-sprite].Data() && TEST(User[u->tgt_sp-sprite]->Flags, PF_DEAD)) // JBF: added User[] null check DoActorPickClosePlayer(SpriteNum); // jumping and falling @@ -932,7 +932,7 @@ DoZombieMove(short SpriteNum) int NullZombie(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); if (u->Counter3++ >= ZOMBIE_TIME_LIMIT) { @@ -943,7 +943,7 @@ NullZombie(short SpriteNum) return 0; } - if (u->tgt_sp && User[u->tgt_sp-sprite] && TEST(User[u->tgt_sp-sprite]->Flags, PF_DEAD)) + if (u->tgt_sp && User[u->tgt_sp-sprite].Data() && TEST(User[u->tgt_sp-sprite]->Flags, PF_DEAD)) DoActorPickClosePlayer(SpriteNum); if (u->WaitTics > 0) @@ -963,7 +963,7 @@ NullZombie(short SpriteNum) int DoZombiePain(short SpriteNum) { - USERp u = User[SpriteNum]; + USERp u = User[SpriteNum].Data(); NullZombie(SpriteNum); From 32955621f873ebe74b5bbe6acb7c36f4aadded81 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 8 Dec 2020 17:16:50 +0100 Subject: [PATCH 04/18] - removed all parental lock garbage from SW. Better get rid of it as it's a major complication as implemented. --- source/games/sw/src/bunny.cpp | 8 +- source/games/sw/src/draw.cpp | 15 -- source/games/sw/src/game.cpp | 5 - source/games/sw/src/game.h | 1 - source/games/sw/src/jsector.cpp | 305 -------------------------------- source/games/sw/src/jsector.h | 3 - source/games/sw/src/panel.cpp | 2 +- source/games/sw/src/parent.h | 31 ---- source/games/sw/src/save.cpp | 63 ------- source/games/sw/src/scrip2.cpp | 52 ------ source/games/sw/src/sounds.cpp | 11 +- source/games/sw/src/sprite.cpp | 2 +- 12 files changed, 4 insertions(+), 494 deletions(-) diff --git a/source/games/sw/src/bunny.cpp b/source/games/sw/src/bunny.cpp index 9ddf29879..20cfe4c7d 100644 --- a/source/games/sw/src/bunny.cpp +++ b/source/games/sw/src/bunny.cpp @@ -1085,11 +1085,6 @@ DoBunnyQuickJump(short SpriteNum) NewStateGroup(SpriteNum, sg_BunnyScrew); NewStateGroup(hit_sprite, sg_BunnyScrew); - if (adult_lockout) - { - SET(sp->cstat, CSTAT_SPRITE_INVISIBLE); // Turn em' invisible - SET(tsp->cstat, CSTAT_SPRITE_INVISIBLE); // Turn em' invisible - } u->WaitTics = tu->WaitTics = SEC(10); // Mate for this long return true; } @@ -1476,8 +1471,7 @@ DoBunnyScrew(short SpriteNum) if (RANDOM_RANGE(1000) > 990) // Bunny sex sounds { - if (!adult_lockout) - PlaySound(DIGI_BUNNYATTACK, sp, v3df_follow); + PlaySound(DIGI_BUNNYATTACK, sp, v3df_follow); } u->WaitTics -= ACTORMOVETICS; diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index 50a7054f4..2a83b008f 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -594,21 +594,6 @@ analyzesprites(int viewx, int viewy, int viewz, bool mirror) continue; } - // Diss any parentally locked sprites - if (adult_lockout) - { - if (aVoxelArray[tsp->picnum].Parental == 6145) - { - tsp->owner = -1; - tu = NULL; - } - else if (aVoxelArray[tsp->picnum].Parental > 0) - { - ASSERT(aVoxelArray[tsp->picnum].Parental >= 0 && aVoxelArray[tsp->picnum].Parental < 6145); - tsp->picnum=aVoxelArray[tsp->picnum].Parental; // Change the pic - } - } - if (tu) { if (tsp->statnum != STAT_DEFAULT) diff --git a/source/games/sw/src/game.cpp b/source/games/sw/src/game.cpp index c52b74690..fb32cd3b2 100644 --- a/source/games/sw/src/game.cpp +++ b/source/games/sw/src/game.cpp @@ -232,7 +232,6 @@ void GameInterface::app_init() INITLIST(&Player[i].PanelSpriteList); LoadKVXFromScript("swvoxfil.txt"); // Load voxels from script file - LoadPLockFromScript("swplock.txt"); // Get Parental Lock setup info LoadCustomInfoFromScript("engine/swcustom.txt"); // load the internal definitions. These also apply to the shareware version. if (!SW_SHAREWARE) LoadCustomInfoFromScript("swcustom.txt"); // Load user customisation information @@ -397,8 +396,6 @@ void InitLevel(MapRecord *maprec) PlayerPanelSetup(); SectorSetup(); JS_InitMirrors(); - JS_InitLockouts(); // Setup the lockout linked lists - JS_ToggleLockouts(); // Init lockouts on/off PlaceSectorObjectsOnTracks(); PlaceActorsOnTracks(); @@ -538,8 +535,6 @@ void TerminateLevel(void) INITLIST(&pp->PanelSpriteList); } - - JS_UnInitLockouts(); } diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index bf48332ae..8225d3463 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -2147,7 +2147,6 @@ int GetZadjustment(short sectnum,short hitag); // rooms.c void InitSetup(void); // setup.c void LoadKVXFromScript(const char *filename); // scrip2.c -void LoadPLockFromScript(const char *filename); // scrip2.c void LoadCustomInfoFromScript(const char *filename); // scrip2.c int PlayerInitChemBomb(PLAYERp pp); // jweapon.c diff --git a/source/games/sw/src/jsector.cpp b/source/games/sw/src/jsector.cpp index a44326e8f..05c6fc3d3 100644 --- a/source/games/sw/src/jsector.cpp +++ b/source/games/sw/src/jsector.cpp @@ -1080,311 +1080,6 @@ JAnalyzeSprites(tspriteptr_t tspr) } } -////////////////////////////////////////////////////////////////////////////////////////////// -// Parental Lockout Stuff -////////////////////////////////////////////////////////////////////////////////////////////// -OrgTileList orgwalllist; // The list containing orginal wall -// pics -OrgTileList orgwalloverlist; // The list containing orginal wall -// over pics -OrgTileList orgsectorceilinglist; // The list containing orginal sector -// ceiling pics -OrgTileList orgsectorfloorlist; // The list containing orginal sector -// floor pics - -void -InsertOrgTile(OrgTileP tp, OrgTileListP thelist) -{ - ASSERT(tp); - - // if list is empty, insert at front - if (EMPTY(thelist)) - { - INSERT(thelist, tp); - return; - } - - // Otherwise insert it at end - INSERT_TAIL(thelist, tp); - return; -} - - -OrgTileP -InitOrgTile(OrgTileListP thelist) -{ - OrgTileP tp; - - - tp = (OrgTileP)CallocMem(sizeof(OrgTile), 1); - - ASSERT(tp); - - InsertOrgTile(tp, thelist); - - return tp; -} - -void -KillOrgTile(OrgTileP tp) -{ - ASSERT(tp); - - REMOVE(tp); - - FreeMem(tp); -} - -OrgTileP -FindOrgTile(short index, OrgTileListP thelist) -{ - OrgTileP tp, next_tp; - - if (EMPTY(thelist)) - return NULL; - - TRAVERSE(thelist, tp, next_tp) - { - if (tp->index == index) - return tp; - } - - return NULL; -} - -// Call this at terminate game time -void -JS_UnInitLockouts(void) -{ - OrgTileP tp=NULL, next_tp=NULL; - - if (orgwalllist.Next) - { - TRAVERSE(&orgwalllist, tp, next_tp) - { - KillOrgTile(tp); - } - } - if (orgwalloverlist.Next) - { - TRAVERSE(&orgwalloverlist, tp, next_tp) - { - KillOrgTile(tp); - } - } - if (orgsectorceilinglist.Next) - { - TRAVERSE(&orgsectorceilinglist, tp, next_tp) - { - KillOrgTile(tp); - } - } - if (orgsectorfloorlist.Next) - { - TRAVERSE(&orgsectorfloorlist, tp, next_tp) - { - KillOrgTile(tp); - } - } -} - -///////////////////////////////////////////////////// -// Initialize the original tiles list -// Creates a list of all orginal tiles and their -// replacements. Several tiles can use the same -// replacement tilenum, so the list is built -// using the original tilenums as a basis for -// memory allocation -// t == 1 - wall -// t == 2 - overpicnum -// t == 3 - ceiling -// t == 4 - floor -///////////////////////////////////////////////////// -void -JS_PlockError(short wall_num, short t) -{ - Printf("ERROR: JS_InitLockouts(), out of range tile number\n"); - switch (t) - { - case 1: - Printf("wall %d, x %d, y %d, pic %d\n", wall_num, wall[wall_num].x, wall[wall_num].y, wall[wall_num].picnum); - break; - case 2: - Printf("wall %d, x %d, y %d, OVERpic %d\n", wall_num, wall[wall_num].x, wall[wall_num].y, wall[wall_num].overpicnum); - break; - case 3: - Printf("sector %d, ceiling %d\n", wall_num, sector[wall_num].ceilingpicnum); - break; - case 4: - Printf("sector %d, floor %d\n", wall_num, sector[wall_num].floorpicnum); - break; - } -} - -void -JS_InitLockouts(void) -{ - short i; - OrgTileP tp; - - INITLIST(&orgwalllist); // The list containing orginal wall - // pics - INITLIST(&orgwalloverlist); // The list containing orginal wall - // over pics - INITLIST(&orgsectorceilinglist); // The list containing orginal sector - // ceiling pics - INITLIST(&orgsectorfloorlist); // The list containing orginal sector - // floor pics - - // Check all walls - for (i = 0; i < numwalls; i++) - { - short picnum; - - picnum = wall[i].picnum; - if (aVoxelArray[picnum].Parental >= INVISTILE) - { - JS_PlockError(i, 1); - continue; - } - - if (aVoxelArray[picnum].Parental >= 0) - { - if ((tp = FindOrgTile(i, &orgwalllist)) == NULL) - tp = InitOrgTile(&orgwalllist); - tp->index = i; - tp->orgpicnum = wall[i].picnum; - } - - picnum = wall[i].overpicnum; - if (aVoxelArray[picnum].Parental >= INVISTILE) - { - JS_PlockError(i, 2); - continue; - } - - if (aVoxelArray[picnum].Parental >= 0) - { - if ((tp = FindOrgTile(i, &orgwalloverlist)) == NULL) - tp = InitOrgTile(&orgwalloverlist); - tp->index = i; - tp->orgpicnum = wall[i].overpicnum; - } - } - // Check all ceilings and floors - for (i = 0; i < numsectors; i++) - { - short picnum; - - picnum = sector[i].ceilingpicnum; - if (aVoxelArray[picnum].Parental >= INVISTILE) - { - JS_PlockError(i, 3); - continue; - } - - if (aVoxelArray[picnum].Parental >= 0) - { - if ((tp = FindOrgTile(i, &orgsectorceilinglist)) == NULL) - tp = InitOrgTile(&orgsectorceilinglist); - tp->index = i; - tp->orgpicnum = sector[i].ceilingpicnum; - } - - picnum = sector[i].floorpicnum; - if (aVoxelArray[picnum].Parental >= INVISTILE) - { - JS_PlockError(i, 2); - continue; - } - - if (aVoxelArray[picnum].Parental >= 0) - { - if ((tp = FindOrgTile(i, &orgsectorfloorlist)) == NULL) - tp = InitOrgTile(&orgsectorfloorlist); - tp->index = i; - tp->orgpicnum = sector[i].floorpicnum; - } - } -} - -///////////////////////////////////////////////////// -// Switch back and forth between locked out stuff -///////////////////////////////////////////////////// -void -JS_ToggleLockouts(void) -{ - short i; - OrgTileP tp; - - - // Check all walls - for (i = 0; i < numwalls; i++) - { - short picnum; - - if (adult_lockout) - { - picnum = wall[i].picnum; - ASSERT(aVoxelArray[picnum].Parental < INVISTILE); // Invalid, walls can't - // be invisible - if (aVoxelArray[picnum].Parental >= 0) - { - wall[i].picnum = aVoxelArray[picnum].Parental; - } - } - else if ((tp = FindOrgTile(i, &orgwalllist)) != NULL) - wall[i].picnum = tp->orgpicnum; // Restore them - - - if (adult_lockout) - { - picnum = wall[i].overpicnum; - ASSERT(aVoxelArray[picnum].Parental < INVISTILE); // Invalid, walls can't - // be invisible - if (aVoxelArray[picnum].Parental >= 0) - { - wall[i].overpicnum = aVoxelArray[picnum].Parental; - } - } - else if ((tp = FindOrgTile(i, &orgwalloverlist)) != NULL) - wall[i].overpicnum = tp->orgpicnum; // Restore them - } - - // Check all sectors - for (i = 0; i < numsectors; i++) - { - short picnum; - - if (adult_lockout) - { - picnum = sector[i].ceilingpicnum; - ASSERT(aVoxelArray[picnum].Parental < INVISTILE); // Invalid, walls can't - // be invisible - if (aVoxelArray[picnum].Parental >= 0) - { - sector[i].ceilingpicnum = aVoxelArray[picnum].Parental; - } - } - else if ((tp = FindOrgTile(i, &orgsectorceilinglist)) != NULL) - sector[i].ceilingpicnum = tp->orgpicnum; // Restore them - - - if (adult_lockout) - { - picnum = sector[i].floorpicnum; - ASSERT(aVoxelArray[picnum].Parental < INVISTILE); // Invalid, walls can't - // be invisible - if (aVoxelArray[picnum].Parental >= 0) - { - sector[i].floorpicnum = aVoxelArray[picnum].Parental; - } - } - else if ((tp = FindOrgTile(i, &orgsectorfloorlist)) != NULL) - sector[i].floorpicnum = tp->orgpicnum; // Restore them - } -} - //////////////////////////////////////////////////////////////////////////////////////////////// void diff --git a/source/games/sw/src/jsector.h b/source/games/sw/src/jsector.h index c7a0ec571..9385b0cf8 100644 --- a/source/games/sw/src/jsector.h +++ b/source/games/sw/src/jsector.h @@ -73,9 +73,6 @@ void JAnalyzeSprites(tspriteptr_t tspr); void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz); void JS_DrawMirrors(PLAYERp pp,int tx,int ty,int tz,fixed_t tpq16ang,fixed_t tpq16horiz); void JS_InitMirrors(void); -void JS_InitLockouts(void); -void JS_ToggleLockouts(void); -void JS_UnInitLockouts(void); void JS_ProcessEchoSpot(void); void JS_SpriteSetup(void); diff --git a/source/games/sw/src/panel.cpp b/source/games/sw/src/panel.cpp index 54c825e8b..3e7094f84 100644 --- a/source/games/sw/src/panel.cpp +++ b/source/games/sw/src/panel.cpp @@ -6956,7 +6956,7 @@ pDisplaySprites(PLAYERp pp, double smoothratio) break; } - if (pp->Bloody && !adult_lockout) + if (pp->Bloody) { switch (picnum) { diff --git a/source/games/sw/src/parent.h b/source/games/sw/src/parent.h index dac70f152..7dfae7be1 100644 --- a/source/games/sw/src/parent.h +++ b/source/games/sw/src/parent.h @@ -34,40 +34,9 @@ BEGIN_SW_NS typedef struct TILE_INFO_TYPE { short Voxel; // Voxel Number to replace sprites with - short Parental; // Tile offset to replace adult tiles with when locked out // 0 = Invisible } ParentalStruct; -struct ORG_TILE; -typedef struct ORG_TILE OrgTile, *OrgTileP; -struct ORG_TILE_LIST; -typedef struct ORG_TILE_LIST OrgTileList, *OrgTileListP; - -void JS_InitLockouts(void); -void JS_UnitInitLockouts(void); -void JS_ToggleLockouts(void); - -struct ORG_TILE -{ - OrgTileP Next, Prev; - short index; - short orgpicnum; -}; - -struct ORG_TILE_LIST -{ - OrgTileP Next, Prev; -}; - -extern OrgTileList orgwalllist; // The list containing orginal wall -// pics -extern OrgTileList orgwalloverlist; // The list containing orginal wall -// over pics -extern OrgTileList orgsectorceilinglist; // The list containing orginal sector -// ceiling pics -extern OrgTileList orgsectorfloorlist; // The list containing orginal sector -// floor pics - END_SW_NS #endif diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index 61a66e134..ec3391408 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -88,8 +88,6 @@ extern short BossSpriteNum[3]; extern STATE s_NotRestored[]; -OrgTileListP otlist[] = {&orgwalllist, &orgwalloverlist, &orgsectorceilinglist, &orgsectorfloorlist}; - int PanelSpriteToNdx(PLAYERp pp, PANEL_SPRITEp psprite) { short ndx = 0; @@ -219,7 +217,6 @@ bool GameInterface::SaveGame() PANEL_SPRITEp psp,cur,next; SECTOR_OBJECTp sop; int saveisshot=0; - OrgTileP otp, next_otp; Saveable_Init(); @@ -565,20 +562,6 @@ bool GameInterface::SaveGame() saveisshot |= so_writeinterpolations(fil); assert(!saveisshot); - // parental lock - for (i = 0; i < (int)SIZ(otlist); i++) - { - ndx = 0; - TRAVERSE(otlist[i], otp, next_otp) - { - MWRITE(&ndx,sizeof(ndx),1,fil); - MWRITE(&otp,sizeof(*otp),1,fil); - ndx++; - } - ndx = -1; - MWRITE(&ndx, sizeof(ndx),1,fil); - } - // mirror MWRITE(mirror,sizeof(mirror),1,fil); MWRITE(&mirrorcnt,sizeof(mirrorcnt),1,fil); @@ -636,7 +619,6 @@ bool GameInterface::LoadGame() SECT_USERp sectu; ANIMp a; PANEL_SPRITEp psp,next; - OrgTileP otp; Saveable_Init(); @@ -756,31 +738,6 @@ bool GameInterface::LoadGame() MREAD(u,sizeof(USER),1,fil); memset((void*)&u->rotator, 0, sizeof(u->rotator)); -#if 0 - if (u->WallShade) - { - u->WallShade = (int8_t*)CallocMem(u->WallCount * sizeof(*u->WallShade), 1); - MREAD(u->WallShade, sizeof(*u->WallShade) * u->WallCount, 1, fil); - } - - if (u->rotator) - { - u->rotator.Alloc(); - MREAD(u->rotator,sizeof(*u->rotator),1,fil); - - if (u->rotator->origx) - { - u->rotator->origx = (int*)CallocMem(u->rotator->num_walls * sizeof(*u->rotator->origx), 1); - MREAD(u->rotator->origx,sizeof(*u->rotator->origx)*u->rotator->num_walls,1,fil); - } - if (u->rotator->origy) - { - u->rotator->origy = (int*)CallocMem(u->rotator->num_walls * sizeof(*u->rotator->origy), 1); - MREAD(u->rotator->origy,sizeof(*u->rotator->origy)*u->rotator->num_walls,1,fil); - } - } -#endif - saveisshot |= LoadSymDataInfo(fil, (void **)&u->WallP); saveisshot |= LoadSymDataInfo(fil, (void **)&u->State); saveisshot |= LoadSymDataInfo(fil, (void **)&u->Rot); @@ -911,26 +868,6 @@ bool GameInterface::LoadGame() saveisshot |= so_readinterpolations(fil); if (saveisshot) { MCLOSE_READ(fil); return false; } - // parental lock - for (i = 0; i < (int)SIZ(otlist); i++) - { - INITLIST(otlist[i]); - - while (true) - { - MREAD(&ndx, sizeof(ndx),1,fil); - - if (ndx == -1) - break; - - otp = (OrgTileP)CallocMem(sizeof(*otp), 1); - ASSERT(otp); - - MREAD(otp, sizeof(*otp),1,fil); - INSERT_TAIL(otlist[i],otp); - } - } - // mirror MREAD(mirror,sizeof(mirror),1,fil); MREAD(&mirrorcnt,sizeof(mirrorcnt),1,fil); diff --git a/source/games/sw/src/scrip2.cpp b/source/games/sw/src/scrip2.cpp index d008ea556..30774a115 100644 --- a/source/games/sw/src/scrip2.cpp +++ b/source/games/sw/src/scrip2.cpp @@ -199,11 +199,6 @@ void LoadKVXFromScript(const char* filename) // zero out the array memory with -1's for pics not being voxelized memset(&aVoxelArray[0], -1, sizeof(struct TILE_INFO_TYPE) * MAXTILES); - for (grabbed = 0; grabbed < MAXTILES; grabbed++) - { - aVoxelArray[grabbed].Voxel = -1; - aVoxelArray[grabbed].Parental = -1; - } grabbed = 0; @@ -249,53 +244,6 @@ void LoadKVXFromScript(const char* filename) script_p = NULL; } -// Load in info for all Parental lock tile targets -// # - Comment -// tilenumber (in artfile), replacement tile offset (if any) -// Ex. 1803 -1 -1 = No tile replacement -// 1804 2000 -// etc.... -void LoadPLockFromScript(const char *filename) -{ - int lNumber=0,lTile=0; // lNumber is the voxel no. and lTile is the editart tile being - // replaced. - - int grabbed=0; // Number of lines parsed - - // Load the file - auto buffer = LoadScriptFile(filename); - if (!buffer.Size()) - { - return; - } - script_p = (char*)buffer.Data(); - scriptend_p = (char*)&buffer.Last(); - - do - { - GetToken(true); // Crossing a line boundary on the end of line to first token - // of a new line is permitted (and expected) - if (endofscript) - break; - - lTile = atoi(token); - - GetToken(false); - lNumber = atoi(token); - - // Store the sprite and voxel numbers for later use - aVoxelArray[lTile].Parental = lNumber; // Replacement to tile, -1 for none - - grabbed++; - ASSERT(grabbed < MAXSPRITES); - - } - while (script_p < scriptend_p); - - script_p = NULL; -} - - /* * Here begins JonoF's modding enhancement stuff */ diff --git a/source/games/sw/src/sounds.cpp b/source/games/sw/src/sounds.cpp index 4733a2dc0..8d0a364b3 100644 --- a/source/games/sw/src/sounds.cpp +++ b/source/games/sw/src/sounds.cpp @@ -625,15 +625,6 @@ int _PlaySound(int num, SPRITEp sp, PLAYERp pp, vec3_t* pos, Voc3D_Flags flags, return -1; SPRITEp sps = sp; - // Weed out parental lock sounds if PLock is active - if (adult_lockout) - { - for (unsigned i = 0; i < sizeof(PLocked_Sounds); i++) - { - if (num == PLocked_Sounds[i]) - return -1; - } - } auto vp = &voc[num]; int sourcetype = SOURCE_None; @@ -693,7 +684,7 @@ int _PlaySound(int num, SPRITEp sp, PLAYERp pp, vec3_t* pos, Voc3D_Flags flags, void PlaySoundRTS(int rts_num) { - if (!adult_lockout && SoundEnabled() && RTS_IsInitialized() && snd_speech) + if (SoundEnabled() && RTS_IsInitialized() && snd_speech) { auto sid = RTS_GetSoundID(rts_num - 1); if (sid != -1) diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 7c7488e7f..8fcb74441 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -5713,7 +5713,7 @@ KeyMain: // Say something witty if (pp == Player+myconnectindex) { - int cookie = (adult_lockout)? STD_RANDOM_RANGE(10) : STD_RANDOM_RANGE(MAX_FORTUNES); + int cookie = STD_RANDOM_RANGE(MAX_FORTUNES); // print to the console, and the user quote display. FStringf msg("%s %s", GStrings("TXTS_FORTUNE"), quoteMgr.GetQuote(QUOTE_COOKIE + cookie)); Printf(PRINT_NONOTIFY, TEXTCOLOR_SAPPHIRE "%s\n", msg.GetChars()); From 8fee2b3ed760513069f089d9846c9c7025a1bfd3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 2 Apr 2021 11:55:23 +0200 Subject: [PATCH 05/18] - save SW's User array as JSON. --- source/common/engine/serializer.h | 2 +- source/core/savegamehelp.h | 25 ++ source/games/sw/src/game.h | 3 +- source/games/sw/src/save.cpp | 467 ++++++++++++++++++++++-------- 4 files changed, 379 insertions(+), 118 deletions(-) diff --git a/source/common/engine/serializer.h b/source/common/engine/serializer.h index b22d0e11b..400a6f4aa 100644 --- a/source/common/engine/serializer.h +++ b/source/common/engine/serializer.h @@ -269,7 +269,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, TArray &value, return arc; } -template +template FSerializer& Serialize(FSerializer& arc, const char* key, TPointer& value, TPointer* def) { if (arc.isWriting()) diff --git a/source/core/savegamehelp.h b/source/core/savegamehelp.h index 94317e32a..d283a181c 100644 --- a/source/core/savegamehelp.h +++ b/source/core/savegamehelp.h @@ -27,3 +27,28 @@ void M_Autosave(); #define SAVEGAME_EXT ".dsave" + +inline FSerializer& Serialize(FSerializer& arc, const char* keyname, spritetype*& w, spritetype** def) +{ + int ndx = w ? int(w - sprite) : -1; + arc(keyname, ndx); + w = ndx == -1 ? nullptr : sprite + ndx; + return arc; +} + +inline FSerializer& Serialize(FSerializer& arc, const char* keyname, sectortype*& w, sectortype** def) +{ + int ndx = w ? int(w - sector) : -1; + arc(keyname, ndx); + w = ndx == -1 ? nullptr : sector + ndx; + return arc; +} + +inline FSerializer& Serialize(FSerializer& arc, const char* keyname, walltype*& w, walltype** def) +{ + int ndx = w ? int(w - wall) : -1; + arc(keyname, ndx); + w = ndx == -1 ? nullptr : wall + ndx; + return arc; +} + diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 8225d3463..32dd04b6c 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -2236,7 +2236,8 @@ struct GameInterface : ::GameInterface bool CanSave() override; bool StartGame(FNewGameStartup& gs) override; FSavegameInfo GetSaveSig() override; - bool LoadGame() override; + void SerializeGameState(FSerializer& arc); + bool LoadGame() override; bool SaveGame() override; void SetAmbience(bool on) override { if (on) StartAmbientSound(); else StopAmbientSound(); } FString GetCoordString() override; diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index ec3391408..3ea4ff1d0 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -88,6 +88,357 @@ extern short BossSpriteNum[3]; extern STATE s_NotRestored[]; + + + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +FSerializer& Serialize(FSerializer& arc, const char* keyname, savedcodesym& w, savedcodesym* def) +{ + static savedcodesym nul; + if (!def) + { + def = &nul; + if (arc.isReading()) w = {}; + } + + if (arc.BeginObject(keyname)) + { + arc("module", w.module, def->module) + ("index", w.index, def->index) + .EndObject(); + } + return arc; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +FSerializer& Serialize(FSerializer& arc, const char* keyname, saveddatasym& w, saveddatasym* def) +{ + static saveddatasym nul; + if (!def) + { + def = &nul; + if (arc.isReading()) w = {}; + } + + if (arc.BeginObject(keyname)) + { + arc("module", w.module, def->module) + ("index", w.index, def->index) + ("offset", w.offset, def->offset) + .EndObject(); + } + return arc; +} + +//--------------------------------------------------------------------------- +// +// todo: make sure all saveables are arrays so we can store indices instead of offsets +// +//--------------------------------------------------------------------------- + +FSerializer& SerializeDataPtr(FSerializer& arc, const char* keyname, void*& w, size_t sizeOf) +{ + saveddatasym sym; + if (arc.isWriting()) + { + Saveable_FindDataSym(w, &sym); + arc(keyname, sym); + } + else + { + arc(keyname, sym); + Saveable_RestoreDataSym(&sym, &w); + } + return arc; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +FSerializer& SerializeCodePtr(FSerializer& arc, const char* keyname, void** w) +{ + savedcodesym sym; + if (arc.isWriting()) + { + Saveable_FindCodeSym(*w, &sym); + arc(keyname, sym); + } + else + { + arc(keyname, sym); + Saveable_RestoreCodeSym(&sym, w); + } + return arc; +} + +//--------------------------------------------------------------------------- +// +// Unfortunately this cannot be simplified with templates. +// This requires an explicit function for each pointer type. +// +//--------------------------------------------------------------------------- + +FSerializer& Serialize(FSerializer& arc, const char* keyname, PANEL_STATEp& w, PANEL_STATEp* def) +{ + return SerializeDataPtr(arc, keyname, *(void**)&w, sizeof(PANEL_STATE)); +} + +FSerializer& Serialize(FSerializer& arc, const char* keyname, STATEp& w, STATEp* def) +{ + return SerializeDataPtr(arc, keyname, *(void**)&w, sizeof(STATE)); +} + +FSerializer& Serialize(FSerializer& arc, const char* keyname, STATEp*& w, STATEp** def) +{ + return SerializeDataPtr(arc, keyname, *(void**)&w, sizeof(STATEp)); +} + +FSerializer& Serialize(FSerializer& arc, const char* keyname, ACTOR_ACTION_SETp& w, ACTOR_ACTION_SETp* def) +{ + return SerializeDataPtr(arc, keyname, *(void**)&w, sizeof(ACTOR_ACTION_SET)); +} + +FSerializer& Serialize(FSerializer& arc, const char* keyname, PERSONALITYp& w, PERSONALITYp* def) +{ + return SerializeDataPtr(arc, keyname, *(void**)&w, sizeof(PERSONALITY)); +} + +FSerializer& Serialize(FSerializer& arc, const char* keyname, ATTRIBUTEp& w, ATTRIBUTEp* def) +{ + return SerializeDataPtr(arc, keyname, *(void**)&w, sizeof(ATTRIBUTE)); +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +FSerializer& Serialize(FSerializer& arc, const char* keyname, PLAYERp& w, PLAYERp* def) +{ + int ndx = w ? int(w - Player) : -1; + arc(keyname, ndx); + w = ndx == -1 ? nullptr : Player + ndx; + return arc; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +FSerializer& Serialize(FSerializer& arc, const char* keyname, SECTOR_OBJECTp& w, SECTOR_OBJECTp* def) +{ + int ndx = w ? int(w - SectorObject) : -1; + arc(keyname, ndx); + w = ndx == -1 ? nullptr : SectorObject; + return arc; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +FSerializer& Serialize(FSerializer& arc, const char* keyname, ROTATOR& w, ROTATOR* def) +{ + if (arc.BeginObject(keyname)) + { + arc("pos", w.pos) + ("open_dest", w.open_dest) + ("tgt", w.tgt) + ("speed", w.speed) + ("orig_speed", w.orig_speed) + ("vel", w.vel) + ("origx", w.origX) + ("origy", w.origY) + .EndObject(); + } + return arc; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- +static USER nuluser; // must be outside the function to evade C++'s retarded initialization rules for static function variables. + +FSerializer& Serialize(FSerializer& arc, const char* keyname, USER& w, USER* def) +{ + if (!def) + { + def = &nuluser; + if (arc.isReading()) w = {}; + } + if (arc.BeginObject(keyname)) + { + arc("WallP", w.WallP, def->WallP) + ("State", w.State, def->State) + ("Rot", w.Rot, def->Rot) + ("StateStart", w.StateStart, def->StateStart) + ("StateEnd", w.StateEnd, def->StateEnd) + ("StateFallOverride", w.StateFallOverride, def->StateFallOverride) + ("ActorActionSet", w.ActorActionSet, def->ActorActionSet) + ("Personality", w.Personality, def->Personality) + ("Attrib", w.Attrib, def->Attrib) + ("sop_parent", w.sop_parent, def->sop_parent) + ("flags", w.Flags, def->Flags) + ("flags2", w.Flags2, def->Flags2) + ("Tics", w.Tics, def->Tics) + ("RotNum", w.RotNum, def->RotNum) + ("ID", w.ID, def->ID) + ("Health", w.Health, def->Health) + ("MaxHealth", w.MaxHealth, def->MaxHealth) + ("LastDamage", w.LastDamage, def->LastDamage) + ("PainThreshold", w.PainThreshold, def->PainThreshold) + ("jump_speed", w.jump_speed, def->jump_speed) + ("jump_grav", w.jump_grav, def->jump_grav) + ("ceiling_dist", w.ceiling_dist, def->ceiling_dist) + ("floor_dist", w.floor_dist, def->floor_dist) + ("lo_step", w.lo_step, def->lo_step) + ("hiz", w.hiz, def->hiz) + ("loz", w.loz, def->loz) + ("zclip", w.zclip, def->zclip) + ("hi_sectp", w.hi_sectp, def->hi_sectp) + ("lo_sectp", w.lo_sectp, def->lo_sectp) + ("hi_sp", w.hi_sp, def->hi_sp) + ("lo_sp", w.lo_sp, def->lo_sp) + ("active_range", w.active_range, def->active_range) + ("SpriteNum", w.SpriteNum, def->SpriteNum) + ("Attach", w.Attach, def->Attach) + ("SpriteP", w.SpriteP, def->SpriteP) + ("PlayerP", w.PlayerP, def->PlayerP) + ("Sibling", w.Sibling, def->Sibling) + ("xchange", w.xchange, def->xchange) + ("ychange", w.ychange, def->ychange) + ("zchange", w.zchange, def->zchange) + ("z_tgt", w.z_tgt, def->z_tgt) + ("vel_tgt", w.vel_tgt, def->vel_tgt) + ("vel_rate", w.vel_rate, def->vel_rate) + ("speed", w.speed, def->speed) + ("Counter", w.Counter, def->Counter) + ("Counter2", w.Counter2, def->Counter2) + ("Counter3", w.Counter3, def->Counter3) + ("DamageTics", w.DamageTics, def->DamageTics) + ("BladeDamageTics", w.BladeDamageTics, def->BladeDamageTics) + ("WpnGoal", w.WpnGoal, def->WpnGoal) + ("Radius", w.Radius, def->Radius) + ("OverlapZ", w.OverlapZ, def->OverlapZ) + ("flame", w.flame, def->flame) + ("tgt_sp", w.tgt_sp, def->tgt_sp) + ("scale_speed", w.scale_speed, def->scale_speed) + ("scale_value", w.scale_value, def->scale_value) + ("scale_tgt", w.scale_tgt, def->scale_tgt) + ("DistCheck", w.DistCheck, def->DistCheck) + ("Dist", w.Dist, def->Dist) + ("TargetDist", w.TargetDist, def->TargetDist) + ("WaitTics", w.WaitTics, def->WaitTics) + ("track", w.track, def->track) + ("point", w.point, def->point) + ("track_dir", w.track_dir, def->track_dir) + ("track_vel", w.track_vel, def->track_vel) + ("slide_ang", w.slide_ang, def->slide_ang) + ("slide_vel", w.slide_vel, def->slide_vel) + ("slide_dec", w.slide_dec, def->slide_dec) + ("motion_blur_dist", w.motion_blur_dist, def->motion_blur_dist) + ("motion_blur_num", w.motion_blur_num, def->motion_blur_num) + ("wait_active_check", w.wait_active_check, def->wait_active_check) + ("inactive_time", w.inactive_time, def->inactive_time) + ("sx", w.sx, def->sx) + ("sy", w.sy, def->sy) + ("sz", w.sz, def->sz) + ("sang", w.sang, def->sang) + ("spal", w.spal, def->spal) + ("ret", w.ret, def->ret) + ("Flag1", w.Flag1, def->Flag1) + ("LastWeaponNum", w.LastWeaponNum, def->LastWeaponNum) + ("WeaponNum", w.WeaponNum, def->WeaponNum) + ("bounce", w.bounce, def->bounce) + ("ShellNum", w.ShellNum, def->ShellNum) + ("FlagOwner", w.FlagOwner, def->FlagOwner) + ("Vis", w.Vis, def->Vis) + ("DidAlert", w.DidAlert, def->DidAlert) + ("filler", w.filler, def->filler) + ("wallshade", w.WallShade) + ("rotator", w.rotator) + ("oz", w.oz, def->oz); + + SerializeCodePtr(arc, "ActorActionFunc", (void**)&w.ActorActionFunc); + arc.EndObject(); + + if (arc.isReading()) + { + w.oangdiff = 0; + } + } + return arc; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void SerializeUser(FSerializer& arc) +{ + FixedBitArray hitlist; + + if (arc.isWriting()) + { + for (int i = 0; i < MAXSPRITES; i++) + { + hitlist.Set(i, !!User[i].Data()); + } + } + else + { + for (int i = 0; i < MAXSPRITES; i++) + { + User[i].Clear(); + } + } + arc("usermap", hitlist); + arc.SparseArray("user", User, MAXSPRITES, hitlist); +} + + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void GameInterface::SerializeGameState(FSerializer& arc) +{ + Saveable_Init(); + + if (arc.BeginObject("state")) + { + SerializeUser(arc); + + arc.EndObject(); + } +} + + + int PanelSpriteToNdx(PLAYERp pp, PANEL_SPRITEp psprite) { short ndx = 0; @@ -227,10 +578,6 @@ bool GameInterface::SaveGame() MWRITE(&Skill,sizeof(Skill),1,fil); MWRITE(&numplayers,sizeof(numplayers),1,fil); - MWRITE(&myconnectindex,sizeof(myconnectindex),1,fil); - MWRITE(&connecthead,sizeof(connecthead),1,fil); - MWRITE(connectpoint2,sizeof(connectpoint2),1,fil); - MWRITE(&crouch_toggle,sizeof(crouch_toggle),1,fil); //save players info pp = &tp; @@ -354,77 +701,6 @@ bool GameInterface::SaveGame() } } - //User information - for (i = 0; i < MAXSPRITES; i++) - { - ndx = i; - if (User[i].Data()) - { - // write header - MWRITE(&ndx,sizeof(ndx),1,fil); - -#if 0 - memcpy(&tu, User[i], sizeof(USER)); - u = &tu; - - MWRITE(u,sizeof(USER),1,fil); - - if (u->WallShade) - { - MWRITE(u->WallShade, sizeof(*u->WallShade) * u->WallCount, 1, fil); - } - - if (u->rotator) - { - MWRITE(u->rotator,sizeof(*u->rotator),1,fil); - if (u->rotator->origx) - MWRITE(u->rotator->origx,sizeof(*u->rotator->origx)*u->rotator->num_walls,1,fil); - if (u->rotator->origy) - MWRITE(u->rotator->origy,sizeof(*u->rotator->origy)*u->rotator->num_walls,1,fil); - } -#endif - - saveisshot |= SaveSymDataInfo(fil, u->WallP); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, u->State); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, u->Rot); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, u->StateStart); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, u->StateEnd); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, u->StateFallOverride); - assert(!saveisshot); - saveisshot |= SaveSymCodeInfo(fil, u->ActorActionFunc); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, u->ActorActionSet); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, u->Personality); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, u->Attrib); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, u->sop_parent); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, u->hi_sectp); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, u->lo_sectp); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, u->hi_sp); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, u->lo_sp); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, u->SpriteP); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, u->PlayerP); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, u->tgt_sp); - assert(!saveisshot); - } - } - ndx = -1; - MWRITE(&ndx,sizeof(ndx),1,fil); - // // Sector object // @@ -630,10 +906,6 @@ bool GameInterface::LoadGame() MREAD(&Skill,sizeof(Skill),1,fil); MREAD(&numplayers, sizeof(numplayers),1,fil); - MREAD(&myconnectindex,sizeof(myconnectindex),1,fil); - MREAD(&connecthead,sizeof(connecthead),1,fil); - MREAD(connectpoint2,sizeof(connectpoint2),1,fil); - MREAD(&crouch_toggle,sizeof(crouch_toggle),1,fil); //save players //MREAD(Player,sizeof(PLAYER), numplayers,fil); @@ -724,43 +996,6 @@ bool GameInterface::LoadGame() } } - //User information - memset(User, 0, sizeof(User)); - - MREAD(&SpriteNum, sizeof(SpriteNum),1,fil); - while (SpriteNum != -1) - { - User[SpriteNum].Alloc(); - u = User[SpriteNum].Data(); - // We need to be careful with allocated content in User when loading a binary save state. - // This needs to be refactored out ASAP. - u->rotator.Clear(); - MREAD(u,sizeof(USER),1,fil); - memset((void*)&u->rotator, 0, sizeof(u->rotator)); - - saveisshot |= LoadSymDataInfo(fil, (void **)&u->WallP); - saveisshot |= LoadSymDataInfo(fil, (void **)&u->State); - saveisshot |= LoadSymDataInfo(fil, (void **)&u->Rot); - saveisshot |= LoadSymDataInfo(fil, (void **)&u->StateStart); - saveisshot |= LoadSymDataInfo(fil, (void **)&u->StateEnd); - saveisshot |= LoadSymDataInfo(fil, (void **)&u->StateFallOverride); - saveisshot |= LoadSymCodeInfo(fil, (void **)&u->ActorActionFunc); - saveisshot |= LoadSymDataInfo(fil, (void **)&u->ActorActionSet); - saveisshot |= LoadSymDataInfo(fil, (void **)&u->Personality); - saveisshot |= LoadSymDataInfo(fil, (void **)&u->Attrib); - saveisshot |= LoadSymDataInfo(fil, (void **)&u->sop_parent); - saveisshot |= LoadSymDataInfo(fil, (void **)&u->hi_sectp); - saveisshot |= LoadSymDataInfo(fil, (void **)&u->lo_sectp); - saveisshot |= LoadSymDataInfo(fil, (void **)&u->hi_sp); - saveisshot |= LoadSymDataInfo(fil, (void **)&u->lo_sp); - saveisshot |= LoadSymDataInfo(fil, (void **)&u->SpriteP); - saveisshot |= LoadSymDataInfo(fil, (void **)&u->PlayerP); - saveisshot |= LoadSymDataInfo(fil, (void **)&u->tgt_sp); - if (saveisshot) { MCLOSE_READ(fil); return false; } - - MREAD(&SpriteNum,sizeof(SpriteNum),1,fil); - } - MREAD(SectorObject, sizeof(SectorObject),1,fil); for (ndx = 0; ndx < (short)SIZ(SectorObject); ndx++) From 9bae2295cc354eb89616aabcc82db53c053abf30 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 2 Apr 2021 12:00:38 +0200 Subject: [PATCH 06/18] - better USER clearing. --- source/games/sw/src/game.h | 13 ++++++++----- source/games/sw/src/save.cpp | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 32dd04b6c..3f178620f 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1134,14 +1134,17 @@ using ROTATORp = ROTATOR*; struct USER { - // These are for easy zero-init of USERs without having to be on the lookout for non-trivial members. - void* operator new(size_t alloc) + // C++'s default init rules suck, so we have to help it out a bit to do what we need (i.e. setting all POD members to 0. + USER() { - return M_Calloc(alloc, 1); + memset(&WallP, 0, sizeof(USER) - myoffsetof(USER, WallP)); } - void operator delete (void* mem) + + void Clear() { - M_Free(mem); + rotator.Clear(); + WallShade.Clear(); + memset(&WallP, 0, sizeof(USER) - myoffsetof(USER, WallP)); } // diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index 3ea4ff1d0..269c45273 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -284,7 +284,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, USER& w, USER* def if (!def) { def = &nuluser; - if (arc.isReading()) w = {}; + if (arc.isReading()) w.Clear(); } if (arc.BeginObject(keyname)) { From 06b03f7301cf005c6711874e06b95f498e5e5879 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 2 Apr 2021 12:30:46 +0200 Subject: [PATCH 07/18] - SW: save the player and related data as JSON. --- source/games/sw/src/cheats.cpp | 4 +- source/games/sw/src/game.h | 9 +- source/games/sw/src/save.cpp | 662 +++++++++++++++++++-------------- 3 files changed, 395 insertions(+), 280 deletions(-) diff --git a/source/games/sw/src/cheats.cpp b/source/games/sw/src/cheats.cpp index 8fff46163..a5f74bea7 100644 --- a/source/games/sw/src/cheats.cpp +++ b/source/games/sw/src/cheats.cpp @@ -196,7 +196,7 @@ static cheatseq_t swcheats[] = { static void WeaponCheat(int player) { auto p = &Player[player]; - auto u = User[p->PlayerSprite]; + auto u = User[p->PlayerSprite].Data(); if (!TEST(p->Flags, PF_TWO_UZI)) { @@ -280,7 +280,7 @@ static void cmd_Give(int player, uint8_t** stream, bool skip) case GIVE_AMMO: { auto p = &Player[player]; - auto u = User[p->PlayerSprite]; + auto u = User[p->PlayerSprite].Data(); p->WpnShotgunAuto = 50; p->WpnRocketHeat = 5; diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 3f178620f..61b30374a 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -851,13 +851,6 @@ struct PLAYERstruct int slide_dec; float drive_avel; - - - // scroll 2D mode stuff - int scr_x, scr_y, oscr_x, oscr_y; - int scr_xvect, scr_yvect; - short scr_ang, oscr_ang, scr_sectnum; - short view_outside_dang; // outside view delta ang short circle_camera_ang; short camera_check_time_delay; @@ -989,7 +982,7 @@ struct PLAYERstruct short Heads; // Number of Accursed Heads orbiting player int PlayerVersion; - char cookieQuote[256]; // Should be an FString but must be POD for now to be storable in a savegame. + char cookieQuote[256]; // Should be an FString but must be POD for now so that PLAYER remains POD. int cookieTime; char WpnReloadState; diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index 269c45273..576bd93bc 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -83,7 +83,6 @@ extern bool sumowasseen; extern bool zillawasseen; extern short BossSpriteNum[3]; -#define PANEL_SAVE 1 #define ANIM_SAVE 1 extern STATE s_NotRestored[]; @@ -227,6 +226,221 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, ATTRIBUTEp& w, ATT // //--------------------------------------------------------------------------- +// Temporary array to serialize the panel sprites. +static TArray pspAsArray; + +FSerializer& Serialize(FSerializer& arc, const char* keyname, PANEL_SPRITEp& w, PANEL_SPRITEp* def) +{ + unsigned idx = ~0u; + if (arc.isWriting()) + { + if (w != nullptr) + { + idx = pspAsArray.Find(w); + if ((unsigned)idx >= pspAsArray.Size()) + { + for (unsigned i = 0; i < MAX_SW_PLAYERS_REG; i++) + { + // special case for pointing to the list head + if ((LIST)w == (LIST)&Player[i].PanelSpriteList) + { + idx = 1000'0000 + i; + break; + } + } + if (idx >= pspAsArray.Size() && idx < 1000'0000) + idx = pspAsArray.Push(w); + } + } + arc(keyname, idx); + } + else + { + unsigned int ndx; + arc(keyname, ndx); + + if (ndx == ~0u) w = nullptr; + else if (ndx >= 1000'0000) w = (PANEL_SPRITEp)&Player[ndx - 1000'0000].PanelSpriteList; + else if ((unsigned)ndx >= pspAsArray.Size()) + I_Error("Bad panel sprite index in savegame"); + else w = pspAsArray[ndx]; + } + return arc; +} + +//--------------------------------------------------------------------------- +// +// we need to allocate the needed panel sprites before loading anything else +// +//--------------------------------------------------------------------------- + +void preSerializePanelSprites(FSerializer& arc) +{ + if (arc.isReading()) + { + unsigned siz; + arc("panelcount", siz); + pspAsArray.Resize(siz); + for (unsigned i = 0; i < siz; i++) + { + pspAsArray[i] = (PANEL_SPRITEp)CallocMem(sizeof(PANEL_SPRITE), 1); + } + } +} + +void postSerializePanelSprites(FSerializer& arc) +{ + if (arc.isWriting()) + { + unsigned siz = pspAsArray.Size(); + arc("panelcount", siz); + } + if (arc.BeginArray("panelsprites")) + { + for (auto psp : pspAsArray) + { + arc(nullptr, *psp); + } + arc.EndArray(); + } + pspAsArray.Clear(); +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +FSerializer& Serialize(FSerializer& arc, const char* keyname, PANEL_SPRITE_OVERLAY& w, PANEL_SPRITE_OVERLAY* def) +{ + if (arc.BeginObject(keyname)) + { + arc("state", w.State) + ("flags", w.flags) + ("tics", w.tics) + ("pic", w.pic) + ("xoff", w.xoff) + ("yoff", w.yoff) + .EndObject(); + } + return arc; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +FSerializer& Serialize(FSerializer& arc, const char* keyname, PANEL_SPRITEstruct& w, PANEL_SPRITEstruct* def) +{ + static PANEL_SPRITEstruct nul; + if (!def) + { + def = &nul; + if (arc.isReading()) w = {}; + } + + if (arc.BeginObject(keyname)) + { + arc("Next", w.Next) + ("Prev", w.Prev) + ("sibling", w.sibling) + ("State", w.State) + ("RetractState", w.RetractState) + ("PresentState", w.PresentState) + ("ActionState", w.ActionState) + ("RestState", w.RestState) + ("xfract", w.xfract) + ("x", w.x) + ("yfract", w.yfract) + ("y", w.y) + .Array("over", w.over, countof(w.over)) + ("id", w.ID) + ("picndx", w.picndx) + ("picnum", w.picnum) + ("vel", w.vel) + ("vel_adj", w.vel_adj) + ("xorig", w.xorig) + ("yorig", w.yorig) + ("flags", w.flags) + ("priority", w.priority) + ("scale", w.scale) + ("jump_speed", w.jump_speed) + ("jump_grav", w.jump_grav) + ("xspeed", w.xspeed) + ("tics", w.tics) + ("delay", w.delay) + ("ang", w.ang) + ("rotate_ang", w.rotate_ang) + ("sin_ndx", w.sin_ndx) + ("sin_amt", w.sin_amt) + ("sin_arc_speed", w.sin_arc_speed) + ("bob_height_divider", w.bob_height_divider) + ("shade", w.shade) + ("pal", w.pal) + ("kill_tics", w.kill_tics) + ("WeaponType", w.WeaponType) + ("playerp", w.PlayerP); + + SerializeCodePtr(arc, "PanelSpriteFunc", (void**)&w.PanelSpriteFunc); + + arc.EndObject(); + } + if (arc.isReading()) + { + w.ox = w.x; + w.oy = w.y; + } + return arc; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +FSerializer& Serialize(FSerializer& arc, const char* keyname, REMOTE_CONTROL& w, REMOTE_CONTROL* def) +{ + static REMOTE_CONTROL nul; + if (!def) + { + def = &nul; + if (arc.isReading()) w = {}; + } + + if (arc.BeginObject(keyname)) + { + arc("cursectnum", w.cursectnum) + ("lastcursectnum", w.lastcursectnum) + ("pang", w.pang) + ("filler", w.filler) + ("xvect", w.xvect) + ("yvect", w.yvect) + ("slide_xvect", w.slide_xvect) + ("slide_yvect", w.slide_yvect) + ("x", w.posx) + ("y", w.posy) + ("z", w.posz) + ("sop_control", w.sop_control) + .EndObject(); + } + if (arc.isReading()) + { + w.oxvect = w.xvect; + w.oyvect = w.yvect; + } + return arc; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + FSerializer& Serialize(FSerializer& arc, const char* keyname, PLAYERp& w, PLAYERp* def) { int ndx = w ? int(w - Player) : -1; @@ -241,6 +455,178 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PLAYERp& w, PLAYER // //--------------------------------------------------------------------------- +FSerializer& Serialize(FSerializer& arc, const char* keyname, PLAYERstruct& w, PLAYERstruct* def) +{ + if (arc.BeginObject(keyname)) + { + arc("x", w.posx) + ("y", w.posy) + ("z", w.posz) + ("lv_sectnum", w.lv_sectnum) + ("lv_x", w.lv_x) + ("lv_y", w.lv_y) + ("lv_z", w.lv_z) + ("remote_sprite", w.remote_sprite) + ("remote", w.remote) + ("sop_remote", w.sop_remote) + ("sop", w.sop) + ("jump_count", w.jump_count) + ("jump_speed", w.jump_speed) + ("down_speed", w.down_speed) + ("up_speed", w.up_speed) + ("z_speed", w.z_speed) + ("climb_ndx", w.climb_ndx) + ("hiz", w.hiz) + ("loz", w.loz) + ("ceiling_dist", w.ceiling_dist) + ("floor_dist", w.floor_dist) + ("hi_sectp", w.hi_sectp) + ("lo_sectp", w.lo_sectp) + ("hi_sp", w.hi_sp) + ("lo_sp", w.lo_sp) + ("last_camera_sp", w.last_camera_sp) + ("circle_camera_dist", w.circle_camera_dist) + ("six", w.six) + ("siy", w.siy) + ("siz", w.siz) + ("siang", w.siang) + ("xvect", w.xvect) + ("yvect", w.yvect) + ("friction", w.friction) + ("slide_xvect", w.slide_xvect) + ("slide_yvect", w.slide_yvect) + ("slide_ang", w.slide_ang) + ("slide_dec", w.slide_dec) + ("drive_avel", w.drive_avel) + ("view_outside_dang", w.view_outside_dang) + ("circle_camera_ang", w.circle_camera_ang) + ("camera_check_time_delay", w.camera_check_time_delay) + ("cursectnum", w.cursectnum) + ("lastcursectnum", w.lastcursectnum) + ("turn180_target", w.turn180_target) + ("hvel", w.hvel) + ("tilt", w.tilt) + ("tilt_dest", w.tilt_dest) + ("horizon", w.horizon) + ("angle", w.angle) + ("recoil_amt", w.recoil_amt) + ("recoil_speed", w.recoil_speed) + ("recoil_ndx", w.recoil_ndx) + ("recoil_horizoff", w.recoil_horizoff) + ("oldposx", w.oldposx) + ("oldposy", w.oldposy) + ("oldposz", w.oldposz) + ("revolvex", w.RevolveX) + ("revolvey", w.RevolveY) + ("RevolveDeltaAng", w.RevolveDeltaAng) + ("RevolveAng", w.RevolveAng) + ("PlayerSprite", w.PlayerSprite) + ("PlayerUnderSprite", w.PlayerUnderSprite) + ("SpriteP", w.SpriteP) + ("UnderSpriteP", w.UnderSpriteP) + ("pnum", w.pnum) + ("LadderSector", w.LadderSector) + ("lx", w.lx) + ("ly", w.ly) + ("JumpDuration", w.JumpDuration) + ("WadeDepth", w.WadeDepth) + ("bob_amt", w.bob_amt) + ("bob_ndx", w.bob_ndx) + ("bcnt", w.bcnt) + ("bob_z", w.bob_z) + ("playerreadyflag", w.playerreadyflag) + ("Flags", w.Flags) + ("Flags2", w.Flags2) + ("sop_control", w.sop_control) + ("sop_riding", w.sop_riding) + .Array("HasKey", w.HasKey, countof(w.HasKey)) + ("SwordAng", w.SwordAng) + ("WpnGotOnceFlags", w.WpnGotOnceFlags) + ("WpnFlags", w.WpnFlags) + .Array("WpnAmmo", w.WpnAmmo, countof(w.WpnAmmo)) + ("WpnNum", w.WpnNum) + ("pnum", w.pnum) + ("panelnext", w.PanelSpriteList.Next) + ("panelprev", w.PanelSpriteList.Prev) + ("curwpn", w.CurWpn) + .Array("wpn", w.Wpn, countof(w.Wpn)) + ("WpnRocketType", w.WpnRocketType) + ("WpnRocketHeat", w.WpnRocketHeat) + ("WpnRocketNuke", w.WpnRocketNuke) + ("WpnFlameType", w.WpnFlameType) + ("WpnFirstType", w.WpnFirstType) + ("WeaponType", w.WeaponType) + ("FirePause", w.FirePause) + ("InventoryNum", w.InventoryNum) + ("InventoryBarTics", w.InventoryBarTics) + .Array("InventoryTics", w.InventoryTics, countof(w.InventoryTics)) + .Array("InventoryPercent", w.InventoryPercent, countof(w.InventoryPercent)) + .Array("InventoryAmount", w.InventoryAmount, countof(w.InventoryAmount)) + .Array("InventoryActive", w.InventoryActive, countof(w.InventoryActive)) + ("DiveTics", w.DiveTics) + ("DiveDamageTics", w.DiveDamageTics) + ("DeathType", w.DeathType) + ("Kills", w.Kills) + ("Killer", w.Killer) + .Array("KilledPlayer", w.KilledPlayer, countof(w.KilledPlayer)) + ("SecretsFound", w.SecretsFound) + ("Armor", w.Armor) + ("MaxHealth", w.MaxHealth) + ("UziShellLeftAlt", w.UziShellLeftAlt) + ("UziShellRightAlt", w.UziShellRightAlt) + ("TeamColor", w.TeamColor) + ("FadeTics", w.FadeTics) + ("FadeAmt", w.FadeAmt) + ("NightVision", w.NightVision) + ("IsAI", w.IsAI) + ("NumFootPrints", w.NumFootPrints) + ("WpnUziType", w.WpnUziType) + ("WpnShotgunType", w.WpnShotgunType) + ("WpnShotgunAuto", w.WpnShotgunAuto) + ("WpnShotgunLastShell", w.WpnShotgunLastShell) + ("WpnRailType", w.WpnRailType) + ("Bloody", w.Bloody) + ("InitingNuke", w.InitingNuke) + ("TestNukeInit", w.TestNukeInit) + ("NukeInitialized", w.NukeInitialized) + ("FistAng", w.FistAng) + ("WpnKungFuMove", w.WpnKungFuMove) + ("HitBy", w.HitBy) + ("Reverb", w.Reverb) + ("Heads", w.Heads) + ("PlayerVersion", w.PlayerVersion) + ("cookieTime", w.cookieTime) + ("WpnReloadState", w.WpnReloadState) + ("keypressbits", w.KeyPressBits) + ("chops", w.Chops); + + SerializeCodePtr(arc, "DoPlayerAction", (void**)&w.DoPlayerAction); + arc.EndObject(); + } + if (arc.isReading()) + { + w.oposx = w.posx; + w.oposy = w.posx; + w.oposz = w.posx; + w.oz_speed = w.z_speed; + w.oxvect = w.xvect; + w.oyvect = w.yvect; + w.obob_z = w.bob_z; + w.input = {}; + w.lastinput = {}; + memset(w.cookieQuote, 0, sizeof(w.cookieQuote)); // no need to remember this. + w.StartColor = 0; + + } + return arc; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + FSerializer& Serialize(FSerializer& arc, const char* keyname, SECTOR_OBJECTp& w, SECTOR_OBJECTp* def) { int ndx = w ? int(w - SectorObject) : -1; @@ -431,57 +817,18 @@ void GameInterface::SerializeGameState(FSerializer& arc) if (arc.BeginObject("state")) { + preSerializePanelSprites(arc); SerializeUser(arc); - + arc("numplayers", numplayers) + .Array("players", Player, numplayers) + ; + postSerializePanelSprites(arc); arc.EndObject(); } } -int PanelSpriteToNdx(PLAYERp pp, PANEL_SPRITEp psprite) -{ - short ndx = 0; - PANEL_SPRITEp psp=NULL, next=NULL; - - TRAVERSE(&pp->PanelSpriteList, psp, next) - { - if (psp == psprite) - return ndx; - - ndx++; - } - - // special case for pointing to the list head - if ((LIST)psprite == (LIST)&pp->PanelSpriteList) - return 9999; - - return -1; -} - - -PANEL_SPRITEp PanelNdxToSprite(PLAYERp pp, int ndx) -{ - short count = 0; - PANEL_SPRITEp psp, next; - - if (ndx == -1) - return NULL; - - if (ndx == 9999) - return (PANEL_SPRITEp)&pp->PanelSpriteList; - - TRAVERSE(&pp->PanelSpriteList, psp, next) - { - if (count == ndx) - return psp; - - count++; - } - - return NULL; -} - int SaveSymDataInfo(MFILE_WRITE fil, void *ptr) { saveddatasym sym; @@ -577,110 +924,6 @@ bool GameInterface::SaveGame() MWRITE(&Skill,sizeof(Skill),1,fil); - MWRITE(&numplayers,sizeof(numplayers),1,fil); - - //save players info - pp = &tp; - for (i = 0; i < numplayers; i++) - { - memcpy(&tp, &Player[i], sizeof(PLAYER)); - - // this does not point to global data - this is allocated link list based - // save this inside the structure -#if PANEL_SAVE - pp->CurWpn = (PANEL_SPRITEp)(intptr_t)PanelSpriteToNdx(&Player[i], pp->CurWpn); - for (ndx = 0; ndx < MAX_WEAPONS; ndx++) - pp->Wpn[ndx] = (PANEL_SPRITEp)(intptr_t)PanelSpriteToNdx(&Player[i], pp->Wpn[ndx]); - pp->Chops = (PANEL_SPRITEp)(intptr_t)PanelSpriteToNdx(&Player[i], pp->Chops); -#endif - - MWRITE(&tp, sizeof(PLAYER),1,fil); - - ////// - - saveisshot |= SaveSymDataInfo(fil, pp->remote_sprite); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, pp->remote.sop_control); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, pp->sop_remote); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, pp->sop); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, pp->hi_sectp); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, pp->lo_sectp); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, pp->hi_sp); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, pp->lo_sp); - assert(!saveisshot); - - saveisshot |= SaveSymDataInfo(fil, pp->last_camera_sp); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, pp->SpriteP); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, pp->UnderSpriteP); - assert(!saveisshot); - - saveisshot |= SaveSymCodeInfo(fil, pp->DoPlayerAction); - assert(!saveisshot); - - saveisshot |= SaveSymDataInfo(fil, pp->sop_control); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, pp->sop_riding); - assert(!saveisshot); - } - -#if PANEL_SAVE - // local copy - psp = &tpanel_sprite; - for (i = 0; i < numplayers; i++) - { - unsigned j; - pp = &Player[i]; - ndx = 0; - - TRAVERSE(&pp->PanelSpriteList, cur, next) - { - // this is a HEADER - MWRITE(&ndx, sizeof(ndx),1,fil); - - memcpy(psp, cur, sizeof(PANEL_SPRITE)); - - // Panel Sprite - save in structure - psp->sibling = (PANEL_SPRITEp)(intptr_t)PanelSpriteToNdx(pp, cur->sibling); - MWRITE(psp, sizeof(PANEL_SPRITE),1,fil); - - saveisshot |= SaveSymDataInfo(fil, psp->PlayerP); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, psp->State); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, psp->RetractState); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, psp->PresentState); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, psp->ActionState); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, psp->RestState); - assert(!saveisshot); - saveisshot |= SaveSymCodeInfo(fil, psp->PanelSpriteFunc); - assert(!saveisshot); - - for (j = 0; j < SIZ(psp->over); j++) - { - saveisshot |= SaveSymDataInfo(fil, psp->over[j].State); - assert(!saveisshot); - } - - ndx++; - } - - // store -1 when done for player - ndx = -1; - MWRITE(&ndx, sizeof(ndx),1,fil); - } -#endif - //Sector User information for (i = 0; i < numsectors; i++) { @@ -905,85 +1148,6 @@ bool GameInterface::LoadGame() MREAD(&Skill,sizeof(Skill),1,fil); - MREAD(&numplayers, sizeof(numplayers),1,fil); - - //save players - //MREAD(Player,sizeof(PLAYER), numplayers,fil); - - //save players info - - for (auto& pp : Player) - { - pp.cookieTime = 0; - memset(pp.cookieQuote, 0, sizeof(pp.cookieQuote)); - } - - for (i = 0; i < numplayers; i++) - { - pp = &Player[i]; - - MREAD(pp, sizeof(*pp), 1, fil); - - saveisshot |= LoadSymDataInfo(fil, (void **)&pp->remote_sprite); - saveisshot |= LoadSymDataInfo(fil, (void **)&pp->remote.sop_control); - saveisshot |= LoadSymDataInfo(fil, (void **)&pp->sop_remote); - saveisshot |= LoadSymDataInfo(fil, (void **)&pp->sop); - - saveisshot |= LoadSymDataInfo(fil, (void **)&pp->hi_sectp); - saveisshot |= LoadSymDataInfo(fil, (void **)&pp->lo_sectp); - - saveisshot |= LoadSymDataInfo(fil, (void **)&pp->hi_sp); - saveisshot |= LoadSymDataInfo(fil, (void **)&pp->lo_sp); - - saveisshot |= LoadSymDataInfo(fil, (void **)&pp->last_camera_sp); - saveisshot |= LoadSymDataInfo(fil, (void **)&pp->SpriteP); - saveisshot |= LoadSymDataInfo(fil, (void **)&pp->UnderSpriteP); - saveisshot |= LoadSymCodeInfo(fil, (void **)&pp->DoPlayerAction); - saveisshot |= LoadSymDataInfo(fil, (void **)&pp->sop_control); - saveisshot |= LoadSymDataInfo(fil, (void **)&pp->sop_riding); - if (saveisshot) { MCLOSE_READ(fil); return false; } - } - - -#if PANEL_SAVE - for (i = 0; i < numplayers; i++) - { - int j; - pp = &Player[i]; - - INITLIST(&pp->PanelSpriteList); - - while (true) - { - MREAD(&ndx, sizeof(ndx),1,fil); - - if (ndx == -1) - break; - - psp = (PANEL_SPRITEp)CallocMem(sizeof(PANEL_SPRITE), 1); - ASSERT(psp); - - MREAD(psp, sizeof(PANEL_SPRITE),1,fil); - INSERT_TAIL(&pp->PanelSpriteList,psp); - - saveisshot |= LoadSymDataInfo(fil, (void **)&psp->PlayerP); - saveisshot |= LoadSymDataInfo(fil, (void **)&psp->State); - saveisshot |= LoadSymDataInfo(fil, (void **)&psp->RetractState); - saveisshot |= LoadSymDataInfo(fil, (void **)&psp->PresentState); - saveisshot |= LoadSymDataInfo(fil, (void **)&psp->ActionState); - saveisshot |= LoadSymDataInfo(fil, (void **)&psp->RestState); - saveisshot |= LoadSymCodeInfo(fil, (void **)&psp->PanelSpriteFunc); - if (saveisshot) { MCLOSE_READ(fil); return false; } - - for (j = 0; j < (int)SIZ(psp->over); j++) - { - saveisshot |= LoadSymDataInfo(fil, (void **)&psp->over[j].State); - if (saveisshot) { MCLOSE_READ(fil); return false; } - } - - } - } -#endif //Sector User information for (i = 0; i < numsectors; i++) @@ -1149,28 +1313,6 @@ bool GameInterface::LoadGame() MCLOSE_READ(fil); - //!!IMPORTANT - this POST stuff will not work here now becaus it does actual reads - - - // - // POST processing of info MREAD in - // - -#if PANEL_SAVE - for (i = 0; i < numplayers; i++) - { - pp = &Player[i]; - TRAVERSE(&pp->PanelSpriteList, psp, next) - { - // dont need to set Next and Prev this was done - // when sprites were inserted - - // sibling is the only PanelSprite (malloced ptr) in the PanelSprite struct - psp->sibling = PanelNdxToSprite(pp, (int)(intptr_t)psp->sibling); - } - } -#endif - DoTheCache(); // this is ok - just duplicating sector list with pointers @@ -1180,21 +1322,6 @@ bool GameInterface::LoadGame() sop->sectp[i] = §or[sop->sector[i]]; } - //!!Again this will not work here - //restore players info - for (i = 0; i < numplayers; i++) - { -#if PANEL_SAVE - pp->CurWpn = PanelNdxToSprite(pp, (int)(intptr_t)pp->CurWpn); - - for (ndx = 0; ndx < MAX_WEAPONS; ndx++) - pp->Wpn[ndx] = PanelNdxToSprite(pp, (int)(intptr_t)pp->Wpn[ndx]); - - pp->Chops = PanelNdxToSprite(pp, (int)(intptr_t)pp->Chops); - -#endif - } - { int SavePlayClock = PlayClock; InitTimingVars(); @@ -1208,11 +1335,6 @@ bool GameInterface::LoadGame() if (snd_ambience) StartAmbientSound(); - TRAVERSE_CONNECT(i) - { - Player[i].StartColor = 0; - } - // this is not a new game ShadowWarrior::NewGame = false; From 66e5b9ada7d3d7f0940a13b2385350e842452669 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 2 Apr 2021 12:55:58 +0200 Subject: [PATCH 08/18] - SW: save SectUser as JSON, also store in a managed array. --- l | 34 +++++++++++ source/games/sw/src/actor.cpp | 8 +-- source/games/sw/src/cheats.cpp | 2 +- source/games/sw/src/coolg.cpp | 2 +- source/games/sw/src/coolie.cpp | 2 +- source/games/sw/src/copysect.cpp | 2 +- source/games/sw/src/draw.cpp | 2 +- source/games/sw/src/eel.cpp | 2 +- source/games/sw/src/game.cpp | 14 +---- source/games/sw/src/game.h | 7 ++- source/games/sw/src/hornet.cpp | 2 +- source/games/sw/src/jweapon.cpp | 8 +-- source/games/sw/src/morph.cpp | 10 ++-- source/games/sw/src/panel.cpp | 2 +- source/games/sw/src/player.cpp | 22 +++---- source/games/sw/src/rooms.cpp | 2 +- source/games/sw/src/rotator.cpp | 2 +- source/games/sw/src/save.cpp | 100 ++++++++++++++++++++----------- source/games/sw/src/sector.cpp | 12 ++-- source/games/sw/src/slidor.cpp | 2 +- source/games/sw/src/sprite.cpp | 9 +-- source/games/sw/src/track.cpp | 12 ++-- source/games/sw/src/vator.cpp | 6 +- source/games/sw/src/weapon.cpp | 42 ++++++------- source/games/sw/src/zombie.cpp | 2 +- 25 files changed, 180 insertions(+), 128 deletions(-) create mode 100644 l diff --git a/l b/l new file mode 100644 index 000000000..243f3dcab --- /dev/null +++ b/l @@ -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. + diff --git a/source/games/sw/src/actor.cpp b/source/games/sw/src/actor.cpp index d40885300..65b017abb 100644 --- a/source/games/sw/src/actor.cpp +++ b/source/games/sw/src/actor.cpp @@ -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 = §or[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; diff --git a/source/games/sw/src/cheats.cpp b/source/games/sw/src/cheats.cpp index a5f74bea7..6897cdd6a 100644 --- a/source/games/sw/src/cheats.cpp +++ b/source/games/sw/src/cheats.cpp @@ -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 } } diff --git a/source/games/sw/src/coolg.cpp b/source/games/sw/src/coolg.cpp index 53e7254b7..6ae1b33cf 100644 --- a/source/games/sw/src/coolg.cpp +++ b/source/games/sw/src/coolg.cpp @@ -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 diff --git a/source/games/sw/src/coolie.cpp b/source/games/sw/src/coolie.cpp index 17eaf864b..cdb011e90 100644 --- a/source/games/sw/src/coolie.cpp +++ b/source/games/sw/src/coolie.cpp @@ -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; } diff --git a/source/games/sw/src/copysect.cpp b/source/games/sw/src/copysect.cpp index 0da16c661..632f8cc4d 100644 --- a/source/games/sw/src/copysect.cpp +++ b/source/games/sw/src/copysect.cpp @@ -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); diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index 2a83b008f..c384de81a 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -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; diff --git a/source/games/sw/src/eel.cpp b/source/games/sw/src/eel.cpp index c450c379d..fa6900585 100644 --- a/source/games/sw/src/eel.cpp +++ b/source/games/sw/src/eel.cpp @@ -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 diff --git a/source/games/sw/src/game.cpp b/source/games/sw/src/game.cpp index fb32cd3b2..0c3af8e89 100644 --- a/source/games/sw/src/game.cpp +++ b/source/games/sw/src/game.cpp @@ -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) { diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 61b30374a..246a0d972 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -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 SectUser[MAXSECTORS]; SECT_USERp SpawnSectUser(short sectnum); diff --git a/source/games/sw/src/hornet.cpp b/source/games/sw/src/hornet.cpp index ac4036f26..a5fa6bd85 100644 --- a/source/games/sw/src/hornet.cpp +++ b/source/games/sw/src/hornet.cpp @@ -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 diff --git a/source/games/sw/src/jweapon.cpp b/source/games/sw/src/jweapon.cpp index 32575053b..ee357d651 100644 --- a/source/games/sw/src/jweapon.cpp +++ b/source/games/sw/src/jweapon.cpp @@ -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 diff --git a/source/games/sw/src/morph.cpp b/source/games/sw/src/morph.cpp index 34c3ca0a6..3db13aeb7 100644 --- a/source/games/sw/src/morph.cpp +++ b/source/games/sw/src/morph.cpp @@ -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); diff --git a/source/games/sw/src/panel.cpp b/source/games/sw/src/panel.cpp index 3e7094f84..89e7927d6 100644 --- a/source/games/sw/src/panel.cpp +++ b/source/games/sw/src/panel.cpp @@ -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; diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index eeb4dc683..6ef06080d 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -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 = §or[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) diff --git a/source/games/sw/src/rooms.cpp b/source/games/sw/src/rooms.cpp index 240dd3c74..0ee79b5ba 100644 --- a/source/games/sw/src/rooms.cpp +++ b/source/games/sw/src/rooms.cpp @@ -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); diff --git a/source/games/sw/src/rotator.cpp b/source/games/sw/src/rotator.cpp index 8f05a6e37..91522732e 100644 --- a/source/games/sw/src/rotator.cpp +++ b/source/games/sw/src/rotator.cpp @@ -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; diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index 576bd93bc..e67b19343 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -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 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; jptr >= 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(§num,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 { diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index 8e9c1494c..f89f912b3 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -82,7 +82,7 @@ int lavadropsiz[LAVAMAXDROPS], lavadropsizlookup[LAVAMAXDROPS]; int lavaradx[32][128], lavarady[32][128], lavaradcnt[32]; #endif -SECT_USERp SectUser[MAXSECTORS]; +TPointer SectUser[MAXSECTORS]; TPointer 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; istag == 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 = §or[pp->cursectnum]; if (TEST(sectu->flags, SECTFU_DAMAGE_ABOVE_SECTOR)) diff --git a/source/games/sw/src/slidor.cpp b/source/games/sw/src/slidor.cpp index b86f62e83..a37589ab2 100644 --- a/source/games/sw/src/slidor.cpp +++ b/source/games/sw/src/slidor.cpp @@ -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; diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 8fcb74441..686a4b5c7 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -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); } diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index 44d0de861..fbc75d85a 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -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; diff --git a/source/games/sw/src/vator.cpp b/source/games/sw/src/vator.cpp index e0cfb2eb4..6b97b4433 100644 --- a/source/games/sw/src/vator.cpp +++ b/source/games/sw/src/vator.cpp @@ -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); diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index d294fbb29..b24a2c946 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -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 = §or[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 = §or[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 = §or[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)) diff --git a/source/games/sw/src/zombie.cpp b/source/games/sw/src/zombie.cpp index ca003308b..3fc5cc99f 100644 --- a/source/games/sw/src/zombie.cpp +++ b/source/games/sw/src/zombie.cpp @@ -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 = §or[sp->sectnum]; owner = sprite[Weapon].owner; From e9b1342ffd153fed7d20894d38732063d26122f4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 2 Apr 2021 13:05:24 +0200 Subject: [PATCH 09/18] - SW: save globals as JSON. --- source/games/sw/src/game.h | 14 +- source/games/sw/src/jsector.h | 2 +- source/games/sw/src/save.cpp | 327 ++++++++++++++++++++++------------ 3 files changed, 222 insertions(+), 121 deletions(-) diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 246a0d972..865d07d6f 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1613,30 +1613,30 @@ typedef struct short sector, angopen, angclosed, angopendir, sang, anginc, wall[17]; } SWING; -typedef struct +typedef struct SINE_WAVE_FLOOR { int floor_origz, ceiling_origz, range; short sector, sintable_ndx, speed_shift; - char flags; -} SINE_WAVE_FLOOR, *SINE_WAVE_FLOORp; + uint8_t flags; +} *SINE_WAVE_FLOORp; #define MAX_SINE_WAVE 6 extern SINE_WAVE_FLOOR SineWaveFloor[MAX_SINE_WAVE][21]; -typedef struct +typedef struct SINE_WALL { int orig_xy, range; short wall, sintable_ndx, speed_shift, type; -} SINE_WALL, *SINE_WALLp; +} *SINE_WALLp; #define MAX_SINE_WALL 10 #define MAX_SINE_WALL_POINTS 64 extern SINE_WALL SineWall[MAX_SINE_WALL][MAX_SINE_WALL_POINTS]; -typedef struct +struct SPRING_BOARD { short Sector, TimeOut; -} SPRING_BOARD; +}; extern SPRING_BOARD SpringBoard[20]; extern SWING Rotate[17]; diff --git a/source/games/sw/src/jsector.h b/source/games/sw/src/jsector.h index 9385b0cf8..245567bf9 100644 --- a/source/games/sw/src/jsector.h +++ b/source/games/sw/src/jsector.h @@ -54,7 +54,7 @@ typedef struct // level for a // max of up to 4 coolie ghosts to spawn. bool ismagic; // Is this a magic mirror? - MIRRORSTATE mstate; // What state the mirror is currently + uint8_t mstate; // What state the mirror is currently // in int maxtics; // Tic count used to time mirror // events diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index e67b19343..27fb3bf07 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -864,6 +864,180 @@ void SerializeUser(FSerializer& arc) } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +FSerializer& Serialize(FSerializer& arc, const char* keyname, SINE_WAVE_FLOOR& w, SINE_WAVE_FLOOR* def) +{ + static SINE_WAVE_FLOOR nul = { -1,-1,-1,-1,-1,-1,255 }; + if (!def) + { + def = &nul; + if (arc.isReading()) w = nul; + } + + if (arc.BeginObject(keyname)) + { + arc("floor_origz", w.floor_origz, def->floor_origz) + ("ceiling_origz", w.ceiling_origz, def->ceiling_origz) + ("range", w.range, def->range) + ("sector", w.sector, def->sector) + ("sintable_ndx", w.sintable_ndx, def->sintable_ndx) + ("speed_shift", w.speed_shift, def->speed_shift) + ("flags", w.flags, def->flags) + .EndObject(); + } + return arc; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +FSerializer& Serialize(FSerializer& arc, const char* keyname, SINE_WALL& w, SINE_WALL* def) +{ + static SINE_WALL nul = { -1,-1,-1,-1,-1,-1 }; + if (!def) + { + def = &nul; + if (arc.isReading()) w = nul; + } + + if (arc.BeginObject(keyname)) + { + arc("orig_xy", w.orig_xy, def->orig_xy) + ("range", w.range, def->range) + ("sector", w.wall, def->wall) + ("sintable_ndx", w.sintable_ndx, def->sintable_ndx) + ("speed_shift", w.speed_shift, def->speed_shift) + ("flags", w.type, def->type) + .EndObject(); + } + return arc; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +FSerializer& Serialize(FSerializer& arc, const char* keyname, SPRING_BOARD& w, SPRING_BOARD* def) +{ + static SPRING_BOARD nul = { -1,-1 }; + if (!def) + { + def = &nul; + if (arc.isReading()) w = nul; + } + + if (arc.BeginObject(keyname)) + { + arc("sector", w.Sector, def->Sector) + ("timeout", w.TimeOut, def->TimeOut) + .EndObject(); + } + return arc; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +FSerializer& Serialize(FSerializer& arc, const char* keyname, MIRRORTYPE& w, MIRRORTYPE* def) +{ + static MIRRORTYPE nul; + if (!def) + { + def = &nul; + if (arc.isReading()) w = {}; + } + if (arc.BeginObject(keyname)) + { + arc("mirrorwall", w.mirrorwall, def->mirrorwall) + ("mirrorsector", w.mirrorsector, def->mirrorsector) + ("camera", w.camera, def->camera) + ("camsprite", w.camsprite, def->camsprite) + ("campic", w.campic, def->campic) + ("numspawnspots", w.numspawnspots, def->numspawnspots) + .Array("spawnspots", w.spawnspots, def->spawnspots, w.numspawnspots) + ("ismagic", w.ismagic, def->ismagic) + ("mstate", w.mstate, def->mstate) + ("maxtics", w.maxtics, def->maxtics) + ("tics", w.tics, def->tics) + .EndObject(); + } + return arc; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +FSerializer& Serialize(FSerializer& arc, const char* keyname, gNET& w, gNET* def) +{ + static gNET nul; + if (!def) + { + def = &nul; + if (arc.isReading()) w = {}; + } + if (arc.BeginObject(keyname)) + { + arc("KillLimit", w.KillLimit, def->KillLimit) + ("TimeLimit", w.TimeLimit, def->TimeLimit) + ("TimeLimitClock", w.TimeLimitClock, def->TimeLimitClock) + ("MultiGameType", w.MultiGameType, def->MultiGameType) + ("TeamPlay", w.TeamPlay, def->TeamPlay) + ("HurtTeammate", w.HurtTeammate, def->HurtTeammate) + ("SpawnMarkers", w.SpawnMarkers, def->SpawnMarkers) + ("AutoAim", w.AutoAim, def->AutoAim) + ("NoRespawn", w.NoRespawn, def->NoRespawn) + ("Nuke", w.Nuke, def->Nuke) + .EndObject(); + } + return arc; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +FSerializer& Serialize(FSerializer& arc, const char* keyname, GAME_SET& w, GAME_SET* def) +{ + static GAME_SET nul; + if (!def) + { + def = &nul; + if (arc.isReading()) w = {}; + } + if (arc.BeginObject(keyname)) + { + arc("NetGameType", w.NetGameType, def->NetGameType) + ("NetMonsters", w.NetMonsters, def->NetMonsters) + ("NetHurtTeammate", w.NetHurtTeammate, def->NetHurtTeammate) + ("NetSpawnMarkers", w.NetSpawnMarkers, def->NetSpawnMarkers) + ("NetTeamPlay", w.NetTeamPlay, def->NetTeamPlay) + ("NetKillLimit", w.NetKillLimit, def->NetKillLimit) + ("NetTimeLimit", w.NetTimeLimit, def->NetTimeLimit) + ("NetColor", w.NetColor, def->NetColor) + ("Nuke", w.NetNuke, def->NetNuke) + .EndObject(); + } + return arc; +} + //--------------------------------------------------------------------------- // // @@ -881,6 +1055,46 @@ void GameInterface::SerializeGameState(FSerializer& arc) SerializeSectUser(arc); arc("numplayers", numplayers) .Array("players", Player, numplayers) + ("skill", Skill) + ("screenpeek", screenpeek) + ("randomseed", randomseed) +// .Array("sop", SectorObject, countof(SectorObject)) + .Array("swf", &SineWaveFloor[0][0], 6 * 21) + .Array("sinewall", &SineWall[0][0], 10 * 64) + .Array("springboard", SpringBoard, countof(SpringBoard)) + ("NormalVisibility", NormalVisibility) + ("MoveSkip2", MoveSkip2) + ("MoveSkip4", MoveSkip4) + ("MoveSkip8", MoveSkip8) + ("mirrorcnt", mirrorcnt) + .Array("mirror", mirror, mirrorcnt) + ("mirrorinview", mirrorinview) + ("StarQueueHead", StarQueueHead) + .Array("StarQueue", StarQueue, countof(StarQueue)) + ("HoleQueueHead", HoleQueueHead) + .Array("HoleQueue", HoleQueue, countof(HoleQueue)) + ("WallBloodQueueHead", WallBloodQueueHead) + .Array("WallBloodQueue", WallBloodQueue, countof(WallBloodQueue)) + ("FloorBloodQueueHead", FloorBloodQueueHead) + .Array("FloorBloodQueue", FloorBloodQueue, countof(FloorBloodQueue)) + ("GenericQueueHead", GenericQueueHead) + .Array("GenericQueue", GenericQueue, countof(GenericQueue)) + ("LoWangsQueueHead", LoWangsQueueHead) + .Array("LoWangsQueue", LoWangsQueue, countof(LoWangsQueue)) + ("PlayClock", PlayClock) + ("TotalKillable", TotalKillable) + ("net", gNet) + ("gs", gs) + ("LevelSecrets", LevelSecrets) + ("Bunny_Count", Bunny_Count) + ("GodMode", GodMode) + ("FinishTimer", FinishTimer) + ("FinishAnim", FinishAnim) + ("serpwasseen", serpwasseen) + ("sumowasseen", sumowasseen) + ("zillawasseen", zillawasseen) + .Array("BossSpriteNum", BossSpriteNum, 3) + ; postSerializePanelSprites(arc); arc.EndObject(); @@ -982,8 +1196,6 @@ bool GameInterface::SaveGame() // workaround until the level info here has been transitioned. fil = WriteSavegameChunk("snapshot.sw"); - MWRITE(&Skill,sizeof(Skill),1,fil); - // // Sector object // @@ -1007,9 +1219,6 @@ bool GameInterface::SaveGame() } - MWRITE(SineWaveFloor, sizeof(SineWaveFloor),1,fil); - MWRITE(SineWall, sizeof(SineWall),1,fil); - MWRITE(SpringBoard, sizeof(SpringBoard),1,fil); MWRITE(Track, sizeof(Track),1,fil); @@ -1023,8 +1232,6 @@ bool GameInterface::SaveGame() } MWRITE(&Player[myconnectindex].input,sizeof(Player[myconnectindex].input),1,fil); - MWRITE(&screenpeek,sizeof(screenpeek),1,fil); - MWRITE(&randomseed, sizeof(randomseed), 1, fil); // do all sector manipulation structures @@ -1112,57 +1319,10 @@ bool GameInterface::SaveGame() #endif #endif - MWRITE(&NormalVisibility,sizeof(NormalVisibility),1,fil); - MWRITE(&MoveSkip2,sizeof(MoveSkip2),1,fil); - MWRITE(&MoveSkip4,sizeof(MoveSkip4),1,fil); - MWRITE(&MoveSkip8,sizeof(MoveSkip8),1,fil); - // SO interpolations saveisshot |= so_writeinterpolations(fil); assert(!saveisshot); - // mirror - MWRITE(mirror,sizeof(mirror),1,fil); - MWRITE(&mirrorcnt,sizeof(mirrorcnt),1,fil); - MWRITE(&mirrorinview,sizeof(mirrorinview),1,fil); - - // queue - MWRITE(&StarQueueHead,sizeof(StarQueueHead),1,fil); - MWRITE(StarQueue,sizeof(StarQueue),1,fil); - MWRITE(&HoleQueueHead,sizeof(HoleQueueHead),1,fil); - MWRITE(HoleQueue,sizeof(HoleQueue),1,fil); - MWRITE(&WallBloodQueueHead,sizeof(WallBloodQueueHead),1,fil); - MWRITE(WallBloodQueue,sizeof(WallBloodQueue),1,fil); - MWRITE(&FloorBloodQueueHead,sizeof(FloorBloodQueueHead),1,fil); - MWRITE(FloorBloodQueue,sizeof(FloorBloodQueue),1,fil); - MWRITE(&GenericQueueHead,sizeof(GenericQueueHead),1,fil); - MWRITE(GenericQueue,sizeof(GenericQueue),1,fil); - MWRITE(&LoWangsQueueHead,sizeof(LoWangsQueueHead),1,fil); - MWRITE(LoWangsQueue,sizeof(LoWangsQueue),1,fil); - - MWRITE(&PlayClock,sizeof(PlayClock),1,fil); - MWRITE(&TotalKillable,sizeof(TotalKillable),1,fil); - - // game settings - MWRITE(&gNet,sizeof(gNet),1,fil); - - MWRITE(&gs,sizeof(gs),1,fil); - - MWRITE(&LevelSecrets,sizeof(LevelSecrets),1,fil); - - MWRITE(&Bunny_Count,sizeof(Bunny_Count),1,fil); - - MWRITE(&GodMode,sizeof(GodMode),1,fil); - - MWRITE(&FinishTimer,sizeof(FinishTimer),1,fil); - MWRITE(&FinishAnim,sizeof(FinishAnim),1,fil); - - MWRITE(&serpwasseen, sizeof(serpwasseen), 1, fil); - MWRITE(&sumowasseen, sizeof(sumowasseen), 1, fil); - MWRITE(&zillawasseen, sizeof(zillawasseen), 1, fil); - MWRITE(BossSpriteNum, sizeof(BossSpriteNum), 1, fil); - //MWRITE(&Zombies, sizeof(Zombies), 1, fil); - return !saveisshot; } @@ -1186,8 +1346,6 @@ bool GameInterface::LoadGame() if (!filr.isOpen()) return false; fil = &filr; - MREAD(&Skill,sizeof(Skill),1,fil); - MREAD(SectorObject, sizeof(SectorObject),1,fil); for (ndx = 0; ndx < (short)SIZ(SectorObject); ndx++) @@ -1202,10 +1360,6 @@ bool GameInterface::LoadGame() if (saveisshot) { MCLOSE_READ(fil); return false; } } - MREAD(SineWaveFloor, sizeof(SineWaveFloor),1,fil); - MREAD(SineWall, sizeof(SineWall),1,fil); - MREAD(SpringBoard, sizeof(SpringBoard),1,fil); - MREAD(Track, sizeof(Track),1,fil); for (i = 0; i < MAX_TRACKS; i++) { @@ -1223,9 +1377,6 @@ bool GameInterface::LoadGame() MREAD(&Player[myconnectindex].input,sizeof(Player[myconnectindex].input),1,fil); - MREAD(&screenpeek,sizeof(screenpeek),1,fil); - MREAD(&randomseed, sizeof(randomseed), 1, fil); - // do all sector manipulation structures #if ANIM_SAVE @@ -1285,59 +1436,9 @@ bool GameInterface::LoadGame() #endif #endif - MREAD(&NormalVisibility,sizeof(NormalVisibility),1,fil); - - MREAD(&MoveSkip2,sizeof(MoveSkip2),1,fil); - MREAD(&MoveSkip4,sizeof(MoveSkip4),1,fil); - MREAD(&MoveSkip8,sizeof(MoveSkip8),1,fil); - // SO interpolations saveisshot |= so_readinterpolations(fil); if (saveisshot) { MCLOSE_READ(fil); return false; } - - // mirror - MREAD(mirror,sizeof(mirror),1,fil); - MREAD(&mirrorcnt,sizeof(mirrorcnt),1,fil); - MREAD(&mirrorinview,sizeof(mirrorinview),1,fil); - - // queue - MREAD(&StarQueueHead,sizeof(StarQueueHead),1,fil); - MREAD(StarQueue,sizeof(StarQueue),1,fil); - MREAD(&HoleQueueHead,sizeof(HoleQueueHead),1,fil); - MREAD(HoleQueue,sizeof(HoleQueue),1,fil); - MREAD(&WallBloodQueueHead,sizeof(WallBloodQueueHead),1,fil); - MREAD(WallBloodQueue,sizeof(WallBloodQueue),1,fil); - MREAD(&FloorBloodQueueHead,sizeof(FloorBloodQueueHead),1,fil); - MREAD(FloorBloodQueue,sizeof(FloorBloodQueue),1,fil); - MREAD(&GenericQueueHead,sizeof(GenericQueueHead),1,fil); - MREAD(GenericQueue,sizeof(GenericQueue),1,fil); - MREAD(&LoWangsQueueHead,sizeof(LoWangsQueueHead),1,fil); - MREAD(LoWangsQueue,sizeof(LoWangsQueue),1,fil); - - // init timing vars before PlayClock is read - MREAD(&PlayClock,sizeof(PlayClock),1,fil); - MREAD(&TotalKillable,sizeof(TotalKillable),1,fil); - - // game settings - MREAD(&gNet,sizeof(gNet),1,fil); - - MREAD(&gs,sizeof(gs),1,fil); - - MREAD(&LevelSecrets,sizeof(LevelSecrets),1,fil); - - MREAD(&Bunny_Count,sizeof(Bunny_Count),1,fil); - - MREAD(&GodMode,sizeof(GodMode),1,fil); - - MREAD(&FinishTimer,sizeof(FinishTimer),1,fil); - MREAD(&FinishAnim,sizeof(FinishAnim),1,fil); - - MREAD(&serpwasseen, sizeof(serpwasseen), 1, fil); - MREAD(&sumowasseen, sizeof(sumowasseen), 1, fil); - MREAD(&zillawasseen, sizeof(zillawasseen), 1, fil); - MREAD(BossSpriteNum, sizeof(BossSpriteNum), 1, fil); - //MREAD(&Zombies, sizeof(Zombies), 1, fil); - MCLOSE_READ(fil); From 2d571586bd4cc1ce8e3062e1560c892a12e47706 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 2 Apr 2021 13:15:34 +0200 Subject: [PATCH 10/18] - save sector objects as JSON --- source/games/sw/src/save.cpp | 170 ++++++++++++++++++++++++++--------- 1 file changed, 126 insertions(+), 44 deletions(-) diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index 27fb3bf07..3f3b4a462 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -641,6 +641,131 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, SECTOR_OBJECTp& w, // //--------------------------------------------------------------------------- +FSerializer& Serialize(FSerializer& arc, const char* keyname, SECTOR_OBJECTstruct& w, SECTOR_OBJECTstruct* def) +{ + static SECTOR_OBJECTstruct nul; + if (!def) + { + def = &nul; + if (arc.isReading()) w = {}; + } + if (arc.BeginObject(keyname)) + { + int sp_cnt; + for (sp_cnt = 0; w.sp_num[sp_cnt] != -1 && sp_cnt < (int)countof(w.sp_num); sp_cnt++) {} + + arc("num_sectors", w.num_sectors, def->num_sectors) + ("num_walls", w.num_walls, def->num_walls) + ("num_sp", sp_cnt) + ("clipbox_num", w.clipbox_num, def->clipbox_num) + .Array("sectp", w.sectp, def->sectp, w.num_sectors) + .Array("sector", w.sector, def->sector, w.num_sectors) // is this really different from sectp? + .Array("zorig_floor", w.zorig_floor, def->zorig_floor, w.num_sectors) + .Array("zorig_ceiling", w.zorig_ceiling, def->zorig_ceiling, w.num_sectors) + .Array("sp_num", w.sp_num, def->sp_num, sp_cnt + 1) + .Array("xorig", w.xorig, def->xorig, w.num_walls) + .Array("yorig", w.yorig, def->yorig, w.num_walls) + ("controller", w.controller, def->controller) + ("child", w.sp_child, def->sp_child) + ("xmid", w.xmid, def->xmid) + ("ymid", w.ymid, def->ymid) + ("zmid", w.zmid, def->zmid) + ("vel", w.vel, def->vel) + ("vel_tgt", w.vel_tgt, def->vel_tgt) + ("player_xoff", w.player_xoff, def->player_xoff) + ("player_yoff", w.player_yoff, def->player_yoff) + ("zdelta", w.zdelta, def->zdelta) + + ("z_tgt", w.z_tgt, def->z_tgt) + ("z_rate", w.z_rate, def->z_rate) + ("update", w.update, def->update) + ("bob_diff", w.bob_diff, def->bob_diff) + ("target_dist", w.target_dist, def->target_dist) + ("floor_loz", w.floor_loz, def->floor_loz) + ("floor_hiz", w.floor_hiz, def->floor_hiz) + ("morph_z", w.morph_z, def->morph_z) + ("morph_z_min", w.morph_z_min, def->morph_z_min) + ("morph_z_max", w.morph_z_max, def->morph_z_max) + ("bob_amt", w.bob_amt, def->bob_amt) + ("drive_angspeed", w.drive_angspeed, def->drive_angspeed) + ("drive_angslide", w.drive_angslide, def->drive_angslide) + ("drive_speed", w.drive_speed, def->drive_speed) + ("drive_slide", w.drive_slide, def->drive_slide) + ("crush_z", w.crush_z, def->crush_z) + ("flags", w.flags, def->flags) + ("sectnum", w.sectnum, def->sectnum) + ("mid_sector", w.mid_sector, def->mid_sector) + ("max_damage", w.max_damage, def->max_damage) + ("ram_damage", w.ram_damage, def->ram_damage) + ("wait_tics", w.wait_tics, def->wait_tics) + ("track", w.track, def->track) + ("point", w.point, def->point) + ("vel_rate", w.vel_rate, def->vel_rate) + ("dir", w.dir, def->dir) + ("ang", w.ang, def->ang) + ("ang_moving", w.ang_moving, def->ang_moving) + ("clipdist", w.clipdist, def->clipdist) + ("ang_tgt", w.ang_tgt, def->ang_tgt) + ("ang_orig", w.ang_orig, def->ang_orig) + ("last_ang", w.last_ang, def->last_ang) + ("old_ang", w.old_ang, def->old_ang) + ("spin_speed", w.spin_speed, def->spin_speed) + ("spin_ang", w.spin_ang, def->spin_ang) + ("turn_speed", w.turn_speed, def->turn_speed) + ("bob_sine_ndx", w.bob_sine_ndx, def->bob_sine_ndx) + ("bob_speed", w.bob_speed, def->bob_speed) + ("op_main_sector", w.op_main_sector, def->op_main_sector) + ("save_vel", w.save_vel, def->save_vel) + ("save_spin_speed", w.save_spin_speed, def->save_spin_speed) + ("match_event", w.match_event, def->match_event) + ("match_event_sprite", w.match_event_sprite, def->match_event_sprite) + ("scale_type", w.scale_type, def->scale_type) + ("scale_active_type", w.scale_active_type, def->scale_active_type) + ("scale_dist", w.scale_dist, def->scale_dist) + ("scale_speed", w.scale_speed, def->scale_speed) + ("scale_dist_min", w.scale_dist_min, def->scale_dist_min) + ("scale_dist_max", w.scale_dist_max, def->scale_dist_max) + ("scale_rand_freq", w.scale_rand_freq, def->scale_rand_freq) + .Array("clipbox_dist", w.clipbox_dist, def->clipbox_dist, w.clipbox_num) + .Array("clipbox_xoff", w.clipbox_xoff, def->clipbox_xoff, w.clipbox_num) + .Array("clipbox_yoff", w.clipbox_yoff, def->clipbox_yoff, w.clipbox_num) + .Array("clipbox_ang", w.clipbox_ang, def->clipbox_ang, w.clipbox_num) + .Array("clipbox_vdist", w.clipbox_vdist, def->clipbox_vdist, w.clipbox_num) + .Array("scale_point_dist", w.scale_point_dist, def->scale_point_dist, MAX_SO_POINTS) + .Array("scale_point_speed", w.scale_point_speed, def->scale_point_speed, MAX_SO_POINTS) + ("scale_point_base_speed", w.scale_point_base_speed, def->scale_point_base_speed) + ("scale_point_dist_min", w.scale_point_dist_min, def->scale_point_dist_min) + ("scale_point_dist_max", w.scale_point_dist_max, def->scale_point_dist_max) + ("scale_point_rand_freq", w.scale_point_rand_freq, def->scale_point_rand_freq) + ("scale_x_mult", w.scale_x_mult, def->scale_x_mult) + ("scale_y_mult", w.scale_y_mult, def->scale_y_mult) + ("morph_wall_point", w.morph_wall_point, def->morph_wall_point) + ("morph_ang", w.morph_ang, def->morph_ang) + ("morph_speed", w.morph_speed, def->morph_speed) + ("morph_dist_max", w.morph_dist_max, def->morph_dist_max) + ("morph_rand_freq", w.morph_rand_freq, def->morph_rand_freq) + ("morph_dist", w.morph_dist, def->morph_dist) + ("morph_z_speed", w.morph_z_speed, def->morph_z_speed) + ("morph_xoff", w.morph_xoff, def->morph_xoff) + ("morph_yoff", w.morph_yoff, def->morph_yoff) + ("limit_ang_center", w.limit_ang_center, def->limit_ang_center) + ("limit_ang_delta", w.limit_ang_delta, def->limit_ang_delta); + + SerializeCodePtr(arc, "preanimator", (void**)&w.PreMoveAnimator); + SerializeCodePtr(arc, "postanimator", (void**)&w.PostMoveAnimator); + SerializeCodePtr(arc, "animator", (void**)&w.Animator); + + arc.EndObject(); + } + return arc; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + FSerializer& Serialize(FSerializer& arc, const char* keyname, ROTATOR& w, ROTATOR* def) { if (arc.BeginObject(keyname)) @@ -1058,7 +1183,7 @@ void GameInterface::SerializeGameState(FSerializer& arc) ("skill", Skill) ("screenpeek", screenpeek) ("randomseed", randomseed) -// .Array("sop", SectorObject, countof(SectorObject)) + .Array("sop", SectorObject, countof(SectorObject)) .Array("swf", &SineWaveFloor[0][0], 6 * 21) .Array("sinewall", &SineWall[0][0], 10 * 64) .Array("springboard", SpringBoard, countof(SpringBoard)) @@ -1196,28 +1321,6 @@ bool GameInterface::SaveGame() // workaround until the level info here has been transitioned. fil = WriteSavegameChunk("snapshot.sw"); - // - // Sector object - // - - MWRITE(SectorObject, sizeof(SectorObject),1,fil); - - for (ndx = 0; ndx < (short)SIZ(SectorObject); ndx++) - { - sop = &SectorObject[ndx]; - - saveisshot |= SaveSymCodeInfo(fil, sop->PreMoveAnimator); - assert(!saveisshot); - saveisshot |= SaveSymCodeInfo(fil, sop->PostMoveAnimator); - assert(!saveisshot); - saveisshot |= SaveSymCodeInfo(fil, sop->Animator); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, sop->controller); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, sop->sp_child); - assert(!saveisshot); - } - @@ -1346,20 +1449,6 @@ bool GameInterface::LoadGame() if (!filr.isOpen()) return false; fil = &filr; - MREAD(SectorObject, sizeof(SectorObject),1,fil); - - for (ndx = 0; ndx < (short)SIZ(SectorObject); ndx++) - { - sop = &SectorObject[ndx]; - - saveisshot |= LoadSymCodeInfo(fil, (void **)&sop->PreMoveAnimator); - saveisshot |= LoadSymCodeInfo(fil, (void **)&sop->PostMoveAnimator); - saveisshot |= LoadSymCodeInfo(fil, (void **)&sop->Animator); - saveisshot |= LoadSymDataInfo(fil, (void **)&sop->controller); - saveisshot |= LoadSymDataInfo(fil, (void **)&sop->sp_child); - if (saveisshot) { MCLOSE_READ(fil); return false; } - } - MREAD(Track, sizeof(Track),1,fil); for (i = 0; i < MAX_TRACKS; i++) { @@ -1444,13 +1533,6 @@ bool GameInterface::LoadGame() DoTheCache(); - // this is ok - just duplicating sector list with pointers - for (sop = SectorObject; sop < &SectorObject[SIZ(SectorObject)]; sop++) - { - for (i = 0; i < sop->num_sectors; i++) - sop->sectp[i] = §or[sop->sector[i]]; - } - { int SavePlayClock = PlayClock; InitTimingVars(); From c49c5fcf1dbfbe0938a98b78609c74dc0fdc7e9d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 2 Apr 2021 13:20:48 +0200 Subject: [PATCH 11/18] - SW: serialize SO interpolations as JSON. --- source/games/sw/src/interpso.cpp | 79 ++++++++++++++------------------ source/games/sw/src/interpso.h | 3 +- source/games/sw/src/save.cpp | 8 +--- 3 files changed, 36 insertions(+), 54 deletions(-) diff --git a/source/games/sw/src/interpso.cpp b/source/games/sw/src/interpso.cpp index 744d2ba6a..197e5c68b 100644 --- a/source/games/sw/src/interpso.cpp +++ b/source/games/sw/src/interpso.cpp @@ -30,6 +30,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "game.h" #include "interpso.h" +#include "serializer.h" #include "names2.h" BEGIN_SW_NS @@ -398,58 +399,46 @@ void so_restoreinterpolations(void) // Stick at end of drawscree } } -int SaveSymDataInfo(MFILE_WRITE fil, void *ptr); - -int so_writeinterpolations(MFILE_WRITE fil) +void so_serializeinterpolations(FSerializer& arc) { - int32_t i; SECTOR_OBJECTp sop; - so_interp *interp; - int saveisshot = 0; + so_interp* interp; - for (sop = SectorObject, interp = so_interpdata; - sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++) + if (arc.BeginArray("sop_interp")) { - so_interp::interp_data *data = interp->data; - MWRITE(&interp->numinterpolations,sizeof(interp->numinterpolations),1,fil); - MWRITE(&interp->hasvator,sizeof(interp->hasvator),1,fil); - for (i = 0; i < interp->numinterpolations; i++, data++) + for (sop = SectorObject, interp = so_interpdata; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++) { - MWRITE(&data->curelement, sizeof(data->curelement), 1, fil); - MWRITE(&data->oldipos,sizeof(data->oldipos),1,fil); - MWRITE(&data->spriteofang,sizeof(data->spriteofang),1,fil); + if (arc.BeginObject(nullptr)) + { + so_interp::interp_data* data = interp->data; + arc("numinterp", interp->numinterpolations) + ("hasvator", interp->hasvator); + if (arc.BeginArray("data")) + { + for (int i = 0; i < interp->numinterpolations; i++, data++) + { + if (arc.BeginObject(nullptr)) + { + arc("curelement", data->curelement) + ("oldipos", data->oldipos) + ("spriteofang", data->spriteofang) + .EndObject(); + if (arc.isReading()) + { + data->lastipos = data->lastoldipos = data->oldipos; + data->lastangdiff = 0; + } + } + } + arc.EndArray(); + } + arc.EndObject(); + interp->tic = 0; + interp->lasttic = synctics; + } } + arc.EndArray(); } - return saveisshot; -} - -int LoadSymDataInfo(MFILE_READ fil, void** ptr); - -int so_readinterpolations(MFILE_READ fil) -{ - int32_t i; - SECTOR_OBJECTp sop; - so_interp *interp; - int saveisshot = 0; - - for (sop = SectorObject, interp = so_interpdata; - sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++) - { - so_interp::interp_data *data = interp->data; - MREAD(&interp->numinterpolations,sizeof(interp->numinterpolations),1,fil); - MREAD(&interp->hasvator,sizeof(interp->hasvator),1,fil); - for (i = 0; i < interp->numinterpolations; i++, data++) - { - MREAD(&data->curelement, sizeof(data->curelement), 1, fil); - MREAD(&data->oldipos,sizeof(data->oldipos),1,fil); - MREAD(&data->spriteofang,sizeof(data->spriteofang),1,fil); - data->lastipos = data->lastoldipos = data->oldipos; - data->lastangdiff = 0; - } - interp->tic = 0; - interp->lasttic = synctics; - } - return saveisshot; } END_SW_NS diff --git a/source/games/sw/src/interpso.h b/source/games/sw/src/interpso.h index 512b61c9e..b22254dad 100644 --- a/source/games/sw/src/interpso.h +++ b/source/games/sw/src/interpso.h @@ -41,8 +41,7 @@ void so_setinterpolationtics(SECTOR_OBJECTp sop, int16_t locktics); void so_updateinterpolations(void); void so_dointerpolations(int32_t smoothratio); void so_restoreinterpolations(void); -int so_writeinterpolations(MFILE_WRITE fil); -int so_readinterpolations(MFILE_READ fil); +void so_serializeinterpolations(FSerializer& arc); END_SW_NS diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index 3f3b4a462..fa2338ab2 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -1178,6 +1178,7 @@ void GameInterface::SerializeGameState(FSerializer& arc) preSerializePanelSprites(arc); SerializeUser(arc); SerializeSectUser(arc); + so_serializeinterpolations(arc); arc("numplayers", numplayers) .Array("players", Player, numplayers) ("skill", Skill) @@ -1422,10 +1423,6 @@ bool GameInterface::SaveGame() #endif #endif - // SO interpolations - saveisshot |= so_writeinterpolations(fil); - assert(!saveisshot); - return !saveisshot; } @@ -1525,9 +1522,6 @@ bool GameInterface::LoadGame() #endif #endif - // SO interpolations - saveisshot |= so_readinterpolations(fil); - if (saveisshot) { MCLOSE_READ(fil); return false; } MCLOSE_READ(fil); From bb8309831cae0f58dfacca630bdda33a839649bb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 8 Dec 2020 20:42:52 +0100 Subject: [PATCH 12/18] - SW: eliminated the int pointer in ANIM. # Conflicts: # source/games/sw/src/save.cpp --- source/games/sw/src/game.h | 63 +++++++-- source/games/sw/src/save.cpp | 249 +-------------------------------- source/games/sw/src/sector.cpp | 23 +-- source/games/sw/src/sprite.cpp | 4 +- source/games/sw/src/track.cpp | 22 +-- 5 files changed, 76 insertions(+), 285 deletions(-) diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 865d07d6f..935cd87a9 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1552,7 +1552,11 @@ 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 + union + { + struct { short depth_fract, depth; }; // do NOT change this, doubles as a long FIXED point number + int depth_fixed; + }; short stag, // ST? tag number - for certain things it helps to know it ang, height, @@ -1655,18 +1659,15 @@ typedef void ANIM_CALLBACK (ANIMp, void *); typedef ANIM_CALLBACK *ANIM_CALLBACKp; typedef void *ANIM_DATAp; -struct ANIMstruct +enum { - int *ptr, goal; - int vel; - short vel_adj; - ANIM_CALLBACKp callback; - ANIM_DATAp callbackdata; + ANIM_Floorz, + ANIM_SopZ, + ANIM_Spritez, + ANIM_Userz, + ANIM_SUdepth, }; -extern ANIM Anim[MAXANIM]; -extern short AnimCnt; - typedef struct TRACK_POINT { @@ -1880,6 +1881,39 @@ struct SECTOR_OBJECTstruct extern SECTOR_OBJECT SectorObject[MAX_SECTOR_OBJECTS]; + +struct ANIMstruct +{ + int animtype, index; + int goal; + int vel; + short vel_adj; + ANIM_CALLBACKp callback; + SECTOR_OBJECTp callbackdata; // only gets used in one place for this so having a proper type makes serialization easier. + + int& Addr() + { + switch (animtype) + { + case ANIM_Floorz: + return sector[index].floorz; + case ANIM_SopZ: + return SectorObject[index].zmid; + case ANIM_Spritez: + return sprite[index].z; + case ANIM_Userz: + return User[index]->sz; + case ANIM_SUdepth: + return SectUser[index]->depth_fixed; + default: + return index; + } + } +}; + +extern ANIM Anim[MAXANIM]; +extern short AnimCnt; + /////////////////////////////////////////////////////////////////////////////////////////// // // Prototypes @@ -1955,11 +1989,10 @@ void PlayerUpdateKills(PLAYERp pp, short value); void RefreshInfoLine(PLAYERp pp); void DoAnim(int numtics); -void AnimDelete(int *animptr); -short AnimGetGoal(int *animptr); -short AnimSet(int *animptr, int thegoal, int thevel); -//short AnimSetCallback(int *animptr, int thegoal, int thevel, ANIM_CALLBACKp call, ANIM_DATAp data); -short AnimSetCallback(short anim_ndx, ANIM_CALLBACKp call, ANIM_DATAp data); +void AnimDelete(int animtype, int animindex); +short AnimGetGoal(int animtype, int animindex); +short AnimSet(int animtype, int animindex, int thegoal, int thevel); +short AnimSetCallback(short anim_ndx, ANIM_CALLBACKp call, SECTOR_OBJECTp data); short AnimSetVelAdj(short anim_ndx, short vel_adj); void EnemyDefaults(short SpriteNum, ACTOR_ACTION_SETp action, PERSONALITYp person); diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index fa2338ab2..401f36400 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -1229,104 +1229,15 @@ void GameInterface::SerializeGameState(FSerializer& arc) -int SaveSymDataInfo(MFILE_WRITE fil, void *ptr) -{ - saveddatasym sym; - - if (Saveable_FindDataSym(ptr, &sym)) - { - FILE *fp; - - assert(false); - fp = fopen("savegame symbols missing.txt", "a"); - if (fp) - { - fprintf(fp,"data %p - reference variable xdim at %p\n",ptr, &xdim); - fclose(fp); - } - return 1; - } - - MWRITE(&sym, sizeof(sym), 1, fil); - - return 0; -} - -static int SaveSymCodeInfo_raw(MFILE_WRITE fil, void *ptr) -{ - savedcodesym sym; - - if (Saveable_FindCodeSym(ptr, &sym)) - { - FILE *fp; - - assert(false); - fp = fopen("savegame symbols missing.txt", "a"); - if (fp) - { - fprintf(fp,"code %p - reference function SaveSymDataInfo at %p\n",ptr, SaveSymDataInfo); - fclose(fp); - } - return 1; - } - - MWRITE(&sym, sizeof(sym), 1, fil); - - return 0; -} -template -static int SaveSymCodeInfo(MFILE_WRITE fil, T * ptr) -{ - return SaveSymCodeInfo_raw(fil, (void *)ptr); -} - -int LoadSymDataInfo(MFILE_READ fil, void **ptr) -{ - saveddatasym sym; - - MREAD(&sym, sizeof(sym), 1, fil); - - return Saveable_RestoreDataSym(&sym, ptr); -} -int LoadSymCodeInfo(MFILE_READ fil, void **ptr) -{ - savedcodesym sym; - - MREAD(&sym, sizeof(sym), 1, fil); - - return Saveable_RestoreCodeSym(&sym, ptr); -} - - - bool GameInterface::SaveGame() { - MFILE_WRITE fil; - int i,j; - short ndx; - PLAYER tp; - PLAYERp pp; - SECT_USERp sectu; - USER tu; - USERp u; - ANIM tanim; - ANIMp a; - PANEL_SPRITE tpanel_sprite; - PANEL_SPRITEp psp,cur,next; - SECTOR_OBJECTp sop; - int saveisshot=0; - - Saveable_Init(); - // workaround until the level info here has been transitioned. - fil = WriteSavegameChunk("snapshot.sw"); - - + auto fil = WriteSavegameChunk("snapshot.sw"); MWRITE(Track, sizeof(Track),1,fil); - for (i = 0; i < MAX_TRACKS; i++) + for (int i = 0; i < MAX_TRACKS; i++) { ASSERT(Track[i].TrackPoint); if (Track[i].NumPoints == 0) @@ -1335,95 +1246,7 @@ bool GameInterface::SaveGame() MWRITE(Track[i].TrackPoint, Track[i].NumPoints * sizeof(TRACK_POINT),1,fil); } - MWRITE(&Player[myconnectindex].input,sizeof(Player[myconnectindex].input),1,fil); - - // do all sector manipulation structures - -#if ANIM_SAVE -#if 1 - MWRITE(&AnimCnt,sizeof(AnimCnt),1,fil); - - for (i = 0, a = &tanim; i < AnimCnt; i++) - { - intptr_t offset; - memcpy(a,&Anim[i],sizeof(ANIM)); - - // maintain compatibility with sinking boat which points to user data - for (j=0; jptr >= bp && (uint8_t*)a->ptr < bp + sizeof(USER)) - { - offset = (intptr_t)((uint8_t*)a->ptr - bp); // offset from user data - a->ptr = (int *)-2; - break; - } - } - } - - if ((intptr_t)a->ptr != -2) - { - for (j=0; jptr >= bp && (uint8_t*)a->ptr < bp + sizeof(SECT_USER)) - { - offset = (intptr_t)((uint8_t*)a->ptr - bp); // offset from user data - a->ptr = (int *)-3; - break; - } - } - } - } - MWRITE(a,sizeof(ANIM),1,fil); - - if ((intptr_t)a->ptr == -2 || (intptr_t)a->ptr == -3) - { - MWRITE(&j, sizeof(j),1,fil); - MWRITE(&offset, sizeof(offset),1,fil); - } - else - { - saveisshot |= SaveSymDataInfo(fil, a->ptr); - assert(!saveisshot); - } - - saveisshot |= SaveSymCodeInfo(fil, a->callback); - assert(!saveisshot); - saveisshot |= SaveSymDataInfo(fil, a->callbackdata); - assert(!saveisshot); - } - -#else - ndx = 0; - for (i = AnimCnt - 1, a = &tanim; i >= 0; i--) - { - // write header - MWRITE(&ndx,sizeof(ndx),1,fil); - - memcpy(a,&Anim[i],sizeof(ANIM)); - MWRITE(a,sizeof(ANIM),1,fil); - - saveisshot |= SaveSymDataInfo(fil, a->ptr); - saveisshot |= SaveSymCodeInfo(fil, a->callback); - saveisshot |= SaveSymDataInfo(fil, a->callbackdata); - - ndx++; - } - - // write trailer - ndx = -1; - MWRITE(&ndx,sizeof(ndx),1,fil); -#endif -#endif - - return !saveisshot; + return true; } @@ -1440,8 +1263,6 @@ bool GameInterface::LoadGame() PANEL_SPRITEp psp,next; - Saveable_Init(); - auto filr = ReadSavegameChunk("snapshot.sw"); if (!filr.isOpen()) return false; fil = &filr; @@ -1461,70 +1282,6 @@ bool GameInterface::LoadGame() } } - MREAD(&Player[myconnectindex].input,sizeof(Player[myconnectindex].input),1,fil); - - // do all sector manipulation structures - -#if ANIM_SAVE -#if 1 - MREAD(&AnimCnt,sizeof(AnimCnt),1,fil); - - for (i = 0; i < AnimCnt; i++) - { - a = &Anim[i]; - MREAD(a,sizeof(ANIM),1,fil); - - if ((intptr_t)a->ptr == -2) - { - // maintain compatibility with sinking boat which points to user data - int offset; - MREAD(&j, sizeof(j),1,fil); - MREAD(&offset, sizeof(offset),1,fil); - a->ptr = (int *)(((char *)User[j].Data()) + offset); - } - else if ((intptr_t)a->ptr == -3) - { - // maintain compatibility with sinking boat which points to user data - int offset; - MREAD(&j, sizeof(j),1,fil); - MREAD(&offset, sizeof(offset),1,fil); - a->ptr = (int *)(((char *)SectUser[j].Data()) + offset); - } - else - { - saveisshot |= LoadSymDataInfo(fil, (void **)&a->ptr); - } - - saveisshot |= LoadSymCodeInfo(fil, (void **)&a->callback); - saveisshot |= LoadSymDataInfo(fil, (void **)&a->callbackdata); - if (saveisshot) { MCLOSE_READ(fil); return false; } - } -#else - AnimCnt = 0; - for (i = MAXANIM - 1; i >= 0; i--) - { - a = &Anim[i]; - - MREAD(&ndx,sizeof(ndx),1,fil); - - if (ndx == -1) - break; - - AnimCnt++; - - MREAD(a,sizeof(ANIM),1,fil); - - saveisshot |= LoadSymDataInfo(fil, (void **)&a->ptr); - saveisshot |= LoadSymCodeInfo(fil, (void **)&a->callback); - saveisshot |= LoadSymDataInfo(fil, (void **)&a->callbackdata); - if (saveisshot) { MCLOSE_READ(fil); return false; } - } -#endif -#endif - - MCLOSE_READ(fil); - - DoTheCache(); { diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index f89f912b3..892bd91e8 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -686,7 +686,7 @@ DoSpringBoardDown(void) destz = sector[nextsectorneighborz(sbp->Sector, sector[sbp->Sector].floorz, 1, 1)].floorz; - AnimSet(§or[sbp->Sector].floorz, destz, 256); + AnimSet(ANIM_Floorz, sbp->Sector, destz, 256); sector[sbp->Sector].lotag = TAG_SPRING_BOARD; @@ -2845,7 +2845,7 @@ DoAnim(int numtics) for (i = AnimCnt - 1; i >= 0; i--) { - animval = *Anim[i].ptr; + animval = Anim[i].Addr(); // if LESS THAN goal if (animval < Anim[i].goal) @@ -2871,7 +2871,7 @@ DoAnim(int numtics) animval = Anim[i].goal; } - *Anim[i].ptr = animval; + Anim[i].Addr() =animval; // EQUAL this entry has finished if (animval == Anim[i].goal) @@ -2920,14 +2920,14 @@ AnimClear(void) } short -AnimGetGoal(int *animptr) +AnimGetGoal(int animtype, int animindex) { int i, j; j = -1; for (i = 0; i < AnimCnt; i++) { - if (animptr == Anim[i].ptr) + if (animtype == Anim[i].animtype && animindex == Anim[i].index) { j = i; break; @@ -2938,14 +2938,14 @@ AnimGetGoal(int *animptr) } void -AnimDelete(int *animptr) +AnimDelete(int animtype, int animindex) { int i, j; j = -1; for (i = 0; i < AnimCnt; i++) { - if (animptr == Anim[i].ptr) + if (animtype == Anim[i].animtype && animindex == Anim[i].index) { j = i; break; @@ -2968,7 +2968,7 @@ AnimDelete(int *animptr) short -AnimSet(int *animptr, fixed_t thegoal, int thevel) +AnimSet(int animtype, int animindex, fixed_t thegoal, int thevel) { int i, j; @@ -2979,14 +2979,15 @@ AnimSet(int *animptr, fixed_t thegoal, int thevel) // look for existing animation and reset it for (i = 0; i < AnimCnt; i++) { - if (animptr == Anim[i].ptr) + if (animtype == Anim[i].animtype && animindex == Anim[i].index) { j = i; break; } } - Anim[j].ptr = animptr; + Anim[j].animtype = animtype; + Anim[j].index = animindex; Anim[j].goal = thegoal; Anim[j].vel = Z(thevel); Anim[j].vel_adj = 0; @@ -3000,7 +3001,7 @@ AnimSet(int *animptr, fixed_t thegoal, int thevel) } short -AnimSetCallback(short anim_ndx, ANIM_CALLBACKp call, ANIM_DATAp data) +AnimSetCallback(short anim_ndx, ANIM_CALLBACKp call, SECTOR_OBJECTp data) { ASSERT(anim_ndx < AnimCnt); diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 686a4b5c7..dabedb11a 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -648,8 +648,8 @@ KillSprite(int16_t SpriteNum) // for attached sprites that are getable make sure they don't have // any Anims attached - AnimDelete(&u->sz); - AnimDelete(&sp->z); + AnimDelete(ANIM_Userz, SpriteNum); + AnimDelete(ANIM_Spritez, SpriteNum); StopInterpolation(SpriteNum, Interp_Sprite_Z); //if (TEST(u->Flags2, SPR2_DONT_TARGET_OWNER)) diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index fbc75d85a..ed2d80f33 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -2189,7 +2189,7 @@ MoveZ(SECTOR_OBJECTp sop) if (TEST(sop->flags, SOBJ_MOVE_VERTICAL)) { - i = AnimGetGoal(&sop->zmid); + i = AnimGetGoal (ANIM_SopZ, int(sop - SectorObject)); if (i < 0) RESET(sop->flags, SOBJ_MOVE_VERTICAL); } @@ -2204,7 +2204,7 @@ MoveZ(SECTOR_OBJECTp sop) { for (i = 0, sectp = &sop->sectp[0]; *sectp; sectp++, i++) { - AnimSet(&(*sectp)->floorz, sop->zorig_floor[i] + sop->z_tgt, sop->z_rate); + AnimSet(ANIM_Floorz, int(*sectp - sector), sop->zorig_floor[i] + sop->z_tgt, sop->z_rate); } RESET(sop->flags, SOBJ_ZDOWN); @@ -2213,7 +2213,7 @@ MoveZ(SECTOR_OBJECTp sop) { for (i = 0, sectp = &sop->sectp[0]; *sectp; sectp++, i++) { - AnimSet(&(*sectp)->floorz, sop->zorig_floor[i] + sop->z_tgt, sop->z_rate); + AnimSet(ANIM_Floorz, int(*sectp - sector), sop->zorig_floor[i] + sop->z_tgt, sop->z_rate); } RESET(sop->flags, SOBJ_ZUP); @@ -2248,7 +2248,7 @@ void CallbackSOsink(ANIMp ap, void *data) for (i = 0; sop->sector[i] != -1; i++) { - if (ap->ptr == §or[sop->sector[i]].floorz) + if (ap->animtype == ANIM_Floorz && ap->index == sop->sector[i]) { dest_sector = sop->sector[i]; break; @@ -2301,7 +2301,7 @@ void CallbackSOsink(ANIMp ap, void *data) // Added a depth_fract to the struct so I could do a // 16.16 Fixed point representation to change the depth // in a more precise way - ndx = AnimSet((int *)&su->depth_fract, IntToFixed(tgt_depth), (ap->vel<<8)>>8); + ndx = AnimSet(ANIM_SUdepth, dest_sector, IntToFixed(tgt_depth), (ap->vel << 8) >> 8); AnimSetVelAdj(ndx, ap->vel_adj); found = true; break; @@ -2322,7 +2322,7 @@ void CallbackSOsink(ANIMp ap, void *data) continue; // move sprite WAY down in water - ndx = AnimSet(&u->sz, -u->sz - SPRITEp_SIZE_Z(sp) - Z(100), ap->vel>>8); + ndx = AnimSet(ANIM_Userz, i, -u->sz - SPRITEp_SIZE_Z(sp) - Z(100), ap->vel>>8); AnimSetVelAdj(ndx, ap->vel_adj); } @@ -2579,7 +2579,7 @@ void DoTrack(SECTOR_OBJECTp sop, short locktics, int *nx, int *ny) 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); + ndx = AnimSet(ANIM_Floorz, int(*sectp-sector), sector[dest_sector].floorz, tpoint->tag_high); AnimSetCallback(ndx, CallbackSOsink, sop); AnimSetVelAdj(ndx, 6); } @@ -2600,7 +2600,7 @@ void DoTrack(SECTOR_OBJECTp sop, short locktics, int *nx, int *ny) if (sectu && sectu->stag == SECT_SO_FORM_WHIRLPOOL) { - AnimSet(&(*sectp)->floorz, (*sectp)->floorz + Z(sectu->height), 128); + AnimSet(ANIM_Floorz, int(*sectp - sector), (*sectp)->floorz + Z(sectu->height), 128); (*sectp)->floorshade += sectu->height/6; RESET((*sectp)->extra, SECTFX_NO_RIDE); @@ -2625,7 +2625,7 @@ void DoTrack(SECTOR_OBJECTp sop, short locktics, int *nx, int *ny) tpoint = Track[sop->track].TrackPoint + sop->point; // set anim - AnimSet(&sop->zmid, tpoint->z, zr); + AnimSet(ANIM_SopZ, int(sop-SectorObject), tpoint->z, zr); // move back to current point by reversing direction sop->dir *= -1; @@ -2721,14 +2721,14 @@ void DoTrack(SECTOR_OBJECTp sop, short locktics, int *nx, int *ny) if (TEST(sop->flags, SOBJ_SPRITE_OBJ)) { // only modify zmid for sprite_objects - AnimSet(&sop->zmid, dz, sop->z_rate); + AnimSet(ANIM_SopZ, int(sop - SectorObject), dz, sop->z_rate); } else { // churn through sectors setting their new z values for (i = 0; sop->sector[i] != -1; i++) { - AnimSet(§or[sop->sector[i]].floorz, dz - (sector[sop->mid_sector].floorz - sector[sop->sector[i]].floorz), sop->z_rate); + AnimSet(ANIM_Floorz, sop->sector[i], dz - (sector[sop->mid_sector].floorz - sector[sop->sector[i]].floorz), sop->z_rate); } } } From b85da221d71b918cf93f2b66fbfc68e661c549dd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 18 Apr 2021 23:55:21 +0200 Subject: [PATCH 13/18] - SW: save tracks as JSON. --- source/games/sw/src/game.h | 6 +- source/games/sw/src/save.cpp | 121 +++++++++++++++++------------------ 2 files changed, 60 insertions(+), 67 deletions(-) diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 935cd87a9..bda4566a1 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1679,8 +1679,8 @@ typedef struct TRACK { TRACK_POINTp TrackPoint; int ttflags; - short flags; - short NumPoints; + int flags; + int NumPoints; void FreeTrackPoints() { @@ -2267,8 +2267,6 @@ struct GameInterface : ::GameInterface bool StartGame(FNewGameStartup& gs) override; FSavegameInfo GetSaveSig() override; void SerializeGameState(FSerializer& arc); - bool LoadGame() override; - bool SaveGame() override; void SetAmbience(bool on) override { if (on) StartAmbientSound(); else StopAmbientSound(); } FString GetCoordString() override; ReservedSpace GetReservedScreenSpace(int viewsize) override; diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index 401f36400..aa6e8417b 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -1169,6 +1169,59 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, GAME_SET& w, GAME_ // //--------------------------------------------------------------------------- +FSerializer& Serialize(FSerializer& arc, const char* keyname, TRACK_POINT& w, TRACK_POINT* def) +{ + static TRACK_POINT nul; + if (!def) + { + def = &nul; + if (arc.isReading()) w = {}; + } + if (arc.BeginObject(keyname)) + { + arc("x", w.x, def->x) + ("y", w.y, def->y) + ("z", w.z, def->z) + ("ang", w.ang, def->ang) + ("tag_low", w.tag_low, def->tag_low) + ("tag_high", w.tag_high, def->tag_high) + ("filler", w.filler, def->filler) + .EndObject(); + } + return arc; +} + +FSerializer& Serialize(FSerializer& arc, const char* keyname, TRACK& w, TRACK* def) +{ + static int nul; + if (!def) + { + if (arc.isReading()) w.flags = w.ttflags = 0; + } + if (arc.BeginObject(keyname)) + { + arc("numpoints", w.NumPoints, nul) + ("flags", w.flags, nul) + ("ttflag", w.ttflags, nul); + + if (arc.isReading()) + { + if (w.TrackPoint) FreeMem(w.TrackPoint); + int size = w.NumPoints ? w.NumPoints : 1; + w.TrackPoint = (TRACK_POINT*)CallocMem(sizeof(TRACK_POINT), size); + } + if (w.NumPoints > 0) arc.Array("points", w.TrackPoint, w.NumPoints) + .EndObject(); + } + return arc; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + void GameInterface::SerializeGameState(FSerializer& arc) { Saveable_Init(); @@ -1220,75 +1273,19 @@ void GameInterface::SerializeGameState(FSerializer& arc) ("sumowasseen", sumowasseen) ("zillawasseen", zillawasseen) .Array("BossSpriteNum", BossSpriteNum, 3) - + .Array("tracks", Track, countof(Track)) ; postSerializePanelSprites(arc); arc.EndObject(); } -} - - -bool GameInterface::SaveGame() -{ - - // workaround until the level info here has been transitioned. - auto fil = WriteSavegameChunk("snapshot.sw"); - - - MWRITE(Track, sizeof(Track),1,fil); - for (int i = 0; i < MAX_TRACKS; i++) + if (arc.isReading()) { - ASSERT(Track[i].TrackPoint); - if (Track[i].NumPoints == 0) - MWRITE(Track[i].TrackPoint, sizeof(TRACK_POINT),1,fil); - else - MWRITE(Track[i].TrackPoint, Track[i].NumPoints * sizeof(TRACK_POINT),1,fil); - } - - return true; -} - - -bool GameInterface::LoadGame() -{ - MFILE_READ fil; - int i,j,saveisshot=0; - short ndx,SpriteNum,sectnum; - PLAYERp pp = NULL; - USERp u; - SECTOR_OBJECTp sop; - SECT_USERp sectu; - ANIMp a; - PANEL_SPRITEp psp,next; - - - auto filr = ReadSavegameChunk("snapshot.sw"); - if (!filr.isOpen()) return false; - fil = &filr; - - MREAD(Track, sizeof(Track),1,fil); - for (i = 0; i < MAX_TRACKS; i++) - { - if (Track[i].NumPoints == 0) - { - Track[i].TrackPoint = (TRACK_POINTp)CallocMem(sizeof(TRACK_POINT), 1); - MREAD(Track[i].TrackPoint, sizeof(TRACK_POINT),1,fil); - } - else - { - Track[i].TrackPoint = (TRACK_POINTp)CallocMem(Track[i].NumPoints * sizeof(TRACK_POINT), 1); - MREAD(Track[i].TrackPoint, Track[i].NumPoints * sizeof(TRACK_POINT),1,fil); - } - } - DoTheCache(); - { int SavePlayClock = PlayClock; InitTimingVars(); PlayClock = SavePlayClock; - } InitNetVars(); screenpeek = myconnectindex; @@ -1300,12 +1297,10 @@ bool GameInterface::LoadGame() // this is not a new game ShadowWarrior::NewGame = false; - - DoPlayerDivePalette(Player+myconnectindex); - DoPlayerNightVisionPalette(Player+myconnectindex); - + DoPlayerDivePalette(Player + myconnectindex); + DoPlayerNightVisionPalette(Player + myconnectindex); InitLevelGlobals(); - return true; + } } END_SW_NS From 97d8aee2e82cf65eec0174d348f337c67b2ad6f5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 18 Apr 2021 23:55:33 +0200 Subject: [PATCH 14/18] - savegame code cleanup. --- source/common/utility/tarray.h | 8 +++++-- source/core/gamestruct.h | 2 -- source/core/savegamehelp.cpp | 42 ++++++++-------------------------- source/core/savegamehelp.h | 4 ---- 4 files changed, 15 insertions(+), 41 deletions(-) diff --git a/source/common/utility/tarray.h b/source/common/utility/tarray.h index d10c3224f..635f1cc75 100644 --- a/source/common/utility/tarray.h +++ b/source/common/utility/tarray.h @@ -1380,20 +1380,24 @@ public: { Ptr = nullptr; } - TPointer(const T& other) + TPointer(const T& other) = delete; + /* { Alloc(); *Ptr = other; } + */ TPointer(T&& other) { Alloc(); *Ptr = other; } - TPointer(const TPointer& other) + TPointer(const TPointer& other) = delete; + /* { DoCopy(other); } + */ TPointer(TPointer&& other) { Ptr = other.Ptr; diff --git a/source/core/gamestruct.h b/source/core/gamestruct.h index c32603825..4b8b95e28 100644 --- a/source/core/gamestruct.h +++ b/source/core/gamestruct.h @@ -67,8 +67,6 @@ struct GameInterface virtual bool StartGame(FNewGameStartup& gs) { return false; } virtual FSavegameInfo GetSaveSig() { return { "", 0, 0}; } virtual double SmallFontScale() { return 1; } - virtual bool SaveGame() { return true; } - virtual bool LoadGame() { return true; } virtual void SerializeGameState(FSerializer& arc) {} virtual void DrawPlayerSprite(const DVector2& origin, bool onteam) {} virtual void QuitToTitle() {} diff --git a/source/core/savegamehelp.cpp b/source/core/savegamehelp.cpp index 32440c6dc..a7f5017b7 100644 --- a/source/core/savegamehelp.cpp +++ b/source/core/savegamehelp.cpp @@ -107,19 +107,11 @@ static void SerializeSession(FSerializer& arc) //============================================================================= // -// This is for keeping my sanity while working with the horrible mess -// that is the savegame code in Duke Nukem. -// Without handling this in global variables it is a losing proposition -// to save custom data along with the regular snapshot. :( -// With this the savegame code can mostly pretend to load from and write -// to files while really using a composite archive. // -// All global non-game dependent state is also saved right here for convenience. // //============================================================================= - -bool OpenSaveGameForRead(const char *name) +bool ReadSavegame(const char *name) { if (savereader) delete savereader; savereader = FResourceFile::OpenResourceFile(name, true, true); @@ -180,11 +172,6 @@ FileReader ReadSavegameChunk(const char *name) return lump->NewReader(); } -bool FinishSavegameWrite() -{ - return savewriter.WriteToFile(); -} - void FinishSavegameRead() { delete savereader; @@ -199,7 +186,7 @@ CVAR(Bool, save_formatted, false, 0) // should be set to false once the conversi // //============================================================================= -bool OpenSaveGameForWrite(const char* filename, const char *name) +bool WriteSavegame(const char* filename, const char *name) { savewriter.Clear(); savewriter.SetFileName(filename); @@ -262,8 +249,7 @@ bool OpenSaveGameForWrite(const char* filename, const char *name) M_AppendPNGText(picfile, "Title", name); M_AppendPNGText(picfile, "Current Map", lev->labelName); M_FinishPNG(picfile); - - return true; + return savewriter.WriteToFile(); } //============================================================================= @@ -699,16 +685,9 @@ static int nextquicksave = -1; void DoLoadGame(const char* name) { - if (OpenSaveGameForRead(name)) + if (ReadSavegame(name)) { - if (gi->LoadGame()) - { - gameaction = ga_level; - } - else - { - I_Error("%s: Failed to load savegame", name); - } + gameaction = ga_level; } else { @@ -727,14 +706,11 @@ static int nextquicksave = -1; void G_SaveGame(const char *fn, const char *desc, bool ok4q, bool forceq) { - if (OpenSaveGameForWrite(fn, desc)) + if (WriteSavegame(fn, desc)) { - if (gi->SaveGame() && FinishSavegameWrite()) - { - savegameManager.NotifyNewSave(fn, desc, ok4q, forceq); - Printf(PRINT_NOTIFY, "%s\n", GStrings("GAME SAVED")); - BackupSaveGame = fn; - } + savegameManager.NotifyNewSave(fn, desc, ok4q, forceq); + Printf(PRINT_NOTIFY, "%s\n", GStrings("GAME SAVED")); + BackupSaveGame = fn; } } diff --git a/source/core/savegamehelp.h b/source/core/savegamehelp.h index d283a181c..b605f4835 100644 --- a/source/core/savegamehelp.h +++ b/source/core/savegamehelp.h @@ -5,13 +5,9 @@ extern FixedBitArray activeSprites; -bool OpenSaveGameForWrite(const char *fname, const char *name); -bool OpenSaveGameForRead(const char *name); - FileWriter *WriteSavegameChunk(const char *name); FileReader ReadSavegameChunk(const char *name); -bool FinishSavegameWrite(); void FinishSavegameRead(); // Savegame utilities From c17ec5fa45e617d5695afb26c8f4b0e34b726721 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 19 Apr 2021 00:00:09 +0200 Subject: [PATCH 15/18] - cleanup of savegame framework --- source/CMakeLists.txt | 1 - source/core/compositesaveame.h | 44 --------- source/core/compositesavegame.cpp | 155 ------------------------------ source/core/savegamehelp.cpp | 119 +++++++++-------------- source/core/savegamehelp.h | 5 - source/games/sw/src/interpso.h | 2 - source/games/sw/src/mfile.h | 52 ---------- source/games/sw/src/save.cpp | 10 +- 8 files changed, 51 insertions(+), 337 deletions(-) delete mode 100644 source/core/compositesaveame.h delete mode 100644 source/core/compositesavegame.cpp delete mode 100644 source/games/sw/src/mfile.h diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 4bbd3c85a..8c8460de6 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -1060,7 +1060,6 @@ set (PCH_SOURCES core/initfs.cpp core/statistics.cpp core/secrets.cpp - core/compositesavegame.cpp core/savegamehelp.cpp core/precache.cpp core/quotes.cpp diff --git a/source/core/compositesaveame.h b/source/core/compositesaveame.h deleted file mode 100644 index d4a3222ab..000000000 --- a/source/core/compositesaveame.h +++ /dev/null @@ -1,44 +0,0 @@ -#pragma once - -#include -#include "files.h" -#include "zstring.h" -#include "tarray.h" -#include "resourcefile.h" - -class CompositeSavegameWriter -{ - FString filename; - TDeletingArray subfiles; - TArray subbuffers; - TArray subfilenames; - TArray isCompressed; - - FCompressedBuffer CompressElement(BufferWriter* element, bool compress); -public: - void Clear() - { - for (auto& b : subbuffers) b.Clean(); - isCompressed.Clear(); - subfilenames.Clear(); - subfiles.DeleteAndClear(); - subbuffers.Clear(); - filename = ""; - } - void SetFileName(const char* fn) - { - filename = fn; - } - void SetFileName(const FString& fn) - { - filename = fn; - } - ~CompositeSavegameWriter() - { - assert(subfiles.Size() == 0); // must be written out. - } - FileWriter& NewElement(const char* filename, bool compress = true); - void AddCompressedElement(const char* filename, FCompressedBuffer& buffer); - bool WriteToFile(); -}; - diff --git a/source/core/compositesavegame.cpp b/source/core/compositesavegame.cpp deleted file mode 100644 index 7a278ad0a..000000000 --- a/source/core/compositesavegame.cpp +++ /dev/null @@ -1,155 +0,0 @@ - -/* -** compositesavegame.cpp -** Container for savegame files with multiple sub-content -** -**--------------------------------------------------------------------------- -** Copyright 2019 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OFf -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ - -#include -#include "compositesaveame.h" -#include "file_zip.h" -#include "resourcefile.h" -#include "m_png.h" -#include "gamecontrol.h" - - -bool WriteZip(const char *filename, TArray &filenames, TArray &content); - - -FileWriter &CompositeSavegameWriter::NewElement(const char *filename, bool compress) -{ - FCompressedBuffer b{}; - subfilenames.Push(filename); - subbuffers.Push(b); - isCompressed.Push(compress); - auto bwr = new BufferWriter; - subfiles.Push(bwr); - return *bwr; -} - -void CompositeSavegameWriter::AddCompressedElement(const char* filename, FCompressedBuffer& buffer) -{ - subfilenames.Push(filename); - subbuffers.Push(buffer); - buffer = {}; - subfiles.Push(nullptr); - isCompressed.Push(true); -} - -FCompressedBuffer CompositeSavegameWriter::CompressElement(BufferWriter *bw, bool compress) -{ - FCompressedBuffer buff; - - auto buffer =bw->GetBuffer(); - buff.mSize = buffer->Size(); - buff.mZipFlags = 0; - buff.mCRC32 = crc32(0, (const Bytef*)buffer->Data(), buffer->Size()); - - uint8_t *compressbuf = new uint8_t[buff.mSize+1]; - - z_stream stream; - int err; - - stream.next_in = (Bytef *)buffer->Data(); - stream.avail_in = buff.mSize; - stream.next_out = (Bytef*)compressbuf; - stream.avail_out = buff.mSize; - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - stream.opaque = (voidpf)0; - - if (!compress) goto error; - - // create output in zip-compatible form as required by FCompressedBuffer - err = deflateInit2(&stream, 8, Z_DEFLATED, -15, 9, Z_DEFAULT_STRATEGY); - if (err != Z_OK) - { - goto error; - } - - err = deflate(&stream, Z_FINISH); - if (err != Z_STREAM_END) - { - deflateEnd(&stream); - goto error; - } - buff.mCompressedSize = stream.total_out; - - err = deflateEnd(&stream); - if (err == Z_OK) - { - buff.mBuffer = new char[buff.mCompressedSize]; - buff.mMethod = METHOD_DEFLATE; - memcpy(buff.mBuffer, compressbuf, buff.mCompressedSize); - delete[] compressbuf; - return buff; - } - -error: - if (buff.mSize) memcpy(compressbuf, buffer->Data(), buff.mSize + 1); - buff.mBuffer = (char*)compressbuf; - buff.mCompressedSize = buff.mSize; - buff.mMethod = METHOD_STORED; - return buff; - -} - -bool CompositeSavegameWriter::WriteToFile() -{ - if (subfiles.Size() == 0) return false; - TArray compressed(subfiles.Size(), 1); - for (unsigned i = 0; i < subfiles.Size(); i++) - { - if (subfiles[i]) - compressed[i] = CompressElement(subfiles[i], isCompressed[i]); - else - { - compressed[i] = subbuffers[i]; - subbuffers[i] = {}; - } - } - - if (WriteZip(filename, subfilenames, compressed)) - { - // Check whether the file is ok by trying to open it. - //FResourceFile *test = FResourceFile::OpenResourceFile(filename, true); - //if (test != nullptr) - { - Clear(); - //delete test; - return true; - } - } - - Clear(); - return false; -} - diff --git a/source/core/savegamehelp.cpp b/source/core/savegamehelp.cpp index a7f5017b7..c344ef58e 100644 --- a/source/core/savegamehelp.cpp +++ b/source/core/savegamehelp.cpp @@ -33,7 +33,6 @@ ** */ -#include "compositesaveame.h" #include "savegamehelp.h" #include "gstrings.h" #include "i_specialpaths.h" @@ -56,14 +55,14 @@ #include "gamestate.h" #include "razemenu.h" #include "interpolate.h" +#include sectortype sectorbackup[MAXSECTORS]; walltype wallbackup[MAXWALLS]; -static CompositeSavegameWriter savewriter; -static FResourceFile *savereader; void WriteSavePic(FileWriter* file, int width, int height); +bool WriteZip(const char* filename, TArray& filenames, TArray& content); extern FString BackupSaveGame; void SerializeMap(FSerializer &arc); FixedBitArray activeSprites; @@ -111,23 +110,21 @@ static void SerializeSession(FSerializer& arc) // //============================================================================= -bool ReadSavegame(const char *name) +bool ReadSavegame(const char* name) { - if (savereader) delete savereader; - savereader = FResourceFile::OpenResourceFile(name, true, true); + auto savereader = FResourceFile::OpenResourceFile(name, true, true); if (savereader != nullptr) { - auto file = ReadSavegameChunk("info.json"); - if (!file.isOpen()) + auto lump = savereader->FindLump("info.json"); + if (!lump) { - FinishSavegameRead(); delete savereader; return false; } + auto file = lump->NewReader(); if (G_ValidateSavegame(file, nullptr, false) <= 0) { - FinishSavegameRead(); delete savereader; return false; } @@ -135,6 +132,7 @@ bool ReadSavegame(const char *name) FResourceLump* info = savereader->FindLump("session.json"); if (info == nullptr) { + delete savereader; return false; } @@ -142,40 +140,19 @@ bool ReadSavegame(const char *name) FSerializer arc; if (!arc.OpenReader((const char*)data, info->LumpSize)) { + delete savereader; info->Unlock(); return false; } info->Unlock(); - // Load system-side data from savegames. + // Load the savegame. loadMapBackup(currentLevel->fileName); SerializeSession(arc); + delete savereader; + return true; } - return savereader != nullptr; -} - -FileWriter *WriteSavegameChunk(const char *name) -{ - return &savewriter.NewElement(name); -} - -void AddCompressedSavegameChunk(const char* name, FCompressedBuffer& buffer) -{ - savewriter.AddCompressedElement(name, buffer); -} - -FileReader ReadSavegameChunk(const char *name) -{ - if (!savereader) return FileReader(); - auto lump = savereader->FindLump(name); - if (!lump) return FileReader(); - return lump->NewReader(); -} - -void FinishSavegameRead() -{ - delete savereader; - savereader = nullptr; + return false; } CVAR(Bool, save_formatted, false, 0) // should be set to false once the conversion is done @@ -188,15 +165,9 @@ CVAR(Bool, save_formatted, false, 0) // should be set to false once the conversi bool WriteSavegame(const char* filename, const char *name) { - savewriter.Clear(); - savewriter.SetFileName(filename); - + BufferWriter savepic; FSerializer savegameinfo; // this is for displayable info about the savegame. FSerializer savegamesession; // saved game session settings. - FSerializer savegameengine; // saved play state. - - savegameinfo.OpenWriter(true); - savegameengine.OpenWriter(save_formatted); char buf[100]; mysnprintf(buf, countof(buf), GAMENAME " %s", GetVersionString()); @@ -205,6 +176,7 @@ bool WriteSavegame(const char* filename, const char *name) FStringf timeStr("%02d:%02d", gs.timesecnd / 60, gs.timesecnd % 60); auto lev = currentLevel; + savegameinfo.OpenWriter(true); savegameinfo.AddString("Software", buf) ("Save Version", savesig.currentsavever) .AddString("Engine", savesig.savesig) @@ -226,30 +198,48 @@ bool WriteSavegame(const char* filename, const char *name) if (mapcname) savegameinfo.AddString("Map Resource", mapcname); else { - savewriter.Clear(); return false; // this should never happen. Saving on a map that isn't present is impossible. } } - auto buff = savegameinfo.GetCompressedOutput(); - AddCompressedSavegameChunk("info.json", buff); - // Handle system-side modules that need to persist data in savegames here, in a central place. + // Save the game state savegamesession.OpenWriter(save_formatted); SerializeSession(savegamesession); - buff = savegamesession.GetCompressedOutput(); - AddCompressedSavegameChunk("session.json", buff); - auto picfile = WriteSavegameChunk("savepic.png"); - WriteSavePic(picfile, 240, 180); + WriteSavePic(&savepic, 240, 180); mysnprintf(buf, countof(buf), GAMENAME " %s", GetVersionString()); // put some basic info into the PNG so that this isn't lost when the image gets extracted. - M_AppendPNGText(picfile, "Software", buf); - M_AppendPNGText(picfile, "Title", name); - M_AppendPNGText(picfile, "Current Map", lev->labelName); - M_FinishPNG(picfile); - return savewriter.WriteToFile(); + M_AppendPNGText(&savepic, "Software", buf); + M_AppendPNGText(&savepic, "Title", name); + M_AppendPNGText(&savepic, "Current Map", lev->labelName); + M_FinishPNG(&savepic); + + auto picdata = savepic.GetBuffer(); + FCompressedBuffer bufpng = { picdata->Size(), picdata->Size(), METHOD_STORED, 0, static_cast(crc32(0, &(*picdata)[0], picdata->Size())), (char*)&(*picdata)[0] }; + + TArray savegame_content; + TArray savegame_filenames; + + savegame_content.Push(bufpng); + savegame_filenames.Push("savepic.png"); + savegame_content.Push(savegameinfo.GetCompressedOutput()); + savegame_filenames.Push("info.json"); + savegame_content.Push(savegamesession.GetCompressedOutput()); + savegame_filenames.Push("session.json"); + + if (WriteZip(filename, savegame_filenames, savegame_content)) + { + // Check whether the file is ok by trying to open it. + FResourceFile* test = FResourceFile::OpenResourceFile(filename, true); + if (test != nullptr) + { + delete test; + return true; + } + } + return false; } //============================================================================= @@ -430,23 +420,6 @@ FString G_BuildSaveName (const char *prefix) #include "build.h" #include "mmulti.h" -static const int magic = 0xbeefcafe; -void WriteMagic(FileWriter *fw) -{ - fw->Write(&magic, 4); -} - -void CheckMagic(FileReader& fr) -{ - int m = 0; - fr.Read(&m, 4); - assert(m == magic); -#ifndef _DEBUG - if (m != magic) I_Error("Savegame corrupt"); -#endif -} - - #define V(x) x static spritetype zsp; static spriteext_t zspx; diff --git a/source/core/savegamehelp.h b/source/core/savegamehelp.h index b605f4835..84502debb 100644 --- a/source/core/savegamehelp.h +++ b/source/core/savegamehelp.h @@ -5,11 +5,6 @@ extern FixedBitArray activeSprites; -FileWriter *WriteSavegameChunk(const char *name); -FileReader ReadSavegameChunk(const char *name); - -void FinishSavegameRead(); - // Savegame utilities class FileReader; diff --git a/source/games/sw/src/interpso.h b/source/games/sw/src/interpso.h index b22254dad..616efe59e 100644 --- a/source/games/sw/src/interpso.h +++ b/source/games/sw/src/interpso.h @@ -27,8 +27,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #ifndef INTERPSO_H #define INTERPSO_H -#include "mfile.h" - BEGIN_SW_NS extern int32_t so_numinterpolations; diff --git a/source/games/sw/src/mfile.h b/source/games/sw/src/mfile.h deleted file mode 100644 index 8f30762e6..000000000 --- a/source/games/sw/src/mfile.h +++ /dev/null @@ -1,52 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 1997, 2005 - 3D Realms Entertainment - -This file is part of Shadow Warrior version 1.2 - -Shadow Warrior is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -Original Source: 1997 - Frank Maddin and Jim Norwood -Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms -*/ -//------------------------------------------------------------------------- - -#include "compat.h" - -#include "savegamehelp.h" - -BEGIN_SW_NS - -typedef FileWriter* MFILE_WRITE; -typedef FileReader* MFILE_READ; - -inline size_t MREAD(void* buf, size_t size, size_t nelem, FileReader* handle) -{ - return handle->Read(buf, size * nelem) / size; -} - -inline size_t MWRITE(void* buf, size_t size, size_t nelem, FileWriter* handle) -{ - return handle->Write(buf, size * nelem) / size; -} - -inline void MCLOSE_READ(FileReader* handle) -{ - handle->Close(); - FinishSavegameRead(); -} - -END_SW_NS diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index aa6e8417b..bd9c09cf6 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -1210,8 +1210,8 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, TRACK& w, TRACK* d int size = w.NumPoints ? w.NumPoints : 1; w.TrackPoint = (TRACK_POINT*)CallocMem(sizeof(TRACK_POINT), size); } - if (w.NumPoints > 0) arc.Array("points", w.TrackPoint, w.NumPoints) - .EndObject(); + if (w.NumPoints > 0) arc.Array("points", w.TrackPoint, w.NumPoints); + arc.EndObject(); } return arc; } @@ -1233,7 +1233,7 @@ void GameInterface::SerializeGameState(FSerializer& arc) SerializeSectUser(arc); so_serializeinterpolations(arc); arc("numplayers", numplayers) - .Array("players", Player, numplayers) + .Array("players", Player, numplayers) ("skill", Skill) ("screenpeek", screenpeek) ("randomseed", randomseed) @@ -1272,8 +1272,8 @@ void GameInterface::SerializeGameState(FSerializer& arc) ("serpwasseen", serpwasseen) ("sumowasseen", sumowasseen) ("zillawasseen", zillawasseen) - .Array("BossSpriteNum", BossSpriteNum, 3) - .Array("tracks", Track, countof(Track)) + .Array("BossSpriteNum", BossSpriteNum, 3); + arc.Array("tracks", Track, countof(Track)) ; postSerializePanelSprites(arc); arc.EndObject(); From c3e5cf322e935d4291a1e0f60d2a36deb2048c55 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 19 Apr 2021 00:24:25 +0200 Subject: [PATCH 16/18] - SW: cleaned up the depth variable handling in SECT_USER which was endian dependent, including the savegame handler --- source/games/sw/src/actor.cpp | 4 ++-- source/games/sw/src/coolg.cpp | 4 ++-- source/games/sw/src/coolie.cpp | 2 +- source/games/sw/src/eel.cpp | 4 ++-- source/games/sw/src/game.h | 6 +---- source/games/sw/src/hornet.cpp | 4 ++-- source/games/sw/src/jweapon.cpp | 8 +++---- source/games/sw/src/player.cpp | 4 ++-- source/games/sw/src/rooms.cpp | 4 ++-- source/games/sw/src/save.cpp | 2 +- source/games/sw/src/sprite.cpp | 6 ++--- source/games/sw/src/track.cpp | 39 +++++---------------------------- source/games/sw/src/weapon.cpp | 12 +++++----- 13 files changed, 34 insertions(+), 65 deletions(-) diff --git a/source/games/sw/src/actor.cpp b/source/games/sw/src/actor.cpp index 65b017abb..79f8601e5 100644 --- a/source/games/sw/src/actor.cpp +++ b/source/games/sw/src/actor.cpp @@ -455,7 +455,7 @@ DoActorDebris(short SpriteNum) } } - if (SectUser[sp->sectnum].Data() && SectUser[sp->sectnum]->depth > 10) // JBF: added null check + if (SectUser[sp->sectnum].Data() && FixedToInt(SectUser[sp->sectnum]->depth_fixed) > 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); @@ -540,7 +540,7 @@ KeepActorOnFloor(short SpriteNum) return; if (u->lo_sectp && SectUser[u->lo_sectp - sector].Data()) - depth = SectUser[u->lo_sectp - sector]->depth; + depth = FixedToInt(SectUser[u->lo_sectp - sector]->depth_fixed); else depth = 0; diff --git a/source/games/sw/src/coolg.cpp b/source/games/sw/src/coolg.cpp index 6ae1b33cf..d4ee8cd8b 100644 --- a/source/games/sw/src/coolg.cpp +++ b/source/games/sw/src/coolg.cpp @@ -668,8 +668,8 @@ int DoCoolgMatchPlayerZ(short SpriteNum) hiz = u->hiz; // adjust loz/hiz for water 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); + if (u->lo_sectp && SectUser[u->lo_sectp - sector].Data() && FixedToInt(SectUser[u->lo_sectp - sector]->depth_fixed)) + loz -= Z(FixedToInt(SectUser[u->lo_sectp - sector]->depth_fixed)) - Z(8); // lower bound if (u->lo_sp) diff --git a/source/games/sw/src/coolie.cpp b/source/games/sw/src/coolie.cpp index cdb011e90..ddfe249c6 100644 --- a/source/games/sw/src/coolie.cpp +++ b/source/games/sw/src/coolie.cpp @@ -478,7 +478,7 @@ void EnemyDefaults(short SpriteNum, ACTOR_ACTION_SETp action, PERSONALITYp perso if (SectUser[sectnum].Data() && TEST(u->lo_sectp->extra, SECTFX_SINK)) { - depth = SectUser[sectnum]->depth; + depth = FixedToInt(SectUser[sectnum]->depth_fixed); } else { diff --git a/source/games/sw/src/eel.cpp b/source/games/sw/src/eel.cpp index fa6900585..ab96b766f 100644 --- a/source/games/sw/src/eel.cpp +++ b/source/games/sw/src/eel.cpp @@ -504,8 +504,8 @@ int DoEelMatchPlayerZ(short SpriteNum) hiz = u->hiz; // adjust loz/hiz for water 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); + if (u->lo_sectp && SectUser[u->lo_sectp - sector].Data() && FixedToInt(SectUser[u->lo_sectp - sector]->depth_fixed)) + loz -= Z(FixedToInt(SectUser[u->lo_sectp - sector]->depth_fixed)) - Z(8); // lower bound if (u->lo_sp && u->tgt_sp == u->hi_sp) diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index bda4566a1..804525de2 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1552,11 +1552,7 @@ typedef struct SECT_USER { SECT_USER() { memset(this, 0, sizeof(*this)); } int dist, flags; - union - { - struct { short depth_fract, depth; }; // do NOT change this, doubles as a long FIXED point number - int depth_fixed; - }; + int depth_fixed; short stag, // ST? tag number - for certain things it helps to know it ang, height, diff --git a/source/games/sw/src/hornet.cpp b/source/games/sw/src/hornet.cpp index a5fa6bd85..6a7230b30 100644 --- a/source/games/sw/src/hornet.cpp +++ b/source/games/sw/src/hornet.cpp @@ -380,8 +380,8 @@ int DoHornetMatchPlayerZ(short SpriteNum) hiz = u->hiz; // adjust loz/hiz for water 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); + if (u->lo_sectp && SectUser[u->lo_sectp - sector].Data() && FixedToInt(SectUser[u->lo_sectp - sector]->depth_fixed)) + loz -= Z(FixedToInt(SectUser[u->lo_sectp - sector]->depth_fixed)) - Z(8); // lower bound if (u->lo_sp) diff --git a/source/games/sw/src/jweapon.cpp b/source/games/sw/src/jweapon.cpp index ee357d651..70ad98837 100644 --- a/source/games/sw/src/jweapon.cpp +++ b/source/games/sw/src/jweapon.cpp @@ -515,7 +515,7 @@ DoBloodSpray(int16_t Weapon) SET(u->Flags, SPR_BOUNCE); // no bouncing // underwater - if (u->lo_sectp && SectUser[sp->sectnum].Data() && SectUser[sp->sectnum]->depth) + if (u->lo_sectp && SectUser[sp->sectnum].Data() && FixedToInt(SectUser[sp->sectnum]->depth_fixed)) 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].Data() && SectUser[sp->sectnum]->depth) + if (u->lo_sectp && SectUser[sp->sectnum].Data() && FixedToInt(SectUser[sp->sectnum]->depth_fixed)) 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].Data() && SectUser[sp->sectnum]->depth) + if (u->lo_sectp && SectUser[sp->sectnum].Data() && FixedToInt(SectUser[sp->sectnum]->depth_fixed)) 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].Data() && SectUser[sp->sectnum]->depth) + if (u->lo_sectp && SectUser[sp->sectnum].Data() && FixedToInt(SectUser[sp->sectnum]->depth_fixed)) SET(u->Flags, SPR_BOUNCE); // no bouncing on // shallow water diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 6ef06080d..90367ccdb 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1462,8 +1462,8 @@ DoPlayerSetWadeDepth(PLAYERp pp) if (TEST(sectp->extra, SECTFX_SINK)) { // make sure your even in the water - if (pp->posz + PLAYER_HEIGHT > pp->lo_sectp->floorz - Z(SectUser[pp->lo_sectp - sector]->depth)) - pp->WadeDepth = SectUser[pp->lo_sectp - sector]->depth; + if (pp->posz + PLAYER_HEIGHT > pp->lo_sectp->floorz - Z(FixedToInt(SectUser[pp->lo_sectp - sector]->depth_fixed))) + pp->WadeDepth = FixedToInt(SectUser[pp->lo_sectp - sector]->depth_fixed); } } diff --git a/source/games/sw/src/rooms.cpp b/source/games/sw/src/rooms.cpp index 0ee79b5ba..e0684d681 100644 --- a/source/games/sw/src/rooms.cpp +++ b/source/games/sw/src/rooms.cpp @@ -492,8 +492,8 @@ void WaterAdjust(short florhit, int32_t* loz) { SECT_USERp sectu = SectUser[NORM_SECTOR(florhit)].Data(); - if (sectu && sectu->depth) - *loz += Z(sectu->depth); + if (sectu && FixedToInt(sectu->depth_fixed)) + *loz += Z(FixedToInt(sectu->depth_fixed)); } break; case HIT_SPRITE: diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index bd9c09cf6..8d237682b 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -801,7 +801,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, SECT_USER& w, SECT { arc("dist", w.dist, def->dist) ("flags", w.flags, def->flags) - ("depth_fract", w.depth_fract, def->depth_fract) + ("depth", w.depth_fixed, def->depth_fixed) ("stag", w.stag, def->stag) ("ang", w.ang, def->ang) ("height", w.height, def->height) diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index dabedb11a..c35ad0e52 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -1984,7 +1984,7 @@ SpriteSetup(void) if (TEST(bit, SECTFX_SINK)) { sectu = GetSectUser(sp->sectnum); - sectu->depth = sp->lotag; + sectu->depth_fixed = IntToFixed(sp->lotag); KillSprite(SpriteNum); } else if (TEST(bit, SECTFX_OPERATIONAL)) @@ -7155,8 +7155,8 @@ MissileWaterAdjust(short SpriteNum) if (u->lo_sectp) { SECT_USERp sectu = SectUser[u->lo_sectp - sector].Data(); - if (sectu && sectu->depth) - u->loz -= Z(sectu->depth); + if (sectu && FixedToInt(sectu->depth_fixed)) + u->loz -= Z(FixedToInt(sectu->depth_fixed)); } return 0; } diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index ed2d80f33..fdb44f96e 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -834,7 +834,7 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop) sop->zorig_ceiling[sop->num_sectors] = sector[k].ceilingz; if (TEST(sector[k].extra, SECTFX_SINK)) - sop->zorig_floor[sop->num_sectors] += Z(SectUser[k]->depth); + sop->zorig_floor[sop->num_sectors] += Z(FixedToInt(SectUser[k]->depth_fixed)); // lowest and highest floorz's if (sector[k].floorz > sop->floor_loz) @@ -2269,46 +2269,19 @@ void CallbackSOsink(ANIMp ap, void *data) ASSERT(su != NULL); ASSERT(GetSectUser(src_sector)); - tgt_depth = (GetSectUser(src_sector))->depth; + tgt_depth = FixedToInt((GetSectUser(src_sector))->depth_fixed); -#if 0 - for (w = &Water[0]; w < &Water[MAX_WATER]; w++) + short sectnum; + for (sectnum = 0; sectnum < numsectors; sectnum++) { - if (w->sector == dest_sector) + if (sectnum == dest_sector) { - ndx = AnimSet(&w->depth, Z(tgt_depth), ap->vel>>8); + ndx = AnimSet(ANIM_SUdepth, dest_sector, IntToFixed(tgt_depth), (ap->vel << 8) >> 8); AnimSetVelAdj(ndx, ap->vel_adj); - - // This is interesting - // Added a depth_fract to the struct so I could do a - // 16.16 Fixed point representation to change the depth - // in a more precise way - ndx = AnimSet((int *)&su->depth_fract, IntToFixed(tgt_depth), (ap->vel<<8)>>8); - AnimSetVelAdj(ndx, ap->vel_adj); - found = true; break; } } -#else - { - short sectnum; - for (sectnum = 0; sectnum < numsectors; sectnum++) - { - if (sectnum == dest_sector) - { - // This is interesting - // Added a depth_fract to the struct so I could do a - // 16.16 Fixed point representation to change the depth - // in a more precise way - ndx = AnimSet(ANIM_SUdepth, dest_sector, IntToFixed(tgt_depth), (ap->vel << 8) >> 8); - AnimSetVelAdj(ndx, ap->vel_adj); - found = true; - break; - } - } - } -#endif ASSERT(found); diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index b24a2c946..d2ea1f4d6 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -4516,7 +4516,7 @@ WeaponMoveHit(short SpriteNum) return true; } - if (SectUser[hit_sect].Data() && SectUser[hit_sect]->depth > 0) + if (SectUser[hit_sect].Data() && FixedToInt(SectUser[hit_sect]->depth_fixed) > 0) { SpawnSplash(SpriteNum); //SetSuicide(SpriteNum); @@ -4798,7 +4798,7 @@ DoFireballFlames(short SpriteNum) } else { - if (SectUser[sp->sectnum].Data() && SectUser[sp->sectnum]->depth > 0) + if (SectUser[sp->sectnum].Data() && FixedToInt(SectUser[sp->sectnum]->depth_fixed) > 0) { if (labs(sector[sp->sectnum].floorz - sp->z) <= Z(4)) { @@ -4871,7 +4871,7 @@ DoBreakFlames(short SpriteNum) } else { - if (SectUser[sp->sectnum].Data() && SectUser[sp->sectnum]->depth > 0) + if (SectUser[sp->sectnum].Data() && FixedToInt(SectUser[sp->sectnum]->depth_fixed) > 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].Data() && SectUser[hit_sect]->depth > 0) + if (SectUser[hit_sect].Data() && FixedToInt(SectUser[hit_sect]->depth_fixed) > 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].Data() && SectUser[sp->sectnum]->depth) + if (u->lo_sectp && SectUser[sp->sectnum].Data() && FixedToInt(SectUser[sp->sectnum]->depth_fixed)) SET(u->Flags, SPR_BOUNCE); // no bouncing on shallow water if (!TEST(u->Flags, SPR_BOUNCE)) @@ -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].Data() && SectUser[sp->sectnum]->depth) + if (u->lo_sectp && SectUser[sp->sectnum].Data() && FixedToInt(SectUser[sp->sectnum]->depth_fixed)) SET(u->Flags, SPR_BOUNCE); // no bouncing on shallow water if (!TEST(u->Flags, SPR_BOUNCE)) From a4f5a3268099a5c09d46be4bfd2b3c71d7cda2ac Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 19 Apr 2021 00:30:06 +0200 Subject: [PATCH 17/18] - fixed issue with restoring SO sprite array. This array has -1 for empty entries so it cannot be saved partially. --- source/games/sw/src/save.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index 8d237682b..420f5f1c5 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -662,7 +662,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, SECTOR_OBJECTstruc .Array("sector", w.sector, def->sector, w.num_sectors) // is this really different from sectp? .Array("zorig_floor", w.zorig_floor, def->zorig_floor, w.num_sectors) .Array("zorig_ceiling", w.zorig_ceiling, def->zorig_ceiling, w.num_sectors) - .Array("sp_num", w.sp_num, def->sp_num, sp_cnt + 1) + .Array("sp_num", w.sp_num, def->sp_num, countof(w.sp_num)) .Array("xorig", w.xorig, def->xorig, w.num_walls) .Array("yorig", w.yorig, def->yorig, w.num_walls) ("controller", w.controller, def->controller) From 729928c576b0335eeae8a0d298bd8fa8cc31ea14 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 19 Apr 2021 23:49:10 +0200 Subject: [PATCH 18/18] - SW: fixed bad serialization of sector object pointers --- source/games/sw/src/save.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index 420f5f1c5..e71037235 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -631,7 +631,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, SECTOR_OBJECTp& w, { int ndx = w ? int(w - SectorObject) : -1; arc(keyname, ndx); - w = ndx == -1 ? nullptr : SectorObject; + if (arc.isReading() )w = ndx == -1 ? nullptr : SectorObject + ndx; return arc; }