Fixes some miscellaneous issues for Switch builds.

This commit is contained in:
Christopher Leggett 2023-12-12 18:51:26 -05:00
parent c7c29034eb
commit 674645ef14
No known key found for this signature in database
GPG Key ID: 22E7784811D1BD98
5 changed files with 27 additions and 8 deletions

View File

@ -127,6 +127,20 @@ ItemLocation* Context::GetItemLocation(size_t locKey) {
return &itemLocationTable[static_cast<RandomizerCheck>(locKey)];
}
ItemOverride& Context::GetItemOverride(RandomizerCheck locKey) {
if (!overrides.contains(locKey)) {
overrides.emplace(locKey, ItemOverride());
}
return overrides.at(locKey);
}
ItemOverride& Context::GetItemOverride(size_t locKey) {
if (!overrides.contains(static_cast<RandomizerCheck>(locKey))) {
overrides.emplace(static_cast<RandomizerCheck>(locKey), ItemOverride());
}
return overrides.at(static_cast<RandomizerCheck>(locKey));
}
void Context::PlaceItemInLocation(const RandomizerCheck locKey, const RandomizerGet item, const bool applyEffectImmediately,
const bool setHidden) {
const auto loc = GetItemLocation(locKey);

View File

@ -37,6 +37,8 @@ class Context {
RandomizerArea hintedArea = RA_NONE);
ItemLocation* GetItemLocation(RandomizerCheck locKey);
ItemLocation* GetItemLocation(size_t locKey);
ItemOverride& GetItemOverride(RandomizerCheck locKey);
ItemOverride& GetItemOverride(size_t locKey);
void PlaceItemInLocation(RandomizerCheck locKey, RandomizerGet item, bool applyEffectImmediately = false,
bool setHidden = false);
std::vector<RandomizerCheck> allLocations;

View File

@ -2355,6 +2355,9 @@ extern "C" GetItemEntry ItemTable_Retrieve(int16_t getItemID) {
}
extern "C" GetItemEntry ItemTable_RetrieveEntry(s16 tableID, s16 getItemID) {
if (tableID == MOD_RANDOMIZER) {
return Rando::StaticData::RetrieveItem(static_cast<RandomizerGet>(getItemID)).GetGIEntry_Copy();
}
return ItemTableManager::Instance->RetrieveItemEntry(tableID, getItemID);
}

View File

@ -331,13 +331,12 @@ void SaveManager::LoadRandomizerVersion3() {
RandomizerGet rg = RG_NONE;
SaveManager::Instance->LoadData("fakeRgID", rg, RG_NONE);
if (rg != RG_NONE) {
randoContext->overrides[static_cast<RandomizerCheck>(i)] =
Rando::ItemOverride(static_cast<RandomizerCheck>(i), rg);
randoContext->overrides.emplace(static_cast<RandomizerCheck>(i), Rando::ItemOverride(static_cast<RandomizerCheck>(i), rg));
SaveManager::Instance->LoadStruct("trickName", [&]() {
SaveManager::Instance->LoadData(
"english", randoContext->overrides[static_cast<RandomizerCheck>(i)].GetTrickName().english);
"english", randoContext->GetItemOverride(i).GetTrickName().english);
SaveManager::Instance->LoadData(
"french", randoContext->overrides[static_cast<RandomizerCheck>(i)].GetTrickName().french);
"french", randoContext->GetItemOverride(i).GetTrickName().french);
});
}
uint16_t price = 0;
@ -437,10 +436,10 @@ void SaveManager::SaveRandomizer(SaveContext* saveContext, int sectionID, bool f
SaveManager::Instance->SaveStruct("", [&]() {
SaveManager::Instance->SaveData("rgID", randoContext->GetItemLocation(i)->GetPlacedRandomizerGet());
if (randoContext->GetItemLocation(i)->GetPlacedRandomizerGet() == RG_ICE_TRAP) {
SaveManager::Instance->SaveData("fakeRgID", randoContext->overrides[static_cast<RandomizerCheck>(i)].LooksLike());
SaveManager::Instance->SaveData("fakeRgID", randoContext->GetItemOverride(i).LooksLike());
SaveManager::Instance->SaveStruct("trickName", [&]() {
SaveManager::Instance->SaveData("english", randoContext->overrides[static_cast<RandomizerCheck>(i)].GetTrickName().GetEnglish());
SaveManager::Instance->SaveData("french", randoContext->overrides[static_cast<RandomizerCheck>(i)].GetTrickName().GetFrench());
SaveManager::Instance->SaveData("english", randoContext->GetItemOverride(i).GetTrickName().GetEnglish());
SaveManager::Instance->SaveData("french", randoContext->GetItemOverride(i).GetTrickName().GetFrench());
// TODO: German (trick names don't have german translations yet)
});
}

View File

@ -1336,7 +1336,8 @@ void FileChoose_GenerateRandoSeed(GameState* thisx) {
memcpy(Save_GetSaveMetaInfo(this->buttonIndex)->playerName,
CVarGetInteger("gLinkDefaultName", 0) ? &linkName : &emptyName, 8);
return;
} else {
}
if (!generating) {
Randomizer_GenerateSeed();
}
}