From fefc9e91dadccb4a47e4dc7493c679fc11e6698e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 30 Aug 2021 08:12:39 +0200 Subject: [PATCH] - rename weaponhit to DDukeActor. Just make do with one name instead of aliasing it. --- source/games/duke/src/animatesprites_d.cpp | 2 +- source/games/duke/src/animatesprites_r.cpp | 2 +- source/games/duke/src/gamevar.h | 3 +-- source/games/duke/src/global.cpp | 2 +- source/games/duke/src/savegame.cpp | 4 ++-- source/games/duke/src/types.h | 26 ++++++++++------------ 6 files changed, 18 insertions(+), 21 deletions(-) diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index c72d4c58c..1797ae32f 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -51,7 +51,7 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int int l, t1, t3, t4; spritetype* s; tspritetype* t; - weaponhit* h; + DDukeActor* h; for (j = 0; j < spritesortcnt; j++) { diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index 4832c7843..dd2d2cb44 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -44,7 +44,7 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int int l, t1, t3, t4; spritetype* s; tspritetype* t; - weaponhit* h; + DDukeActor* h; int bg = 0; diff --git a/source/games/duke/src/gamevar.h b/source/games/duke/src/gamevar.h index ca383a25b..9fb32adc3 100644 --- a/source/games/duke/src/gamevar.h +++ b/source/games/duke/src/gamevar.h @@ -124,8 +124,7 @@ int GetDefID(const char *szGameLabel); void ClearGameVars(void); void AddSystemVars(); void ResetGameVars(void); -struct weaponhit; -using DDukeActor = weaponhit; +struct DDukeActor; int GetGameVarID(int id, DDukeActor* sActor, int sPlayer); void SetGameVarID(int id, int lValue, DDukeActor* sActor, int sPlayer); int GetGameVar(const char* szGameLabel, int lDefault, DDukeActor* sActor, int sPlayer); diff --git a/source/games/duke/src/global.cpp b/source/games/duke/src/global.cpp index d6ea7a92b..e6a5caca4 100644 --- a/source/games/duke/src/global.cpp +++ b/source/games/duke/src/global.cpp @@ -91,7 +91,7 @@ bool sound445done; // used in checksectors_r. This was local state inside // serialized uint8_t sectorextra[MAXSECTORS]; // something about keys, all access through the haskey function. -weaponhit hittype[MAXSPRITES + 1]; // +1 to have a blank entry for serialization, all access in game code through the iterators. +DDukeActor hittype[MAXSPRITES + 1]; // +1 to have a blank entry for serialization, all access in game code through the iterators. int spriteqamount = 64; // internal sprite queue int spriteqloc; DDukeActor* spriteq[1024]; diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index 3f5cf3ae2..f99f049db 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -39,7 +39,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms // //========================================================================== -template<> FSerializer& Serialize(FSerializer& arc, const char* key, Duke3d::weaponhit*& ht, Duke3d::weaponhit** def) +template<> FSerializer& Serialize(FSerializer& arc, const char* key, Duke3d::DDukeActor*& ht, Duke3d::DDukeActor** def) { int index = ht? int(ht - Duke3d::hittype) : -1; assert(index >= -1 && index < MAXSPRITES); @@ -268,7 +268,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w, } -FSerializer& Serialize(FSerializer& arc, const char* keyname, weaponhit& w, weaponhit* def) +FSerializer& Serialize(FSerializer& arc, const char* keyname, DDukeActor& w, DDukeActor* def) { if (!def) def = &hittype[MAXSPRITES]; if (arc.BeginObject(keyname)) diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 14d081e6b..2f506bf6d 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -20,7 +20,7 @@ struct STATUSBARTYPE bool gotweapon[MAX_WEAPONS]; }; -struct weaponhit +struct DDukeActor { uint8_t cgg; uint8_t spriteextra; // moved here for easier maintenance. This was originally a hacked in field in the sprite structure called 'filler'. @@ -34,14 +34,14 @@ struct weaponhit int palvals; }; int temp_data[6]; - weaponhit* temp_actor, *seek_actor; + DDukeActor* temp_actor, *seek_actor; spritetype* s; // direct reference to the corresponding sprite. - static weaponhit* array(); // this is necessary to allow define inline functions referencing the global array inside the definition itself. + static DDukeActor* array(); // this is necessary to allow define inline functions referencing the global array inside the definition itself. - weaponhit() : s(&sprite[this - array()]) {} // little trick to initialize the reference automatically. ;) - weaponhit(const weaponhit& other) = delete; // we also do not want to allow copies. - weaponhit& operator=(const weaponhit& other) = delete; + DDukeActor() : s(&sprite[this - array()]) {} // little trick to initialize the reference automatically. ;) + DDukeActor(const DDukeActor& other) = delete; // we also do not want to allow copies. + DDukeActor& operator=(const DDukeActor& other) = delete; void clear() { cgg = spriteextra = 0; @@ -52,23 +52,23 @@ struct weaponhit int GetIndex() const { return int(this - array()); } // Wrapper around some ugliness. The 'owner' field gets abused by some actors, so better wrap its real use in access functions to keep things in order. - inline weaponhit* GetOwner() + inline DDukeActor* GetOwner() { return s->owner < 0 ? nullptr : &array()[s->owner]; } - inline void SetOwner(weaponhit* a) + inline void SetOwner(DDukeActor* a) { s->owner = a? a->GetIndex() : -1; } // same for the 'hittype' owner - which is normally the shooter in an attack. - inline weaponhit* GetHitOwner() + inline DDukeActor* GetHitOwner() { return owner < 0 ? nullptr : &array()[owner]; } - inline void SetHitOwner(weaponhit* a) + inline void SetHitOwner(DDukeActor* a) { owner = a ? a->GetIndex() : -1; } @@ -93,10 +93,8 @@ struct weaponhit }; -extern weaponhit hittype[MAXSPRITES + 1]; -inline weaponhit* weaponhit::array() { return hittype; } - -using DDukeActor = weaponhit; // we do not really want that stupid name in our interface (but also not rename the struct yet.) The preceding 'D' is for the DObject interface this should be transitioned to later. +extern DDukeActor hittype[MAXSPRITES + 1]; +inline DDukeActor* DDukeActor::array() { return hittype; } struct animwalltype {