Skip to content

Commit

Permalink
PlayerSelectScreen: Fix invalid SaveRAM access in no-save mode
Browse files Browse the repository at this point in the history
In no-save mode, this code was trying to access `saveGame->files[-1]`.
No-save doesn't write anything to SaveRAM in the original code, and
save mode already wrote it, so all we need is to get the charID.
  • Loading branch information
Mefiresu committed Sep 29, 2024
1 parent c8ab01f commit 3b70007
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions RSDKv4/NativeObjects/PlayerSelectScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,14 @@ void PlayerSelectScreen_Main(void *objPtr)
SetGlobalVariableByName("starPostID", 0);
debugMode = false;

int charID = 0;
switch (self->playerID) {
case SAVESEL_SONIC: saveGame->files[saveSel->selectedButton - 1].characterID = 0; break;
case SAVESEL_TAILS: saveGame->files[saveSel->selectedButton - 1].characterID = 1; break;
case SAVESEL_KNUX: saveGame->files[saveSel->selectedButton - 1].characterID = 2; break;
case SAVESEL_ST: saveGame->files[saveSel->selectedButton - 1].characterID = 3; break;
case SAVESEL_SONIC: charID = 0; break;
case SAVESEL_TAILS: charID = 1; break;
case SAVESEL_KNUX: charID = 2; break;
case SAVESEL_ST: charID = 3; break;
}
InitStartingStage(STAGELIST_PRESENTATION, 0, saveGame->files[saveSel->selectedButton - 1].characterID);
InitStartingStage(STAGELIST_PRESENTATION, 0, charID);

CREATE_ENTITY(FadeScreen);
}
Expand Down

0 comments on commit 3b70007

Please sign in to comment.