-
Notifications
You must be signed in to change notification settings - Fork 119
Plugin SDK Coding Style
! Note: These rules are applied to all files in plugin-sdk repository, except third-party modules (like
injector
) files.
Every header (.h
/.hpp
) and source (.cpp
) file should start with a comment:
/*
Plugin-SDK ($GAME_NAME$) $SHARED$ $FILE_TYPE$ file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
Where
-
GAME_NAME
- game to which the file belongs - 'Grand Theft Auto San Andreas', 'Grand Theft Auto Vice City' or 'Grand Theft Auto 3'. 'Grand Theft Auto' for shared files. -
SHARED
- optional, 'SHARED' for shared files. -
FILE_TYPE
- 'source' for.cpp
files, 'header' for.h
and.hpp
files.
Don't use tabs! Spaces only.
-Wrong
struct MyStruct {
unsigned int m_nVariable;
float m_fVariable;
};
+Correct
struct MyStruct {
unsigned int m_nVariable;
float m_fVariable;
};
Don't use special MS types, like __int8
, __int64
.
Don't use stdint
aliases, like int8_t
, int64_t
.
When you need a 64-bit integer variable, use long long
or int64
.
When you need a 32-bit boolean variable, use bool32
.
-Wrong
struct MyStruct {
int8_t m_nInt8Variable;
__int64 m_nInt64Variable;
unsigned int m_bBoolVariable;
};
+Correct
struct MyStruct {
char m_nInt8Variable;
int64 m_nInt64Variable;
bool32 m_bBoolVariable;
};
Use special API types
only when a code (or structure) directly uses that API
(or related to that API
).
For example, if a code uses Windows API
functionality, it's allowed to use (but not necessarily) such aliases as BYTE
, DWORD
, etc.
Same for RenderWare API
and its base types: RwChar
, RwInt32
, RwReal
, etc.
Don't use C-style casting
. Use static_cast
or reinterpret_cast
.
-Wrong
m_vecPos.x = (short)(coord * 8.0f);
+Correct
m_vecPos.x = static_cast<short>(coord * 8.0f);
It's recommended that all text files in the repository end with a newline character.