Merge branch 'develop-rachael' into develop-zhora

This commit is contained in:
David Chavez 2022-07-22 02:34:55 +02:00
commit b3d3148383
13 changed files with 157 additions and 115 deletions

View File

@ -1355,10 +1355,20 @@ namespace SohImGui {
EnhancementCheckbox("OoT Debug Mode", "gDebugEnabled");
Tooltip("Enables Debug Mode, allowing you to select maps with L + R + Z, noclip with L + D-pad Right,\nand open the debug menu with L on the pause screen");
EnhancementCheckbox("Fast File Select", "gSkipLogoTitle");
Tooltip("Load the game to the selected slot below upon launch\nUse slot number 4 to load directly into the game's internal Map Select\n(Does not require the Debug Menu, but you will be unable to save there\nYou can also load the Map Select with OoT Debug Mode + slot 0)\nWith slot 0 you can directly go to the File Select menu\nAttention: loading an empty save file will result in a crash");
Tooltip("Load the game to the selected menu or file\n\"Zelda Map Select\" require debug mode else you will fallback to File choose menu\nUsing a file number that don't have save will create a save file only\nif you toggle on \"Create a new save if none ?\" else it will bring you to the\nFile choose menu");
if (CVar_GetS32("gSkipLogoTitle", 0)) {
EnhancementSliderInt("Loading %d", "##SaveFileID", "gSaveFileID", 0, 4, "");
}
const char* FastFileSelect[5] = {
"File N.1",
"File N.2",
"File N.3",
"File select",
"Zelda Map Select (require OoT Debug Mode)"
};
ImGui::Text("Loading :");
EnhancementCombobox("gSaveFileID", FastFileSelect, 5, 0);
EnhancementCheckbox("Create a new save if none", "gCreateNewSave");
Tooltip("Enable the creation of a new save file\nif none exist in the File number selected\nNo file name will be assigned please do in Save editor once you see the first text\nelse your save file name will be named \"00000000\"\nIf disabled you will fall back in File select menu");
};
ImGui::Separator();
EnhancementCheckbox("Stats", "gStatsEnabled");
Tooltip("Shows the stats window, with your FPS and frametimes,\nand the OS you're playing on");

View File

@ -42,7 +42,7 @@ static RandomizerHash randomizerHash;
static SpoilerData spoilerData;
void GenerateHash() {
for (size_t i = 0; i < Settings::seed.size(); i++) {
for (size_t i = 0; i < Settings::hashIconIndexes.size(); i++) {
int number = Settings::seed[i] - '0';
Settings::hashIconIndexes[i] = number;
}
@ -371,10 +371,11 @@ static void WriteSettings(const bool printAll = false) {
// }
// }
}
// 3drando doesn't have a "skip child zelda" setting, manually add it to the spoilerfile
jsonData["settings"]["Skip Child Zelda"] = Settings::skipChildZelda;
}
// 3drando doesn't have a "skip child zelda" setting, manually add it to the spoilerfile
jsonData["settings"]["Skip Child Zelda"] = Settings::skipChildZelda;
// spoilerLog.RootElement()->InsertEndChild(parentNode);
// for (const uint32_t key : allLocations) {

View File

@ -869,21 +869,19 @@ SaveStateReturn SaveStateMgr::AddRequest(const SaveStateRequest request) {
switch (request.type) {
case RequestType::SAVE:
requests.push(request);
break;
return SaveStateReturn::SUCCESS;
case RequestType::LOAD:
if (states.contains(request.slot)) {
requests.push(request);
return SaveStateReturn::SUCCESS;
} else {
SPDLOG_ERROR("Invalid SaveState slot: {}", request.type);
SohImGui::overlay->TextDrawNotification(1.0f, true, "state slot %u empty", request.slot);
return SaveStateReturn::FAIL_INVALID_SLOT;
}
break;
[[unlikely]] default:
SPDLOG_ERROR("Invalid SaveState request type: {}", request.type);
return SaveStateReturn::FAIL_BAD_REQUEST;
break;
}
}

View File

@ -517,6 +517,19 @@ void SaveManager::LoadFile(int fileNum) {
InitMeta(fileNum);
}
bool SaveManager::SaveFile_Exist(int fileNum) {
try {
std::filesystem::exists(GetFileName(fileNum));
printf("File[%d] - exist \n",fileNum);
return true;
}
catch(std::filesystem::filesystem_error const& ex) {
printf("File[%d] - do not exist \n",fileNum);
return false;
}
}
void SaveManager::AddInitFunction(InitFunc func) {
initFuncs.emplace_back(func);
}
@ -1332,3 +1345,7 @@ extern "C" void Save_CopyFile(int from, int to) {
extern "C" void Save_DeleteFile(int fileNum) {
SaveManager::Instance->DeleteZeldaFile(fileNum);
}
extern "C" bool Save_Exist(int fileNum) {
return SaveManager::Instance->SaveFile_Exist(fileNum);
}

View File

@ -41,6 +41,7 @@ public:
void SaveFile(int fileNum);
void SaveGlobal();
void LoadFile(int fileNum);
bool SaveFile_Exist(int fileNum);
// Adds a function that is called when we are intializing a save, including when we are loading a save.
void AddInitFunction(InitFunc func);
@ -149,5 +150,5 @@ void Save_AddSaveFunction(char* name, int version, Save_SaveFunc func);
SaveFileMetaInfo* Save_GetSaveMetaInfo(int fileNum);
void Save_CopyFile(int from, int to);
void Save_DeleteFile(int fileNum);
bool Save_Exist(int fileNum);
#endif

View File

@ -1676,13 +1676,15 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) {
if (item == ITEM_SWORD_BGS) {
gSaveContext.swordHealth = 8;
if (ALL_EQUIP_VALUE(EQUIP_SWORD) == 0xF) {
gSaveContext.inventory.equipment ^= 8 << gEquipShifts[EQUIP_SWORD];
if (ALL_EQUIP_VALUE(EQUIP_SWORD) == 0xF
||(gSaveContext.n64ddFlag && ALL_EQUIP_VALUE(EQUIP_SWORD) == 0xE)) { // In rando, when buying Giant's Knife, also check
gSaveContext.inventory.equipment ^= 8 << gEquipShifts[EQUIP_SWORD]; // for 0xE in case we don't have Kokiri Sword
if (gSaveContext.equips.buttonItems[0] == ITEM_SWORD_KNIFE) {
gSaveContext.equips.buttonItems[0] = ITEM_SWORD_BGS;
Interface_LoadItemIcon1(globalCtx, 0);
}
}
} else if (item == ITEM_SWORD_MASTER) {
gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER;
gSaveContext.equips.equipment &= 0xFFF0;

View File

@ -402,6 +402,12 @@ BgImage* func_80096A74(PolygonType1* polygon1, GlobalContext* globalCtx) {
camera = GET_ACTIVE_CAM(globalCtx);
camId = camera->camDataIdx;
if (camId == -1 && CVar_GetS32("gNoRestrictItems", 0)) {
// This prevents a crash when using items that change the
// camera (such as din's fire) on scenes with prerendered backgrounds
return NULL;
}
// jfifid
camId2 = func_80041C10(&globalCtx->colCtx, camId, BGCHECK_SCENE)[2].y;
if (camId2 >= 0) {

View File

@ -34,6 +34,7 @@ void BgHakaGate_Init(Actor* thisx, GlobalContext* globalCtx);
void BgHakaGate_Destroy(Actor* thisx, GlobalContext* globalCtx);
void BgHakaGate_Update(Actor* thisx, GlobalContext* globalCtx);
void BgHakaGate_Draw(Actor* this, GlobalContext* globalCtx);
void BgHakaGate_Reset(void);
void BgHakaGate_DoNothing(BgHakaGate* this, GlobalContext* globalCtx);
void BgHakaGate_StatueInactive(BgHakaGate* this, GlobalContext* globalCtx);
@ -62,7 +63,7 @@ const ActorInit Bg_Haka_Gate_InitVars = {
(ActorFunc)BgHakaGate_Destroy,
(ActorFunc)BgHakaGate_Update,
(ActorFunc)BgHakaGate_Draw,
NULL,
(ActorResetFunc)BgHakaGate_Reset,
};
static InitChainEntry sInitChain[] = {
@ -378,3 +379,7 @@ void BgHakaGate_Draw(Actor* thisx, GlobalContext* globalCtx) {
BgHakaGate_DrawFlame(this, globalCtx);
}
}
void BgHakaGate_Reset(void) {
sStatueRotY = 0;
}

View File

@ -228,8 +228,8 @@ void func_8087FFC0(BgHakaTrap* this, GlobalContext* globalCtx) {
this->colliderCylinder.dim.pos.z = this->dyna.actor.world.pos.z + sp28.x * sine + sp28.z * cosine;
}
static UNK_TYPE D_80881018 = 0;
void func_808801B8(BgHakaTrap* this, GlobalContext* globalCtx) {
static UNK_TYPE D_80881018 = 0;
Player* player = GET_PLAYER(globalCtx);
if ((D_80880F30 == 0) && (!Player_InCsMode(globalCtx))) {
@ -553,4 +553,5 @@ void BgHakaTrap_Draw(Actor* thisx, GlobalContext* globalCtx) {
void BgHakaTrap_Reset(void) {
D_80880F30 = 0;
D_80881014 = 0;
D_80881018 = 0;
}

View File

@ -929,7 +929,7 @@ void BossMo_Tentacle(BossMo* this, GlobalContext* globalCtx) {
this->actor.flags &= ~ACTOR_FLAG_0;
Math_ApproachF(&this->baseAlpha, 0.0, 1.0f, 5.0f);
for (indS1 = 0; indS1 < 40; indS1++) {
if (sMorphaTent2->tentSpawnPos) {}
if (sMorphaTent2 && sMorphaTent2->tentSpawnPos) {}
indT5 = Rand_ZeroFloat(20.9f);
indS0 = sTentSpawnIndex[indT5];
spFC.x = 0;
@ -3604,4 +3604,4 @@ void BossMo_Reset(void) {
sBossGanonSeed1 = 0;
sBossGanonSeed2 = 0;
sBossGanonSeed3 = 0;
}
}

View File

@ -290,7 +290,8 @@ void EnMa1_Init(Actor* thisx, GlobalContext* globalCtx) {
this->actor.targetMode = 6;
this->unk_1E8.unk_00 = 0;
if (!(gSaveContext.eventChkInf[1] & 0x10) || (CHECK_QUEST_ITEM(QUEST_SONG_EPONA) && !gSaveContext.n64ddFlag)) {
if (!(gSaveContext.eventChkInf[1] & 0x10) || (CHECK_QUEST_ITEM(QUEST_SONG_EPONA) && !gSaveContext.n64ddFlag) ||
(gSaveContext.n64ddFlag && Flags_GetTreasure(globalCtx, 0x1F))) {
this->actionFunc = func_80AA0D88;
EnMa1_ChangeAnim(this, ENMA1_ANIM_2);
} else {

View File

@ -11,9 +11,9 @@
#include "textures/nintendo_rogo_static/nintendo_rogo_static.h"
#include <soh/Enhancements/bootcommands.h>
#include "GameVersions.h"
#include <soh/SaveManager.h>
const char* GetGameVersionString();
char* quote;
void Title_PrintBuildInfo(Gfx** gfxp) {
@ -224,72 +224,6 @@ void Title_Draw(TitleContext* this) {
void Title_Main(GameState* thisx) {
TitleContext* this = (TitleContext*)thisx;
if (CVar_GetS32("gSkipLogoTitle",0)!=0) {
gSaveContext.language = CVar_GetS32("gLanguages", 0);
Sram_InitSram(&this->state);
s16 selectedfile = CVar_GetS32("gSaveFileID", 0);
if (selectedfile == 4) {
selectedfile = 0xFF;
} else if(selectedfile == 0){
gSaveContext.fileNum = selectedfile;
gSaveContext.gameMode = 0;
this->state.running = false;
SET_NEXT_GAMESTATE(&this->state, FileChoose_Init, SelectContext);
return;
} else {
selectedfile--;
if (selectedfile < 0) {
selectedfile = 0xFF;
}
}
if (selectedfile == 0xFF) {
gSaveContext.fileNum = selectedfile;
Sram_OpenSave();
gSaveContext.gameMode = 0;
this->state.running = false;
SET_NEXT_GAMESTATE(&this->state, Select_Init, SelectContext);
} else {
gSaveContext.fileNum = selectedfile;
Sram_OpenSave();
gSaveContext.gameMode = 0;
this->state.running = false;
//return;
SET_NEXT_GAMESTATE(&this->state, Gameplay_Init, GlobalContext);
}
gSaveContext.respawn[0].entranceIndex = -1;
gSaveContext.respawnFlag = 0;
gSaveContext.seqId = (u8)NA_BGM_DISABLED;
gSaveContext.natureAmbienceId = 0xFF;
gSaveContext.showTitleCard = true;
gSaveContext.dogParams = 0;
gSaveContext.timer1State = 0;
gSaveContext.timer2State = 0;
gSaveContext.eventInf[0] = 0;
gSaveContext.eventInf[1] = 0;
gSaveContext.eventInf[2] = 0;
gSaveContext.eventInf[3] = 0;
gSaveContext.unk_13EE = 0x32;
gSaveContext.nayrusLoveTimer = 0;
gSaveContext.healthAccumulator = 0;
gSaveContext.unk_13F0 = 0;
gSaveContext.unk_13F2 = 0;
gSaveContext.forcedSeqId = NA_BGM_GENERAL_SFX;
gSaveContext.skyboxTime = 0;
gSaveContext.nextTransition = 0xFF;
gSaveContext.nextCutsceneIndex = 0xFFEF;
gSaveContext.cutsceneTrigger = 0;
gSaveContext.chamberCutsceneNum = 0;
gSaveContext.nextDayTime = 0xFFFF;
gSaveContext.unk_13C3 = 0;
gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = gSaveContext.buttonStatus[3] = gSaveContext.buttonStatus[4] = BTN_ENABLED;
gSaveContext.unk_13E7 = gSaveContext.unk_13E8 = gSaveContext.unk_13EA = gSaveContext.unk_13EC = gSaveContext.unk_13F4 = 0;
gSaveContext.unk_13F6 = gSaveContext.magic;
gSaveContext.magic = 0;
gSaveContext.magicLevel = gSaveContext.magic;
gSaveContext.naviTimer = 0;
return;
}
OPEN_DISPS(this->state.gfxCtx);
gSPSegment(POLY_OPA_DISP++, 0, NULL);
@ -330,27 +264,94 @@ void Title_Destroy(GameState* thisx) {
void Title_Init(GameState* thisx) {
//u32 size = 0;
TitleContext* this = (TitleContext*)thisx;
FileChooseContext* FileChooseCtx = (FileChooseContext*)thisx;
quote = SetQuote();
if (CVar_GetS32("gSkipLogoTitle",0)) {
bool saveloading = false;
Sram_InitSram(&this->state.init);
gSaveContext.language = CVar_GetS32("gLanguages", 0);
s32 selectedfile = CVar_GetS32("gSaveFileID", 0);
if (selectedfile == 4) {
if (CVar_GetS32("gDebugEnabled",0)) {
selectedfile = 0xFF;
} else {
selectedfile = 3;
}
}
if (selectedfile < 0) {
selectedfile = 3; //If somehow the save file number under 0 revert back to 3 to prevent boot error
}
if(selectedfile == 3){
saveloading = true;
gSaveContext.seqId = (u8)NA_BGM_DISABLED;
gSaveContext.natureAmbienceId = 0xFF;
gSaveContext.gameMode = 1;
SET_NEXT_GAMESTATE(&this->state, FileChoose_Init, FileChooseContext);
this->state.running = false;
return;
} else if (selectedfile == 0xFF || selectedfile > 3) {
saveloading = true;
Sram_InitDebugSave();
gSaveContext.fileNum = selectedfile;
SET_NEXT_GAMESTATE(&this->state, Select_Init, SelectContext);
this->state.running = false;
return;
} else if (selectedfile >= 0 && selectedfile <= 2) {
if (Save_Exist(selectedfile) == true) { //The file exist load it
saveloading = true;
gSaveContext.fileNum = selectedfile;
Sram_OpenSave();
gSaveContext.gameMode = 0;
gSaveContext.magic = gSaveContext.magic;
SET_NEXT_GAMESTATE(&this->state, Gameplay_Init, GlobalContext);
this->state.running = false;
return;
} else {
if (CVar_GetS32("gCreateNewSave",0)) {
//File do not exist create a new save file
saveloading = true;
Sram_InitSram(&FileChooseCtx->state.init);
gSaveContext.fileNum = selectedfile;
Sram_InitSave(FileChooseCtx);
Sram_OpenSave();
gSaveContext.gameMode = 0;
SET_NEXT_GAMESTATE(&this->state, Gameplay_Init, GlobalContext);
this->state.running = false;
return;
} else {
//File do not exist but user do not wish to auto create a save file with blank name
saveloading = true;
gSaveContext.seqId = (u8)NA_BGM_DISABLED;
gSaveContext.natureAmbienceId = 0xFF;
gSaveContext.gameMode = 1;
SET_NEXT_GAMESTATE(&this->state, FileChoose_Init, FileChooseContext);
this->state.running = false;
return;
}
}
}
} else {
quote = SetQuote();
//this->staticSegment = GAMESTATE_ALLOC_MC(&this->state, size);
osSyncPrintf("z_title.c\n");
//ASSERT(this->staticSegment != NULL);
//this->staticSegment = GAMESTATE_ALLOC_MC(&this->state, size);
osSyncPrintf("z_title.c\n");
//ASSERT(this->staticSegment != NULL);
//ResourceMgr_CacheDirectory("nintendo_rogo_static*");
//ResourceMgr_CacheDirectory("nintendo_rogo_static*");
// Disable vismono
D_801614B0.a = 0;
R_UPDATE_RATE = 1;
Matrix_Init(&this->state);
View_Init(&this->view, this->state.gfxCtx);
this->state.main = Title_Main;
this->state.destroy = Title_Destroy;
this->exit = false;
gSaveContext.fileNum = 0xFF;
this->ult = 0;
this->unk_1D4 = 0x14;
this->coverAlpha = 255;
this->addAlpha = -3;
this->visibleDuration = 0x3C;
// Disable vismono
D_801614B0.a = 0;
R_UPDATE_RATE = 1;
Matrix_Init(&this->state);
View_Init(&this->view, this->state.gfxCtx);
this->state.main = Title_Main;
this->state.destroy = Title_Destroy;
this->exit = false;
gSaveContext.fileNum = 0xFF;
this->ult = 0;
this->unk_1D4 = 0x14;
this->coverAlpha = 255;
this->addAlpha = -3;
this->visibleDuration = 0x3C;
}
}

View File

@ -637,24 +637,23 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) {
gItemIcons[sAdultUpgradeItemBases[i] + CUR_UPG_VALUE(sAdultUpgrades[i]) - 1], 32, 32, 0);
}
}
// Draw inventory screen icons
for (k = 0, bit = rowStart, point = 4; k < 3; k++, point += 4, temp++, bit++) {
int itemId = ITEM_SWORD_KOKIRI + temp;
bool age_restricted = (gItemAgeReqs[itemId] != 9) && (gItemAgeReqs[itemId] != gSaveContext.linkAge);
if (age_restricted) {
gsDPSetGrayscaleColor(POLY_KAL_DISP++, 109, 109, 109, 255);
gsSPGrayscale(POLY_KAL_DISP++, true);
}
if (((u32)i == 0) && (k == 2) && (gSaveContext.bgsFlag != 0)) {
KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gBiggoronSwordIconTex, 32, 32, point);
} else if ((i == 0) && (k == 2) && (gBitFlags[bit + 1] & gSaveContext.inventory.equipment)) {
KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gBrokenGiantsKnifeIconTex, 32, 32, point);
}
if (gBitFlags[bit] & gSaveContext.inventory.equipment) {
int itemId = ITEM_SWORD_KOKIRI + temp;
bool not_acquired = (gItemAgeReqs[itemId] != 9) && (gItemAgeReqs[itemId] != gSaveContext.linkAge);
if (not_acquired) {
gsDPSetGrayscaleColor(POLY_KAL_DISP++, 109, 109, 109, 255);
gsSPGrayscale(POLY_KAL_DISP++, true);
}
} else if (gBitFlags[bit] & gSaveContext.inventory.equipment) {
KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gItemIcons[itemId], 32, 32, point);
gsSPGrayscale(POLY_KAL_DISP++, false);
}
gsSPGrayscale(POLY_KAL_DISP++, false);
}
}