| Classes, structures and enum names |
- CClassName for a server class.
- C_ClassName for a client class.
- IClassName for interfaces.
- Sufix "_t" : |
| Members and methods of classes |
- m_variable for variables members of a class. (Begin
by "m_").
- FunctionName() for methods of a class. (Begin by a capital
letter, no underscore). |
| Header files |
- Use forward declarations whenever possible.
- Inline whenever possible.
- Use the following syntax to avoid mutliple inclusions :
#ifndef FILENAME_H
#define FILENAME_H
#ifdef _WIN32
#pragma once
#endif
// declarations.......
#endif // FILENAME_H
|
| Source files |
- memdbgon must be included last in a .cpp file (#include "tier0/memdbgon.h")
- For shared code, the Client-Server abstraction should be done like this,
using the CLIENT_DLL macro :
#ifdef CLIENT_DLL
#include "c_tdp_player.h"
#else
#include "tdp_player.h"
#endif
|
| Data structures |
- We should not use STL, instead we'll use the templated
utility library (CUtl*) from Valve.
| class CUtlBuffer |
Command parsing, not recommanded? |
| class CUtlCachedFileData |
To put data in a LRU type of cache. |
| class CUtlDict |
Dictionary mapping from symbol to structure. |
| class CUtlFixedLinkedList |
Linked list with no node displacement. |
| class CUtlFixedMemory |
Fixed size memory. |
| class CUtlHash |
Hash table. |
| class CUtlLinkedList |
Index-based linked list. |
| class CUtlMap |
Associative container. similar to std::map. |
| class CUtlMemory |
Growable memory class (doubles in size by default). |
| class CUtlMultiList |
Index-based linked list, can contain sub-lists. |
| class CUtlPriorityQueue |
FIFO with priority |
| class CUtlRBTree |
Red-black binary search tree. |
| class CUtlSortVector |
Sorted order-preserving vector |
| class CUtlVector |
Growable array class (doubles in size by default). |
| class CUtlVectorFixed |
Array class with a fixed allocation scheme |
- User smart pointers CSmartPtr whenever using a collection of
dynamicly allocated objects.
|
| Math |
- We should use the math classes provided by Valve :
| class Vector |
3D Vector (x,y,z) class. |
| class Vector32 |
Compressed 3D vector into 32bits |
| class Vector2D |
2D Vector (x,y) class. |
| class Vector4D |
4D Vector (x,y,z,w) (with homogenous factor) class. |
| struct cplane_t |
Plane struct. |
| class VPlane |
Plane class. |
| class Frustum_t |
6 Planes Frustrum class. |
| struct matrix3x4_t |
3 by 4 matrix struct. |
| class VMatrix |
4 by 4 matrix class. |
| class QAngle |
Euler angles (pitch, yaw, roll) class. |
| class Quaternion |
Quaternion angles (x,y,z,w) class. |
|