Skip to content

Commit

Permalink
Improve client-side anti-cheat
Browse files Browse the repository at this point in the history
Based on code from @is-this-c
  • Loading branch information
rafalh committed Feb 22, 2025
1 parent 3733d25 commit 1624e8b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Version 1.9.0 (not released yet)
- Search command descriptions in `.` command
- Improve PF network protocol compatibility
- Add a spawned player count to the scoreboard
- Improve client-side anti-cheat

[@Mystyle-48](https://github.com/Mystyle-48)
- Simplify installation detection in setup and launcher
Expand Down
2 changes: 2 additions & 0 deletions game_patch/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "../rf/os/os.h"
#include "../rf/save_restore.h"
#include "../rf/gameseq.h"
#include "../purefaction/pf_ac.h"

#ifdef HAS_EXPERIMENTAL
#include "../experimental/experimental.h"
Expand Down Expand Up @@ -66,6 +67,7 @@ CodeInjection after_full_game_init_hook{
console_init();
multi_after_full_game_init();
debug_init();
pf_ac_init();

xlog::info("Game fully initialized");
xlog::LoggerConfig::get().flush_appenders();
Expand Down
5 changes: 5 additions & 0 deletions game_patch/os/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "../rf/input.h"
#include "../rf/crt.h"
#include "../main/main.h"
#include "../purefaction/pf_ac.h"
#include "win32_console.h"
#include <xlog/xlog.h>

Expand Down Expand Up @@ -40,6 +41,10 @@ LRESULT WINAPI wnd_proc(HWND wnd_handle, UINT msg, WPARAM w_param, LPARAM l_para
static_cast<void*>(wnd_handle), msg);
}

if (!pf_ac_check_wnd_msg(msg, w_param, l_param)) {
return DefWindowProcA(wnd_handle, msg, w_param, l_param);
}

for (int i = 0; i < rf::num_msg_handlers; ++i) {
rf::msg_handlers[i](msg, w_param, l_param);
}
Expand Down
2 changes: 2 additions & 0 deletions game_patch/purefaction/pf_ac.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ namespace rf {
struct Player;
}

void pf_ac_init();
bool pf_ac_process_packet(const void* data, size_t len, const rf::NetAddr& addr, rf::Player* player);
void pf_ac_init_player(rf::Player* player);
void pf_ac_verify_player(rf::Player* player);
pf_pure_status pf_ac_get_pure_status(rf::Player* player);
bool pf_ac_check_wnd_msg(unsigned msg, long wparam, long lparam);

// callback
void pf_player_verified(rf::Player* player, pf_pure_status pure_status);
9 changes: 9 additions & 0 deletions game_patch/purefaction/pf_ac_stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ bool pf_ac_process_packet(const void*, size_t, const rf::NetAddr&, rf::Player*)
return false;
}

void pf_ac_init()
{
}

void pf_ac_init_player(rf::Player*)
{
}
Expand All @@ -21,3 +25,8 @@ pf_pure_status pf_ac_get_pure_status(rf::Player*)
{
return pf_pure_status::none;
}

bool pf_ac_check_wnd_msg(unsigned msg, long wparam, long lparam)
{
return true;
}

0 comments on commit 1624e8b

Please sign in to comment.