Jazz2::Multiplayer namespace

Multiplayer-related classes, compiled only if WITH_MULTIPLAYER.

Classes

struct AllPeersT
All connected peers tag type.
class BattleMode
Battle game mode (free-for-all).
class CaptureTheFlagMode
Capture The Flag game mode.
struct ConnectionResult
Describes a connection result of INetworkHandler::OnPeerConnected().
class CooperationMode
Cooperation game mode.
struct GameEndResult
Result of IGameMode::CheckGameEnds.
class IGameMode
Rules of a single multiplayer game mode.
class IGameModeContext
Services a game mode needs from its host level handler.
class IGameModeHUD
Drawing surface a game mode uses to render its own part of the HUD.
class INetworkHandler
Interface to handle incomming network requests.
class IServerObserver
Interface to observe publicly-listed running servers.
class IServerStatusProvider
Interface to provide current status of the server.
struct LocalPeerT
Local peer tag type.
class MpLevelHandler
Level handler of a multiplayer game session (online or local splitscreen).
struct MpPlayerState
Network-agnostic per-player game-mode state for a single round.
class NetworkManager
Manages game-specific network connections.
class NetworkManagerBase
Allows to create generic network clients and servers.
struct Peer
Remote peer as opaque handle.
struct PeerDescriptor
Peer descriptor.
struct PlaylistEntry
Playlist entry in ServerConfiguration.
class RaceMode
Race game mode.
struct RespawnDecision
Result of IGameMode::DecideRespawn.
struct ServerConfiguration
Server configuration.
struct ServerDescription
Server description.
class ServerDiscovery
Allows to monitor publicly-listed running servers for server listing.
struct ServerInitialization
Server initialization parameters.
class TeamBattleMode
Team Battle game mode.
class TeamRaceMode
Team Race game mode.
class TeamTreasureHuntMode
Team Treasure Hunt game mode.
class TreasureHuntMode
Treasure Hunt game mode.

Enums

enum class LevelExitAction { Ignore, ChangeToNextLevel, EndGameForInitiator, WarpToStartIncrementLap }
What should happen when a player reaches the level exit, as decided by the game mode.
enum class GameModeFontType { Small, Medium }
Selects which HUD font a game mode draws text with.
enum class GameModeHudIcon { Food, GemRed, GemGreen }
A semantic HUD icon a game mode can draw; the HUD maps it to a concrete sprite.
enum class MpGameMode { Unknown = 0, Battle, TeamBattle, Race, TeamRace, TreasureHunt, TeamTreasureHunt, CaptureTheFlag, Cooperation }
Multiplayer game mode.
enum class NetworkChannel : std::uint8_t { Main, UnreliableUpdates, Count }
Network packet channel.
enum class NetworkState { None, Listening, Connecting, Connected, Local }
State of network connection.
enum class BroadcastPacketType { Null, DiscoveryRequest, DiscoveryResponse }
Packet type broadcasted on the local network.
enum class ClientPacketType { Null, Ping, Reserved, Rpc, Auth = 10, LevelReady, ChatMessage, ValidateAssetsResponse, ForceResyncActors = 20, PlayerReady = 30, PlayerUpdate, PlayerKeyPress, PlayerChangeWeaponRequest, PlayerSpectateRequest, PlayerAckWarped, PlayerChangeCharacter, PlayerChangeTeamRequest }
Packet type going from client to server.
enum class ServerPacketType { Null, Pong, Reserved, Rpc, AuthResponse = 70, PeerSetProperty, ValidateAssets, StreamAsset, LoadLevel = 80, LevelSetProperty, LevelResetProperties, ShowInGameLobby, FadeOut, PlaySfx, PlayCommonSfx, ShowAlert, ChatMessage, SyncTileMap, SetTrigger, AdvanceTileAnimation, RevertTileAnimation, CreateDebris, CreateControllablePlayer = 110, CreateRemoteActor, CreateMirroredActor, DestroyRemoteActor, UpdateAllActors, ChangeRemoteActorMetadata, MarkRemoteActorAsPlayer, UpdatePositionsInRound, SyncRaceCheckpoints, SyncTeamScores, SyncScoreboard, PlayerSetProperty = 130, PlayerResetProperties, PlayerRespawn, PlayerMoveInstantly, PlayerAckWarped, PlayerActivateForce, PlayerEmitWeaponFlare, PlayerChangeWeapon, PlayerTakeDamage, PlayerPush, PlayerActivateSpring, PlayerWarpIn }
Packet type going from server to client.
enum class PeerPropertyType { Unknown, Connected, Disconnected, Roasted, Count }
Peer property type from ServerPacketType::PeerSetProperty.
enum class LevelPropertyType { Unknown, State = 1, GameMode, LevelText = 10, Music, Count }
Level property type from ServerPacketType::LevelSetProperty.
enum class PlayerPropertyType { Unknown, PlayerType = 1, Lives, Health, Controllable, Invulnerable, Modifier, Dizzy, Freeze, Shield, LimitCameraView, OverrideCameraView, ShakeCameraView, Spectate, Team, BeingStoodOn, WeaponAmmo = 30, WeaponUpgrades, Coins = 60, Gems, Score, Points = 90, PositionInRound, Deaths, Kills, Laps, TreasureCollected, Count }
Player property type from ServerPacketType::PlayerSetProperty.
enum class PeerLevelState { Unknown, ValidatingAssets, StreamingMissingAssets, LevelLoaded, LevelSynchronized, Spectating, PlayerReady, PlayerSpawned }
Peer state in a level.
enum class SpectateMode : std::uint8_t { None, Forced, Requested, FreeCamera = 0x10, Mask = 0x0F }
Spectate mode flags.
enum class Reason : std::uint32_t { Unknown, Disconnected, InvalidParameter, IncompatibleVersion, ProtocolViolation, SecurityPolicyViolation, AuthFailed, InvalidPassword, InvalidPlayerName, NotInWhitelist, Requires3rdPartyAuthProvider, ServerIsFull, ServerNotReady, ServerStopped, ServerStoppedForMaintenance, ServerStoppedForReconfiguration, ServerStoppedForUpdate, ConnectionLost, ConnectionTimedOut, Kicked, Banned, CheatingDetected, AssetStreamingNotAllowed, Idle }
Client disconnect reason.

Functions

auto CreateGameMode(MpGameMode mode) -> std::unique_ptr<IGameMode>
Creates the IGameMode implementation for the specified game mode.
auto IsTeamGameMode(MpGameMode mode) -> bool
Returns true if the specified game mode splits players into teams.
auto GetTeamColor(std::uint8_t team) -> nCine::Colorf
Returns the display color of the specified team (Blue, Red, Green, Yellow).
auto GetTeamName(std::uint8_t team) -> Death::Containers::StringView
Returns the display name of the specified team.
auto ApplyTeamFurColor(std::uint32_t furColor, std::uint8_t team) -> std::uint32_t
Recolors a packed fur color so the primary character color section matches the team color.

Variables

AllPeersT AllPeers constexpr
All connected peers tag.
LocalPeerT LocalPeer constexpr
Local peer tag.
static std::uint8_t MaxTeamCount constexpr
Maximum number of teams supported.
static std::uint8_t NoPreferredTeam constexpr
Sentinel team value meaning "no preference, let the server decide".

Enum documentation

enum class Jazz2::Multiplayer::LevelExitAction

What should happen when a player reaches the level exit, as decided by the game mode.

Enumerators
Ignore

Ignore the exit (competitive modes without a level-exit win condition)

ChangeToNextLevel

Proceed to the next level (Cooperation)

EndGameForInitiator

End the round with the initiator as the winner (Treasure Hunt with enough treasure)

WarpToStartIncrementLap

Warp the initiator back to the start and count a lap (Race)

enum class Jazz2::Multiplayer::GameModeFontType

Selects which HUD font a game mode draws text with.

Enumerators
Small

Small font

Medium

Medium font

enum class Jazz2::Multiplayer::GameModeHudIcon

A semantic HUD icon a game mode can draw; the HUD maps it to a concrete sprite.

Enumerators
Food

Food / score pickup icon

GemRed

Red gem (treasure not yet sufficient)

GemGreen

Green gem (enough treasure collected)

enum class Jazz2::Multiplayer::MpGameMode

Multiplayer game mode.

Selects the win condition and team rules of a multiplayer round, from free-for-all and team variants of Battle, Race and Treasure Hunt to Capture The Flag and Cooperation.

Enumerators
Unknown

Unspecified

Battle

Battle

TeamBattle

Team Battle

Race

Race

TeamRace

Team Race

TreasureHunt

Treasure Hunt

TeamTreasureHunt

Team Treasure Hunt

CaptureTheFlag

Capture The Flag

Cooperation

Cooperation

enum class Jazz2::Multiplayer::NetworkChannel : std::uint8_t

Network packet channel.

Selects which transport channel a packet is sent on, separating reliable, ordered traffic on the main channel from frequent unreliable state updates.

Enumerators
Main

Main

UnreliableUpdates

Unreliable updates

Count

Count of supported channels

enum class Jazz2::Multiplayer::NetworkState

State of network connection.

Describes the current role and connection status of a NetworkManagerBase: idle, listening as a server, or connecting to and connected with a remote server as a client.

Enumerators
None

Disconnected

Listening

Listening as server

Connecting

Connecting to server as client

Connected

Connected to server as client

Local

Local session with no socket (local splitscreen multiplayer)

enum class Jazz2::Multiplayer::BroadcastPacketType

Packet type broadcasted on the local network.

Identifies a connectionless packet exchanged over the LAN discovery channel, used by clients to locate running servers and by servers to announce themselves in response.

Enumerators
Null

Empty packet

DiscoveryRequest

Request to discover servers on the local network

DiscoveryResponse

Response of a server to a discovery request

enum class Jazz2::Multiplayer::ClientPacketType

Packet type going from client to server.

Identifies the kind of message sent in the client-to-server direction, covering connection setup (ping, authentication), level and chat handshakes, and periodic player state and input updates.

Enumerators
Null

Empty packet

Ping

Ping request to measure round trip time

Reserved

Reserved

Rpc

Remote procedure call forwarded to a scripted actor

Auth

Authentication request

LevelReady

Notifies the server that the level finished loading

ChatMessage

Chat message sent to the server

ValidateAssetsResponse

Response to a server request to validate required assets

ForceResyncActors

Requests the server to resynchronize all actors

PlayerReady

Notifies the server that the player is ready to spawn

PlayerUpdate

Periodic update of the local player state

PlayerKeyPress

Player input state

PlayerChangeWeaponRequest

Requests a weapon change

PlayerSpectateRequest

Requests to enable or disable spectate mode

PlayerAckWarped

Acknowledges that the player has been warped

PlayerChangeCharacter

Requests to change the player character

PlayerChangeTeamRequest

Requests to change the player team

enum class Jazz2::Multiplayer::ServerPacketType

Packet type going from server to client.

Identifies the kind of message sent in the server-to-client direction, covering authentication and asset handshakes, level loading and synchronization, actor creation and updates, and player state changes pushed by the server.

Enumerators
Null

Empty packet

Pong

Response to a ping request

Reserved

Reserved

Rpc

Remote procedure call forwarded to a scripted actor

AuthResponse

Response to an authentication request

PeerSetProperty

Sets a property of a peer

ValidateAssets

Requests the client to validate its required assets

StreamAsset

Streams a missing asset to the client

LoadLevel

Requests the client to load a level

LevelSetProperty

Sets a property of the current level

LevelResetProperties

ShowInGameLobby

Requests the client to show the in-game lobby

FadeOut

Requests the client to fade out the screen

PlaySfx

Plays a sound effect attached to an actor

PlayCommonSfx

Plays a common sound effect at a position

ShowAlert

ChatMessage

Chat message broadcasted to the client

SyncTileMap

Synchronizes the state of the tile map

SetTrigger

Sets the state of a trigger

AdvanceTileAnimation

Advances a destructible tile animation

RevertTileAnimation

CreateDebris

Creates particle or sprite debris

CreateControllablePlayer

Creates a player controllable by the client

CreateRemoteActor

Creates a remote actor on the client

CreateMirroredActor

Creates a mirrored actor on the client

DestroyRemoteActor

Destroys a remote actor on the client

UpdateAllActors

Periodic update of all remote actors

ChangeRemoteActorMetadata

Changes metadata of a remote actor

MarkRemoteActorAsPlayer

Marks a remote actor as another player

UpdatePositionsInRound

Updates player positions in the current round

SyncRaceCheckpoints

Sends the ordered race checkpoint polyline and start markers for the minimap

SyncTeamScores

Sends the per-team aggregate scores for the HUD

SyncScoreboard

Sends per-player scoreboard rows (name, kills, deaths, points, ping)

PlayerSetProperty

Sets a property of a player

PlayerResetProperties

Resets all properties of a player

PlayerRespawn

Respawns a player

PlayerMoveInstantly

Moves a player instantly to a position

PlayerAckWarped

PlayerActivateForce

PlayerEmitWeaponFlare

Emits a weapon flare from a player

PlayerChangeWeapon

Changes the current weapon of a player

PlayerTakeDamage

Applies damage to a player

PlayerPush

Pushes a player

PlayerActivateSpring

Activates a spring under a player

PlayerWarpIn

Warps a player into the level

enum class Jazz2::Multiplayer::PeerPropertyType

Peer property type from ServerPacketType::PeerSetProperty.

Identifies which per-peer session property the server is announcing to clients, such as a peer connecting, disconnecting or being roasted.

Enumerators
Unknown

Unknown

Connected

Peer connected

Disconnected

Peer disconnected

Roasted

Peer was roasted (killed)

Count

Count of supported property types

enum class Jazz2::Multiplayer::LevelPropertyType

Level property type from ServerPacketType::LevelSetProperty.

Identifies which property of the current level the server is updating on clients, such as the level state, the active game mode or the currently playing music.

Enumerators
Unknown

Unknown

State

Level state

GameMode

Game mode

LevelText

Music

Currently playing music

Count

Count of supported property types

enum class Jazz2::Multiplayer::PlayerPropertyType

Player property type from ServerPacketType::PlayerSetProperty.

Identifies which property of a player the server is updating on clients, covering character and health state, weapon ammo and upgrades, collected currency, and per-round statistics.

Enumerators
Unknown

Unknown

PlayerType

Player type (character)

Lives

Remaining lives

Health

Current health

Controllable

Whether the player is controllable

Invulnerable

Invulnerability state

Modifier

Active modifier (e.g., copter, frog)

Dizzy

Dizziness state

Freeze

Freeze state

Shield

Active shield

LimitCameraView

Camera view limit

OverrideCameraView

Camera view override

ShakeCameraView

Camera shake

Spectate

Spectate mode state

Team

Team the player belongs to

BeingStoodOn

Whether another player is standing on this one (cosmetic lift animation)

WeaponAmmo

Ammo of a weapon

WeaponUpgrades

Upgrades of a weapon

Coins

Collected coins

Gems

Collected gems

Score

Current score

Points

Earned points in the session

PositionInRound

Deaths

Deaths in the current round

Kills

Kills in the current round

Laps

Completed laps in the current round

TreasureCollected

Treasure collected in the current round

Count

Count of supported property types

enum class Jazz2::Multiplayer::PeerLevelState

Peer state in a level.

Tracks how far a peer has progressed through joining the current level, from validating and streaming required assets through loading and synchronization to spectating or having a spawned player. The server advances this state as the join handshake completes.

Enumerators
Unknown

Unknown

ValidatingAssets

Peer received list of required assets, the server is waiting for response

StreamingMissingAssets

Missing assets are being streamed to peer

LevelLoaded

Peer finished loading of the level

LevelSynchronized

Peer finished synchronized entities in the level

Spectating

Peer is spectating

PlayerReady

Player is ready to spawn

PlayerSpawned

Player is spawned

enum class Jazz2::Multiplayer::SpectateMode : std::uint8_t

Spectate mode flags.

Describes whether and how a player is spectating instead of playing. The low bits hold the base mode (not spectating, forced by the server, or requested by the client), while the SpectateMode::FreeCamera flag selects a free-roaming camera over a player-following one.

Enumerators
None

Not spectating

Forced

Spectate mode is forced by the server, the client cannot disable it

Requested

Spectate mode is requested by the client, the server can accept or reject it

FreeCamera

Spectate with free camera, otherwise spectate with player camera

Mask

Mask for spectate mode flags

enum class Jazz2::Multiplayer::Reason : std::uint32_t

Client disconnect reason.

Describes why a connection was refused or terminated, ranging from user-initiated disconnects and protocol or version mismatches to authentication failures, moderation actions and various server shutdown states. It is reported on disconnect and when kicking a peer.

Enumerators
Unknown

Unspecified

Disconnected

Client disconnected by user

InvalidParameter

Invalid parameter specified

IncompatibleVersion

Incompatible client version

ProtocolViolation

Protocol violation (e.g., received malformed packet)

SecurityPolicyViolation

Security policy violation (e.g., "ws://" from "https://")

AuthFailed

Authentication failed

InvalidPassword

Invalid password specified

InvalidPlayerName

Invalid player name specified

NotInWhitelist

Client is not in server whitelist

Requires3rdPartyAuthProvider

Server requires 3rd party authentication provider (e.g., Discord)

ServerIsFull

Server is full or busy

ServerNotReady

Server is not ready yet

ServerStopped

Server is stopped for unknown reason

ServerStoppedForMaintenance

Server is stopped for maintenance

ServerStoppedForReconfiguration

Server is stopped for reconfiguration

ServerStoppedForUpdate

Server is stopped for update

ConnectionLost

Connection lost

ConnectionTimedOut

Connection timed out

Kicked

Kicked by server

Banned

Banned by server

CheatingDetected

Cheating detected

AssetStreamingNotAllowed

Downloading of assets is not allowed, but some assets are missing

Idle

Inactivity

Function documentation

std::unique_ptr<IGameMode> Jazz2::Multiplayer::CreateGameMode(MpGameMode mode)

Creates the IGameMode implementation for the specified game mode.

Returns the rules object a level handler should host for mode. Every game mode has an implementation; modes still in the staged migration own only their HUD and report IGameMode::OwnsRoundLogic as false. Returns nullptr only for MpGameMode::Unknown.

bool Jazz2::Multiplayer::IsTeamGameMode(MpGameMode mode)

Returns true if the specified game mode splits players into teams.

nCine::Colorf Jazz2::Multiplayer::GetTeamColor(std::uint8_t team)

Returns the display color of the specified team (Blue, Red, Green, Yellow).

Death::Containers::StringView Jazz2::Multiplayer::GetTeamName(std::uint8_t team)

Returns the display name of the specified team.

std::uint32_t Jazz2::Multiplayer::ApplyTeamFurColor(std::uint32_t furColor, std::uint8_t team)

Recolors a packed fur color so the primary character color section matches the team color.

Forces the low byte (the first of the four packed fur sections, i.e. the primary fur color) of furColor to the team's signature sprite-palette gradient start, keeping the player's own choice for the remaining sections. The gradient bytes match the in-game character color options (Jazz2::ContentResolver::FurHueShiftFlag = 0x80 marks a hue-shifted variant): Red = 0x18, Blue = 0x20, Yellow = 0x28, Green = 0x58 | 0x80 (the last hue-shifted variant). Unknown/neutral teams are left unchanged.

Variable documentation

AllPeersT Jazz2::Multiplayer::AllPeers constexpr

All connected peers tag.

Use in NetworkManagerBase::SendTo() to send to all connected peers or the remote server peer.

LocalPeerT Jazz2::Multiplayer::LocalPeer constexpr

Local peer tag.

static std::uint8_t Jazz2::Multiplayer::MaxTeamCount constexpr

Maximum number of teams supported.

static std::uint8_t Jazz2::Multiplayer::NoPreferredTeam constexpr

Sentinel team value meaning "no preference, let the server decide".