-
Notifications
You must be signed in to change notification settings - Fork 10
Coding Guidelines
All header files will always have the file name extension of .hpp
.
Config files will be split up into different header files, each with the name of the config and be included in the config.cpp of the component.
Example:
// config.cpp
#include "CfgVehicles.hpp"
// CfgVehicles.hpp
class CfgVehicles {
// Content
};
All text that will be displayed to a user shall be defined in a stingtable.xml
file for multi-language support.
- There will not be any empty stringtable language values.
- All stringtables will follow the format as specified by Tabler (reference Translation Guide).
All texture files should be placed in the data
folder inside the component folder, have the same or at least similar name to the class name and be in .paa
format.
All UI picture files should be placed in the UI
folder inside the component folder, have the same or at least similar name to the class name and be in .paa
format.
- Files without alpha channel shall be suffixed with
_co
. - Files with alpha channel shall be suffixed with
_ca
.
Macro | Expanded |
---|---|
MAINPREFIX |
x |
PREFIX |
tacs |
SUBPREFIX |
addons |
COMPONENT |
Specific to each module |
ADDON |
PREFIX_COMPONENT |
Macro | Expanded |
---|---|
QUOTE(foo) |
"foo" |
CLASS(foo) |
PREFIX_foo |
QCLASS(foo) |
"PREFIX_foo" |
Macro | Expanded |
---|---|
PATHTOF(foo) |
\MAINPREFIX\PREFIX\SUBPREFIX\COMPONENT\foo |
PATHTOEF(bar,foo) |
\MAINPREFIX\PREFIX\SUBPREFIX\bar\foo |
QPATHTOF(foo) |
"\MAINPREFIX\PREFIX\SUBPREFIX\COMPONENT\foo" |
QPATHTOEF(bar,foo) |
"\MAINPREFIX\PREFIX\SUBPREFIX\bar\foo" |
Macro | Expanded |
---|---|
CSTRING(foo) |
"$STR_ADDON_foo" |
ECSTRING(bar,foo) |
"$STR_PREFIX_bar_foo" |
Macro | Expanded |
---|---|
ITEMS_n(foo) |
n times repeated foo in format foo, foo, foo ...
|
Macro | Expanded |
---|---|
MACRO_ADDWEAPON(bar,foo) |
class _xx_bar { weapon = "bar"; count = foo; }; |
MACRO_ADDITEM(bar,foo) |
class _xx_bar { name = "bar"; count = foo; }; |
MACRO_ADDMAGAZINE(bar,foo) |
class _xx_bar { magazine = "bar"; count = foo; }; |
MACRO_ADDBACKPACK(bar,foo) |
class _xx_bar { backpack = "bar"; count = foo; }; |
- Opening brace on the same line as keyword
- Closing brace in own line, same level of indentation as keyword
Yes:
class Something: Or {
class Other {
foo = "bar";
};
};
No:
class Something : Or
{
class Other
{
foo = "bar";
};
};
No:
class Something : Or {
class Other {
foo = "bar";
};
};
In cases where you have a lot of one-liner classes, it is allowed to use something like this to save space:
class One {foo = 1;};
class Two {foo = 2;};
class Three {foo = 3;};
Putting the opening brace in it’s own line wastes a lot of space, and keeping the closing brace on the same level as the keyword makes it easier to recognize what exactly the brace closes.
Ever new scope should be on a new indent. This will make the code easier to understand and read. Indentations consist of 4 spaces. Tabs are not allowed.
Yes:
class Something {
class Other {
// Content
};
};
No:
class Something {
class Other {
// Content
};
};
Inline comments should use //
. Usage of /* */
is allowed for larger comment blocks.
Yes:
// Comment
Yes:
/* Loooo
ooooooong
commeeeeeent */
No:
//// Comment
Adapted from the ACE3 documentation.