teeworlds

Table of content

Client

Installation of Client

$ apt install teeworlds

Vanilla Server

Installation of Server

$ apt insatll teeworlds-server

FW rules

These are only needed if you run the teeworlds server behind a FW or as a vm/container

$ interntwservernet="10.13.37"
$ interntwserversubnet="${interntwservernet}0/24"
$ interntwserverip="${interntwservernet}.64"
$ interntwserverport=8303
$ externalserverip="37.120.185.132"
$ externalnic="ens3"
$ internalnic="lxcbr0"
$ iptables -A FORWARD -i ${internalnic} -j ACCEPT
$ iptables -A FORWARD -p udp -d ${interntwserverip} --dport ${interntwserverport} -j ACCEPT
$ iptables -A OUTPUT -d 0.0.0.0/0 -p udp -m udp --sport ${interntwserverport} -s ${interntwserverip} -j ACCEPT
$ iptables -A PREROUTING -i ${externalnic} -p udp -d ${externalserverip} --dport ${interntwserverport} -j DNAT --to-destination ${interntwserverip}:${interntwserverport} -t nat
$ iptables -A POSTROUTING -s ${interntwserversubnet} -o ${externalnic} -j MASQUERADES -t nat

Configruation of TWServer

You can use the file /etc/teeworlds/server.cfg as configuration file. After you have installed it with the package you will get there a default configuration, open it with your editor of trust (e.g. vim ;) and change the following lines (minimum)

  • sv_name
  • sv_port
  • sv_bindaddr
  • sv_rcon_password
  • password

Or you can do it just with sed like this:

sed -e -i 's/^sv_name .*/sv_name This is the name of my server/g;
           s/^sv_port.*/sv_port 8303/g;
           s/^sv_bindaddr.*/^sv_bindaddr 37.120.185.132/g;
           s/^sv_rcon_password/^sv_rcon_password ThisIsThePwdForTheRemoteConsoleMakeItAGood0ne/g;
           s/^password/password ThePWDtoConnect4Playing/g' /etc/teeworlds/server.cfg

By default teewolds uses untypical paths where it is looking for data/confs/files To get rid of that issue, you can create the file storage.cfg and store it at the same dir as the teeworlds-server bin is located.

Sample for file:

####
# This specifies where and in which order Teeworlds looks
# for its data (sounds, skins, ...). The search goes top
# down which means the first path has the highest priority.
# Furthermore the top entry also defines the save path where
# all data (settings.cfg, screenshots, ...) are stored.
# There are 3 special paths available:
#   $USERDIR
#   - ~/.appname on UNIX based systems
#   - ~/Library/Applications Support/appname on Mac OS X
#   - %APPDATA%/Appname on Windows based systems
#   $DATADIR
#   - the 'data' directory which is part of an official
#   release
#   $CURRENTDIR
#   - current working directory
#   $APPDIR
#   - usable path provided by argv[0]
#
#
# The default file has the following entries:
#   add_path $USERDIR
#   add_path $DATADIR
#   add_path $CURRENTDIR
#
# A customised one could look like this:
#   add_path user
#   add_path mods/mymod
####

add_path /home/_teeworlds/.local/share/teeworlds
add_path /usr/share/games/teeworlds/data
add_path /home/_teeworlds
add_path /usr/games

Running the server

For you first runs, you can just start it directly from the CLI like

$ su - _teeworlds
$ /usr/games/teeworlds-server -f /etc/teeworlds/server.cfg | /usr/share/games/teeworlds/teeworlds_datetime.sh

If everything works as you want, i would enable in the server.cfg the logging (don’t forget about logrotation and a fail2ban monitoring), you can create a simple systemd unit file something like that:

###### NEED TO DO

Custom or Mod Server

To have something like AI/Bots running around on your server/map or you want to have new weapons or I don’t know, maybe Darth Vader passing by and killing everyone, you need to get a custom or modded server. Have a look on google, there are some projects out there. E.g. for Bots we are trying currently: GitHub/nheir/teeworlds

Installing custom or modded server

First, download the git repository

$ cd /opt
$ git clone https://github.com/nheir/teeworlds.git
$ cd teeworlds

Next is to get the git submodules

$ git submodules update --init

Now you want to create a build directory and run the cmake command

As a small hint, you can use the parameters -GNinja -DDEV=ON -DCLIENT=OFF to speek up the build process

-GNinja: Use the Ninja build system instead of Make. This automatically parallizes the build and is generally faster. (Needs sudo apt install ninja-build on Debian, sudo dnf install ninja-build on Fedora, and sudo pacman -S --needed ninja on Arch Linux.)

-DDEV=ON: Enable debug mode and disable some release mechanics. This leads to faster builds.

-DCLIENT=OFF: Disable generation of the client target. Can be useful on headless servers which don’t have graphics libraries like SDL2 installed.

$ mkdir build
$ cd build
$ cmake .. -GNinja -DDEV=ON -DCLIENT=OFF

After the build finis successfully you should find a new binary in the build dir e.g.:

$ ls -lart
drwxr-xr-x 16 root root    4096 Jul 15 18:45 CMakeFiles
-rw-r--r--  1 root root  110307 Jul 15 18:45 build.ninja
-rwxr-xr-x  1 root root 2279848 Jul 15 18:50 teeworlds_srv

Congratulations, new you have the custom server binary file teeworlds_srv build and it is ready to use.

The execution of the server is normally the same was as you would do with the vanilla server, just use instead of the old path/bin the new one.

Old or vanilla server call

$ /usr/games/teeworlds-server -f /etc/teeworlds/server.cfg | /usr/share/games/teeworlds/teeworlds_datetime.sh

New or custom or modded call

$ /opt/teeworlds/build/teeworlds_srv -f /etc/teeworlds/server.cfg | /usr/share/games/teeworlds/teeworlds_datetime.sh