aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeckoEidechse <gecko.eidechse+git@pm.me>2022-06-16 01:00:38 +0200
committerGeckoEidechse <gecko.eidechse+git@pm.me>2022-06-16 01:00:38 +0200
commit96df08b6133eab68a4e9b4eb85e5c15b4c7a7532 (patch)
treef3fea7c91fa25d555e1cef1e83ca96777a305c32
parentd9f39f14fa0b0e8d025a8deef1d0c85da89c31f6 (diff)
downloadNorthstarLauncher-96df08b6133eab68a4e9b4eb85e5c15b4c7a7532.tar.gz
NorthstarLauncher-96df08b6133eab68a4e9b4eb85e5c15b4c7a7532.zip
Splice out grapple fixes from #193
-rw-r--r--NorthstarDedicatedTest/ExploitFixes.cpp63
1 files changed, 16 insertions, 47 deletions
diff --git a/NorthstarDedicatedTest/ExploitFixes.cpp b/NorthstarDedicatedTest/ExploitFixes.cpp
index af7d48ac..79287d4d 100644
--- a/NorthstarDedicatedTest/ExploitFixes.cpp
+++ b/NorthstarDedicatedTest/ExploitFixes.cpp
@@ -35,9 +35,9 @@ struct Vector
Vector(float x = 0, float y = 0, float z = 0) : x(x), y(y), z(z) {}
- bool IsValid()
+ bool IsInvalid()
{
- return ValidateFloats(x, y, z);
+ return !ValidateFloats(x, y, z);
}
};
@@ -260,60 +260,29 @@ KHOOK(ReadUsercmd, ("server.dll", "4C 89 44 24 ? 53 55 56 57"), void, __fastcall
std::string BLOCK_PREFIX =
"ReadUsercmd (command_number delta: " + std::to_string(cmd->command_number - fromCmd->command_number) + "): ";
- if (cmd->worldViewAngles.IsInvalid())
- {
- BLOCKED_INFO("CMD has invalid worldViewAngles");
- goto INVALID_CMD;
- }
+#define FORCE_3_VALID(name) \
+ if (name.IsInvalid()) \
+ name = {0, 0, 0}
- if (cmd->attackangles.IsInvalid())
- {
- BLOCKED_INFO("CMD has invalid attackangles");
- goto INVALID_CMD;
- }
+ FORCE_3_VALID(cmd->localViewAngles);
+ FORCE_3_VALID(cmd->cameraAngles);
+ FORCE_3_VALID(cmd->attackangles);
+ FORCE_3_VALID(cmd->worldViewAngles);
- if (cmd->localViewAngles.IsInvalid())
- {
- BLOCKED_INFO("CMD has invalid localViewAngles");
- goto INVALID_CMD;
- }
-
- if (cmd->cameraAngles.IsInvalid())
- {
- BLOCKED_INFO("CMD has invalid cameraAngles");
- goto INVALID_CMD;
- }
+ FORCE_3_VALID(cmd->cameraPos);
+ FORCE_3_VALID(cmd->move);
if (cmd->frameTime <= 0 || cmd->tick_count == 0 || cmd->command_time <= 0)
{
BLOCKED_INFO(
"Bogus cmd timing (tick_count: " << cmd->tick_count << ", frameTime: " << cmd->frameTime
<< ", commandTime : " << cmd->command_time << ")");
- goto INVALID_CMD; // No simulation of bogus-timed cmds
+ // Fix any gameplay-affecting cmd properties
+ // NOTE: Currently tickcount/frametime is set to 0, this ~shouldn't~ cause any problems
+ cmd->tick_count = cmd->frameTime = 0;
+ cmd->buttons = 0;
+ cmd->meleetarget = 0;
}
-
- if (!cmd->move.IsValid())
- {
- BLOCKED_INFO("Invalid move vector");
- goto INVALID_CMD;
- }
-
- if (!cmd->cameraPos.IsValid())
- {
- BLOCKED_INFO("Invalid cameraPos"); // IIRC this can crash spectating clients or anyone watching replays
- goto INVALID_CMD;
- }
-
- return;
-INVALID_CMD:
-
- // Fix any gameplay-affecting cmd properties
- // NOTE: Currently tickcount/frametime is set to 0, this ~shouldn't~ cause any problems
- cmd->worldViewAngles = cmd->localViewAngles = cmd->attackangles = cmd->cameraAngles = Angle(0, 0, 0);
- cmd->tick_count = cmd->frameTime = 0;
- cmd->move = cmd->cameraPos = Vector(0, 0, 0);
- cmd->buttons = 0;
- cmd->meleetarget = 0;
}
// basically: by default r2 isn't set as a valve mod, meaning that m_bRestrictServerCommands is false