Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Plugin SDK Coding Style

Dmitry edited this pageMar 20, 2018 ·2 revisions

! Note: These rules are applied to all files in plugin-sdk repository, except third-party modules (likeinjector) files.

1. License comment

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.

2. Tabs vs Spaces

Don't use tabs! Spaces only.

-Wrongstruct MyStruct {unsigned intm_nVariable;floatm_fVariable;};
+Correctstruct MyStruct {    unsigned int m_nVariable;    float        m_fVariable;};

3. In-built types

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.

4. Names

5. Classes and structures

6. Type casting

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);

7. Comments

8. Final newline

It's recommended that all text files in the repository end with a newline character.

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp