From 4722d9f028e402192aa176ae4a81766f58fa2ca0 Mon Sep 17 00:00:00 2001 From: "simon.kagstrom" Date: Sat, 4 Apr 2009 11:18:03 +0000 Subject: [PATCH] Good error message if no servers --- Src/Network.cpp | 8 ++++++++ Src/Network.h | 1 + 2 files changed, 9 insertions(+) diff --git a/Src/Network.cpp b/Src/Network.cpp index 7a00140..c94a758 100644 --- a/Src/Network.cpp +++ b/Src/Network.cpp @@ -970,6 +970,8 @@ network_connection_error_t Network::WaitForPeerList() return SERVER_GARBAGE_ERROR; pi = (NetworkUpdateListPeers *)this->ud->data; + if (pi->n_peers == 0) + return NO_PEERS_ERROR; msgs = (const char**)calloc(pi->n_peers + 1, sizeof(const char*)); for (int i = 0; i < pi->n_peers; i++) { @@ -1108,6 +1110,7 @@ network_connection_error_t Network::ConnectFSM() bool Network::Connect() { + this->network_connection_state = CONN_CONNECT_TO_BROKER; while (1) { SDL_FillRect(real_screen, 0, SDL_MapRGB(real_screen->format, @@ -1142,6 +1145,11 @@ bool Network::Connect() return true; case AGAIN_ERROR: break; + case NO_PEERS_ERROR: + menu_print_font(real_screen, 255,255,0, 30, 70, + "No servers to connect to."); + sleep(1); + return false; case VERSION_ERROR: menu_print_font(real_screen, 255,255,0, 30, 70, "Your frodo is too old."); diff --git a/Src/Network.h b/Src/Network.h index 42976cd..dd88c1d 100644 --- a/Src/Network.h +++ b/Src/Network.h @@ -58,6 +58,7 @@ typedef enum AGAIN_ERROR, VERSION_ERROR, SERVER_GARBAGE_ERROR, + NO_PEERS_ERROR, } network_connection_error_t; struct NetworkUpdate