port: net: fix team/handicap menus with 5+ players

This commit is contained in:
fgsfds committed 2024-01-14 17:54:16 +01:00
1 parent e6df6014c7
commit 7ec54e6d0b
3 files changed
+72

No files matched your search

+2
View File
@@ -148,6 +148,8 @@ void netServerStageStart(void);
void netServerStageEnd(void);
void netServerKick(struct netclient *cl, const u32 reason);
struct netclient *netClientForPlayerNum(s32 playernum);
void netClientSyncRng(void);
void netClientSettingsChanged(void);
+15
View File
@@ -330,6 +330,21 @@ static inline const char *netGetDisconnectReason(const u32 reason)
return msgs[0];
}
struct netclient *netClientForPlayerNum(s32 playernum)
{
s32 slot = 0;
for (s32 i = 0; i < g_NetMaxClients; ++i) {
struct netclient *cl = &g_NetClients[i];
if (cl->state >= CLSTATE_LOBBY) {
if (slot == playernum) {
return cl;
}
++slot;
}
}
return NULL;
}
void netInit(void)
{
if (enet_initialize() < 0) {
+55
View File
@@ -23,6 +23,9 @@
#include "data.h"
#include "gbiex.h"
#include "types.h"
#ifndef PLATFORM_N64
#include "net/net.h"
#endif
struct menuitem g_MpCharacterMenuItems[];
struct menudialogdef g_MpAddSimulantMenuDialog;
@@ -2297,6 +2300,15 @@ MenuItemHandlerResult menuhandlerMpHandicapPlayer(s32 operation, struct menuitem
char *mpMenuTextHandicapPlayerName(struct menuitem *item)
{
if (g_MpSetup.chrslots & (1 << item->param)) {
#ifndef PLATFORM_N64
if (g_NetMode) {
// use client names directly, as the config names are not set yet
struct netclient *cl = netClientForPlayerNum(item->param);
if (cl) {
return cl->settings.name;
}
}
#endif
return g_PlayerConfigsArray[item->param].base.name;
}
@@ -2598,6 +2610,40 @@ struct menuitem g_MpHandicapsMenuItems[] = {
0x000000ff,
menuhandlerMpHandicapPlayer,
},
#if MAX_PLAYERS > 4
{
MENUITEMTYPE_SLIDER,
4,
MENUITEMFLAG_LESSLEFTPADDING | MENUITEMFLAG_LOCKABLEMINOR,
(uintptr_t)&mpMenuTextHandicapPlayerName,
0x000000ff,
menuhandlerMpHandicapPlayer,
},
{
MENUITEMTYPE_SLIDER,
5,
MENUITEMFLAG_LESSLEFTPADDING | MENUITEMFLAG_LOCKABLEMINOR,
(uintptr_t)&mpMenuTextHandicapPlayerName,
0x000000ff,
menuhandlerMpHandicapPlayer,
},
{
MENUITEMTYPE_SLIDER,
6,
MENUITEMFLAG_LESSLEFTPADDING | MENUITEMFLAG_LOCKABLEMINOR,
(uintptr_t)&mpMenuTextHandicapPlayerName,
0x000000ff,
menuhandlerMpHandicapPlayer,
},
{
MENUITEMTYPE_SLIDER,
7,
MENUITEMFLAG_LESSLEFTPADDING | MENUITEMFLAG_LOCKABLEMINOR,
(uintptr_t)&mpMenuTextHandicapPlayerName,
0x000000ff,
menuhandlerMpHandicapPlayer,
},
#endif
{
MENUITEMTYPE_SEPARATOR,
0,
@@ -3407,6 +3453,15 @@ char *mpMenuTextChrNameForTeamSetup(struct menuitem *item)
struct mpchrconfig *mpchr = mpGetChrConfigBySlotNum(item->param);
if (mpchr) {
#ifndef PLATFORM_N64
if (g_NetMode) {
// use client names directly, as the config names are not set yet
struct netclient *cl = netClientForPlayerNum(item->param);
if (cl) {
return cl->settings.name;
}
}
#endif
return mpchr->name;
}