Restore Original Scene Command Object List Behaviour (MacReady) (#3827)

* Restore Original Scene_CommandObjectList Behaviour

* remove some vrom stuff

* add some comments
This commit is contained in:
inspectredc 2024-01-15 15:30:20 +00:00 committed by GitHub
parent 861bd09848
commit db02870a05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 35 deletions

View File

@ -149,6 +149,13 @@ bool Scene_CommandMeshHeader(PlayState* play, LUS::ISceneCommand* cmd) {
extern "C" void* func_800982FC(ObjectContext* objectCtx, s32 bankIndex, s16 objectId); extern "C" void* func_800982FC(ObjectContext* objectCtx, s32 bankIndex, s16 objectId);
bool OTRfunc_800982FC(ObjectContext* objectCtx, s32 bankIndex, s16 objectId) {
objectCtx->status[bankIndex].id = -objectId;
return false;
}
bool Scene_CommandObjectList(PlayState* play, LUS::ISceneCommand* cmd) { bool Scene_CommandObjectList(PlayState* play, LUS::ISceneCommand* cmd) {
// LUS::SetObjectList* cmdObj = static_pointer_cast<LUS::SetObjectList>(cmd); // LUS::SetObjectList* cmdObj = static_pointer_cast<LUS::SetObjectList>(cmd);
LUS::SetObjectList* cmdObj = (LUS::SetObjectList*)cmd; LUS::SetObjectList* cmdObj = (LUS::SetObjectList*)cmd;
@ -164,49 +171,30 @@ bool Scene_CommandObjectList(PlayState* play, LUS::ISceneCommand* cmd) {
void* nextPtr; void* nextPtr;
k = 0; k = 0;
// i = play->objectCtx.unk_09; i = play->objectCtx.unk_09;
i = 0;
firstStatus = &play->objectCtx.status[0]; firstStatus = &play->objectCtx.status[0];
status = &play->objectCtx.status[i]; status = &play->objectCtx.status[i];
for (int i = 0; i < cmdObj->objects.size(); i++) { // Loop until a mismatch in the object lists
bool alreadyIncluded = false; // Then clear all object ids past that in the context object list and kill actors for those objects
for (i = play->objectCtx.unk_09, k = 0; i < play->objectCtx.num; i++, k++) {
for (int j = 0; j < play->objectCtx.num; j++) { if (play->objectCtx.status[i].id != cmdObj->objects[k]) {
if (play->objectCtx.status[j].id == cmdObj->objects[i]) { for (j = i; j < play->objectCtx.num; j++) {
alreadyIncluded = true; play->objectCtx.status[j].id = OBJECT_INVALID;
break;
} }
}
if (!alreadyIncluded) {
play->objectCtx.status[play->objectCtx.num++].id = cmdObj->objects[i];
func_80031A28(play, &play->actorCtx); func_80031A28(play, &play->actorCtx);
break;
} }
} }
/* // Continuing from the last index, add the remaining object ids from the command object list
while (i < play->objectCtx.num) { for (; k < cmdObj->objects.size(); k++, i++) {
if (status->id != *objectEntry) { if (i < OBJECT_EXCHANGE_BANK_MAX - 1) {
status2 = &play->objectCtx.status[i]; OTRfunc_800982FC(&play->objectCtx, i, cmdObj->objects[k]);
for (j = i; j < play->objectCtx.num; j++) {
status2->id = OBJECT_INVALID;
status2++;
}
play->objectCtx.num = i;
func_80031A28(play, &play->actorCtx);
continue;
} }
i++;
k++;
objectEntry++;
status++;
} }
play->objectCtx.num = i; play->objectCtx.num = i;
*/
return false; return false;
} }

View File

@ -1219,8 +1219,7 @@ void Actor_Init(Actor* actor, PlayState* play) {
CollisionCheck_InitInfo(&actor->colChkInfo); CollisionCheck_InitInfo(&actor->colChkInfo);
actor->floorBgId = BGCHECK_SCENE; actor->floorBgId = BGCHECK_SCENE;
ActorShape_Init(&actor->shape, 0.0f, NULL, 0.0f); ActorShape_Init(&actor->shape, 0.0f, NULL, 0.0f);
//if (Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) if (Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) {
{
//Actor_SetObjectDependency(play, actor); //Actor_SetObjectDependency(play, actor);
actor->init(actor, play); actor->init(actor, play);
actor->init = NULL; actor->init = NULL;
@ -3129,6 +3128,9 @@ void Actor_FreeOverlay(ActorDBEntry* dbEntry) {
osSyncPrintf(VT_RST); osSyncPrintf(VT_RST);
} }
// SoH: Flag to check if actors are being spawned from the actor entry list
// This flag is checked against to allow actors which dont have an objectBankIndex in the objectCtx slot/status array to spawn
// An example of what this fixes, is that it allows hookshot to be used as child
int gMapLoading = 0; int gMapLoading = 0;
Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 posX, f32 posY, f32 posZ, Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 posX, f32 posY, f32 posZ,

View File

@ -83,9 +83,10 @@ void Object_UpdateBank(ObjectContext* objectCtx) {
RomFile* objectFile; RomFile* objectFile;
size_t size; size_t size;
/*
for (i = 0; i < objectCtx->num; i++) { for (i = 0; i < objectCtx->num; i++) {
if (status->id < 0) { if (status->id < 0) {
/*
if (status->dmaRequest.vromAddr == 0) { if (status->dmaRequest.vromAddr == 0) {
osCreateMesgQueue(&status->loadQueue, &status->loadMsg, 1); osCreateMesgQueue(&status->loadQueue, &status->loadMsg, 1);
objectFile = &gObjectTable[-status->id]; objectFile = &gObjectTable[-status->id];
@ -96,10 +97,12 @@ void Object_UpdateBank(ObjectContext* objectCtx) {
} else if (!osRecvMesg(&status->loadQueue, NULL, OS_MESG_NOBLOCK)) { } else if (!osRecvMesg(&status->loadQueue, NULL, OS_MESG_NOBLOCK)) {
status->id = -status->id; status->id = -status->id;
} }
*/
status->id = -status->id;
} }
status++; status++;
} }
*/
} }
s32 Object_GetIndex(ObjectContext* objectCtx, s16 objectId) { s32 Object_GetIndex(ObjectContext* objectCtx, s16 objectId) {