Lobby Overhaul

Rewrote lobby to unify common and Doom-specific packet structure, allowing for saner handling of in-game joining. Added a new per-client stage system that allows individual clients to be handled at a time when gathering and sharing info. Reworked lobby UI to display user info and added kick/ban functionalities. Bans are only a temporary per-game IP ban (use passwords to keep unwanted users out). Increased max player count to 64 and unified engine constant.
This commit is contained in:
Boondorl 2025-03-05 17:52:13 -05:00 committed by Rachael Alexanderson
commit ad3bcfddba
21 changed files with 1596 additions and 1465 deletions

File diff suppressed because it is too large Load diff

View file

@ -2,45 +2,43 @@
#define __I_NET_H__
#include <stdint.h>
#include "tarray.h"
// Called by D_DoomMain.
int I_InitNetwork (void);
void I_ClearNode(int node);
void I_NetCmd (void);
void I_NetMessage(const char*, ...);
void I_NetError(const char* error);
void I_NetProgress(int val);
void I_NetInit(const char* msg, int num);
bool I_NetLoop(bool (*timer_callback)(void*), void* userdata);
void I_NetDone();
inline constexpr size_t MAXPLAYERS = 64u;
enum ENetConstants
{
DOOMCOM_ID = 0x12345678,
DEFAULT_GAME_ID = 0x12345678,
BACKUPTICS = 35 * 5, // Remember up to 5 seconds of data.
MAXTICDUP = 3,
MAXSENDTICS = 35 * 1, // Only send up to 1 second of data at a time.
LOCALCMDTICS = (BACKUPTICS*MAXTICDUP),
LOCALCMDTICS = (BACKUPTICS * MAXTICDUP),
MAX_MSGLEN = 14000,
CMD_SEND = 1,
CMD_GET = 2,
};
enum ENCMD
enum ENetCommand
{
NCMD_EXIT = 0x80, // Client has left the game
NCMD_RETRANSMIT = 0x40, //
NCMD_SETUP = 0x20, // Guest is letting the host know who it is
NCMD_LEVELREADY = 0x10, // After loading a level, guests send this over to the host who then sends it back after all are received
NCMD_QUITTERS = 0x08, // Client is getting info about one or more players quitting (packet server only)
NCMD_COMPRESSED = 0x04, // Remainder of packet is compressed
NCMD_LATENCYACK = 0x02, // A latency packet was just read, so let the sender know.
NCMD_LATENCY = 0x01, // Latency packet, used for measuring RTT.
CMD_NONE,
CMD_SEND,
CMD_GET,
};
NCMD_USERINFO = NCMD_SETUP + 1, // Guest is getting another client's user info
NCMD_GAMEINFO = NCMD_SETUP + 2, // Guest is getting the state of the game from the host
NCMD_GAMEREADY = NCMD_SETUP + 3, // Host has verified the game is ready to be started
enum ENetFlags
{
NCMD_EXIT = 0x80, // Client has left the game
NCMD_RETRANSMIT = 0x40, //
NCMD_SETUP = 0x20, // Guest is letting the host know who it is
NCMD_LEVELREADY = 0x10, // After loading a level, guests send this over to the host who then sends it back after all are received
NCMD_QUITTERS = 0x08, // Client is getting info about one or more players quitting (packet server only)
NCMD_COMPRESSED = 0x04, // Remainder of packet is compressed
NCMD_LATENCYACK = 0x02, // A latency packet was just read, so let the sender know.
NCMD_LATENCY = 0x01, // Latency packet, used for measuring RTT.
};
enum ENetMode
{
NET_PeerToPeer,
NET_PacketServer
};
struct FClientStack : public TArray<int>
@ -59,31 +57,22 @@ struct FClientStack : public TArray<int>
}
};
extern FClientStack NetworkClients;
//
// Network packet data.
//
struct doomcom_t
{
// info common to all nodes
uint32_t id; // should be DOOMCOM_ID
int16_t ticdup; // 1 = no duplication, 2-3 = dup for slow nets
int16_t numplayers;
// info specific to this node
int16_t consoleplayer;
// communication between DOOM and the driver
int16_t command; // CMD_SEND or CMD_GET
int16_t remoteplayer; // dest for send, set by get (-1 = no packet).
// packet data to be sent
int16_t datalength; // bytes in data to be sent
uint8_t data[MAX_MSGLEN];
};
extern doomcom_t doomcom;
extern bool netgame, multiplayer;
extern int consoleplayer;
extern int Net_Arbitrator;
extern FClientStack NetworkClients;
extern ENetMode NetMode;
extern uint8_t NetBuffer[MAX_MSGLEN];
extern size_t NetBufferLength;
extern uint8_t TicDup;
extern int RemoteClient;
extern uint8_t MaxClients;
extern uint32_t GameID;
bool I_InitNetwork();
void I_ClearClient(size_t client);
void I_NetCmd(ENetCommand cmd);
void I_NetDone();
void HandleIncomingConnection();
#endif

View file

@ -51,15 +51,21 @@ public:
virtual ~FStartupScreen() = default;
virtual void Progress() {}
virtual void AppendStatusLine(const char* status) {}
virtual void LoadingStatus(const char* message, int colors) {}
virtual void NetInit(const char *message, int num_players) {}
virtual void NetProgress(int count) {}
virtual void NetInit(const char* message, bool host) {}
virtual void NetMessage(const char* message) {}
virtual void NetConnect(int client, const char* name, unsigned flags, int status) {}
virtual void NetUpdate(int client, int status) {}
virtual void NetDisconnect(int client) {}
virtual void NetProgress(int cur, int limit) {}
virtual void NetDone() {}
virtual void NetClose() {}
virtual bool ShouldStartNet() { return false; }
virtual bool NetLoop(bool (*timer_callback)(void *), void *userdata) { return false; }
virtual void AppendStatusLine(const char* status) {}
virtual void LoadingStatus(const char* message, int colors) {}
virtual int GetNetKickClient() { return -1; }
virtual int GetNetBanClient() { return -1; }
virtual bool NetLoop(bool (*loopCallback)(void *), void *data) { return false; }
protected:
int MaxPos, CurPos, NotchPos;
@ -71,14 +77,21 @@ public:
FBasicStartupScreen(int max_progress);
~FBasicStartupScreen();
void Progress();
void NetInit(const char* message, int num_players);
void NetProgress(int count);
void NetMessage(const char* format, ...); // cover for printf
void NetDone();
void NetClose();
void Progress() override;
void NetInit(const char* message, bool host) override;
void NetMessage(const char* message) override;
void NetConnect(int client, const char* name, unsigned flags, int status) override;
void NetUpdate(int client, int status) override;
void NetDisconnect(int client) override;
void NetProgress(int cur, int limit) override;
void NetDone() override;
void NetClose() override;
bool ShouldStartNet() override;
bool NetLoop(bool (*timer_callback)(void*), void* userdata);
int GetNetKickClient() override;
int GetNetBanClient() override;
bool NetLoop(bool (*loopCallback)(void*), void* data) override;
protected:
int NetMaxPos, NetCurPos;
};