From 7dffd63c391dfa725470ced81387181a2ec30fef Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Thu, 14 Sep 2023 21:31:05 -0500 Subject: [PATCH] Initial pass on some logging that would be helpful for debugging crashes/problems (#1457) --- soh/soh/SaveManager.cpp | 2 ++ soh/soh/z_play_otr.cpp | 1 + soh/soh/z_scene_otr.cpp | 2 ++ soh/src/code/z_actor.c | 4 ++++ soh/src/code/z_message_PAL.c | 1 + soh/src/code/z_parameter.c | 1 + 6 files changed, 11 insertions(+) diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index d6d7b9bc0..c7665115f 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -708,6 +708,7 @@ void SaveManager::InitFileDebug() { // Threaded SaveFile takes copy of gSaveContext for local unmodified storage void SaveManager::SaveFileThreaded(int fileNum, SaveContext* saveContext, int sectionID) { + SPDLOG_INFO("Save File - fileNum: {}", fileNum); // Needed for first time save, hasn't changed in forever anyway saveBlock["version"] = 1; if (sectionID == SECTION_ID_BASE) { @@ -800,6 +801,7 @@ void SaveManager::SaveGlobal() { } void SaveManager::LoadFile(int fileNum) { + SPDLOG_INFO("Load File - fileNum: {}", fileNum); assert(std::filesystem::exists(GetFileName(fileNum))); InitFile(false); diff --git a/soh/soh/z_play_otr.cpp b/soh/soh/z_play_otr.cpp index 81d4769c1..1f5e21c94 100644 --- a/soh/soh/z_play_otr.cpp +++ b/soh/soh/z_play_otr.cpp @@ -87,6 +87,7 @@ void OTRPlay_InitScene(PlayState* play, s32 spawn) { auto data2 = ResourceMgr_LoadVtxByCRC(0x68d4ea06044e228f);*/ GameInteractor::Instance->ExecuteHooks(play->sceneNum); + SPDLOG_INFO("Scene Init - sceneNum: {0:#x}, entranceIndex: {1:#x}", play->sceneNum, gSaveContext.entranceIndex); volatile int a = 0; } diff --git a/soh/soh/z_scene_otr.cpp b/soh/soh/z_scene_otr.cpp index 381cca4d2..ef98a4b3a 100644 --- a/soh/soh/z_scene_otr.cpp +++ b/soh/soh/z_scene_otr.cpp @@ -541,6 +541,8 @@ extern "C" s32 OTRfunc_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomN roomCtx->unk_30 ^= 1; + SPDLOG_INFO("Room Init - curRoom.num: {0:#x}", roomCtx->curRoom.num); + return 1; } diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c index 953886f12..a8f258c1b 100644 --- a/soh/src/code/z_actor.c +++ b/soh/src/code/z_actor.c @@ -662,6 +662,7 @@ s32 Flags_GetSwitch(PlayState* play, s32 flag) { * Sets current scene switch flag. */ void Flags_SetSwitch(PlayState* play, s32 flag) { + lusprintf(__FILE__, __LINE__, 2, "Switch Flag Set - %#x", flag); if (flag < 0x20) { play->actorCtx.flags.swch |= (1 << flag); } else { @@ -673,6 +674,7 @@ void Flags_SetSwitch(PlayState* play, s32 flag) { * Unsets current scene switch flag. */ void Flags_UnsetSwitch(PlayState* play, s32 flag) { + lusprintf(__FILE__, __LINE__, 2, "Switch Flag Unset - %#x", flag); if (flag < 0x20) { play->actorCtx.flags.swch &= ~(1 << flag); } else { @@ -724,6 +726,7 @@ s32 Flags_GetTreasure(PlayState* play, s32 flag) { * Sets current scene chest flag. */ void Flags_SetTreasure(PlayState* play, s32 flag) { + lusprintf(__FILE__, __LINE__, 2, "Treasure Flag Set - %#x", flag); play->actorCtx.flags.chest |= (1 << flag); } @@ -784,6 +787,7 @@ s32 Flags_GetCollectible(PlayState* play, s32 flag) { * Sets current scene collectible flag. */ void Flags_SetCollectible(PlayState* play, s32 flag) { + lusprintf(__FILE__, __LINE__, 2, "Collectible Flag Set - %#x", flag); if (flag != 0) { if (flag < 0x20) { play->actorCtx.flags.collect |= (1 << flag); diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index c595f4516..91f9003a2 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -1576,6 +1576,7 @@ void Message_Decode(PlayState* play) { extern const char* msgStaticTbl[]; void Message_OpenText(PlayState* play, u16 textId) { + lusprintf(__FILE__, __LINE__, 2, "Display Text - textId: %#x", textId); static s16 messageStaticIndices[] = { 0, 1, 3, 2 }; MessageContext* msgCtx = &play->msgCtx; Font* font = &msgCtx->font; diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index 571cbb947..5e7ef5e8e 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -1759,6 +1759,7 @@ u8 Return_Item(u8 itemID, ModIndex modId, ItemID returnItem) { * @return u8 */ u8 Item_Give(PlayState* play, u8 item) { + lusprintf(__FILE__, __LINE__, 2, "Item Give - item: %#x", item); static s16 sAmmoRefillCounts[] = { 5, 10, 20, 30, 5, 10, 30, 0, 5, 20, 1, 5, 20, 50, 200, 10 }; s16 i; s16 slot;