R-Type  2
Doom but in better
Loading...
Searching...
No Matches
R-Type server

Table of contents

  • Introduction
  • Compiling
  • Running the server
  • Configuration file
  • Troubleshooting
    • Common issues
      • Missing dependencies
      • CMake configuration failure
      • Build errors
      • Runtime errors
      • Networking issues
      • High latency or disconnects
    • Debugging tips
    • Getting help

Introduction

This file is dedicated to the R-Type server binary.

This is a binary that will provide a graphical interface to the program and allow the users to be able to interract with the game.

This document will only focus on the following sections of the server binary:

  • Compilation (from scratch) of the server binary
  • Running the server binary (and the options for the binary)
  • Editing the configuration file

Compiling

This section focuses on compiling the server binary without compiling the whole project (this means, without compiling the client).

If you wish to compile the project, please refer to the Getting Stated - Dependency - from source to make sure you have the required dependencies set up on your system.

If you wish to compile the whole project from source, please refer to the Getting Started - Deploy from source

Wether you are on Mac, Windows or Linux, the lines are the same, however, where Linux and Mac will use bash, Windows will use batch cmd.exe, most of the commands used are similare, however:

  • ls becomes dir
  • cd is the same
  • rm becomes del
  • cp becomes copy
  • mv becomes move
  • rm -rf becomes rmdir /s /q
  • tree is the same (although it is not natively installed on all linux systems)

In Windows, / become \ and you do not need to prefix files with ./.

Now that the differences are explained, let us attend to the core of this subject, compiling the program.

To do so, we will:

  • Navigate to the server folder
  • Create a build folder

We will now configure our project.

We will thus, run cmake -S . -B ./build in the server folder and let it run it's course.

‍Please make sure you have a stable internet connection or you will need to re-run this command for it to finish completing it's tasks.

This is only the case if you get a cloning error, red text saying something simmilare the following: Trying to clone , attempt 1 [...] attempt 3 error

However, if it is a missing dependency, try and install it, then re-run the cmake command.

The output of the command should be similare to the following:

‍The exact output may vary depending on the system but a simple rule to keep in mind is, no red color=no error.

-- The C compiler identification is GNU 13.3.0
-- The CXX compiler identification is GNU 13.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Configuring done (14.7s)
-- Generating done (0.0s)
-- Build files have been written to: /home/<user_account>/path/to/the/project/rtype/server/build

Once this command has run it's course, we can move on to the next section Compiling. To do so, while remaining in the same directory, you can run the command: cmake --build ./build.

The following output should appear colorised on your terminal (could not be reproduced here), this output should be simmilare to yours:

[ 14%] Building CXX object CMakeFiles/r-type_server.dir/src/GameManager.cpp.o
[ 28%] Building CXX object CMakeFiles/r-type_server.dir/src/main.cpp.o
[ 42%] Building CXX object CMakeFiles/r-type_server.dir/src/NetworkManager.cpp.o
[ 57%] Building CXX object CMakeFiles/r-type_server.dir/src/ProtocolHandler.cpp.o
[ 71%] Building CXX object CMakeFiles/r-type_server.dir/src/Server.cpp.o
[ 85%] Building CXX object CMakeFiles/r-type_server.dir/src/ThreadPool.cpp.o
[100%] Linking CXX executable r-type_server
[100%] Built target r-type_server

Now, when you look into the build folder using ls -ls build

‍Again, here, your output might be colourised, but due to the limitations of this document, they could ne be represented.

total 5224
20 -rw-rw-r-- 1 account_name account_name 50826 déc. 26 08:15 CMakeCache.txt
4 drwxrwxr-x 6 account_name account_name 4096 déc. 26 08:24 CMakeFiles
4 -rw-rw-r-- 1 account_name account_name 1895 déc. 26 08:15 cmake_install.cmake
4 drwxrwxr-x 8 account_name account_name 4096 déc. 26 08:15 _deps
4 drwxrwxr-x 5 account_name account_name 4096 déc. 26 08:15 lib
12 -rw-rw-r-- 1 account_name account_name 10147 déc. 26 08:15 Makefile
420 -rwxrwxr-x 1 account_name account_name 426040 déc. 26 08:24 r-type_server

The next step is to copy the binary r-type_server from the build folder to the base of the repository rtype.

Assuming you are still in the server folder, the following command to execute is: cp ./build/r-type_server ../

You can now copy (assuming you are still located in the server folder) the server_config.toml to the base of the repository with the following command: cp server_config.toml ../.

We are now done with the compilation of the server binary. You can keep this terminal open an run the cd .. command (assuming you are still located in the server folder) or reopen a fresh one in the base of the repository.

You can then follow the Running the server section.

Running the server

To check if the server binary is working, you can, in a terminal located in the same folder as the binary, run the command ./r-type_server --help

This should output the following content:

UDP Socket initialized on port 4242
Initializing game manager in progress
Server components build : ✅
Server started : ✅

Configuration file

The configuration file is a toml file that contains the settings for the server. Here is the default configuration:

‍The field names should not be changed because they are directly referenced by the program, however, feel free to change the field values.

But, be warned, with great power comes great responsability, changing critical ressources can lead to unexpected program behaviours.

>The default file name if server_config.toml

>The default expected location is <the same folder as the executable>

All relative paths located in the configuration file are based on the location where the program is located, but more importantly, they will be calculated by the program the moment it is run (thus, if not launched in the same folder, ressources may not be available).

[Connectivity]
# The host on which the server is listening
host="0.0.0.0"
# The port on which the server is listening
port=4242
[client]
# The maximum number of clients that can connect to the server
max_clients=100
# The maximum number of clients that can be in the same room
max_clients_per_room=10
# The maximum number of rooms that can be created
max_rooms=10
[timeouts]
# The maximum time in seconds a client can stay inactive connected before being disconnected (in seconds)
max_connection_time=300

Let's break it down:

Located in the [Connectivity] section is:

  • host: The host on which the server is listening. It can be a local IP address
  • port: The port on which the server is listening

Located in the [client] section:

  • max_clients: The maximum number of clients that can connect to the server
  • max_clients_per_room: The maximum number of clients that can be in the same room
  • max_rooms: The maximum number of rooms that can be created
  • max_connection_time: The maximum time in seconds a client can stay inactive connected before being disconnected

Located in the [timeouts] section:

  • max_connection_time: The maximum time in seconds a client can stay inactive connected before being disconnected

Troubleshooting

This section addresses common issues and solutions for the R-Type server.

Common Issues

1. Missing Dependencies

  • Symptom: Errors during the cmake or cmake --build process indicating missing tools or libraries.
  • Solution:

2. CMake Configuration Fails

  • Symptom: Errors during the cmake -S . -B ./build step, such as cloning error or missing components.
  • Solution:
    • Check your internet connection as cloning errors often result from connectivity issues.
    • Re-clone the repository if the source code appears incomplete or corrupted.
    • Address any missing dependencies highlighted in the error logs.

3. Build Errors

  • Symptom: The cmake --build ./build command fails with errors about missing files or incorrect configurations.
  • Solution:
    • Ensure the build folder is created within the server directory.
    • Delete and recreate the build directory, then rerun the configuration and build commands.

4. Runtime Errors

  • Symptom: The server binary crashes or fails to start with unexpected errors.
  • Solution:
    • Verify that the server_config.toml file is present in the same directory as the binary.
    • Check the configuration file for invalid values or missing required fields.
    • Use ./r-type_server --help to confirm the binary is working as expected.

5. Networking Issues

  • Symptom: Clients cannot connect to the server, or the server is unreachable.
  • Solution:
    • Ensure the server is running on a machine with an accessible IP address and port as specified in server_config.toml.
    • Check firewall or security settings that might block incoming or outgoing connections.
    • Verify the host and port settings in the [Connectivity] section of server_config.toml.

6. High Latency or Disconnects

  • Symptom: Clients experience lag or are disconnected frequently.
  • Solution:
    • Increase the max_connection_time in the [timeouts] section of server_config.toml.
    • Ensure the server has adequate hardware resources and network bandwidth to handle the number of connected clients.

Debugging Tips

  • Run the server with logging enabled (if supported) to capture detailed runtime information.
  • Validate the configuration file syntax to ensure all fields are correctly defined.
  • Test the server in isolation (without client connections) to identify potential issues with the server setup.

Getting Help

  • Refer to the Getting Started guide for dependency setup and compilation instructions.
  • Check the GitHub Issues page for existing problem reports.
  • Provide detailed information when seeking assistance:
    • Operating system and environment details.
    • Steps to reproduce the issue.
    • Complete error messages or logs.