f8607d114c
Implements the multiplayer transport layer from ROADMAP.md: UUID-based client identity, a reliable-packet channel over UDP, handshake/ack/ ping/disconnect/player-joined/player-left/player-state packet types, and split online (networked) vs offline (in-process singleplayer) server modes wired into the engine's update/dispose loop.
51 lines
1.2 KiB
C
51 lines
1.2 KiB
C
/**
|
|
* Copyright (c) 2026 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#pragma once
|
|
#include "util/uuid.h"
|
|
#include "network/socket/client/client.h"
|
|
|
|
#define CLIENT_COUNT_MAX 16
|
|
|
|
extern client_t CLIENT_ROSTER[CLIENT_COUNT_MAX];
|
|
|
|
/**
|
|
* Resets every roster slot back to CLIENT_TYPE_NULL.
|
|
*/
|
|
void clientRosterInit(void);
|
|
|
|
/**
|
|
* Finds the one CLIENT_TYPE_LOCAL slot in the roster, if any.
|
|
*
|
|
* @return The local client slot, or NULL if not connected/hosting.
|
|
*/
|
|
client_t * clientRosterFindLocal(void);
|
|
|
|
/**
|
|
* Finds a CLIENT_TYPE_REMOTE slot by its assigned id.
|
|
*
|
|
* @param id The remote client's id to search for.
|
|
* @return The matching slot, or NULL if not found.
|
|
*/
|
|
client_t * clientRosterFindById(const uuid_t *id);
|
|
|
|
/**
|
|
* Claims the first CLIENT_TYPE_NULL slot in the roster and assigns it
|
|
* the given type. The rest of the slot's data is zeroed.
|
|
*
|
|
* @param type The type to assign to the claimed slot.
|
|
* @return The claimed slot, or NULL if the roster is full.
|
|
*/
|
|
client_t * clientRosterClaim(const clienttype_t type);
|
|
|
|
/**
|
|
* Returns a slot to CLIENT_TYPE_NULL, clearing its data.
|
|
*
|
|
* @param client The slot to free.
|
|
*/
|
|
void clientRosterRemove(client_t *client);
|