diff --git a/port/include/net/net.h b/port/include/net/net.h index 38085846e..c80b6fbf3 100644 --- a/port/include/net/net.h +++ b/port/include/net/net.h @@ -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); diff --git a/port/src/net/net.c b/port/src/net/net.c index 42a22669a..2ec34dfcc 100644 --- a/port/src/net/net.c +++ b/port/src/net/net.c @@ -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) { diff --git a/src/game/mplayer/setup.c b/src/game/mplayer/setup.c index f9aed5955..2aa1f3297 100644 --- a/src/game/mplayer/setup.c +++ b/src/game/mplayer/setup.c @@ -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; }