- Notifications
You must be signed in to change notification settings - Fork126
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.cppfiles, 'header' for.hand.hppfiles.
Don't use tabs! Spaces only.
-Wrongstruct MyStruct {unsigned intm_nVariable;floatm_fVariable;};+Correctstruct MyStruct { unsigned int m_nVariable; float m_fVariable;};Don't use special MS types, like__int8,__int64.
Don't usestdint aliases, likeint8_t,int64_t.
When you need a 64-bit integer variable, uselong long orint64.
When you need a 32-bit boolean variable, usebool32.
-Wrongstruct MyStruct { int8_t m_nInt8Variable; __int64 m_nInt64Variable; unsigned int m_bBoolVariable;};+Correctstruct MyStruct { char m_nInt8Variable; int64 m_nInt64Variable; bool32 m_bBoolVariable;};Use specialAPI types only when a code (or structure) directly uses thatAPI (or related to thatAPI).
For example, if a code usesWindows API functionality, it's allowed to use (but not necessarily) such aliases asBYTE,DWORD, etc.
Same forRenderWare API and its base types:RwChar,RwInt32,RwReal, etc.
Don't useC-style casting. Usestatic_cast orreinterpret_cast.
-Wrongm_vecPos.x = (short)(coord * 8.0f);+Correctm_vecPos.x = static_cast<short>(coord * 8.0f);It's recommended that all text files in the repository end with a newline character.