mirror of
https://github.com/R2Northstar/NorthstarLauncher
synced 2026-08-23 20:26:04 -04:00
Set execution markers properly (#849)
Set execution markers properly if there's enough room or ignore command otherwise. Stops servers from executing commands on the client if not in vanilla. Co-authored-by: RoyalBlue1 <11448698+RoyalBlue1@users.noreply.github.com>
This commit is contained in:
parent
1277b3711d
commit
8290f7b3c0
1 changed files with 21 additions and 1 deletions
|
|
@ -14,6 +14,8 @@ ConVar* Cvar_ns_should_log_all_clientcommands;
|
|||
|
||||
ConVar* Cvar_sv_cheats;
|
||||
|
||||
int* g_ExecutionMarkerCount;
|
||||
|
||||
#define BLOCKED_INFO(s) \
|
||||
( \
|
||||
[=]() -> bool \
|
||||
|
|
@ -294,6 +296,24 @@ bool, __fastcall, (const char* pModName)) // 48 83 EC 28 48 8B 0D ? ? ? ? 48 8D
|
|||
return (!strcmp("r2", pModName) || !strcmp("r1", pModName)) && !CommandLine()->CheckParm("-norestrictservercommands");
|
||||
}
|
||||
|
||||
// Checks if there's room left for execution markers
|
||||
bool Cbuf_HasRoomForExecutionMarkers(const int marker)
|
||||
{
|
||||
return (*g_ExecutionMarkerCount + marker) < 2048;
|
||||
}
|
||||
|
||||
// Set execution markers properly if there's space
|
||||
// If not enough space, ignore command
|
||||
// clang-format off
|
||||
AUTOHOOK(CBaseClientState_ProcessStringCmd, engine.dll + 0x1A1C20,
|
||||
bool, __fastcall, (CBaseClient* self, int64_t a2))
|
||||
// clang-format on
|
||||
{
|
||||
if (!Cbuf_HasRoomForExecutionMarkers(2))
|
||||
return true;
|
||||
return CBaseClientState_ProcessStringCmd(self, a2);
|
||||
}
|
||||
|
||||
// ratelimit stringcmds, and prevent remote clients from calling commands that they shouldn't
|
||||
// clang-format off
|
||||
AUTOHOOK(CGameClient__ExecuteStringCommand, engine.dll + 0x1022E0,
|
||||
|
|
@ -428,7 +448,7 @@ bool, __fastcall, (void* a1))
|
|||
ON_DLL_LOAD("engine.dll", EngineExploitFixes, (CModule module))
|
||||
{
|
||||
AUTOHOOK_DISPATCH_MODULE(engine.dll)
|
||||
|
||||
g_ExecutionMarkerCount = module.Offset(0x130DE8F0).RCast<int*>();
|
||||
// allow client/ui to run clientcommands despite restricting servercommands
|
||||
module.Offset(0x4FB65).Patch("EB 11");
|
||||
module.Offset(0x4FBAC).Patch("EB 16");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue