Fixes Switch/Wii U crashes with Wonder Rupees and Bottleable Entities (#1360)

* Reorders switch statement to prevent some code that shouldn't execute.

* Potentially fixes bottleable entities crash

* Solves lack of ItemEntry for GI_MAX

* Adds comment clarifying new GetItemEntry
This commit is contained in:
Christopher Leggett 2022-09-02 13:19:12 -04:00 committed by GitHub
parent 584a4ad818
commit 64aca78450
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 8 deletions

View File

@ -289,6 +289,7 @@ extern "C" void VanillaItemTable_Init() {
GET_ITEM(ITEM_BULLET_BAG_50, OBJECT_GI_DEKUPOUCH, GID_BULLET_BAG_50, 0x6C, 0x80, CHEST_ANIM_LONG, MOD_NONE, GI_BULLET_BAG_50),
GET_ITEM_NONE,
GET_ITEM_NONE,
GET_ITEM_NONE // GI_MAX - if you need to add to this table insert it before this entry.
};
ItemTableManager::Instance->AddItemTable(MOD_NONE);
for (uint8_t i = 0; i < ARRAY_COUNT(getItemTable); i++) {
@ -1613,7 +1614,7 @@ extern "C" CustomMessageEntry Randomizer_GetHintFromCheck(RandomizerCheck check)
}
extern "C" GetItemEntry ItemTable_Retrieve(int16_t getItemID) {
GetItemEntry giEntry = ItemTableManager::Instance->RetrieveItemEntry(OTRGlobals::Instance->getItemModIndex, getItemID);
GetItemEntry giEntry = ItemTableManager::Instance->RetrieveItemEntry(MOD_NONE, getItemID);
return giEntry;
}

View File

@ -21,7 +21,6 @@ public:
std::shared_ptr<Ship::Window> context;
std::shared_ptr<SaveStateMgr> gSaveStateMgr;
std::shared_ptr<Randomizer> gRandomizer;
uint16_t getItemModIndex;
OTRGlobals();
~OTRGlobals();

View File

@ -60,7 +60,6 @@ void OTRGameplay_InitScene(GlobalContext* globalCtx, s32 spawn) {
globalCtx->cUpElfMsgs = nullptr;
globalCtx->setupPathList = nullptr;
globalCtx->numSetupActors = 0;
OTRGlobals::Instance->getItemModIndex = MOD_NONE;
Object_InitBank(globalCtx, &globalCtx->objectCtx);
LightContext_Init(globalCtx, &globalCtx->lightCtx);
TransitionActor_InitContext(&globalCtx->state, &globalCtx->transiActorCtx);

View File

@ -515,13 +515,13 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) {
}
if (!Actor_HasParent(&this->actor, globalCtx)) {
if (!gSaveContext.n64ddFlag) {
if (getItemId != GI_NONE) {
if (getItemId != GI_NONE) {
if (!gSaveContext.n64ddFlag) {
func_8002F554(&this->actor, globalCtx, getItemId);
} else {
getItem = Randomizer_GetRandomizedItem(getItemId, this->actor.id, this->ogParams, globalCtx->sceneNum);
GiveItemEntryFromActorWithFixedRange(&this->actor, globalCtx, getItem);
}
} else {
getItem = Randomizer_GetRandomizedItem(getItemId, this->actor.id, this->ogParams, globalCtx->sceneNum);
GiveItemEntryFromActorWithFixedRange(&this->actor, globalCtx, getItem);
}
}