summaryrefslogtreecommitdiff
path: root/HACKING
blob: 98a9876c2903d8d5a4d206f9045e641ddf0a18db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
Coding style guidelines
=======================

You should set tabs to display as eight spaces, not four.  However, 
_indentation_ should be four spaces.  If possible, do not use tab
characters at all.  There is a utility called "expand" which will
remove tab characters.

Please write code to an 80 column limit so that it fits within a 
standard 80 column terminal.

Functions should be named like this: 'AB_FunctionName'.  The 'AB' prefix 
denotes the subsystem (AM_ for automap, G_ for game, etc).  If a 
function is static, you can omit the prefix and just name it like
'FunctionName'.  Functions and global variables should always be
made static if possible.

Put '_t' on the end of types created with typedef.  Type names like this
should be all lowercase and have the subsystem name at the start. An
example of this is 'txt_window_t'.  When creating structures, always
typedef them.

Do not use the goto statement.

Use C++-style comments, ie. '//' comments, not '/* ... */' comments.
I don't care that this isn't standard C.

Variables should be named like this: 'my_variable_name', not like
this: 'MyVariableName'.  In pointer variable declarations, place
the '*' next to the variable name, not the type.

When using an if, do, while, or for statement, always use the { }
braces even when they are not necessary.  For example, do this:

    if (condition)
    {
        body;
    }

Not this:

    if (condition)   // NO
        body;

Write code like this:

typedef struct
{
    int member1;
    char *member2;
} my_structure_t;

void FunctionName(int argument, int arg2, int arg3, int arg4, int arg5, 
                  int arg6, int arg7)
{
    if (condition)
    {
        body;
    }
    else if (condition)
    {
        body;
    }
    else 
    {
        body;
    }

    if (very_long_condition_like_this_one_that_forces_a_line_break
     && other_condition)
    {
        body;
    }

    switch (argument)
    {
        case FIRST:
	    code;
	    break;
	    
	case SECOND:
	    code;
	    break;
	    
	default:
	    break;
    }

    for (a=0; a<10; ++a)
    {
        loop_body;
    }

    while (a < 10)
    {
        loop_body;
    }

    do 
    {

    } while (condition);
}

GNU GPL and licensing
=====================

All code submitted to the project must be licensed under the GNU GPL or
a compatible license.  If you use code that you haven't 100% written 
yourself, say so. Add a copyright header to the start of every file.  
Use this template:

// Emacs style mode select   -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright(C) YEAR Author's name
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.