2022-02-27 07:53:44 -05:00
|
|
|
#include <STDInclude.hpp>
|
2017-01-19 16:23:59 -05:00
|
|
|
|
|
|
|
namespace Components
|
|
|
|
{
|
|
|
|
int SlowMotion::Delay = 0;
|
|
|
|
|
2022-11-03 20:28:44 -04:00
|
|
|
const Game::dvar_t* SlowMotion::cg_drawDisconnect;
|
|
|
|
|
|
|
|
void SlowMotion::Com_UpdateSlowMotion(int msec)
|
2017-01-19 16:23:59 -05:00
|
|
|
{
|
2022-10-09 14:46:53 -04:00
|
|
|
if (Delay <= 0)
|
2017-01-19 16:23:59 -05:00
|
|
|
{
|
2022-11-03 20:28:44 -04:00
|
|
|
Game::Com_UpdateSlowMotion(msec);
|
2017-01-19 16:23:59 -05:00
|
|
|
}
|
|
|
|
else
|
2021-08-15 20:01:21 -04:00
|
|
|
{
|
2022-11-03 20:28:44 -04:00
|
|
|
Delay -= msec;
|
2021-08-15 20:01:21 -04:00
|
|
|
}
|
2017-01-19 16:23:59 -05:00
|
|
|
}
|
2021-08-15 20:01:21 -04:00
|
|
|
|
2022-11-03 20:28:44 -04:00
|
|
|
__declspec(naked) void SlowMotion::Com_UpdateSlowMotion_Stub()
|
2021-08-15 20:01:21 -04:00
|
|
|
{
|
|
|
|
__asm
|
|
|
|
{
|
|
|
|
pushad
|
|
|
|
|
2022-11-03 20:28:44 -04:00
|
|
|
push [esp + 0x20 + 0x4]
|
|
|
|
call Com_UpdateSlowMotion
|
|
|
|
add esp, 0x4
|
2021-08-15 20:01:21 -04:00
|
|
|
|
|
|
|
popad
|
|
|
|
|
|
|
|
retn
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-03 20:28:44 -04:00
|
|
|
void SlowMotion::ScrCmd_SetSlowMotion_Stub()
|
2017-01-19 16:23:59 -05:00
|
|
|
{
|
2022-10-09 14:46:53 -04:00
|
|
|
auto duration = 1000;
|
|
|
|
auto start = Game::Scr_GetFloat(0);
|
|
|
|
auto end = 1.0f;
|
2017-01-19 16:23:59 -05:00
|
|
|
|
2022-11-03 20:28:44 -04:00
|
|
|
if (Game::Scr_GetNumParam() >= 2)
|
2017-01-19 16:23:59 -05:00
|
|
|
{
|
|
|
|
end = Game::Scr_GetFloat(1);
|
|
|
|
}
|
|
|
|
|
2022-11-03 20:28:44 -04:00
|
|
|
if (Game::Scr_GetNumParam() >= 3)
|
2017-01-19 16:23:59 -05:00
|
|
|
{
|
2022-06-04 16:16:55 -04:00
|
|
|
duration = static_cast<int>(Game::Scr_GetFloat(2) * 1000.0f);
|
2017-01-19 16:23:59 -05:00
|
|
|
}
|
|
|
|
|
2022-10-09 14:46:53 -04:00
|
|
|
auto delay = 0;
|
2017-01-19 16:23:59 -05:00
|
|
|
|
|
|
|
if (start > end)
|
|
|
|
{
|
|
|
|
if (duration < 150)
|
|
|
|
{
|
|
|
|
delay = duration;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
delay = 150;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
duration = duration - delay;
|
|
|
|
|
|
|
|
Game::Com_SetSlowMotion(start, end, duration);
|
2022-10-09 14:46:53 -04:00
|
|
|
Delay = delay;
|
2017-01-19 16:23:59 -05:00
|
|
|
|
2022-11-03 20:28:44 -04:00
|
|
|
// Set snapshot num to 1 behind (T6 does this, why shouldn't we?)
|
2022-10-09 14:46:53 -04:00
|
|
|
for (auto i = 0; i < *Game::svs_clientCount; ++i)
|
2017-01-19 16:23:59 -05:00
|
|
|
{
|
2022-08-20 06:30:34 -04:00
|
|
|
Game::svs_clients[i].nextSnapshotTime = *Game::svs_time - 1;
|
2017-01-19 16:23:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-03 20:28:44 -04:00
|
|
|
void SlowMotion::CG_DrawDisconnect_Stub(const int localClientNum)
|
|
|
|
{
|
|
|
|
if (cg_drawDisconnect->current.enabled)
|
|
|
|
{
|
|
|
|
Game::CG_DrawDisconnect(localClientNum);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-29 17:03:57 -04:00
|
|
|
SlowMotion::SlowMotion()
|
|
|
|
{
|
2022-11-03 20:28:44 -04:00
|
|
|
cg_drawDisconnect = Game::Dvar_RegisterBool("cg_drawDisconnect", false, Game::DVAR_NONE, "Draw connection interrupted");
|
2022-10-09 14:46:53 -04:00
|
|
|
|
2022-11-03 20:28:44 -04:00
|
|
|
Delay = 0;
|
|
|
|
Utils::Hook(0x5F5FF2, ScrCmd_SetSlowMotion_Stub, HOOK_JUMP).install()->quick();
|
|
|
|
Utils::Hook(0x60B38A, Com_UpdateSlowMotion_Stub, HOOK_CALL).install()->quick();
|
2017-06-29 17:03:57 -04:00
|
|
|
|
2022-11-03 20:28:44 -04:00
|
|
|
Utils::Hook(0x4A54ED, CG_DrawDisconnect_Stub, HOOK_CALL).install()->quick();
|
|
|
|
Utils::Hook(0x4A54FB, CG_DrawDisconnect_Stub, HOOK_CALL).install()->quick();
|
2017-06-29 17:03:57 -04:00
|
|
|
}
|
2022-03-07 17:35:12 -05:00
|
|
|
}
|