summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
Diffstat (limited to 'src/network')
-rw-r--r--src/network/core/tcp_game.cpp4
-rw-r--r--src/network/network.cpp4
-rw-r--r--src/network/network_client.cpp31
3 files changed, 19 insertions, 20 deletions
diff --git a/src/network/core/tcp_game.cpp b/src/network/core/tcp_game.cpp
index 4f0202c60..64b7ba97a 100644
--- a/src/network/core/tcp_game.cpp
+++ b/src/network/core/tcp_game.cpp
@@ -18,6 +18,7 @@
#include "../network.h"
#include "../network_internal.h"
#include "../../debug.h"
+#include "../../error.h"
#include "table/strings.h"
@@ -46,8 +47,7 @@ NetworkRecvStatus NetworkGameSocketHandler::CloseConnection(bool error)
if (!_network_server && _networking) {
_switch_mode = SM_MENU;
_networking = false;
- extern StringID _switch_mode_errorstr;
- _switch_mode_errorstr = STR_NETWORK_ERROR_LOSTCONNECTION;
+ ShowErrorMessage(STR_NETWORK_ERROR_LOSTCONNECTION, INVALID_STRING_ID, WL_CRITICAL);
return NETWORK_RECV_STATUS_CONN_LOST;
}
diff --git a/src/network/network.cpp b/src/network/network.cpp
index 0b6e9c35a..dd47be172 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -36,6 +36,7 @@
#include "../rev.h"
#include "../core/pool_func.hpp"
#include "../gfx_func.h"
+#include "../error.h"
#include "table/strings.h"
#ifdef DEBUG_DUMP_COMMANDS
@@ -287,8 +288,7 @@ uint NetworkCalculateLag(const NetworkClientSocket *cs)
void NetworkError(StringID error_string)
{
_switch_mode = SM_MENU;
- extern StringID _switch_mode_errorstr;
- _switch_mode_errorstr = error_string;
+ ShowErrorMessage(error_string, INVALID_STRING_ID, WL_CRITICAL);
}
/**
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index c98253648..fd133dc54 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -526,12 +526,11 @@ bool ClientNetworkGameSocketHandler::IsConnected()
************/
extern bool SafeLoad(const char *filename, int mode, GameMode newgm, Subdirectory subdir, struct LoadFilter *lf = NULL);
-extern StringID _switch_mode_errorstr;
NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_FULL(Packet *p)
{
/* We try to join a server which is full */
- _switch_mode_errorstr = STR_NETWORK_ERROR_SERVER_FULL;
+ ShowErrorMessage(STR_NETWORK_ERROR_SERVER_FULL, INVALID_STRING_ID, WL_CRITICAL);
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
return NETWORK_RECV_STATUS_SERVER_FULL;
@@ -540,7 +539,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_FULL(Packet *p)
NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_BANNED(Packet *p)
{
/* We try to join a server where we are banned */
- _switch_mode_errorstr = STR_NETWORK_ERROR_SERVER_BANNED;
+ ShowErrorMessage(STR_NETWORK_ERROR_SERVER_BANNED, INVALID_STRING_ID, WL_CRITICAL);
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
return NETWORK_RECV_STATUS_SERVER_BANNED;
@@ -652,28 +651,28 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_ERROR(Packet *p
case NETWORK_ERROR_NOT_AUTHORIZED:
case NETWORK_ERROR_NOT_EXPECTED:
case NETWORK_ERROR_COMPANY_MISMATCH:
- _switch_mode_errorstr = STR_NETWORK_ERROR_SERVER_ERROR;
+ ShowErrorMessage(STR_NETWORK_ERROR_SERVER_ERROR, INVALID_STRING_ID, WL_CRITICAL);
break;
case NETWORK_ERROR_FULL:
- _switch_mode_errorstr = STR_NETWORK_ERROR_SERVER_FULL;
+ ShowErrorMessage(STR_NETWORK_ERROR_SERVER_FULL, INVALID_STRING_ID, WL_CRITICAL);
break;
case NETWORK_ERROR_WRONG_REVISION:
- _switch_mode_errorstr = STR_NETWORK_ERROR_WRONG_REVISION;
+ ShowErrorMessage(STR_NETWORK_ERROR_WRONG_REVISION, INVALID_STRING_ID, WL_CRITICAL);
break;
case NETWORK_ERROR_WRONG_PASSWORD:
- _switch_mode_errorstr = STR_NETWORK_ERROR_WRONG_PASSWORD;
+ ShowErrorMessage(STR_NETWORK_ERROR_WRONG_PASSWORD, INVALID_STRING_ID, WL_CRITICAL);
break;
case NETWORK_ERROR_KICKED:
- _switch_mode_errorstr = STR_NETWORK_ERROR_KICKED;
+ ShowErrorMessage(STR_NETWORK_ERROR_KICKED, INVALID_STRING_ID, WL_CRITICAL);
break;
case NETWORK_ERROR_CHEATER:
- _switch_mode_errorstr = STR_NETWORK_ERROR_CHEATER;
+ ShowErrorMessage(STR_NETWORK_ERROR_CHEATER, INVALID_STRING_ID, WL_CRITICAL);
break;
case NETWORK_ERROR_TOO_MANY_COMMANDS:
- _switch_mode_errorstr = STR_NETWORK_ERROR_TOO_MANY_COMMANDS;
+ ShowErrorMessage(STR_NETWORK_ERROR_TOO_MANY_COMMANDS, INVALID_STRING_ID, WL_CRITICAL);
break;
default:
- _switch_mode_errorstr = STR_NETWORK_ERROR_LOSTCONNECTION;
+ ShowErrorMessage(STR_NETWORK_ERROR_LOSTCONNECTION, INVALID_STRING_ID, WL_CRITICAL);
}
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
@@ -710,7 +709,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CHECK_NEWGRFS(P
}
/* NewGRF mismatch, bail out */
- _switch_mode_errorstr = STR_NETWORK_ERROR_NEWGRF_MISMATCH;
+ ShowErrorMessage(STR_NETWORK_ERROR_NEWGRF_MISMATCH, INVALID_STRING_ID, WL_CRITICAL);
return ret;
}
@@ -849,7 +848,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(Packet
if (!load_success) {
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
- _switch_mode_errorstr = STR_NETWORK_ERROR_SAVEGAMEERROR;
+ ShowErrorMessage(STR_NETWORK_ERROR_SAVEGAMEERROR, INVALID_STRING_ID, WL_CRITICAL);
return NETWORK_RECV_STATUS_SAVEGAME;
}
/* If the savegame has successfully loaded, ALL windows have been removed,
@@ -1053,7 +1052,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_SHUTDOWN(Packet
/* Only when we're trying to join we really
* care about the server shutting down. */
if (this->status >= STATUS_JOIN) {
- _switch_mode_errorstr = STR_NETWORK_MESSAGE_SERVER_SHUTDOWN;
+ ShowErrorMessage(STR_NETWORK_MESSAGE_SERVER_SHUTDOWN, INVALID_STRING_ID, WL_CRITICAL);
}
return NETWORK_RECV_STATUS_SERVER_ERROR;
@@ -1068,7 +1067,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_NEWGAME(Packet
* Client ID modulo 16. This way reconnects should be spread
* out a bit. */
_network_reconnect = _network_own_client_id % 16;
- _switch_mode_errorstr = STR_NETWORK_MESSAGE_SERVER_REBOOT;
+ ShowErrorMessage(STR_NETWORK_MESSAGE_SERVER_REBOOT, INVALID_STRING_ID, WL_CRITICAL);
}
return NETWORK_RECV_STATUS_SERVER_ERROR;
@@ -1157,7 +1156,7 @@ void ClientNetworkGameSocketHandler::CheckConnection()
* the server will forcefully disconnect you. */
if (lag > 20) {
this->NetworkGameSocketHandler::CloseConnection();
- _switch_mode_errorstr = STR_NETWORK_ERROR_LOSTCONNECTION;
+ ShowErrorMessage(STR_NETWORK_ERROR_LOSTCONNECTION, INVALID_STRING_ID, WL_CRITICAL);
return;
}