Skip to content

Commit

Permalink
Merge pull request #3 from garrettjoecox/entrance-rando-fixes
Browse files Browse the repository at this point in the history
Entirely replace gSaveContext.entranceIndex, and near the top of Gameplay_Init
  • Loading branch information
Ryanoberlein authored Aug 13, 2022
2 parents 737075e + e60013d commit 819f669
Showing 1 changed file with 15 additions and 35 deletions.
50 changes: 15 additions & 35 deletions soh/src/code/z_play.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,16 @@ void Gameplay_Init(GameState* thisx) {
u8 tempSetupIndex;
s32 pad[2];

if (gSaveContext.n64ddFlag && true) { // TODO: Replace true with check for entrance rando setting
// TODO: Can we use a map here for a constant time lookup?
for (i = 0; i < 250; i++) { // TODO: Magic number 250, replace with actual size of vector
if (gSaveContext.EntranceIndeces[i].index == gSaveContext.entranceIndex) {
gSaveContext.entranceIndex = gSaveContext.EntranceIndeces[i].overrideindex;
break;
}
}
}

// Skip Child Stealth when option is enabled, Zelda's Letter isn't obtained and Impa's reward hasn't been received
// eventChkInf[4] & 1 = Got Zelda's Letter
// eventChkInf[5] & 0x200 = Got Impa's reward
Expand Down Expand Up @@ -382,41 +392,11 @@ void Gameplay_Init(GameState* thisx) {
gSaveContext.sceneSetupIndex = (gSaveContext.eventChkInf[4] & 0x100) ? 3 : 2;
}

int index;
for (index = 0; index<250; ++index) {
// NOTE: this is why filling with -1 matters, sometimes gSaveContext.entranceIndex is 0
if (gSaveContext.EntranceIndeces[index].index == gSaveContext.entranceIndex) {
Gameplay_SpawnScene(
globalCtx,
gEntranceTable[((void)0, gSaveContext.EntranceIndeces[index].overrideindex) + ((void)0,
gSaveContext.sceneSetupIndex)].scene, gEntranceTable[((void)0, gSaveContext.sceneSetupIndex) +
((void)0, gSaveContext.EntranceIndeces[index].overrideindex)].spawn);
break;
} else if (index==249){
Gameplay_SpawnScene(
globalCtx,
gEntranceTable[((void)0, gSaveContext.entranceIndex) + ((void)0,
gSaveContext.sceneSetupIndex)].scene, gEntranceTable[((void)0, gSaveContext.sceneSetupIndex) +
((void)0, gSaveContext.entranceIndex)].spawn);
break;
}
else {
continue;
}
}
//if (gSaveContext.entranceIndex == 0000 || gSaveContext.entranceIndex == 0001 || gSaveContext.entranceIndex == 0002 ||
// gSaveContext.entranceIndex == 0003) {
// Gameplay_SpawnScene(
// globalCtx,
// gEntranceTable[(4) + ((void)0, gSaveContext.sceneSetupIndex)]
// .scene,
// gEntranceTable[((void)0, gSaveContext.sceneSetupIndex) + (4)].spawn);
//} else {
// Gameplay_SpawnScene(
// globalCtx,
// gEntranceTable[((void)0, gSaveContext.entranceIndex) + ((void)0, gSaveContext.sceneSetupIndex)].scene,
// gEntranceTable[((void)0, gSaveContext.sceneSetupIndex) + ((void)0, gSaveContext.entranceIndex)].spawn);
//}
Gameplay_SpawnScene(
globalCtx,
gEntranceTable[((void)0, gSaveContext.entranceIndex) + ((void)0, gSaveContext.sceneSetupIndex)].scene,
gEntranceTable[((void)0, gSaveContext.sceneSetupIndex) + ((void)0, gSaveContext.entranceIndex)].spawn);

osSyncPrintf("\nSCENE_NO=%d COUNTER=%d\n", ((void)0, gSaveContext.entranceIndex), gSaveContext.sceneSetupIndex);

Cutscene_HandleEntranceTriggers(globalCtx);
Expand Down

0 comments on commit 819f669

Please sign in to comment.