diff options
-rw-r--r-- | src/net/network.cpp | 19 | ||||
-rw-r--r-- | src/net/protocol.cpp | 11 |
2 files changed, 16 insertions, 14 deletions
diff --git a/src/net/network.cpp b/src/net/network.cpp index 8ad0fd85..b9d0fc55 100644 --- a/src/net/network.cpp +++ b/src/net/network.cpp @@ -22,6 +22,7 @@ */ #include "network.h" +#include "../main.h" #ifndef WIN32 #include <unistd.h> #include <fcntl.h> @@ -44,7 +45,7 @@ fd_set write_socket; void WFIFOSET(int len) { if (out_size + len >= buffer_size) { - log("Warning: Output buffer full"); + logger.log("Warning: Output buffer full"); } else { out_size += len; @@ -153,30 +154,30 @@ void flush() } } if (ret == SOCKET_ERROR) { - error("Socket Error"); + logger.error("Socket Error"); #ifdef WIN32 - log("Error: Socket error: %i ", WSAGetLastError()); + logger.log("Error: Socket error: %i ", WSAGetLastError()); if (WSAGetLastError() == 10053) - log("Error: Packet size error"); + logger.log("Error: Packet size error"); /** Probably the last packet you sent, was defined with * wrong size: WFIFOSET(size); */ #else - log("Error: Undefined socket error"); + logger.log("Error: Undefined socket error"); #endif } } // Read data, if available - if(FD_ISSET(sock, &read_socket)) { + if (FD_ISSET(sock, &read_socket)) { /* There's no check for partial received packets because at this level the app doesn't know packet length, but it will done when parsing received data */ ret = recv(sock, in+in_size, RFIFOSPACE, 0); - if(ret==SOCKET_ERROR) { + if (ret == SOCKET_ERROR) { #ifdef WIN32 - log("Error: Socket error: %i ", WSAGetLastError()); + logger.log("Error: Socket error: %i ", WSAGetLastError()); #else - log("Error: Undefined socket error"); + logger.log("Error: Undefined socket error"); #endif } else RFIFOSET(ret); // Set size of available data to read } diff --git a/src/net/protocol.cpp b/src/net/protocol.cpp index ab873576..94c4a5e1 100644 --- a/src/net/protocol.cpp +++ b/src/net/protocol.cpp @@ -156,8 +156,9 @@ void set_coordinates(char *data, unsigned short x, unsigned short y, void map_start() { // Connect to map server - if (open_session(iptostring(map_address), map_port) == SOCKET_ERROR) { - log("Warning: Unable to connect to map server"); + if (open_session(iptostring(map_address), map_port) == SOCKET_ERROR) + { + logger.log("Warning: Unable to connect to map server"); throw "Unable to connect to map server"; return; } @@ -181,13 +182,13 @@ void map_start() startX = get_x(RFIFOP(6)); startY = get_y(RFIFOP(6)); int direction = get_direction(RFIFOP(6)); - log("Protocol: Player start position: (%d, %d), Direction: %d", + logger.log("Protocol: Player start position: (%d, %d), Direction: %d", startX, startY, direction); RFIFOSKIP(11); } else if (0x0081) { - log("Warning: Map server D/C"); + logger.log("Warning: Map server D/C"); } else { - error("Unknown packet: map_start"); + logger.error("Unknown packet: map_start"); } // Send "map loaded" |