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

Increase chestRewarded second array dimension to larger number. #7

Merged
merged 2 commits into from
Jan 24, 2024
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
4 changes: 2 additions & 2 deletions code/include/rnd/savefile.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "z3d/z3DVec.h"

// Increment the version number whenever the ExtSaveData structure is changed
#define EXTSAVEDATA_VERSION 8
#define EXTSAVEDATA_VERSION 9
#define SAVEFILE_SCENES_DISCOVERED_IDX_COUNT 4
#define SAVEFILE_SPOILER_ITEM_MAX 512

Expand Down Expand Up @@ -94,7 +94,7 @@ namespace rnd {
TingleCollectRegister tingleMaps;
u32 scenesDiscovered[SAVEFILE_SCENES_DISCOVERED_IDX_COUNT];
u8 itemCollected[SAVEFILE_SPOILER_ITEM_MAX];
u8 chestRewarded[116][30]; // Reward table that's stored by scene and chest param/flag.
u8 chestRewarded[116][32]; // Reward table that's stored by scene and chest param/flag.
} ExtSaveData;

extern "C" ExtSaveData gExtSaveData;
Expand Down
8 changes: 6 additions & 2 deletions code/source/rnd/item_override.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,10 @@ namespace rnd {
if (rActiveItemOverride.key.type == ItemOverride_Type::OVR_CHEST) {
// Check and see if we have trade items or repeatable bottles and add to the array.
if (rActiveItemRow->itemId < 0x28 || (rActiveItemRow->itemId > 0x30 && rActiveItemRow->itemId < 0x9f)) {
gExtSaveData.chestRewarded[rActiveItemOverride.key.scene][rActiveItemOverride.key.flag] = 1;
// XXX: Hacky fix but maybe we need to redo how we track chests. Mark Giant's Mask Chest
// to be repeatably obtainable since we're not extending this array to 126 in the second dimension.
if (rActiveItemOverride.key.flag < 0x20)
gExtSaveData.chestRewarded[rActiveItemOverride.key.scene][rActiveItemOverride.key.flag] = 1;
}
}
game::GlobalContext* gctx = rnd::GetContext().gctx;
Expand Down Expand Up @@ -566,7 +569,8 @@ namespace rnd {
ItemOverride_Clear();
player->get_item_id = incomingGetItemId;
return;
} else if (gExtSaveData.chestRewarded[override.key.scene][override.key.flag] == 1) {
} else if (override.key.type == ItemOverride_Type::OVR_CHEST &&
gExtSaveData.chestRewarded[override.key.scene][override.key.flag] == 1) {
// Override was already given, use base game's item code
ItemOverride_Clear();
player->get_item_id = -(s16)GetItemID::GI_RUPEE_BLUE;
Expand Down