How arturohe/darkmultiplayerenchanced works
1. What this repository is
DarkMultiPlayer is a client-server multiplayer mod for Kerbal Space Program. The repo is split into a game client plugin and a standalone server, with a small shared common library used by both sides.
2. Top-level architecture
The main boundaries are:
- Client/: code that runs inside the KSP game process and integrates with the game/UI.
- Server/: headless multiplayer server that manages sessions, state, permissions, and persistence.
- Common/: shared low-level utilities for message buffering, compression, recycling, and serialization support.
- External/: vendored third-party dependencies and KSP-managed assemblies required to compile against the game API.
- Documentation/: protocol and behavior notes that describe key subsystems like network messages and subspace locking.
3. Runtime model
The client is a game plugin loaded by KSP and is responsible for syncing local gameplay with multiplayer state.
The server is a separate .NET application intended to run cross-platform; the README notes .NET/Mono support and a server config folder. This is a classic authoritative server model rather than peer-to-peer.
4. Shared protocol layer
Common/ contains infrastructure used by both sides:
- byte-array pooling/recycling for network efficiency,
- compression utilities,
- serializers and shared helpers.
The presence of Documentation/network-message-format.txt and many message-specific classes on the server indicates a custom binary message protocol between client and server.
5. Server responsibilities
The server is the authoritative coordinator for multiplayer state. Its major subsystems include:
- Connection and client management (ClientHandler, ServerInfo, Main)
- Administrative controls (AdminSystem, AdminCommand, KickCommand, PMCommand, WhitelistCommand)
- Access control and policy (Permissions, BanSystem, WhitelistSystem, Groups)
- Gameplay synchronization (LockSystem, ModpackSystem, GameplaySettings, WarpControl, vessel and kerbal messages)
- Persistence/safety helpers (SafeFile, log expiration, screenshot expiration)
6. Server message surface
Server/Messages/ is a strong architectural clue: each file maps to a protocol domain such as:
- handshake and heartbeat,
- chat,
- vessel updates/removal/requests,
- time sync and warp control,
- player status/color,
- scenario and kerbal data,
- modpack and server settings,
- screenshots, craft library, flags, permissions, and lock state.
This suggests the server is organized around domain messages, not a single monolithic sync loop.
7. Client responsibilities
The client side is a set of coordinated workers and UI windows that embed multiplayer behavior into KSP. Key areas include:
- Network/session management (NetworkWorker, ConnectionWindow, ServerListConnection)
- Vessel synchronization (VesselWorker, VesselUpdate, VesselProtoUpdate, VesselRecorder, VesselCtrlUpdate)
- Time and warp (TimeSyncer, WarpWorker, DynamicTickWorker)
- Game-state sync (ScenarioWorker, CraftLibraryWorker, FlagSyncer, PlayerColorWorker, PlayerStatusWorker)
- Social/admin features (ChatWorker, AdminSystem, PermissionsWindow, GroupsWindow)
- Safety and gameplay helpers (SafetyBubble, PartKiller, KerbalReassigner, VesselRangeBumper)
8. Client UI and integration boundary
The numerous *Window.cs files show that the client includes in-game UI for connection, options, mod control, server lists, debugging, permissions, groups, disclaimers, and universe conversion.
This indicates a boundary between:
- presentation/UI logic
- sync/control workers
- KSP game object manipulation
The client appears to use KSP’s mod/plugin extension points rather than a separate launcher as its primary runtime.
9. Gameplay and state synchronization
A central design goal is preserving consistency across players while allowing KSP gameplay to continue. Important state domains include:
- Vessels: state, control, prototypes, deletion, and range constraints
- Kerbals: status and reassignment
- Scenarios: persisted game/scenario data
- Flags and craft libraries
- Player presence/status
- Subspace time / warp control
The Documentation/subspace-locking.txt file and the README mention subspace-style warping and master-controlled warp, so time handling is a first-class system, not a simple clock sync.
10. Mod and compatibility control
Mod compatibility is treated as part of the multiplayer contract:
- ModpackSystem on the server
- ModWorker, ModpackWorker, DMPModInterface on the client
- README references DMPModControl.txt and whitelist/blacklist mode
This means connection eligibility depends not just on the server address, but also on mod set compatibility, which is enforced as part of session setup.
11. External dependencies and KSP coupling
The External/ folder contains third-party parsing, messaging, and KSP-specific assemblies. That implies:
- the client compiles against Kerbal Space Program managed assemblies,
- the networking/serialization stack is partly vendored,
- the repo is designed to be buildable from source with game binaries present.
12. Configuration and operational model
Server behavior is driven by editable config files such as Config/Settings.txt and Config/GameplaySettings.txt per the README.
The server therefore acts as an operator-managed multiplayer authority: admins configure rules, permissions, whitelists, bans, groups, and gameplay settings externally from the code.
13. Diagram-friendly summary
For an architecture diagram, the key nodes are:
- KSP Game Client + DarkMultiPlayer plugin
- DarkMultiPlayer Server
- Shared Common library
- External KSP/utility dependencies
The main arrows are:
- client ↔ server over a custom binary message protocol,
- server → clients for authoritative state sync,
- clients → server for user actions and local game events,
- both sides using shared serialization/compression utilities.
Main entry points: Client/Main.cs Game plugin · Server/Main.cs Server core · Handshake.cs Message types · NetworkWorker.cs Network worker
Components 18
Client
In-game KSP plugin and UI/runtime workers
- Game plugin · Entry point and integration with Kerbal Space Program
Client/Main.cs - Network worker · Handles server connection, session setup, and message flow
Client/NetworkWorker.cs - Vessel sync · Coordinates vessel updates, control, recording, and range rules
Client/VesselWorker.cs - Time sync · Manages subspace timing, warp control, and tick behavior
Client/TimeSyncer.cs - Game sync · Synchronizes scenarios, flags, craft library, colors, status, and screenshots
Client/ScenarioWorker.cs - UI windows · Connection, options, permissions, groups, debug, and conversion screens
Client/ConnectionWindow.cs - Client controls · Chat, admin actions, permissions, groups, and mod control
Client/AdminSystem.cs - Safety helpers · Prevents desync-prone or unsafe gameplay behavior
Client/SafetyBubble.cs
Server
Standalone authoritative multiplayer server
- Server core · Main process for client management, session orchestration, and server lifecycle
Server/Main.cs - Client handler · Tracks connected players and per-client state
Server/ClientHandler.cs - Sync systems · Authoritative systems for vessels, time, locks, settings, and modpack state
Server/LockSystem.cs - Policy layer · Admins, bans, whitelists, permissions, and groups
Server/AdminSystem.cs - Message types · Custom binary message handlers for handshake, chat, vessels, time, players, scenarios, and settings
Server/Messages/Handshake.cs - Ops helpers · Safe file handling, log expiration, screenshot expiration, and server info
Server/SafeFile.cs
Shared
Code and assets used by both client and server
- Common lib · Shared byte buffers, recycling, compression, and common helpers
Common/Common.cs
Dependencies
Vendored external libraries and game assemblies
- KSP assemblies · Kerbal Space Program managed assemblies needed by the client plugin
External/KSPManaged/files_go_here.txt - Vendored libs · Parser, messaging, and utility libraries bundled for builds
External/MessageStream2
Docs
Protocol and behavior documentation
- Protocol docs · Network message format and subspace locking behavior
Documentation/network-message-format.txt
Connections 23
- Game plugin → Network worker: starts · Bootstraps networking and session setup
- Game plugin → Vessel sync: runs · Coordinates vessel sync workers
- Game plugin → Time sync: runs · Coordinates warp and time sync
- Game plugin → Game sync: runs · Coordinates scenario and world-state sync
- Game plugin → UI windows: shows · Presents in-game windows and dialogs
- Game plugin → Client controls: uses · Provides chat, admin, and mod-control features
- Game plugin → Safety helpers: enforces · Applies gameplay safety constraints
- Network worker → Server core: connects to · Client session reaches the authoritative server
- Vessel sync → Message types: exchanges · Sends and receives vessel protocol messages
- Time sync → Message types: exchanges · Syncs time and warp control messages
- Game sync → Message types: exchanges · Syncs scenario, flags, screenshots, and player state
- Client controls → Message types: exchanges · Uses chat, permissions, and admin-related messages
- Server core → Client handler: manages · Accepts and tracks connected clients
- Server core → Sync systems: orchestrates · Coordinates authoritative multiplayer subsystems
- Server core → Policy layer: applies · Loads and enforces access and admin policy
- Server core → Message types: routes · Dispatches protocol messages to domain handlers
- Server core → Ops helpers: uses · Handles persistence and operational housekeeping
- Message types → Protocol docs: defined by · Protocol domains are documented in message format notes
- Game plugin → Common lib: uses · Shares serialization and buffer utilities
- Server core → Common lib: uses · Shares serialization and buffer utilities
- Game plugin → KSP assemblies: depends on · Runs inside the KSP game process and API
- Game plugin → Vendored libs: depends on · Uses bundled parsing and utility libraries
- Server core → Vendored libs: depends on · Uses bundled parsing and utility libraries