A Guide to Set Up a Freeciv Game Server on Your Linux Machine

Introduction

In this guide, I will show you how you can set up your own Freeciv game server with the stable LTT (LongTurn Traditional) ruleset and host your own games in it. I will also show where to find all the latest releases of the Freeciv client. 

Note: I used an AWS machine that is running an Ubuntu Server 22.04.1 LTS. These steps should generally apply to any Debian-based Linux distros using the APT package management tool.

Step 1 – Preparations

Before actually installing the Freeciv client you need to download the .deb file first. To do this, you can use the wget command. Like this:

wget https://github.com/longturn/freeciv21/releases/download/v3.0-rc.1/freeciv21_3.0-rc.1_amd64.deb

Note: By the time I’m writing this guide, the latest stable version of the Freeciv client is 3.0-rc.1. Later releases can be downloaded by replacing that .deb file with the corresponding link to the desired client version. All the latest releases can be found in the Longturn GitHub repository: https://github.com/longturn/freeciv21/releases

Step 2 – Installation

Now that you have downloaded the .deb file, you can start installing the client on your machine. To do this, you need to use the apt command with root privileges. Like this:

sudo apt install ./freeciv21_*_amd64.deb

Step 3 – Preparations for the Addition of the LTT Ruleset

The client will be installed under your home directory. For me the path was /home/user/.local/share/freeciv21

Before you do anything too crazy, you have to create a subdirectory for the LTT ruleset files under the freeciv21 directory. You can use the mkdir command to create it. Like this:

mkdir ~/.local/share/freeciv21/LTT

Step 4 – Retrieving the LTT Ruleset Files

To play the game with the LTT ruleset, you need to have the files in your computer. You can get them from the Longturn GitHub repository with the help of the wget command. The LTT ruleset files can be found at: https://github.com/longturn/LTT-LTX/tree/master/LTT/data/LTT

Click the README.LTT and get the raw link by pressing the “raw” button on the top right corner of the file.

Press the "raw" button on the bottom right corner in GitHub to retrieve the ruleset files.

Then you can use the wget command to download the files on your computer. Like this:

wget https://raw.githubusercontent.com/longturn/LTT-LTX/master/LTT/data/LTT/README.LTT

Note: Repeat the same with every file in the folder. Keep the base and just change the filename in the link. Alternatively, you can use some GitHub zip download tool to speed up the process.

Step 5 – Moving the Ruleset Files to the Correct Folder

After downloading the ruleset files under your home directory, you need to move the files to the LTT folder under the freeciv21 directory. You can do this with the mv command. Like this:

mv ~/README.LTT ~/.local/share/freeciv21/LTT

You can search the ruleset files from your home directory with the help of find and grep commands. Like this:

find /home | grep ruleset

Note: Remember to copy all the files from your home directory to the LTT folder. Not every file are .ruleset files so if you used grep to search for the files in your home directory, remember to also search for .lua and .LTT files.

Step 6 – Retrieving the LTT Serv File

After successfully retrieving and moving the LTT ruleset files in the LTT folder under your freeciv21 directory, you have to download the .serv file for the game. You can one again use the wget command to do this. Like this:

wget https://raw.githubusercontent.com/longturn/LTT-LTX/master/LTT/LTT.serv

Step 7 – Modifying the LTT Serv File

Before you can start hosting your own games, you have to modify the LTT.serv file to work properly on your machine. First, you have to open the .serv file in your preferred text editor like nano. Like this:

nano ~/LTT.serv

Now that you have the file open, you have to remove a few sections of it and change the value of the set maxconnectionsperhost to 100.

7.1 What to Remove?

Scroll to the bottom of the file and remove everything from the #players section to the word start. In other words, remove lines 160-165. You can press Alt+C to show the line numbers in nano or alternatively, you can use the cat command with the -n option. Like this:

cat -n ~/LTT.serv

You have to also remove lines 110-112 (from set timeout to set fixedlength) unless you want the turn to last 23 hours. By default, the turn ends when every player has pressed the “turn done” button.

After you have removed the lines mentioned above, search for set maxconnectionsperhost and change the value from 4 to 100. This is to prevent any connection errors.

Now the .serv file is modified and almost ready to be used to host your own games.

Note: Remember to save the file! Press Ctrl+X in nano and then press “y” when it asks whether the modified buffer should be saved or not. Then just press enter.

Step 8 – Moving the Modified Serv File to the Correct Directory

After you have modified and hopefully saved the .serv file, it’s time to move it to the correct directory. You can use the same technique for this as you used to move the ruleset files to the LTT folder. Like this:

mv ~/LTT.serv ~/.local/share/freeciv21

Note: It’s important to move the LTT.serv file directly under the freeciv21 directory not to the LTT folder.

The Freeciv game server files should be located under /home/User/.local/share/freeciv21/
After moving all the ruleset files and the .serv file to the correct places, your freeciv21 directory should look something like this. You can use find and grep commands to confirm that. Like this:
























find /home | grep freeciv

Step 9 – Launching the Server

Now you are ready to launch the server for the first time. To do this, use the command freeciv21-server with the option -r LTT.serv so it loads the correct ruleset for the game. Like this:

freeciv21-server -r LTT.serv

Note: While it’s not necessary, it’s recommended to use a terminal multiplexer like tmux to run the game. That way you don’t have to have an open connection to the server the whole time.

You can get tmux with the apt install command. Since you are installing an app on your computer, you need to run the command with root privileges. Like this:

sudo apt install tmux

After you have installed tmux on your computer, you can run it with the command tmux or you can create a new session with a name with the following command:

tmux new -s (your session)

Now that you have your session running, you can use the command freeciv21-server -r LTT.serv to start your server.

Note: The default port for Freeciv21 is 5556. You can change the port by typing -p (your port) after the freeciv21-server -r LTT.serv command when starting the server. Like this:

freeciv21-server -r LTT.serv -p (your port)

You can now close the terminal window if you want to. The game will continue running in the background. You can always return to the tmux session with the following command:

tmux a -t (your session)

Or just tmux a if you didn’t create a name for the session or if this is your only session running.

Step 10 – Installing the GUI Client and Setting Up a Game

Now that you have your server running, you need players, right? The server client is actually the same as the GUI client so the installation steps are essentially the same. 

If you have Linux, you can follow the steps mentioned at the top of the page. If you have Windows, go to https://github.com/longturn/freeciv21/releases and download the latest .exe version of the client.

Note: The current stable version of the client is v3.0.-patch.4

10.1 Connecting to the Game

When you have the server running, the players can connect to the game via the GUI client. On the client, click “Connect to network game” and use the following settings to connect to the game:

Connect: Your host machine’s IP address

Port: Either the default port (5556) or if you set a custom port, use that.

Username: Since this guide didn’t cover how to enable fcdb, you can pick whatever username you want to. Fcdb allows you to accept connections only from registered users.

10.2 Starting and Ending the Game

After starting the server, wait until all players have connected and picked their nations. When everyone is ready, type start to the server’s console. This will start the game. To end the game, type end or endgame. Type help for additional info.

Conclusion

Installing and configuring a Freeciv game server on your machine is a rather easy task and shouldn’t take you much time. However, you should be extra careful not to put any files into wrong folders as it can cause reading issues between the .serv configuration files and ruleset files. The server will notify you in case there is a problem in reading the correct ruleset files. Remember to also make sure the permissions to those files are correct.

image_pdf
Kotisivu » Artikkelit » A Guide to Set Up a Freeciv Game Server on Your Linux Machine

Ei vielä kommentteja

Harkitsehan kommentin jättämistä!