summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAetias <144526980+AetiasHax@users.noreply.github.com>2025-06-29 20:56:46 +0200
committerGitHub <noreply@github.com>2025-06-29 20:56:46 +0200
commit3fe49695b4936ea29526eb8b7d07250a69a06c38 (patch)
treeac3efc0f20e0c349357e7ddd49e3859f5f0ee27a /src
parent21aaec6b40f8cb756e5ef4fff5552b980ab58d4e (diff)
parentf1c2aa37a7a706808b4c992638d89ee211cc0efd (diff)
Merge pull request #97 from AetiasHax/decomp-ActorSpawner
Decomp `ActorSpawner`
Diffstat (limited to 'src')
-rw-r--r--src/00_Core/Actor/Actor.cpp5
-rw-r--r--src/00_Core/Actor/ActorManager.cpp2
-rw-r--r--src/00_Core/Actor/ActorSpawner.cpp104
-rw-r--r--src/00_Core/Actor/Dungeon/ActorActionObject.cpp2
-rw-r--r--src/00_Core/Actor/Dungeon/ActorEventIcon.cpp2
-rw-r--r--src/00_Core/Actor/Dungeon/ActorSwitchObject.cpp4
-rw-r--r--src/00_Core/Item/ItemManager.cpp6
-rw-r--r--src/04_Load/Actor/Navi/ActorNaviBase.cpp2
-rw-r--r--src/14_Land/Actor/ActorRupee.cpp2
-rw-r--r--src/14_Land/Actor/Player/ActorArrow.cpp2
-rw-r--r--src/14_Land/Actor/Player/ActorBlast.cpp2
-rw-r--r--src/14_Land/Actor/Player/ActorBomb.cpp2
-rw-r--r--src/14_Land/Actor/Player/ActorRefill.cpp28
-rw-r--r--src/57_Rope/Actor/Player/ActorRope.cpp2
14 files changed, 126 insertions, 39 deletions
diff --git a/src/00_Core/Actor/Actor.cpp b/src/00_Core/Actor/Actor.cpp
index 123b2abe..85f58869 100644
--- a/src/00_Core/Actor/Actor.cpp
+++ b/src/00_Core/Actor/Actor.cpp
@@ -48,8 +48,7 @@ ARM Actor::Actor() :
mUnk_010(0),
mUnk_011(0),
mUnk_012(0),
- mUnk_034(-1),
- mUnk_038(-1),
+ mUnk_034(-1, -1),
mUnk_03c(-1),
mUnk_040(-1, -1),
mGravity(FLOAT_TO_Q20(0.0498)),
@@ -113,7 +112,7 @@ ARM Actor::Actor() :
ARM Actor::~Actor() {}
-ARM bool Actor::vfunc_08() {
+ARM bool Actor::Init() {
return true;
}
diff --git a/src/00_Core/Actor/ActorManager.cpp b/src/00_Core/Actor/ActorManager.cpp
index fed1075e..955c447d 100644
--- a/src/00_Core/Actor/ActorManager.cpp
+++ b/src/00_Core/Actor/ActorManager.cpp
@@ -154,7 +154,7 @@ ARM Actor *ActorManager::GetActor(ActorRef *ref) {
ARM bool FilterActor::Filter(Actor *actor) {
if (mType != actor->mType) return false;
- if (mUnk_08 != -1 && mUnk_08 != actor->mUnk_034) return false;
+ if (mUnk_08 != -1 && mUnk_08 != actor->mUnk_034.id) return false;
if (mExcludeRefs != NULL) {
for (s32 i = 0; mExcludeRefs[i].id != -1; ++i) {
ActorRef *ref = &mExcludeRefs[i];
diff --git a/src/00_Core/Actor/ActorSpawner.cpp b/src/00_Core/Actor/ActorSpawner.cpp
index 76b4ae74..55cf1a57 100644
--- a/src/00_Core/Actor/ActorSpawner.cpp
+++ b/src/00_Core/Actor/ActorSpawner.cpp
@@ -1,10 +1,98 @@
#include "Actor/ActorSpawner.hpp"
+#include "Actor/ActorManager.hpp"
+#include "Map/MapManager.hpp"
-ActorSpawner *ActorSpawner::Create() {}
-void ActorSpawner::Destroy() {}
-ActorSpawner::ActorSpawner() {}
-ActorSpawner::~ActorSpawner() {}
-void ActorSpawner::func_ov000_020c4014() {}
-void ActorSpawner::func_ov000_020c4018() {}
-Actor *ActorSpawner::CreateActor(ActorTypeId type) {}
-s32 ActorSpawner::Spawn(ActorTypeId type, Vec3p *pos, void *param3, ActorRef *ref) {}
+extern u32 *data_027e0ce0[];
+ARM ActorSpawner *ActorSpawner::Create() {
+ gActorSpawner = new(data_027e0ce0[1], 4) ActorSpawner();
+}
+
+ARM void ActorSpawner::Destroy() {
+ delete gActorSpawner;
+ gActorSpawner = NULL;
+}
+
+ARM ActorSpawner::ActorSpawner() {}
+
+ARM ActorSpawner::~ActorSpawner() {}
+
+ARM void ActorSpawner::func_ov000_020c4014() {}
+
+ARM void ActorSpawner::func_ov000_020c4018() {}
+
+ARM Actor *ActorSpawner::CreateActor(ActorTypeId typeId) {
+ Actor *actor = NULL;
+ ActorType *type = ActorType::Find(typeId);
+ if (type != NULL) {
+ actor = type->create();
+ }
+ return actor;
+}
+
+extern "C" unk32 GetCardinal(s16 angle);
+ARM s32 ActorSpawner::Spawn(ActorTypeId type, Vec3p *pos, ActorSpawnOptions *options, ActorRef *ref) {
+ ActorManager *actorManager = gActorManager;
+ u16 maxActors = actorManager->mMaxActors;
+ s32 id = -1;
+ s32 index;
+ Actor **actorSlot = actorManager->mActorTable;
+ for (index = 0; index < maxActors; index++, actorSlot++) {
+ if (*actorSlot != NULL) {
+ continue;
+ }
+
+ Actor *actor = this->CreateActor(type);
+ *actorSlot = actor;
+ if (actor == NULL) {
+ if (ref != NULL) {
+ ref->Reset();
+ }
+ return -1;
+ }
+ actor->mType = type;
+ (*actorSlot)->mRef.id = actorManager->mNextActorId;
+ (*actorSlot)->mRef.index = index;
+ (*actorSlot)->mUnk_014 = *pos;
+ (*actorSlot)->mUnk_020 = options->mUnk_00;
+ (*actorSlot)->mAngle = options->mAngle;
+ (*actorSlot)->mUnk_012 = options->mAngle;
+ (*actorSlot)->mUnk_074 = GetCardinal(options->mAngle);
+ if (options->mUnk_18 >= 0xffff) {
+ (*actorSlot)->mUnk_03c = -1;
+ } else {
+ (*actorSlot)->mUnk_03c = options->mUnk_18;
+ }
+ (*actorSlot)->mUnk_034 = options->mUnk_1c;
+ (*actorSlot)->mUnk_140 = options->mUnk_24;
+ (*actorSlot)->mUnk_144 = options->mUnk_28;
+ Actor *actor2 = *actorSlot;
+ actor2->mPos = *pos;
+ actor2->mPrevPos = *pos;
+ (*actorSlot)->mUnk_010 = gMapManager->GetCourseData_Unk_1c();
+ (*actorSlot)->mUnk_011 = gMapManager->GetCourseData_Unk_1d();
+ u16 nextIndex = index + 1;
+ if (actorManager->mMaxActorIndex < nextIndex) {
+ actorManager->mMaxActorIndex = nextIndex;
+ }
+ actorManager->mCacheEmptyActorIndex = index;
+
+ id = actorManager->mNextActorId;
+ if (ref != NULL) {
+ *ref = ActorRef(id, index);
+ }
+ actorManager->mNextActorId += 1;
+ actorManager->mNumActors += 1;
+ if (!(*actorSlot)->Init()) {
+ (*actorSlot)->mAlive = false;
+ if (ref != NULL) {
+ ref->Reset();
+ }
+ return -1;
+ }
+ break;
+ }
+ if ((id == -1) && (ref != NULL)) {
+ ref->Reset();
+ }
+ return id;
+}
diff --git a/src/00_Core/Actor/Dungeon/ActorActionObject.cpp b/src/00_Core/Actor/Dungeon/ActorActionObject.cpp
index 0a2c3970..ea2dfec2 100644
--- a/src/00_Core/Actor/Dungeon/ActorActionObject.cpp
+++ b/src/00_Core/Actor/Dungeon/ActorActionObject.cpp
@@ -18,7 +18,7 @@ ARM ActorActionObject::ActorActionObject() {}
ARM ActorActionObject::~ActorActionObject() {}
// non-matching
-ARM bool ActorActionObject::vfunc_08() {
+ARM bool ActorActionObject::Init() {
mGravity = 0;
mHitbox.pos = gVec3p_ZERO;
mHitbox.size = -1;
diff --git a/src/00_Core/Actor/Dungeon/ActorEventIcon.cpp b/src/00_Core/Actor/Dungeon/ActorEventIcon.cpp
index 94e7381d..22e35d8e 100644
--- a/src/00_Core/Actor/Dungeon/ActorEventIcon.cpp
+++ b/src/00_Core/Actor/Dungeon/ActorEventIcon.cpp
@@ -4,7 +4,7 @@ ActorType ActorEventIcon::gType = ActorType(ActorTypeId_EventIcon, (ActorCreateF
ActorEventIcon *ActorEventIcon::Create() {}
ActorEventIcon::ActorEventIcon() {}
-bool ActorEventIcon::vfunc_08() {}
+bool ActorEventIcon::Init() {}
void ActorEventIcon::vfunc_14(u32 param1) {}
void ActorEventIcon::vfunc_18(u32 param1) {}
u32 ActorEventIcon::func_ov000_02090648(u32 param1) {}
diff --git a/src/00_Core/Actor/Dungeon/ActorSwitchObject.cpp b/src/00_Core/Actor/Dungeon/ActorSwitchObject.cpp
index c767e5b9..78e229db 100644
--- a/src/00_Core/Actor/Dungeon/ActorSwitchObject.cpp
+++ b/src/00_Core/Actor/Dungeon/ActorSwitchObject.cpp
@@ -5,8 +5,8 @@ ActorType ActorSwitchObject::gType = ActorType(ActorTypeId_SwitchObject, (ActorC
ActorSwitchObject *ActorSwitchObject::Create() {}
-bool ActorSwitchObject::vfunc_08() {
- Actor::vfunc_08();
+bool ActorSwitchObject::Init() {
+ Actor::Init();
this->func_ov000_0208fc7c();
this->mUnk_130 = 0;
return true;
diff --git a/src/00_Core/Item/ItemManager.cpp b/src/00_Core/Item/ItemManager.cpp
index 4b2e7b44..3c77b0ab 100644
--- a/src/00_Core/Item/ItemManager.cpp
+++ b/src/00_Core/Item/ItemManager.cpp
@@ -461,7 +461,7 @@ static char *sItemModelNames2[8] = {
[ItemId_SandOfHours - ItemId_SwordsmanScroll] = "sand_m",
};
static char *sItemModelNames3[9] = {
- [ItemId_CycloneSlate - ItemId_CycloneSlate] = "compass", [ItemId_Unk_128 - ItemId_CycloneSlate] = "lure",
+ [ItemId_CycloneSlate - ItemId_CycloneSlate] = "compass", [ItemId_BigCatchLure - ItemId_CycloneSlate] = "lure",
[ItemId_Rupoor10 - ItemId_CycloneSlate] = "rupee_bb", [ItemId_Rupoor50 - ItemId_CycloneSlate] = "rupee_bb",
[ItemId_Unk_131 - ItemId_CycloneSlate] = NULL, [ItemId_Unk_132 - ItemId_CycloneSlate] = NULL,
[ItemId_Unk_133 - ItemId_CycloneSlate] = NULL, [ItemId_Unk_134 - ItemId_CycloneSlate] = NULL,
@@ -778,8 +778,8 @@ THUMB void ItemManager::GiveItem(ItemId id) {
SET_FLAG(mItemFlags.flags, ItemFlag_CycloneSlate);
} break;
- case ItemId_Unk_128: {
- SET_FLAG(mItemFlags.flags, ItemFlag_Unk_47);
+ case ItemId_BigCatchLure: {
+ SET_FLAG(mItemFlags.flags, ItemFlag_BigCatchLure);
} break;
case ItemId_Rupoor10: {
diff --git a/src/04_Load/Actor/Navi/ActorNaviBase.cpp b/src/04_Load/Actor/Navi/ActorNaviBase.cpp
index c4f5a069..21d91459 100644
--- a/src/04_Load/Actor/Navi/ActorNaviBase.cpp
+++ b/src/04_Load/Actor/Navi/ActorNaviBase.cpp
@@ -3,4 +3,4 @@
ActorNaviBase::ActorNaviBase() {}
ActorNaviBase::~ActorNaviBase() {}
void func_ov004_021079d4(unk32 *param1) {}
-bool ActorNaviBase::vfunc_08() {}
+bool ActorNaviBase::Init() {}
diff --git a/src/14_Land/Actor/ActorRupee.cpp b/src/14_Land/Actor/ActorRupee.cpp
index 32a95333..23ac82dc 100644
--- a/src/14_Land/Actor/ActorRupee.cpp
+++ b/src/14_Land/Actor/ActorRupee.cpp
@@ -36,7 +36,7 @@ ActorRupee::ActorRupee() {
}
// https://decomp.me/scratch/1qjCc
-bool ActorRupee::vfunc_08() {
+bool ActorRupee::Init() {
u32 dVar5;
u32 iVar7;
diff --git a/src/14_Land/Actor/Player/ActorArrow.cpp b/src/14_Land/Actor/Player/ActorArrow.cpp
index 48d27797..96529bf4 100644
--- a/src/14_Land/Actor/Player/ActorArrow.cpp
+++ b/src/14_Land/Actor/Player/ActorArrow.cpp
@@ -11,7 +11,7 @@ void ActorArrow::func_ov014_0211fd80(unk32 param1) {}
void ActorArrow::func_ov014_0211fd90() {}
ActorArrow::ActorArrow() {}
ActorArrow::~ActorArrow() {}
-bool ActorArrow::vfunc_08() {}
+bool ActorArrow::Init() {}
bool ActorArrow::CollidesWith(Actor *other) {}
void ActorArrow::func_ov014_021200d4() {}
void ActorArrow::func_ov014_02120118() {}
diff --git a/src/14_Land/Actor/Player/ActorBlast.cpp b/src/14_Land/Actor/Player/ActorBlast.cpp
index 0f892335..06f82f63 100644
--- a/src/14_Land/Actor/Player/ActorBlast.cpp
+++ b/src/14_Land/Actor/Player/ActorBlast.cpp
@@ -6,7 +6,7 @@ ActorBlast *ActorBlast::Create() {}
void ActorBlast_Unk1::vfunc_10(s32 *param1) {}
ActorBlast::ActorBlast() {}
ActorBlast::~ActorBlast() {}
-bool ActorBlast::vfunc_08() {}
+bool ActorBlast::Init() {}
void ActorBlast::vfunc_14(u32 param1) {}
ActorBlast_Unk1::~ActorBlast_Unk1() {}
void ActorBlast::vfunc_18(u32 param1) {}
diff --git a/src/14_Land/Actor/Player/ActorBomb.cpp b/src/14_Land/Actor/Player/ActorBomb.cpp
index 1ee7c1bc..91224f12 100644
--- a/src/14_Land/Actor/Player/ActorBomb.cpp
+++ b/src/14_Land/Actor/Player/ActorBomb.cpp
@@ -9,7 +9,7 @@ ActorBomb::ActorBomb() {}
ActorBomb_Unk2::~ActorBomb_Unk2() {}
ActorBomb::~ActorBomb() {}
ActorBomb_Unk2::ActorBomb_Unk2() {}
-bool ActorBomb::vfunc_08() {}
+bool ActorBomb::Init() {}
void ActorBomb::vfunc_14(u32 param1) {}
ActorBomb_Unk1::~ActorBomb_Unk1() {}
void ActorBomb::vfunc_18(u32 param1) {}
diff --git a/src/14_Land/Actor/Player/ActorRefill.cpp b/src/14_Land/Actor/Player/ActorRefill.cpp
index 0e6a9edf..91efd351 100644
--- a/src/14_Land/Actor/Player/ActorRefill.cpp
+++ b/src/14_Land/Actor/Player/ActorRefill.cpp
@@ -41,16 +41,16 @@ ARM ActorRefill::ActorRefill(unk32 param1) :
ARM ActorRefill::~ActorRefill() {}
-ARM bool ActorRefill::vfunc_08() {
+ARM bool ActorRefill::Init() {
ItemManager *itemManager;
- if (this->vfunc_b4() == ItemFlag_None) {
+ if (this->GetAmmoItem() == ItemFlag_None) {
if (data_027e0d38->func_ov000_02078b40() != 3) {
return false;
}
} else {
ItemManager *itemManager = gItemManager;
- ItemFlag item = this->vfunc_b4();
+ ItemFlag item = this->GetAmmoItem();
if (!itemManager->HasItem(item)) {
return false;
}
@@ -111,11 +111,11 @@ ARM void ActorRefill::vfunc_14(u32 param1) {
case 4:
case 5:
if (this->CollidesWithPlayer(PlayerCollide_PickupFlags) != 0) {
- if (this->vfunc_b4() == -1) {
+ if (this->GetAmmoItem() == -1) {
data_027e103c->func_ov000_020cfbf0(mUnk_158 * 60, 1, 0);
} else {
ItemManager *itemManager = gItemManager;
- itemManager->GiveAmmo(this->vfunc_b4(), mUnk_158);
+ itemManager->GiveAmmo(this->GetAmmoItem(), mUnk_158);
}
func_ov000_020d7ad4(&data_ov000_020eec9c, 0x100);
this->func_ov014_02135364(3);
@@ -227,7 +227,7 @@ ARM ActorRefillBombs::ActorRefillBombs() :
ARM ActorRefillBombs::~ActorRefillBombs() {}
-ARM ItemFlag ActorRefillBombs::vfunc_b4() {
+ARM ItemFlag ActorRefillBombs::GetAmmoItem() {
return ItemFlag_BombBag;
}
@@ -239,7 +239,7 @@ ARM ActorRefillBombchus::ActorRefillBombchus() :
ARM ActorRefillBombchus::~ActorRefillBombchus() {}
-ARM ItemFlag ActorRefillBombchus::vfunc_b4() {
+ARM ItemFlag ActorRefillBombchus::GetAmmoItem() {
return ItemFlag_BombchuBag;
}
@@ -251,7 +251,7 @@ ARM ActorRefillArrows::ActorRefillArrows() :
ARM ActorRefillArrows::~ActorRefillArrows() {}
-ARM ItemFlag ActorRefillArrows::vfunc_b4() {
+ARM ItemFlag ActorRefillArrows::GetAmmoItem() {
return ItemFlag_Bow;
}
@@ -263,8 +263,8 @@ ARM ActorRefillTime::ActorRefillTime() :
ARM ActorRefillTime::~ActorRefillTime() {}
-ARM bool ActorRefillTime::vfunc_08() {
- if (!ActorRefill::vfunc_08()) {
+ARM bool ActorRefillTime::Init() {
+ if (!ActorRefill::Init()) {
return false;
}
switch (mUnk_020.mUnk_00[0]) {
@@ -293,7 +293,7 @@ ARM bool ActorRefillTime::vfunc_08() {
return true;
}
-ARM ItemFlag ActorRefillTime::vfunc_b4() {
+ARM ItemFlag ActorRefillTime::GetAmmoItem() {
return ItemFlag_None;
}
@@ -305,8 +305,8 @@ ARM ActorLSTM::ActorLSTM() :
ARM ActorLSTM::~ActorLSTM() {}
-ARM bool ActorLSTM::vfunc_08() {
- if (!ActorRefill::vfunc_08()) {
+ARM bool ActorLSTM::Init() {
+ if (!ActorRefill::Init()) {
return false;
}
switch (mUnk_020.mUnk_00[0]) {
@@ -335,6 +335,6 @@ ARM bool ActorLSTM::vfunc_08() {
return true;
}
-ARM ItemFlag ActorLSTM::vfunc_b4() {
+ARM ItemFlag ActorLSTM::GetAmmoItem() {
return ItemFlag_None;
}
diff --git a/src/57_Rope/Actor/Player/ActorRope.cpp b/src/57_Rope/Actor/Player/ActorRope.cpp
index 023f134b..40ab1aa4 100644
--- a/src/57_Rope/Actor/Player/ActorRope.cpp
+++ b/src/57_Rope/Actor/Player/ActorRope.cpp
@@ -5,7 +5,7 @@ ActorRope_Unk_0219a3b0 gUnk_0219a3b0;
void ActorRope_Unk_0219a3b0::vfunc_08(unk16 *param1) {}
void ActorRope_Unk_0219a3b0::vfunc_10(s32 *param1) {}
ActorRope::ActorRope() {}
-bool ActorRope::vfunc_08() {}
+bool ActorRope::Init() {}
q20 ActorRope::func_ov057_0219a5ac() {}
void ActorRope::func_ov057_0219a6b8() {}
void ActorRope::func_ov057_0219a850() {}