forked from Ports/perfect_dark
port: net: fix team/handicap menus with 5+ players
This commit is contained in:
1 parent
e6df6014c7
commit
7ec54e6d0b
3 files changed
+72
No files matched your search
@@ -148,6 +148,8 @@ void netServerStageStart(void);
|
|||||||
void netServerStageEnd(void);
|
void netServerStageEnd(void);
|
||||||
void netServerKick(struct netclient *cl, const u32 reason);
|
void netServerKick(struct netclient *cl, const u32 reason);
|
||||||
|
|
||||||
|
struct netclient *netClientForPlayerNum(s32 playernum);
|
||||||
|
|
||||||
void netClientSyncRng(void);
|
void netClientSyncRng(void);
|
||||||
void netClientSettingsChanged(void);
|
void netClientSettingsChanged(void);
|
||||||
|
|
||||||
|
|||||||
@@ -330,6 +330,21 @@ static inline const char *netGetDisconnectReason(const u32 reason)
|
|||||||
return msgs[0];
|
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)
|
void netInit(void)
|
||||||
{
|
{
|
||||||
if (enet_initialize() < 0) {
|
if (enet_initialize() < 0) {
|
||||||
|
|||||||
@@ -23,6 +23,9 @@
|
|||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "gbiex.h"
|
#include "gbiex.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#ifndef PLATFORM_N64
|
||||||
|
#include "net/net.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
struct menuitem g_MpCharacterMenuItems[];
|
struct menuitem g_MpCharacterMenuItems[];
|
||||||
struct menudialogdef g_MpAddSimulantMenuDialog;
|
struct menudialogdef g_MpAddSimulantMenuDialog;
|
||||||
@@ -2297,6 +2300,15 @@ MenuItemHandlerResult menuhandlerMpHandicapPlayer(s32 operation, struct menuitem
|
|||||||
char *mpMenuTextHandicapPlayerName(struct menuitem *item)
|
char *mpMenuTextHandicapPlayerName(struct menuitem *item)
|
||||||
{
|
{
|
||||||
if (g_MpSetup.chrslots & (1 << item->param)) {
|
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;
|
return g_PlayerConfigsArray[item->param].base.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2598,6 +2610,40 @@ struct menuitem g_MpHandicapsMenuItems[] = {
|
|||||||
0x000000ff,
|
0x000000ff,
|
||||||
menuhandlerMpHandicapPlayer,
|
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,
|
MENUITEMTYPE_SEPARATOR,
|
||||||
0,
|
0,
|
||||||
@@ -3407,6 +3453,15 @@ char *mpMenuTextChrNameForTeamSetup(struct menuitem *item)
|
|||||||
struct mpchrconfig *mpchr = mpGetChrConfigBySlotNum(item->param);
|
struct mpchrconfig *mpchr = mpGetChrConfigBySlotNum(item->param);
|
||||||
|
|
||||||
if (mpchr) {
|
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;
|
return mpchr->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user