On this page
Settings and profiles: where the game keeps what you chose
Refractor 2 has no settings file format. Every setting that is saved is saved as console commands, in a script that the game runs again at the next start. There are two layers: a small typed store that the engine reads, and a set of settings objects behind the options screens, each of which writes one file into the player's profile folder. This page covers both, and the handful of oddities a port has to copy to write the same files.
The settings repository#
The first thing the engine creates (bf2_w32ded.exe!0x00409730, BF2.exe!0x0040fdf0), registered under a name with a typing error that the port keeps, SettingsRepostitory. It is seven independent maps from a name to a value: int, float, unsigned, string, bool, and vectors of three and four. Names are case-sensitive. The same name may exist in several of the maps at once.
Reading a setting never creates it: get answers the stored value or the caller's default.
The engine's defaults#
Registered before the command line is read (0x00403bd0):
| Name | Default | Saved |
|---|---|---|
GSModDirectory | mods/bf2 | |
GSLevelDirectory | Levels/ | |
GSViewDistance | 850 | |
GSPlayerName | DefaultPlayerName | yes |
GSInterpolationTime | 100 | yes |
GSExtrapolationTime | 1200 | yes |
GSDefaultLatencyCompensation | 0.1 | yes |
GSUseObjectCache | true | yes |
GSExtrapolateFrame, GSShowNetGraph | false | yes |
GSPerfLogAtPlayerCount | 30 | yes |
GSUseClientSidePrediction | true | no |
GSUseLatencyCompensation | false | no |
GSFullScreen | true | no |
Nine settings are registered as persistent (the eight marked above and one for the anti-cheat client), and those nine are all that Usersettings.con ever holds. The command line writes more settings, and the level code reads others by name.
Usersettings.con#
Loaded while the subsystems start; saved when the client shuts down. The dedicated server never saves it. The game ships no such file: it appears after the first run.
The writer emits a three-line header and then one line a registered name, in name order:
rem
rem Settingsfile automatically saved by bf2
rem
SettingsManager.floatSet GSDefaultLatencyCompensation 0.100000
SettingsManager.U32Set GSExtrapolationTime 1200
SettingsManager.stringSet GSPlayerName "DefaultPlayerName"
SettingsManager.boolSet GSUseObjectCache 1(four of the nine lines shown). A SettingsManager.*Set command acts only on a registered name: a line for anything else returns 0 and changes nothing. You cannot add a setting by editing the file.
Profiles#
A profile is a folder under the player's documents folder (Battlefield 2/Profiles/<number>), and each file in it is a console script written by one settings object:
| File | Console object | What it holds |
|---|---|---|
Profile.con | LocalProfile | the profile's name and nick, played time, login count |
General.con | GeneralSettings | HUD and crosshair options, bot settings, the server browser's filters, favourites and history: 30 properties |
Audio.con | AudioSettings | volumes, provider, quality, voice chat: 15 properties (voices and space, voice chat) |
Video.con | VideoSettings | resolution, antialiasing, eight quality levels, the view distance scale |
Controls.con | the control maps | key bindings (input) |
ServerSettings.con | sv | the settings of a server you host from the menu: 50 properties |
Haptic.con | HapticSettings | a haptic controller's 224 settings |
Profiles/Global.con names the default profile. Activating a profile runs Profile.con, then each settings object's file, then the demo bookmarks and the profile's map list, and sets GSPlayerName to the profile's nick.
How a float is written#
The settings objects write through a C++ text stream, and the port's writer reproduces its habits so that a file the original wrote is written back byte for byte:
- six significant digits, as
%g:0.5,1.23457e+006; - an exponent has three digits:
1e-005; - negative zero prints
0; - a NaN prints in the old Microsoft spelling,
1.#QNAN, and infinity1.#INF; - a bool prints as a number; line ends are single line feeds.
Some lines are written only sometimes: the audio object writes its "force number of voices" line only for a positive value.
A fresh profile's defaults#
Each settings object has a constructor and a reset, and the options screen's "defaults" button is the reset.
- Video starts at 800 x 600 at 60 Hz, antialiasing off, every quality at its middle level. The real defaults come from the renderer's hardware detection, which picks a low, medium or high preset; that detection is not reimplemented, and the port resets Video without a renderer for now.
- Audio picks its quality from the machine's memory (
0x004b0b80):Lowbelow 768 MB, elseMedium.
The memory is read with a 32-bit call. On a machine with more than 4 GB it reports the largest 32-bit number; the original then adds half a megabyte to round, the sum wraps to zero, and the default sound quality comes out as Low: 16 voices on every modern machine, until the player changes it. The port computes the same.
What differs per game#
The repository and the console-script files are the same idea in all three. 2142 has its own profile folder and volume defaults (music and help voice at 0.5); Heroes keeps a hero's data on its account service's side, which is outside this wiki, and its local options in the same kind of script.
What the port has#
| Part | State |
|---|---|
the repository, the engine's defaults, the Usersettings.con writer | verified from the code; the port's tests reproduce the file |
| the settings objects' writers, console setters and copies | verified in-process against the original; files the original wrote are re-saved byte for byte |
| constructors and resets | verified: 960 written texts and 960 object dumps, no difference |
| the activation order of a profile's files | from the code |
| the renderer's video presets and hardware detection | not reimplemented |
| the event a changed setting raises | not modelled |
How it is tested#
The original's settings objects are constructed, set by random console calls, written and reset inside the original program's own code, and the port's objects are put through the same calls: the written texts and the objects' bytes are compared (the oracle). The Usersettings.con test writes the defaults and compares the text with the one above.
In the code#
| What | Where |
|---|---|
the repository and Usersettings.con | crates/bf2-engine/src/settings.rs |
| the settings objects, their tables and defaults | crates/bf2-engine/src/ (profile_settings, profile_defaults, generated settings_tables.rs, settings_defaults.rs) |
the console's SettingsManager commands | crates/bf2-runtime |
| control maps | crates/bf2-input |
Notes: notes/subsystems/settings-profiles.md, notes/subsystems/input.md (section 9).
docs/dev/engine/settings-and-profiles.md · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.