7#ifndef BOMBERMAN_SERVER_SERVERFLOWINTERNAL_H
8#define BOMBERMAN_SERVER_SERVERFLOWINTERNAL_H
21namespace bomberman::server::flow_internal
23 static_assert(
net::kMaxPlayers <= 32,
"Current match-player mask assumes at most 32 player ids");
25 inline constexpr uint32_t kLobbyCountdownTicks =
static_cast<uint32_t
>(
sim::kTickRate) * 3u;
26 inline constexpr uint32_t kMatchStartLoadTimeoutTicks =
static_cast<uint32_t
>(
sim::kTickRate) * 5u;
27 inline constexpr uint32_t kMatchStartGoDelayTicks =
static_cast<uint32_t
>(
sim::kTickRate);
28 inline constexpr uint32_t kMatchStartUnlockDelayTicks = kMatchStartGoDelayTicks;
29 inline constexpr uint32_t kEndOfMatchReturnTicks =
static_cast<uint32_t
>(
sim::kTickRate) * 3u;
32 constexpr uint32_t playerMaskBit(
const uint8_t playerId)
34 return 1u << playerId;
37 template<std::
size_t N>
38 bool queueReliableControlToPlayer(ServerState& state,
39 const uint8_t playerId,
41 const std::size_t payloadSize,
42 const std::array<uint8_t, N>& packet)
45 const bool queued = session !=
nullptr &&
46 session->peer !=
nullptr &&
49 state.diag.recordPacketSent(type,
51 static_cast<uint8_t
>(net::EChannel::ControlReliable),
52 net::kPacketHeaderSize + payloadSize,
59 uint8_t computeCountdownSecondsRemaining(
const ServerState& state);
62 constexpr std::string_view coarseServerFlowState(
const ServerPhase phase)
73 return "end_of_match";
80 inline bool isServerIdleForDiagnostics(
const ServerState& state)
82 if (coarseServerFlowState(state.phase) !=
"lobby")
85 return std::none_of(state.playerSlots.begin(),
86 state.playerSlots.end(),
87 [](
const auto& slotEntry) { return slotEntry.has_value(); });
90 void cancelStartingMatch(ServerState& state, uint32_t notifyMask, std::string_view reason);
Thin wrappers around ENet packet creation, queueing, and flushing.
Authoritative server receive-path entry point and shared handler declarations.
Authoritative server state model, lifecycle helpers, and fixed-tick simulation API.
Shared simulation tuning constants used by client and server gameplay code.
NetPacketResult
Diagnostics classification for one packet attempt or receive path outcome.
Definition NetDiagShared.h:49
bool queueReliableControl(ENetPeer *peer, const std::array< uint8_t, N > &bytes)
Queues a reliable control packet.
Definition NetSend.h:63
EMsgType
Message type identifiers used in packet headers.
Definition NetCommon.h:316
constexpr uint8_t kMaxPlayers
Maximum supported player count in a game instance.
Definition NetCommon.h:54
PeerSession * findPeerSessionByPlayerId(ServerState &state, const uint8_t playerId)
Returns the live peer session currently bound to playerId, if any.
Definition ServerSession.cpp:216
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 int16_t kTickRate
Simulation tick rate in Hz.
Definition SimConfig.h:14