#include namespace Components { Utils::Signal Events::ClientDisconnectSignal; Utils::Signal Events::ClientConnectSignal; Utils::Signal Events::SteamDisconnectSignal; Utils::Signal Events::ShutdownSystemSignal; Utils::Signal Events::ClientInitSignal; Utils::Signal Events::ServerInitSignal; Utils::Signal Events::DvarInitSignal; void Events::OnClientDisconnect(const Utils::Slot& callback) { ClientDisconnectSignal.connect(callback); } void Events::OnClientConnect(const Utils::Slot& callback) { ClientConnectSignal.connect(callback); } void Events::OnSteamDisconnect(const Utils::Slot& callback) { SteamDisconnectSignal.connect(callback); } void Events::OnVMShutdown(const Utils::Slot& callback) { ShutdownSystemSignal.connect(callback); } void Events::OnClientInit(const Utils::Slot& callback) { ClientInitSignal.connect(callback); } void Events::OnSVInit(const Utils::Slot& callback) { ServerInitSignal.connect(callback); } void Events::OnDvarInit(const Utils::Slot& callback) { DvarInitSignal.connect(callback); } /* * Should be called when a client drops from the server * but not "between levels" (Quake-III-Arena) */ void Events::ClientDisconnect_Hk(const int clientNum) { ClientDisconnectSignal(clientNum); Utils::Hook::Call(0x4AA430)(clientNum); // ClientDisconnect } void Events::SV_UserinfoChanged_Hk(Game::client_t* cl) { ClientConnectSignal(cl); Utils::Hook::Call(0x401950)(cl); // SV_UserinfoChanged } void Events::SteamDisconnect_Hk() { SteamDisconnectSignal(); Utils::Hook::Call(0x467CC0)(); // LiveSteam_Client_SteamDisconnect } void Events::Scr_ShutdownSystem_Hk(unsigned char sys) { ShutdownSystemSignal(); Utils::Hook::Call(0x421EE0)(sys); // Scr_ShutdownSystem } void Events::CL_InitOnceForAllClients_HK() { ClientInitSignal(); ClientInitSignal.clear(); Utils::Hook::Call(0x404CA0)(); // CL_InitOnceForAllClients } void Events::SV_Init_Hk() { ServerInitSignal(); ServerInitSignal.clear(); Utils::Hook::Call(0x474320)(); // SV_InitGameMode } void Events::Com_InitDvars_Hk() { DvarInitSignal(); DvarInitSignal.clear(); Utils::Hook::Call(0x60AD10)(); // Com_InitDvars } Events::Events() { Utils::Hook(0x625235, ClientDisconnect_Hk, HOOK_CALL).install()->quick(); // SV_FreeClient Utils::Hook(0x4612BD, SV_UserinfoChanged_Hk, HOOK_CALL).install()->quick(); // SV_DirectConnect Utils::Hook(0x403582, SteamDisconnect_Hk, HOOK_CALL).install()->quick(); // CL_Disconnect Utils::Hook(0x47548B, Scr_ShutdownSystem_Hk, HOOK_CALL).install()->quick(); // G_LoadGame Utils::Hook(0x4D06BA, Scr_ShutdownSystem_Hk, HOOK_CALL).install()->quick(); // G_ShutdownGame Utils::Hook(0x60BE5B, CL_InitOnceForAllClients_HK, HOOK_CALL).install()->quick(); // Com_Init_Try_Block_Function Utils::Hook(0x60BB3A, Com_InitDvars_Hk, HOOK_CALL).install()->quick(); // Com_Init_Try_Block_Function Utils::Hook(0x4D3665, SV_Init_Hk, HOOK_CALL).install()->quick(); // SV_Init } }