On this page
Server-side vs client-side mods
"If I add boost to a vehicle and use that mod on my server, do clients need it?" It depends on which lines you change. Every template property and every data file has a scope: the server reads it, the game client reads it, or both do. This page explains the three scopes, how bf2-rs works them out, and walks through three mods. Every property's scope is a badge per game in the cross-game command table (the scope table keeps the file types), the unified reference finds one name in all three games, and the web editor shows the same scope as a badge next to each property.
The three scopes#
The reference tables call the third scope shared (both in scope.json and the editor's B badge).
| Scope | Who reads it | A mod on the server alone | Players need the mod |
|---|---|---|---|
| server | only the server | takes effect for everyone | no |
| client | only the game client (drawing, sound, HUD) | changes nothing anyone sees | yes, each player who should see it |
| shared | the server and every client | the server's result is right, but each client computes its own view with the old value | yes, the same version as the server |
"Both" is the case that surprises people. A client does not just display what the server sends: it predicts its own soldier and vehicle, fires its own weapon locally, and builds the same object tree as the server. If its copy of a value differs, it predicts wrong and then snaps to the server's answer (rubber-banding, shots that seem to go elsewhere, a speedometer that lies).
A server with the content check on compares an MD5 of the client's ClientArchives.con, ServerArchives.con, Init.con, GameLogicInit.con and of pieces of every mounted archive with its own (runMiscChecksum / runArchiveChecksum, BF2.exe!0x006b57f0 / 0x006b6170, bf2-rs crates/bf2-fs/src/checksum.rs). On such a server even a client-only mod has to be the server's exact files.
How the files are split#
Each mod folder has two archive lists. ServerArchives.con mounts the *_server.zip archives (template scripts, collision meshes, AI, animations), ClientArchives.con the *_client.zip archives (meshes, textures, sounds, effects, fonts, shaders). The dedicated server mounts only the server list; the game client mounts both, server list first (mod start-up bf2_w32ded.exe!0x00404500, BF2.exe!0x00408ef0; bf2-rs crates/bf2-fs/src/startup.rs mount_mod). The shipped dedicated server packages hold no _client archive at all. So:
- a file that only exists in a
_clientarchive (.dds,.tga,.staticmesh,.bundledmesh,.skinnedmesh,.ogg,.wav,.fx, ...) is client: the server never sees it; - a file in a
_serverarchive is read by the server and by every client (they mount it too). Whether the client actually uses a given line decides its scope..aifiles are the exception that is server only: bots run in the server.
Level folders work the same way: Levels/<name>/server.zip and client.zip. StaticObjects.con is both (each side builds the statics from its own copy). In GamePlayObjects.con both sides run the template definitions at the top, but the placements (Object.create and its position lines for spawners, control points and spawn points) sit inside if v_arg1 == host and run on the server only: moving a spawner is server, the clients get the objects over the network (crates/bf2-engine/src/level.rs runs the file with host or client).
How a property's scope is worked out#
tools/bfheroes/mod_scope.py derives every scope from the data the engine is built from, in this order (the table's Basis column names the step that decided):
- Retail behaviour - a short list of properties where the original game's behaviour is clear and bf2-rs's reads say less, for example
ObjectTemplate.damage(the server applies damage; clients receive hit points). - Rule - whole families: the AI templates (
aiTemplate,aiTemplatePlugIn,kitTemplateandweaponTemplatestrengths) are server;NetworkableInfo(the object's network format) andCollisionManagerare both. - Retail registry - a command only the game client registers (
BF2.exeorRendDX9.dll, notbf2_w32ded.exe) is client: the dedicated server does not even know the line (everyhudBuildercommand,weaponHud.*,vehicleHud.*,GeometryTemplate.*). A property the dedicated server accepts and ignores (re/data/template_properties.tsv categorynoop) is client too. bf2-rs does the same: its template host only has the client-only commands when it runs as the client (crates/bf2-objects/src/template/host.rsTemplateHost::new). - bf2-rs reads - which crates read the property: its generated field in
crates/bf2-objects/src/template/props.rsor its name as a string, in the server crates (bf2-server,bfh-server,bf2-ai), the client crates (bf2-client,bfh-client,bf2-hud,bf2-render,bf2-audio,bf2-effects, ...) or the shared simulation both run (bf2-world,bf2-gameplay,bf2-physics, ...). A client-only read of a value the dedicated server stores counts as both unless it is presentation (sound, HUD, effects); a server-only read of a simulation value (mass, drag, speed, torque) counts as both, because clients predict their own soldier and vehicle with it. - Name - a 2142 or Heroes property bf2-rs does not read yet, named like presentation (hud, sound, effect, light, camera), is client.
- Retail reads - what the original code itself reads (
tools/bfheroes/template_reads.pyover the decompiled game clientBF2.exeand dedicated serverbf2_w32ded.exe, kept intools/bfheroes/template_reads.yaml): a template field the dedicated server's code reads through a template pointer is both; one only the client's code reads, at an offset the server never names, is client. Battlefield 2142 commands its dedicated server (bf2142ded) does not register are client, as in step 3; the others take their field from the 2142 server's setter and are read the same way inbf2142ded(the Linux dedicated server) andBF2142.exe. A read counts only for the template type of the reading function's class (or a type along its inheritance), so another template's field at the same offset does not count; a read whose function has no known class is left out. - Default - anything else is both: nobody has shown that the clients ignore it, so keep server and clients the same. Most of these are Heroes-only commands: Battlefield Heroes shipped no dedicated server binary to compare its client with.
The table is rebuilt from the code on every wiki build, so it follows bf2-rs as more of the engine is read.
Worked example 1: more speed for a jeep#
Michael's mod: make Battlefield 2's HMMWV faster. Its speed comes from the Engine template in Objects/Vehicles/Land/USJEP_HMMWV/USJEP_HMMWV.tweak (in Objects_server.zip):
ObjectTemplate.activeSafe Engine USJEP_HMMWV_Engine
ObjectTemplate.setEngineType c_ETNewCar2
ObjectTemplate.setTorque 225
ObjectTemplate.setDifferential 4
ObjectTemplate.setGearRatios 2.25 1.25 1 0.6 0.6
ObjectTemplate.newCar2.maxRpm 4000| Line | Scope | Why |
|---|---|---|
setTorque, setDifferential, newCar2.maxRpm | shared | the vehicle simulation; the driver's client predicts its own vehicle with them |
setGearRatios, setEngineType | shared | read by the shared vehicle code (bf2-world vehicle.rs) |
soundFilename of the engine sounds | client | only the client plays sounds |
Answer: clients need the mod. On the server alone the jeep really is faster (the server simulates it and every other player sees the server's position), but its driver's client keeps predicting the old speed and is pulled forward every update. A Heroes jeep's boost flame (statusGLEffect.effectName E_wheel_Boost) is client only.
Worked example 2: a new weapon's damage#
A harder-hitting M16A2: Weapons/Handheld/usrif_m16a2/USRIF_M16A2.tweak.
ObjectTemplate.fire.roundsPerMinute 900
ObjectTemplate.projectileTemplate M16a2Projectile
ObjectTemplate.velocity 1000
ObjectTemplate.create GenericProjectile M16a2Projectile
ObjectTemplate.minDamage 1
ObjectTemplate.damage 30| Line | Scope | Why |
|---|---|---|
damage, minDamage, distToMinDamage | server | the server applies damage; clients only receive the hit points |
fire.roundsPerMinute, velocity, projectileTemplate | shared | the shooter's client fires the weapon locally (rate, muzzle flash, tracer) |
weaponHud.weaponIcon | client | the HUD; the dedicated server does not know the command |
Answer: changing only the damage is a pure server mod. Changing the rate of fire or the muzzle velocity is not: the shooter would see a different weapon from the one the server simulates.
Worked example 3: a new HUD icon#
A new weapon icon is a .tga / .dds under Menu/HUD/... or Objects/Weapons/.../Icons (a _client archive) and the ObjectTemplate.weaponHud.weaponIcon line that names it (client only: BF2.exe registers it, the dedicated server does not). Answer: a client mod. The server needs nothing; every player who should see the icon installs it (and on a pure server it must still match the server's files).
In the editor#
The web editor's inspector shows a scope badge (S, C, B) next to every property of the selected object's template chain (hover it for the reason), and its Mod scope line says what a change to the object needs. The same lookup tells an overlay what it needs: this overlay needs: the server only / every client / server and clients (web/editor/src/engine/scope.ts overlayNeeds).
Scopes generated by tools/bfheroes/mod_scope.py (docs/dev/modding/scope.json).
How it is tested#
- The table is generated from the code (
tools/bfheroes/mod_scope.py): which crate reads a property decides its scope, and the tool's own tests hold its rules (tools/bfheroes/test_mod_scope.py). - Kept current: the wiki's publish reports when the committed scope file no longer matches the code, and the editor's checks fail on a stale one.
- In play: on a pure server a client whose files differ from the server's fails the content check, whose lists every shipped level passes (server start-up).
A property with the scope "default" is read by nothing in the port yet; that it must be equal on both sides is the safe assumption, not a tested fact.
In the code#
The crates this page names, each with its line of docs/release/LAYOUT.md (the list is gathered by the wiki's build from the page itself):
| Crate | What it is |
|---|---|
crates/bf2-fs | the engine's file system: file manager, archives |
crates/bf2-objects | the object model: class and interface ids, templates, objects |
crates/bf2-world | the runtime object world: objects from templates, object manager, hierarchy, tick order |
crates/bf2-ai | bot AI: navigation data formats and pathfinding |
crates/bf2-audio | the sound system: decoders, sound templates, mixing rules |
crates/bf2-client | the client's engine assembly as a library: boot, console, profiles, movies, join, level load, frame loop |
crates/bf2-effects | visual effects: templates and the simulation of particles, decals and lights |
crates/bf2-engine | engine assembly shared by the programs: command line, start-up and level-load order, main loop timing, localization, settings |
Files this page names: crates/bf2-fs/src/checksum.rs, crates/bf2-fs/src/startup.rs, crates/bf2-engine/src/level.rs, crates/bf2-objects/src/template/host.rs, crates/bf2-objects/src/template/props.rs.
docs/dev/modding/server-vs-client.md · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.