- renamed DDukeActor::GetIndex to GetSpriteIndex to bring it in line with the other games.

This commit is contained in:
Christoph Oelckers 2021-10-24 09:22:35 +02:00
parent 7ebe492e94
commit 821f3d356b
7 changed files with 18 additions and 18 deletions

View file

@ -78,7 +78,7 @@ void deletesprite(DDukeActor *const actor)
S_StopSound(actor->s->lotag, actor); S_StopSound(actor->s->lotag, actor);
else else
S_RelinkActorSound(actor, nullptr); S_RelinkActorSound(actor, nullptr);
::deletesprite(actor->GetIndex()); ::deletesprite(actor->GetSpriteIndex());
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View file

@ -1561,7 +1561,7 @@ static bool movefireball(DDukeActor* actor)
int trail = actor->temp_data[1]; int trail = actor->temp_data[1];
auto ball = spawn(actor, FIREBALL); auto ball = spawn(actor, FIREBALL);
auto spr = ball->s; auto spr = ball->s;
actor->temp_data[1] = ball->GetIndex(); actor->temp_data[1] = ball->GetSpriteIndex();
spr->xvel = s->xvel; spr->xvel = s->xvel;
spr->yvel = s->yvel; spr->yvel = s->yvel;
@ -1585,7 +1585,7 @@ static bool movefireball(DDukeActor* actor)
FireProj proj = { spr->x, spr->y, spr->z, spr->xvel, spr->yvel, spr->zvel }; FireProj proj = { spr->x, spr->y, spr->z, spr->xvel, spr->yvel, spr->zvel };
fire.Insert(ball->GetIndex(), proj); fire.Insert(ball->GetSpriteIndex(), proj);
changeactorstat(ball, STAT_PROJECTILE); changeactorstat(ball, STAT_PROJECTILE);
} }
actor->temp_data[0]++; actor->temp_data[0]++;

View file

@ -97,22 +97,22 @@ inline int player_struct::GetPlayerNum()
// Refactoring helpers/intermediates // Refactoring helpers/intermediates
inline void changeactorstat(DDukeActor* a, int newstat) inline void changeactorstat(DDukeActor* a, int newstat)
{ {
::changespritestat(a->GetIndex(), newstat); ::changespritestat(a->GetSpriteIndex(), newstat);
} }
inline void changeactorsect(DDukeActor* a, int newsect) inline void changeactorsect(DDukeActor* a, int newsect)
{ {
::changespritesect(a->GetIndex(), newsect); ::changespritesect(a->GetSpriteIndex(), newsect);
} }
inline int setsprite(DDukeActor* a, int x, int y, int z) inline int setsprite(DDukeActor* a, int x, int y, int z)
{ {
return ::setsprite(a->GetIndex(), x, y, z); return ::setsprite(a->GetSpriteIndex(), x, y, z);
} }
inline int setsprite(DDukeActor* a, const vec3_t& pos) inline int setsprite(DDukeActor* a, const vec3_t& pos)
{ {
return ::setsprite(a->GetIndex(), pos.x, pos.y, pos.z); return ::setsprite(a->GetSpriteIndex(), pos.x, pos.y, pos.z);
} }
// see comment for changespritestat. // see comment for changespritestat.
@ -124,7 +124,7 @@ inline int setsprite(int i, int x, int y, int z)
inline int ActorToScriptIndex(DDukeActor* a) inline int ActorToScriptIndex(DDukeActor* a)
{ {
if (!a) return -1; if (!a) return -1;
return a->GetIndex(); return a->GetSpriteIndex();
} }
inline DDukeActor* ScriptIndexToActor(int index) inline DDukeActor* ScriptIndexToActor(int index)
@ -139,7 +139,7 @@ int spawn_r(int j, int pn);
inline DDukeActor* spawn(DDukeActor* spawner, int type) inline DDukeActor* spawn(DDukeActor* spawner, int type)
{ {
int i = (isRR()? spawn_r : spawn_d)(spawner ? spawner->GetIndex() : -1, type); int i = (isRR()? spawn_r : spawn_d)(spawner ? spawner->GetSpriteIndex() : -1, type);
return i == -1 ? nullptr : &hittype[i]; return i == -1 ? nullptr : &hittype[i];
} }

View file

@ -286,7 +286,7 @@ int GetGameVarID(int id, DDukeActor* sActor, int sPlayer)
} }
if (id == g_iThisActorID) if (id == g_iThisActorID)
{ {
return sActor->GetIndex(); return sActor->GetSpriteIndex();
} }
if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER ) if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER )
{ {
@ -305,7 +305,7 @@ int GetGameVarID(int id, DDukeActor* sActor, int sPlayer)
// for the current actor // for the current actor
if(sActor != nullptr) if(sActor != nullptr)
{ {
return aGameVars[id].plArray[sActor->GetIndex()]; return aGameVars[id].plArray[sActor->GetSpriteIndex()];
} }
else else
{ {
@ -359,7 +359,7 @@ void SetGameVarID(int id, int lValue, DDukeActor* sActor, int sPlayer)
else if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR ) else if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR )
{ {
// for the current actor // for the current actor
if (sActor != nullptr) aGameVars[id].plArray[sActor->GetIndex()]=lValue; if (sActor != nullptr) aGameVars[id].plArray[sActor->GetSpriteIndex()]=lValue;
else for (auto& i : aGameVars[id].plArray) i = lValue; // -1 sets all actors - was undefined OOB access in WW2GI. else for (auto& i : aGameVars[id].plArray) i = lValue; // -1 sets all actors - was undefined OOB access in WW2GI.
} }
else if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PLONG ) else if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PLONG )

View file

@ -623,7 +623,7 @@ void resetpspritevars(int g)
else else
s->pal = ps[j].palookup = ud.user_pals[j]; s->pal = ps[j].palookup = ud.user_pals[j];
ps[j].i = act->GetIndex(); ps[j].i = act->GetSpriteIndex();
ps[j].frag_ps = j; ps[j].frag_ps = j;
act->SetOwner(act); act->SetOwner(act);

View file

@ -147,7 +147,7 @@ int initspriteforspawn(DDukeActor* actj, int pn, const std::initializer_list<int
spawned->picnum = actj->s->picnum; spawned->picnum = actj->s->picnum;
sp = spawned->s; sp = spawned->s;
t = spawned->temp_data; t = spawned->temp_data;
i = spawned->GetIndex(); i = spawned->GetSpriteIndex();
} }
else else
{ {

View file

@ -39,7 +39,7 @@ struct DDukeActor
static DDukeActor* 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.
DDukeActor() : s(&sprite[this - array()]) {} // little trick to initialize the reference automatically. ;) DDukeActor() : s(&sprite[this - array()]) {}
DDukeActor(const DDukeActor& other) = delete; // we also do not want to allow copies. DDukeActor(const DDukeActor& other) = delete; // we also do not want to allow copies.
DDukeActor& operator=(const DDukeActor& other) = delete; DDukeActor& operator=(const DDukeActor& other) = delete;
void clear() void clear()
@ -49,7 +49,7 @@ struct DDukeActor
floorz = ceilingz = lastvx = lastvy = aflags = saved_ammo = 0; floorz = ceilingz = lastvx = lastvy = aflags = saved_ammo = 0;
memset(temp_data, 0, sizeof(temp_data)); memset(temp_data, 0, sizeof(temp_data));
} }
int GetIndex() const { return int(this - array()); } int GetSpriteIndex() 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. // 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 DDukeActor* GetOwner() inline DDukeActor* GetOwner()
@ -59,7 +59,7 @@ struct DDukeActor
inline void SetOwner(DDukeActor* a) inline void SetOwner(DDukeActor* a)
{ {
s->owner = a? a->GetIndex() : -1; s->owner = a? a->GetSpriteIndex() : -1;
} }
// same for the 'hittype' owner - which is normally the shooter in an attack. // same for the 'hittype' owner - which is normally the shooter in an attack.
@ -70,7 +70,7 @@ struct DDukeActor
inline void SetHitOwner(DDukeActor* a) inline void SetHitOwner(DDukeActor* a)
{ {
owner = a ? a->GetIndex() : -1; owner = a ? a->GetSpriteIndex() : -1;
} }
// This used the Owner field - better move this to something more safe. // This used the Owner field - better move this to something more safe.