diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 92a23ec24..f8cfbdef6 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -78,7 +78,7 @@ void deletesprite(DDukeActor *const actor) S_StopSound(actor->s->lotag, actor); else S_RelinkActorSound(actor, nullptr); - ::deletesprite(actor->GetIndex()); + ::deletesprite(actor->GetSpriteIndex()); } //--------------------------------------------------------------------------- diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index e49bbe035..a84cefff8 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -1561,7 +1561,7 @@ static bool movefireball(DDukeActor* actor) int trail = actor->temp_data[1]; auto ball = spawn(actor, FIREBALL); auto spr = ball->s; - actor->temp_data[1] = ball->GetIndex(); + actor->temp_data[1] = ball->GetSpriteIndex(); spr->xvel = s->xvel; 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 }; - fire.Insert(ball->GetIndex(), proj); + fire.Insert(ball->GetSpriteIndex(), proj); changeactorstat(ball, STAT_PROJECTILE); } actor->temp_data[0]++; diff --git a/source/games/duke/src/dukeactor.h b/source/games/duke/src/dukeactor.h index 7c75b6479..d7804b525 100644 --- a/source/games/duke/src/dukeactor.h +++ b/source/games/duke/src/dukeactor.h @@ -97,22 +97,22 @@ inline int player_struct::GetPlayerNum() // Refactoring helpers/intermediates inline void changeactorstat(DDukeActor* a, int newstat) { - ::changespritestat(a->GetIndex(), newstat); + ::changespritestat(a->GetSpriteIndex(), newstat); } 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) { - return ::setsprite(a->GetIndex(), x, y, z); + return ::setsprite(a->GetSpriteIndex(), x, y, z); } 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. @@ -124,7 +124,7 @@ inline int setsprite(int i, int x, int y, int z) inline int ActorToScriptIndex(DDukeActor* a) { if (!a) return -1; - return a->GetIndex(); + return a->GetSpriteIndex(); } inline DDukeActor* ScriptIndexToActor(int index) @@ -139,7 +139,7 @@ int spawn_r(int j, int pn); 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]; } diff --git a/source/games/duke/src/gamevar.cpp b/source/games/duke/src/gamevar.cpp index 68b73a236..29b432626 100644 --- a/source/games/duke/src/gamevar.cpp +++ b/source/games/duke/src/gamevar.cpp @@ -286,7 +286,7 @@ int GetGameVarID(int id, DDukeActor* sActor, int sPlayer) } if (id == g_iThisActorID) { - return sActor->GetIndex(); + return sActor->GetSpriteIndex(); } if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER ) { @@ -305,7 +305,7 @@ int GetGameVarID(int id, DDukeActor* sActor, int sPlayer) // for the current actor if(sActor != nullptr) { - return aGameVars[id].plArray[sActor->GetIndex()]; + return aGameVars[id].plArray[sActor->GetSpriteIndex()]; } else { @@ -359,7 +359,7 @@ void SetGameVarID(int id, int lValue, DDukeActor* sActor, int sPlayer) else if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR ) { // 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 if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PLONG ) diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 0d9781deb..e410615a6 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -623,7 +623,7 @@ void resetpspritevars(int g) else s->pal = ps[j].palookup = ud.user_pals[j]; - ps[j].i = act->GetIndex(); + ps[j].i = act->GetSpriteIndex(); ps[j].frag_ps = j; act->SetOwner(act); diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 24a5ef141..1c909aaa7 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -147,7 +147,7 @@ int initspriteforspawn(DDukeActor* actj, int pn, const std::initializer_listpicnum = actj->s->picnum; sp = spawned->s; t = spawned->temp_data; - i = spawned->GetIndex(); + i = spawned->GetSpriteIndex(); } else { diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 2f506bf6d..9256a53e5 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -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. - 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& operator=(const DDukeActor& other) = delete; void clear() @@ -49,7 +49,7 @@ struct DDukeActor floorz = ceilingz = lastvx = lastvy = aflags = saved_ammo = 0; 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. inline DDukeActor* GetOwner() @@ -59,7 +59,7 @@ struct DDukeActor 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. @@ -70,7 +70,7 @@ struct DDukeActor 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.