#All code in teeworlds should match this code guidelines.
Hardtabs, tabsize 4.
Use Allman style brackets like this:
if(MyInt != 5)
{
while(MyInt)
{
MyFunction(&MyInt);
}
}
ContinueMyStuff();
Use //
style comments for most things. Larger blocks of comments can use /* */
style but shouldn't be used inside function bodies.
Use CamelCase with upper case on the first letter as well.
m_
Class member
g_
Global variable
s_
Static variable
_p
Pointer
_a
Fixed array
Combine them appropriately.
C
Class, CMyClass, This goes for structures as well.
I
Interface, IMyClass
Pass by value for smaller things, const reference for larger objects. By pointer if the function needs to modify the object. Don't cast values as just a reference. If the function needs to modify it, use a pointer to show it as well.
void MyFunction(int MyVar);
void MyFunction(const CMyClass &MyVar);
void MyFunction(int *pMyVar);
void MyFunction(int &pMyVar); // Never do this!
class IMyInterface
{
public:
virtual void MyFunction(int InputVar) = 0;
};
class CMyImplementation : public IMyInterface
{
static int ms_StaticCounter;
int m_aSomeData[16];
public:
void *m_pMyData;
virtual void MyFunction(int InputVar)
{
// ...
}
};