Cosmetic changes only.

This commit is contained in:
hiker 2015-10-19 08:11:28 +11:00
parent faf697ef5d
commit e535afc9d8

View File

@ -55,16 +55,16 @@ NetworkManager::~NetworkManager()
delete m_peers.back();
m_peers.pop_back();
}
}
//-----------------------------------------------------------------------------
} // ~Networkmanager
//----------------------------------------------------------------------------
void NetworkManager::run()
{
// create the protocol manager
ProtocolManager::getInstance<ProtocolManager>();
}
} // run
//-----------------------------------------------------------------------------
void NetworkManager::reset()
{
if (m_localhost)
@ -75,8 +75,9 @@ void NetworkManager::reset()
delete m_peers.back();
m_peers.pop_back();
}
}
} // reset
//-----------------------------------------------------------------------------
void NetworkManager::abort()
{
m_localhost->stopListening();
@ -84,7 +85,7 @@ void NetworkManager::abort()
// a new packet_log file (and therefore delete the previous file)???
// reset();
ProtocolManager::getInstance()->abort();
}
} // abort
//-----------------------------------------------------------------------------
@ -94,7 +95,7 @@ bool NetworkManager::connect(const TransportAddress& peer)
return isConnectedTo(peer);
return STKPeer::connectToHost(m_localhost, peer, 2, 0);
}
} // connect
//-----------------------------------------------------------------------------
@ -104,47 +105,52 @@ void NetworkManager::setManualSocketsMode(bool manual)
m_localhost->stopListening();
else
m_localhost->startListening();
}
} // setManualSocketsMode
//-----------------------------------------------------------------------------
void NetworkManager::notifyEvent(Event* event)
{
Log::verbose("NetworkManager", "EVENT received of type %d", (int)(event->type));
Log::verbose("NetworkManager", "EVENT received of type %d",
(int)(event->type));
STKPeer* peer = *event->peer;
if (event->type == EVENT_TYPE_CONNECTED)
{
Log::info("NetworkManager", "A client has just connected. There are now %lu peers.", m_peers.size() + 1);
Log::debug("NetworkManager", "Addresses are : %lx, %lx, %lx", event->peer, *event->peer, peer);
Log::info("NetworkManager", "A client has just connected. There are "
"now %lu peers.", m_peers.size() + 1);
Log::debug("NetworkManager", "Addresses are : %lx, %lx, %lx",
event->peer, *event->peer, peer);
// create the new peer:
m_peers.push_back(peer);
}
if (event->type == EVENT_TYPE_MESSAGE)
{
uint32_t addr = peer->getAddress();
Log::verbose("NetworkManager", "Message, Sender : %i.%i.%i.%i, message = \"%s\"",
((addr>>24)&0xff),
((addr>>16)&0xff),
((addr>>8)&0xff),
(addr & 0xff), event->data().std_string().c_str());
Log::verbose("NetworkManager",
"Message, Sender : %i.%i.%i.%i, message = \"%s\"",
((addr>>24)&0xff),
((addr>>16)&0xff),
((addr>>8)&0xff),
(addr & 0xff), event->data().std_string().c_str());
}
// notify for the event now.
ProtocolManager::getInstance()->notifyEvent(event);
}
} // notifyEvent
//-----------------------------------------------------------------------------
void NetworkManager::sendPacket(STKPeer* peer, const NetworkString& data, bool reliable)
void NetworkManager::sendPacket(STKPeer* peer, const NetworkString& data,
bool reliable)
{
if (peer)
peer->sendPacket(data, reliable);
}
} // sendPacket
//-----------------------------------------------------------------------------
void NetworkManager::sendPacketExcept(STKPeer* peer, const NetworkString& data, bool reliable)
void NetworkManager::sendPacketExcept(STKPeer* peer, const NetworkString& data,
bool reliable)
{
for (unsigned int i = 0; i < m_peers.size(); i++)
{
@ -154,7 +160,7 @@ void NetworkManager::sendPacketExcept(STKPeer* peer, const NetworkString& data,
p->sendPacket(data, reliable);
}
}
}
} // sendPacketExcept
//-----------------------------------------------------------------------------
@ -165,7 +171,7 @@ GameSetup* NetworkManager::setupNewGame()
m_game_setup = NULL;
m_game_setup = new GameSetup();
return m_game_setup;
}
} // setupNewGame
//-----------------------------------------------------------------------------
@ -183,7 +189,7 @@ void NetworkManager::disconnected()
m_peers[i] = NULL;
}
m_peers.clear();
}
} // disconnected
//-----------------------------------------------------------------------------
@ -191,7 +197,7 @@ void NetworkManager::setLogin(std::string username, std::string password)
{
m_player_login.username = username;
m_player_login.password = password;
}
} // setLogin
//-----------------------------------------------------------------------------
@ -222,30 +228,35 @@ void NetworkManager::removePeer(STKPeer* peer)
{
delete m_peers[i];
m_peers.erase(m_peers.begin()+i, m_peers.begin()+i+1);
Log::verbose("NetworkManager", "The peer has been removed from the Network Manager.");
Log::verbose("NetworkManager",
"The peer has been removed from the Network Manager.");
removed = true;
}
else if (m_peers[i]->isSamePeer(peer))
{
Log::fatal("NetworkManager", "Multiple peers match the disconnected one.");
Log::fatal("NetworkManager",
"Multiple peers match the disconnected one.");
}
}
if (!removed)
Log::warn("NetworkManager", "The peer that has been disconnected was not registered by the Network Manager.");
Log::warn("NetworkManager", "The peer that has been disconnected was "
"not registered by the Network Manager.");
Log::info("NetworkManager", "Somebody is now disconnected. There are now %lu peers.", m_peers.size());
}
Log::info("NetworkManager",
"Somebody is now disconnected. There are now %lu peers.",
m_peers.size());
} // removePeer
//-----------------------------------------------------------------------------
bool NetworkManager::peerExists(const TransportAddress& peer)
{
return m_localhost->peerExists(peer);
}
} // peerExists
//-----------------------------------------------------------------------------
bool NetworkManager::isConnectedTo(const TransportAddress& peer)
{
return m_localhost->isConnectedTo(peer);
}
} // isConnectedTo