@@ -28,14 +28,14 @@ We always try to avoid magic numbers like memory addresses, offsets,
2828some constant numbers, etc. You can use the ** #define** macro to define
2929the numbers or at least use comments to document these numbers.
3030
31- ``` cpp
31+ ``` cpp
3232float CWeatherSA::GetWetRoads () const
3333{
3434 return *(float*)0xC81308; // CWeather::WetRoads
3535}
3636```
3737
38- ``` cpp
38+ ``` cpp
3939// In the header
4040#define NUM_WETROADS 0xC81308
4141
@@ -49,7 +49,7 @@ float CWeatherSA::GetWetRoads() const
4949When using the ** #define** macro, we use a prefix that specifies what it
5050defines.
5151
52- ``` cpp
52+ ``` cpp
5353#define FUNC_RemoveRef 0x4C4BB0 // Function address
5454#define ARRAY_aCannons 0xC80740 // Array address
5555#define STRUCT_CAESoundManager 0xB62CB0 // Struct address
@@ -65,25 +65,25 @@ defines.
6565We use different naming conventions depending on the context.
6666
6767- Use ** lower camel case** for variable names and types:
68- ``` cpp
68+ ``` cpp
6969 SSomeStruct valueOne;
7070 ESomeEnum m_valueTwo;
7171 ```
7272- Use **upper camel case ** for functions and classes:
73- ``` cpp
73+ ```cpp
7474 void UpperCamelCase ();
7575 class Vector ;
7676 ```
7777- Class member, should start with the prefix **m\_**
78- ``` cpp
78+ ```cpp
7979 CVector m_vecPosition;
8080 CVector m_vecRotation;
8181 bool m_isVisible;
8282 bool m_isFrozen;
8383 ```
8484- We **avoid** Hungarian notation in new codes, so use it only if
8585 necessary for consistency with the current code you are editing.
86- ``` cpp
86+ ```cpp
8787 float fValue ; // Local variable
8888 unsigned char m_ucValue; // Class member variable
8989 char ms_cValue; // Class static member variable
@@ -98,7 +98,7 @@ We use different naming conventions depending on the context.
9898Define and call functions without arguments simply with empty
9999parentheses. Don' t use *void* in this case as it is an old practice!
100100
101- ``` cpp
101+ ```cpp
102102// Bad
103103void MyFunction(void);
104104MyFunction(void);
@@ -115,7 +115,7 @@ make your code as readable as possible so that anyone can easily read it
115115and understand its purpose.
116116
117117- Use **early-returns** to improve code readability.
118- ``` cpp
118+ ```cpp
119119 // Poor readability
120120 bool CStaticFunctionDefinitions::RespawnObject(CElement* pElement)
121121 {
@@ -183,7 +183,7 @@ and understand its purpose.
183183 ```
184184- Always strive to maintain code readability. If a type is lengthy to
185185 write, you can use auto to improve readability
186- ``` cpp
186+ ```cpp
187187 CDeatchmatchObject* pObject = static_cast<CDeathmatchObject*>(pEntity);
188188 // Can be
189189 auto* pObject = static_cast<CDeathmatchObject*>(pEntity);
@@ -192,7 +192,7 @@ and understand its purpose.
192192 We prefer to use **auto\* ** when it comes to pointer, even though
193193 auto itself is sufficient.
194194- Use logical conditions whenever possible
195- ``` cpp
195+ ```cpp
196196 // Poor readability
197197 const CPositionRotationAnimation* CObject::GetMoveAnimation()
198198 {
@@ -212,8 +212,13 @@ and understand its purpose.
212212 return IsMoving() ? m_pMoveAnimation : nullptr;
213213 }
214214 ```
215+ <<<<<<< Updated upstream
215216- If a loop or condition is short, omit curly braces
216217 ``` cpp
218+ =======
219+ - if a loop or condition is short, omit curly braces
220+ ```cpp
221+ >>>>>>> Stashed changes
217222 // Instead of
218223 if (!bStillRunning)
219224 {
@@ -248,7 +253,7 @@ and understand its purpose.
248253
249254- Functions that only return a value should be placed in header files.
250255 For example, instead of:
251- ``` cpp
256+ ```cpp
252257 // In .cpp file
253258 int GetGameSpeed()
254259 {
@@ -258,11 +263,11 @@ and understand its purpose.
258263
259264 Do it in the header:
260265
261- ``` cpp
266+ ```cpp
262267 int GetGameSpeed() const noexcept { return m_iGameSpeed; }
263268 ```
264269- Don' t use unnecessary parenthesis.
265- ``` cpp
270+ ```cpp
266271 // Bad
267272 bool CClientPed::IsDead ()
268273 {
@@ -276,7 +281,7 @@ and understand its purpose.
276281 }
277282 ```
278283- Use [ range-based for loops] ( https://en.cppreference.com/w/cpp/language/range-for ) when possible.
279- ``` cpp
284+ ``` cpp
280285 std::vector<int > vec; // Example std container
281286
282287 // Bad:
@@ -298,7 +303,7 @@ and understand its purpose.
298303
299304- Always place a copyight comment at the beginning of header files
300305
301- ``` cpp
306+ ```cpp
302307 /* ****************************************************************************
303308 *
304309 * PROJECT: Multi Theft Auto
@@ -354,7 +359,7 @@ setting or returning a null pointer.
354359Use [member initialization lists](https://en.cppreference.com/w/cpp/language/constructor)
355360whenever possible. Instead of doing:
356361
357- ``` cpp
362+ ```cpp
358363CObject::CObject(CElement* pParent, CObjectManager* pObjectManager, bool bIsLowLod)
359364 : CElement(pParent), m_bIsLowLod(bIsLowLod), m_pLowLodObject(NULL)
360365{
@@ -382,7 +387,7 @@ CObject::CObject(CElement* pParent, CObjectManager* pObjectManager, bool bIsLowL
382387
383388Do:
384389
385- ``` cpp
390+ ```cpp
386391CObject::CObject(CElement* pParent, CObjectManager* pObjectManager, bool bIsLowLod)
387392 : CElement(pParent),
388393 m_bIsLowLod(bIsLowLod),
@@ -457,7 +462,7 @@ yet been used in many places and you can often see the old **CScriptArgReader**.
457462For new codes, use a new parser if possible. If you are refactoring older functions,
458463you usually need to use ** ArgumentParserWarn** to maintain backward compatibility.
459464
460- ``` cpp
465+ ``` cpp
461466// New function
462467{"pathListDir", ArgumentParser<pathListDir >},
463468
0 commit comments