Revision as of 09:36, 5 October 2024 by Librae (talk | contribs) (Created page with "This article describes the structure of the code of Librae. [The code itself is https://gitlab.com/librae/librae available on GitLab]. Part of the game engine is called <code>rustorion</code>. It's the older name for the project, and intended to be the name of the engine, when it is fully separated from game logic. ==Language== The game is written in Rust. It tries to be pure Rust, but some unique foreign components are still used, most prominently GTK4 for the user i...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Development:Structure

From librae wiki

This article describes the structure of the code of Librae. [The code itself is https://gitlab.com/librae/librae available on GitLab].

Part of the game engine is called rustorion. It's the older name for the project, and intended to be the name of the engine, when it is fully separated from game logic.

Language

The game is written in Rust. It tries to be pure Rust, but some unique foreign components are still used, most prominently GTK4 for the user interface.

Game state

The game is structured to support trustless (except the server), simultaneous multiplayer. The game state is stored as a single universe structure (rustorion::Universe). Client receives a view which contains only the information the client is supposed to know. Client sends actions to the server that contain the information about what the client wants to do on the current turn. When all the players are ready (submitted their actions or it's a timeout), the server processes all the actions (they are designed to be executed independently of each other, so there are no race conditions), performs various updating on the universe and notifies clients that they can download new views.

In the future, clients might be able to download previous views to browse them at will or use for gathering statistics.

Entities and IDs

Most things, entities within the universe, or anything else that implements EntityStored have an ID. It is an unique identifier of an entity within the storing structure. Using EntityStored::get() and other similar methods you can obtain a reference to the entity by its ID. IDs are used to store links between entities through plain inclusion on a structure, or using types from rustorion::storage::links for more complex relations like many-to-many.

IDs are issued sequentially, but then the number is encrypted with Blowfish to ensure there is no leaking information about number of entities in an universe. Because the encryption key is stored in Universe, only Universe can issue new IDs.