[Slowmotion] Cleanup functions defs (#551)
This commit is contained in:
@ -4,27 +4,29 @@ namespace Components
|
||||
{
|
||||
int SlowMotion::Delay = 0;
|
||||
|
||||
void SlowMotion::ApplySlowMotion(int timePassed)
|
||||
const Game::dvar_t* SlowMotion::cg_drawDisconnect;
|
||||
|
||||
void SlowMotion::Com_UpdateSlowMotion(int msec)
|
||||
{
|
||||
if (Delay <= 0)
|
||||
{
|
||||
Utils::Hook::Call<void(int)>(0x60B2D0)(timePassed);
|
||||
Game::Com_UpdateSlowMotion(msec);
|
||||
}
|
||||
else
|
||||
{
|
||||
Delay -= timePassed;
|
||||
Delay -= msec;
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(naked) void SlowMotion::ApplySlowMotionStub()
|
||||
__declspec(naked) void SlowMotion::Com_UpdateSlowMotion_Stub()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
pushad
|
||||
|
||||
push [esp + 24h]
|
||||
call ApplySlowMotion
|
||||
add esp, 4h
|
||||
push [esp + 0x20 + 0x4]
|
||||
call Com_UpdateSlowMotion
|
||||
add esp, 0x4
|
||||
|
||||
popad
|
||||
|
||||
@ -32,18 +34,18 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
void SlowMotion::SetSlowMotion()
|
||||
void SlowMotion::ScrCmd_SetSlowMotion_Stub()
|
||||
{
|
||||
auto duration = 1000;
|
||||
auto start = Game::Scr_GetFloat(0);
|
||||
auto end = 1.0f;
|
||||
|
||||
if (Game::Scr_GetNumParam() >= 2u)
|
||||
if (Game::Scr_GetNumParam() >= 2)
|
||||
{
|
||||
end = Game::Scr_GetFloat(1);
|
||||
}
|
||||
|
||||
if (Game::Scr_GetNumParam() >= 3u)
|
||||
if (Game::Scr_GetNumParam() >= 3)
|
||||
{
|
||||
duration = static_cast<int>(Game::Scr_GetFloat(2) * 1000.0f);
|
||||
}
|
||||
@ -67,21 +69,30 @@ namespace Components
|
||||
Game::Com_SetSlowMotion(start, end, duration);
|
||||
Delay = delay;
|
||||
|
||||
// set snapshot num to 1 behind (T6 does this, why shouldn't we?)
|
||||
// Set snapshot num to 1 behind (T6 does this, why shouldn't we?)
|
||||
for (auto i = 0; i < *Game::svs_clientCount; ++i)
|
||||
{
|
||||
Game::svs_clients[i].nextSnapshotTime = *Game::svs_time - 1;
|
||||
}
|
||||
}
|
||||
|
||||
void SlowMotion::CG_DrawDisconnect_Stub(const int localClientNum)
|
||||
{
|
||||
if (cg_drawDisconnect->current.enabled)
|
||||
{
|
||||
Game::CG_DrawDisconnect(localClientNum);
|
||||
}
|
||||
}
|
||||
|
||||
SlowMotion::SlowMotion()
|
||||
{
|
||||
cg_drawDisconnect = Game::Dvar_RegisterBool("cg_drawDisconnect", false, Game::DVAR_NONE, "Draw connection interrupted");
|
||||
|
||||
Delay = 0;
|
||||
Utils::Hook(0x5F5FF2, SetSlowMotion, HOOK_JUMP).install()->quick();
|
||||
Utils::Hook(0x60B38A, ApplySlowMotionStub, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(0x5F5FF2, ScrCmd_SetSlowMotion_Stub, HOOK_JUMP).install()->quick();
|
||||
Utils::Hook(0x60B38A, Com_UpdateSlowMotion_Stub, HOOK_CALL).install()->quick();
|
||||
|
||||
|
||||
Utils::Hook::Nop(0x4A54ED, 5);
|
||||
Utils::Hook::Nop(0x4A54FB, 5);
|
||||
Utils::Hook(0x4A54ED, CG_DrawDisconnect_Stub, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(0x4A54FB, CG_DrawDisconnect_Stub, HOOK_CALL).install()->quick();
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,13 @@ namespace Components
|
||||
private:
|
||||
static int Delay;
|
||||
|
||||
static void SetSlowMotion();
|
||||
static void ApplySlowMotion(int timePassed);
|
||||
static void ApplySlowMotionStub();
|
||||
static const Game::dvar_t* cg_drawDisconnect;
|
||||
|
||||
static void Com_UpdateSlowMotion(int timePassed);
|
||||
static void Com_UpdateSlowMotion_Stub();
|
||||
|
||||
static void ScrCmd_SetSlowMotion_Stub();
|
||||
|
||||
static void CG_DrawDisconnect_Stub(int localClientNum);
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user