[Scheduler] Introduce scheduler with 80 compile errors
This commit is contained in:
parent
c0575fdc50
commit
fe6cb2d737
@ -64,6 +64,7 @@ namespace Components
|
||||
};
|
||||
}
|
||||
|
||||
#include "Modules/Scheduler.hpp"
|
||||
#include "Modules/Auth.hpp"
|
||||
#include "Modules/Bans.hpp"
|
||||
#include "Modules/Bots.hpp"
|
||||
|
@ -582,7 +582,7 @@ namespace Components
|
||||
Utils::Hook(0x60BE9D, AntiCheat::SoundInitStub, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(0x60BE8E, AntiCheat::SoundInitDriverStub, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(0x418204, AntiCheat::SoundInitDriverStub, HOOK_CALL).install()->quick();
|
||||
Renderer::OnFrame(AntiCheat::PerformScan);
|
||||
if(!Dedicated::IsEnabled() && !ZoneBuilder::IsEnabled()) Scheduler::OnFrame(AntiCheat::PerformScan);
|
||||
|
||||
// Detect aimbots
|
||||
Utils::Hook(0x426580, AntiCheat::DObjGetWorldTagPosStub, HOOK_JUMP).install()->quick();
|
||||
|
@ -418,7 +418,7 @@ namespace Components
|
||||
Utils::Hook(0x5BB6EC, AssetHandler::StoreEmptyAssetStub, HOOK_CALL).install()->quick();
|
||||
|
||||
// Log missing empty assets
|
||||
QuickPatch::OnFrame([] ()
|
||||
Scheduler::OnFrame([] ()
|
||||
{
|
||||
if (FastFiles::Ready() && !AssetHandler::EmptyAssets.empty())
|
||||
{
|
||||
|
@ -404,7 +404,7 @@ namespace Components
|
||||
Auth::LoadKey(true);
|
||||
Steam::SteamUser()->GetSteamID();
|
||||
|
||||
QuickPatch::OnFrame(Auth::Frame);
|
||||
Scheduler::OnFrame(Auth::Frame);
|
||||
|
||||
// Register dvar
|
||||
Dvar::Register<int>("sv_securityLevel", 23, 0, 512, Game::dvar_flag::DVAR_FLAG_SERVERINFO, "Security level for GUID certificates (POW)");
|
||||
|
@ -194,7 +194,7 @@ namespace Components
|
||||
});
|
||||
|
||||
// Verify the list on startup
|
||||
QuickPatch::Once([] ()
|
||||
Scheduler::Once([] ()
|
||||
{
|
||||
Bans::BanList list;
|
||||
Bans::LoadBans(&list);
|
||||
|
@ -42,20 +42,20 @@ namespace Components
|
||||
{
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
{
|
||||
Renderer::OnDelay([]()
|
||||
Scheduler::OnDelay([]()
|
||||
{
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
Game::gentity_t* entRef = Game::SV_AddTestClient();
|
||||
if (entRef)
|
||||
{
|
||||
Renderer::OnDelay([entRef]()
|
||||
Scheduler::OnDelay([entRef]()
|
||||
{
|
||||
Game::Scr_AddString("autoassign");
|
||||
Game::Scr_AddString("team_marinesopfor");
|
||||
Game::Scr_Notify(entRef, Game::SL_GetString("menuresponse", 0), 2);
|
||||
|
||||
Renderer::OnDelay([entRef]()
|
||||
Scheduler::OnDelay([entRef]()
|
||||
{
|
||||
Game::Scr_AddString(Utils::String::VA("class%d", Utils::Cryptography::Rand::GenerateInt() % 5));
|
||||
Game::Scr_AddString("changeclass");
|
||||
|
@ -614,7 +614,7 @@ namespace Components
|
||||
}
|
||||
}, HOOK_CALL).install()->quick();
|
||||
|
||||
QuickPatch::OnFrame([] ()
|
||||
Scheduler::OnFrame([] ()
|
||||
{
|
||||
Console::LastRefresh = Game::Sys_Milliseconds();
|
||||
});
|
||||
|
@ -2,9 +2,6 @@
|
||||
|
||||
namespace Components
|
||||
{
|
||||
Utils::Signal<Dedicated::Callback> Dedicated::FrameSignal;
|
||||
Utils::Signal<Dedicated::Callback> Dedicated::FrameOnceSignal;
|
||||
|
||||
SteamID Dedicated::PlayerGuids[18][2];
|
||||
|
||||
bool Dedicated::SendChat;
|
||||
@ -170,7 +167,7 @@ namespace Components
|
||||
partyEnable = Dvar::Var("party_enable").get<bool>();
|
||||
mapname = Dvar::Var("mapname").get<std::string>();
|
||||
|
||||
QuickPatch::Once([]()
|
||||
Scheduler::Once([]()
|
||||
{
|
||||
Dvar::Var("party_enable").set(partyEnable);
|
||||
|
||||
@ -280,32 +277,12 @@ namespace Components
|
||||
Network::SendCommand(master, "heartbeat", "IW4");
|
||||
}
|
||||
|
||||
void Dedicated::Once(Utils::Slot<Dedicated::Callback> callback)
|
||||
{
|
||||
Dedicated::FrameOnceSignal.connect(callback);
|
||||
}
|
||||
|
||||
void Dedicated::OnFrame(Utils::Slot<Dedicated::Callback> callback)
|
||||
{
|
||||
Dedicated::FrameSignal.connect(callback);
|
||||
}
|
||||
|
||||
void Dedicated::FrameHandler()
|
||||
{
|
||||
auto copy = Dedicated::FrameSignal;
|
||||
copy();
|
||||
|
||||
copy = Dedicated::FrameOnceSignal;
|
||||
Dedicated::FrameOnceSignal.clear();
|
||||
copy();
|
||||
}
|
||||
|
||||
__declspec(naked) void Dedicated::FrameStub()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
pushad
|
||||
call Dedicated::FrameHandler
|
||||
call Scheduler::FrameHandler
|
||||
popad
|
||||
|
||||
push 5A8E80h
|
||||
@ -323,7 +300,7 @@ namespace Components
|
||||
if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled()) // Run zonebuilder as dedi :P
|
||||
{
|
||||
// Make sure all callbacks are handled
|
||||
Dedicated::OnFrame(Steam::SteamAPI_RunCallbacks);
|
||||
Scheduler::OnFrame(Steam::SteamAPI_RunCallbacks);
|
||||
|
||||
Dvar::Register<bool>("sv_lanOnly", false, Game::dvar_flag::DVAR_FLAG_NONE, "Don't act as node");
|
||||
|
||||
@ -546,7 +523,7 @@ namespace Components
|
||||
});
|
||||
}
|
||||
|
||||
QuickPatch::OnFrame([]()
|
||||
Scheduler::OnFrame([]()
|
||||
{
|
||||
if(Dvar::Var("sv_running").get<bool>())
|
||||
{
|
||||
@ -563,7 +540,6 @@ namespace Components
|
||||
|
||||
Dedicated::~Dedicated()
|
||||
{
|
||||
Dedicated::FrameOnceSignal.clear();
|
||||
Dedicated::FrameSignal.clear();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,6 @@ namespace Components
|
||||
class Dedicated : public Component
|
||||
{
|
||||
public:
|
||||
typedef void(Callback)();
|
||||
|
||||
Dedicated();
|
||||
~Dedicated();
|
||||
|
||||
@ -16,18 +14,10 @@ namespace Components
|
||||
|
||||
static void Heartbeat();
|
||||
|
||||
static void OnFrame(Utils::Slot<Callback> callback);
|
||||
static void Once(Utils::Slot<Callback> callback);
|
||||
|
||||
private:
|
||||
static Utils::Signal<Callback> FrameSignal;
|
||||
static Utils::Signal<Callback> FrameOnceSignal;
|
||||
|
||||
static bool SendChat;
|
||||
|
||||
static void MapRotate();
|
||||
static void FrameHandler();
|
||||
static void FrameStub();
|
||||
static void InitDedicatedServer();
|
||||
|
||||
static void PostInitialization();
|
||||
@ -38,6 +28,8 @@ namespace Components
|
||||
static void PreSayStub();
|
||||
static void PostSayStub();
|
||||
|
||||
static void FrameStub();
|
||||
|
||||
static void TransmitGuids();
|
||||
|
||||
static void TimeWrapStub(int code, const char* message);
|
||||
|
@ -20,7 +20,7 @@ namespace Components
|
||||
{
|
||||
if (Download::CLDownload.running) return;
|
||||
|
||||
QuickPatch::Once([]()
|
||||
Scheduler::Once([]()
|
||||
{
|
||||
Dvar::Var("ui_dl_timeLeft").set(Utils::String::FormatTimeSpan(0));
|
||||
Dvar::Var("ui_dl_progress").set("(0/0) %");
|
||||
@ -119,7 +119,7 @@ namespace Components
|
||||
if (!framePushed)
|
||||
{
|
||||
framePushed = true;
|
||||
QuickPatch::Once([]()
|
||||
Scheduler::Once([]()
|
||||
{
|
||||
framePushed = false;
|
||||
Dvar::Var("ui_dl_progress").set(Utils::String::VA("(%d/%d) %d%%", dlIndex, dlSize, dlProgress));
|
||||
@ -149,7 +149,7 @@ namespace Components
|
||||
dlDelta = delta;
|
||||
dlTsBytes = fDownload->download->timeStampBytes;
|
||||
|
||||
QuickPatch::Once([]()
|
||||
Scheduler::Once([]()
|
||||
{
|
||||
Dvar::Var("ui_dl_timeLeft").set(Utils::String::FormatTimeSpan(dlTimeLeft));
|
||||
Dvar::Var("ui_dl_transRate").set(Utils::String::FormatBandwidth(dlTsBytes, dlDelta));
|
||||
@ -241,7 +241,7 @@ namespace Components
|
||||
download->thread.detach();
|
||||
download->clear();
|
||||
|
||||
QuickPatch::Once([]()
|
||||
Scheduler::Once([]()
|
||||
{
|
||||
Command::Execute("closemenu mod_download_popmenu");
|
||||
Party::ConnectError("Failed to download the modlist!");
|
||||
@ -259,7 +259,7 @@ namespace Components
|
||||
download->thread.detach();
|
||||
download->clear();
|
||||
|
||||
QuickPatch::Once([]()
|
||||
Scheduler::Once([]()
|
||||
{
|
||||
Command::Execute("closemenu mod_download_popmenu");
|
||||
Party::ConnectError("Failed to parse the modlist!");
|
||||
@ -285,7 +285,7 @@ namespace Components
|
||||
download->thread.detach();
|
||||
download->clear();
|
||||
|
||||
QuickPatch::Once([]()
|
||||
Scheduler::Once([]()
|
||||
{
|
||||
Dvar::Var("partyend_reason").set(mod);
|
||||
mod.clear();
|
||||
@ -305,7 +305,7 @@ namespace Components
|
||||
|
||||
if(download->isMap)
|
||||
{
|
||||
QuickPatch::Once([]()
|
||||
Scheduler::Once([]()
|
||||
{
|
||||
Command::Execute("reconnect", false);
|
||||
});
|
||||
@ -313,7 +313,7 @@ namespace Components
|
||||
else
|
||||
{
|
||||
// Run this on the main thread
|
||||
QuickPatch::Once([]()
|
||||
Scheduler::Once([]()
|
||||
{
|
||||
auto fsGame = Dvar::Var("fs_game");
|
||||
fsGame.set(mod);
|
||||
@ -754,7 +754,7 @@ namespace Components
|
||||
});
|
||||
}
|
||||
|
||||
QuickPatch::OnFrame([]()
|
||||
Scheduler::OnFrame([]()
|
||||
{
|
||||
int workingCount = 0;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace Components
|
||||
{
|
||||
Utils::Signal<Dvar::Callback> Dvar::RegistrationSignal;
|
||||
Utils::Signal<Scheduler::Callback> Dvar::RegistrationSignal;
|
||||
|
||||
Dvar::Var::Var(std::string dvarName) : Var()
|
||||
{
|
||||
@ -131,7 +131,7 @@ namespace Components
|
||||
return Game::Dvar_RegisterInt(name, value, min, max, flag.val, description);
|
||||
}
|
||||
|
||||
void Dvar::OnInit(Utils::Slot<Dvar::Callback> callback)
|
||||
void Dvar::OnInit(Utils::Slot<Scheduler::Callback> callback)
|
||||
{
|
||||
Dvar::RegistrationSignal.connect(callback);
|
||||
}
|
||||
|
@ -5,8 +5,6 @@ namespace Components
|
||||
class Dvar : public Component
|
||||
{
|
||||
public:
|
||||
typedef void(Callback)();
|
||||
|
||||
class Flag
|
||||
{
|
||||
public:
|
||||
@ -44,14 +42,14 @@ namespace Components
|
||||
Dvar();
|
||||
~Dvar();
|
||||
|
||||
static void OnInit(Utils::Slot<Callback> callback);
|
||||
static void OnInit(Utils::Slot<Scheduler::Callback> callback);
|
||||
|
||||
// Only strings and bools use this type of declaration
|
||||
template<typename T> static Var Register(const char* name, T value, Flag flag, const char* description);
|
||||
template<typename T> static Var Register(const char* name, T value, T min, T max, Flag flag, const char* description);
|
||||
|
||||
private:
|
||||
static Utils::Signal<Callback> RegistrationSignal;
|
||||
static Utils::Signal<Scheduler::Callback> RegistrationSignal;
|
||||
|
||||
static Game::dvar_t* RegisterName(const char* name, const char* defaultVal, Game::dvar_flag flag, const char* description);
|
||||
|
||||
|
@ -174,7 +174,7 @@ namespace Components
|
||||
|
||||
#ifdef DEBUG
|
||||
// Display DEBUG branding, so we know we're on a debug build
|
||||
Renderer::OnFrame([]()
|
||||
Scheduler::OnFrame([]()
|
||||
{
|
||||
Game::Font* font = Game::R_RegisterFont("fonts/normalFont", 0);
|
||||
float color[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
|
@ -564,7 +564,7 @@ namespace Components
|
||||
FastFiles::AddZonePath("zone\\patch\\");
|
||||
FastFiles::AddZonePath("zone\\dlc\\");
|
||||
|
||||
Renderer::OnFrame([] ()
|
||||
Scheduler::OnFrame([] ()
|
||||
{
|
||||
if (FastFiles::Current().empty() || !Dvar::Var("ui_zoneDebug").get<bool>()) return;
|
||||
|
||||
|
@ -597,7 +597,7 @@ namespace Components
|
||||
}
|
||||
});
|
||||
|
||||
QuickPatch::OnFrame([]()
|
||||
Scheduler::OnFrame([]()
|
||||
{
|
||||
static Utils::Time::Interval timeInterval;
|
||||
static Utils::Time::Interval sortInterval;
|
||||
@ -658,7 +658,7 @@ namespace Components
|
||||
}
|
||||
});
|
||||
|
||||
QuickPatch::Once([]()
|
||||
Scheduler::Once([]()
|
||||
{
|
||||
if (Steam::Proxy::SteamFriends)
|
||||
{
|
||||
|
@ -247,7 +247,7 @@ namespace Components
|
||||
|
||||
Logger::PipeOutput(nullptr);
|
||||
|
||||
QuickPatch::OnFrame(Logger::Frame);
|
||||
Scheduler::OnFrame(Logger::Frame);
|
||||
|
||||
Utils::Hook(0x4B0218, Logger::GameLogStub, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(Game::Com_PrintMessage, Logger::PrintMessageStub, HOOK_JUMP).install()->quick();
|
||||
|
@ -187,7 +187,7 @@ namespace Components
|
||||
}
|
||||
#endif
|
||||
|
||||
// Renderer::OnFrame([] ()
|
||||
// Scheduler::OnFrame([] ()
|
||||
// {
|
||||
// Game::Font* font = Game::R_RegisterFont("fonts/normalFont");
|
||||
// float color[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
|
@ -895,7 +895,7 @@ namespace Components
|
||||
});
|
||||
|
||||
// Install frame handlers
|
||||
QuickPatch::OnFrame(Node::FrameHandler);
|
||||
Scheduler::OnFrame(Node::FrameHandler);
|
||||
|
||||
Network::OnStart([] ()
|
||||
{
|
||||
|
@ -3,9 +3,6 @@
|
||||
namespace Components
|
||||
{
|
||||
int QuickPatch::FrameTime = 0;
|
||||
bool QuickPatch::ReadyPassed = false;
|
||||
Utils::Signal<QuickPatch::Callback> QuickPatch::ReadySignal;
|
||||
Utils::Signal<QuickPatch::Callback> QuickPatch::ShutdownSignal;
|
||||
|
||||
int64_t* QuickPatch::GetStatsID()
|
||||
{
|
||||
@ -13,58 +10,6 @@ namespace Components
|
||||
return &id;
|
||||
}
|
||||
|
||||
void QuickPatch::OnReady(Utils::Slot<QuickPatch::Callback> callback)
|
||||
{
|
||||
if(QuickPatch::ReadyPassed) QuickPatch::Once(callback);
|
||||
else QuickPatch::ReadySignal.connect(callback);
|
||||
}
|
||||
|
||||
void QuickPatch::ReadyHandler()
|
||||
{
|
||||
if (!FastFiles::Ready()) QuickPatch::Once(QuickPatch::ReadyHandler);
|
||||
else
|
||||
{
|
||||
QuickPatch::ReadyPassed = true;
|
||||
QuickPatch::ReadySignal();
|
||||
QuickPatch::ReadySignal.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void QuickPatch::OnShutdown(Utils::Slot<QuickPatch::Callback> callback)
|
||||
{
|
||||
QuickPatch::ShutdownSignal.connect(callback);
|
||||
}
|
||||
|
||||
void QuickPatch::ShutdownStub(int num)
|
||||
{
|
||||
QuickPatch::ShutdownSignal();
|
||||
Utils::Hook::Call<void(int)>(0x46B370)(num);
|
||||
}
|
||||
|
||||
void QuickPatch::OnFrame(Utils::Slot<QuickPatch::Callback> callback)
|
||||
{
|
||||
if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled())
|
||||
{
|
||||
Dedicated::OnFrame(callback);
|
||||
}
|
||||
else
|
||||
{
|
||||
Renderer::OnFrame(callback);
|
||||
}
|
||||
}
|
||||
|
||||
void QuickPatch::Once(Utils::Slot<QuickPatch::Callback> callback)
|
||||
{
|
||||
if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled())
|
||||
{
|
||||
Dedicated::Once(callback);
|
||||
}
|
||||
else
|
||||
{
|
||||
Renderer::Once(callback);
|
||||
}
|
||||
}
|
||||
|
||||
void QuickPatch::UnlockStats()
|
||||
{
|
||||
if (Dedicated::IsEnabled()) return;
|
||||
@ -196,17 +141,14 @@ namespace Components
|
||||
|
||||
QuickPatch::QuickPatch()
|
||||
{
|
||||
QuickPatch::ReadyPassed = false;
|
||||
QuickPatch::Once(QuickPatch::ReadyHandler);
|
||||
|
||||
QuickPatch::FrameTime = 0;
|
||||
QuickPatch::OnFrame([]()
|
||||
Scheduler::OnFrame([]()
|
||||
{
|
||||
QuickPatch::FrameTime = Game::Sys_Milliseconds();
|
||||
});
|
||||
|
||||
// Make sure preDestroy is called when the game shuts down
|
||||
QuickPatch::OnShutdown(Loader::PreDestroy);
|
||||
Scheduler::OnShutdown(Loader::PreDestroy);
|
||||
|
||||
// protocol version (workaround for hacks)
|
||||
Utils::Hook::Set<int>(0x4FB501, PROTOCOL);
|
||||
@ -671,7 +613,7 @@ namespace Components
|
||||
Dvar::Register<bool>("r_drawAabbTrees", false, Game::DVAR_FLAG_USERCREATED, "Draw aabb trees");
|
||||
});
|
||||
|
||||
Renderer::OnFrame([]()
|
||||
Scheduler::OnFrame([]()
|
||||
{
|
||||
if (!Game::CL_IsCgameInitialized() || !Dvar::Var("r_drawAabbTrees").get<bool>()) return;
|
||||
|
||||
@ -735,8 +677,7 @@ namespace Components
|
||||
|
||||
QuickPatch::~QuickPatch()
|
||||
{
|
||||
QuickPatch::ReadySignal.clear();
|
||||
QuickPatch::ShutdownSignal.clear();
|
||||
|
||||
}
|
||||
|
||||
bool QuickPatch::unitTest()
|
||||
|
@ -5,31 +5,20 @@ namespace Components
|
||||
class QuickPatch : public Component
|
||||
{
|
||||
public:
|
||||
typedef void(Callback)();
|
||||
|
||||
QuickPatch();
|
||||
~QuickPatch();
|
||||
|
||||
bool unitTest() override;
|
||||
|
||||
static void UnlockStats();
|
||||
static void OnShutdown(Utils::Slot<Callback> callback);
|
||||
static void OnFrame(Utils::Slot<Callback> callback);
|
||||
static void OnReady(Utils::Slot<Callback> callback);
|
||||
static void Once(Utils::Slot<Callback> callback);
|
||||
static int GetFrameTime() { return FrameTime; }
|
||||
|
||||
private:
|
||||
static int FrameTime;
|
||||
static bool ReadyPassed;
|
||||
static Utils::Signal<Callback> ReadySignal;
|
||||
static Utils::Signal<Callback> ShutdownSignal;
|
||||
|
||||
static int64_t* GetStatsID();
|
||||
static void ShutdownStub(int num);
|
||||
|
||||
static void ReadyHandler();
|
||||
|
||||
static void SelectStringTableEntryInDvarStub();
|
||||
|
||||
static int MsgReadBitsCompressCheckSV(const char *from, char *to, int size);
|
||||
|
@ -2,21 +2,17 @@
|
||||
|
||||
namespace Components
|
||||
{
|
||||
Utils::Signal<Renderer::Callback> Renderer::FrameSignal;
|
||||
Utils::Signal<Renderer::Callback> Renderer::FrameOnceSignal;
|
||||
Utils::Signal<Renderer::BackendCallback> Renderer::BackendFrameSignal;
|
||||
|
||||
Utils::Signal<Renderer::Callback> Renderer::EndRecoverDeviceSignal;
|
||||
Utils::Signal<Renderer::Callback> Renderer::BeginRecoverDeviceSignal;
|
||||
|
||||
std::vector<Renderer::DelayedSlot> Renderer::DelayedSlots;
|
||||
Utils::Signal<Scheduler::Callback> Renderer::EndRecoverDeviceSignal;
|
||||
Utils::Signal<Scheduler::Callback> Renderer::BeginRecoverDeviceSignal;
|
||||
|
||||
__declspec(naked) void Renderer::FrameStub()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
pushad
|
||||
call Renderer::FrameHandler
|
||||
call Scheduler::FrameHandler
|
||||
popad
|
||||
|
||||
push 5AC950h
|
||||
@ -24,16 +20,6 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::FrameHandler()
|
||||
{
|
||||
Renderer::DelaySignal();
|
||||
Renderer::FrameSignal();
|
||||
|
||||
Utils::Signal<Renderer::Callback> copy(Renderer::FrameOnceSignal);
|
||||
Renderer::FrameOnceSignal.clear();
|
||||
copy();
|
||||
}
|
||||
|
||||
__declspec(naked) void Renderer::BackendFrameStub()
|
||||
{
|
||||
__asm
|
||||
@ -60,61 +46,21 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::Once(Utils::Slot<Renderer::Callback> callback)
|
||||
{
|
||||
if (Dedicated::IsEnabled()) return;
|
||||
Renderer::FrameOnceSignal.connect(callback);
|
||||
}
|
||||
|
||||
void Renderer::OnFrame(Utils::Slot<Renderer::Callback> callback)
|
||||
{
|
||||
if (Dedicated::IsEnabled()) return;
|
||||
Renderer::FrameSignal.connect(callback);
|
||||
}
|
||||
|
||||
void Renderer::OnBackendFrame(Utils::Slot<Renderer::BackendCallback> callback)
|
||||
{
|
||||
Renderer::BackendFrameSignal.connect(callback);
|
||||
}
|
||||
|
||||
void Renderer::OnDeviceRecoveryEnd(Utils::Slot<Renderer::Callback> callback)
|
||||
void Renderer::OnDeviceRecoveryEnd(Utils::Slot<Scheduler::Callback> callback)
|
||||
{
|
||||
Renderer::EndRecoverDeviceSignal.connect(callback);
|
||||
}
|
||||
|
||||
void Renderer::OnDeviceRecoveryBegin(Utils::Slot<Renderer::Callback> callback)
|
||||
void Renderer::OnDeviceRecoveryBegin(Utils::Slot<Scheduler::Callback> callback)
|
||||
{
|
||||
Renderer::BeginRecoverDeviceSignal.connect(callback);
|
||||
}
|
||||
|
||||
void Renderer::OnDelay(Utils::Slot<Renderer::Callback> callback, std::chrono::nanoseconds delay)
|
||||
{
|
||||
Renderer::DelayedSlot slot;
|
||||
slot.callback = callback;
|
||||
slot.delay = delay;
|
||||
|
||||
Renderer::DelayedSlots.push_back(slot);
|
||||
}
|
||||
|
||||
void Renderer::DelaySignal()
|
||||
{
|
||||
Utils::Signal<Renderer::Callback> signal;
|
||||
|
||||
for(auto i = Renderer::DelayedSlots.begin(); i != Renderer::DelayedSlots.end();)
|
||||
{
|
||||
if(i->interval.elapsed(i->delay))
|
||||
{
|
||||
signal.connect(i->callback);
|
||||
i = Renderer::DelayedSlots.erase(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
signal();
|
||||
}
|
||||
|
||||
int Renderer::Width()
|
||||
{
|
||||
return Utils::Hook::Get<int>(0x66E1C68);
|
||||
@ -178,8 +124,6 @@ namespace Components
|
||||
Renderer::~Renderer()
|
||||
{
|
||||
Renderer::BackendFrameSignal.clear();
|
||||
Renderer::FrameOnceSignal.clear();
|
||||
Renderer::FrameSignal.clear();
|
||||
|
||||
Renderer::EndRecoverDeviceSignal.clear();
|
||||
Renderer::BeginRecoverDeviceSignal.clear();
|
||||
|
@ -5,7 +5,6 @@ namespace Components
|
||||
class Renderer : public Component
|
||||
{
|
||||
public:
|
||||
typedef void(Callback)();
|
||||
typedef void(BackendCallback)(IDirect3DDevice9*);
|
||||
|
||||
Renderer();
|
||||
@ -14,39 +13,20 @@ namespace Components
|
||||
static int Width();
|
||||
static int Height();
|
||||
|
||||
static void Once(Utils::Slot<Callback> callback);
|
||||
static void OnFrame(Utils::Slot<Callback> callback);
|
||||
static void OnBackendFrame(Utils::Slot<BackendCallback> callback);
|
||||
static void OnDelay(Utils::Slot<Callback> callback, std::chrono::nanoseconds delay);
|
||||
static void OnDeviceRecoveryEnd(Utils::Slot<Scheduler::Callback> callback);
|
||||
static void OnDeviceRecoveryBegin(Utils::Slot<Scheduler::Callback> callback);
|
||||
|
||||
static void OnDeviceRecoveryEnd(Utils::Slot<Callback> callback);
|
||||
static void OnDeviceRecoveryBegin(Utils::Slot<Callback> callback);
|
||||
|
||||
private:
|
||||
class DelayedSlot
|
||||
{
|
||||
public:
|
||||
std::chrono::nanoseconds delay;
|
||||
Utils::Time::Interval interval;
|
||||
Utils::Slot<Callback> callback;
|
||||
};
|
||||
|
||||
static void FrameStub();
|
||||
static void FrameHandler();
|
||||
|
||||
static void BackendFrameStub();
|
||||
static void BackendFrameHandler();
|
||||
|
||||
static void DelaySignal();
|
||||
|
||||
static Utils::Signal<Callback> FrameSignal;
|
||||
static Utils::Signal<Callback> FrameOnceSignal;
|
||||
|
||||
static Utils::Signal<Callback> EndRecoverDeviceSignal;
|
||||
static Utils::Signal<Callback> BeginRecoverDeviceSignal;
|
||||
static Utils::Signal<Scheduler::Callback> EndRecoverDeviceSignal;
|
||||
static Utils::Signal<Scheduler::Callback> BeginRecoverDeviceSignal;
|
||||
|
||||
static Utils::Signal<BackendCallback> BackendFrameSignal;
|
||||
|
||||
static std::vector<DelayedSlot> DelayedSlots;
|
||||
};
|
||||
}
|
||||
|
83
src/Components/Modules/Scheduler.cpp
Normal file
83
src/Components/Modules/Scheduler.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
#include "STDInclude.hpp"
|
||||
|
||||
namespace Components
|
||||
{
|
||||
bool Scheduler::ReadyPassed = false;
|
||||
Utils::Signal<Scheduler::Callback> Scheduler::ReadySignal;
|
||||
Utils::Signal<Scheduler::Callback> Scheduler::ShutdownSignal;
|
||||
|
||||
Utils::Signal<Scheduler::Callback> Scheduler::FrameSignal;
|
||||
Utils::Signal<Scheduler::Callback> Scheduler::FrameOnceSignal;
|
||||
std::vector<Scheduler::DelayedSlot> Scheduler::DelayedSlots;
|
||||
|
||||
void Scheduler::Once(Utils::Slot<Scheduler::Callback> callback)
|
||||
{
|
||||
Scheduler::FrameOnceSignal.connect(callback);
|
||||
}
|
||||
|
||||
void Scheduler::OnFrame(Utils::Slot<Scheduler::Callback> callback)
|
||||
{
|
||||
Scheduler::FrameSignal.connect(callback);
|
||||
}
|
||||
|
||||
void Scheduler::ReadyHandler()
|
||||
{
|
||||
if (!FastFiles::Ready()) Scheduler::Once(Scheduler::ReadyHandler);
|
||||
else
|
||||
{
|
||||
Scheduler::ReadyPassed = true;
|
||||
Scheduler::ReadySignal();
|
||||
Scheduler::ReadySignal.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void Scheduler::FrameHandler()
|
||||
{
|
||||
Scheduler::DelaySignal();
|
||||
Scheduler::FrameSignal();
|
||||
|
||||
Utils::Signal<Scheduler::Callback> copy(Scheduler::FrameOnceSignal);
|
||||
Scheduler::FrameOnceSignal.clear();
|
||||
copy();
|
||||
}
|
||||
|
||||
void Scheduler::OnDelay(Utils::Slot<Scheduler::Callback> callback, std::chrono::nanoseconds delay)
|
||||
{
|
||||
Scheduler::DelayedSlot slot;
|
||||
slot.callback = callback;
|
||||
slot.delay = delay;
|
||||
|
||||
Scheduler::DelayedSlots.push_back(slot);
|
||||
}
|
||||
|
||||
void Scheduler::DelaySignal()
|
||||
{
|
||||
Utils::Signal<Scheduler::Callback> signal;
|
||||
|
||||
for (auto i = Scheduler::DelayedSlots.begin(); i != Scheduler::DelayedSlots.end();)
|
||||
{
|
||||
if (i->interval.elapsed(i->delay))
|
||||
{
|
||||
signal.connect(i->callback);
|
||||
i = Scheduler::DelayedSlots.erase(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
signal();
|
||||
}
|
||||
|
||||
Scheduler::Scheduler()
|
||||
{
|
||||
Scheduler::ReadyPassed = false;
|
||||
Scheduler::Once(Scheduler::ReadyHandler);
|
||||
}
|
||||
|
||||
Scheduler::~Scheduler()
|
||||
{
|
||||
Scheduler::FrameOnceSignal.clear();
|
||||
Scheduler::FrameSignal.clear();
|
||||
}
|
||||
}
|
41
src/Components/Modules/Scheduler.hpp
Normal file
41
src/Components/Modules/Scheduler.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
namespace Components
|
||||
{
|
||||
class Scheduler : public Component
|
||||
{
|
||||
public:
|
||||
typedef void(Callback)();
|
||||
|
||||
Scheduler();
|
||||
~Scheduler();
|
||||
|
||||
static void OnShutdown(Utils::Slot<Callback> callback);
|
||||
static void OnFrame(Utils::Slot<Callback> callback);
|
||||
static void OnReady(Utils::Slot<Callback> callback);
|
||||
static void Once(Utils::Slot<Callback> callback);
|
||||
static void OnDelay(Utils::Slot<Callback> callback, std::chrono::nanoseconds delay);
|
||||
|
||||
static void FrameHandler();
|
||||
|
||||
private:
|
||||
class DelayedSlot
|
||||
{
|
||||
public:
|
||||
std::chrono::nanoseconds delay;
|
||||
Utils::Time::Interval interval;
|
||||
Utils::Slot<Callback> callback;
|
||||
};
|
||||
|
||||
static Utils::Signal<Callback> FrameSignal;
|
||||
static Utils::Signal<Callback> FrameOnceSignal;
|
||||
static std::vector<DelayedSlot> DelayedSlots;
|
||||
|
||||
static bool ReadyPassed;
|
||||
static Utils::Signal<Callback> ReadySignal;
|
||||
static Utils::Signal<Callback> ShutdownSignal;
|
||||
|
||||
static void ReadyHandler();
|
||||
static void DelaySignal();
|
||||
};
|
||||
}
|
@ -8,7 +8,7 @@ namespace Components
|
||||
std::vector<std::string> Script::ScriptNameStack;
|
||||
unsigned short Script::FunctionName;
|
||||
|
||||
Utils::Signal<Script::Callback> Script::VMShutdownSignal;
|
||||
Utils::Signal<Scheduler::Callback> Script::VMShutdownSignal;
|
||||
|
||||
void Script::FunctionError()
|
||||
{
|
||||
@ -247,7 +247,7 @@ namespace Components
|
||||
Script::ScriptFunctions.push_back({ name, function, isDev });
|
||||
}
|
||||
|
||||
void Script::OnVMShutdown(Utils::Slot<Script::Callback> callback)
|
||||
void Script::OnVMShutdown(Utils::Slot<Scheduler::Callback> callback)
|
||||
{
|
||||
Script::VMShutdownSignal.connect(callback);
|
||||
}
|
||||
|
@ -6,8 +6,6 @@ namespace Components
|
||||
class Script : public Component
|
||||
{
|
||||
public:
|
||||
typedef void(Callback)();
|
||||
|
||||
class Function
|
||||
{
|
||||
public:
|
||||
@ -29,7 +27,7 @@ namespace Components
|
||||
static int LoadScriptAndLabel(std::string script, std::string label);
|
||||
static void AddFunction(std::string name, Game::scr_function_t function, bool isDev = false);
|
||||
|
||||
static void OnVMShutdown(Utils::Slot<Callback> callback);
|
||||
static void OnVMShutdown(Utils::Slot<Scheduler::Callback> callback);
|
||||
|
||||
private:
|
||||
static std::string ScriptName;
|
||||
@ -38,7 +36,7 @@ namespace Components
|
||||
static std::vector<std::string> ScriptNameStack;
|
||||
static unsigned short FunctionName;
|
||||
|
||||
static Utils::Signal<Callback> VMShutdownSignal;
|
||||
static Utils::Signal<Scheduler::Callback> VMShutdownSignal;
|
||||
|
||||
static void CompileError(unsigned int offset, const char* message, ...);
|
||||
static void PrintSourcePos(const char* filename, unsigned int offset);
|
||||
|
@ -849,11 +849,11 @@ namespace Components
|
||||
UIScript::AddOwnerDraw(253, ServerList::UpdateGameType);
|
||||
|
||||
// Add frame callback
|
||||
Renderer::OnFrame(ServerList::Frame);
|
||||
Scheduler::OnFrame(ServerList::Frame);
|
||||
|
||||
// This is placed here in case the anticheat has been disabled!
|
||||
#if !defined(DEBUG) && !defined(DISABLE_ANTICHEAT) && defined(PROCTECT_PROCESS)
|
||||
Renderer::OnFrame(AntiCheat::ReadIntegrityCheck);
|
||||
Scheduler::OnFrame(AntiCheat::ReadIntegrityCheck);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ namespace Components
|
||||
|
||||
QuickPatch::OnReady([]()
|
||||
{
|
||||
Renderer::OnFrame(Toast::Handler);
|
||||
Scheduler::OnFrame(Toast::Handler);
|
||||
});
|
||||
|
||||
Command::Add("testtoast", [] (Command::Params*)
|
||||
|
@ -140,7 +140,7 @@ namespace Components
|
||||
Utils::Hook(0x48E5D3, Window::DrawCursorStub, HOOK_CALL).install()->quick();
|
||||
|
||||
// Draw the cursor if necessary
|
||||
Renderer::OnFrame([] ()
|
||||
Scheduler::OnFrame([] ()
|
||||
{
|
||||
if (Window::NativeCursor.get<bool>() && IsWindow(Window::MainWindow) && GetForegroundWindow() == Window::MainWindow && Window::IsCursorWithin(Window::MainWindow))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user