Coding Style - Unarelith/OpenMiner GitHub Wiki
- Naming
 - Pointers and references
 - Indentation
 - Line length
 - Operators
 - Class
 - Function
 - Conditional statements
 - Loops
 
Variables and functions use camelCase.
Class names and file names use PascalCase.
Class private members must be prefixed by a m_.
Static private members should be prefixed by a s_.
The prefix is should be used for boolean variables and methods (ex: isSet, isFinished, isVisible, isFound, isOpen).
There are a few alternatives to the is prefix that fit better in some situations. These are the has, can and should prefixes (ex: hasLicense, canEvaluate, shouldSort).
Usually, a variable that will store an amount of items will be named itemCount and not nItems.
Only use a pointer when needed, always prefer using references.
The &/* should be placed before the name of the variable.
Examples:
- 
const Item &item: valid - 
Biome *biome: valid - 
Recipe* recipe: invalid 
If an object is bigger than 64 bits, always pass it using a const reference, never pass it by copy.
Examples:
- 
void setItems(const std::vector<Item> &items);: valid - 
void setItems(std::vector<Item> items);: invalid 
In OpenMiner, we use tabs for indentation, and spaces for alignment.
Example:
....foo(bar1,
....____bar2);Here, the . represents tabs and _ represents spaces.
There's currently no hard limit on line length, but try to keep the length below 100 chars when possible.
Every operator (+, -, *, /, &/&&, |/||, ^) should be preceded and followed by a space.
Example:
- 
5 * (3 + 2): valid - 
5*(3+2): invalid 
Here an example of class declaration:
class Foo : public Bar {
	public:
		Foo();
	private:
		int m_baz = 0;
};Here is an example of function definition:
int add(int a, int b) {
	return a + b;
}Here is an example of a if/else if/else statement:
if (condition && otherCondition) {
	// do something
}
else if (condition && !otherCondition) {
	// do something else
}
else {
	// do something else 2
}Here is an example for different types of loops:
while (condition) {
	// do something
}
do {
	// do something
} while (condition);
for (int i = 0 ; i < max ; ++i) {
	// do something
}
for (auto &it : vector) {
	// do something
}