What you see
- Players are dropped from an online game, often at a repeatable moment.
- The game writes a folder under
Documents\Warcraft III\Errorswith aDesync.txtand a replay. - Testing alone never shows it.
Why it happens
GetLocalPlayer() returns a different player on each machine, so code inside if GetLocalPlayer() == p then runs on one client only. If that code creates a handle (a unit, group, timer, effect or location) or changes game state (moves a unit, issues an order, rolls a random number), the clients drift apart. ForGroup and ForForce inside such a block desync reliably.
Some values differ between machines by nature, such as camera positions and others the documentation marks as asynchronous. Using them to change game state desyncs.
In Lua maps, pairs() can visit table keys in a different order on each client. A loop that damages units or hands out rewards in that order desyncs. So can tostring on game objects, and GetHandleId used in local code.
How to fix it
- Do every handle-creating and state-changing call on all clients. Branch on the local player only to choose a value: a model path, a text, a transparency, whether a frame is visible.
- Per-player effects: choose the model path inside the local branch (empty for everyone else) and create the effect outside it, so every client creates it.
- Create UI frames for all players, then show, hide or set their text locally.
- Lua: iterate arrays with a numeric
fororipairs. For sets, keep a separate array of keys or use a table type that remembers insertion order. - If a desync still happens, note the game time and the Errors folder, then check what runs at that moment.
How WC3 Map Doctor detects it
- SevereA handle is created or game state changes inside a GetLocalPlayer branch, which desyncs the other players.DESYNC-localplayer-handle
- SevereA pairs() or next() loop changes game state, and the iteration order differs between clients, so the game desyncs.DESYNC-lua-pairs-state
Desync fixes need to know what the author meant, so they are reported with the line, not changed automatically. The example report leaves one in place and says why.
Sources
Written in our own words from our lab notes; these are the pages behind them.