[Threading] Make the game run single-threaded
This commit is contained in:
parent
ef263d35c1
commit
68548ad45a
@ -55,6 +55,7 @@ namespace Components
|
|||||||
Loader::Register(new FastFiles());
|
Loader::Register(new FastFiles());
|
||||||
Loader::Register(new Gametypes());
|
Loader::Register(new Gametypes());
|
||||||
Loader::Register(new Materials());
|
Loader::Register(new Materials());
|
||||||
|
Loader::Register(new Threading());
|
||||||
#ifndef DISABLE_BITMESSAGE
|
#ifndef DISABLE_BITMESSAGE
|
||||||
Loader::Register(new BitMessage());
|
Loader::Register(new BitMessage());
|
||||||
#endif
|
#endif
|
||||||
|
@ -70,6 +70,7 @@ namespace Components
|
|||||||
#include "Modules\Gametypes.hpp"
|
#include "Modules\Gametypes.hpp"
|
||||||
#include "Modules\Materials.hpp"
|
#include "Modules\Materials.hpp"
|
||||||
#include "Modules\Singleton.hpp"
|
#include "Modules\Singleton.hpp"
|
||||||
|
#include "Modules\Threading.hpp"
|
||||||
#include "Modules\BitMessage.hpp"
|
#include "Modules\BitMessage.hpp"
|
||||||
#include "Modules\FileSystem.hpp"
|
#include "Modules\FileSystem.hpp"
|
||||||
#include "Modules\ModelSurfs.hpp"
|
#include "Modules\ModelSurfs.hpp"
|
||||||
|
47
src/Components/Modules/Threading.cpp
Normal file
47
src/Components/Modules/Threading.cpp
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#include "STDInclude.hpp"
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
__declspec(naked) void Threading::FrameEpilogueStub()
|
||||||
|
{
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
pop edi
|
||||||
|
pop esi
|
||||||
|
pop ebx
|
||||||
|
mov esp, ebp
|
||||||
|
pop ebp
|
||||||
|
retn
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(naked) void Threading::PacketEventStub()
|
||||||
|
{
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
mov eax, 49F0B0h
|
||||||
|
call eax
|
||||||
|
mov eax, 458160h
|
||||||
|
jmp eax
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Threading::Threading()
|
||||||
|
{
|
||||||
|
// remove starting of server thread from Com_Init_Try_Block_Function
|
||||||
|
Utils::Hook::Nop(0x60BEC0, 5);
|
||||||
|
|
||||||
|
// make server thread function jump to per-frame stuff
|
||||||
|
Utils::Hook(0x627049, 0x6271CE, HOOK_JUMP).install()->quick();
|
||||||
|
|
||||||
|
// make SV_WaitServer insta-return
|
||||||
|
Utils::Hook::Set<BYTE>(0x4256F0, 0xC3);
|
||||||
|
|
||||||
|
// dvar setting function, unknown stuff related to server thread sync
|
||||||
|
Utils::Hook::Set<BYTE>(0x647781, 0xEB);
|
||||||
|
|
||||||
|
Utils::Hook(0x627695, 0x627040, HOOK_CALL).install()->quick();
|
||||||
|
Utils::Hook(0x43D1C7, Threading::PacketEventStub, HOOK_JUMP).install()->quick();
|
||||||
|
Utils::Hook(0x6272E3, Threading::FrameEpilogueStub, HOOK_JUMP).install()->quick();
|
||||||
|
}
|
||||||
|
}
|
16
src/Components/Modules/Threading.hpp
Normal file
16
src/Components/Modules/Threading.hpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
class Threading : public Component
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Threading();
|
||||||
|
|
||||||
|
#if defined(DEBUG) || defined(FORCE_UNIT_TESTS)
|
||||||
|
const char* getName() { return "Threading"; };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void FrameEpilogueStub();
|
||||||
|
static void PacketEventStub();
|
||||||
|
};
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user