mirror of
https://github.com/perfect-dark-pc-port/perfect_dark.git
synced 2026-10-24 00:02:43 +02:00
port: net: fix teams in netgames
This commit is contained in:
1 parent
7bee9cdcfc
commit
53fbbb8a10
4 files changed
+21
-1
No files matched your search
@@ -78,6 +78,7 @@ struct netclient {
|
||||
char name[NET_MAX_NAME];
|
||||
u8 headnum;
|
||||
u8 bodynum;
|
||||
u8 team;
|
||||
} settings;
|
||||
|
||||
struct mpplayerconfig *config;
|
||||
|
||||
@@ -164,6 +164,7 @@ static inline void netClientReset(struct netclient *cl)
|
||||
cl->out.data = cl->out_data;
|
||||
cl->out.size = sizeof(cl->out_data);
|
||||
cl->id = cl - g_NetClients;
|
||||
cl->settings.team = 0xff;
|
||||
}
|
||||
|
||||
static inline void netClientResetAll(void)
|
||||
|
||||
+12
-1
@@ -377,7 +377,9 @@ u32 netmsgSvcStageStartWrite(struct netbuf *dst)
|
||||
for (s32 i = 0; i < g_NetMaxClients; ++i) {
|
||||
struct netclient *ncl = &g_NetClients[i];
|
||||
if (ncl->state) {
|
||||
ncl->settings.team = g_PlayerConfigsArray[ncl->id].base.team;
|
||||
netbufWriteU8(dst, ncl->id);
|
||||
netbufWriteU8(dst, ncl->settings.team);
|
||||
netbufWriteU8(dst, ncl->settings.bodynum);
|
||||
netbufWriteU8(dst, ncl->settings.headnum);
|
||||
netbufWriteStr(dst, ncl->settings.name);
|
||||
@@ -438,6 +440,7 @@ u32 netmsgSvcStageStartRead(struct netbuf *src, struct netclient *srccl)
|
||||
for (u8 i = 0; i < numplayers; ++i) {
|
||||
const u8 id = netbufReadU8(src);
|
||||
struct netclient *ncl = &g_NetClients[id];
|
||||
ncl->settings.team = netbufReadU8(src);
|
||||
if (ncl != g_NetLocalClient) {
|
||||
ncl->id = id;
|
||||
ncl->settings.bodynum = netbufReadU8(src);
|
||||
@@ -449,11 +452,19 @@ u32 netmsgSvcStageStartRead(struct netbuf *src, struct netclient *srccl)
|
||||
sysLogPrintf(LOG_WARNING, "NET: malformed SVC_STAGE from server");
|
||||
return 3;
|
||||
}
|
||||
// if this is the server player, set team on server's player config
|
||||
if (ncl->id == 0) {
|
||||
g_PlayerConfigsArray[g_NetLocalClient->id].base.team = ncl->settings.team;
|
||||
} else {
|
||||
g_PlayerConfigsArray[ncl->id].base.team = ncl->settings.team;
|
||||
}
|
||||
} else {
|
||||
// skip our own settings
|
||||
// skip our own settings except for the team
|
||||
netbufReadU8(src);
|
||||
netbufReadU8(src);
|
||||
netbufReadStr(src);
|
||||
// set team on the player 0 config
|
||||
g_PlayerConfigsArray[0].base.team = ncl->settings.team;
|
||||
}
|
||||
ncl->state = CLSTATE_GAME;
|
||||
ncl->player = NULL;
|
||||
|
||||
@@ -2996,6 +2996,13 @@ struct mpchrconfig *mpGetChrConfigBySlotNum(s32 slot)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
// ignore chrslots while setting up a netgame
|
||||
if (!result && g_NetMode && slot < g_NetMaxClients && g_NetClients[slot].state >= CLSTATE_LOBBY) {
|
||||
result = &g_PlayerConfigsArray[slot].base;
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user