CPP File Format: Difference between revisions

From Bohemia Interactive Community
(Add syntax)
m (Fix)
Line 16: Line 16:
== Syntax ==
== 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.
Values are set in the following format: {{hl|1= valueName = value;}} - a semicolon always ends the line.
 
They can be present at the root of the file but more frequently than not will be defined in a '''class''' - note that '''classes are also ended by a semicolon'''.
{{Feature|warning|A class is '''always''' closed by a semicolon as well.}}


<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">

Revision as of 22:43, 7 May 2025

bi symbol white.png
Disclaimer: This page describes internal undocumented structures of Bohemia Interactive software.

This page contains unofficial information.

Some usage of this information may constitute a violation of the rights of Bohemia Interactive and is in no way endorsed or recommended by Bohemia Interactive.
Bohemia Interactive is not willing to tolerate use of such tools if it contravenes any general licenses granted to end users of this community wiki or BI products.

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.

The binarised (raPified) equivalent of .cpp file is .bin - see Config.cpp/bin File Format.

There are currently several cpp/bin files used by Bohemia Interactive:


Syntax

Values are set in the following format: valueName = value; - a semicolon always ends the line. They can be present at the root of the file but more frequently than not will be defined in a class - note that classes are also ended by a semicolon.

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.