t7x/src/client/component/client_patches.cpp

57 lines
1.1 KiB
C++
Raw Normal View History

2023-02-13 12:47:22 -05:00
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "scheduler.hpp"
2023-02-16 13:38:13 -05:00
#include <game/game.hpp>
#include <utils/hook.hpp>
#include <mmeapi.h>
2023-02-13 12:47:22 -05:00
namespace client_patches
{
namespace
{
void reduce_process_affinity()
{
2023-02-17 02:36:58 -05:00
const DWORD_PTR affinity = (1ULL << (std::min(std::thread::hardware_concurrency(), 4U))) - 1;
2023-02-13 12:47:22 -05:00
SetProcessAffinityMask(GetCurrentProcess(), affinity);
}
void reset_process_affinity()
{
DWORD_PTR affinity_proc, affinity_sys;
GetProcessAffinityMask(GetCurrentProcess(), &affinity_proc, &affinity_sys);
SetProcessAffinityMask(GetCurrentProcess(), affinity_sys);
}
void fix_amd_cpu_stuttering()
{
scheduler::once([]
{
reduce_process_affinity();
scheduler::once(reset_process_affinity, scheduler::pipeline::main, 1s);
}, scheduler::pipeline::main);
}
MMRESULT mixer_open_stub()
{
return MMSYSERR_NODRIVER;
}
2023-02-13 12:47:22 -05:00
}
class component final : public client_component
{
public:
void post_unpack() override
{
fix_amd_cpu_stuttering();
// Kill microphones for now
2023-02-16 13:38:13 -05:00
utils::hook::set(0x15AAEB254_g, mixer_open_stub);
2023-02-13 12:47:22 -05:00
}
};
}
REGISTER_COMPONENT(client_patches::component)