-
Notifications
You must be signed in to change notification settings - Fork 27
/
codeguide.txt
69 lines (45 loc) · 1.19 KB
/
codeguide.txt
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
OTSERV code guidelines draft
* ClassLooksLikeThis::functionsLookLikeThis()
* Local variable names should be short and still make sense
* Use 'const' when possible
* enumsLookLikeThis_t{
* You can use Player* player, Item* item, Creature* creature, etc
* Use Tab character, NOT spaces
* Use spaces in the code
a == (b / 2) + 1 && b == (c % 2) - 3
* Control staments
if(a == b){
foo();
}
else{
bar();
}
if(a == b)
foo();
for(i = 1; i < 10; i++){
//doing something important here
}
switch(a){
case 1:
break;
case 2:
break;
default:
break;
}
int functionName(int param1, void *param2)
{
}
* For default parameters value
in the .h file
int functionName(int param1, void *param2 = NULL);
in the .cpp file
int functionName(int param1, void *param2 /*= NULL*/)
{
}
* Try to not include itemids in the code, you can "only" use itemids that are in const7x.h
* Do not use literals often, you can use #define, or better use enums
* Try to find in the code a function that fit to your needs to avoid duplicate code, you can change existing functions to make them more powerful
* Avoid include funtions on Game class that are not really Game class related
* Use typedef for your std types
* ....