28#include <entt/entity/entity.hpp>
31#include <unordered_map>
124 void tick(
float dt, Uint64 nextTick);
298 return (
static_cast<std::size_t
>(k.shooterClientId) << 32) ^ k.shotInputTick;
Stores every ability available in the game and maps type to ability.
PR-27 — per-entity animation state snapshot, decoupled from CharacterAnimator.
Catalog of ozz animation clips shared across all animated entities.
Per-entity animator — state machine, sampling, blending, CPU skinning.
Shared skinned-character rig: skeleton, bind-pose mesh, skin weights.
Network client identifier component for multiplayer entities.
Client Event structure to be consumed by server game loop.
Skeleton-driven hitbox types: body regions, capsule definitions, damage profiles, and per-entity runt...
Server-side lobby state machine: player join/leave, ready-up, and match-start gating.
Load collision geometry (and optionally visual data) from a map GLB file.
Controls match flow, including starting and ending matches and managing match state.
MatchPhase
Definition MatchStatus.hpp:8
Network configuration loaded from config.toml at startup.
Palette + tunables for the per-player color tint feature.
Curated animal-handle list used as default player nicknames.
Player status manager for things like life state and healing.
Shared ECS registry type alias for the game engine.
entt::registry Registry
Shared ECS registry type alias.
Definition Registry.hpp:11
TCP game server that accepts clients and dispatches incoming packets.
Definition AbilityRegistry.hpp:12
Collection of animation clips loaded on top of a shared skeleton.
Definition AnimationLibrary.hpp:75
Shared skinned rig — skeleton + bind-pose meshes + joint map.
Definition CharacterRig.hpp:45
A single gameplay event produced by network input processing.
Definition Event.hpp:47
Manages authoritative lobby state and broadcasts updates to connected clients.
Definition LobbyManager.hpp:17
Manages match flow: lobby → countdown → in-progress → finished → lobby.
Definition MatchController.hpp:15
Top-level server game loop.
Definition ServerGame.hpp:39
physics::ContactCache contactCache_
Persistent contact-manifold cache for warm-starting the PGS solver across ticks.
Definition ServerGame.hpp:213
bool idleShutdownEnabled_
True if idle shutdown is enabled via env var.
Definition ServerGame.hpp:304
void initAnimation()
Initialise the server-side animation subsystem (skeleton, clips, hitboxes).
Definition ServerGame.cpp:1143
bool init(Server &server, int tickRateHz=128, int snapshotHz=32, bool skipLobby=false)
Attach to an already-bound Server and initialise game state.
Definition ServerGame.cpp:118
int tickRateHz
Physics ticks per second.
Definition ServerGame.hpp:198
std::FILE * truthCsv_
Definition ServerGame.hpp:246
void openGroundTruthLog()
Open the ground-truth CSV from env var if set.
Definition ServerGame.cpp:316
void attachServerAnimator(entt::entity player)
Create and store a server-side animator for the given player entity.
Definition ServerGame.cpp:1219
bool setIdleShutdownMinutes(int minutes)
Configure idle shutdown timeout in minutes; non-positive values disable it.
Definition ServerGame.cpp:1479
void detachServerAnimator(entt::entity player)
Remove the server-side animator for the given entity.
Definition ServerGame.cpp:1229
float rigScale_
Rig model-space → game-unit scale factor.
Definition ServerGame.hpp:219
bool shotDebugEnabled_
Opt-in lag-comp shot visualizer capture/send path.
Definition ServerGame.hpp:207
int snapshotEveryNTicks
Send a registry snapshot every Nth tick.
Definition ServerGame.hpp:206
AnimationLibrary serverAnimLibrary_
Animation clips for server-side sampling.
Definition ServerGame.hpp:217
void onMatchConfigUpdated(std::function< void(const MatchConfig &)> fn)
Register a callback fired after the host updates match settings.
Definition ServerGame.hpp:68
bool setMaxPlayers(int maxPlayers)
Update only the maximum accepted player count in the authoritative match config.
Definition ServerGame.cpp:1454
std::unordered_map< ClientId, entt::entity > clientEntities
Maps client IDs to ECS entities.
Definition ServerGame.hpp:183
bool isHost(ClientId clientId) const
True if the given client currently owns host-only lobby/server controls.
Definition ServerGame.cpp:1444
void shutdown()
Signal the loop to stop and release all resources.
Definition ServerGame.cpp:307
void tick(float dt, Uint64 nextTick)
Advance one physics tick: drain events, run ECS systems, broadcast state.
Definition ServerGame.cpp:626
std::vector< NetKillEvent > pendingKillEvents
Accumulates kill events waiting for network broadcast.
Definition ServerGame.hpp:184
CharacterRig serverRig_
Shared skeleton (loaded from same FBX as client).
Definition ServerGame.hpp:216
void updateLagCompTargets()
Phase 6: write LagCompTarget onto each connected player's entity from their connection's last-reporte...
Definition ServerGame.cpp:1234
std::vector< AbilityType > matchPrimaryAbilities
list of abilities available during the match
Definition ServerGame.hpp:173
static constexpr std::size_t k_pendingShotIntentsMax
Definition ServerGame.hpp:301
HitboxRig hitboxRig_
Shared hitbox capsule definitions.
Definition ServerGame.hpp:218
uint64_t lastNonEmptyMs_
Timestamp of the last player activity, for idle shutdown.
Definition ServerGame.hpp:306
bool running
Loop continues while true.
Definition ServerGame.hpp:197
std::array< int, player_colors::k_paletteSize > colorSlotUseCounts_
Use-count per palette slot for least-used color reservation.
Definition ServerGame.hpp:191
void closeGroundTruthLog() noexcept
Flush + close the CSV if open. Safe to call from dtor.
Definition ServerGame.cpp:370
int tickCount
Total ticks since start, used for periodic logging.
Definition ServerGame.hpp:199
bool lobbyStartCountdownActive
True while lobby is counting down before entering match countdown.
Definition ServerGame.hpp:180
void eventHandler(const Event &event)
Apply a single event to the ECS registry.
Definition ServerGame.cpp:394
std::vector< AbilityType > matchSecondaryAbilities
Definition ServerGame.hpp:174
void writeGroundTruthLogIfDue()
Write one row per replicated player entity if the current tickCount aligns with truthHzDivider_.
Definition ServerGame.cpp:338
int truthHzDivider_
Definition ServerGame.hpp:247
Registry registry
ECS entity/component store.
Definition ServerGame.hpp:171
MatchController matchController
Manages match flow and state.
Definition ServerGame.hpp:176
float rigMeshMinY_
Minimum Y of bind-pose mesh (for vertical offset).
Definition ServerGame.hpp:220
uint64_t idleShutdownMs_
Idle shutdown timeout in ms, from env var. 0 = no timeout.
Definition ServerGame.hpp:305
bool isGameplayInputAllowed(MatchPhase phase) const
Determine if server should allow input based on phase.
Definition ServerGame.cpp:1561
void updateAnimationAndHitboxes(float dt)
Update all server-side animators and recompute hitbox capsules.
Definition ServerGame.cpp:1356
std::unordered_map< ShotIntentKey, ShotIntentPayload, ShotIntentKeyHash > pendingShotIntents_
Definition ServerGame.hpp:302
LobbyManager lobbyManager
Owns lobby roster and validates host-initiated match starts.
Definition ServerGame.hpp:175
bool setKillsToWin(int kills)
Update only the kill threshold in the authoritative match config.
Definition ServerGame.cpp:1449
void deletePlayerEntity(ClientId clientId)
Remove player entity from ECS.
Definition ServerGame.cpp:1105
bool setMatchConfig(const MatchConfig &config)
Apply a complete match config to the authoritative match controller.
Definition ServerGame.cpp:1466
ClientId lobbyStartRequester
Host that requested the active lobby staging countdown.
Definition ServerGame.hpp:182
std::function< void(const DiscoverySettings &)> discoverySettingsUpdatedFn_
Mirrors discovery visibility changes.
Definition ServerGame.hpp:179
std::array< int, player_nicknames::k_nicknameCount > nicknameSlotUseCounts_
Use-count per nickname slot — same selection scheme as colors.
Definition ServerGame.hpp:196
void run()
Block on the game loop until shutdown() is called.
Definition ServerGame.cpp:200
void resetPlayersForCountdown()
Reset live players to spawn points for countdown.
Definition ServerGame.cpp:1492
void selectMatchAbilityPool()
Select the subset of abilities for new match.
Definition ServerGame.cpp:605
void applyMatchAbilityChoices(AbilityState &state) const
Definition ServerGame.cpp:616
physics::MapCollisionData mapCollision_
Map collision data — owns vectors backing activeWorld().
Definition ServerGame.hpp:168
bool animationLoaded_
True if rig+clips loaded successfully.
Definition ServerGame.hpp:221
std::unordered_map< entt::entity, std::unique_ptr< CharacterAnimator > > serverAnimators_
Per-entity server animators (not ECS components to avoid pulling animation headers into the component...
Definition ServerGame.hpp:225
void onDiscoverySettingsUpdated(std::function< void(const DiscoverySettings &)> fn)
Register a callback fired after the host updates discovery visibility.
Definition ServerGame.hpp:71
void initNewPlayerEntity(ClientId clientId)
Create a new player entity and map it to the given client ID.
Definition ServerGame.cpp:1021
AbilityRegistry abilityRegistry
Registry of abilities via type idx.
Definition ServerGame.hpp:172
std::function< void(const MatchConfig &)> matchConfigUpdatedFn_
Mirrors match updates to networking/discovery.
Definition ServerGame.hpp:177
void applyInputEvent(ClientId clientId, const InputSnapshot &inputSnapshot)
Definition ServerGame.cpp:378
bool isLobbyPhase(MatchPhase phase) const
Return true when roster changes should use lobby updates instead of in-match popups.
Definition ServerGame.cpp:1571
float lobbyStartCountdownTimer
Seconds remaining in the lobby staging countdown.
Definition ServerGame.hpp:181
TCP stream socket — receives client packets and echoes them back.
Definition Server.hpp:42
Definition LagCompMath.hpp:10
Definition AbilityState.hpp:87
Associates an entity with a connected network client.
Definition ClientId.hpp:10
Host-managed discovery visibility flags.
Definition DiscoverySettings.hpp:11
Hitbox rig (shared per character archetype).
Definition Hitbox.hpp:159
Definition MatchConfig.hpp:4
Definition ServerGame.hpp:293
std::size_t operator()(const ShotIntentKey &k) const noexcept
Definition ServerGame.hpp:294
Definition ServerGame.hpp:284
std::uint32_t shotInputTick
Definition ServerGame.hpp:286
bool operator==(const ShotIntentKey &o) const noexcept
Definition ServerGame.hpp:287
std::uint16_t shooterClientId
Definition ServerGame.hpp:285
Collision data.
Definition MapLoader.hpp:36