diff options
author | Eugenio Favalli <elvenprogrammer@gmail.com> | 2005-09-26 17:24:37 +0000 |
---|---|---|
committer | Eugenio Favalli <elvenprogrammer@gmail.com> | 2005-09-26 17:24:37 +0000 |
commit | a0fd39a05151848bef85e18e25aa0824bc9cef93 (patch) | |
tree | 60f9ed2136268d7570b4716a318e510b2c30d2ce /src/net | |
parent | 1a7f56901301fb8fe08f26526f3314b0974626ca (diff) | |
download | mana-a0fd39a05151848bef85e18e25aa0824bc9cef93.tar.gz mana-a0fd39a05151848bef85e18e25aa0824bc9cef93.tar.bz2 mana-a0fd39a05151848bef85e18e25aa0824bc9cef93.tar.xz mana-a0fd39a05151848bef85e18e25aa0824bc9cef93.zip |
Added a nicer handling of when you get disconnected from the server.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/network.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/net/network.cpp b/src/net/network.cpp index d5a6579b..2d48fc8c 100644 --- a/src/net/network.cpp +++ b/src/net/network.cpp @@ -30,6 +30,7 @@ #include "messagein.h" #include "../log.h" +#include "../main.h" /** Warning: buffers and other variables are shared, so there can be only one connection active at a time */ @@ -215,10 +216,8 @@ void flush() int ret = SDLNet_TCP_Recv(sock, in + in_size, buffer_size - in_size); if (ret <= 0) { - logger->log("Warning: unknown error when receiving data"); - logger->log("SDLNet_GetError(): %s", SDLNet_GetError()); - // The client disconnected, notify it somewhere - logger->error("Disconnected from server"); + logger->log("Error in SDLNet_TCP_Recv(): %s", SDLNet_GetError()); + state = ERROR_STATE; return; } else { @@ -232,10 +231,8 @@ void flush() int ret = SDLNet_TCP_Send(sock, (char*)out, out_size); if (ret < (int)out_size) { - // It is likely that the server disconnected - std::stringstream ss; - ss << "Error in SDLNet_TCP_Send(): " << SDLNet_GetError(); - logger->error(ss.str()); + logger->log("Error in SDLNet_TCP_Send(): %s", SDLNet_GetError()); + state = ERROR_STATE; return; } out_size -= ret; |