Scoreboard is now works.

This commit is contained in:
Jocke
2016-03-12 19:36:12 +01:00
parent c544f349fd
commit 60df30fa59
5 changed files with 27 additions and 3 deletions
+10 -3
View File
@@ -174,10 +174,16 @@ void Server::sendSnapshot()
Packet packet(MessageType::Snapshot);
addInputCommandsToPacket(packet);
addPlayersToPacket(packet, EntityID_Invalid);
//addChildrenToPacket(packet, EntityID_Invalid);
unreliableBroadcast(packet);
}
// Send snapshot fields
void Server::createWorldSnapshot(Packet& packet)
{
addInputCommandsToPacket(packet);
addChildrenToPacket(packet, EntityID_Invalid);
}
void Server::addInputCommandsToPacket(Packet& packet)
{
// Number of input commands
@@ -380,8 +386,7 @@ void Server::parseTCPConnect(Packet & packet)
m_Reliable.Send(connnectPacket, m_ConnectedPlayers.at(playerID));
Packet firstSnapshot(MessageType::Snapshot);
addInputCommandsToPacket(firstSnapshot);
addChildrenToPacket(firstSnapshot, EntityID_Invalid);
createWorldSnapshot(firstSnapshot);
m_Reliable.Send(firstSnapshot);
// Send notification that a player has connected
@@ -545,6 +550,7 @@ bool Server::OnPlayerDeath(const Events::PlayerDeath& e)
bool Server::OnWin(const Events::Win & e)
{
// Postpone this code and trigger after some time in a update
Events::Reset reset;
m_EventBroker->Publish(reset);
Packet removeMap(MessageType::RemoveWorld);
@@ -554,6 +560,7 @@ bool Server::OnWin(const Events::Win & e)
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/CP_Rocky2.xml");
entityFile->MergeInto(m_World);
Packet newWorld(MessageType::Snapshot);
createWorldSnapshot(newWorld);
reliableBroadcast(newWorld);
return true;
}