Markasium CS2 sheetSheet Note N2 · Sheet 07 TR / EN

Note N2 · Markasium CS2

SERVER-SIDE ANTI-WALLHACK (FOW)

A server-side answer to CS2 wallhacks: never send the opponent the player shouldn't see

Sheet
MARKASIUM CS2
Topic
CS2 · C# · CheckTransmit
Source
OSAntiCheat/Markasium/FowShadow.cs
Date
2026-11-12
Reading
4 min

Short answer: instead of trying to catch wallhacks and radar hacks on the client, cut the information on the server. For every pair of players, test whether the opponent is visible against the map geometry, and never send that player the hidden opponent's body, weapons or attached entities (CheckTransmit). No cheat can draw data it never received. The hard part is not hiding but not breaking legitimate play: ping-based prediction, close range, footstep and team radar exceptions, and hysteresis to stop flickering in and out.

01The idea

A wallhack draws positions the client already knows. A CS2 server normally sends every nearby player's data to every player; standing behind a wall changes nothing. Server-side hiding (fog of war) cuts that transmission: the opponent a player shouldn't see does not exist for them.

There is no way for a cheater to bypass it; the server never leaks a position it didn't send. That is why FOW is the first layer of the Markasium anti-cheat: deny the information before trying to detect anything.

02A decision for every pair

Hiding is computed every two ticks and only for real players; bots don't need network packets. For every viewer × opponent pair, decisions are made in order; the first rule that holds wins:

  • Teammate: always sent (except in FFA modes).
  • Close range: an opponent within 350 units (~9 m) is never hidden.
  • Fire or damage: when shots are fired or damage is taken, the opponent stays visible for a short while.
  • Line of sight: sent if there is a direct line from the viewer's eye to at least one sample point on the opponent's body. The test runs against the map's pre-built geometry (BVH) and the smoke grenades active at that moment.
  • Prediction: if neither sees the other now, a short time ahead is predicted (below).
  • Footsteps: a running opponent within 1,000 units is sent; the player already hears them.
  • Team radar: sent if someone on the viewer's team has spotted the opponent; the legitimate radar keeps working, and a radar hack sees no more than it.
  • Hysteresis: not hidden for 24 ticks after last being seen.
  • If none of these holds, the opponent is hidden from that viewer.

03Ping-based prediction

The known side effect of hiding is "pop-in": an opponent stepping out from a corner is invisible for an instant, because the client runs a few milliseconds ahead of the server. To prevent it, both the opponent's and the viewer's positions are moved forward by their velocity; if either enters line of sight within that window, the opponent is sent already.

float rtt = Math.Clamp(rx.Ping / 1000f, 0f, 0.4f);
float obsLead = MathF.Max(0.15f, rtt + 0.1f);       // viewer
float enLead  = MathF.Max(0.15f, rtt * 0.5f + 0.1f); // opponent

Vector3 predFeet = ep.feet + ep.velocity * enLead;
Vector3 predEye  = rp.eye  + rp.velocity * obsLead;

A fixed 150 ms was not enough at high ping. The window now grows with ping (at least 150, at most 500 ms): a high-ping player gets slightly less hiding, but opponents don't appear late. The trade-off between security and playability deliberately favours playability.

04Stopping the flicker

An opponent standing on the edge of visibility can flip between visible and hidden every tick. On every flip the client deletes and recreates the entity; that means flicker on screen and errors in the engine. Two measures:

  • An opponent keeps being sent for 24 ticks after last being seen.
  • The footstep rule uses two speed thresholds (a Schmitt trigger): once an opponent counts as "heard", they stay so until they drop below a lower speed.

05Hiding the body is not enough

The first version hid the opponent's body and the weapon in hand. Measurements showed two leaks:

  • Their other weapons (pistol, knife, grenades, C4) were still sent, and a weapon's position is the player's position. Now all of a player's weapons are hidden.
  • Other entities were attached to the player: glow effects, cosmetic props, a chicken a plugin attached to follow the player. They leaked position and could crash the client once their owner was hidden. Now every child entity attached to the player (up to 4 levels of parents) is hidden too.

Walking the whole map on every scan to find attached entities took about 6 ms in a single tick on one map. Now only newly spawned entities enter the candidate list, with one full scan when the plugin loads; a candidate not attached to a player within 5 seconds drops off the list. The scan runs every half second and its measured cost is 0.2 ms.

06Don't turn it on without measuring

An earlier version claimed "FOW on, 0% late appearance"; measurement showed the hiding wasn't working at all. So hiding now sits behind a measurement gate: it does not switch on automatically until enough hits from real players have been collected. Wallbang hits and test accounts' hits are counted separately from the measurement. The reason behind each pair's decision (visible, prediction, footsteps, radar, hysteresis, hidden) is kept and logged on demand; when a player says "the opponent appeared late", the rule that made the call can be found.

→More notes from this project

—End of notewritten by MUHAMMEDPYZ