Removed unnecessary setting of token, use ProtocolManager sendExcept

instead of loop.
This commit is contained in:
hiker 2016-03-01 16:45:42 +11:00
parent d086501035
commit 052e369df2
2 changed files with 4 additions and 15 deletions

View File

@ -105,18 +105,9 @@ bool ControllerEventsProtocol::notifyEventAsynchronous(Event* event)
}
if (NetworkConfig::get()->isServer())
{
const std::vector<STKPeer*> &peers = STKHost::get()->getPeers();
for(unsigned int i=0; i<peers.size(); i++)
{
STKPeer *peer = peers[i];
// Don't send message to the host from which the message
// was sent from originally
if(peer != event->getPeer())
{
pure_message.setToken(peer->getClientServerToken());
peer->sendPacket(&pure_message, false);
} // if peer != event->getPeer()
} // for i in peers
// Send update to all clients except the original sender.
ProtocolManager::getInstance()->sendMessageExcept(event->getPeer(),
&pure_message, false);
} // if server
return true;
} // notifyEventAsynchronous
@ -157,7 +148,6 @@ void ControllerEventsProtocol::controllerAction(Controller* controller,
uint8_t serialized_3 = (uint8_t)(controls->m_steer*127.0);
NetworkString *ns = getNetworkString(17);
ns->setToken(STKHost::get()->getPeers()[0]->getClientServerToken());
ns->addFloat(World::getWorld()->getTime());
ns->addUInt8(controller->getKart()->getWorldKartId());
ns->addUInt8(serialized_1).addUInt8(serialized_2).addUInt8(serialized_3);

View File

@ -85,8 +85,7 @@ void GameEventsProtocol::collectedItem(Item* item, AbstractKart* kart)
const std::vector<STKPeer*> &peers = STKHost::get()->getPeers();
for (unsigned int i = 0; i < peers.size(); i++)
{
NetworkString *ns = getNetworkString(11);
ns->setToken(peers[i]->getClientServerToken());
NetworkString *ns = getNetworkString(7);
ns->setSynchronous(true);
// Item picked : send item id, powerup type and kart race id
uint8_t powerup = 0;