Source Code

From Simutrans Wiki

Jump to: navigation, search

Contents

Download

The source code for the latest version can be downloaded using an SVN client as:

$ svn co svn://tron.homeunix.org/simutrans/simutrans/trunk

Official instructions: http://forum.simutrans.com/index.php/topic,6046.0.html
Discussion about setting up an official server: http://forum.simutrans.com/index.php/topic,6227.0.html

Build

(from the instructions included with the source)

How to compile

Libraries needed

(Note: on Ubuntu, I had to install -dev versions of libraries separately. --Stormoog)


libz http://www.zlib.net/ libpng http://www.libpng.org/pub/png/ for makeobj

libSDL and libSDL_mixer http://www.libsdl.org/ for SDL

Allegro http://www.talula.demon.co.uk/allegro/ (or http://alleg.sourceforge.net/index.de.html) for Allegro

To make life easier, you can follow the instructions to compile OpenTTD. A system set up for OpenTTD will also compile simutrans without problems.

If you are on a MS Windows machine, download either MS VC Express or MingW. The latter is easier to use as part of the DEV-C++ IDE, which makes the installation of additional libraries like libz and libsdl and so on very easy. However, to compile the command line is easier.

For all other systems, it is recommended you get the latest GCC and matching zlib, and libpng and a game library. For unix system you may have to use tools like apt-get or yast.

It is recommended that you always use the latest source version.

Compiling with GCC

Go to Simutrans/sim.

Then copy the file sim/config.template to sim/config.default and edit the file. You need to specify: - frontend (gdi, allegro, sdl) - color depth (usually 16) - system (you should know it)

I recommend to uncomment #DEBUG=1 and #OPTIMISE = 1 (i.e. removing the #).

For allegro or libsdl you may need to define the path of the config file (or at least on Win98 and empty path).

Finally type make. If you want a smaller program and do not care about error messages, you can comment out #DEBUG=1 and run strip sim resp. strip sim.exe after compile and linking.

For users on Windows systems: To debug, I recommend to run drmingw -i once in a shell. You will get a caller history in case of an error. gdb does not really work well and is a pain to use with the text interface.

Image:Make.png

Compiling with MS Visual C Express

For MS VC Express you have to hunt the matching zlib. Any version which is compatible with VC will do. Take a look at the instructions for compiling OpenTTD, which contains a libpng and a libz suited for simutrans too: http://wiki.openttd.org/index.php/MicrosoftVisualCExpress

You can compile without zlib, just make sure you disabled support for compressed savegames in your simuconf.tab. But you will not able to load compressed savegames then.

For debugging, you have to set the correct working directory, i.e. the directory where the pak/ folders are located and use the -use_workdir command line option.

Contribute

If you want to contribute, read the coding guidelines in sim/documentation/coding_styles.txt You might want to check out the international forum as well.

Problems

Building from source on AMD64 Linux: http://forum.simutrans.com/index.php/topic,5988.0.html

Personal tools