Handle host drop errors.

Restart the background screen on errors (instead of looking at a small map preview)

fixes ticket:3313
master
vexed 2012-03-26 00:19:37 -04:00
parent 2f1e063ec8
commit 0de4f38295
2 changed files with 41 additions and 29 deletions

View File

@ -246,6 +246,7 @@ static size_t NET_fillBuffer(Socket **pSocket, SocketSet* socket_set, uint8_t *b
bsocket = NULL; // Because tcp_socket == bsocket...
//Game is pretty much over --should just end everything when HOST dies.
NetPlay.isHostAlive = false;
ingame.localJoiningInProgress = false;
setLobbyError(ERROR_HOSTDROPPED);
NETclose();
return 0;
@ -1798,6 +1799,11 @@ bool NETrecvNet(NETQUEUE *queue, uint8_t *type)
NETplayerDropped(current);
connected_bsocket[current] = NULL; // clear their socket
}
else
{
// lobby errors were set in NET_fillBuffer()
return false;
}
}
}
@ -2691,7 +2697,7 @@ bool NETfindGame(void)
int result = 0;
debug(LOG_NET, "Looking for games...");
if (getLobbyError() == ERROR_INVALID || getLobbyError() == ERROR_KICKED)
if (getLobbyError() == ERROR_INVALID || getLobbyError() == ERROR_KICKED || getLobbyError() == ERROR_HOSTDROPPED)
{
return false;
}

View File

@ -819,8 +819,6 @@ void setLobbyError (LOBBY_ERROR_TYPES error_type)
bool joinGame(const char* host, uint32_t port)
{
PLAYERSTATS playerStats;
LOBBY_ERROR_TYPES oldError;
UDWORD id;
if(ingame.localJoiningInProgress)
{
@ -829,26 +827,23 @@ bool joinGame(const char* host, uint32_t port)
if (!NETjoinGame(host, port, (char*)sPlayer)) // join
{
// Save the error.
oldError = getLobbyError();
if (!oldError)
switch (getLobbyError())
{
oldError = ERROR_CONNECTION;
}
else if (oldError == ERROR_WRONGPASSWORD)
{
// Change to GAMEFIND, screen with a password dialog.
changeTitleMode(GAMEFIND);
showPasswordForm();
id = widgRunScreen(psWScreen); // Run the current set of widgets
if (id != CON_PASSWORD)
{
return false;
}
NETsetGamePassword(widgGetString(psWScreen, CON_PASSWORD));
case ERROR_HOSTDROPPED:
setLobbyError(ERROR_NOERROR);
break;
case ERROR_WRONGPASSWORD:
// Change to GAMEFIND, screen with a password dialog.
changeTitleMode(GAMEFIND);
showPasswordForm();
if (widgRunScreen(psWScreen) != CON_PASSWORD) // Run the current set of widgets
{
return false;
}
NETsetGamePassword(widgGetString(psWScreen, CON_PASSWORD));
break;
default:
break;
}
// Hide a (maybe shown) password form.
@ -857,9 +852,6 @@ bool joinGame(const char* host, uint32_t port)
// Change to GAMEFIND, screen.
changeTitleMode(GAMEFIND);
// Reset the error to the saved one.
setLobbyError(oldError);
// Shows the lobby error.
addGames();
addConsoleBox();
@ -1058,7 +1050,10 @@ void runGameFind(void )
lastupdate = gameTime;
if(safeSearch)
{
NETfindGame(); // find games synchronously
if (!NETfindGame()) // find games synchronously
{
pie_LoadBackDrop(SCREEN_RANDOMBDROP);
}
}
addGames(); //redraw list
addConsoleBox();
@ -1074,7 +1069,10 @@ void runGameFind(void )
if(id == MULTIOP_REFRESH)
{
ingame.localOptionsReceived = true;
NETfindGame(); // find games synchronously
if (!NETfindGame()) // find games synchronously
{
pie_LoadBackDrop(SCREEN_RANDOMBDROP);
}
addGames(); //redraw list.
addConsoleBox();
}
@ -1199,7 +1197,10 @@ void startGameFind(void)
widgHide(psWScreen, MULTIOP_REFRESH);
}
NETfindGame();
if (!NETfindGame())
{
pie_LoadBackDrop(SCREEN_RANDOMBDROP);
}
addGames(); // now add games.
addConsoleBox();
displayConsoleMessages();
@ -1275,7 +1276,7 @@ static void hidePasswordForm(void)
widgReveal(psWScreen, CON_CANCEL);
if (!safeSearch && (!disableLobbyRefresh))
{
widgReveal(psWScreen, MULTIOP_REFRESH);
if (widgGetFromID(psWScreen, MULTIOP_REFRESH)) widgReveal(psWScreen, MULTIOP_REFRESH);
}
addGames();
addConsoleBox();
@ -3639,6 +3640,11 @@ void runMultiOptions(void)
{
processMultiopWidgets(CON_CANCEL); // "Press" the cancel button to clean up net connections and stuff.
}
if (!NetPlay.isHostAlive && !ingame.bHostSetup)
{
changeTitleMode(GAMEFIND);
screen_RestartBackDrop();
}
}
bool startMultiOptions(bool bReenter)