diff --git a/config/implemented.csv b/config/implemented.csv index fdd30f72..3fe4097c 100644 --- a/config/implemented.csv +++ b/config/implemented.csv @@ -117,6 +117,7 @@ th06::EffectManager::EffectUpdateCallback4 th06::EffectManager::EffectCallbackAttract th06::EffectManager::EffectCallbackAttractSlow th06::EnemyManager::Initialize +th06::EnemyManager::EnemyManager th06::EnemyManager::RegisterChain th06::EnemyManager::CutChain th06::EnemyManager::AddedCallback diff --git a/src/EclManager.cpp b/src/EclManager.cpp index 02851094..fbdf81e8 100644 --- a/src/EclManager.cpp +++ b/src/EclManager.cpp @@ -855,7 +855,7 @@ ZunResult EclManager::RunEcl(Enemy *enemy) break; case ECL_OPCODE_ENEMYKILLALL: for (local_b4 = &g_EnemyManager.enemies[0], local_b8 = 0; - local_b8 < ARRAY_SIZE_SIGNED(g_EnemyManager.enemies); local_b8++, local_b4++) + local_b8 < ARRAY_SIZE_SIGNED(g_EnemyManager.enemies) - 1; local_b8++, local_b4++) { if (!local_b4->flags.unk5) { diff --git a/src/EnemyManager.cpp b/src/EnemyManager.cpp index b89a821e..54a328bd 100644 --- a/src/EnemyManager.cpp +++ b/src/EnemyManager.cpp @@ -83,6 +83,11 @@ void EnemyManager::Initialize() enemy->bulletRankSpeedHigh = 0.5f; } +EnemyManager::EnemyManager() +{ + this->Initialize(); +} + Enemy *EnemyManager::SpawnEnemy(i32 eclSubId, D3DXVECTOR3 *pos, i16 life, i16 itemDrop, i32 score) { Enemy *newEnemy; @@ -90,7 +95,7 @@ Enemy *EnemyManager::SpawnEnemy(i32 eclSubId, D3DXVECTOR3 *pos, i16 life, i16 it newEnemy = this->enemies; idx = 0; - for (; idx < ARRAY_SIZE_SIGNED(this->enemies); idx++, newEnemy++) + for (; idx < ARRAY_SIZE_SIGNED(this->enemies) - 1; idx++, newEnemy++) { if (newEnemy->flags.unk5) continue; @@ -352,7 +357,7 @@ ZunBool Enemy::HandleLifeCallback() this->stackDepth = 0; curEnemy = g_EnemyManager.enemies; - for (i = 0; i < ARRAY_SIZE_SIGNED(g_EnemyManager.enemies); i++, curEnemy++) + for (i = 0; i < ARRAY_SIZE_SIGNED(g_EnemyManager.enemies) - 1; i++, curEnemy++) { if (!curEnemy->flags.unk5) { @@ -410,7 +415,7 @@ ZunBool Enemy::HandleTimerCallback() } curEnemy = g_EnemyManager.enemies; - for (i = 0; i < ARRAY_SIZE_SIGNED(g_EnemyManager.enemies); i++, curEnemy++) + for (i = 0; i < ARRAY_SIZE_SIGNED(g_EnemyManager.enemies) - 1; i++, curEnemy++) { if (!curEnemy->flags.unk5) { @@ -524,7 +529,7 @@ ChainCallbackResult EnemyManager::OnUpdate(EnemyManager *mgr) local_8 = 0; mgr->RunEclTimeline(); - for (curEnemy = &mgr->enemies[0], mgr->enemyCount = 0, enemyIdx = 0; enemyIdx < ARRAY_SIZE_SIGNED(mgr->enemies); + for (curEnemy = &mgr->enemies[0], mgr->enemyCount = 0, enemyIdx = 0; enemyIdx < ARRAY_SIZE_SIGNED(mgr->enemies) - 1; enemyIdx++, curEnemy++) { if (!curEnemy->flags.unk5) @@ -768,7 +773,7 @@ ChainCallbackResult EnemyManager::OnDraw(EnemyManager *mgr) i32 curEnemyVmIdx; i32 curEnemyIdx; - for (curEnemy = &mgr->enemies[0], curEnemyIdx = 0; curEnemyIdx < ARRAY_SIZE_SIGNED(mgr->enemies); + for (curEnemy = &mgr->enemies[0], curEnemyIdx = 0; curEnemyIdx < ARRAY_SIZE_SIGNED(mgr->enemies) - 1; curEnemyIdx++, curEnemy++) { if (!curEnemy->flags.unk5) diff --git a/src/EnemyManager.hpp b/src/EnemyManager.hpp index 6aa3d3d0..cebf52a5 100644 --- a/src/EnemyManager.hpp +++ b/src/EnemyManager.hpp @@ -22,6 +22,7 @@ C_ASSERT(sizeof(RunningSpellcardInfo) == 0x14); struct EnemyManager { void Initialize(); + EnemyManager(); static ZunResult RegisterChain(char *stgEnm1, char *stgEnm2); static void CutChain(); static ChainCallbackResult OnUpdate(EnemyManager *enemyManager); @@ -35,8 +36,7 @@ struct EnemyManager char *stgEnmAnmFilename; char *stgEnm2AnmFilename; Enemy enemyTemplate; - Enemy enemies[256]; - Enemy dummyEnemyForFailedSpawns; + Enemy enemies[257]; Enemy *bosses[8]; u16 randomItemSpawnIndex; u16 randomItemTableIndex;