Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 19 additions & 31 deletions soh/soh/z_scene_otr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ bool Scene_CommandMeshHeader(PlayState* play, LUS::ISceneCommand* cmd) {

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) {
// LUS::SetObjectList* cmdObj = static_pointer_cast<LUS::SetObjectList>(cmd);
LUS::SetObjectList* cmdObj = (LUS::SetObjectList*)cmd;
Expand All @@ -164,49 +171,30 @@ bool Scene_CommandObjectList(PlayState* play, LUS::ISceneCommand* cmd) {
void* nextPtr;

k = 0;
// i = play->objectCtx.unk_09;
i = 0;
i = play->objectCtx.unk_09;
firstStatus = &play->objectCtx.status[0];
status = &play->objectCtx.status[i];

for (int i = 0; i < cmdObj->objects.size(); i++) {
bool alreadyIncluded = false;

for (int j = 0; j < play->objectCtx.num; j++) {
if (play->objectCtx.status[j].id == cmdObj->objects[i]) {
alreadyIncluded = true;
break;
// Loop until a mismatch in the object lists
// 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++) {
if (play->objectCtx.status[i].id != cmdObj->objects[k]) {
for (j = i; j < play->objectCtx.num; j++) {
play->objectCtx.status[j].id = OBJECT_INVALID;
}
}

if (!alreadyIncluded) {
play->objectCtx.status[play->objectCtx.num++].id = cmdObj->objects[i];
func_80031A28(play, &play->actorCtx);
break;
}
}

/*
while (i < play->objectCtx.num) {
if (status->id != *objectEntry) {
status2 = &play->objectCtx.status[i];
for (j = i; j < play->objectCtx.num; j++) {
status2->id = OBJECT_INVALID;
status2++;
}
play->objectCtx.num = i;
func_80031A28(play, &play->actorCtx);

continue;
// Continuing from the last index, add the remaining object ids from the command object list
for (; k < cmdObj->objects.size(); k++, i++) {
if (i < OBJECT_EXCHANGE_BANK_MAX - 1) {
OTRfunc_800982FC(&play->objectCtx, i, cmdObj->objects[k]);
}

i++;
k++;
objectEntry++;
status++;
}

play->objectCtx.num = i;
*/

return false;
}
Expand Down
6 changes: 4 additions & 2 deletions soh/src/code/z_actor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1219,8 +1219,7 @@ void Actor_Init(Actor* actor, PlayState* play) {
CollisionCheck_InitInfo(&actor->colChkInfo);
actor->floorBgId = BGCHECK_SCENE;
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->init(actor, play);
actor->init = NULL;
Expand Down Expand Up @@ -3129,6 +3128,9 @@ void Actor_FreeOverlay(ActorDBEntry* dbEntry) {
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;

Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 posX, f32 posY, f32 posZ,
Expand Down
7 changes: 5 additions & 2 deletions soh/src/code/z_scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ void Object_UpdateBank(ObjectContext* objectCtx) {
RomFile* objectFile;
size_t size;

/*

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

}

s32 Object_GetIndex(ObjectContext* objectCtx, s16 objectId) {
Expand Down
Loading