[Scheduler] Distinguish between dedi and client interface

This commit is contained in:
momo5502 2017-06-01 10:25:13 +02:00
parent 38e4f75411
commit fe3e37347d
11 changed files with 41 additions and 40 deletions

View File

@ -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();
if(!Dedicated::IsEnabled() && !ZoneBuilder::IsEnabled()) Scheduler::OnFrame(AntiCheat::PerformScan);
Scheduler::OnFrame(AntiCheat::PerformScan, true);
// Detect aimbots
Utils::Hook(0x426580, AntiCheat::DObjGetWorldTagPosStub, HOOK_JUMP).install()->quick();

View File

@ -161,7 +161,7 @@ namespace Components
lastValidName = name;
Friends::UpdateName();
}
});
}, true);
std::string username = "Unknown Soldier";

View File

@ -174,7 +174,6 @@ namespace Components
#ifdef DEBUG
// Display DEBUG branding, so we know we're on a debug build
if (!Dedicated::IsEnabled() && !ZoneBuilder::IsEnabled()) {
Scheduler::OnFrame([]()
{
Game::Font* font = Game::R_RegisterFont("fonts/normalFont", 0);
@ -189,8 +188,7 @@ namespace Components
}
Game::R_AddCmdDrawText("DEBUG-BUILD", 0x7FFFFFFF, font, 15.0f, 10.0f + Game::R_TextHeight(font), 1.0f, 1.0f, 0.0f, color, Game::ITEM_TEXTSTYLE_SHADOWED);
});
}
}, true);
#endif
#if !defined(DEBUG) || defined(FORCE_EXCEPTION_HANDLER)
Exception::SetFilterHook.initialize(SetUnhandledExceptionFilter, Exception::SetUnhandledExceptionFilterStub, HOOK_JUMP);

View File

@ -568,7 +568,7 @@ namespace Components
{
if (FastFiles::Current().empty() || !Dvar::Var("ui_zoneDebug").get<bool>()) return;
Game::Font* font = Game::R_RegisterFont("fonts/consoleFont", 0); // Inlining that seems to skip xpos, no idea why xD
Game::Font* font = Game::R_RegisterFont("fonts/consoleFont", 0);
float color[4] = { 1.0f, 1.0f, 1.0f, (Game::CL_IsCgameInitialized() ? 0.3f : 1.0f) };
std::uint32_t FFTotalSize = *reinterpret_cast<std::uint32_t*>(0x10AA5D8);
@ -585,7 +585,7 @@ namespace Components
}
Game::R_AddCmdDrawText(Utils::String::VA("Loading FastFile: %s [%0.1f%%]", FastFiles::Current().data(), fastfileLoadProgress), 0x7FFFFFFF, font, 5.0f, static_cast<float>(Renderer::Height() - 5), 1.0f, 1.0f, 0.0f, color, Game::ITEM_TEXTSTYLE_NORMAL);
});
}, true);
Command::Add("loadzone", [] (Command::Params* params)
{

View File

@ -1007,7 +1007,7 @@ namespace Components
{
Command::Execute("closemenu popup_reconnectingtoparty", false);
Command::Execute("reconnect", false);
}, 6s);
}, 6s, true);
});
if(Dedicated::IsEnabled())
@ -1104,7 +1104,7 @@ namespace Components
{
Game::R_AddCmdDrawText(Utils::String::VA("%d %s", model.second, model.first.data()), 0x7FFFFFFF, font, 15.0f, (height * scale + 1) * (i++ + 1) + 15.0f, scale, scale, 0.0f, color, Game::ITEM_TEXTSTYLE_NORMAL);
}
});
}, true);
}
Maps::~Maps()

View File

@ -193,7 +193,7 @@ namespace Components
// float color[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
//
// Game::R_AddCmdDrawText("test^==preview_mp_rustzob", 0x7FFFFFFF, font, 500.0f, 150.0f, 1.0f, 1.0f, 0.0f, color, Game::ITEM_TEXTSTYLE_SHADOWED);
// });
// }, true);
}
Materials::~Materials()

View File

@ -290,7 +290,7 @@ namespace Components
Party::ConnectError("Playlist request timed out.");
}
}
});
}, true);
// Basic info handler
Network::Handle("getInfo", [] (Network::Address address, std::string data)

View File

@ -656,15 +656,13 @@ namespace Components
// Constantly draw the mini console
Utils::Hook::Set<BYTE>(0x412A45, 0xEB);
if (!Dedicated::IsEnabled() && !ZoneBuilder::IsEnabled()) {
Scheduler::OnFrame([]()
{
if (*reinterpret_cast<Game::Font**>(0x62E4BAC))
{
Game::Con_DrawMiniConsole(0, 2, 4, (Game::CL_IsCgameInitialized() ? 1.0f : 0.4f));
}
});
}
}, true);
#else
// Remove missing tag message
Utils::Hook::Nop(0x4EBF1A, 5);

View File

@ -10,8 +10,9 @@ namespace Components
Utils::Signal<Scheduler::Callback> Scheduler::FrameOnceSignal;
std::vector<Scheduler::DelayedSlot> Scheduler::DelayedSlots;
void Scheduler::Once(Utils::Slot<Scheduler::Callback> callback)
void Scheduler::Once(Utils::Slot<Scheduler::Callback> callback, bool clientOnly)
{
if (clientOnly && (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled())) return;
Scheduler::FrameOnceSignal.connect(callback);
}
@ -20,13 +21,15 @@ namespace Components
Scheduler::ShutdownSignal.connect(callback);
}
void Scheduler::OnFrame(Utils::Slot<Scheduler::Callback> callback)
void Scheduler::OnFrame(Utils::Slot<Scheduler::Callback> callback, bool clientOnly)
{
if (clientOnly && (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled())) return;
Scheduler::FrameSignal.connect(callback);
}
void Scheduler::OnReady(Utils::Slot<Scheduler::Callback> callback)
void Scheduler::OnReady(Utils::Slot<Scheduler::Callback> callback, bool clientOnly)
{
if (clientOnly && (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled())) return;
if (Scheduler::ReadyPassed) Scheduler::Once(callback);
else Scheduler::ReadySignal.connect(callback);
}
@ -57,8 +60,10 @@ namespace Components
copy();
}
void Scheduler::OnDelay(Utils::Slot<Scheduler::Callback> callback, std::chrono::nanoseconds delay)
void Scheduler::OnDelay(Utils::Slot<Scheduler::Callback> callback, std::chrono::nanoseconds delay, bool clientOnly)
{
if (clientOnly && (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled())) return;
Scheduler::DelayedSlot slot;
slot.callback = callback;
slot.delay = delay;

View File

@ -11,10 +11,10 @@ namespace Components
~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 OnFrame(Utils::Slot<Callback> callback, bool clientOnly = false);
static void OnReady(Utils::Slot<Callback> callback, bool clientOnly = false);
static void Once(Utils::Slot<Callback> callback, bool clientOnly = false);
static void OnDelay(Utils::Slot<Callback> callback, std::chrono::nanoseconds delay, bool clientOnly = false);
static void FrameHandler();

View File

@ -853,7 +853,7 @@ namespace Components
// This is placed here in case the anticheat has been disabled!
#if !defined(DEBUG) && !defined(DISABLE_ANTICHEAT) && defined(PROCTECT_PROCESS)
if(!Dedicated::IsEnabled() && !ZoneBuilder::IsEnabled()) Scheduler::OnFrame(AntiCheat::ReadIntegrityCheck);
Scheduler::OnFrame(AntiCheat::ReadIntegrityCheck, true);
#endif
}