Skip to content

Commit

Permalink
port: net: fix main menu lockup after playing a 5+ player game
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsfdsfgs committed Jan 7, 2024
1 parent 4eca4a1 commit 9f6b21e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
24 changes: 22 additions & 2 deletions port/src/net/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#include "game/bondgun.h"
#include "game/game_1531a0.h"
#include "game/game_0b0fd0.h"
#include "game/title.h"
#include "game/menu.h"
#include "game/pdmode.h"
#include "game/mplayer/mplayer.h"
#include "lib/main.h"
#include "lib/vi.h"
#include "config.h"
Expand Down Expand Up @@ -504,8 +508,24 @@ s32 netDisconnect(void)
sysLogPrintf(LOG_CHAT, "NET: disconnected");

if (wasingame) {
// skip the "want to save" dialog for all players
for (s32 i = 0; i < MAX_PLAYERS; ++i) {
if (g_Vars.players[i]) {
g_PlayerConfigsArray[i].options |= OPTION_ASKEDSAVEPLAYER;
}
}
// end the stage immediately
mainEndStage();
// try to drop back to main menu with 1 player
mpSetPaused(MPPAUSEMODE_UNPAUSED);
g_MpSetup.chrslots = 1;
g_Vars.mplayerisrunning = false;
g_Vars.normmplayerisrunning = false;
g_Vars.lvmpbotlevel = 0;
titleSetNextStage(STAGE_CITRAINING);
setNumPlayers(1);
titleSetNextMode(TITLEMODE_SKIP);
mainChangeToStage(STAGE_CITRAINING);
}

return 0;
Expand Down Expand Up @@ -850,8 +870,8 @@ void netPlayersAllocate(void)
cfg->options = g_PlayerConfigsArray[0].options & OPTION_PAINTBALL;
cfg->options |= cl->settings.options & ~OPTION_PAINTBALL;
// don't enable toggle aim, invert pitch or lookahead for remote players
cfg->options &= ~(OPTION_AIMCONTROL | OPTION_LOOKAHEAD | OPTION_ASKEDSAVEPLAYER);
cfg->options |= OPTION_FORWARDPITCH;
cfg->options &= ~(OPTION_AIMCONTROL | OPTION_LOOKAHEAD);
cfg->options |= OPTION_FORWARDPITCH | OPTION_ASKEDSAVEPLAYER;
}

cl->config = &g_PlayerConfigsArray[cl->playernum];
Expand Down
4 changes: 2 additions & 2 deletions port/src/pdmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ void mainEndStage(void)
s32 prevplayernum = g_Vars.currentplayernum;
s32 i;

for (i = 0; i < PLAYERCOUNT(); i++) {
for (i = 0; i < LOCALPLAYERCOUNT(); i++) {
setCurrentPlayerNum(i);
endscreenPushCoop();
}
Expand All @@ -596,7 +596,7 @@ void mainEndStage(void)
s32 prevplayernum = g_Vars.currentplayernum;
s32 i;

for (i = 0; i < PLAYERCOUNT(); i++) {
for (i = 0; i < LOCALPLAYERCOUNT(); i++) {
setCurrentPlayerNum(i);
endscreenPushAnti();
}
Expand Down
4 changes: 2 additions & 2 deletions src/game/lv.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ void lvReset(s32 stagenum)
}

if (g_Vars.mplayerisrunning == false) {
g_Vars.playerstats[0].mpindex = 4;
g_Vars.playerstats[0].mpindex = MAX_PLAYERS;
g_PlayerConfigsArray[MAX_PLAYERS].contpad1 = 0;
g_PlayerConfigsArray[MAX_PLAYERS].contpad2 = 1;
}
Expand Down Expand Up @@ -1700,7 +1700,7 @@ Gfx *lvRender(Gfx *gdl)
artifactsTick();

#ifndef PLATFORM_N64
if ((g_NetMode && i) || i > MAX_LOCAL_PLAYERS) {
if ((g_NetMode && i) || i >= MAX_LOCAL_PLAYERS) {
gdl = savedgdl;
}
#endif
Expand Down

0 comments on commit 9f6b21e

Please sign in to comment.