summaryrefslogtreecommitdiff
path: root/mm/src/code
diff options
context:
space:
mode:
authorArchez <Archez@users.noreply.github.com>2024-04-28 20:12:19 -0400
committerGarrett Cox <garrettjcox@gmail.com>2024-05-22 09:05:02 -0500
commit0da645e7e63f1c76de2dbee56574c3e2753ed467 (patch)
tree90eabaa1e081f9a0be1abdce58853b924f086eec /mm/src/code
parent5eb543bfdf7732dc9da2e64a09254970d32a8f63 (diff)
Fix actor inits happening too early (#248)
Diffstat (limited to 'mm/src/code')
-rw-r--r--mm/src/code/z_scene.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/mm/src/code/z_scene.c b/mm/src/code/z_scene.c
index caf78f9e4..e74852dc2 100644
--- a/mm/src/code/z_scene.c
+++ b/mm/src/code/z_scene.c
@@ -35,6 +35,9 @@ s32 Object_SpawnPersistent(ObjectContext* objectCtx, s16 id) {
return objectCtx->numEntries - 1;
}
+// 2S2H [Port] Track when objects are first loaded for a scene
+static u8 sObjectFirstUpdateSkippedForScene = false;
+
void Object_InitContext(GameState* gameState, ObjectContext* objectCtx) {
PlayState* play = (PlayState*)gameState;
s32 pad;
@@ -66,6 +69,8 @@ void Object_InitContext(GameState* gameState, ObjectContext* objectCtx) {
objectCtx->mainKeepSlot = Object_SpawnPersistent(objectCtx, GAMEPLAY_KEEP);
gSegments[4] = OS_K0_TO_PHYSICAL(objectCtx->slots[objectCtx->mainKeepSlot].segment);
+
+ sObjectFirstUpdateSkippedForScene = false;
}
void Object_UpdateEntries(ObjectContext* objectCtx) {
@@ -74,18 +79,25 @@ void Object_UpdateEntries(ObjectContext* objectCtx) {
RomFile* objectFile;
size_t size;
+ // 2S2H [Port] Skip the first object load after scene init so that actors have their init delayed by one frame
+ // This seems to mostly if not nearly resolve actors that depend on console DMA requests ending later
+ if (!sObjectFirstUpdateSkippedForScene) {
+ sObjectFirstUpdateSkippedForScene = true;
+ return;
+ }
+
for (i = 0; i < objectCtx->numEntries; i++) {
if (entry->id < 0) {
s32 id = -entry->id;
- // #region 2S2H [Port] We don't care to load the object from DMA, consider it already loaded
+ // 2S2H [Port] We don't care to load the object from DMA, consider it already loaded
// There is a weird case handled below that accounts for RomFiles with a size of 0, but according
// to object_table.h there is only one instance of this, along with a bunch of placeholder entries
// so we _should_ be fine. Famous last words.
entry->id = id;
}
- entry++;
+ entry++;
}
}