2022-06-13 14:16:57 -04:00
|
|
|
#include <STDInclude.hpp>
|
|
|
|
|
|
|
|
namespace Components
|
|
|
|
{
|
|
|
|
Utils::Signal<Events::ClientCallback> Events::ClientDisconnectSignal;
|
2023-01-25 13:20:44 -05:00
|
|
|
Utils::Signal<Events::ClientConnectCallback> Events::ClientConnectSignal;
|
2022-06-13 14:16:57 -04:00
|
|
|
Utils::Signal<Events::Callback> Events::SteamDisconnectSignal;
|
|
|
|
Utils::Signal<Events::Callback> Events::ShutdownSystemSignal;
|
2022-07-16 17:24:26 -04:00
|
|
|
Utils::Signal<Events::Callback> Events::ClientInitSignal;
|
2022-06-28 14:57:58 -04:00
|
|
|
Utils::Signal<Events::Callback> Events::ServerInitSignal;
|
2022-06-13 14:16:57 -04:00
|
|
|
|
|
|
|
void Events::OnClientDisconnect(const Utils::Slot<ClientCallback>& callback)
|
|
|
|
{
|
|
|
|
ClientDisconnectSignal.connect(callback);
|
|
|
|
}
|
|
|
|
|
2023-01-25 13:20:44 -05:00
|
|
|
void Events::OnClientConnect(const Utils::Slot<ClientConnectCallback>& callback)
|
|
|
|
{
|
|
|
|
ClientConnectSignal.connect(callback);
|
|
|
|
}
|
|
|
|
|
2022-06-13 14:16:57 -04:00
|
|
|
void Events::OnSteamDisconnect(const Utils::Slot<Callback>& callback)
|
|
|
|
{
|
|
|
|
SteamDisconnectSignal.connect(callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Events::OnVMShutdown(const Utils::Slot<Callback>& callback)
|
|
|
|
{
|
|
|
|
ShutdownSystemSignal.connect(callback);
|
|
|
|
}
|
|
|
|
|
2022-07-16 17:24:26 -04:00
|
|
|
void Events::OnClientInit(const Utils::Slot<Callback>& callback)
|
|
|
|
{
|
|
|
|
ClientInitSignal.connect(callback);
|
|
|
|
}
|
|
|
|
|
2022-06-28 14:57:58 -04:00
|
|
|
void Events::OnSVInit(const Utils::Slot<Callback>& callback)
|
|
|
|
{
|
|
|
|
ServerInitSignal.connect(callback);
|
|
|
|
}
|
|
|
|
|
2022-06-13 14:16:57 -04:00
|
|
|
/*
|
|
|
|
* 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<void(int)>(0x4AA430)(clientNum); // ClientDisconnect
|
|
|
|
}
|
|
|
|
|
2023-01-25 13:20:44 -05:00
|
|
|
void Events::SV_UserinfoChanged_Hk(Game::client_t* cl)
|
|
|
|
{
|
|
|
|
ClientConnectSignal(cl);
|
|
|
|
|
|
|
|
Utils::Hook::Call<void(Game::client_t*)>(0x401950)(cl); // SV_UserinfoChanged
|
|
|
|
}
|
|
|
|
|
2022-06-13 14:16:57 -04:00
|
|
|
void Events::SteamDisconnect_Hk()
|
|
|
|
{
|
|
|
|
SteamDisconnectSignal();
|
|
|
|
|
|
|
|
Utils::Hook::Call<void()>(0x467CC0)(); // LiveSteam_Client_SteamDisconnect
|
|
|
|
}
|
|
|
|
|
|
|
|
void Events::Scr_ShutdownSystem_Hk(unsigned char sys)
|
|
|
|
{
|
|
|
|
ShutdownSystemSignal();
|
|
|
|
|
|
|
|
Utils::Hook::Call<void(unsigned char)>(0x421EE0)(sys); // Scr_ShutdownSystem
|
|
|
|
}
|
|
|
|
|
2022-07-16 17:24:26 -04:00
|
|
|
void Events::CL_InitOnceForAllClients_HK()
|
|
|
|
{
|
|
|
|
ClientInitSignal();
|
|
|
|
ClientInitSignal.clear();
|
|
|
|
|
|
|
|
Utils::Hook::Call<void()>(0x404CA0)(); // CL_InitOnceForAllClients
|
|
|
|
}
|
|
|
|
|
2022-06-28 14:57:58 -04:00
|
|
|
void Events::SV_Init_Hk()
|
|
|
|
{
|
|
|
|
ServerInitSignal();
|
|
|
|
ServerInitSignal.clear();
|
|
|
|
|
|
|
|
Utils::Hook::Call<void()>(0x474320)(); // SV_InitGameMode
|
|
|
|
}
|
|
|
|
|
2022-06-13 14:16:57 -04:00
|
|
|
Events::Events()
|
|
|
|
{
|
|
|
|
Utils::Hook(0x625235, ClientDisconnect_Hk, HOOK_CALL).install()->quick(); // SV_FreeClient
|
|
|
|
|
2023-01-25 13:20:44 -05:00
|
|
|
Utils::Hook(0x4612BD, SV_UserinfoChanged_Hk, HOOK_CALL).install()->quick(); // SV_DirectConnect
|
|
|
|
|
2022-06-13 14:16:57 -04:00
|
|
|
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
|
2022-06-28 14:57:58 -04:00
|
|
|
|
2022-07-16 17:24:26 -04:00
|
|
|
Utils::Hook(0x60BE5B, CL_InitOnceForAllClients_HK, HOOK_CALL).install()->quick(); // Com_Init_Try_Block_Function
|
|
|
|
|
2022-06-28 14:57:58 -04:00
|
|
|
Utils::Hook(0x4D3665, SV_Init_Hk, HOOK_CALL).install()->quick(); // SV_Init
|
2022-06-13 14:16:57 -04:00
|
|
|
}
|
|
|
|
}
|