Use macros for max key count (#1818)

This commit is contained in:
Garrett Cox 2022-10-20 21:01:54 -05:00 committed by GitHub
parent a920aea8de
commit f4ac37f54a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 24 deletions

View File

@ -263,5 +263,15 @@ extern GraphicsContext* __gfxCtx;
#define NUM_TRIALS 6 #define NUM_TRIALS 6
#define NUM_SHOP_ITEMS 64 #define NUM_SHOP_ITEMS 64
#define NUM_SCRUBS 35 #define NUM_SCRUBS 35
#define FOREST_TEMPLE_SMALL_KEY_MAX (ResourceMgr_IsSceneMasterQuest(SCENE_BMORI1) ? 6 : 5)
#define FIRE_TEMPLE_SMALL_KEY_MAX (ResourceMgr_IsSceneMasterQuest(SCENE_HIDAN) ? 5 : 8)
#define WATER_TEMPLE_SMALL_KEY_MAX (ResourceMgr_IsSceneMasterQuest(SCENE_MIZUSIN) ? 2 : 6)
#define SPIRIT_TEMPLE_SMALL_KEY_MAX (ResourceMgr_IsSceneMasterQuest(SCENE_JYASINZOU) ? 7 : 5)
#define SHADOW_TEMPLE_SMALL_KEY_MAX (ResourceMgr_IsSceneMasterQuest(SCENE_HAKADAN) ? 6 : 5)
#define BOTTOM_OF_THE_WELL_SMALL_KEY_MAX (ResourceMgr_IsSceneMasterQuest(SCENE_HAKADANCH) ? 2 : 3)
#define GERUDO_TRAINING_GROUNDS_SMALL_KEY_MAX (ResourceMgr_IsSceneMasterQuest(SCENE_MEN) ? 3 : 9)
#define GERUDO_FORTRESS_SMALL_KEY_MAX 4
#define GANONS_CASTLE_SMALL_KEY_MAX (ResourceMgr_IsSceneMasterQuest(SCENE_GANONTIKA) ? 3 : 2)
#define TREASURE_GAME_SMALL_KEY_MAX 6
#endif #endif

View File

@ -24,6 +24,7 @@
#include "rando_hash.h" #include "rando_hash.h"
extern "C" uint32_t ResourceMgr_IsGameMasterQuest(); extern "C" uint32_t ResourceMgr_IsGameMasterQuest();
extern "C" uint32_t ResourceMgr_IsSceneMasterQuest(s16 sceneNum);
using json = nlohmann::json; using json = nlohmann::json;
using namespace std::literals::string_literals; using namespace std::literals::string_literals;
@ -1396,27 +1397,26 @@ ItemObtainability Randomizer::GetItemObtainabilityFromRandomizerGet(RandomizerGe
return !CHECK_DUNGEON_ITEM(DUNGEON_KEY_BOSS, SCENE_HAKADAN) ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE; return !CHECK_DUNGEON_ITEM(DUNGEON_KEY_BOSS, SCENE_HAKADAN) ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE;
case RG_GANONS_CASTLE_BOSS_KEY: case RG_GANONS_CASTLE_BOSS_KEY:
return !CHECK_DUNGEON_ITEM(DUNGEON_KEY_BOSS, SCENE_GANON) ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE; return !CHECK_DUNGEON_ITEM(DUNGEON_KEY_BOSS, SCENE_GANON) ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE;
// TODO: Handle MQ key counts
case RG_FOREST_TEMPLE_SMALL_KEY: case RG_FOREST_TEMPLE_SMALL_KEY:
return gSaveContext.inventory.dungeonKeys[SCENE_BMORI1] < 5 ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE; return gSaveContext.inventory.dungeonKeys[SCENE_BMORI1] < FOREST_TEMPLE_SMALL_KEY_MAX ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE;
case RG_FIRE_TEMPLE_SMALL_KEY: case RG_FIRE_TEMPLE_SMALL_KEY:
return gSaveContext.inventory.dungeonKeys[SCENE_HIDAN] < 8 ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE; return gSaveContext.inventory.dungeonKeys[SCENE_HIDAN] < FIRE_TEMPLE_SMALL_KEY_MAX ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE;
case RG_WATER_TEMPLE_SMALL_KEY: case RG_WATER_TEMPLE_SMALL_KEY:
return gSaveContext.inventory.dungeonKeys[SCENE_MIZUSIN] < 6 ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE; return gSaveContext.inventory.dungeonKeys[SCENE_MIZUSIN] < WATER_TEMPLE_SMALL_KEY_MAX ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE;
case RG_SPIRIT_TEMPLE_SMALL_KEY: case RG_SPIRIT_TEMPLE_SMALL_KEY:
return gSaveContext.inventory.dungeonKeys[SCENE_JYASINZOU] < 5 ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE; return gSaveContext.inventory.dungeonKeys[SCENE_JYASINZOU] < SPIRIT_TEMPLE_SMALL_KEY_MAX ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE;
case RG_SHADOW_TEMPLE_SMALL_KEY: case RG_SHADOW_TEMPLE_SMALL_KEY:
return gSaveContext.inventory.dungeonKeys[SCENE_HAKADAN] < 5 ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE; return gSaveContext.inventory.dungeonKeys[SCENE_HAKADAN] < SHADOW_TEMPLE_SMALL_KEY_MAX ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE;
case RG_BOTTOM_OF_THE_WELL_SMALL_KEY: case RG_BOTTOM_OF_THE_WELL_SMALL_KEY:
return gSaveContext.inventory.dungeonKeys[SCENE_HAKADANCH] < 3 ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE; return gSaveContext.inventory.dungeonKeys[SCENE_HAKADANCH] < BOTTOM_OF_THE_WELL_SMALL_KEY_MAX ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE;
case RG_GERUDO_TRAINING_GROUNDS_SMALL_KEY: case RG_GERUDO_TRAINING_GROUNDS_SMALL_KEY:
return gSaveContext.inventory.dungeonKeys[SCENE_MEN] < 9 ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE; return gSaveContext.inventory.dungeonKeys[SCENE_MEN] < GERUDO_TRAINING_GROUNDS_SMALL_KEY_MAX ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE;
case RG_GERUDO_FORTRESS_SMALL_KEY: case RG_GERUDO_FORTRESS_SMALL_KEY:
return gSaveContext.inventory.dungeonKeys[SCENE_GERUDOWAY] < 4 ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE; return gSaveContext.inventory.dungeonKeys[SCENE_GERUDOWAY] < GERUDO_FORTRESS_SMALL_KEY_MAX ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE;
case RG_GANONS_CASTLE_SMALL_KEY: case RG_GANONS_CASTLE_SMALL_KEY:
return gSaveContext.inventory.dungeonKeys[SCENE_GANONTIKA] < 2 ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE; return gSaveContext.inventory.dungeonKeys[SCENE_GANONTIKA] < GANONS_CASTLE_SMALL_KEY_MAX ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE;
case RG_TREASURE_GAME_SMALL_KEY: case RG_TREASURE_GAME_SMALL_KEY:
return gSaveContext.inventory.dungeonKeys[SCENE_TAKARAYA] < 6 ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE; return gSaveContext.inventory.dungeonKeys[SCENE_TAKARAYA] < TREASURE_GAME_SMALL_KEY_MAX ? CAN_OBTAIN : CANT_OBTAIN_ALREADY_HAVE;
// Dungeon Rewards // Dungeon Rewards
case RG_KOKIRI_EMERALD: case RG_KOKIRI_EMERALD:

View File

@ -20,6 +20,7 @@ extern GlobalContext* gGlobalCtx;
#include "textures/icon_item_static/icon_item_static.h" #include "textures/icon_item_static/icon_item_static.h"
#include "textures/icon_item_24_static/icon_item_24_static.h" #include "textures/icon_item_24_static/icon_item_24_static.h"
} }
extern "C" uint32_t ResourceMgr_IsSceneMasterQuest(s16 sceneNum);
void DrawEquip(ItemTrackerItem item); void DrawEquip(ItemTrackerItem item);
void DrawItem(ItemTrackerItem item); void DrawItem(ItemTrackerItem item);
@ -300,31 +301,31 @@ ItemTrackerNumbers GetItemCurrentAndMax(ItemTrackerItem item) {
result.currentAmmo = MAX(gSaveContext.inventory.dungeonKeys[item.data], 0); result.currentAmmo = MAX(gSaveContext.inventory.dungeonKeys[item.data], 0);
switch (item.data) { switch (item.data) {
case SCENE_BMORI1: case SCENE_BMORI1:
result.maxCapacity = result.currentCapacity = 5; result.maxCapacity = result.currentCapacity = FOREST_TEMPLE_SMALL_KEY_MAX;
break; break;
case SCENE_HIDAN: case SCENE_HIDAN:
result.maxCapacity = result.currentCapacity = 8; result.maxCapacity = result.currentCapacity = FIRE_TEMPLE_SMALL_KEY_MAX;
break; break;
case SCENE_MIZUSIN: case SCENE_MIZUSIN:
result.maxCapacity = result.currentCapacity = 6; result.maxCapacity = result.currentCapacity = WATER_TEMPLE_SMALL_KEY_MAX;
break; break;
case SCENE_JYASINZOU: case SCENE_JYASINZOU:
result.maxCapacity = result.currentCapacity = 5; result.maxCapacity = result.currentCapacity = SPIRIT_TEMPLE_SMALL_KEY_MAX;
break; break;
case SCENE_HAKADAN: case SCENE_HAKADAN:
result.maxCapacity = result.currentCapacity = 5; result.maxCapacity = result.currentCapacity = SHADOW_TEMPLE_SMALL_KEY_MAX;
break; break;
case SCENE_HAKADANCH: case SCENE_HAKADANCH:
result.maxCapacity = result.currentCapacity = 3; result.maxCapacity = result.currentCapacity = BOTTOM_OF_THE_WELL_SMALL_KEY_MAX;
break;
case SCENE_GANONTIKA:
result.maxCapacity = result.currentCapacity = 2;
break; break;
case SCENE_MEN: case SCENE_MEN:
result.maxCapacity = result.currentCapacity = 9; result.maxCapacity = result.currentCapacity = GERUDO_TRAINING_GROUNDS_SMALL_KEY_MAX;
break; break;
case SCENE_GERUDOWAY: case SCENE_GERUDOWAY:
result.maxCapacity = result.currentCapacity = 4; result.maxCapacity = result.currentCapacity = GERUDO_FORTRESS_SMALL_KEY_MAX;
break;
case SCENE_GANONTIKA:
result.maxCapacity = result.currentCapacity = GANONS_CASTLE_SMALL_KEY_MAX;
break; break;
} }
break; break;

View File

@ -638,7 +638,7 @@ extern "C" uint32_t ResourceMgr_GetGameVersion()
return OTRGlobals::Instance->context->GetResourceManager()->GetGameVersion(); return OTRGlobals::Instance->context->GetResourceManager()->GetGameVersion();
} }
uint32_t IsGameMasterQuest() { uint32_t IsSceneMasterQuest(s16 sceneNum) {
uint32_t value = 0; uint32_t value = 0;
if (OTRGlobals::Instance->HasMasterQuest()) { if (OTRGlobals::Instance->HasMasterQuest()) {
if (!OTRGlobals::Instance->HasOriginal()) { if (!OTRGlobals::Instance->HasOriginal()) {
@ -649,7 +649,7 @@ uint32_t IsGameMasterQuest() {
value = 0; value = 0;
if (gSaveContext.n64ddFlag) { if (gSaveContext.n64ddFlag) {
if (!OTRGlobals::Instance->gRandomizer->masterQuestDungeons.empty()) { if (!OTRGlobals::Instance->gRandomizer->masterQuestDungeons.empty()) {
if (gGlobalCtx != NULL && OTRGlobals::Instance->gRandomizer->masterQuestDungeons.contains(gGlobalCtx->sceneNum)) { if (gGlobalCtx != NULL && OTRGlobals::Instance->gRandomizer->masterQuestDungeons.contains(sceneNum)) {
value = 1; value = 1;
} }
} }
@ -659,6 +659,10 @@ uint32_t IsGameMasterQuest() {
return value; return value;
} }
uint32_t IsGameMasterQuest() {
return gGlobalCtx != NULL ? IsSceneMasterQuest(gGlobalCtx->sceneNum) : 0;
}
extern "C" uint32_t ResourceMgr_GameHasMasterQuest() { extern "C" uint32_t ResourceMgr_GameHasMasterQuest() {
return OTRGlobals::Instance->HasMasterQuest(); return OTRGlobals::Instance->HasMasterQuest();
} }
@ -667,6 +671,10 @@ extern "C" uint32_t ResourceMgr_GameHasOriginal() {
return OTRGlobals::Instance->HasOriginal(); return OTRGlobals::Instance->HasOriginal();
} }
extern "C" uint32_t ResourceMgr_IsSceneMasterQuest(s16 sceneNum) {
return IsSceneMasterQuest(sceneNum);
}
extern "C" uint32_t ResourceMgr_IsGameMasterQuest() { extern "C" uint32_t ResourceMgr_IsGameMasterQuest() {
return IsGameMasterQuest(); return IsGameMasterQuest();
} }