summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShishu the Dragon <183069616+ShishuTheDragon@users.noreply.github.com>2026-07-04 13:51:28 +1200
committerGitHub <noreply@github.com>2026-07-04 01:51:28 +0000
commitb09c0733e2937ef83c1e255568632018dcd647ed (patch)
tree104a2577c093a51eded7526c29f46b38e0b01613
parentc76d1755262bac1cb7355c09b76f50266fc78281 (diff)
Ivan: Move ActorDB registration into IvanCoop.cpp (#6815)
-rw-r--r--soh/soh/ActorDB.cpp21
-rw-r--r--soh/soh/ActorDB.h2
-rw-r--r--soh/soh/Enhancements/ExtraModes/IvanCoop.cpp43
-rw-r--r--soh/soh/OTRGlobals.cpp1
-rw-r--r--soh/src/code/z_play.c1
5 files changed, 37 insertions, 31 deletions
diff --git a/soh/soh/ActorDB.cpp b/soh/soh/ActorDB.cpp
index 1455b9c50..c1e001dc2 100644
--- a/soh/soh/ActorDB.cpp
+++ b/soh/soh/ActorDB.cpp
@@ -595,27 +595,6 @@ void ActorDB::Entry::SetDesc(const std::string& newDesc) {
entry.desc = desc.c_str();
}
-#include "src/overlays/actors/ovl_En_Partner/z_en_partner.h"
-static ActorDBInit EnPartnerInit = {
- "En_Partner",
- "Ivan",
- ACTORCAT_ITEMACTION,
- (ACTOR_FLAG_UPDATE_CULLING_DISABLED | ACTOR_FLAG_DRAW_CULLING_DISABLED | ACTOR_FLAG_HOOKSHOT_PULLS_PLAYER |
- ACTOR_FLAG_CAN_PRESS_SWITCHES),
- OBJECT_GAMEPLAY_KEEP,
- sizeof(EnPartner),
- (ActorFunc)EnPartner_Init,
- (ActorFunc)EnPartner_Destroy,
- (ActorFunc)EnPartner_Update,
- (ActorFunc)EnPartner_Draw,
- nullptr,
-};
-extern "C" s16 gEnPartnerId;
-
-void ActorDB::AddBuiltInCustomActors() {
- gEnPartnerId = ActorDB::Instance->AddEntry(EnPartnerInit).entry.id;
-}
-
extern "C" ActorDBEntry* ActorDB_Retrieve(const int id) {
return &ActorDB::Instance->RetrieveEntry(id).entry;
}
diff --git a/soh/soh/ActorDB.h b/soh/soh/ActorDB.h
index dd8ecf901..4515c709a 100644
--- a/soh/soh/ActorDB.h
+++ b/soh/soh/ActorDB.h
@@ -62,8 +62,6 @@ class ActorDB {
Entry& RetrieveEntry(const int id);
int RetrieveId(const std::string& name);
- static void AddBuiltInCustomActors();
-
int GetEntryCount();
private:
diff --git a/soh/soh/Enhancements/ExtraModes/IvanCoop.cpp b/soh/soh/Enhancements/ExtraModes/IvanCoop.cpp
index f33fbe6ff..60659b745 100644
--- a/soh/soh/Enhancements/ExtraModes/IvanCoop.cpp
+++ b/soh/soh/Enhancements/ExtraModes/IvanCoop.cpp
@@ -1,16 +1,45 @@
+#include "soh/ActorDB.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#include "soh/ShipInit.hpp"
+#include "src/overlays/actors/ovl_En_Partner/z_en_partner.h"
extern "C" {
#include "macros.h"
#include "functions.h"
extern PlayState* gPlayState;
-extern s16 gEnPartnerId;
}
#define CVAR_NAME CVAR_ENHANCEMENT("IvanCoopModeEnabled")
#define CVAR_VALUE CVarGetInteger(CVAR_NAME, 0)
+static s16 ivanActorId = -1;
+
+static void AddToActorDB() {
+ if (ivanActorId == -1) {
+ ActorDBInit entry = {
+ "En_Partner",
+ "Ivan",
+ ACTORCAT_ITEMACTION,
+ (ACTOR_FLAG_UPDATE_CULLING_DISABLED | ACTOR_FLAG_DRAW_CULLING_DISABLED | ACTOR_FLAG_HOOKSHOT_PULLS_PLAYER |
+ ACTOR_FLAG_CAN_PRESS_SWITCHES),
+ OBJECT_GAMEPLAY_KEEP,
+ sizeof(EnPartner),
+ (ActorFunc)EnPartner_Init,
+ (ActorFunc)EnPartner_Destroy,
+ (ActorFunc)EnPartner_Update,
+ (ActorFunc)EnPartner_Draw,
+ nullptr,
+ };
+ ivanActorId = ActorDB::Instance->AddEntry(entry).entry.id;
+ }
+}
+
+static Actor* FindIvan(ActorContext* actorCtx) {
+ if (ivanActorId == -1)
+ return nullptr;
+ return Actor_Find(actorCtx, ivanActorId, ACTORCAT_ITEMACTION);
+}
+
static void SpawnIvan() {
if (!gPlayState)
return;
@@ -19,11 +48,13 @@ static void SpawnIvan() {
if (!player)
return;
- if (Actor_Find(&gPlayState->actorCtx, gEnPartnerId, ACTORCAT_ITEMACTION))
+ if (FindIvan(&gPlayState->actorCtx))
return;
+ AddToActorDB();
+
PosRot& world = player->actor.world;
- Actor_Spawn(&gPlayState->actorCtx, gPlayState, gEnPartnerId, world.pos.x,
+ Actor_Spawn(&gPlayState->actorCtx, gPlayState, ivanActorId, world.pos.x,
world.pos.y + Player_GetHeight(player) + 5.0f, world.pos.z, 0, world.rot.y, 0, 1);
}
@@ -31,7 +62,7 @@ static void KillIvan() {
if (!gPlayState)
return;
- Actor* ivan = Actor_Find(&gPlayState->actorCtx, gEnPartnerId, ACTORCAT_ITEMACTION);
+ Actor* ivan = FindIvan(&gPlayState->actorCtx);
if (ivan)
Actor_Kill(ivan);
}
@@ -85,8 +116,8 @@ static void PatchDistIfNeeded(Actor* actor) {
if (!ShouldPatchDist(actor->id))
return;
- Actor* ivan = Actor_Find(&gPlayState->actorCtx, gEnPartnerId, ACTORCAT_ITEMACTION);
- if (ivan == nullptr)
+ Actor* ivan = FindIvan(&gPlayState->actorCtx);
+ if (!ivan)
return;
f32 ivanDist = Actor_WorldDistXZToActor(actor, ivan);
diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp
index 8e1e5148f..cc21f4646 100644
--- a/soh/soh/OTRGlobals.cpp
+++ b/soh/soh/OTRGlobals.cpp
@@ -1561,7 +1561,6 @@ extern "C" void InitOTR(int argc, char* argv[]) {
VanillaItemTable_Init();
DebugConsole_Init();
- ActorDB::AddBuiltInCustomActors();
// #region SOH [Randomizer] TODO: Remove these and refactor spoiler file handling for randomizer
CVarClear(CVAR_GENERAL("RandomizerNewFileDropped"));
CVarClear(CVAR_GENERAL("RandomizerDroppedFile"));
diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c
index 701a1e339..0816b5a6b 100644
--- a/soh/src/code/z_play.c
+++ b/soh/src/code/z_play.c
@@ -33,7 +33,6 @@ Input* D_8012D1F8 = NULL;
PlayState* gPlayState;
s16 firstInit = 0;
-s16 gEnPartnerId;
void Play_SpawnScene(PlayState* play, s32 sceneId, s32 spawn);