7#ifndef BOMBERMAN_SERVERSTATE_H
8#define BOMBERMAN_SERVERSTATE_H
56 static_cast<std::size_t
>(tileArrayHeight);
87 std::string playerName;
101 std::string playerName;
116 ENetPeer* peer =
nullptr;
118 uint32_t connectedServerTick = 0;
147 uint8_t playerId = 0;
150 bool inputLocked =
false;
151 uint8_t activeBombCount = 0;
154 uint32_t invincibleUntilTick = 0;
155 uint32_t speedBoostUntilTick = 0;
156 uint32_t bombRangeBoostUntilTick = 0;
157 uint32_t maxBombsBoostUntilTick = 0;
160 std::array<InputRingEntry, kServerInputBufferSize>
inputRing{};
161 uint32_t lastReceivedInputSeq = 0;
162 uint32_t lastProcessedInputSeq = 0;
165 uint8_t appliedButtons = 0;
166 uint8_t previousTickButtons = 0;
170 uint32_t nextConsumeServerTick = 0;
173 uint16_t consecutiveTooFarAheadBatches = 0;
174 uint16_t consecutiveInputGaps = 0;
175 uint32_t nextTooFarAheadWarnTick = 0;
176 uint32_t nextGapWarnTick = 0;
195 uint32_t placedTick = 0;
196 uint32_t explodeTick = 0;
208 uint32_t revealedTick = 0;
260 uint8_t playerIdPoolSize = 0;
265 uint32_t mapSeed = 0;
270 uint32_t nextMatchId = 1;
273 uint32_t currentLobbyCountdownDeadlineTick = 0;
274 uint8_t currentLobbyCountdownLastBroadcastSecond = 0;
277 uint32_t currentMatchLoadedMask = 0;
278 uint32_t currentMatchStartDeadlineTick = 0;
279 uint32_t currentMatchGoShowTick = 0;
280 uint32_t currentMatchUnlockTick = 0;
281 uint32_t currentEndOfMatchReturnTick = 0;
283 bool roundEndedInDraw =
false;
296 ENetPeer* peer =
nullptr;
307 bool diagEnabled =
false,
308 bool overrideMapSeed =
false,
309 uint32_t mapSeed = 0,
312 bool powersEnabled =
true);
353 PeerSession& session,
355 std::string_view playerName,
356 uint8_t carriedWins = 0);
constexpr unsigned int tileArrayWidth
Tile map width in tiles.
Definition Const.h:43
Shared authoritative movement simulation primitives.
Shared client/server wire contract for the multiplayer protocol.
Session-local multiplayer diagnostics recorder and report model.
Shared multiplayer powerup types and round-setup tuning.
Session-local recorder for recent multiplayer diagnostics and aggregate counters.
Definition NetDiagnostics.h:103
NetPacketResult
Diagnostics classification for one packet attempt or receive path outcome.
Definition NetDiagShared.h:49
constexpr uint8_t kMaxInputBatchSize
Maximum number of inputs in a single batched MsgInput packet.
Definition NetCommon.h:67
constexpr uint8_t kMaxPlayers
Maximum supported player count in a game instance.
Definition NetCommon.h:54
Authoritative dedicated-server state, match flow, and fixed-tick simulation support.
Definition ServerBombs.cpp:21
bool acquireSpecificPlayerId(ServerState &state, const uint8_t playerId)
Removes a specific playerId from the free pool if available.
Definition ServerSession.cpp:148
PeerSession * bindPeerSession(ServerState &state, ENetPeer &peer)
Binds a connected ENet peer to stable live peer-session storage.
Definition ServerSession.cpp:185
void destroyMatchPlayerState(ServerState &state, const uint8_t playerId)
Destroys active in-match state for one player seat, if present.
Definition ServerSession.cpp:320
void rollNextRoundMapSeed(ServerState &state)
Chooses the seed for the next round map.
Definition ServerSession.cpp:123
void initServerState(ServerState &state, ENetHost *host, const bool diagEnabled, const bool overrideMapSeed, uint32_t mapSeed, const uint32_t inputLeadTicks, const uint32_t snapshotIntervalTicks, const bool powersEnabled)
Resets a ServerState for a new dedicated-server session.
Definition ServerSession.cpp:64
void acceptPeerSession(ServerState &state, PeerSession &session, const uint8_t playerId, const std::string_view playerName, const uint8_t carriedWins)
Commits an accepted peer session into active player metadata.
Definition ServerSession.cpp:244
std::optional< uint8_t > acquirePlayerId(ServerState &state)
Returns the lowest available playerId.
Definition ServerSession.cpp:134
constexpr uint32_t kMaxBufferedInputLead
Maximum distance ahead of lastProcessedInputSeq that a received input is allowed to be.
Definition ServerState.h:50
void releasePlayerId(ServerState &state, const uint8_t playerId)
Returns a playerId to the free pool.
Definition ServerSession.cpp:165
std::optional< uint8_t > releasePeerSession(ServerState &state, ENetPeer &peer)
Releases the live peer session bound to peer, if any.
Definition ServerSession.cpp:266
constexpr std::size_t kServerPowerupCapacity
Maximum number of hidden/revealed round powerups the server tracks at once.
Definition ServerState.h:59
constexpr std::size_t kServerBombCapacity
Maximum bombs the server stores for one match.
Definition ServerState.h:55
PeerSession * findPeerSessionByPlayerId(ServerState &state, const uint8_t playerId)
Returns the live peer session currently bound to playerId, if any.
Definition ServerSession.cpp:216
PeerSession * getPeerSession(ENetPeer *peer)
Returns the live peer session referenced by peer->data, if any.
Definition ServerSession.cpp:206
void simulateServerTick(ServerState &state)
Advances the authoritative server by one fixed simulation tick.
Definition ServerSimulation.cpp:273
constexpr std::size_t kServerPeerSessionCapacity
Maximum ENet peers the dedicated server provisions live peer-session storage for.
Definition ServerState.h:35
void createMatchPlayerState(ServerState &state, const uint8_t playerId)
Creates active in-match state for one player seat.
Definition ServerSession.cpp:301
ServerPhase
High-level dedicated-server phase for the current lobby and match flow.
Definition ServerState.h:67
@ Lobby
Accepting players and waiting for match start.
@ StartingMatch
Transitioning accepted players from lobby into the next match.
@ LobbyCountdown
All required players are ready and the lobby countdown is running.
@ InMatch
Authoritative gameplay is active.
@ EndOfMatch
Match has finished and end-of-round presentation/results are active.
constexpr std::size_t kServerInputBufferSize
Input slots retained per active MatchPlayerState.
Definition ServerState.h:40
constexpr int32_t kDefaultServerInputLeadTicks
Default server-side input lead in ticks for authoritative input scheduling.
Definition SimConfig.h:42
constexpr uint8_t kPowerupsPerRound
Number of hidden powerups seeded into each round when enabled.
Definition PowerupConfig.h:44
PowerupType
Supported temporary multiplayer powerup effects.
Definition PowerupConfig.h:22
Tile[tileArrayHeight][tileArrayWidth] TileMap
Read-only view of a runtime tile map (same layout as LevelScene::tiles).
Definition Movement.h:36
constexpr int32_t kDefaultServerSnapshotIntervalTicks
Default server snapshot interval in simulation ticks (1 = every tick / 60 Hz).
Definition SimConfig.h:45
constexpr uint8_t kDefaultPlayerBombRange
Default explosion radius in tiles for newly placed bombs.
Definition SimConfig.h:20
constexpr uint8_t kDefaultPlayerMaxBombs
Default number of simultaneously active bombs a player may own.
Definition SimConfig.h:17
Tile-map cell coordinate used by bomb and powerup state.
Definition ServerState.h:181
Authoritative state for one active bomb in the current match.
Definition ServerState.h:192
uint8_t radius
Snapped from the owner's loadout at placement time.
Definition ServerState.h:197
Bounded reconnect cache for one recently disconnected player seat.
Definition ServerState.h:100
One buffered authoritative input entry for a match player.
Definition ServerState.h:130
bool valid
True while this slot still holds an unconsumed input.
Definition ServerState.h:133
bool seenDirect
Seen as the newest entry in a received batch.
Definition ServerState.h:134
bool seenBuffered
Seen through redundant batch history.
Definition ServerState.h:135
Authoritative in-match state for one accepted player seat.
Definition ServerState.h:146
bool inputTimelineStarted
True once the fixed-delay consume timeline has been armed.
Definition ServerState.h:169
std::array< InputRingEntry, kServerInputBufferSize > inputRing
Indexed by seq % @ref kServerInputBufferSize.
Definition ServerState.h:160
uint8_t lastAppliedButtons
Reused when the next sequence misses its deadline.
Definition ServerState.h:164
Per-dispatch context passed through the typed packet handlers.
Definition ServerState.h:294
std::optional< uint8_t > recordedPlayerId
std::nullopt for pre-handshake traffic.
Definition ServerState.h:299
Live transport/session state for one connected ENet peer.
Definition ServerState.h:115
std::optional< uint8_t > playerId
Populated once Hello is accepted.
Definition ServerState.h:117
Current-session metadata for one accepted player assignment.
Definition ServerState.h:85
Authoritative state for one round-scoped hidden or revealed powerup.
Definition ServerState.h:204
bool revealed
True once the covering brick has been destroyed.
Definition ServerState.h:207
Long-lived authoritative server state shared across receive and simulation paths.
Definition ServerState.h:222
bool powersEnabled
Round powerups are seeded and replicated.
Definition ServerState.h:231
uint32_t currentMatchPlayerMask
Bitmask of player ids participating in the current round start or active round.
Definition ServerState.h:276
std::array< std::optional< DisconnectedPlayerReclaim >, net::kMaxPlayers > disconnectedPlayerReclaims
Last disconnected occupant per player id for bounded lobby-only reconnect reclaim.
Definition ServerState.h:243
std::optional< uint8_t > roundWinnerPlayerId
Winner of the current or most recent round, if any.
Definition ServerState.h:282
std::array< std::optional< PowerupState >, kServerPowerupCapacity > powerups
Hidden and revealed round powerups for the current or next match.
Definition ServerState.h:252
net::NetDiagnostics diag
Diagnostics recorder for this session.
Definition ServerState.h:287
std::array< std::optional< MatchPlayerState >, net::kMaxPlayers > matchPlayers
Stable-address active in-match state keyed by player id.
Definition ServerState.h:248
ServerPhase phase
Current high-level server flow phase.
Definition ServerState.h:226
std::optional< uint32_t > fixedMapSeedOverride
Fixed map seed reused for every round when started with --seed.
Definition ServerState.h:264
std::array< uint8_t, net::kMaxPlayers > playerIdPool
Sorted free-list of available player ids.
Definition ServerState.h:259
std::array< std::optional< BombState >, kServerBombCapacity > bombs
Active bombs for the current round.
Definition ServerState.h:250
ENetHost * host
Non-owning ENet host for this session.
Definition ServerState.h:225
std::array< std::optional< PlayerSlot >, net::kMaxPlayers > playerSlots
Active accepted-player metadata keyed by player id. See PlayerSlot.
Definition ServerState.h:241
uint32_t serverTick
Authoritative simulation tick advanced by simulateServerTick().
Definition ServerState.h:227
uint32_t currentLobbyCountdownPlayerMask
Bitmask of players currently participating in the lobby countdown.
Definition ServerState.h:272
uint32_t currentMatchId
Current match identifier, or 0 while idle in the lobby.
Definition ServerState.h:269
std::array< std::optional< PeerSession >, kServerPeerSessionCapacity > peerSessions
Stable-address live peer sessions indexed by ENet incoming peer id.
Definition ServerState.h:236
sim::TileMap tiles
Collision map shared by all server-side movement steps.
Definition ServerState.h:255
Tile-space Q8 position representing the CENTER of the entity.
Definition Movement.h:30