Architecture
Freeciv21 uses a client/server model where two programs interact over a network connection. The client
(freeciv21-client
) is the program that you see on the screen. It handles user commands and forwards them
to the second program, that we call the server (freeciv21-server
). The server checks the commands,
computes their result and sends updates back to the client. The client is capable of managing a server for
its own needs, which is used for single player games. It can also connect to a server managed externally,
which is how multiplayer games work.
The Freeciv21 code is old and evolved from a program written in C. It still bears a lot of this history, but this is being worked on. New code is written in C++, using modern constructs when it makes sense and relying heavily on the Qt Framework for platform abstraction. This is currently most visible in the client, but the rest of the code base is slowly being converted as well.
Repository Organization
The source code is organized in directories at the root of the repository. The client and server share a lot
of code found in the common
and utility
folders. The first one contains code to manage the
game state, of which both the client and server have a copy, and the second is home to various lower-level
utilities that do not have an equivalent in Qt or the C standard library. Freeciv21 also ships with a couple
of external dependencies under dependencies
.
The client code is found in the client
folder. The server code is located under server
,
with the exception of the computer (AI) players which is under ai
. The code for other programs
bundled with Freeciv21, such as the Modpack Installer, is located under
tools
.
All the assets used by the client and server are grouped under data
. This includes among
others rulesets and tilesets.
Localization files are located under translations
.
There are a few additional folders that you will touch less often. The table below describes the complete structure of the repository:
Folder |
Usage |
---|---|
|
Code for computer opponents. |
|
Client code. |
|
Build system support code. |
|
Code dealing with the game state. Shared by the client, server, and tools. |
|
Game assets. |
|
External dependencies not found in package managers. |
|
Files related to distributing Freeciv21 for various operating systems. |
|
This documentation. |
|
Useful scripts used by the maintainers. |
|
Server code. |
|
Small game-related programs. |
|
Localization. |
|
Utility classes and functions not found in Qt or other dependencies. |
Note
Some folders do not follow this structure. Their contents should eventually be moved.