From 3eca8915fd14dcebe88647a198bfce5d789a6efb Mon Sep 17 00:00:00 2001 From: Eugenio Favalli Date: Thu, 9 Nov 2006 22:19:45 +0000 Subject: Fixed a conflict with Windows headers and updated project files --- src/main.cpp | 2 +- src/net/network.cpp | 24 ++++++++++++------------ src/net/network.h | 3 ++- 3 files changed, 15 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 8cd993fb..0e0fad2f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -578,7 +578,7 @@ int main(int argc, char *argv[]) network->flush(); network->dispatchMessages(); - if (network->getState() == Network::ERROR) + if (network->getState() == Network::NET_ERROR) { state = ERROR_STATE; errorMessage = "Got disconnected from server!"; diff --git a/src/net/network.cpp b/src/net/network.cpp index a7ff6d1d..8da0033d 100644 --- a/src/net/network.cpp +++ b/src/net/network.cpp @@ -107,7 +107,7 @@ Network::~Network() { clearHandlers(); - if (mState != IDLE && mState != ERROR) + if (mState != IDLE && mState != NET_ERROR) disconnect(); SDL_DestroyMutex(mMutex); @@ -118,7 +118,7 @@ Network::~Network() bool Network::connect(const std::string &address, short port) { - if (mState != IDLE && mState != ERROR) + if (mState != IDLE && mState != NET_ERROR) { logger->log("Tried to connect an already connected socket!"); return false; @@ -127,7 +127,7 @@ bool Network::connect(const std::string &address, short port) if (address.empty()) { logger->log("Empty address given to Network::connect()!"); - mState = ERROR; + mState = NET_ERROR; return false; } @@ -146,7 +146,7 @@ bool Network::connect(const std::string &address, short port) if (!mWorkerThread) { logger->log("Unable to create network worker thread"); - mState = ERROR; + mState = NET_ERROR; return false; } @@ -233,7 +233,7 @@ void Network::flush() if (ret < (int)mOutSize) { logger->log("Error in SDLNet_TCP_Send(): %s", SDLNet_GetError()); - mState = ERROR; + mState = NET_ERROR; } mOutSize = 0; SDL_mutexV(mMutex); @@ -287,7 +287,7 @@ MessageIn Network::getNextMessage() { while (!messageReady()) { - if (mState == ERROR) + if (mState == NET_ERROR) break; } @@ -315,7 +315,7 @@ bool Network::realConnect() if (SDLNet_ResolveHost(&ipAddress, mAddress.c_str(), mPort) == -1) { logger->log("Error in SDLNet_ResolveHost(): %s", SDLNet_GetError()); - mState = ERROR; + mState = NET_ERROR; return false; } @@ -325,7 +325,7 @@ bool Network::realConnect() if (!mSocket) { logger->log("Error in SDLNet_TCP_Open(): %s", SDLNet_GetError()); - mState = ERROR; + mState = NET_ERROR; return false; } @@ -344,14 +344,14 @@ void Network::receive() if (!(set = SDLNet_AllocSocketSet(1))) { logger->log("Error in SDLNet_AllocSocketSet(): %s", SDLNet_GetError()); - mState = ERROR; + mState = NET_ERROR; return; } if (SDLNet_TCP_AddSocket(set, mSocket) == -1) { logger->log("Error in SDLNet_AddSocket(): %s", SDLNet_GetError()); - mState = ERROR; + mState = NET_ERROR; } while (mState == CONNECTED) @@ -382,7 +382,7 @@ void Network::receive() else if (ret < 0) { logger->log("Error in SDLNet_TCP_Recv(): %s", SDLNet_GetError()); - mState = ERROR; + mState = NET_ERROR; } else { mInSize += ret; @@ -408,7 +408,7 @@ void Network::receive() // more than one socket is ready.. // this should not happen since we only listen once socket. logger->log("Error in SDLNet_TCP_Recv(), %d sockets are ready : %s", numReady, SDLNet_GetError()); - mState = ERROR; + mState = NET_ERROR; break; } } diff --git a/src/net/network.h b/src/net/network.h index f4637f73..13929ec1 100644 --- a/src/net/network.h +++ b/src/net/network.h @@ -63,12 +63,13 @@ class Network void dispatchMessages(); void flush(); + // ERROR replaced by NET_ERROR because already defined in Windows enum { IDLE, CONNECTED, CONNECTING, DATA, - ERROR + NET_ERROR }; protected: -- cgit v1.2.3-70-g09d2