Skip to content

Commit

Permalink
- rename weaponhit to DDukeActor.
Browse files Browse the repository at this point in the history
Just make do with one name instead of aliasing it.
  • Loading branch information
coelckers committed Aug 30, 2021
1 parent 2b6bc41 commit fefc9e9
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 21 deletions.
2 changes: 1 addition & 1 deletion source/games/duke/src/animatesprites_d.cpp
Expand Up @@ -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++)
{
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/animatesprites_r.cpp
Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions source/games/duke/src/gamevar.h
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/global.cpp
Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions source/games/duke/src/savegame.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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))
Expand Down
26 changes: 12 additions & 14 deletions source/games/duke/src/types.h
Expand Up @@ -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'.
Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -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
{
Expand Down

0 comments on commit fefc9e9

Please sign in to comment.