From: Holger Schemel Date: Thu, 31 May 2018 11:26:51 +0000 (+0200) Subject: added some missing error handling and more detailed error messages X-Git-Tag: 4.1.1.0~124 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=3cd6ce46ede907d634625bd3458b374a86a5fb42;p=rocksndiamonds.git added some missing error handling and more detailed error messages --- diff --git a/src/netserv.c b/src/netserv.c index 7c38ceed..547c2c91 100644 --- a/src/netserv.c +++ b/src/netserv.c @@ -483,14 +483,20 @@ void NetworkServer(int port, int serveronly) #endif if (SDLNet_ResolveHost(&ip, NULL, port) == -1) - Error(ERR_EXIT_NETWORK_SERVER, "SDLNet_ResolveHost() failed"); + Error(ERR_EXIT_NETWORK_SERVER, "SDLNet_ResolveHost() failed: %s", + SDLNet_GetError()); - lfd = SDLNet_TCP_Open(&ip); - if (!lfd) - Error(ERR_EXIT_NETWORK_SERVER, "SDLNet_TCP_Open() failed"); + if ((fds = SDLNet_AllocSocketSet(MAX_PLAYERS + 1)) == NULL) + Error(ERR_EXIT_NETWORK_SERVER, "SDLNet_AllocSocketSet() failed: %s"), + SDLNet_GetError(); - fds = SDLNet_AllocSocketSet(MAX_PLAYERS+1); - SDLNet_TCP_AddSocket(fds, lfd); + if ((lfd = SDLNet_TCP_Open(&ip)) == NULL) + Error(ERR_EXIT_NETWORK_SERVER, "SDLNet_TCP_Open() failed: %s"), + SDLNet_GetError(); + + if (SDLNet_TCP_AddSocket(fds, lfd) == -1) + Error(ERR_EXIT_NETWORK_SERVER, "SDLNet_TCP_AddSocket() failed: %s"), + SDLNet_GetError(); if (options.verbose) {