Fix achievement sound not playing in certain conditions. (#373)

* Fix achievement sound not playing in cutscenes.

* Prevent achievement overlay from showing if sounds cannot be played.
This commit is contained in:
Skyth (Asilkan)
2025-02-11 23:50:24 +03:00
committed by GitHub
parent 99d6cebf92
commit dd294a30d4
5 changed files with 73 additions and 30 deletions
+5 -1
View File
@@ -5,6 +5,7 @@
#include <kernel/heap.h>
#include <kernel/memory.h>
#include <ui/game_window.h>
#include <patches/inspire_patches.h>
void Game_PlaySound(const char* pName)
{
@@ -14,8 +15,11 @@ void Game_PlaySound(const char* pName)
}
else
{
// Use EVENT category in cutscenes since SYSTEM gets muted by the game.
uint32_t category = !InspirePatches::s_sceneName.empty() ? 10 : 7;
guest_stack_var<boost::anonymous_shared_ptr> soundPlayer;
GuestToHostFunction<void>(sub_82B4DF50, soundPlayer.get(), ((be<uint32_t>*)g_memory.Translate(0x83367900))->get(), 7, 0, 0);
GuestToHostFunction<void>(sub_82B4DF50, soundPlayer.get(), ((be<uint32_t>*)g_memory.Translate(0x83367900))->get(), category, 0, 0);
auto soundPlayerVtable = (be<uint32_t>*)g_memory.Translate(*(be<uint32_t>*)soundPlayer->get());
uint32_t virtualFunction = *(soundPlayerVtable + 1);