1 # DarkPlaces Contributing Guidelines
2 -------------------------------------------------------------------------------
4 1. ### Do not break Quake or its mods, and any other game using the engine.
6 The engine has known compatibility issues with Quake and many community
7 mods. All code must not make the situation worse. This is analogous to the policy
8 of the Linux kernel to not break userspace.
10 2. ### Sign off all of your commits if they are to be included upstream.
12 You must use a valid, permanent email address.
14 2. ### All code submitted should follow the Allman style for the most part.
16 1. In statements, the curly brace should be placed on the next line at the
17 same indentation level as the statement. If the statement only involves
18 a single line, do not use curly braces.
28 Do_Something_Else_Else();
31 Do_Something_Else_Else_Else();
34 2. Use tabs for indentation.
36 Use spaces subsequently for alignment of the
37 parameters of multi-line function calls or declarations, or statements.
41 if(very_long_statement &&
42 very_long_statement_aligned &&
53 3. If possible, try to keep individual lines of code less than 100
56 4. Pointer operators should be placed on the right-hand side.
63 5. Type casts should have a space between the type and the pointer.
66 int *foo = (int *)malloc(5);
69 6. Use spaces after each comma when listing parameters or variables of a
72 7. Multi-line comments should be formatted like so:
76 * This is a multi-line comment.
77 * Sometimes, I dream about cheese.
84 /* This is another multi-line comment.
89 8. If following these guidelines in any manner would make any code less
90 readable or harder to follow, ***ignore them***. This section is only
91 guidelines, not rules. We're not gonna beat you over the head in pull
92 requests because you misplaced a dereference operator.
94 For example, in some situations, placing the block on the same line as
95 the condition would be okay because it looks cleaner:
98 if (foo) Do_Something();
99 if (bar) Do_Something_Else();
101 if (boo) AHH("!!!\n");
104 4. DarkPlaces is written in a special subset of C and C++ that sits in the
105 center of the Venn diagram of compatibility between the two languages.
106 While there is no practical reason for keeping it this way (yet), it is
107 generally preferred that all code submitted at least compiles under gcc and
108 g++ and clang(++). This could be done by setting the CC environment
109 variable to g++ or clang++ on the command-line before building.
111 Most of the differences are enforced by a compile warning set to be an
112 error (`-Werror=c++-compat`) but some are subtle and would cause behavior
113 differences between the two compilers, or are not caught by that warning.
114 The things to look out for are:
116 1. Character constants are `int`-sized in C but `char`-sized in C++. This
117 means `sizeof('a')` will be 4 in C, but 1 in C++.
119 2. `goto label;` cannot jump over a variable initialization. This will
120 cause a compiler error as C++ but is not caught by `-Wc++-compat`.