TrackMania Dedicated Server

1. INSTALLATION:

Decompress the zip file in a directory to install TrackMania Dedicated Server.
It can be installed either in the same directory of TMOriginal, TMSunrise or TMNations game, or in another directory.

Note: In order to run, you need,
- the server exe
- the GameData/DedicatedTrackMania.TrackMania.gbx file
- any challenges / matchsettings you want to play in the GameData/Tracks directory
- a dedicated.cfg file to set some parameters.


2. LAUNCH:

The dedicated server can be run from a windows shortcut or from a command line prompt.

The format of the command line is:

"{PATH}\TrackManiaServer.exe" /game={original | sunrise | nations} [/dedicated_cfg=config_file] [/game_settings=settings_file] [/internet]

If you use a windows shortcut, you can modify its properties to configure the launch of the server on the same way.
The target of the shortcut properties (first field) shares the same format of the command line.
So it will eventually have to look like this:

"{PATH}\TrackManiaServer.exe" /game=sunrise /dedicated_cfg=dedicated.cfg /game_settings=MatchSettings/settings.txt /internet

The working directory of the shortcut must also be set to the right directory.
It must correspond to the directory where TrackManiaServer.exe has been installed.


The dedicated server must be launched with the '/game=' option to define the game type (TMOriginal, TMSunrise or TMNations) that it will support.
To launch the dedicated server to support connection from TMOriginal games, 'game=original' must be specified, or '/game=sunrise' for TMSunrise, or '/game=nations' for TMNations

The dedicated server can be launched with or without a configuration file.
To pass the name of the configuration file to the dedicated server, the parameter '/dedicated_cfg=' must be specified followed by the name of the file.
The filename can be defined by a relative (to the exe location) or an absolute path.
The configuration file is an xml file which defines some basic parameters for the dedicated server.
See below for further details on configuration file.

A file containing game settings can also be specified to the dedicated server.
To do that the parameter '/game_settings=' must be defined followed by the name of the file.
This filename can be defined either by an absolute path or by a relative path to the '(PATH)\GameData\Tracks' directory.
The game settings file is an xml file which defines the match settings and a playlist of challenge that will be loaded.
See below for further details on game settings file.

If the server has been launched with a valid configuration file and a valid game settings file, it will directly start a new server on lan, or on Internet if the option '/internet' is specified.


TrackManiaServer can be launched at the same time that the retail version of TMOriginal, TMSunrise Extreme or TMNations game, but they cannot share TCP and UDP ports.
That's why it is recommended to launch the dedicated server before the game, so the dedicated server can use the expected ports.


In summary all the options, that can be specified to the dedicated server, are the following:

/dedicated_cfg=config_file

Specify a configuration file to use.

/game_settings=settings_file

Specify a game settings file to use.

/internet

Specify to the server that it must connect to the master server, in order to be an Internet server.

/verbose_rpc

Display the XmlRpc requests the dedicated server receives.

The server will only display the name of the XmlRpc command and some parameters.

/verbose_rpc_full

Display the whole contents of the XmlRpc requests the dedicated server receives.

/nodaemon

(linux) Doesn't detach the process.

/nologs

disable the creation of "GameLog.txt" and "ConsoleLog.txt"

/login=xxx

Masterserver account (overrides the value from the config_file)

/password=xxx

Masterserver account (overrides the value from the config_file)

/nation=xxx

Masterserver account (overrides the value from the config_file)

/servername=xxx

name of the server to create. (overrides the value from the config_file)

/serverpassword=xxx

password to join the server. (overrides the value from the config_file)

/loadcache

loads the "checksum.txt" instead of recomputing it. *DO NOT USE* if you run several servers in the same directory!

/forceip=xxx(:xx)

Forces the public ip address to this value (overrides the value force_ip_address from the config_file)

/bindip=xxx(:xx)

Choses the ip to bind to, and sets the public ip to this value. (you still can use /forceip to chose a different public ip)

/autoquit

If the server is not "live" (with a map loaded and ready to receive player), exit. Most notably, if there is a configuration error that prevent the server to be successfully launched, quit instead of staying in the "waiting for rpc commands" state.

3. CONTROL:

After being launched (with or without configuration files), the server can be also configured and controlled by rpc calls. (rpc= remote procedure call)
An external application can use any xmlrpc library to communicate with the dedicated server.

Some calls are only permitted to certain authorization level. There are three authorization levels (User, Admin and SuperAdmin), each one having an associated password (by default the same as the level name).
The 'Authenticate' method can be used to switch to a specified level.

The list of methods that can be called by xmlrpc can be found in the ListMethods.html file.

Some samples are available in the RemoteControlExamples/ directory:

In RemoteControlExamples/PhpRemote/ there is a basic.php script file that allows basic control of the dedicated server.
To use it, a web server must be installed on the same computer as the Trackmania server.
Any web server supporting PHP can be used, as the free web server Apache (www.apache.org) or EasyPHP a software package including Apache, PHP and MySQL (www.easyphp.org).

In RemoteControlExamples/GameController.Net/
There is a .net application "GameController.exe", that allows controlling the dedicated server through a point&click interface. This application is unfortunately not supported and rather buggy.
However, the sources are provided to build the application, including a library and interface file for easy use in other .net applications.
You can use them easily with either Microsoft's "Visual Studio .NET" or the free IDE "SharpDevelop" (http://www.icsharpcode.net/), both projects files are provided (GameController.sln and GameController.cmbx).

It includes a slightly modified version (that supports connecting to TrackMania) of the Xml-RPC.Net library, from http://www.xml-rpc.net

In RemoteControlExamples/c/xmlrpc-c
This is aimed at developers, it is the XmlRPC-c v1.03.11 library modified to support connecting to TrackMania. (from http://xmlrpc-c.sourceforge.net/ )
It also includes examples/xmlrpc_sample_trackmania.c : a small example of how to use the library, including a simple version and a more complete example with callbacks from the game.

Other people have developed very useful applications to control the TrackMania Server, you'll find more info about them on http://www.tm-forum.com/


4. CONFIGURATION FILE:

The configuration file is an xml file which defines some parameters like the system configuration of server (IP address, ports...), passwords for the three authorization levels.
The master server account parameters that can be used for the launch of the dedicated server on Internet, and other server parameters (name, comment, password, max players/spectators...).

You can find an example of configuration file (dedicated.cfg) in the TrackManiaServer root directory.
Here is what it contains by default:


<?xml version="1.0" encoding="utf-8" ?>
<dedicated>
<authorization_levels>
<level>
<name>SuperAdmin</name>
<password>SuperAdmin</password>
</level>
<level>
<name>Admin</name>
<password>Admin</password>
</level>
<level>
<name>User</name>
<password>User</password>
</level>
</authorization_levels>

<masterserver_account>
<login></login>
<password></password>
<nation></nation>
</masterserver_account>

<system_config>
<connection_type>DSL_512</connection_type>
<server_port>2350</server_port>
<server_p2p_port>3450</server_p2p_port>
<xmlrpc_port>5000</xmlrpc_port>
<xmlrpc_allowremote>False</xmlrpc_allowremote>
<force_ip_address>0.0.0.0:0</force_ip_address>
<bind_ip_address></bind_ip_address>
<blacklist_url></blacklist_url>
</system_config>

<server_options>
<name></name>
<comment></comment>
<password></password>
<password_spectator></password_spectator>
<max_players>8</max_players>
<max_spectators>8</max_spectators>
<ladder_mode>normal</ladder_mode> // value between 'inactive', 'normal' and 'forced' (or '0', '1', '2')
<vehicle_netquality>0</vehicle_netquality> // value between 'fast' and 'high' (or '0', '1')
<enable_p2p_upload>True</enable_p2p_upload>
<enable_p2p_download>True</enable_p2p_download>
<callvote_timeout>60000</callvote_timeout>
<callvote_ratio>0.5</callvote_ratio>
<allow_challenge_download>True</allow_challenge_download>
</server_options>
</dedicated>

The first block of parameters (<authorization_levels>...</authorization_levels>) allows to define passwords for the three authorization levels.

The second block of parameters (<masterserver_account>...</masterserver_account>) is used for the connection to master server of the dedicated server.
To allow the server to connect to master server, a login and password, that identify the dedicated server, must be specified.

* For nations, the account is automatically registered when the server is launched if it doesn't exist. You need to specify a valid nation.

* For sunrise and original, this account has to be created beforehand.
To do that, go to:
http://www.trackmania.com/dedicated/indexUk.php
or
http://www.trackmania.com/dedicated/indexFr.php
for a dedicated server account for TrackMania Original

And go to:
http://www.trackmaniasunrise.com/dedicated/indexUk.php
or
http://www.trackmaniasunrise.com/dedicated/indexFr.php
for a dedicated server account for TrackMania Sunrise

Here you must enter your multiplayer key to connect to the account creation site.
After that, you can create/modify as many accounts you want for dedicated server.

Game player accounts and dedicated server accounts are distinct.

The login and password of a game player account can also be used in the 'masterserver_account' block, instead of parameters from a dedicated server account.
But in this case the player cannot connect to Internet with his game, because his account is already used by the dedicated server.


The third block of parameters (<system_config>...</system_config>) defines the system configuration of the server.
For example it allows to define the type of network connection used, the different ports used by the dedicated server, or an IP that will be published on the master server.
The settings are:

connection_type

type of network connection used. It defines the network limitations of bandwidth that can be expected by the dedicated server (see below for values)

server_port

port number used by the server to listen the game connections

server_p2p_port

port number used by the server to listen the peer-to-peer connections

xmlrpc_port

port number used by the server to listen xmlrpc calls

xmlrpc_allowremote

should remote connections be accepted?

You can either set it to True or False, or specify an ip (or a symbolic name): in that case, only connections from that ip and localhost will be accepted.

(note: security on this channel isn't very strong and hasn't been thoroughly tested)

force_ip_address

if an IP address is defined in this parameter, the dedicated server will publish it as its public address instead of autodetecting it.

bind_ip_address

if an IP address is defined in this parameter, the dedicated server will bind to this ip and publish it as public ip, expect if force_ip_address is also specified.

blacklist_url

if an url is specified here, the dedicated server will check if there is an xml file that can be downloaded, and in this case if it's a blacklist file. If it is the case this blacklist will automatically loaded for this server


The values allowed for the 'connection_type' parameter are the following: 'Modem_56K', 'DSL_128', 'DSL_512', 'DSL_1024_128', 'DSL_1024_256', 'DSL_2048_128', 'DSL_2048_256', 'DSL_2048_512', 'DSL_4096_256', 'DSL_4096_512', 'DSL_4096_1024', 'DSL_6144_256', 'DSL_6144_512', 'DSL_6144_1024', 'DSL_8192_256', 'DSL_8192_512', 'DSL_8192_1024', 'DSL_8192_2048', 'DSL_16384_512', 'DSL_16384_1024', 'DSL_16384_2048', 'DSL_16384_4096', 'LAN'.


The fourth block of parameters (<server_options>...</server_options>) defines the main parameters that will be used by the dedicated server.
The settings are:

name

name of the dedicated server (must be specified for the game to launch)

comment

comment of the dedicated server

password

password needed at the connection to the dedicated server as player

password_spectator

password needed at the connection to the dedicated server as spectator

max_players

maximum number of clients that can join the server as player

max_spectators

maximum number of clients that can join the server as spectator

ladder_mode

ladder mode. The mode can be defined between these values : 'inactive' (0), 'normal' (1), and 'forced' (2)

enable_p2p_upload

value indicating if the server can upload custom data for P2P (0=False, 1=True)

enable_p2p_download

value indicating if the server can download custom data for P2P (0=False, 1=True)

callvote_timeout

timeout for waiting for votes (value in milliseconds)

callvote_ratio

ratio for accepting callvote. The value must lie between 0 and 1 (0=0%, 1=100%)

allow_challenge_download

value indicating if the server allows clients to download challenge (0=False, 1=True)


5. GAME SETTINGS FILE:

A game settings file is an xml file which defines the match settings like chat time, game mode, mode parameters, and a playlist of challenges that will be loaded.

You can find examples of game settings files in the (PATH)\GameData\Tracks\MatchSettings\ directory.
Here is what it contains:


<?xml version="1.0" encoding="utf-8" ?>
<playlist>
<gameinfos>
<game_mode>1</game_mode>
<chat_time>15000</chat_time>
<rounds_pointslimit>50</rounds_pointslimit>
<rounds_usenewrules>0</rounds_usenewrules>
<timeattack_limit>300000</timeattack_limit>
<team_pointslimit>5</team_pointslimit>
<team_maxpoints>8</team_maxpoints>
<team_usenewrules>1</team_usenewrules>
<laps_nblaps>3</laps_nblaps>
<laps_timelimit>0</laps_timelimit>
</gameinfos>

<filter>
<random_map_order>0</random_map_order>
</filter>

<challenge>
<file>Campaigns\Nadeo\Sunrise\Race\Holidays\CarPark.Challenge.Gbx</file>
</challenge>
<challenge>
<file>Campaigns\Nadeo\Sunrise\Race\Holidays\GoodMorning.Challenge.Gbx</file>
</challenge>
.
.
.
<challenge>
<file>Campaigns\Nadeo\Sunrise\Race\Pointbreak\HappyBay.Challenge.Gbx</file>
</challenge>
<challenge>
<file>Campaigns\Nadeo\Sunrise\Race\Pointbreak\Orbital.Challenge.Gbx</file>
</challenge>
</playlist>


The first block of parameters (<gameinfos>...</gameinfos>) defines the match settings that will be used by the dedicated server.
The settings are:

game_mode

game mode used between Rounds (0), TimeAttack (1), Team (2), Laps (3) and Stunts (4)

chat_time

chat time value in milliseconds

rounds_pointslimit

points limit for rounds mode

rounds_usenewrules

value indicating if new rules are used for rounds mode (0=False, 1=True)

timeattack_limit

time limit in milliseconds for time attack mode

team_pointslimit

points limit for team mode

team_maxpoints

number of maximum points per round for team mode

team_usenewrules

value indicating if new rules are used for team mode (0=False, 1=True)

laps_nblaps

number of laps for laps mode

laps_timelimit

time limit in milliseconds for laps mode


<random_map_order>..</random_map_order> : shuffle the list of challenges when the playlist is loaded. If not set, keep the playlist in the specified order.

Other blocks (<challenge>...</challenge>) describe all the challenges that will be loaded by the dedicated server.
Each block specifies the filename of a challenge.
Filenames can be defined either by an absolute path or by a relative path to the '(PATH)\GameData\Tracks' directory.


Any other elements in the file are ignored by the dedicated server.

Game settings file can be saved by the game with the 'save match settings' button in the server creation menu, after having selected the maps.
The files saved by the game are in the '(PATH)\GameData\Tracks\MatchSettings' directory.
So the relative designation for a such file is 'MatchSettings/settings_file.txt', where 'settings_file.txt' is the name of the saved file.

As a general rule, the challenges and matchsettings must always be in the directory "GameData/Tracks", and any relative name is interpreted using the "GameData/Tracks" as root.


6. GUESTLIST FILE:

A guestlist file "guestlist.txt" can be created in the GameData repertory, and will be automatically loaded by the game or server.
A player on the guest list is allowed to enter into the server in any case, even if there is no player slot left, and without needing to specify the password.

The guestlist file is an xml file as follows :

<?xml version="1.0" encoding="utf-8" ?>
<guestlist>
<player>
<login>Login1</login>
</player>
.
.
.
<player>
<login>LoginN</login>
</player>
</guestlist>

7. BLACKLIST FILE:

A blacklist file "blacklist.txt" can be created in the GameData repertory, and will be automatically loaded by the game or server.
A player on the black list will never be able to enter onto the server.

The blacklist file is an xml file as follows :

<?xml version="1.0" encoding="utf-8" ?>
<blacklist>
<player>
<login>Login1</login>
</player>
.
.
.
<player>
<login>LoginN</login>
</player>
</blacklist>

8. KNOWN ISSUES

- On the command you can't use names with ' ' in them, since the options are separated on whitespace, and no escaping (neither '\ ' nor '"') is supported.
- (linux only) the server expects the file names to be UTF-8 encoded. So pay attention if you're using non-ASCII characters.


9. CHANGELOG

2006-05-30:
- (linux) sometimes the server locked up with 100% cpu.
- escape the linefeeds in the chat log.
- fixes and enhancements to the xmlrpc-c library.
- changed the .Net lib so that it reattemps connection when broken

2006-04-25:
- a little issue with the logs.

2006-04-20b:
- it is no longer possible to connect to a server with the same login twice.
- fixed a bug in LAN games introduced in v2006-04-18.
- the field IpAddress in the player info now actually contains the IP (and not the login...)
- updated the c# xml-rpc lib so that it's easier to change server port / ip. (thanks to Cyrlaur).
- (windows) After a server restart, the gamelog file is no longer overwritten.

2006-04-18:
- added /autoquit to avoid zombie servers.
- added ChatSendServerMessageToId, ChatSendServerMessageToLogin xml-rpc commands.
- worked around a bug with the case of logins. (disturbing, for instance, the votes)
- (team, laps, rounds) sorted the scores by time when points identical.
- other small bugs.. (dns issues, random crashes ...)

2006-03-28:
- The guestlist has now precendence over black/ban lists.
- (rounds, team) BestCheckpoints now contains the checkpoints from the best race, and not the checkpoints from the last race..
- GetVersion() also returns the current dedicated server version.
- EndRace() callback now also sends the current challenge
- fixed issues with validation in team mode
- new chat command '/version'

2006-03-24:
- fixed score in rounds mode when more than 20 players cross the finish line.
- (sunrise, orginal) PlayerConnect callback now has the login..
- Some problems with team mode (validate, ...)
- (windows) Fixed the logs (shared read flag, directory now correctly created)
- Only '/s' is a reserved chat command, and not all strings starting with 's'...
- More infos in GetCurrentRanking: the PlayerId (which is the team number in team mode), + all the checkpoints time of the best times
- updated php and c xml-rpc samples.
- added some more details in the logs
- fixed some issues in ChooseNextChallenge()
- ChatSendToLogin() now works even if the player is a spectator.
- New command ForceScores() available in rounds and team to change fix the scores.
- (linux, original/sunrise) some problems with invalid times should be fixed.

2006-03-10:
- fixed a little problem with dealing with default value for /bindip
- Added a xml-rpc command to cancel a vote.
- fixed a bug in xml-rpc that would shutdown the connection when receiving a lot of commands at the same time.
- Added a StatusChanged() callback
- Fixed a problem introduced in the previous version with saving guest/black lists.
- (sunrise, original) Some adjustments to SetFinishTimeout()
- (nations) Added the nation of the players in the PlayerInfo xml-rpc struct.
- polished the xml-rpc C example.
- fixed an issue with GetCurrentRanking() in team mode.

2006-03-07:
- You can now chose the IP to bind to. (/bindip , <bind_ip_address>)
- If no blacklist filename is specified, the default one is loaded.
- You can now read the result of a ServerMessage via xml-rpc (GetServerMessageResults, and PlayerServerMessageAnswer callback)
- A new sample xml-rpc client has been added. It is a C library, and shows how to use callbacks.
- some bugs fixed (memleaks, c# client library, the xml-rpc callbacks,...)
- there was an unused UDP port opened..

2006-02-24:
features:
- the dedicated server account is now automatically registered. you don't need to do it from the game any longer. (but you have to provide a valid nation in addition to login/password)
- You can now limit the xml-rpc to listen only a specific ip (in addition to the loopback address). Just specify an ip (or symbolic address) in xmlrpc_allowremote parameter.
- added a command to force the current Round/laps to finish. ForceEndRound()
- (sunrise, original) Rounds/Laps mode. You can now set the time allowed for the other players to finish the race after the first one arrived. Set/GetFinishTimeout().
- added a command to upload a file via xml-rpc interface. WriteFile()
- Changed the xml-rpc custom protocol, in order to allow "callbacks". You can now receive the following events:
    PlayerConnect, PlayerDisconnect, PlayerChat, ServerStart, ServerStop, BeginRace, BeginRound, RaceOver, PlayerCheckPoint, PlayerFinish
- set SO_REUSEADDR on listening sockets.
bugs fixed:
- The ladder is now disabled if you create a server with more than 50 players.
- (linux) The server should no longer block for a long time, and make all player times invalid.
- (linux) The dns problems that where present on some distributions should now be fixed.
- Security checks on the xml-rpc command have been reinforced.
- During the vote, after the time expires, the abstentionists no longer count as voting "no".
- The restart no longer triggers a full reload after changing some parameters that don't need it.
- The shuffle should now be always different at each run.
- Fixed issues with filenames - RemoveChallenge & friends should now work better.
- GetPlayerList(10,0) now returns 10 players if available (and not 9..)

2006-02-03b:
- Playlists are no-longer shuffled by default.
(add <filter> <random_map_order>1</random_map_order> </filter> in the match settings to enable it again)
- The logs are written in the "Logs" subdir
- various problems with P2P and the shutdown of connections.
- Enabled optional (and not recommended!) remote access to the xml-rpc port.
- Enabled "/netip=" command line option back, to allow specifying the force_ip_address option.
- A few more error messages to the console log.
- some rare crashes were fixed.
- Default black/guest list filenames are now correct, so they are actually loaded on server startup if they are in the default "GameData/{guest,black}list.txt" location.
- (linux) the game now works on reiser filesystems. ("DT_UNKNOWN" errors fixed)
- (linux) Fixed the P2P on the server. The server can now also act as a relay for the P2P.
- (linux) GetxxxDirectory() now returns a correct value.
- (linux) The cpu load has been reduced.
- (windows) DirectX is no longer needed to run the dedicated server.
- (windows) fixed a problem with the Timer going out of control
- (windows) Included an updated version of the c# remote example. (but it's not supported at all and just hardly working...)

2006-01-29:
- xml-rpc LoadGuestList and LoadBlackList now work (linux).
- support of running several instances of the server in the same folder.
- the logs are now postfixed with process id / login; and the cache checksum file is ignored by default.
- support of overriding some config_file values from the command line.
- fixed a network race condition, where a server could be put in a state where
it was still running but no longer published on the masterserver.

2006-01-25b:
initial Nations support release.