CPP File Format: Difference between revisions
Lou Montana (talk | contribs) m (Text replacement - "{{unsupported-doc}}" to "{{Feature|UnsupportedDoc}}") |
Lou Montana (talk | contribs) (Add syntax) |
||
Line 1: | Line 1: | ||
{{Feature|UnsupportedDoc}} | {{Feature|UnsupportedDoc}} | ||
The {{hl|.cpp}} file extension is a generic identifier that ''indicates'' the contents contain pre-raPified text and ''can'' be raPified (binarised). | |||
This is by convention only - the actual content could be binarised already and the engine would load it without failure. | |||
The binarised (raPified) equivalent of | {{Feature|informative|The binarised (raPified) equivalent of {{hl|.cpp}} file is {{hl|.bin}} - see {{Link|Config.cpp/bin File Format}}.}} | ||
There are currently several cpp/bin files used by | There are currently several cpp/bin files used by {{Name|bi}}: | ||
*[[Config.cpp/bin File Format|Config.cpp/bin]] | * [[Config.cpp/bin File Format|Config.cpp/bin]] | ||
*[[Mod.cpp/bin File Format|Mod.cpp/bin]] | * [[Mod.cpp/bin File Format|Mod.cpp/bin]] | ||
*[[Product.cpp/bin File Format|Product.cpp/bin]] | * [[Product.cpp/bin File Format|Product.cpp/bin]] | ||
*[[Resource.cpp/bin]] | * [[Resource.cpp/bin]] - {{ofp}} only | ||
[[Category: | == Syntax == | ||
A '''class''' is defined (with the exception of {{Link|Rvmat File Format|RVMAT}} files for which the engine does it automatically) then values are set in the following format: {{hl|1= valueName = value;}} - a semicolon always ends the line. | |||
{{Feature|warning|A class is '''always''' closed by a semicolon as well.}} | |||
<syntaxhighlight lang="cpp"> | |||
class MyConfigClass | |||
{ | |||
intValue = 42; | |||
floatValue = 66.6; | |||
stringValue = "text"; | |||
translatedValue = "$STR_MyStringtableKey"; // quotes are good practice | |||
arrayValueColour[] = { 1, 0, 0, 1 }; | |||
arrayValueRandom[] = { "ValuesCanBeMixed", 1, 42.0, { 0, 1, 0, 1 } }; | |||
class MySubConfigClass // subclasses are possible | |||
{ | |||
subValue = 123456; | |||
}; | |||
}; // a semicolon ALWAYS closes a class | |||
</syntaxhighlight> | |||
There are '''no boolean value''' in config; you can define them for ease of use/readability using {{hl|#define}}, usually in the first lines: | |||
<syntaxhighlight lang="cpp"> | |||
#define true 1 | |||
#define false 0 | |||
class MyConfigClass | |||
{ | |||
// ... | |||
useTexture = true; // would have otherwise to be useTexture = 1; | |||
// ... | |||
}; | |||
</syntaxhighlight> | |||
A commonly-edited config file is [[Description.ext]], a file storing scenario settings - the file extension differs but the syntax remains the same. | |||
[[Category:BIS File Formats]] |
Revision as of 19:02, 7 May 2025
The .cpp file extension is a generic identifier that indicates the contents contain pre-raPified text and can be raPified (binarised). This is by convention only - the actual content could be binarised already and the engine would load it without failure.
There are currently several cpp/bin files used by Bohemia Interactive:
- Config.cpp/bin
- Mod.cpp/bin
- Product.cpp/bin
- Resource.cpp/bin - Operation Flashpoint only
Syntax
A class is defined (with the exception of RVMAT files for which the engine does it automatically) then values are set in the following format: valueName = value; - a semicolon always ends the line.
class MyConfigClass
{
intValue = 42;
floatValue = 66.6;
stringValue = "text";
translatedValue = "$STR_MyStringtableKey"; // quotes are good practice
arrayValueColour[] = { 1, 0, 0, 1 };
arrayValueRandom[] = { "ValuesCanBeMixed", 1, 42.0, { 0, 1, 0, 1 } };
class MySubConfigClass // subclasses are possible
{
subValue = 123456;
};
}; // a semicolon ALWAYS closes a class
There are no boolean value in config; you can define them for ease of use/readability using #define, usually in the first lines:
#define true 1
#define false 0
class MyConfigClass
{
// ...
useTexture = true; // would have otherwise to be useTexture = 1;
// ...
};
A commonly-edited config file is Description.ext, a file storing scenario settings - the file extension differs but the syntax remains the same.