mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-28 05:11:37 +00:00
Fix achievement sound not playing in cutscenes.
This commit is contained in:
parent
99d6cebf92
commit
eb639e3fc5
3 changed files with 15 additions and 8 deletions
|
|
@ -5,6 +5,7 @@
|
||||||
#include <kernel/heap.h>
|
#include <kernel/heap.h>
|
||||||
#include <kernel/memory.h>
|
#include <kernel/memory.h>
|
||||||
#include <ui/game_window.h>
|
#include <ui/game_window.h>
|
||||||
|
#include <patches/inspire_patches.h>
|
||||||
|
|
||||||
void Game_PlaySound(const char* pName)
|
void Game_PlaySound(const char* pName)
|
||||||
{
|
{
|
||||||
|
|
@ -14,8 +15,11 @@ void Game_PlaySound(const char* pName)
|
||||||
}
|
}
|
||||||
else
|
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;
|
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());
|
auto soundPlayerVtable = (be<uint32_t>*)g_memory.Translate(*(be<uint32_t>*)soundPlayer->get());
|
||||||
uint32_t virtualFunction = *(soundPlayerVtable + 1);
|
uint32_t virtualFunction = *(soundPlayerVtable + 1);
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,9 @@
|
||||||
#include <app.h>
|
#include <app.h>
|
||||||
#include <sdl_events.h>
|
#include <sdl_events.h>
|
||||||
|
|
||||||
|
std::string InspirePatches::s_sceneName;
|
||||||
|
|
||||||
static SWA::Inspire::CScene* g_pScene;
|
static SWA::Inspire::CScene* g_pScene;
|
||||||
static std::string g_sceneName;
|
|
||||||
static bool g_isFirstFrameChecked;
|
static bool g_isFirstFrameChecked;
|
||||||
static uint32_t g_eventDispatchCount;
|
static uint32_t g_eventDispatchCount;
|
||||||
|
|
||||||
|
|
@ -49,7 +50,7 @@ PPC_FUNC(sub_82B98D30)
|
||||||
__imp__sub_82B98D30(ctx, base);
|
__imp__sub_82B98D30(ctx, base);
|
||||||
|
|
||||||
g_pScene = nullptr;
|
g_pScene = nullptr;
|
||||||
g_sceneName.clear();
|
InspirePatches::s_sceneName.clear();
|
||||||
|
|
||||||
SDL_User_EvilSonic(App::s_isWerehog);
|
SDL_User_EvilSonic(App::s_isWerehog);
|
||||||
}
|
}
|
||||||
|
|
@ -59,7 +60,7 @@ PPC_FUNC(sub_82B9BA98)
|
||||||
{
|
{
|
||||||
auto sceneName = (Hedgehog::Base::CSharedString*)g_memory.Translate(ctx.r5.u32);
|
auto sceneName = (Hedgehog::Base::CSharedString*)g_memory.Translate(ctx.r5.u32);
|
||||||
|
|
||||||
g_sceneName = sceneName->c_str();
|
InspirePatches::s_sceneName = sceneName->c_str();
|
||||||
|
|
||||||
__imp__sub_82B9BA98(ctx, base);
|
__imp__sub_82B9BA98(ctx, base);
|
||||||
}
|
}
|
||||||
|
|
@ -72,7 +73,7 @@ void InspirePatches::DrawDebug()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Text("Name: %s", g_sceneName.c_str());
|
ImGui::Text("Name: %s", InspirePatches::s_sceneName.c_str());
|
||||||
ImGui::Text("Frame: %f", g_pScene->m_pData->Frame.get());
|
ImGui::Text("Frame: %f", g_pScene->m_pData->Frame.get());
|
||||||
ImGui::Text("Cut: %d", g_pScene->m_pData->Cut.get());
|
ImGui::Text("Cut: %d", g_pScene->m_pData->Cut.get());
|
||||||
|
|
||||||
|
|
@ -97,17 +98,17 @@ void InspirePatches::DrawDebug()
|
||||||
|
|
||||||
void InspirePatches::Update()
|
void InspirePatches::Update()
|
||||||
{
|
{
|
||||||
if (!g_pScene || !g_sceneName.size())
|
if (!g_pScene || !InspirePatches::s_sceneName.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!g_isFirstFrameChecked && std::find(g_alwaysEvilSonic.begin(), g_alwaysEvilSonic.end(), g_sceneName) != g_alwaysEvilSonic.end())
|
if (!g_isFirstFrameChecked && std::find(g_alwaysEvilSonic.begin(), g_alwaysEvilSonic.end(), InspirePatches::s_sceneName) != g_alwaysEvilSonic.end())
|
||||||
{
|
{
|
||||||
SDL_User_EvilSonic(true);
|
SDL_User_EvilSonic(true);
|
||||||
g_isFirstFrameChecked = true;
|
g_isFirstFrameChecked = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto findResult = g_evilSonicTimings.find(g_sceneName);
|
auto findResult = g_evilSonicTimings.find(InspirePatches::s_sceneName);
|
||||||
|
|
||||||
if (findResult != g_evilSonicTimings.end())
|
if (findResult != g_evilSonicTimings.end())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
class InspirePatches
|
class InspirePatches
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static std::string s_sceneName;
|
||||||
|
|
||||||
static void DrawDebug();
|
static void DrawDebug();
|
||||||
static void Update();
|
static void Update();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue