Fix fov being recalculated when you move into a wall. Because I'm stupid
[SmugglerRL.git] / style.txt
blobb6b6dbac6630c961c45ee42b6dfd22a04b835a6e
1 This document outlines the coding style that I try to use and sometimes fail at
2 in this codebase.
5 LEGAL STUFF
7 This document is released into the public domain for use by
8 anyone who wishes for any reason, with no accreditation, payment, or
9 consultation necessary.  That is, you're ALLOWED to use it for anything, but
10 I'd PREFER it if you asked me first.
13 CODING STYLE:
15 This style can probably be used in c, c++, java, dart, or whatever with a little
16 modification, but it was made for D.  Consider yourself warned, if you use it
17 for anything else.
21 SPACING AND WHITESPACE
23 Add spaces in between keywords (if, for, while, etc.) and parentheses.  Do this:
25         while (...)
27 Not this
29         while(...)
31 EXCEPTION!
33 Don't insert a space when doing an assert(0);
37 One space in between a variable and an assignment operator.  Do this:
39         foo = 7;
41 Not these:
43         foo=7;
44         foo =7;
45         foo= 7;
47 EXCEPTION!
49 When you have a long chain of assignments, possibly auto-generated, you may use
50 tabs to align all the "="s together.  If one of the variables touches the tab,
51 don't insert a tab, forcing yourself to indent everything else.  Like so:
53         foo     = 7;
54         booze   = 9;
55         x       = y;
56         longname= 17;
59 BRACES
61 Put an open-curlybrace on the same line as the code delimeter.  Put the
62 end-curlybrace on its own line; or, if there is another code delimiter that's
63 connected to the first one, put the end-brace on the same line.  Do this:
65         if (condition) {
66                 stuff
67         } else if (condition) {
68                 otherstuff
69         } else {
70                 different stuff
71         }
73 NEVER UNDER ANY CIRCUMSTANCES leave out the brace.  NEVER do this:
75         if (condition)
76                 stuff
77         else if (condition)
78                 otherstuff
79         else
80                 different stuff
82 This isn't python.
86 TABS AND SPACES
88 For indentation purposes, only tabs should be used.  For the purpose of
89 aligning already-indented text, only tabs should be used.  For the purpose of
90 seperating various similar items on the same line, a single space should be
91 used.  Do this:
93         try {
94                 int[5] foo      = [5, 7, 9];
95                 int[18] bar     = [7, 9, 11];
96                 int[283947] baz = [5, 3, 2, 3, 9];
97                 int[2] biz      = [3, 4, 1, 2];
98         } catch (RangeError) {
99                 throw;
100         }
102 Note that the character in between "baz" and "=" is a tab, NOT a space.