summaryrefslogtreecommitdiff
path: root/src/net/ea/network.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-04-09 14:48:07 +0300
committerAndrei Karas <akaras@inbox.ru>2013-04-09 14:48:07 +0300
commit099c67f93cf49cda90be55606e1b744c47624b92 (patch)
tree43a07082db3961e7aa121813ec52c6add0de6df8 /src/net/ea/network.cpp
parent8d1a43609fcf67bbffb26ab52fdb07f095f602b8 (diff)
downloadmanaverse-099c67f93cf49cda90be55606e1b744c47624b92.tar.gz
manaverse-099c67f93cf49cda90be55606e1b744c47624b92.tar.bz2
manaverse-099c67f93cf49cda90be55606e1b744c47624b92.tar.xz
manaverse-099c67f93cf49cda90be55606e1b744c47624b92.zip
improve network class.
Diffstat (limited to 'src/net/ea/network.cpp')
-rw-r--r--src/net/ea/network.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp
index 00c83d3b0..c7441d579 100644
--- a/src/net/ea/network.cpp
+++ b/src/net/ea/network.cpp
@@ -144,10 +144,8 @@ void Network::flush()
if (!mOutSize || mState != CONNECTED)
return;
- int ret;
-
SDL_mutexP(mMutex);
- ret = TcpNet::send(mSocket, mOutBuffer, mOutSize);
+ int ret = TcpNet::send(mSocket, mOutBuffer, mOutSize);
DEBUGLOG(std::string("Send ").append(toString(mOutSize)).append(" bytes"));
if (ret < static_cast<int>(mOutSize))
{
@@ -158,7 +156,7 @@ void Network::flush()
SDL_mutexV(mMutex);
}
-void Network::skip(int len)
+void Network::skip(const int len)
{
SDL_mutexP(mMutex);
mToSkip += len;
@@ -189,8 +187,9 @@ bool Network::realConnect()
if (TcpNet::resolveHost(&ipAddress, mServer.hostname.c_str(),
mServer.port) == -1)
{
- std::string errorMessage = std::string(_("Unable to resolve host \""))
- .append(mServer.hostname).append("\"");
+ const std::string errorMessage = std::string(
+ _("Unable to resolve host \"")).append(
+ mServer.hostname).append("\"");
setError(errorMessage);
logger->log("TcpNet::ResolveHost: %s", errorMessage.c_str());
return false;
@@ -210,7 +209,6 @@ bool Network::realConnect()
ipToString(ipAddress.host), ipAddress.port);
mState = CONNECTED;
-
return true;
}
@@ -237,7 +235,6 @@ void Network::receive()
// to escape the loop
const int numReady = TcpNet::checkSockets(
set, (static_cast<uint32_t>(500)));
- int ret;
switch (numReady)
{
case -1:
@@ -247,6 +244,7 @@ void Network::receive()
break;
case 1:
+ {
// Receive data from the socket
SDL_mutexP(mMutex);
if (mInSize > BUFFER_LIMIT)
@@ -256,8 +254,8 @@ void Network::receive()
continue;
}
- ret = TcpNet::recv(mSocket, mInBuffer + mInSize,
- BUFFER_SIZE - mInSize);
+ int ret = TcpNet::recv(mSocket, mInBuffer + mInSize,
+ BUFFER_SIZE - mInSize);
if (!ret)
{
@@ -291,6 +289,7 @@ void Network::receive()
}
SDL_mutexV(mMutex);
break;
+ }
default:
// more than one socket is ready..