Address review, clean up code
This commit is contained in:
parent
8e4c102984
commit
f8c177085c
@ -2,42 +2,38 @@
|
|||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
/// This component is a workaround for issue https://github.com/XLabsProject/iw4x-client/issues/80
|
// This component is a workaround for issue https://github.com/XLabsProject/iw4x-client/issues/80
|
||||||
/// In case the link goes down, this is a "game hangs randomly" issue:
|
// In case the link goes down, this is a "game hangs randomly" issue:
|
||||||
///
|
//
|
||||||
/// Investigations on the issue pointed out it comes from a situation on Intel processors where
|
// Investigations on the issue pointed out it comes from a situation on Intel processors where
|
||||||
/// WaitForSingleObjectA is ignored by a thread, for some (?) reason.
|
// WaitForSingleObjectA is ignored by a thread, for some (?) reason.
|
||||||
///
|
//
|
||||||
/// This locks up the game randomly, mostly at the end of rounds or when too many things happen at
|
// This locks up the game randomly, mostly at the end of rounds or when too many things happen at
|
||||||
/// once, due to trying to stop sounds (AIL_Stop_sounds) and playing streams at the same time,
|
// once, due to trying to stop sounds (AIL_Stop_sounds) and playing streams at the same time,
|
||||||
/// rushing for the same resource via AIL_lock_mutex.
|
// rushing for the same resource via AIL_lock_mutex.
|
||||||
///
|
//
|
||||||
/// This bug has been reproduced on mp_terminal, mp_overgrown, mp_rust, with and without bots,
|
// This bug has been reproduced on mp_terminal, mp_overgrown, mp_rust, with and without bots,
|
||||||
/// and so far this has been the only way to circumvent it afaik. This component wraps
|
// and so far this has been the only way to circumvent it afaik. This component wraps
|
||||||
/// miles' mutex into another mutex, created below, and for some reason (?) that mutex is
|
// miles' mutex into another mutex, created below, and for some reason (?) that mutex is
|
||||||
/// respected when miles' is not.
|
// respected when miles' is not.
|
||||||
///
|
//
|
||||||
/// As soon as a real fix is found, please discard this fix. In the meantime, it should not
|
// As soon as a real fix is found, please discard this fix. In the meantime, it should not
|
||||||
/// have side effects too bad - worst case it might cause a slight performance drop during
|
// have side effects too bad - worst case it might cause a slight performance drop during
|
||||||
/// team switch and intermission.
|
// team switch and intermission.
|
||||||
///
|
//
|
||||||
|
|
||||||
std::mutex SoundMutexFix::snd_mutex;
|
std::mutex SoundMutexFix::snd_mutex;
|
||||||
|
|
||||||
static void __stdcall LockSoundMutex(int unk)
|
void __stdcall SoundMutexFix::LockSoundMutex(int unk)
|
||||||
{
|
{
|
||||||
std::lock_guard lock(SoundMutexFix::snd_mutex);
|
std::lock_guard lock(SoundMutexFix::snd_mutex);
|
||||||
|
|
||||||
DWORD funcPtr = *reinterpret_cast<DWORD*>(0x6D7554); // AIL_close_stream
|
DWORD funcPtr = *reinterpret_cast<DWORD*>(0x6D7554); // AIL_close_stream
|
||||||
((void(__stdcall*)(int unk))(funcPtr))(unk);
|
Utils::Hook::Call<void __stdcall(int)>(funcPtr)(unk);
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundMutexFix::SoundMutexFix()
|
SoundMutexFix::SoundMutexFix()
|
||||||
{
|
{
|
||||||
Utils::Hook(0x689EFE, &LockSoundMutex, HOOK_JUMP).install()->quick();
|
Utils::Hook(0x689EFE, &SoundMutexFix::LockSoundMutex, HOOK_JUMP).install()->quick();
|
||||||
}
|
|
||||||
|
|
||||||
SoundMutexFix::~SoundMutexFix()
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
@ -6,9 +7,9 @@ namespace Components
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SoundMutexFix();
|
SoundMutexFix();
|
||||||
~SoundMutexFix();
|
|
||||||
|
|
||||||
static void SND_StopStreamChannelHook(int channel);
|
private:
|
||||||
static std::mutex snd_mutex;
|
static std::mutex snd_mutex;
|
||||||
|
static void LockSoundMutex(int unk);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user