Repository navigation
feat: config values like the binarizer, +=, enums, int64, text output - #51
Merged
Merged
Conversation
Text configs ignored every line starting with #, so macros were left unexpanded and #include was dropped. - rap::Preprocessor: #define (arguments, variadic __VA_* macros, # and ##, multi-line), #undef, #if/#ifdef/#ifndef/#else/#endif, #include, __has_include and the __XXX__ built-ins. - Follows the game where it differs from C: arguments are expanded before # and ##, arguments are not trimmed, ## keeps the whitespace around it, single-quoted strings are expanded, double-quoted not. - Includes go through IncludeResolver: FsIncludeResolver for files on disk, or any closure, with join_include_path for virtual paths. - Cfg::parse_config and Cfg::read preprocess first, #include without a resolver is an error. Cfg::parse_config_with and Cfg::parse_path take a preprocessor.
Text configs failed on much of what the game loads: += arrays, unquoted
values (true, $STR_x, 0.2*4/3), numbers with leading zeros or in hex,
class names starting with a digit, enum blocks. The parser is now
hand-written instead of chumsky and stores values the way the game's
binarizer does:
- Integers are Long (Int64 when larger), hex included. Numbers with a
fraction or exponent are Float, also 1.0. Everything else unquoted is
a String with the text as written, true and false included (they were
Long 1 and 0).
- name[] += {...} sets CfgProperty::append, in binary configs too
(entry type 5).
- enum blocks go to Cfg::enums, also read from binary configs.
- A missing ; at line ends and after classes, ; in arrays, empty values
and a stray } at the end are accepted, the game loads them.
- CfgValue::Int64 for binary value type 6.
Binary configs:
- read_compressed_int computed in u8: counts of 384 and more could
read wrong, a root of 388 entries read 132.
- Unknown entry and value types are RapError instead of panics, class
nesting is limited and counts aren't allocated up front, so damaged
files fail instead of aborting or overflowing the stack.
/tmp/x/config.cpp on Linux was taken for a path of the game (\a3\...) and only looked up in the include directories.
Cfg, CfgEntry, CfgClass, CfgProperty and CfgValue implement Display, writing text that parses back to the same config: quotes doubled, line breaks as " \n ", floats with a dot. PrettyPrint and to_strr use it, they didn't escape quotes and wrote 1.0 as 1. Every binarized config of the base game (19,025) reads back the same from its text. Tests for the entry accessors, class loops, binary configs without enums, round trips of the test data. The rap tests that only printed errors now fail on them. Removes unused read helpers and the parser's comment handling, the preprocessor removes comments.
TheWillard
added a commit
that referenced
this pull request
Nov 11, 2026
check_for_magic_and_decompress_lzss, Pbo::verify and the signature hashes printed their values to stderr. The one in read_compressed_int goes with #51, which rewrites that function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Text configs failed on much of what the game loads:
+=arrays, unquoted values (true,$STR_x,0.2*4/3), numbers with leading zeros or in hex, class names starting with a digit,enumblocks. The parser is now hand-written instead of chumsky (raw value text isn't recoverable from the token stream) and stores values the way the game's binarizer does. Checked against the base game's config.bin files:Long(Int64when larger), hex included. Numbers with a fraction or exponent areFloat, also1.0: the base game has 7,636 whole-number floats.Stringwith the text as written: config.bin storescolumns = "6 - 1",idc = "125+1",default = "true". Behavior change:true/falsewereLong(1)/Long(0).name[] += {...}sets the newCfgProperty::append, also for binary entry type 5 (flags 1, found in ACE).enum { A, B = 5, C };goes to the newCfg::enums, also read from the table atenum_offsetof binary configs. Best-effort there: its count can be larger than the values stored (24 for 15 in 3den's config.bin), and damaged files point past the end.;at line ends and after classes,;instead of,in arrays, empty values (texture = ;), a stray}at the end and a quoted string followed by more text ('Indep' >> "IND_C_F", RHS Warlords) are accepted: BI's own and published mod files have them.__EXEC(...)is skipped,__EVAL(...)is a string.CfgValue::Int64for binary value type 6 (2 base game configs panicked on it).Binary configs:
read_compressed_intcomputed(b - 1) * 0x80inu8: counts of 384 and more could read wrong.data_f\loadorder\config.binfailed, a Posadkovo rvmat read 132 of its 388 entries. It also printed every second byte (dbg!).RapErrorinstead of panics, class nesting is limited to 256 and counts aren't allocated up front: damaged files and decoys of obfuscated PBOs fail instead of aborting or overflowing the stack.Writing configs:
Cfg,CfgEntry,CfgClass,CfgPropertyandCfgValueimplementDisplay, writing text that parses back to the same config (quotes doubled, line breaks as\n, floats always with a.or exponent,+=, enums). Every binarized config of the base game (19,025) reads back the same from its text.PrettyPrintandto_strruse it: they didn't escape quotes and wrote1.0as1.Breaking: new fields
CfgProperty::append,Cfg::enums, new variantCfgValue::Int64,true/falseare strings.Checked every config in every PBO (config.bin, .cpp, .rvmat, .bisurf, .sqm, .ext, .bikb, .fsm, .cfg), text through the preprocessor of #50 with includes resolved across all PBOs, before and after:
Based on #50.