1
0

Updated CONTRIBUTING file with formatting and essential rules.

This commit is contained in:
Mattes D 2014-02-23 14:57:59 +01:00
parent 6da013c538
commit b432f57608

View File

@ -1,35 +1,39 @@
Code Stuff Code Stuff
---------- ----------
* Because some devs use MSVC2008, we use C++03 - no C++11 magic for now at least :( * We use C++03
* Use the provided wrappers for OS stuff: * Use the provided wrappers for OS stuff:
- Threading is done by inheriting from cIsThread, thread synchronization through cCriticalSection, cSemaphore and cEvent, file access and filesystem operations through the cFile class, high-precision timers through cTimer, high-precision sleep through cSleep - Threading is done by inheriting from `cIsThread`, thread synchronization through `cCriticalSection`, `cSemaphore` and `cEvent`, file access and filesystem operations through the `cFile` class, high-precision timers through `cTimer`, high-precision sleep through `cSleep`
* No magic numbers, use named constants: * No magic numbers, use named constants:
- E_ITEM_XXX, E_BLOCK_XXX and E_META_XXX for items and blocks - `E_ITEM_XXX`, `E_BLOCK_XXX` and `E_META_XXX` for items and blocks
- E_ENTITY_TYPE_XXX for mob types - `cEntity::etXXX` for entity types, `cMonster::mtXXX` for mob types
- dimNether, dimOverworld and dimEnd for world dimension - `dimNether`, `dimOverworld` and `dimEnd` for world dimension
- gmSurvival, gmCreative, gmAdventure for game modes - `gmSurvival`, `gmCreative`, `gmAdventure` for game modes
- wSunny, wRain, wThunderstorm for weather - `wSunny`, `wRain`, `wThunderstorm` for weather
- cChunkDef::Width, cChunkDef::Height for chunk dimensions (C++) - `cChunkDef::Width`, `cChunkDef::Height` for chunk dimensions (C++)
- etc. - etc.
* Instead of checking for specific value, use Is functions, if available: * Instead of checking for a specific value, use an `IsXXX` function, if available:
- cPlayer:IsGameModeCreative() instead of (cPlayer:GetGameMode() == gmCreative) - `cPlayer:IsGameModeCreative()` instead of` (cPlayer:GetGameMode() == gmCreative)` (the player can also inherit the gamemode from the world, which the value-d condition doesn't catch)
* Please use tabs for indentation and spaces for alignment. This means that if it's at line start, it's a tab; if it's in the middle of a line, it's a space * Please use **tabs for indentation and spaces for alignment**. This means that if it's at line start, it's a tab; if it's in the middle of a line, it's a space
* Alpha-sort stuff that makes sense alpha-sorting - long lists of similar items etc. * Alpha-sort stuff that makes sense alpha-sorting - long lists of similar items etc.
* Keep individual functions spaced out by 5 empty lines, this enhances readability and makes navigation in the source file easier. * Keep individual functions spaced out by 5 empty lines, this enhances readability and makes navigation in the source file easier.
* Add those extra parentheses to conditions, especially in C++ * Add those extra parentheses to conditions, especially in C++
- "if ((a == 1) && ((b == 2) || (c == 3)))" instead of ambiguous "if (a == 1 && b == 2 || c == 3)" - `if ((a == 1) && ((b == 2) || (c == 3)))` instead of ambiguous `if (a == 1 && b == 2 || c == 3)`
- This helps prevent mistakes such as "if (a & 1 == 0)" - This helps prevent mistakes such as `if (a & 1 == 0)`
* White space is free, so use it freely * White space is free, so use it freely
- "freely" as in "plentifully", not "arbitrarily" - "freely" as in "plentifully", not "arbitrarily"
* Each and every control statement deserves its braces. This helps maintainability later on when the file is edited, lines added or removed - the control logic doesn't break so easily. * Each and every control statement deserves its braces. This helps maintainability later on when the file is edited, lines added or removed - the control logic doesn't break so easily.
* Please leave the first line of all source files blank, to get around an IDE bug. - The only exception: a `switch` statement with all `case` statements being a single short statement is allowed to use the short brace-less form.
* Also leave the last line of all source files blank (GCC and GIT can complain otherwise) * Add an empty last line in all source files (GCC and GIT can complain otherwise)
* Use doxy-comments for functions in the header file, format as `/** Description */`
* Use spaces after the comment markers: `// Comment` instead of `//Comment`
Copyright Copyright
--------- ---------
Your work should be licensed under the Apache license, and you should add yourself to the CONTRIBUTORS file. Your work must be licensed at least under the Apache license.
If your work is not licensed under the Apache license, then it must be compatible and marked as such. Note that only plugins may choose a different license; MC-server's internals need to be single-license. You can add yourself to the CONTRIBUTORS file if you wish.
**PLUGINS ONLY**: If your plugin is not licensed under the Apache license, then it must be compatible and marked as such. This is only valid for the plugins included within the MCServer source; plugins developed on separate repositories can use whatever license they want.