-
Notifications
You must be signed in to change notification settings - Fork 60
/
Development
300 lines (234 loc) · 10.9 KB
/
Development
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
Development information
=======================
Content
=======
Configure your IDE
Information for Dev-C++
Mac OS X
MSVC
Linux
Code
SVN
Basic information
Style guidelines
Overview of the code
IDE : Information for Dev-C++
=============================
Firstly, I am using Dev-C++ 4.9.9.2 (some beta of v5).
I have used the Package manager to download the following packets:
- zlib (1.2.3)
- libiconv (1.9.1)
- Libxml (2.6.19)
- libjpeg (6b-4)
- libpng (1.2.8)
- libsdl (1.2.11)
- SDL_image (1.2.4-notiff)
- SDL_mixer (1.2.6)
I only had to download libgd manually. I did this here:
https://www.libgd.org/Downloads
I downloaded the file:
gd-2.0.34-win32.zip
And extracted all the contents simply directly to my Dev-C++ (so all included
files goes to the right subdirs).
The provided Dev-C++ project-file (under build/DevCpp) should work now.
If you have trouble with compiling, visit:
https://lxalliance.net/forum/index.php?topic=6444.0
IDE : Mac OS X
==============
You need the following frameworks (directories) in /Library/Frameworks/:
SDL.framework
SDL_image.framework
SDL_mixer.framework
GD.framework
FreeType.framework
UnixImageIO.framework
I created a ZIP-package containing all these frameworks. You can download it here: https://sourceforge.net/project/showfiles.php?group_id=180059&package_id=289742
You can also download all the files yourself:
Download SDL: https://www.libsdl.org/release/SDL-1.2.12.dmg
Download SDL_image: https://www.libsdl.org/projects/SDL_image/release/SDL_image-1.2.6.dmg
Download SDL_mixer: https://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-1.2.8.dmg
Download GD, FreeType, UnixImageIO: https://www.kyngchaos.com/staticpages/index.php?page=software-unixport-frameworks
You can use now the Xcode-projectfile under build/Xcode.
Use the script build/Xcode/fix_binary.sh if you want to distribute your
builded application-binary. This script fixes some hardcoded library linking
paths in the binary to relative ones (linked to the frameworks inside the
application-package).
The script build/Xcode/make_tmp_build.sh creates a ZIP-archiv for
you under distrib/tmpbuild.
IDE : MSVC
==========
First you have to install the dependencies:
- zlib (1.2.3) (www.zlib.net)
- libiconv (1.9.1) (www.gnu.org/software/libiconv/)
- Libxml (2.6.19) (www.libxml.org)
- libjpeg (6b-4) (www.ijg.org)
- libpng (1.2.8) (www.libpng.org)
- libsdl (1.2.11) (www.libsdl.org)
- libgd (2.0.35) (www.libgd.org)
- SDL_image (1.2.4) (www.libsdl.org)
- SDL_mixer (1.2.6) (www.libsdl.org)
Then simply open the corresponding project in build directory
(msvc 2005 - VC++ 8 (2005), msvc 2008 - VC++ 9 (2008))
and press F5 or F7 to compile.
MSVC6 is not supported anymore. MSVC6 doesn't correctly supports the C++
standards and has therefore some problems. To make it work with MSVC6, you
would need to hack the code a bit. Also, the project files of MSVC6 are
not updated anymore. Therefore MSVC6 is not included in the release. If
you are interested though in refreshing and using them, grab them from SVN
revision 1999 in build/msvc.
If you have trouble with getting dependencies or compiling, visit
https://lxalliance.net/forum/index.php?topic=6444.0
IDE : Linux
===========
First of all, you should install all packages (like SDL) this game depends on.
Take a look into the file DEPS for a list. Then, you should install also a
compiler (I would prefer GCC) and CMake (we use CMake as our make-system).
Now let's test if the game compiles fine for you; type:
cmake . # this will create you an ordinary Makefile
# you only have to do this once or when you added new code-files
make # this will start the compilation
Run the game with:
./start.sh
If everything works fine and you want to start coding now, I would recommend
you to use an IDE. I myself use KDevelop and I think it's also fine for you.
In KDevelop, you can very easily import this project. Simply select the
"import project" option in the menu and select the directory of OpenLieroX.
It will find all source-files automatically now. Because it will also find the
Makefile you have created with CMake, the building of the project will also
work directly. The onliest thing you still have to set is the path to the
binary (it is bin/openlierox). But look also over other project settings or
general settings in KDevelop, perhaps you find some other nice features which
you can enable.
We support also multiple configurations for your build via CMake. When you run
'cmake .' firstly, you will get a list of available variables and their values.
For example, to enable HawkNL-builtin support, type this:
cmake -D HAWKNL_BUILTIN=Yes .
The provided compile.sh script is intended only for end-user who want to
compile the game only once. It is also used from within other Linux
distribution packages like the Gentoo-ebuild.
Code : SVN
==========
Some basic rules for your work with SVN:
- Ensure that the code is compiling and working before you commit it!
- Please commit only good code. See the guidelines.
- Write a comment to every commit! When watching the changes, it helps a lot
if I can read within a comment what you changed.
- Make small commits. A commit should only contain one new feature or one
bugfix, not more. It is a lot more easier to watch the changes if the
commits are small. Also it is easier to find a bug later on.
- Before you want make a real important or huge change to something in SVN,
please contact the other developers and discuss this first.
- Always keep in mind that others don't like to get disturbed by you.
- Take a short look at the commits of the others. Perhaps they have made some
changes to your code or placed some important comment there.
Webinterface to our SVN:
https://openlierox.svn.sourceforge.net/viewvc/openlierox/
Code : Basic information
========================
If you want to work with the code, read this paragraph (and perhaps this whole
file).
Some starting hints:
- Read the code-overview.
- Esp., look at doc/TODO to get a rough idea what currently needs some work.
- Look also at the other files under doc/.
- Configure your IDE. That will help you a lot on working on it.
- Do a global search in the source-code for the string "TODO". It will give
you a lot of results. If you are bored or so, simply start fixing these
TODOs. :) This will also gives you some impressions of the code.
- Make some cleanups. I marked the most terrible parts which have to be
recoded but there are much more which don't look that nice.
- Talk to us.
Code : Style guidelines
=======================
[TODO: this has to be extended]
Some basic rules you should keep in every case:
- Use standard C++. Not MS C++!!
For example:
for(int i = 0;;) {}
for(i = 0;;) {}
is *no* correct C++ code! But this is:
for(int i = 0;;) {}
for(int i = 0;;) {}
- Don't make any realy crazy optimisations. Produce clear, simple and short
code.
- Make small functions! If your function is too big, cut it into pieces.
- Don't use too much local variables in a function.
1. It is slow.
2. You made something wrong. Generaly, you don't need this.
3. It looks terrible!
- Don't ever use C-technics. That includes for example all strcpy and related
functions and of course in general C-strings. Also don't use int if you
mean bool. Things like these...
- Use the STL and STL-like technics (for example, use std::string, std::list,
...).
Some good links:
https://www.cppreference.com/index.html
https://www.sgi.com/tech/stl/table_of_contents.html
- Produce abstract and general code!
(This is realy important because we soon want to change the base code
and all code, which is not general enough has to be redone. Keep this
in mind...)
- Don't hack around!
It's not good if you add some new features only with some small hacks to
the code. The code becomes even more terrible by this. Also, almost every
hacked-in feature isn't general enough to allow a simple reuse of it in a
new codebase.
If you want to add kind of a hack for some backward-compatibility, think
first about if you realy want this. Perhaps it's just better for this new
feature to allow it only for new versions. Because you should not only
think of the backward-compatibility. Also think of the
forward-compatibility. Also, if you realy want to implement a hack,
leave at least the code clean!
- Format and indent the code correct! (Use tabs for indenting!)
- Place spaces between each element which should be read seperated!
For example, this looks terrible:
CVec* v=somewhat;for(v->x=0,v->y=10;(v->x<10&&v->y>=0);v->x++,v->y--)cout<<v->x<<v->y<<endl;
This looks much better:
CVec* v = somewhat;
for(v->x = 0, v->y = 10; v->x < 10 && v->y >= 0; v->x++, v->y--)
cout << v->x << v->y << endl;
- Mark incomplete or temporary code with a TODO!
- Comment your code where you made some strange, not selfexplaining stuff.
- Don't upload any temporary testing-code into the code which produces for
example some debug-files for you which is useless for the others.
- Don't add options for every single change you made in the code. If you are
unsure if users will like it, discuss the problem with othrer devs or community
first. Too many weird options will only confuse the user.
- Make sure that the code compiles before uploading
- TEST your code before uploading (the deeper the better)
- Mark unstable parts with TODO
- Brackets after if/for/while etc. statements are separated by two spaces, for example:
for (int i=0; i < 10, i++) {
// some code here
}
...
Code : Overview of the code
===========================
[TODO: this has to be extended a bit]
[but don't extend it to much, it should only be an overview here that allows
you withing an hour to get some basic ideas and impressions of the code :)]
[also, don't explain every single code file here; if you want to know what
each single code-file is for, look into them; they (should) contain this
information themself]
So, you are new to the code, so this will perhaps help you a bit:
Files:
src/main.cpp - includes the main-entry point and the gameloop
src/client/* - mainly the menu and all client-related stuff
src/common/* - all more generaly stuff and also the main-structures
(like worm, map, ..)
src/server/* - server-related stuff, also for example the game itself
include/* - header-files for all sources
Take also a look to the most important structures:
CMap, CWorm, CServer, CClient, CGameScript, LieroX
Game-logic:
CServer, CClient, CGameScript
Important for physics:
Physics*
CMap, CWorm, CProjectile, Entity, CNinjaRope
Other important things:
File-IO, also (mainly) searchpath-handling: FindFile
Caching system for graphics and sounds: Cache
Network-related things: Networking, CBytestream, CChannel
Sound-related: Sounds
Graphic-related: Graphics, GfxPrimitives
...