Fix rupee overflow in StartingItemGive (#6039)
This commit is contained in:
@@ -14,24 +14,6 @@ uint8_t Randomizer_GetSettingValue(RandomizerSettingKey randoSettingKey);
|
||||
GetItemEntry Randomizer_GetItemFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId);
|
||||
}
|
||||
|
||||
void StartingItemGive(GetItemEntry getItemEntry, RandomizerCheck randomizerCheck) {
|
||||
if (randomizerCheck != RC_MAX) {
|
||||
OTRGlobals::Instance->gRandoContext->GetItemLocation(randomizerCheck)->SetCheckStatus(RCSHOW_SAVED);
|
||||
}
|
||||
if (getItemEntry.modIndex == MOD_NONE) {
|
||||
if (getItemEntry.getItemId == GI_SWORD_BGS) {
|
||||
gSaveContext.bgsFlag = true;
|
||||
}
|
||||
Item_Give(NULL, static_cast<uint8_t>(getItemEntry.itemId));
|
||||
} else if (getItemEntry.modIndex == MOD_RANDOMIZER) {
|
||||
if (getItemEntry.getItemId == RG_ICE_TRAP) {
|
||||
gSaveContext.ship.pendingIceTrapCount++;
|
||||
} else {
|
||||
Randomizer_Item_Give(NULL, getItemEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// RANDOTODO: Replace most of these GiveLink functions with calls to
|
||||
// Item_Give in z_parameter, we'll need to update Item_Give to ensure
|
||||
// nothing breaks when calling it without a valid play first.
|
||||
@@ -55,6 +37,36 @@ void GiveLinkRupees(int numOfRupees) {
|
||||
}
|
||||
}
|
||||
|
||||
static uint16_t rupeeCounts[] = {
|
||||
1, // ITEM_RUPEE_GREEN
|
||||
5, // ITEM_RUPEE_BLUE
|
||||
20, // ITEM_RUPEE_RED
|
||||
50, // ITEM_RUPEE_PURPLE
|
||||
200, // ITEM_RUPEE_GOLD
|
||||
};
|
||||
|
||||
void StartingItemGive(GetItemEntry getItemEntry, RandomizerCheck randomizerCheck) {
|
||||
if (randomizerCheck != RC_MAX) {
|
||||
OTRGlobals::Instance->gRandoContext->GetItemLocation(randomizerCheck)->SetCheckStatus(RCSHOW_SAVED);
|
||||
}
|
||||
if (getItemEntry.modIndex == MOD_NONE) {
|
||||
if (getItemEntry.itemId >= ITEM_RUPEE_GREEN && getItemEntry.itemId <= ITEM_RUPEE_GOLD) {
|
||||
GiveLinkRupees(rupeeCounts[getItemEntry.itemId - ITEM_RUPEE_GREEN]);
|
||||
} else {
|
||||
if (getItemEntry.getItemId == GI_SWORD_BGS) {
|
||||
gSaveContext.bgsFlag = true;
|
||||
}
|
||||
Item_Give(NULL, static_cast<uint8_t>(getItemEntry.itemId));
|
||||
}
|
||||
} else if (getItemEntry.modIndex == MOD_RANDOMIZER) {
|
||||
if (getItemEntry.getItemId == RG_ICE_TRAP) {
|
||||
gSaveContext.ship.pendingIceTrapCount++;
|
||||
} else {
|
||||
Randomizer_Item_Give(NULL, getItemEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GiveLinkDekuSticks(int howManySticks) {
|
||||
int maxStickCount = 0;
|
||||
if (CUR_UPG_VALUE(UPG_STICKS) == 0) {
|
||||
|
||||
Reference in New Issue
Block a user