Share online membership and game setup with the server

Profile, member join/leave and building a fresh game move into the sim library,
and the packet reader and writer into protocol.h, so the server can run lobbies
exactly as clients do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-11-08 01:54:27 -05:00
1 parent 465f75f6d7
commit 9613e85706
7 files changed
+181 -105

No files matched your search

+20
View File
@@ -142,8 +142,25 @@ inline int pick_encode(bool isTrinket, int slot, int item)
{.type = EDIT_ITEM, .isTrinket = isTrinket, .index = slot, .value = item < 0 ? EDIT_EMPTY : item});
}
// A player's setup as they join online: their name, the colour they'd like (-1 for any), and their sandbox slots,
// loadouts, levels and stacking, which their fighter starts with. Plain data, sent as it sits in memory.
struct Profile
{
char name[PLAYER_NAME_MAX + 1] = {};
int color = -1;
int weaponSlots = SLOTS_DEFAULT;
int trinketSlots = SLOTS_DEFAULT;
int weaponLoadout[SLOT_MAX] = {};
int trinketLoadout[SLOT_MAX] = {};
int weaponSlotLevels[SLOT_MAX] = {};
int trinketSlotLevels[SLOT_MAX] = {};
int weaponItemLevels[WEAPON_COUNT] = {};
int trinketItemLevels[TRINKET_COUNT] = {};
};
// The default rules for a mode: a best-of-three deathmatch for two, or a three minute race for four.
Rules rules_get(int mode);
Profile profile_get(Fighter& fighter);
Rules rules_clean(Rules rules);
// Online, a game queued in the lobby's sandbox by one of its fighters: its rules, and the area on the ground where
@@ -221,6 +238,9 @@ public:
int queue_startable_get(Sim& sim);
bool is_queue_set(Sim& sim, int queuer);
void queue_slots_shift(int from, int count);
int member_join(Sim& sim, int member, const Profile& profile);
void member_leave(Sim& sim, int member);
int fighter_find(Sim& sim, int member);
int humans_left_get(Sim& sim);
private: