[Script] Added hitch warning
This commit is contained in:
parent
4911be51b0
commit
75caede0b2
@ -9,6 +9,7 @@ namespace Components
|
|||||||
unsigned short Script::FunctionName;
|
unsigned short Script::FunctionName;
|
||||||
std::unordered_map<std::string, std::string> Script::ScriptStorage;
|
std::unordered_map<std::string, std::string> Script::ScriptStorage;
|
||||||
std::unordered_map<int, std::string> Script::ScriptBaseProgramNum;
|
std::unordered_map<int, std::string> Script::ScriptBaseProgramNum;
|
||||||
|
int Script::LastFrameTime = -1;
|
||||||
|
|
||||||
Utils::Signal<Scheduler::Callback> Script::VMShutdownSignal;
|
Utils::Signal<Scheduler::Callback> Script::VMShutdownSignal;
|
||||||
|
|
||||||
@ -566,6 +567,24 @@ namespace Components
|
|||||||
Utils::Hook(0x47548B, Script::ScrShutdownSystemStub, HOOK_CALL).install()->quick();
|
Utils::Hook(0x47548B, Script::ScrShutdownSystemStub, HOOK_CALL).install()->quick();
|
||||||
Utils::Hook(0x4D06BA, Script::ScrShutdownSystemStub, HOOK_CALL).install()->quick();
|
Utils::Hook(0x4D06BA, Script::ScrShutdownSystemStub, HOOK_CALL).install()->quick();
|
||||||
|
|
||||||
|
Scheduler::OnFrame([]()
|
||||||
|
{
|
||||||
|
if (!Game::SV_Loaded())
|
||||||
|
return;
|
||||||
|
|
||||||
|
int nowMs = Game::Sys_Milliseconds();
|
||||||
|
|
||||||
|
if (Script::LastFrameTime != -1)
|
||||||
|
{
|
||||||
|
int timeTaken = static_cast<int>((nowMs - Script::LastFrameTime) * Dvar::Var("timescale").get<float>());
|
||||||
|
|
||||||
|
if (timeTaken >= 500)
|
||||||
|
Logger::Print(23, "Hitch warning: %i msec frame time\n", timeTaken);
|
||||||
|
}
|
||||||
|
|
||||||
|
Script::LastFrameTime = nowMs;
|
||||||
|
});
|
||||||
|
|
||||||
Script::AddFunction("debugBox", [](Game::scr_entref_t)
|
Script::AddFunction("debugBox", [](Game::scr_entref_t)
|
||||||
{
|
{
|
||||||
MessageBoxA(nullptr, Game::Scr_GetString(0), "DEBUG", 0);
|
MessageBoxA(nullptr, Game::Scr_GetString(0), "DEBUG", 0);
|
||||||
|
@ -40,6 +40,7 @@ namespace Components
|
|||||||
static unsigned short FunctionName;
|
static unsigned short FunctionName;
|
||||||
static std::unordered_map<std::string, std::string> ScriptStorage;
|
static std::unordered_map<std::string, std::string> ScriptStorage;
|
||||||
static std::unordered_map<int, std::string> ScriptBaseProgramNum;
|
static std::unordered_map<int, std::string> ScriptBaseProgramNum;
|
||||||
|
static int LastFrameTime;
|
||||||
|
|
||||||
static Utils::Signal<Scheduler::Callback> VMShutdownSignal;
|
static Utils::Signal<Scheduler::Callback> VMShutdownSignal;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user