Skip to content

Commit 494368e

Browse files
authored
Merge pull request #8 from TracerDS/150924_Fix-highlighting
Fix syntax highlighting
2 parents d921dad + 2e31e03 commit 494368e

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

mtasa-blue/CODING_GUIDELINES.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ We always try to avoid magic numbers like memory addresses, offsets,
2828
some constant numbers, etc. You can use the **#define** macro to define
2929
the numbers or at least use comments to document these numbers.
3030

31-
``` cpp
31+
```cpp
3232
float 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
4949
When using the **#define** macro, we use a prefix that specifies what it
5050
defines.
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.
6565
We 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.
9898
Define and call functions without arguments simply with empty
9999
parentheses. Don't use *void* in this case as it is an old practice!
100100
101-
``` cpp
101+
```cpp
102102
// Bad
103103
void MyFunction(void);
104104
MyFunction(void);
@@ -115,7 +115,7 @@ make your code as readable as possible so that anyone can easily read it
115115
and 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
{
@@ -213,7 +213,7 @@ and understand its purpose.
213213
}
214214
```
215215
- If a loop or condition is short, omit curly braces
216-
``` cpp
216+
```cpp
217217
// Instead of
218218
if (!bStillRunning)
219219
{
@@ -248,7 +248,7 @@ and understand its purpose.
248248
249249
- Functions that only return a value should be placed in header files.
250250
For example, instead of:
251-
``` cpp
251+
```cpp
252252
// In .cpp file
253253
int GetGameSpeed()
254254
{
@@ -258,11 +258,11 @@ and understand its purpose.
258258
259259
Do it in the header:
260260
261-
``` cpp
261+
```cpp
262262
int GetGameSpeed() const noexcept { return m_iGameSpeed; }
263263
```
264264
- Don't use unnecessary parenthesis.
265-
``` cpp
265+
```cpp
266266
// Bad
267267
bool CClientPed::IsDead()
268268
{
@@ -276,7 +276,7 @@ and understand its purpose.
276276
}
277277
```
278278
- Use [range-based for loops](https://en.cppreference.com/w/cpp/language/range-for) when possible.
279-
``` cpp
279+
```cpp
280280
std::vector<int> vec; // Example std container
281281

282282
// Bad:
@@ -298,7 +298,7 @@ and understand its purpose.
298298

299299
- Always place a copyight comment at the beginning of header files
300300

301-
``` cpp
301+
```cpp
302302
/*****************************************************************************
303303
*
304304
* PROJECT: Multi Theft Auto
@@ -354,7 +354,7 @@ setting or returning a null pointer.
354354
Use [member initialization lists](https://en.cppreference.com/w/cpp/language/constructor)
355355
whenever possible. Instead of doing:
356356
357-
``` cpp
357+
```cpp
358358
CObject::CObject(CElement* pParent, CObjectManager* pObjectManager, bool bIsLowLod)
359359
: CElement(pParent), m_bIsLowLod(bIsLowLod), m_pLowLodObject(NULL)
360360
{
@@ -382,7 +382,7 @@ CObject::CObject(CElement* pParent, CObjectManager* pObjectManager, bool bIsLowL
382382
383383
Do:
384384
385-
``` cpp
385+
```cpp
386386
CObject::CObject(CElement* pParent, CObjectManager* pObjectManager, bool bIsLowLod)
387387
: CElement(pParent),
388388
m_bIsLowLod(bIsLowLod),
@@ -457,7 +457,7 @@ yet been used in many places and you can often see the old **CScriptArgReader**.
457457
For new codes, use a new parser if possible. If you are refactoring older functions,
458458
you usually need to use **ArgumentParserWarn** to maintain backward compatibility.
459459

460-
``` cpp
460+
```cpp
461461
// New function
462462
{"pathListDir", ArgumentParser<pathListDir>},
463463

0 commit comments

Comments
 (0)