Bomberman Multiplayer
Authoritative multiplayer networking layer for Bomberman.
Loading...
Searching...
No Matches
ServerState.h File Reference

Authoritative server state model, lifecycle helpers, and fixed-tick simulation API. More...

#include <array>
#include <optional>
#include <string>
#include <string_view>
#include <enet/enet.h>
#include "Net/NetCommon.h"
#include "Net/NetDiagnostics.h"
#include "Sim/Movement.h"
#include "Sim/PowerupConfig.h"

Go to the source code of this file.

Classes

struct  bomberman::server::PlayerSlot
 Current-session metadata for one accepted player assignment. More...
 
struct  bomberman::server::DisconnectedPlayerReclaim
 Bounded reconnect cache for one recently disconnected player seat. More...
 
struct  bomberman::server::PeerSession
 Live transport/session state for one connected ENet peer. More...
 
struct  bomberman::server::InputRingEntry
 One buffered authoritative input entry for a match player. More...
 
struct  bomberman::server::MatchPlayerState
 Authoritative in-match state for one accepted player seat. More...
 
struct  bomberman::server::BombCell
 Tile-map cell coordinate used by bomb and powerup state. More...
 
struct  bomberman::server::BombState
 Authoritative state for one active bomb in the current match. More...
 
struct  bomberman::server::PowerupState
 Authoritative state for one round-scoped hidden or revealed powerup. More...
 
struct  bomberman::server::ServerState
 Long-lived authoritative server state shared across receive and simulation paths. More...
 
struct  bomberman::server::PacketDispatchContext
 Per-dispatch context passed through the typed packet handlers. More...
 

Namespaces

namespace  bomberman::server
 Authoritative dedicated-server state, match flow, and fixed-tick simulation support.
 

Enumerations

enum class  bomberman::server::ServerPhase : uint8_t {
  bomberman::server::Lobby , bomberman::server::LobbyCountdown , bomberman::server::StartingMatch , bomberman::server::InMatch ,
  bomberman::server::EndOfMatch
}
 High-level dedicated-server phase for the current lobby and match flow. More...
 

Functions

void bomberman::server::initServerState (ServerState &state, ENetHost *host, bool diagEnabled=false, bool overrideMapSeed=false, uint32_t mapSeed=0, uint32_t inputLeadTicks=sim::kDefaultServerInputLeadTicks, uint32_t snapshotIntervalTicks=sim::kDefaultServerSnapshotIntervalTicks, bool powersEnabled=true)
 Resets a ServerState for a new dedicated-server session.
 
void bomberman::server::rollNextRoundMapSeed (ServerState &state)
 Chooses the seed for the next round map.
 
std::optional< uint8_t > bomberman::server::acquirePlayerId (ServerState &state)
 Returns the lowest available playerId.
 
bool bomberman::server::acquireSpecificPlayerId (ServerState &state, uint8_t playerId)
 Removes a specific playerId from the free pool if available.
 
void bomberman::server::releasePlayerId (ServerState &state, uint8_t playerId)
 Returns a playerId to the free pool.
 
PeerSessionbomberman::server::bindPeerSession (ServerState &state, ENetPeer &peer)
 Binds a connected ENet peer to stable live peer-session storage.
 
PeerSessionbomberman::server::getPeerSession (ENetPeer *peer)
 Returns the live peer session referenced by peer->data, if any.
 
const PeerSessionbomberman::server::getPeerSession (const ENetPeer *peer)
 
PeerSessionbomberman::server::findPeerSessionByPlayerId (ServerState &state, uint8_t playerId)
 Returns the live peer session currently bound to playerId, if any.
 
const PeerSessionbomberman::server::findPeerSessionByPlayerId (const ServerState &state, const uint8_t playerId)
 
void bomberman::server::acceptPeerSession (ServerState &state, PeerSession &session, uint8_t playerId, std::string_view playerName, uint8_t carriedWins=0)
 Commits an accepted peer session into active player metadata.
 
std::optional< uint8_t > bomberman::server::releasePeerSession (ServerState &state, ENetPeer &peer)
 Releases the live peer session bound to peer, if any.
 
void bomberman::server::createMatchPlayerState (ServerState &state, uint8_t playerId)
 Creates active in-match state for one player seat.
 
void bomberman::server::destroyMatchPlayerState (ServerState &state, uint8_t playerId)
 Destroys active in-match state for one player seat, if present.
 
void bomberman::server::simulateServerTick (ServerState &state)
 Advances the authoritative server by one fixed simulation tick.
 

Variables

constexpr std::size_t bomberman::server::kServerPeerSessionCapacity = net::kMaxPlayers + 4
 Maximum ENet peers the dedicated server provisions live peer-session storage for.
 
constexpr std::size_t bomberman::server::kServerInputBufferSize = static_cast<std::size_t>(net::kMaxInputBatchSize) * 2u
 Input slots retained per active MatchPlayerState.
 
constexpr uint32_t bomberman::server::kMaxBufferedInputLead = kServerInputBufferSize - 1
 Maximum distance ahead of lastProcessedInputSeq that a received input is allowed to be.
 
constexpr std::size_t bomberman::server::kServerBombCapacity
 Maximum bombs the server stores for one match.
 
constexpr std::size_t bomberman::server::kServerPowerupCapacity = sim::kPowerupsPerRound
 Maximum number of hidden/revealed round powerups the server tracks at once.
 

Detailed Description

Authoritative server state model, lifecycle helpers, and fixed-tick simulation API.