How zimbadev/crystalserver works
Crystal Server is a C++ MMORPG server emulator; a game client connects to it to play. The principal runtime path is client networking into game handling, which operates on players, creatures, items, and the world map; Lua supplies extensible gameplay behavior. Account and player data are persisted through database and I/O services, with scheduled saves as an internal lifecycle layer. The README also identifies multiworld support. Source excerpts are selective, so several gameplay and protocol links are shown only as unverified rather than asserted calls.
Main entry points: game.cpp Game coordinator · save_manager.cpp Scheduled saves · player.cpp Player state · database.cpp Database access
Components 21
Server runtime
- Network server
src/server/server.cpp - Game protocol
src/server/network/protocol/protocolgame.cpp
World and gameplay
- Game coordinator
src/game/game.cpp - Player state
src/creatures/players/player.cpp - Creature systems
src/creatures/creature.cpp - Monster management
src/creatures/monsters/monsters.hpp - Items and containers
src/items/item.cpp - World map
src/map/map.cpp - Weekly tasks
src/io/ioweeklytasks.cpp - Multiworld support
src/game/worlds/gameworlds.cpp
Lua scripting
- Lua runtime
src/lua/scripts/luascript.cpp - Lua game bindings
src/lua/functions/lua_functions_loader.cpp
Persistence
- Account repository
src/account/account_repository_db.cpp - Database access
src/database/database.cpp - Database management
src/database/databasemanager.cpp - Player load and save
src/io/functions/iologindata_save_player.cpp
Configuration and services
- Scheduled saves
src/game/scheduling/save_manager.cpp - Task dispatcher
src/game/scheduling/dispatcher.hpp - Configuration
src/config/configmanager.cpp - Webhook integration
src/server/network/webhook/webhook.cpp
Other components
- Game client
Connections 22
- Game client → Network server: connects to
README.md - Network server → Game protocol: routes through
- Game protocol → Game coordinator: dispatches gameplay
- Game coordinator → Player state: manages players
- Game coordinator → World map: uses map
- Game coordinator → Creature systems: manages creatures
- Game coordinator → Items and containers: handles items
- Game coordinator → Monster management: uses monster systems
- Player state → Weekly tasks: tracks tasks
src/io/ioweeklytasks.cpp - Lua runtime → Lua game bindings: loads bindings
- Lua game bindings → Game coordinator: exposes game operations
- Account repository → Database access: queries and updates
src/account/account_repository_db.cpp - Database management → Database access: checks and migrates
src/database/databasemanager.cpp - Scheduled saves → Player state: saves player state
src/game/scheduling/save_manager.cpp - Scheduled saves → Player load and save: delegates player save
src/game/scheduling/save_manager.cpp - Scheduled saves → Database access: saves key-value data
- Scheduled saves → Task dispatcher: schedules work
- Configuration → Game coordinator: configures runtime
src/config/configmanager.cpp - Configuration → Webhook integration: configures webhook
src/config/configmanager.cpp - Game coordinator → Multiworld support: uses world registry
- Weekly tasks → Database access: persists task data
src/io/ioweeklytasks.cpp - Weekly tasks → Player state: updates task progress