From a6f9c2708e4eb3c6d7ae0293984662ffefb9b89c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 30 Dec 2022 19:30:53 +0100 Subject: [PATCH] - no more picnum in gameexec.cpp --- source/games/duke/src/animatesprites.cpp | 2 +- source/games/duke/src/gameexec.cpp | 17 +++++++---------- source/games/duke/src/inlines.h | 5 ----- source/games/duke/src/savegame.cpp | 2 +- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/source/games/duke/src/animatesprites.cpp b/source/games/duke/src/animatesprites.cpp index dfed550cca7..f5de2d90285 100644 --- a/source/games/duke/src/animatesprites.cpp +++ b/source/games/duke/src/animatesprites.cpp @@ -109,7 +109,7 @@ bool RRRAFullbrightHack(tspritetype* t, int k) void applyanimations(tspritetype* t, DDukeActor* h, const DVector2& viewVec, DAngle viewang) { - if (GetActorInfo(h)->scriptaddress && !(h->flags2 & SFLAG2_DONTANIMATE))// && (t->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) != CSTAT_SPRITE_ALIGNMENT_SLAB) + if (h->conInfo()->scriptaddress && !(h->flags2 & SFLAG2_DONTANIMATE))// && (t->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) != CSTAT_SPRITE_ALIGNMENT_SLAB) { DAngle kang; auto action = h->curAction; diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index f791433425d..051ab960f1e 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -1400,7 +1400,7 @@ static int ifcanshoottarget(DDukeActor *actor, int g_p, int g_x) } if (hs > sclip) { - if (hit != nullptr && hit->spr.picnum == actor->spr.picnum) + if (hit != nullptr && hit->GetClass() == actor->GetClass()) return 0; else { @@ -1409,7 +1409,7 @@ static int ifcanshoottarget(DDukeActor *actor, int g_p, int g_x) actor->spr.Angles.Yaw -= angdif; if (hs > sclip) { - if (hit != nullptr && hit->spr.picnum == actor->spr.picnum) + if (hit != nullptr && hit->GetClass() == actor->GetClass()) return 0; else { @@ -1418,7 +1418,7 @@ static int ifcanshoottarget(DDukeActor *actor, int g_p, int g_x) actor->spr.Angles.Yaw -= angdif; if (hs > 48) { - if (hit != nullptr && hit->spr.picnum == actor->spr.picnum) + if (hit != nullptr && hit->GetClass() == actor->GetClass()) return 0; return 1; } @@ -1997,7 +1997,7 @@ int ParseState::parse(void) break; case concmd_ifactor: insptr++; - parseifelse(g_ac->spr.picnum == *insptr); + parseifelse(g_ac->GetClass() == GetSpawnType(*insptr)); break; case concmd_resetcount: insptr++; @@ -2127,7 +2127,6 @@ int ParseState::parse(void) if (info != nullptr) { g_ac->ChangeType(info->cls); - g_ac->spr.picnum = *insptr; } insptr++; break; @@ -2471,7 +2470,7 @@ int ParseState::parse(void) DukeStatIterator it(STAT_ACTOR); while (auto actj = it.Next()) { - if (actj->spr.picnum == lType) + if (actj->GetClass() == GetSpawnType(lType)) { lTemp = (g_ac->spr.pos.XY() - actj->spr.pos.XY()).Length(); if (lTemp < lMaxDist) @@ -2514,7 +2513,7 @@ int ParseState::parse(void) DukeStatIterator it(STAT_ACTOR); while (auto actj = it.Next()) { - if (actj->spr.picnum == lType) + if (actj->GetClass() == GetSpawnType(lType)) { lTemp = (g_ac->spr.pos.XY() - actj->spr.pos.XY()).Length(); if (lTemp < lMaxDist) @@ -3233,9 +3232,7 @@ bool execute(DDukeActor *actor,int p,double pdist) s.g_p = p; // Player ID s.g_x = int(pdist / maptoworld); // ?? s.g_ac = actor; - s.insptr = &ScriptCode[4 + (gs.actorinfo[actor->spr.picnum].scriptaddress)]; - auto insptr = coninf? &ScriptCode[4 + coninf->scriptaddress] : nullptr; - if (insptr != s.insptr) Printf("%s: %p vs. %p\n", insptr, s.insptr); + s.insptr = coninf? &ScriptCode[4 + coninf->scriptaddress] : nullptr; s.killit_flag = 0; int done; diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index 2f029a8c703..15ec74f2b96 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -311,11 +311,6 @@ inline void addkill(player_struct* p, DDukeActor* g_ac, int amount) g_ac->actorstayput = nullptr; } -inline ActorInfo* GetActorInfo(DDukeActor* actor) -{ - auto cls = static_cast(actor->GetClass()); - return &gs.actorinfo[cls->ActorInfo()->TypeNum]; -} inline const ActorInfo* DDukeActor::conInfo() const { diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index 52eaaebcfa2..78b36cd4dcb 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -290,7 +290,7 @@ void DDukeActor::Serialize(FSerializer& arc) arc("cgg", cgg) ("spriteextra", spriteextra) - ("picnum", attackertype) + ("attackertype", attackertype) ("ang", hitang) ("extra", hitextra) ("owneractor", ownerActor)