Skip to content

Commit

Permalink
Fix save file init with new layout
Browse files Browse the repository at this point in the history
  • Loading branch information
lilDavid committed Dec 21, 2023
1 parent f0ed065 commit b9c0ad3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 26 deletions.
39 changes: 22 additions & 17 deletions soh/soh/Enhancements/boss-rush/BossRush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ typedef struct BossRushSetting {
std::vector<std::array<std::string, LANGUAGE_MAX>> choices;
} BossRushSetting;

BossRushSetting BossRushOptions[BOSSRUSH_OPTIONS_AMOUNT] = {
BossRushSetting BossRushOptions[BOSSRUSH_OPTIONS_AMOUNT] = {
{
{ "BOSSES:", "BOSSE:", "BOSS:" },
{
Expand Down Expand Up @@ -309,7 +309,7 @@ void BossRush_InitSave() {

// Set health
uint16_t health = 16;
switch (gSaveContext.bossRushOptions[BR_OPTIONS_HEARTS]) {
switch (gSaveContext.bossRushOptions[BR_OPTIONS_HEARTS]) {
case BR_CHOICE_HEARTS_7:
health *= 7;
break;
Expand Down Expand Up @@ -351,52 +351,57 @@ void BossRush_InitSave() {
}

// Set items
std::array<u8, 24> brItems = {
ITEM_STICK, ITEM_NUT, ITEM_BOMB, ITEM_BOW, ITEM_NONE, ITEM_NONE,
ITEM_SLINGSHOT, ITEM_NONE, ITEM_NONE, ITEM_HOOKSHOT, ITEM_NONE, ITEM_NONE,
ITEM_BOOMERANG, ITEM_LENS, ITEM_NONE, ITEM_HAMMER, ITEM_ARROW_LIGHT, ITEM_NONE,
ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE,
std::array<u8, 28> brItems = {
ITEM_NONE, ITEM_BOMB, ITEM_NONE, ITEM_NUT, ITEM_LENS, ITEM_NONE,
ITEM_NONE, ITEM_SLINGSHOT, ITEM_BOOMERANG, ITEM_STICK, ITEM_NONE, ITEM_NONE,
ITEM_NONE, ITEM_BOW, ITEM_HOOKSHOT, ITEM_HAMMER, ITEM_NONE, ITEM_NONE,
ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE,
ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_ARROW_LIGHT,
};

if (gSaveContext.bossRushOptions[BR_OPTIONS_LONGSHOT] == BR_CHOICE_LONGSHOT_YES) {
brItems[9] = ITEM_LONGSHOT;
brItems[SLOT_HOOKSHOT] = ITEM_LONGSHOT;
}

switch (gSaveContext.bossRushOptions[BR_OPTIONS_BOTTLE]) {
case BR_CHOICE_BOTTLE_EMPTY:
brItems[18] = ITEM_BOTTLE;
brItems[SLOT_BOTTLE_1] = ITEM_BOTTLE;
break;
case BR_CHOICE_BOTTLE_FAIRY:
brItems[18] = ITEM_FAIRY;
brItems[SLOT_BOTTLE_1] = ITEM_FAIRY;
break;
case BR_CHOICE_BOTTLE_REDPOTION:
brItems[18] = ITEM_POTION_RED;
brItems[SLOT_BOTTLE_1] = ITEM_POTION_RED;
break;
case BR_CHOICE_BOTTLE_GREENPOTION:
brItems[18] = ITEM_POTION_GREEN;
brItems[SLOT_BOTTLE_1] = ITEM_POTION_GREEN;
break;
case BR_CHOICE_BOTTLE_BLUEPOTION:
brItems[18] = ITEM_POTION_BLUE;
brItems[SLOT_BOTTLE_1] = ITEM_POTION_BLUE;
break;
default:
break;
}

if (gSaveContext.bossRushOptions[BR_OPTIONS_BUNNYHOOD] == BR_CHOICE_BUNNYHOOD_YES) {
brItems[23] = ITEM_MASK_BUNNY;
brItems[SLOT_TRADE_CHILD] = ITEM_MASK_BUNNY;
}

if (gSaveContext.bossRushOptions[BR_OPTIONS_HOVERBOOTS] == BR_CHOICE_HOVERBOOTS_YES) {
brItems[SLOT_BOOTS_HOVER] = ITEM_BOOTS_HOVER;
}

for (int item = 0; item < ARRAY_COUNT(gSaveContext.inventory.items); item++) {
gSaveContext.inventory.items[item] = brItems[item];
}

// Set consumable counts
std::array<s8, 16> brAmmo = { 5, 5, 10, 10, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
std::array<s8, 16> brAmmo = { 0, 10, 0, 5, 0, 0, 0, 10, 0, 5, 0, 0, 0, 10, 0, 0 };

if (gSaveContext.bossRushOptions[BR_OPTIONS_AMMO] == BR_CHOICE_AMMO_FULL) {
brAmmo = { 10, 20, 20, 30, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
brAmmo = { 0, 20, 0, 20, 0, 0, 0, 30, 0, 10, 0, 0, 0, 30, 0, 0 };
} else if (gSaveContext.bossRushOptions[BR_OPTIONS_AMMO] == BR_CHOICE_AMMO_MAXED) {
brAmmo = { 30, 40, 40, 50, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
brAmmo = { 0, 40, 0, 40, 0, 0, 0, 50, 0, 30, 0, 0, 0, 50, 0, 0 };
}

for (int ammo = 0; ammo < ARRAY_COUNT(gSaveContext.inventory.ammo); ammo++) {
Expand Down
19 changes: 10 additions & 9 deletions soh/soh/SaveManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ void SaveManager::InitFileDebug() {

// Inventory
static std::array<u8, 28> sItems = {
ITEM_DINS_FIRE, ITEM_BOMB, ITEM_BOMBCHU, ITEM_NUT, ITEM_LENS, ITEM_BEAN,
ITEM_DINS_FIRE, ITEM_BOMB, ITEM_BOMBCHU, ITEM_NUT, ITEM_LENS, ITEM_BEAN,
ITEM_FARORES_WIND, ITEM_SLINGSHOT, ITEM_BOOMERANG, ITEM_STICK, ITEM_BOOTS_HOVER, ITEM_WEIRD_EGG,
ITEM_NAYRUS_LOVE, ITEM_BOW, ITEM_HOOKSHOT, ITEM_HAMMER, ITEM_BOOTS_IRON, ITEM_CLAIM_CHECK,
ITEM_NONE, ITEM_BOTTLE, ITEM_POTION_RED, ITEM_POTION_GREEN, ITEM_POTION_BLUE, ITEM_NONE,
Expand Down Expand Up @@ -795,16 +795,17 @@ void SaveManager::InitFileMaxed() {
gSaveContext.equips.equipment = 0x1122;

// Inventory
static std::array<u8, 24> sItems = {
ITEM_STICK, ITEM_NUT, ITEM_BOMB, ITEM_BOW, ITEM_ARROW_FIRE, ITEM_DINS_FIRE,
ITEM_SLINGSHOT, ITEM_OCARINA_TIME, ITEM_BOMBCHU, ITEM_LONGSHOT, ITEM_ARROW_ICE, ITEM_FARORES_WIND,
ITEM_BOOMERANG, ITEM_LENS, ITEM_BEAN, ITEM_HAMMER, ITEM_ARROW_LIGHT, ITEM_NAYRUS_LOVE,
ITEM_FAIRY, ITEM_FAIRY, ITEM_BUG, ITEM_FISH, ITEM_CLAIM_CHECK, ITEM_MASK_BUNNY,
static std::array<u8, 28> sItems = {
ITEM_DINS_FIRE, ITEM_BOMB, ITEM_BOMBCHU, ITEM_NUT, ITEM_LENS, ITEM_BEAN,
ITEM_FARORES_WIND, ITEM_SLINGSHOT, ITEM_BOOMERANG, ITEM_STICK, ITEM_BOOTS_HOVER, ITEM_MASK_BUNNY,
ITEM_NAYRUS_LOVE, ITEM_BOW, ITEM_HOOKSHOT, ITEM_HAMMER, ITEM_BOOTS_IRON, ITEM_CLAIM_CHECK,
ITEM_NONE, ITEM_FAIRY, ITEM_FAIRY, ITEM_BUG, ITEM_FISH, ITEM_NONE,
ITEM_OCARINA_TIME, ITEM_ARROW_FIRE, ITEM_ARROW_ICE, ITEM_ARROW_LIGHT,
};
for (int item = 0; item < ARRAY_COUNT(gSaveContext.inventory.items); item++) {
gSaveContext.inventory.items[item] = sItems[item];
}
static std::array<s8, 16> sAmmo = { 30, 40, 40, 50, 0, 0, 50, 0, 50, 0, 0, 0, 0, 0, 15, 0 };
static std::array<s8, 16> sAmmo = { 0, 40, 50, 40, 0, 10, 0, 50, 0, 30, 0, 0, 0, 50, 0, 0 };
for (int ammo = 0; ammo < ARRAY_COUNT(gSaveContext.inventory.ammo); ammo++) {
gSaveContext.inventory.ammo[ammo] = sAmmo[ammo];
}
Expand Down Expand Up @@ -974,13 +975,13 @@ void SaveManager::SaveFileThreaded(int fileNum, SaveContext* saveContext, int se
if (std::filesystem::exists(fileName)) {
std::filesystem::remove(fileName);
}

#if defined(__SWITCH__) || defined(__WIIU__)
copy_file(tempFile.c_str(), fileName.c_str());
#else
std::filesystem::copy_file(tempFile, fileName);
#endif

if (std::filesystem::exists(tempFile)) {
std::filesystem::remove(tempFile);
}
Expand Down

0 comments on commit b9c0ad3

Please sign in to comment.