From 27b9b0d2f8f4f7dba0dc5e13d98d642893e29602 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 16 Apr 2023 17:00:00 +1000 Subject: [PATCH] - Exhumed: Reduce repeated hashtable lookups when building chunks. --- source/games/exhumed/src/object.cpp | 6 ++++-- source/games/exhumed/src/player.cpp | 4 +++- source/games/exhumed/src/queen.cpp | 8 ++++++-- source/games/exhumed/src/spider.cpp | 4 +++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/source/games/exhumed/src/object.cpp b/source/games/exhumed/src/object.cpp index 778147391..51fa4f028 100644 --- a/source/games/exhumed/src/object.cpp +++ b/source/games/exhumed/src/object.cpp @@ -2004,10 +2004,12 @@ void AIObject::Tick(RunListEvent* ev) // int edi = nSprite | 0x4000; + const auto firepotSeqs = getFileSeqs("firepot"); + if (nStat == kStatExplodeTrigger) { for (int i = 4; i < 8; i++) { - BuildCreatureChunk(pActor, getSequence("firepot", (i >> 2) + 1).getFirstTexID(), true); + BuildCreatureChunk(pActor, firepotSeqs->operator[]((i >> 2) + 1).getFirstTexID(), true); } runlist_RadialDamageEnemy(pActor, 200, 20); @@ -2015,7 +2017,7 @@ void AIObject::Tick(RunListEvent* ev) else if (nStat == kStatExplodeTarget) { for (int i = 0; i < 8; i++) { - BuildCreatureChunk(pActor, getSequence("firepot", (i >> 1) + 3).getFirstTexID(), true); + BuildCreatureChunk(pActor, firepotSeqs->operator[]((i >> 1) + 3).getFirstTexID(), true); } } diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 49a1b837d..810a45022 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -638,9 +638,11 @@ void AIPlayer::Damage(RunListEvent* ev) if (ev->isRadialEvent()) { + const auto joeSeqs = getFileSeqs("joe"); + for (int i = 122; i <= 131; i++) { - BuildCreatureChunk(pPlayerActor, getSequence("joe", i).getFirstTexID()); + BuildCreatureChunk(pPlayerActor, joeSeqs->operator[](i).getFirstTexID()); } StartDeathSeq(nPlayer, 1); diff --git a/source/games/exhumed/src/queen.cpp b/source/games/exhumed/src/queen.cpp index 605991e78..9ae9e3800 100644 --- a/source/games/exhumed/src/queen.cpp +++ b/source/games/exhumed/src/queen.cpp @@ -250,9 +250,11 @@ int GrabEgg() void BlowChunks(DExhumedActor* pActor) { + const auto spiderSeqs = getFileSeqs("spider"); + for (int i = 0; i < 4; i++) { - BuildCreatureChunk(pActor, getSequence("spider", i + 41).getFirstTexID()); + BuildCreatureChunk(pActor, spiderSeqs->operator[](i + 41).getFirstTexID()); } } @@ -273,9 +275,11 @@ void DestroyEgg(int nEgg) } else { + const auto queeneggSeqs = getFileSeqs("queenegg"); + for (int i = 0; i < 4; i++) { - BuildCreatureChunk(pActor, getSequence("queenegg", (i % 2) + 24).getFirstTexID()); + BuildCreatureChunk(pActor, queeneggSeqs->operator[]((i % 2) + 24).getFirstTexID()); } } diff --git a/source/games/exhumed/src/spider.cpp b/source/games/exhumed/src/spider.cpp index 5241e415f..0975d1011 100644 --- a/source/games/exhumed/src/spider.cpp +++ b/source/games/exhumed/src/spider.cpp @@ -419,9 +419,11 @@ void AISpider::Damage(RunListEvent* ev) nCreaturesKilled++; + const auto spiderSeqs = getFileSeqs("spider"); + for (int i = 0; i < 7; i++) { - BuildCreatureChunk(spp, getSequence("spider", i + 41).getFirstTexID()); + BuildCreatureChunk(spp, spiderSeqs->operator[](i + 41).getFirstTexID()); } } }