Fix actor inits happening too early (#4742)

* fix dogs not running

* clean up kak gs fix

* clean up scrub leader fix
This commit is contained in:
briaguya 2024-12-21 10:08:48 -05:00 committed by GitHub
parent 6fb974bfeb
commit ff24581281
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 21 deletions

View File

@ -33,6 +33,10 @@ s32 Object_Spawn(ObjectContext* objectCtx, s16 objectId) {
return objectCtx->num - 1; return objectCtx->num - 1;
} }
// SOH [Port] Track when objects are first loaded for a scene
static u8 sObjectFirstUpdateSkippedForScene = false;
void Object_InitBank(PlayState* play, ObjectContext* objectCtx) { void Object_InitBank(PlayState* play, ObjectContext* objectCtx) {
PlayState* play2 = play; // Needs to be a new variable to match (possibly a sub struct?) PlayState* play2 = play; // Needs to be a new variable to match (possibly a sub struct?)
size_t spaceSize; size_t spaceSize;
@ -75,6 +79,8 @@ void Object_InitBank(PlayState* play, ObjectContext* objectCtx) {
objectCtx->mainKeepIndex = Object_Spawn(objectCtx, OBJECT_GAMEPLAY_KEEP); objectCtx->mainKeepIndex = Object_Spawn(objectCtx, OBJECT_GAMEPLAY_KEEP);
gSegments[4] = VIRTUAL_TO_PHYSICAL(objectCtx->status[objectCtx->mainKeepIndex].segment); gSegments[4] = VIRTUAL_TO_PHYSICAL(objectCtx->status[objectCtx->mainKeepIndex].segment);
sObjectFirstUpdateSkippedForScene = false;
} }
void Object_UpdateBank(ObjectContext* objectCtx) { void Object_UpdateBank(ObjectContext* objectCtx) {
@ -83,6 +89,12 @@ void Object_UpdateBank(ObjectContext* objectCtx) {
RomFile* objectFile; RomFile* objectFile;
size_t size; size_t size;
// SOH [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->num; i++) { for (i = 0; i < objectCtx->num; i++) {
if (status->id < 0) { if (status->id < 0) {

View File

@ -102,9 +102,6 @@ void EnDntJiji_Destroy(Actor* thisx, PlayState* play) {
} }
void EnDntJiji_SetFlower(EnDntJiji* this, PlayState* play) { void EnDntJiji_SetFlower(EnDntJiji* this, PlayState* play) {
// SOH: Due to removed object dependencies, parent was still NULL when Init was called. In order to properly set
// stage, redo it here now that we are a frame later.
this->stage = (EnDntDemo*)this->actor.parent;
if (this->actor.bgCheckFlags & 1) { if (this->actor.bgCheckFlags & 1) {
this->flowerPos = this->actor.world.pos; this->flowerPos = this->actor.world.pos;
this->actionFunc = EnDntJiji_SetupWait; this->actionFunc = EnDntJiji_SetupWait;

View File

@ -215,16 +215,6 @@ s32 func_80B0C0CC(EnSw* this, PlayState* play, s32 arg2) {
return sp64; return sp64;
} }
// Presumably, due to the removal of object dependency, there is a race condition where
// the GS on the Kak construction site spawns to early and fails to detect the
// construction site dyna poly. This custom action func rechecks moving the GS
// to the nearest poly one frame after init. Further explanation available:
// https://github.com/HarbourMasters/Shipwright/issues/2310#issuecomment-1492829517
void EnSw_MoveGoldLater(EnSw* this, PlayState* play) {
func_80B0C0CC(this, play, 1);
this->actionFunc = func_80B0D590;
}
void EnSw_Init(Actor* thisx, PlayState* play) { void EnSw_Init(Actor* thisx, PlayState* play) {
EnSw* this = (EnSw*)thisx; EnSw* this = (EnSw*)thisx;
s32 phi_v0; s32 phi_v0;
@ -316,14 +306,6 @@ void EnSw_Init(Actor* thisx, PlayState* play) {
} else { } else {
this->actionFunc = func_80B0D590; this->actionFunc = func_80B0D590;
} }
// If a normal GS failed to get attached to a poly during init
// try once more on the next frame via a custom action func
if ((((thisx->params & 0xE000) >> 0xD) == 1 ||
((thisx->params & 0xE000) >> 0xD) == 2) &&
this->actor.floorPoly == NULL) {
this->actionFunc = EnSw_MoveGoldLater;
}
} }
void EnSw_Destroy(Actor* thisx, PlayState* play) { void EnSw_Destroy(Actor* thisx, PlayState* play) {