How kumpelblase2/skrillax works
Project Type and Purpose
• This is a Rust-based server emulator project for an MMORPG (Silkroad Online). Its main goal is to learn Rust and ECS concepts by implementing a partially working game server.
• The project is modular, consisting of several interrelated subprojects (crates) that handle protocols, game logic, navigation mesh, login, RPC, and more.
• Key servers include the silkroad-gateway (login server) and silkroad-agent (game server), which communicate with each other and a PostgreSQL database.
Analyzing the File Structure
• Top-level directories to note:
– configs (with separate TOML configuration files for the agent and gateway servers)
– migrations (SQL scripts used to set up the database schema)
– crates (contains several sub-crates such as silkroad-protocol, silkroad-data, silkroad-gateway-protocol, silkroad-rpc, silkroad-navmesh, silkroad-game-base, silkroad-protocol, etc.)
– silkroad-agent and silkroad-gateway (each with multiple modules such as login, game, net, chat, sync, etc.)
• There are also Docker-related files and docker-compose examples, indicating containerized deployment is supported.
• The project is organized as a multi-crate Rust workspace which promotes modularity and separation of concerns – for instance, separating protocol definitions from game logic and external communications.
Key Components
a. Client & External Dependencies:
– The Silkroad Online client (external; not part of the repository but as the consumer that interacts with the servers).
– External dependencies such as the “skrillax-network” family of crates.
b. Servers:
– Silkroad Gateway Server: Handles authentication, login procedures, and forwarding registration commands.
– Silkroad Agent Server: Main gameserver, handling game logic such as NPC management, gameplay events, movement, inventory, etc.
c. Shared Components and Libraries:
– Protocol Definitions: Provided by crates like silkroad-protocol and silkroad-gateway-protocol. These define the packet specifications and communication contracts with the client.
– RPC & Shared Types: silkroad-rpc for inter-server communication.
– Navigation Mesh: silkroad-navmesh handles the world geometry/navigation used by agent server.
– Game Base and Data: crates like silkroad-game-base, silkroad-data, and silkroad-definitions encapsulate core game logic, character data, inventory, items, etc.
d. Infrastructure:
– Database: PostgreSQL instance (setup via migrations and configured in the TOML files). It stores persistent game data, user accounts, world definitions, etc.
– Deployment: Docker Compose is utilized to spin up containers for the database, gateway, and agent servers.
– Configuration Files: Located in the “configs” directory, defining server-specific parameters (database credentials, game data location, RPC addresses).
Relationships and Interactions
– Clients connect to the Silkroad Gateway server to authenticate and potentially register new users.
– Once authenticated, the gateway communicates, possibly via defined RPC channels (“silkroad-rpc”), with the Silkroad Agent server where actual game logic and state management are handled.
– Both servers interact with the PostgreSQL database for persistence, relying on SQL migrations and configuration settings.
– Shared libraries (protocol, data, navmesh) form the foundation for data formats and core mechanics (e.g., movement, combat, chat, inventory) that are used throughout the servers.
– The ECS design within the agent’s codebase (evident in directories such as “agent/src/agent” and “agent/src/comp”) organizes game state and systems like chat, movement, skill processing, etc.
Architectural Patterns and Design Principles
– Modularity: The system is divided into several crates each with a focused responsibility (protocol, game core, navigation, etc.).
– Service Separation: A clear separation between the login (gateway) and game (agent) servers.
– ECS (Entity Component System) is used in the agent server to manage game objects and behavior.
– Configuration-as-code: Use of TOML configuration files allows flexible environment setups.
– Containerization: Docker and docker-compose ensure repeatable deployments and clear separation of infrastructure components.