From 5a9978a27bdf30ec9ca667bf6e20c6cc4c6f4a18 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 17 Oct 2021 16:22:25 +0200 Subject: [PATCH] - extended the run list to handle actor targets. Also renamed fields to be more descriptive. --- source/games/exhumed/src/aistuff.h | 22 ++++----- source/games/exhumed/src/anims.cpp | 6 +-- source/games/exhumed/src/anubis.cpp | 12 ++--- source/games/exhumed/src/bubbles.cpp | 6 +-- source/games/exhumed/src/bullet.cpp | 6 +-- source/games/exhumed/src/fish.cpp | 18 +++---- source/games/exhumed/src/grenade.cpp | 8 ++-- source/games/exhumed/src/lavadude.cpp | 16 +++---- source/games/exhumed/src/lion.cpp | 12 ++--- source/games/exhumed/src/move.cpp | 2 +- source/games/exhumed/src/mummy.cpp | 10 ++-- source/games/exhumed/src/object.cpp | 40 ++++++++-------- source/games/exhumed/src/player.cpp | 14 +++--- source/games/exhumed/src/queen.cpp | 32 ++++++------- source/games/exhumed/src/ra.cpp | 8 ++-- source/games/exhumed/src/rat.cpp | 10 ++-- source/games/exhumed/src/rex.cpp | 12 ++--- source/games/exhumed/src/roach.cpp | 12 ++--- source/games/exhumed/src/runlist.cpp | 67 ++++++++++++++++++++------- source/games/exhumed/src/scorp.cpp | 14 +++--- source/games/exhumed/src/set.cpp | 12 ++--- source/games/exhumed/src/snake.cpp | 6 +-- source/games/exhumed/src/spider.cpp | 12 ++--- source/games/exhumed/src/switch.cpp | 42 ++++++++--------- source/games/exhumed/src/wasp.cpp | 10 ++-- 25 files changed, 219 insertions(+), 190 deletions(-) diff --git a/source/games/exhumed/src/aistuff.h b/source/games/exhumed/src/aistuff.h index 9d060cae839..b28c6e184a2 100644 --- a/source/games/exhumed/src/aistuff.h +++ b/source/games/exhumed/src/aistuff.h @@ -406,8 +406,9 @@ enum struct RunStruct { - int nRef; - int nVal; + int nAIType; // todo later: replace this with an AI pointer + int nObjIndex; // If object is a non-actor / not refactored yet. + DExhumedActor* pObjActor; // If object is an actor short next; short prev; }; @@ -437,15 +438,15 @@ enum class EMessageType struct RunListEvent { EMessageType nMessage; - int nIndex; // mostly the player, sometimes the channel list + int nParam; // mostly the player, sometimes the channel list + int nObjIndex; + DExhumedActor* pObjActor; tspritetype* pTSprite; // for the draw event - DExhumedActor* pActor; // for the damage event, radialSpr for radial damage - owner will not be passed as it can be retrieved from this. + DExhumedActor* pOtherActor; // for the damage event, radialSpr for radial damage - owner will not be passed as it can be retrieved from this. int nDamage, nRun; int nRadialDamage; // Radial damage needs a bit more info. int nDamageRadius; - - int RunValue() const; }; struct ExhumedAI @@ -736,11 +737,6 @@ typedef void(*AiFunc)(int, int, int, int nRun); extern FreeListArray RunData; -inline int RunListEvent::RunValue() const -{ - return RunData[nRun].nVal; -} - extern RunChannel sRunChannels[kMaxChannels]; extern short NewRun; extern int nRadialOwner; @@ -750,7 +746,9 @@ void runlist_InitRun(); int runlist_GrabRun(); int runlist_FreeRun(int nRun); -int runlist_AddRunRec(int a, int b, int c); +int runlist_AddRunRec(int index, int object, int aitype); +int runlist_AddRunRec(int index, DExhumedActor* object, int aitype); +int runlist_AddRunRec(int index, RunStruct* other); int runlist_HeadRun(); void runlist_InitChan(); void runlist_ChangeChannel(int eax, short dx); diff --git a/source/games/exhumed/src/anims.cpp b/source/games/exhumed/src/anims.cpp index 2199c6b862d..ffa5c1816c7 100644 --- a/source/games/exhumed/src/anims.cpp +++ b/source/games/exhumed/src/anims.cpp @@ -152,7 +152,7 @@ short GetAnimSprite(short nAnim) void AIAnim::Tick(RunListEvent* ev) { - short nAnim = RunData[ev->nRun].nVal; + short nAnim = RunData[ev->nRun].nObjIndex; assert(nAnim >= 0 && nAnim < kMaxAnims); short nSprite = AnimList[nAnim].nSprite; @@ -264,11 +264,11 @@ void AIAnim::Tick(RunListEvent* ev) void AIAnim::Draw(RunListEvent* ev) { - short nAnim = RunData[ev->nRun].nVal; + short nAnim = RunData[ev->nRun].nObjIndex; assert(nAnim >= 0 && nAnim < kMaxAnims); short nSeq = AnimList[nAnim].nSeq; - seq_PlotSequence(ev->nIndex, nSeq, AnimList[nAnim].field_2, 0x101); + seq_PlotSequence(ev->nParam, nSeq, AnimList[nAnim].field_2, 0x101); ev->pTSprite->owner = -1; } diff --git a/source/games/exhumed/src/anubis.cpp b/source/games/exhumed/src/anubis.cpp index 6a420517149..32e8bc50830 100644 --- a/source/games/exhumed/src/anubis.cpp +++ b/source/games/exhumed/src/anubis.cpp @@ -157,7 +157,7 @@ void BuildAnubis(int nSprite, int x, int y, int z, int nSector, int nAngle, uint void AIAnubis::Tick(RunListEvent* ev) { - int nAnubis = ev->RunValue(); + int nAnubis = RunData[ev->nRun].nObjIndex; auto ap = &AnubisList[nAnubis]; int nSprite = ap->nSprite; auto sp = &sprite[nSprite]; @@ -399,13 +399,13 @@ void AIAnubis::Tick(RunListEvent* ev) void AIAnubis::Draw(RunListEvent* ev) { - auto ap = &AnubisList[ev->RunValue()]; - seq_PlotSequence(ev->nIndex, SeqOffsets[kSeqAnubis] + AnubisSeq[ap->nAction].a, ap->nFrame, AnubisSeq[ap->nAction].b); + auto ap = &AnubisList[RunData[ev->nRun].nObjIndex]; + seq_PlotSequence(ev->nParam, SeqOffsets[kSeqAnubis] + AnubisSeq[ap->nAction].a, ap->nFrame, AnubisSeq[ap->nAction].b); } void AIAnubis::RadialDamage(RunListEvent* ev) { - auto ap = &AnubisList[ev->RunValue()]; + auto ap = &AnubisList[RunData[ev->nRun].nObjIndex]; if (ap->nAction < 11) { ev->nDamage = runlist_CheckRadialDamage(ap->nSprite); @@ -415,7 +415,7 @@ void AIAnubis::RadialDamage(RunListEvent* ev) void AIAnubis::Damage(RunListEvent* ev) { - auto ap = &AnubisList[ev->RunValue()]; + auto ap = &AnubisList[RunData[ev->nRun].nObjIndex]; int nSprite = ap->nSprite; auto sp = &sprite[nSprite]; int nAction = ap->nAction; @@ -430,7 +430,7 @@ void AIAnubis::Damage(RunListEvent* ev) if (ap->nHealth > 0) { - int nTarget = ev->nIndex; + int nTarget = ev->nParam; // loc_258D6: if (nTarget < 0) { diff --git a/source/games/exhumed/src/bubbles.cpp b/source/games/exhumed/src/bubbles.cpp index c84419cae7a..70da34ea76a 100644 --- a/source/games/exhumed/src/bubbles.cpp +++ b/source/games/exhumed/src/bubbles.cpp @@ -164,7 +164,7 @@ int BuildBubble(int x, int y, int z, short nSector) void AIBubble::Tick(RunListEvent* ev) { - short nBubble = RunData[ev->nRun].nVal; + short nBubble = RunData[ev->nRun].nObjIndex; assert(nBubble >= 0 && nBubble < kMaxBubbles); short nSprite = BubbleList[nBubble].nSprite; @@ -197,10 +197,10 @@ void AIBubble::Tick(RunListEvent* ev) void AIBubble::Draw(RunListEvent* ev) { - short nBubble = RunData[ev->nRun].nVal; + short nBubble = RunData[ev->nRun].nObjIndex; assert(nBubble >= 0 && nBubble < kMaxBubbles); - seq_PlotSequence(ev->nIndex, BubbleList[nBubble].nSeq, BubbleList[nBubble].nFrame, 1); + seq_PlotSequence(ev->nParam, BubbleList[nBubble].nSeq, BubbleList[nBubble].nFrame, 1); ev->pTSprite->owner = -1; } diff --git a/source/games/exhumed/src/bullet.cpp b/source/games/exhumed/src/bullet.cpp index 621350d9a9d..75088a99e87 100644 --- a/source/games/exhumed/src/bullet.cpp +++ b/source/games/exhumed/src/bullet.cpp @@ -813,7 +813,7 @@ int BuildBullet(short nSprite, int nType, int, int, int val1, int nAngle, int va void AIBullet::Tick(RunListEvent* ev) { - short nBullet = RunData[ev->nRun].nVal; + short nBullet = RunData[ev->nRun].nObjIndex; assert(nBullet >= 0 && nBullet < kMaxBullets); short nSeq = SeqOffsets[BulletList[nBullet].nSeq]; @@ -853,12 +853,12 @@ void AIBullet::Tick(RunListEvent* ev) void AIBullet::Draw(RunListEvent* ev) { - short nBullet = RunData[ev->nRun].nVal; + short nBullet = RunData[ev->nRun].nObjIndex; assert(nBullet >= 0 && nBullet < kMaxBullets); short nSeq = SeqOffsets[BulletList[nBullet].nSeq]; - short nSprite2 = ev->nIndex; + short nSprite2 = ev->nParam; mytsprite[nSprite2].statnum = 1000; if (BulletList[nBullet].nType == 15) diff --git a/source/games/exhumed/src/fish.cpp b/source/games/exhumed/src/fish.cpp index 2d88cff7e8f..2ff1a77791e 100644 --- a/source/games/exhumed/src/fish.cpp +++ b/source/games/exhumed/src/fish.cpp @@ -149,7 +149,7 @@ void BuildBlood(int x, int y, int z, short nSector) void AIFishLimb::Tick(RunListEvent* ev) { - short nFish = RunData[ev->nRun].nVal; + short nFish = RunData[ev->nRun].nObjIndex; short nSprite = FishChunk[nFish].nSprite; assert(nSprite >= 0 && nSprite < kMaxSprites); auto pSprite = &sprite[nSprite]; @@ -204,9 +204,9 @@ void AIFishLimb::Tick(RunListEvent* ev) void AIFishLimb::Draw(RunListEvent* ev) { - short nFish = RunData[ev->nRun].nVal; + short nFish = RunData[ev->nRun].nObjIndex; int nSeq = SeqOffsets[kSeqFish] + FishChunk[nFish].nSeqIndex; - seq_PlotSequence(ev->nIndex, nSeq, FishChunk[nFish].nIndex, 1); + seq_PlotSequence(ev->nParam, nSeq, FishChunk[nFish].nIndex, 1); } @@ -315,18 +315,18 @@ void DestroyFish(short nFish) void AIFish::Draw(RunListEvent* ev) { - short nFish = RunData[ev->nRun].nVal; + short nFish = RunData[ev->nRun].nObjIndex; assert(nFish >= 0 && nFish < (int)FishList.Size()); short nAction = FishList[nFish].nAction; - seq_PlotSequence(ev->nIndex, SeqOffsets[kSeqFish] + FishSeq[nAction].a, FishList[nFish].nFrame, FishSeq[nAction].b); + seq_PlotSequence(ev->nParam, SeqOffsets[kSeqFish] + FishSeq[nAction].a, FishList[nFish].nFrame, FishSeq[nAction].b); ev->pTSprite->owner = -1; return; } void AIFish::RadialDamage(RunListEvent* ev) { - short nFish = RunData[ev->nRun].nVal; + short nFish = RunData[ev->nRun].nObjIndex; short nSprite = FishList[nFish].nSprite; if (FishList[nFish].nHealth <= 0) { @@ -347,7 +347,7 @@ void AIFish::RadialDamage(RunListEvent* ev) void AIFish::Damage(RunListEvent* ev) { - short nFish = RunData[ev->nRun].nVal; + short nFish = RunData[ev->nRun].nObjIndex; assert(nFish >= 0 && nFish < (int)FishList.Size()); short nAction = FishList[nFish].nAction; short nSprite = FishList[nFish].nSprite; @@ -385,7 +385,7 @@ void AIFish::Damage(RunListEvent* ev) } else { - short nTarget = ev->nIndex; + short nTarget = ev->nParam; if (nTarget >= 0 && sprite[nTarget].statnum < 199) { FishList[nFish].nTarget = nTarget; @@ -399,7 +399,7 @@ void AIFish::Damage(RunListEvent* ev) void AIFish::Tick(RunListEvent* ev) { - short nFish = RunData[ev->nRun].nVal; + short nFish = RunData[ev->nRun].nObjIndex; assert(nFish >= 0 && nFish < (int)FishList.Size()); short nAction = FishList[nFish].nAction; short nSprite = FishList[nFish].nSprite; diff --git a/source/games/exhumed/src/grenade.cpp b/source/games/exhumed/src/grenade.cpp index c669f5164d6..8b7f4808f0b 100644 --- a/source/games/exhumed/src/grenade.cpp +++ b/source/games/exhumed/src/grenade.cpp @@ -278,16 +278,16 @@ void ExplodeGrenade(short nGrenade) void AIGrenade::Draw(RunListEvent* ev) { - short nGrenade = RunData[ev->nRun].nVal; + short nGrenade = RunData[ev->nRun].nObjIndex; assert(nGrenade >= 0 && nGrenade < kMaxGrenades); short nSeq = GrenadeList[nGrenade].field_C ? SeqOffsets[kSeqGrenBoom] : SeqOffsets[kSeqGrenRoll] + GrenadeList[nGrenade].field_A; - seq_PlotSequence(ev->nIndex, nSeq, GrenadeList[nGrenade].field_2 >> 8, 1); + seq_PlotSequence(ev->nParam, nSeq, GrenadeList[nGrenade].field_2 >> 8, 1); } void AIGrenade::Tick(RunListEvent* ev) { - short nGrenade = RunData[ev->nRun].nVal; + short nGrenade = RunData[ev->nRun].nObjIndex; assert(nGrenade >= 0 && nGrenade < kMaxGrenades); short nGrenadeSprite = GrenadeList[nGrenade].nSprite; @@ -415,7 +415,7 @@ void AIGrenade::Tick(RunListEvent* ev) void AIGrenade::RadialDamage(RunListEvent* ev) { - short nGrenade = RunData[ev->nRun].nVal; + short nGrenade = RunData[ev->nRun].nObjIndex; assert(nGrenade >= 0 && nGrenade < kMaxGrenades); short nGrenadeSprite = GrenadeList[nGrenade].nSprite; diff --git a/source/games/exhumed/src/lavadude.cpp b/source/games/exhumed/src/lavadude.cpp index ac7387d447a..53212191114 100644 --- a/source/games/exhumed/src/lavadude.cpp +++ b/source/games/exhumed/src/lavadude.cpp @@ -115,7 +115,7 @@ int BuildLavaLimb(int nSprite, int edx, int ebx) void AILavaDudeLimb::Tick(RunListEvent* ev) { - short nSprite = RunData[ev->nRun].nVal; + short nSprite = RunData[ev->nRun].nObjIndex; assert(nSprite >= 0 && nSprite < kMaxSprites); auto pSprite = &sprite[nSprite]; @@ -139,10 +139,10 @@ void AILavaDudeLimb::Tick(RunListEvent* ev) void AILavaDudeLimb::Draw(RunListEvent* ev) { - short nSprite = RunData[ev->nRun].nVal; + short nSprite = RunData[ev->nRun].nObjIndex; assert(nSprite >= 0 && nSprite < kMaxSprites); auto pSprite = &sprite[nSprite]; - seq_PlotSequence(ev->nIndex, (SeqOffsets[kSeqLavag] + 30) + pSprite->picnum, 0, 1); + seq_PlotSequence(ev->nParam, (SeqOffsets[kSeqLavag] + 30) + pSprite->picnum, 0, 1); } void FuncLavaLimb(int nObject, int nMessage, int nDamage, int nRun) @@ -211,20 +211,20 @@ void BuildLava(short nSprite, int x, int y, int, short nSector, short nAngle, in void AILavaDude::Draw(RunListEvent* ev) { - unsigned nLava = RunData[ev->nRun].nVal; + unsigned nLava = RunData[ev->nRun].nObjIndex; assert(nLava < LavaList.Size()); short nAction = LavaList[nLava].nAction; short nSeq = LavadudeSeq[nAction].a + SeqOffsets[kSeqLavag]; - seq_PlotSequence(ev->nIndex, nSeq, LavaList[nLava].nFrame, LavadudeSeq[nAction].b); + seq_PlotSequence(ev->nParam, nSeq, LavaList[nLava].nFrame, LavadudeSeq[nAction].b); ev->pTSprite->owner = -1; return; } void AILavaDude::Damage(RunListEvent* ev) { - unsigned nLava = RunData[ev->nRun].nVal; + unsigned nLava = RunData[ev->nRun].nObjIndex; assert(nLava < LavaList.Size()); short nAction = LavaList[nLava].nAction; @@ -250,7 +250,7 @@ void AILavaDude::Damage(RunListEvent* ev) } else { - short nTarget = ev->nIndex; + short nTarget = ev->nParam; if (nTarget >= 0) { @@ -276,7 +276,7 @@ void AILavaDude::Damage(RunListEvent* ev) void AILavaDude::Tick(RunListEvent* ev) { - unsigned nLava = RunData[ev->nRun].nVal; + unsigned nLava = RunData[ev->nRun].nObjIndex; assert(nLava < LavaList.Size()); short nAction = LavaList[nLava].nAction; diff --git a/source/games/exhumed/src/lion.cpp b/source/games/exhumed/src/lion.cpp index db81c3d1dce..2d5453ca3e9 100644 --- a/source/games/exhumed/src/lion.cpp +++ b/source/games/exhumed/src/lion.cpp @@ -141,16 +141,16 @@ void BuildLion(short nSprite, int x, int y, int z, short nSector, short nAngle) void AILion::Draw(RunListEvent* ev) { - short nLion = RunData[ev->nRun].nVal; + short nLion = RunData[ev->nRun].nObjIndex; assert(nLion >= 0 && nLion < (int)LionList.Size()); short nAction = LionList[nLion].nAction; - seq_PlotSequence(ev->nIndex, SeqOffsets[kSeqLion] + LionSeq[nAction].a, LionList[nLion].nFrame, LionSeq[nAction].b); + seq_PlotSequence(ev->nParam, SeqOffsets[kSeqLion] + LionSeq[nAction].a, LionList[nLion].nFrame, LionSeq[nAction].b); } void AILion::RadialDamage(RunListEvent* ev) { - short nLion = RunData[ev->nRun].nVal; + short nLion = RunData[ev->nRun].nObjIndex; assert(nLion >= 0 && nLion < (int)LionList.Size()); short nSprite = LionList[nLion].nSprite; @@ -162,7 +162,7 @@ void AILion::RadialDamage(RunListEvent* ev) void AILion::Damage(RunListEvent* ev) { - short nLion = RunData[ev->nRun].nVal; + short nLion = RunData[ev->nRun].nObjIndex; assert(nLion >= 0 && nLion < (int)LionList.Size()); short nSprite = LionList[nLion].nSprite; @@ -203,7 +203,7 @@ void AILion::Damage(RunListEvent* ev) } else { - short nTarget = ev->nIndex; + short nTarget = ev->nParam; if (nTarget > -1) { @@ -243,7 +243,7 @@ void AILion::Damage(RunListEvent* ev) void AILion::Tick(RunListEvent* ev) { - short nLion = RunData[ev->nRun].nVal; + short nLion = RunData[ev->nRun].nObjIndex; assert(nLion >= 0 && nLion < (int)LionList.Size()); short nSprite = LionList[nLion].nSprite; diff --git a/source/games/exhumed/src/move.cpp b/source/games/exhumed/src/move.cpp index 9b6d00c7b6e..f8da39675ed 100644 --- a/source/games/exhumed/src/move.cpp +++ b/source/games/exhumed/src/move.cpp @@ -1507,7 +1507,7 @@ int BuildCreatureChunk(int nVal, int nPic) void AICreatureChunk::Tick(RunListEvent* ev) { - int nSprite = RunData[ev->nRun].nVal; + int nSprite = RunData[ev->nRun].nObjIndex; assert(nSprite >= 0 && nSprite < kMaxSprites); auto pSprite = &sprite[nSprite]; diff --git a/source/games/exhumed/src/mummy.cpp b/source/games/exhumed/src/mummy.cpp index 42dd8b797fd..547cc2e0a0d 100644 --- a/source/games/exhumed/src/mummy.cpp +++ b/source/games/exhumed/src/mummy.cpp @@ -175,7 +175,7 @@ void CheckMummyRevive(short nMummy) void AIMummy::Tick(RunListEvent* ev) { - short nMummy = RunData[ev->nRun].nVal; + short nMummy = RunData[ev->nRun].nObjIndex; assert(nMummy >= 0 && nMummy < kMaxMummies); short nTarget = UpdateEnemy(&MummyList[nMummy].nTarget); @@ -464,17 +464,17 @@ void AIMummy::Tick(RunListEvent* ev) void AIMummy::Draw(RunListEvent* ev) { - short nMummy = RunData[ev->nRun].nVal; + short nMummy = RunData[ev->nRun].nObjIndex; assert(nMummy >= 0 && nMummy < kMaxMummies); short nAction = MummyList[nMummy].nAction; - seq_PlotSequence(ev->nIndex, SeqOffsets[kSeqMummy] + MummySeq[nAction].a, MummyList[nMummy].nFrame, MummySeq[nAction].b); + seq_PlotSequence(ev->nParam, SeqOffsets[kSeqMummy] + MummySeq[nAction].a, MummyList[nMummy].nFrame, MummySeq[nAction].b); return; } void AIMummy::RadialDamage(RunListEvent* ev) { - short nMummy = RunData[ev->nRun].nVal; + short nMummy = RunData[ev->nRun].nObjIndex; assert(nMummy >= 0 && nMummy < kMaxMummies); short nSprite = MummyList[nMummy].nSprite; auto pSprite = &sprite[nSprite]; @@ -488,7 +488,7 @@ void AIMummy::RadialDamage(RunListEvent* ev) void AIMummy::Damage(RunListEvent* ev) { - short nMummy = RunData[ev->nRun].nVal; + short nMummy = RunData[ev->nRun].nObjIndex; assert(nMummy >= 0 && nMummy < kMaxMummies); short nSprite = MummyList[nMummy].nSprite; diff --git a/source/games/exhumed/src/object.cpp b/source/games/exhumed/src/object.cpp index c1002dd2209..3a10485ce52 100644 --- a/source/games/exhumed/src/object.cpp +++ b/source/games/exhumed/src/object.cpp @@ -720,7 +720,7 @@ void StartElevSound(short nSprite, int nVal) void AIElev::ProcessChannel(RunListEvent* ev) { int nRun = ev->nRun; - short nElev = RunData[nRun].nVal; + short nElev = RunData[nRun].nObjIndex; assert(nElev >= 0 && nElev < (int)Elevator.Size()); short nChannel = Elevator[nElev].nChannel; @@ -749,7 +749,7 @@ void AIElev::ProcessChannel(RunListEvent* ev) { if (Elevator[nElev].field_32 < 0) { - Elevator[nElev].field_32 = runlist_AddRunRec(NewRun, RunData[nRun].nVal, RunData[nRun].nRef); + Elevator[nElev].field_32 = runlist_AddRunRec(NewRun, &RunData[nRun]); StartElevSound(Elevator[nElev].nSprite, var_18); edi = 1; @@ -783,7 +783,7 @@ void AIElev::ProcessChannel(RunListEvent* ev) { if (Elevator[nElev].field_32 < 0) { - Elevator[nElev].field_32 = runlist_AddRunRec(NewRun, RunData[nRun].nVal, RunData[nRun].nRef); + Elevator[nElev].field_32 = runlist_AddRunRec(NewRun, &RunData[nRun]); StartElevSound(Elevator[nElev].nSprite, var_18); } @@ -802,7 +802,7 @@ void AIElev::ProcessChannel(RunListEvent* ev) void AIElev::Tick(RunListEvent* ev) { int nRun = ev->nRun; - short nElev = RunData[nRun].nVal; + short nElev = RunData[nRun].nObjIndex; assert(nElev >= 0 && nElev < (int)Elevator.Size()); short nChannel = Elevator[nElev].nChannel; @@ -968,7 +968,7 @@ int BuildWallFace(short nChannel, short nWall, int nCount, ...) void AIWallFace::ProcessChannel(RunListEvent* ev) { - int nWallFace = RunData[ev->nRun].nVal; + int nWallFace = RunData[ev->nRun].nObjIndex; assert(nWallFace >= 0 && nWallFace < (int)WallFace.Size()); short nChannel = WallFace[nWallFace].nChannel; @@ -1129,7 +1129,7 @@ int BuildSlide(int nChannel, int nStartWall, int nWall1, int ecx, int nWall2, in void AISlide::ProcessChannel(RunListEvent* ev) { int nRun = ev->nRun; - int nSlide = RunData[nRun].nVal; + int nSlide = RunData[nRun].nObjIndex; assert(nSlide >= 0 && nSlide < (int)SlideData.Size()); short nChannel = SlideData[nSlide].nChannel; @@ -1144,7 +1144,7 @@ void AISlide::ProcessChannel(RunListEvent* ev) return; } - SlideData[nSlide].field_4a = runlist_AddRunRec(NewRun, RunData[nRun].nVal, RunData[nRun].nRef); + SlideData[nSlide].field_4a = runlist_AddRunRec(NewRun, &RunData[nRun]); if (SlideData[nSlide].field_8a != sRunChannels[nChannel].c) { @@ -1156,7 +1156,7 @@ void AISlide::ProcessChannel(RunListEvent* ev) void AISlide::Tick(RunListEvent* ev) { int nRun = ev->nRun; - int nSlide = RunData[nRun].nVal; + int nSlide = RunData[nRun].nObjIndex; assert(nSlide >= 0 && nSlide < (int)SlideData.Size()); short nChannel = SlideData[nSlide].nChannel; @@ -1373,8 +1373,8 @@ int BuildTrap(int nSprite, int edx, int ebx, int ecx) void AITrap::ProcessChannel(RunListEvent* ev) { - short nChannel = ev->nIndex & 0x3FFF; - short nTrap = RunData[ev->nRun].nVal; + short nChannel = ev->nParam & 0x3FFF; + short nTrap = RunData[ev->nRun].nObjIndex; if (sRunChannels[nChannel].c > 0) { @@ -1388,7 +1388,7 @@ void AITrap::ProcessChannel(RunListEvent* ev) void AITrap::Tick(RunListEvent* ev) { - short nTrap = RunData[ev->nRun].nVal; + short nTrap = RunData[ev->nRun].nObjIndex; short nSprite = sTrap[nTrap].nSprite; auto pSprite = &sprite[nSprite]; @@ -1551,7 +1551,7 @@ int BuildSpark(int nSprite, int nVal) void AISpark::Tick(RunListEvent* ev) { - int nSprite = RunData[ev->nRun].nVal; + int nSprite = RunData[ev->nRun].nObjIndex; auto pSprite = &sprite[nSprite]; assert(nSprite >= 0 && nSprite < kMaxSprites); @@ -1891,7 +1891,7 @@ void ExplodeEnergyBlock(int nSprite) void AIEnergyBlock::Damage(RunListEvent* ev) { - int const nSprite = RunData[ev->nRun].nVal; + int const nSprite = RunData[ev->nRun].nObjIndex; auto spr = &sprite[nSprite]; ev->nDamage >>= 2; @@ -1906,7 +1906,7 @@ void AIEnergyBlock::Damage(RunListEvent* ev) int nSprite2 = insertsprite(lasthitsect, 0); auto pSprite2 = &sprite[nSprite2]; - pSprite2->ang = ev->nIndex; + pSprite2->ang = ev->nParam; pSprite2->x = lasthitx; pSprite2->y = lasthity; pSprite2->z = lasthitz; @@ -1923,7 +1923,7 @@ void AIEnergyBlock::Damage(RunListEvent* ev) void AIEnergyBlock::RadialDamage(RunListEvent* ev) { - int const nSprite = RunData[ev->nRun].nVal; + int const nSprite = RunData[ev->nRun].nObjIndex; auto spr = &sprite[nSprite]; short nSector = spr->sectnum; @@ -2042,7 +2042,7 @@ void ExplodeScreen(short nSprite) void AIObject::Tick(RunListEvent* ev) { - short nObject = RunData[ev->nRun].nVal; + short nObject = RunData[ev->nRun].nObjIndex; auto pObject = &ObjectList[nObject]; short nSprite = pObject->nSprite; @@ -2160,7 +2160,7 @@ void AIObject::Tick(RunListEvent* ev) void AIObject::Damage(RunListEvent* ev) { - short nObject = RunData[ev->nRun].nVal; + short nObject = RunData[ev->nRun].nObjIndex; auto pObject = &ObjectList[nObject]; short nSprite = pObject->nSprite; @@ -2195,20 +2195,20 @@ void AIObject::Damage(RunListEvent* ev) void AIObject::Draw(RunListEvent* ev) { - short nObject = RunData[ev->nRun].nVal; + short nObject = RunData[ev->nRun].nObjIndex; auto pObject = &ObjectList[nObject]; short bx = pObject->field_8; if (bx > -1) { - seq_PlotSequence(ev->nIndex, bx, pObject->field_0, 1); + seq_PlotSequence(ev->nParam, bx, pObject->field_0, 1); } return; } void AIObject::RadialDamage(RunListEvent* ev) { - short nObject = RunData[ev->nRun].nVal; + short nObject = RunData[ev->nRun].nObjIndex; auto pObject = &ObjectList[nObject]; short nSprite = pObject->nSprite; diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index c1374f9a839..8ab63cbb15f 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -245,7 +245,7 @@ void InitPlayerInventory(short nPlayer) short GetPlayerFromSprite(short nSprite) { auto pSprite = &sprite[nSprite]; - return RunData[pSprite->owner].nVal; + return RunData[pSprite->owner].nObjIndex; } void RestartPlayer(short nPlayer) @@ -656,16 +656,16 @@ void UpdatePlayerSpriteAngle(Player* pPlayer) void AIPlayer::Draw(RunListEvent* ev) { - short nPlayer = RunData[ev->nRun].nVal; + short nPlayer = RunData[ev->nRun].nObjIndex; assert(nPlayer >= 0 && nPlayer < kMaxPlayers); short nAction = PlayerList[nPlayer].nAction; - seq_PlotSequence(ev->nIndex, SeqOffsets[PlayerList[nPlayer].nSeq] + PlayerSeq[nAction].a, PlayerList[nPlayer].field_2, PlayerSeq[nAction].b); + seq_PlotSequence(ev->nParam, SeqOffsets[PlayerList[nPlayer].nSeq] + PlayerSeq[nAction].a, PlayerList[nPlayer].field_2, PlayerSeq[nAction].b); } void AIPlayer::RadialDamage(RunListEvent* ev) { - short nPlayer = RunData[ev->nRun].nVal; + short nPlayer = RunData[ev->nRun].nObjIndex; assert(nPlayer >= 0 && nPlayer < kMaxPlayers); short nPlayerSprite = PlayerList[nPlayer].nSprite; @@ -683,7 +683,7 @@ void AIPlayer::Damage(RunListEvent* ev) { int nSprite2; int nDamage = ev->nDamage; - short nPlayer = RunData[ev->nRun].nVal; + short nPlayer = RunData[ev->nRun].nObjIndex; short nAction = PlayerList[nPlayer].nAction; short nPlayerSprite = PlayerList[nPlayer].nSprite; auto pPlayerSprite = &sprite[nPlayerSprite]; @@ -695,7 +695,7 @@ void AIPlayer::Damage(RunListEvent* ev) if (ev->nMessage != EMessageType::RadialDamage) { - nSprite2 = ev->nIndex; + nSprite2 = ev->nParam; } else nSprite2 = nRadialOwner; @@ -796,7 +796,7 @@ void AIPlayer::Tick(RunListEvent* ev) int var_40; bool mplevel = (currentLevel->gameflags & LEVEL_EX_MULTI); - short nPlayer = RunData[ev->nRun].nVal; + short nPlayer = RunData[ev->nRun].nObjIndex; assert(nPlayer >= 0 && nPlayer < kMaxPlayers); short nPlayerSprite = PlayerList[nPlayer].nSprite; diff --git a/source/games/exhumed/src/queen.cpp b/source/games/exhumed/src/queen.cpp index 22760de598d..2091caac4f3 100644 --- a/source/games/exhumed/src/queen.cpp +++ b/source/games/exhumed/src/queen.cpp @@ -511,7 +511,7 @@ void BuildQueenEgg(short nQueen, int nVal) void AIQueenEgg::Tick(RunListEvent* ev) { - short nEgg = RunData[ev->nRun].nVal; + short nEgg = RunData[ev->nRun].nObjIndex; Egg* pEgg = &QueenEgg[nEgg]; short nSprite = pEgg->nSprite; auto pSprite = &sprite[nSprite]; @@ -669,7 +669,7 @@ void AIQueenEgg::Tick(RunListEvent* ev) void AIQueenEgg::RadialDamage(RunListEvent* ev) { - short nEgg = RunData[ev->nRun].nVal; + short nEgg = RunData[ev->nRun].nObjIndex; Egg* pEgg = &QueenEgg[nEgg]; short nSprite = pEgg->nSprite; auto pSprite = &sprite[nSprite]; @@ -684,7 +684,7 @@ void AIQueenEgg::RadialDamage(RunListEvent* ev) void AIQueenEgg::Damage(RunListEvent* ev) { - short nEgg = RunData[ev->nRun].nVal; + short nEgg = RunData[ev->nRun].nObjIndex; Egg* pEgg = &QueenEgg[nEgg]; if (ev->nDamage != 0 && pEgg->nHealth > 0) @@ -698,9 +698,9 @@ void AIQueenEgg::Damage(RunListEvent* ev) void AIQueenEgg::Draw(RunListEvent* ev) { - short nEgg = RunData[ev->nRun].nVal; + short nEgg = RunData[ev->nRun].nObjIndex; Egg* pEgg = &QueenEgg[nEgg]; - seq_PlotSequence(ev->nIndex, SeqOffsets[kSeqQueenEgg] + EggSeq[pEgg->nAction].a, pEgg->nFrame, EggSeq[pEgg->nAction].b); + seq_PlotSequence(ev->nParam, SeqOffsets[kSeqQueenEgg] + EggSeq[pEgg->nAction].a, pEgg->nFrame, EggSeq[pEgg->nAction].b); } @@ -764,7 +764,7 @@ void BuildQueenHead(short nQueen) void AIQueenHead::Tick(RunListEvent* ev) { - short nHead = RunData[ev->nRun].nVal; + short nHead = RunData[ev->nRun].nObjIndex; short nSprite = QueenHead.nSprite; auto pSprite = &sprite[nSprite]; @@ -1062,7 +1062,7 @@ void AIQueenHead::Tick(RunListEvent* ev) void AIQueenHead::RadialDamage(RunListEvent* ev) { - short nHead = RunData[ev->nRun].nVal; + short nHead = RunData[ev->nRun].nObjIndex; short nSprite = QueenHead.nSprite; auto pSprite = &sprite[nSprite]; @@ -1077,7 +1077,7 @@ void AIQueenHead::RadialDamage(RunListEvent* ev) void AIQueenHead::Damage(RunListEvent* ev) { - short nHead = RunData[ev->nRun].nVal; + short nHead = RunData[ev->nRun].nObjIndex; short nSprite = QueenHead.nSprite; auto pSprite = &sprite[nSprite]; @@ -1088,7 +1088,7 @@ void AIQueenHead::Damage(RunListEvent* ev) if (!RandomSize(4)) { - QueenHead.nTarget = ev->nIndex; + QueenHead.nTarget = ev->nParam; QueenHead.nAction = 7; QueenHead.nFrame = 0; } @@ -1114,7 +1114,7 @@ void AIQueenHead::Damage(RunListEvent* ev) void AIQueenHead::Draw(RunListEvent* ev) { - short nHead = RunData[ev->nRun].nVal; + short nHead = RunData[ev->nRun].nObjIndex; short nAction = QueenHead.nAction; short nSeq = SeqOffsets[kSeqQueen]; @@ -1132,7 +1132,7 @@ void AIQueenHead::Draw(RunListEvent* ev) nSeq += 73; } - seq_PlotSequence(ev->nIndex, nSeq, QueenHead.nFrame, edx); + seq_PlotSequence(ev->nParam, nSeq, QueenHead.nFrame, edx); } @@ -1221,7 +1221,7 @@ void SetQueenSpeed(short nSprite, int nSpeed) void AIQueen::Tick(RunListEvent* ev) { - short nQueen = RunData[ev->nRun].nVal; + short nQueen = RunData[ev->nRun].nObjIndex; assert(nQueen >= 0 && nQueen < kMaxQueens); short nSprite = QueenList[nQueen].nSprite; @@ -1482,7 +1482,7 @@ void AIQueen::Tick(RunListEvent* ev) void AIQueen::RadialDamage(RunListEvent* ev) { - short nQueen = RunData[ev->nRun].nVal; + short nQueen = RunData[ev->nRun].nObjIndex; assert(nQueen >= 0 && nQueen < kMaxQueens); short nSprite = QueenList[nQueen].nSprite; auto pSprite = &sprite[nSprite]; @@ -1496,7 +1496,7 @@ void AIQueen::RadialDamage(RunListEvent* ev) void AIQueen::Damage(RunListEvent* ev) { - short nQueen = RunData[ev->nRun].nVal; + short nQueen = RunData[ev->nRun].nObjIndex; assert(nQueen >= 0 && nQueen < kMaxQueens); short nSprite = QueenList[nQueen].nSprite; @@ -1553,10 +1553,10 @@ void AIQueen::Damage(RunListEvent* ev) void AIQueen::Draw(RunListEvent* ev) { - short nQueen = RunData[ev->nRun].nVal; + short nQueen = RunData[ev->nRun].nObjIndex; assert(nQueen >= 0 && nQueen < kMaxQueens); short nAction = QueenList[nQueen].nAction; - seq_PlotSequence(ev->nIndex, SeqOffsets[kSeqQueen] + QueenSeq[nAction].a, QueenList[nQueen].nFrame, QueenSeq[nAction].b); + seq_PlotSequence(ev->nParam, SeqOffsets[kSeqQueen] + QueenSeq[nAction].a, QueenList[nQueen].nFrame, QueenSeq[nAction].b); } void FuncQueen(int nObject, int nMessage, int nDamage, int nRun) diff --git a/source/games/exhumed/src/ra.cpp b/source/games/exhumed/src/ra.cpp index 226ab00c2e9..accec1c2337 100644 --- a/source/games/exhumed/src/ra.cpp +++ b/source/games/exhumed/src/ra.cpp @@ -167,7 +167,7 @@ void MoveRaToEnemy(short nPlayer) void AIRa::Tick(RunListEvent* ev) { - short nPlayer = RunData[ev->nRun].nVal; + short nPlayer = RunData[ev->nRun].nObjIndex; short nCurrentWeapon = PlayerList[nPlayer].nCurrentWeapon; short nSeq = SeqOffsets[kSeqEyeHit] + RaSeq[Ra[nPlayer].nAction].a; @@ -290,11 +290,11 @@ void AIRa::Tick(RunListEvent* ev) void AIRa::Draw(RunListEvent* ev) { - short nPlayer = RunData[ev->nRun].nVal; + short nPlayer = RunData[ev->nRun].nObjIndex; short nSeq = SeqOffsets[kSeqEyeHit] + RaSeq[Ra[nPlayer].nAction].a; - seq_PlotSequence(ev->nIndex, nSeq, Ra[nPlayer].nFrame, 1); - mytsprite[ev->nIndex].owner = -1; + seq_PlotSequence(ev->nParam, nSeq, Ra[nPlayer].nFrame, 1); + mytsprite[ev->nParam].owner = -1; } void FuncRa(int nObject, int nMessage, int nDamage, int nRun) diff --git a/source/games/exhumed/src/rat.cpp b/source/games/exhumed/src/rat.cpp index f82c3737d7d..5a20df81ddf 100644 --- a/source/games/exhumed/src/rat.cpp +++ b/source/games/exhumed/src/rat.cpp @@ -208,7 +208,7 @@ int FindFood(short nSprite) void AIRat::RadialDamage(RunListEvent* ev) { - short nRat = RunData[ev->nRun].nVal; + short nRat = RunData[ev->nRun].nObjIndex; short nSprite = RatList[nRat].nSprite; ev->nDamage = runlist_CheckRadialDamage(nSprite); Damage(ev); @@ -216,7 +216,7 @@ void AIRat::RadialDamage(RunListEvent* ev) void AIRat::Damage(RunListEvent* ev) { - short nRat = RunData[ev->nRun].nVal; + short nRat = RunData[ev->nRun].nObjIndex; short nSprite = RatList[nRat].nSprite; auto pSprite = &sprite[nSprite]; @@ -233,16 +233,16 @@ void AIRat::Damage(RunListEvent* ev) void AIRat::Draw(RunListEvent* ev) { - short nRat = RunData[ev->nRun].nVal; + short nRat = RunData[ev->nRun].nObjIndex; short nAction = RatList[nRat].nAction; - seq_PlotSequence(ev->nIndex, SeqOffsets[kSeqRat] + RatSeq[nAction].a, RatList[nRat].nFrame, RatSeq[nAction].b); + seq_PlotSequence(ev->nParam, SeqOffsets[kSeqRat] + RatSeq[nAction].a, RatList[nRat].nFrame, RatSeq[nAction].b); } void AIRat::Tick(RunListEvent* ev) { - short nRat = RunData[ev->nRun].nVal; + short nRat = RunData[ev->nRun].nObjIndex; short nSprite = RatList[nRat].nSprite; short nAction = RatList[nRat].nAction; auto pSprite = &sprite[nSprite]; diff --git a/source/games/exhumed/src/rex.cpp b/source/games/exhumed/src/rex.cpp index b2b95c28a86..494790fef7e 100644 --- a/source/games/exhumed/src/rex.cpp +++ b/source/games/exhumed/src/rex.cpp @@ -139,7 +139,7 @@ void BuildRex(short nSprite, int x, int y, int z, short nSector, short nAngle, i void AIRex::RadialDamage(RunListEvent* ev) { - short nRex = RunData[ev->nRun].nVal; + short nRex = RunData[ev->nRun].nObjIndex; assert(nRex >= 0 && nRex < (int)RexList.Size()); short nAction = RexList[nRex].nAction; @@ -154,7 +154,7 @@ void AIRex::RadialDamage(RunListEvent* ev) void AIRex::Damage(RunListEvent* ev) { - short nRex = RunData[ev->nRun].nVal; + short nRex = RunData[ev->nRun].nObjIndex; assert(nRex >= 0 && nRex < (int)RexList.Size()); short nAction = RexList[nRex].nAction; @@ -163,7 +163,7 @@ void AIRex::Damage(RunListEvent* ev) if (ev->nDamage) { - short nTarget = ev->nIndex; + short nTarget = ev->nParam; if (nTarget >= 0 && sprite[nTarget].statnum == 100) { RexList[nRex].nTarget = nTarget; @@ -196,18 +196,18 @@ void AIRex::Damage(RunListEvent* ev) void AIRex::Draw(RunListEvent* ev) { - short nRex = RunData[ev->nRun].nVal; + short nRex = RunData[ev->nRun].nObjIndex; assert(nRex >= 0 && nRex < (int)RexList.Size()); short nAction = RexList[nRex].nAction; - seq_PlotSequence(ev->nIndex, SeqOffsets[kSeqRex] + RexSeq[nAction].a, RexList[nRex].nFrame, RexSeq[nAction].b); + seq_PlotSequence(ev->nParam, SeqOffsets[kSeqRex] + RexSeq[nAction].a, RexList[nRex].nFrame, RexSeq[nAction].b); return; } void AIRex::Tick(RunListEvent* ev) { - short nRex = RunData[ev->nRun].nVal; + short nRex = RunData[ev->nRun].nObjIndex; assert(nRex >= 0 && nRex < (int)RexList.Size()); short nAction = RexList[nRex].nAction; diff --git a/source/games/exhumed/src/roach.cpp b/source/games/exhumed/src/roach.cpp index dc3c33fd846..16e465e2d2b 100644 --- a/source/games/exhumed/src/roach.cpp +++ b/source/games/exhumed/src/roach.cpp @@ -153,17 +153,17 @@ void GoRoach(short nSprite) void AIRoach::Draw(RunListEvent* ev) { - short nRoach = RunData[ev->nRun].nVal; + short nRoach = RunData[ev->nRun].nObjIndex; assert(nRoach >= 0 && nRoach < (int)RoachList.Size()); short nAction = RoachList[nRoach].nAction; - seq_PlotSequence(ev->nIndex, RoachSeq[nAction].a + SeqOffsets[kSeqRoach], RoachList[nRoach].nFrame, RoachSeq[nAction].b); + seq_PlotSequence(ev->nParam, RoachSeq[nAction].a + SeqOffsets[kSeqRoach], RoachList[nRoach].nFrame, RoachSeq[nAction].b); return; } void AIRoach::RadialDamage(RunListEvent* ev) { - short nRoach = RunData[ev->nRun].nVal; + short nRoach = RunData[ev->nRun].nObjIndex; assert(nRoach >= 0 && nRoach < (int)RoachList.Size()); short nSprite = RoachList[nRoach].nSprite; @@ -173,7 +173,7 @@ void AIRoach::RadialDamage(RunListEvent* ev) void AIRoach::Damage(RunListEvent* ev) { - short nRoach = RunData[ev->nRun].nVal; + short nRoach = RunData[ev->nRun].nObjIndex; assert(nRoach >= 0 && nRoach < (int)RoachList.Size()); short nSprite = RoachList[nRoach].nSprite; @@ -207,7 +207,7 @@ void AIRoach::Damage(RunListEvent* ev) } else { - short nSprite2 = ev->nIndex; + short nSprite2 = ev->nParam; if (nSprite2 >= 0) { if (sprite[nSprite2].statnum < 199) { @@ -235,7 +235,7 @@ void AIRoach::Damage(RunListEvent* ev) void AIRoach::Tick(RunListEvent* ev) { - short nRoach = RunData[ev->nRun].nVal; + short nRoach = RunData[ev->nRun].nObjIndex; assert(nRoach >= 0 && nRoach < (int)RoachList.Size()); short nSprite = RoachList[nRoach].nSprite; diff --git a/source/games/exhumed/src/runlist.cpp b/source/games/exhumed/src/runlist.cpp index 6d856f1ccef..6751784e7ee 100644 --- a/source/games/exhumed/src/runlist.cpp +++ b/source/games/exhumed/src/runlist.cpp @@ -53,8 +53,9 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, RunStruct& w, RunS { if (arc.BeginObject(keyname)) { - arc("ref", w.nRef) - ("val", w.nVal) + arc("ref", w.nAIType) + ("val", w.nObjIndex) + ("actor", w.pObjActor) ("_4", w.next) ("_6", w.prev) .EndObject(); @@ -136,8 +137,9 @@ int runlist_FreeRun(int nRun) assert(nRun >= 0 && nRun < kMaxRuns); RunData[nRun].prev = -1; - RunData[nRun].nRef = -1; - RunData[nRun].nVal = -1; + RunData[nRun].nAIType = -1; + RunData[nRun].nObjIndex = -1; + RunData[nRun].pObjActor = nullptr; RunData[nRun].next = RunData[nRun].prev; RunData.Release(nRun); return 1; @@ -162,8 +164,9 @@ void runlist_InitRun() for (i = 0; i < kMaxRuns; i++) { - RunData[i].nRef = -1; - RunData[i].nVal = -1; + RunData[i].nAIType = -1; + RunData[i].pObjActor = nullptr; + RunData[i].nObjIndex = -1; RunData[i].prev = -1; RunData[i].next = -1; } @@ -216,17 +219,43 @@ void runlist_InsertRun(int RunLst, int RunNum) RunData[RunLst].next = RunNum; } -int runlist_AddRunRec(int a, int b, int c) +int runlist_AddRunRec(int nIndex, int nObject, int nAIType) { int nRun = runlist_GrabRun(); - RunData[nRun].nRef = c; - RunData[nRun].nVal = b; + RunData[nRun].nAIType = nAIType; + RunData[nRun].nObjIndex = nObject; + RunData[nRun].pObjActor = nullptr; - runlist_InsertRun(a, nRun); + runlist_InsertRun(nIndex, nRun); return nRun; } +int runlist_AddRunRec(int nIndex, DExhumedActor* pObject, int nAIType) +{ + int nRun = runlist_GrabRun(); + + RunData[nRun].nAIType = nAIType; + RunData[nRun].nObjIndex = -1; + RunData[nRun].pObjActor = pObject; + + runlist_InsertRun(nIndex, nRun); + return nRun; +} + +int runlist_AddRunRec(int nIndex, RunStruct* other) +{ + int nRun = runlist_GrabRun(); + + RunData[nRun].nAIType = other->nAIType; + RunData[nRun].nObjIndex = other->nObjIndex; + RunData[nRun].pObjActor = other->pObjActor; + + runlist_InsertRun(nIndex, nRun); + return nRun; +} + + void runlist_DoSubRunRec(int RunPtr) { if (!(RunPtr >= 0 && RunPtr < kMaxRuns)) return; @@ -250,7 +279,7 @@ void runlist_CleanRunRecs() int runPtr = nextPtr; assert(runPtr < kMaxRuns); - int val = RunData[runPtr].nRef; // >> 16; + int val = RunData[runPtr].nAIType; // >> 16; nextPtr = RunData[runPtr].next; if (val < 0) { @@ -263,12 +292,12 @@ void runlist_SubRunRec(int RunPtr) { if (!(RunPtr >= 0 && RunPtr < kMaxRuns)) return; - RunData[RunPtr].nRef = -totalmoves; + RunData[RunPtr].nAIType = -totalmoves; } void runlist_SendMessageToRunRec(int nRun, int nObject, int nMessage, int nDamage) { - int nFunc = RunData[nRun].nRef >> 16; + int nFunc = RunData[nRun].nAIType >> 16; if (nFunc < 0) { return; @@ -302,7 +331,7 @@ void runlist_ExplodeSignalRun() int runPtr = nextPtr; assert(runPtr < kMaxRuns); - int val = RunData[runPtr].nVal; + int val = RunData[runPtr].nObjIndex; nextPtr = RunData[runPtr].next; if (val >= 0) @@ -356,7 +385,7 @@ void runlist_SignalRun(int NxtPtr, int edx) if (RunPtr >= 0) { assert(RunPtr < kMaxRuns); - int val = RunData[RunPtr].nVal; + int val = RunData[RunPtr].nObjIndex; NxtPtr = RunData[RunPtr].next; if (val >= 0) { @@ -1704,7 +1733,9 @@ void runlist_DispatchEvent(ExhumedAI* ai, int nObject, int nMessage, int nDamage { RunListEvent ev{}; ev.nMessage = (EMessageType)(nMessage >> 16); - ev.nIndex = nObject; + ev.nObjIndex = RunData[nRun].nObjIndex; + ev.pObjActor = RunData[nRun].pObjActor; + ev.nParam = nObject; ev.nDamage = nDamage; ev.nRun = nRun; switch (ev.nMessage) @@ -1738,7 +1769,7 @@ void runlist_DispatchEvent(ExhumedAI* ai, int nObject, int nMessage, int nDamage break; case EMessageType::Damage: - ev.pActor = &exhumedActors[nObject]; + ev.pOtherActor = &exhumedActors[nObject]; ai->Damage(&ev); break; @@ -1750,7 +1781,7 @@ void runlist_DispatchEvent(ExhumedAI* ai, int nObject, int nMessage, int nDamage case EMessageType::RadialDamage: ev.nRadialDamage = nRadialDamage; ev.nDamageRadius = nDamageRadius; - ev.pActor = &exhumedActors[nRadialSpr]; + ev.pOtherActor = &exhumedActors[nRadialSpr]; ai->RadialDamage(&ev); break; } diff --git a/source/games/exhumed/src/scorp.cpp b/source/games/exhumed/src/scorp.cpp index 87be4973619..f2e16878846 100644 --- a/source/games/exhumed/src/scorp.cpp +++ b/source/games/exhumed/src/scorp.cpp @@ -150,16 +150,16 @@ void BuildScorp(short nSprite, int x, int y, int z, short nSector, short nAngle, void AIScorp::Draw(RunListEvent* ev) { - short nScorp = RunData[ev->nRun].nVal; + short nScorp = RunData[ev->nRun].nObjIndex; assert(nScorp >= 0 && nScorp < (int)scorpion.Size()); short nAction = scorpion[nScorp].nAction; - seq_PlotSequence(ev->nIndex, SeqOffsets[kSeqScorp] + ScorpSeq[nAction].a, scorpion[nScorp].nFrame, ScorpSeq[nAction].b); + seq_PlotSequence(ev->nParam, SeqOffsets[kSeqScorp] + ScorpSeq[nAction].a, scorpion[nScorp].nFrame, ScorpSeq[nAction].b); } void AIScorp::RadialDamage(RunListEvent* ev) { - short nScorp = RunData[ev->nRun].nVal; + short nScorp = RunData[ev->nRun].nObjIndex; assert(nScorp >= 0 && nScorp < (int)scorpion.Size()); short nSprite = scorpion[nScorp].nSprite; @@ -170,7 +170,7 @@ void AIScorp::RadialDamage(RunListEvent* ev) void AIScorp::Damage(RunListEvent* ev) { - short nScorp = RunData[ev->nRun].nVal; + short nScorp = RunData[ev->nRun].nObjIndex; assert(nScorp >= 0 && nScorp < (int)scorpion.Size()); short nSprite = scorpion[nScorp].nSprite; @@ -204,7 +204,7 @@ void AIScorp::Damage(RunListEvent* ev) } else { - nTarget = ev->nIndex; + nTarget = ev->nParam; if (nTarget >= 0) { @@ -232,7 +232,7 @@ void AIScorp::Damage(RunListEvent* ev) void AIScorp::Tick(RunListEvent* ev) { - short nScorp = RunData[ev->nRun].nVal; + short nScorp = RunData[ev->nRun].nObjIndex; assert(nScorp >= 0 && nScorp < (int)scorpion.Size()); short nSprite = scorpion[nScorp].nSprite; @@ -469,7 +469,7 @@ void AIScorp::Tick(RunListEvent* ev) void AIScorp::Effect(RunListEvent* ev, int nTarget, int mode) { - short nScorp = RunData[ev->nRun].nVal; + short nScorp = RunData[ev->nRun].nObjIndex; assert(nScorp >= 0 && nScorp < (int)scorpion.Size()); short nSprite = scorpion[nScorp].nSprite; diff --git a/source/games/exhumed/src/set.cpp b/source/games/exhumed/src/set.cpp index 9ba5ca15006..a449c5991d0 100644 --- a/source/games/exhumed/src/set.cpp +++ b/source/games/exhumed/src/set.cpp @@ -185,7 +185,7 @@ void BuildSoul(int nSet) void AISoul::Tick(RunListEvent* ev) { - short nSprite = RunData[ev->nRun].nVal; + short nSprite = RunData[ev->nRun].nObjIndex; auto pSprite = &sprite[nSprite]; seq_MoveSequence(nSprite, SeqOffsets[kSeqSet] + 75, 0); @@ -227,7 +227,7 @@ void FuncSoul(int nObject, int nMessage, int nDamage, int nRun) void AISet::RadialDamage(RunListEvent* ev) { - short nSet = RunData[ev->nRun].nVal; + short nSet = RunData[ev->nRun].nObjIndex; assert(nSet >= 0 && nSet < (int)SetList.Size()); short nSprite = SetList[nSet].nSprite; @@ -243,7 +243,7 @@ void AISet::RadialDamage(RunListEvent* ev) void AISet::Damage(RunListEvent* ev) { - short nSet = RunData[ev->nRun].nVal; + short nSet = RunData[ev->nRun].nObjIndex; assert(nSet >= 0 && nSet < (int)SetList.Size()); short nSprite = SetList[nSet].nSprite; @@ -284,18 +284,18 @@ void AISet::Damage(RunListEvent* ev) void AISet::Draw(RunListEvent* ev) { - short nSet = RunData[ev->nRun].nVal; + short nSet = RunData[ev->nRun].nObjIndex; assert(nSet >= 0 && nSet < (int)SetList.Size()); short nAction = SetList[nSet].nAction; - seq_PlotSequence(ev->nIndex, SeqOffsets[kSeqSet] + SetSeq[nAction].a, SetList[nSet].nFrame, SetSeq[nAction].b); + seq_PlotSequence(ev->nParam, SeqOffsets[kSeqSet] + SetSeq[nAction].a, SetList[nSet].nFrame, SetSeq[nAction].b); return; } void AISet::Tick(RunListEvent* ev) { - short nSet = RunData[ev->nRun].nVal; + short nSet = RunData[ev->nRun].nObjIndex; assert(nSet >= 0 && nSet < (int)SetList.Size()); short nSprite = SetList[nSet].nSprite; diff --git a/source/games/exhumed/src/snake.cpp b/source/games/exhumed/src/snake.cpp index 6f561065c19..56aca35bb53 100644 --- a/source/games/exhumed/src/snake.cpp +++ b/source/games/exhumed/src/snake.cpp @@ -313,7 +313,7 @@ int FindSnakeEnemy(short nSnake) void AISnake::Tick(RunListEvent* ev) { - short nSnake = RunData[ev->nRun].nVal; + short nSnake = RunData[ev->nRun].nObjIndex; assert(nSnake >= 0 && nSnake < kMaxSnakes); short nSprite = SnakeList[nSnake].nSprites[0]; @@ -404,8 +404,8 @@ void AISnake::Tick(RunListEvent* ev) void AISnake::Draw(RunListEvent* ev) { - short nSnake = RunData[ev->nRun].nVal; - short nSprite = ev->nIndex; + short nSnake = RunData[ev->nRun].nObjIndex; + short nSprite = ev->nParam; if ((nSnake & 0xFF) == 0) { seq_PlotSequence(nSprite, SeqOffsets[kSeqSnakehed], 0, 0); diff --git a/source/games/exhumed/src/spider.cpp b/source/games/exhumed/src/spider.cpp index f634987f74b..b91951b0129 100644 --- a/source/games/exhumed/src/spider.cpp +++ b/source/games/exhumed/src/spider.cpp @@ -135,7 +135,7 @@ int BuildSpider(int nSprite, int x, int y, int z, short nSector, int nAngle) void AISpider::Tick(RunListEvent* ev) { - int nSpider = RunData[ev->nRun].nVal; + int nSpider = RunData[ev->nRun].nObjIndex; auto spp = &SpiderList[nSpider]; assert(nSpider >= 0 && nSpider < (int)SpiderList.Size()); @@ -385,18 +385,18 @@ void AISpider::Tick(RunListEvent* ev) void AISpider::Draw(RunListEvent* ev) { - int nSpider = RunData[ev->nRun].nVal; + int nSpider = RunData[ev->nRun].nObjIndex; auto spp = &SpiderList[nSpider]; assert(nSpider >= 0 && nSpider < (int)SpiderList.Size()); short nAction = spp->nAction; - seq_PlotSequence(ev->nIndex, SeqOffsets[kSeqSpider] + SpiderSeq[nAction].a, spp->nFrame, SpiderSeq[nAction].b); + seq_PlotSequence(ev->nParam, SeqOffsets[kSeqSpider] + SpiderSeq[nAction].a, spp->nFrame, SpiderSeq[nAction].b); } void AISpider::RadialDamage(RunListEvent* ev) { - int nSpider = RunData[ev->nRun].nVal; + int nSpider = RunData[ev->nRun].nObjIndex; assert(nSpider >= 0 && nSpider < (int)SpiderList.Size()); auto spp = &SpiderList[nSpider]; @@ -409,7 +409,7 @@ void AISpider::RadialDamage(RunListEvent* ev) void AISpider::Damage(RunListEvent* ev) { - int nSpider = RunData[ev->nRun].nVal; + int nSpider = RunData[ev->nRun].nObjIndex; assert(nSpider >= 0 && nSpider < (int)SpiderList.Size()); auto spp = &SpiderList[nSpider]; int nSprite = spp->nSprite; @@ -418,7 +418,7 @@ void AISpider::Damage(RunListEvent* ev) if (!ev->nDamage) return; - short nTarget = ev->nIndex; + short nTarget = ev->nParam; spp->nHealth -= dmgAdjust(ev->nDamage); if (spp->nHealth > 0) diff --git a/source/games/exhumed/src/switch.cpp b/source/games/exhumed/src/switch.cpp index 2cb83aedae4..0a3f8ecaab3 100644 --- a/source/games/exhumed/src/switch.cpp +++ b/source/games/exhumed/src/switch.cpp @@ -137,7 +137,7 @@ std::pair BuildSwReady(int nChannel, short nLink) void AISWReady::Process(RunListEvent* ev) { - short nSwitch = RunData[ev->nRun].nVal; + short nSwitch = RunData[ev->nRun].nObjIndex; assert(nSwitch >= 0 && nSwitch < kMaxSwitches); short nChannel = SwitchData[nSwitch].nChannel; @@ -181,7 +181,7 @@ std::pair BuildSwPause(int nChannel, int nLink, int ebx) void AISWPause::ProcessChannel(RunListEvent* ev) { - short nSwitch = RunData[ev->nRun].nVal; + short nSwitch = RunData[ev->nRun].nObjIndex; if (SwitchData[nSwitch].nRunPtr >= 0) { runlist_SubRunRec(SwitchData[nSwitch].nRunPtr); @@ -191,7 +191,7 @@ void AISWPause::ProcessChannel(RunListEvent* ev) void AISWPause::Tick(RunListEvent* ev) { - short nSwitch = RunData[ev->nRun].nVal; + short nSwitch = RunData[ev->nRun].nObjIndex; short nChannel = SwitchData[nSwitch].nChannel; short nLink = SwitchData[nSwitch].nLink; @@ -210,7 +210,7 @@ void AISWPause::Tick(RunListEvent* ev) void AISWPause::Process(RunListEvent* ev) { - short nSwitch = RunData[ev->nRun].nVal; + short nSwitch = RunData[ev->nRun].nObjIndex; short nChannel = SwitchData[nSwitch].nChannel; short nLink = SwitchData[nSwitch].nLink; assert(sRunChannels[nChannel].c < 8); @@ -223,7 +223,7 @@ void AISWPause::Process(RunListEvent* ev) return; } - SwitchData[nSwitch].nRunPtr = runlist_AddRunRec(NewRun, RunData[ev->nRun].nVal, RunData[ev->nRun].nRef); + SwitchData[nSwitch].nRunPtr = runlist_AddRunRec(NewRun, &RunData[ev->nRun]); int eax; @@ -262,7 +262,7 @@ std::pair BuildSwStepOn(int nChannel, int nLink, int nSector) void AISWStepOn::ProcessChannel(RunListEvent* ev) { - short nSwitch = RunData[ev->nRun].nVal; + short nSwitch = RunData[ev->nRun].nObjIndex; assert(nSwitch >= 0 && nSwitch < kMaxSwitches); short nLink = SwitchData[nSwitch].nLink; @@ -281,13 +281,13 @@ void AISWStepOn::ProcessChannel(RunListEvent* ev) if (var_14 >= 0) { - SwitchData[nSwitch].nRun2 = runlist_AddRunRec(sector[nSector].lotag - 1, RunData[ev->nRun].nVal, RunData[ev->nRun].nRef); + SwitchData[nSwitch].nRun2 = runlist_AddRunRec(sector[nSector].lotag - 1, &RunData[ev->nRun]); } } void AISWStepOn::TouchFloor(RunListEvent* ev) { - short nSwitch = RunData[ev->nRun].nVal; + short nSwitch = RunData[ev->nRun].nObjIndex; assert(nSwitch >= 0 && nSwitch < kMaxSwitches); short nLink = SwitchData[nSwitch].nLink; @@ -334,7 +334,7 @@ std::pair BuildSwNotOnPause(int nChannel, int nLink, int nSector, int void AISWNotOnPause::ProcessChannel(RunListEvent* ev) { - short nSwitch = RunData[ev->nRun].nVal; + short nSwitch = RunData[ev->nRun].nObjIndex; assert(nSwitch >= 0 && nSwitch < kMaxSwitches); if (SwitchData[nSwitch].nRun2 >= 0) @@ -354,7 +354,7 @@ void AISWNotOnPause::ProcessChannel(RunListEvent* ev) void AISWNotOnPause::Tick(RunListEvent* ev) { - short nSwitch = RunData[ev->nRun].nVal; + short nSwitch = RunData[ev->nRun].nObjIndex; assert(nSwitch >= 0 && nSwitch < kMaxSwitches); short nChannel = SwitchData[nSwitch].nChannel; @@ -371,7 +371,7 @@ void AISWNotOnPause::Tick(RunListEvent* ev) void AISWNotOnPause::Process(RunListEvent* ev) { - short nSwitch = RunData[ev->nRun].nVal; + short nSwitch = RunData[ev->nRun].nObjIndex; assert(nSwitch >= 0 && nSwitch < kMaxSwitches); short nChannel = SwitchData[nSwitch].nChannel; @@ -383,19 +383,19 @@ void AISWNotOnPause::Process(RunListEvent* ev) { if (SwitchData[nSwitch].nRunPtr < 0) { - SwitchData[nSwitch].nRunPtr = runlist_AddRunRec(NewRun, RunData[ev->nRun].nVal, RunData[ev->nRun].nRef); + SwitchData[nSwitch].nRunPtr = runlist_AddRunRec(NewRun, &RunData[ev->nRun]); short nSector = SwitchData[nSwitch].nSector; SwitchData[nSwitch].nWaitTimer = SwitchData[nSwitch].nWait; - SwitchData[nSwitch].nRun2 = runlist_AddRunRec(sector[nSector].lotag - 1, RunData[ev->nRun].nVal, RunData[ev->nRun].nRef); + SwitchData[nSwitch].nRun2 = runlist_AddRunRec(sector[nSector].lotag - 1, &RunData[ev->nRun]); } } } void AISWNotOnPause::TouchFloor(RunListEvent* ev) { - short nSwitch = RunData[ev->nRun].nVal; + short nSwitch = RunData[ev->nRun].nObjIndex; SwitchData[nSwitch].nWaitTimer = SwitchData[nSwitch].nWait; return; @@ -425,7 +425,7 @@ std::pair BuildSwPressSector(int nChannel, int nLink, int nSector, int void AISWPressSector::ProcessChannel(RunListEvent* ev) { - short nSwitch = RunData[ev->nRun].nVal; + short nSwitch = RunData[ev->nRun].nObjIndex; assert(nSwitch >= 0 && nSwitch < kMaxSwitches); short nChannel = SwitchData[nSwitch].nChannel; @@ -445,17 +445,17 @@ void AISWPressSector::ProcessChannel(RunListEvent* ev) short nSector = SwitchData[nSwitch].nSector; - SwitchData[nSwitch].nRun2 = runlist_AddRunRec(sector[nSector].lotag - 1, RunData[ev->nRun].nVal, RunData[ev->nRun].nRef); + SwitchData[nSwitch].nRun2 = runlist_AddRunRec(sector[nSector].lotag - 1, &RunData[ev->nRun]); } void AISWPressSector::Use(RunListEvent* ev) { - short nSwitch = RunData[ev->nRun].nVal; + short nSwitch = RunData[ev->nRun].nObjIndex; assert(nSwitch >= 0 && nSwitch < kMaxSwitches); short nChannel = SwitchData[nSwitch].nChannel; short nLink = SwitchData[nSwitch].nLink; - int nPlayer = ev->nIndex; + int nPlayer = ev->nParam; if ((PlayerList[nPlayer].keys & SwitchData[nSwitch].nKeyMask) == SwitchData[nSwitch].nKeyMask) { @@ -498,7 +498,7 @@ std::pair BuildSwPressWall(short nChannel, short nLink, short nWall) void AISWPressWall::Process(RunListEvent* ev) { - short nSwitch = RunData[ev->nRun].nVal; + short nSwitch = RunData[ev->nRun].nObjIndex; assert(nSwitch >= 0 && nSwitch < kMaxSwitches); short nChannel = SwitchData[nSwitch].nChannel; @@ -513,13 +513,13 @@ void AISWPressWall::Process(RunListEvent* ev) if (LinkMap[nLink].v[sRunChannels[nChannel].c] >= 0) { short nWall = SwitchData[nSwitch].nWall; - SwitchData[nSwitch].nRun3 = runlist_AddRunRec(wall[nWall].lotag - 1, RunData[ev->nRun].nVal, RunData[ev->nRun].nRef); + SwitchData[nSwitch].nRun3 = runlist_AddRunRec(wall[nWall].lotag - 1, &RunData[ev->nRun]); } } void AISWPressWall::Use(RunListEvent* ev) { - short nSwitch = RunData[ev->nRun].nVal; + short nSwitch = RunData[ev->nRun].nObjIndex; assert(nSwitch >= 0 && nSwitch < kMaxSwitches); short nChannel = SwitchData[nSwitch].nChannel; diff --git a/source/games/exhumed/src/wasp.cpp b/source/games/exhumed/src/wasp.cpp index bfc751c707d..497cffbab57 100644 --- a/source/games/exhumed/src/wasp.cpp +++ b/source/games/exhumed/src/wasp.cpp @@ -179,16 +179,16 @@ int BuildWasp(short nSprite, int x, int y, int z, short nSector, short nAngle) void AIWasp::Draw(RunListEvent* ev) { - short nWasp = RunData[ev->nRun].nVal; + short nWasp = RunData[ev->nRun].nObjIndex; short nAction = WaspList[nWasp].nAction; - seq_PlotSequence(ev->nIndex, SeqOffsets[kSeqWasp] + WaspSeq[nAction].a, WaspList[nWasp].nFrame, WaspSeq[nAction].b); + seq_PlotSequence(ev->nParam, SeqOffsets[kSeqWasp] + WaspSeq[nAction].a, WaspList[nWasp].nFrame, WaspSeq[nAction].b); return; } void AIWasp::RadialDamage(RunListEvent* ev) { - short nWasp = RunData[ev->nRun].nVal; + short nWasp = RunData[ev->nRun].nObjIndex; short nSprite = WaspList[nWasp].nSprite; auto pSprite = &sprite[nSprite]; @@ -201,7 +201,7 @@ void AIWasp::RadialDamage(RunListEvent* ev) void AIWasp::Damage(RunListEvent* ev) { - short nWasp = RunData[ev->nRun].nVal; + short nWasp = RunData[ev->nRun].nObjIndex; short nSprite = WaspList[nWasp].nSprite; auto pSprite = &sprite[nSprite]; short nAction = WaspList[nWasp].nAction; @@ -251,7 +251,7 @@ void AIWasp::Damage(RunListEvent* ev) void AIWasp::Tick(RunListEvent* ev) { - short nWasp = RunData[ev->nRun].nVal; + short nWasp = RunData[ev->nRun].nObjIndex; short nSprite = WaspList[nWasp].nSprite; auto pSprite = &sprite[nSprite]; short nAction = WaspList[nWasp].nAction;