From c242b6beea6f47b03a4eabace632f42fba3bbca7 Mon Sep 17 00:00:00 2001 From: mouzedrift <43358824+mouzedrift@users.noreply.github.com> Date: Sun, 19 Mar 2023 20:49:31 +0100 Subject: [PATCH] a couple fixes - fix bells leaking when abe dies in a screen with bells - add some logging when animation init fails - hack load dove resources (for some reason it can fail during the game ender when you die and pull the lever) - replace comma with semicolon in Elum.cpp (typo go brr) --- Source/AliveLibAO/Animation.cpp | 3 +++ .../BaseAnimatedWithPhysicsGameObject.cpp | 6 +++++ Source/AliveLibAO/ChimeLock.cpp | 27 +++++-------------- Source/AliveLibAO/Dove.cpp | 12 +++++++++ Source/AliveLibAO/Elum.cpp | 4 +-- 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/Source/AliveLibAO/Animation.cpp b/Source/AliveLibAO/Animation.cpp index 45b65757e..6f8cc26d1 100644 --- a/Source/AliveLibAO/Animation.cpp +++ b/Source/AliveLibAO/Animation.cpp @@ -763,6 +763,7 @@ s16 Animation::Init_402D20(s32 frameTableOffset, DynamicArray* /*animList*/, Bas if (!ppAnimData) { + LOG_WARNING("Animation init failed because the resource wasn't loaded!"); return 0; } @@ -870,6 +871,7 @@ s16 Animation::Init_402D20(s32 frameTableOffset, DynamicArray* /*animList*/, Bas const bool bOk = bVramAllocOK && bPalAllocOK; if (!bOk) { + LOG_WARNING("Animation init failed because the vram or pal alloc failed!"); return 0; } @@ -881,6 +883,7 @@ s16 Animation::Init_402D20(s32 frameTableOffset, DynamicArray* /*animList*/, Bas field_24_dbuf = ResourceManager::Alloc_New_Resource_454F20(ResourceManager::Resource_DecompressionBuffer, id, field_28_dbuf_size); if (!field_24_dbuf) { + LOG_WARNING("Animation init failed because it couldn't alloc a new resource!"); return 0; } } diff --git a/Source/AliveLibAO/BaseAnimatedWithPhysicsGameObject.cpp b/Source/AliveLibAO/BaseAnimatedWithPhysicsGameObject.cpp index 1a30f3885..9fb4af5ff 100644 --- a/Source/AliveLibAO/BaseAnimatedWithPhysicsGameObject.cpp +++ b/Source/AliveLibAO/BaseAnimatedWithPhysicsGameObject.cpp @@ -12,6 +12,7 @@ #include "Particle.hpp" #include "Sfx.hpp" #include "Math.hpp" +#include "../AliveLibCommon/BaseGameAutoPlayer.hpp" namespace AO { @@ -92,6 +93,11 @@ void BaseAnimatedWithPhysicsGameObject::Animation_Init_417FD0(s32 frameTableOffs } else { + if (GetGameAutoPlayer().IsPlaying() || GetGameAutoPlayer().IsRecording()) + { + std::string errMsg = "Animation init failed! frame table offset " + std::to_string(frameTableOffset); + ALIVE_FATAL(errMsg.c_str()); + } field_6_flags.Set(Options::eListAddFailed_Bit1); field_6_flags.Set(Options::eDead_Bit3); } diff --git a/Source/AliveLibAO/ChimeLock.cpp b/Source/AliveLibAO/ChimeLock.cpp index 614aecc14..71fcb4b2e 100644 --- a/Source/AliveLibAO/ChimeLock.cpp +++ b/Source/AliveLibAO/ChimeLock.cpp @@ -146,16 +146,22 @@ BaseGameObject* ChimeLock::dtor_40AE60() if (field_114_left_bell) { field_114_left_bell->field_6_flags.Set(Options::eDead_Bit3); + field_114_left_bell->field_C_refCount--; + field_114_left_bell = nullptr; } if (field_118_center_bell) { field_118_center_bell->field_6_flags.Set(Options::eDead_Bit3); + field_118_center_bell->field_C_refCount--; + field_118_center_bell = nullptr; } if (field_11C_right_bell) { field_11C_right_bell->field_6_flags.Set(Options::eDead_Bit3); + field_11C_right_bell->field_C_refCount--; + field_11C_right_bell = nullptr; } gMap_507BA8.TLV_Reset_446870(field_10C_tlvInfo, -1, 0, 0); @@ -182,27 +188,6 @@ void ChimeLock::VScreenChanged() void ChimeLock::VScreenChanged_40BCD0() { - if (field_114_left_bell) - { - field_114_left_bell->field_6_flags.Set(Options::eDead_Bit3); - field_114_left_bell->field_C_refCount--; - field_114_left_bell = nullptr; - } - - if (field_118_center_bell) - { - field_118_center_bell->field_6_flags.Set(Options::eDead_Bit3); - field_118_center_bell->field_C_refCount--; - field_118_center_bell = nullptr; - } - - if (field_11C_right_bell) - { - field_11C_right_bell->field_6_flags.Set(Options::eDead_Bit3); - field_11C_right_bell->field_C_refCount--; - field_11C_right_bell = nullptr; - } - field_6_flags.Set(Options::eDead_Bit3); } diff --git a/Source/AliveLibAO/Dove.cpp b/Source/AliveLibAO/Dove.cpp index fbaa67a60..10a4f1db7 100644 --- a/Source/AliveLibAO/Dove.cpp +++ b/Source/AliveLibAO/Dove.cpp @@ -49,6 +49,12 @@ Dove* Dove::ctor_40EE50(s32 frameTableOffset, s32 maxW, s32 maxH, s32 resourceID SetVTable(this, 0x4BA858); field_4_typeId = Types::eBird_22; u8** ppRes = ResourceManager::GetLoadedResource_4554F0(ResourceManager::Resource_Animation, resourceID, 1, 0); + if (!ppRes) + { + LOG_WARNING("hack loading dove resources"); + ResourceManager::LoadResourceFile_455270("DOVBASIC.BAN", nullptr); + ppRes = ResourceManager::GetLoadedResource_4554F0(ResourceManager::Resource_Animation, resourceID, 1, 0); + } Animation_Init_417FD0( frameTableOffset, maxW, @@ -114,6 +120,12 @@ Dove* Dove::ctor_40EFF0(s32 frameTableOffset, s32 maxW, s32 maxH, s32 resourceID field_4_typeId = Types::eBird_22; u8** ppRes = ResourceManager::GetLoadedResource_4554F0(ResourceManager::Resource_Animation, resourceID, 1, 0); + if (!ppRes) + { + LOG_WARNING("hack loading dove resources"); + ResourceManager::LoadResourceFile_455270("DOVBASIC.BAN", nullptr); + ppRes = ResourceManager::GetLoadedResource_4554F0(ResourceManager::Resource_Animation, resourceID, 1, 0); + } Animation_Init_417FD0( frameTableOffset, maxW, diff --git a/Source/AliveLibAO/Elum.cpp b/Source/AliveLibAO/Elum.cpp index cc21b922c..c6c9793c0 100644 --- a/Source/AliveLibAO/Elum.cpp +++ b/Source/AliveLibAO/Elum.cpp @@ -3720,7 +3720,7 @@ void Elum::VUpdate_4102A0() { if (GetGameAutoPlayer().IsPlaying() || GetGameAutoPlayer().IsRecording()) { - ResourceManager::LoadResourceFile_455270("ELMRIDE.BAN", nullptr), + ResourceManager::LoadResourceFile_455270("ELMRIDE.BAN", nullptr); ResourceManager::LoadResourceFile_455270("ELMPDMNT.BAN", nullptr); VLoadMountedResources_411300(); ppRes = GetResBlock_410D00(field_E4_previous_motion); @@ -3755,7 +3755,7 @@ void Elum::VUpdate_4102A0() { if (GetGameAutoPlayer().IsPlaying() || GetGameAutoPlayer().IsRecording()) { - ResourceManager::LoadResourceFile_455270("ELMRIDE.BAN", nullptr), + ResourceManager::LoadResourceFile_455270("ELMRIDE.BAN", nullptr); ResourceManager::LoadResourceFile_455270("ELMPDMNT.BAN", nullptr); VLoadMountedResources_411300(); ppRes = GetResBlock_410D00(field_FC_current_motion);