Fixed bug when client would recieve input command from an entity that the client didn't know about

This commit is contained in:
2016-02-12 06:10:20 +01:00
parent 1e04244590
commit 2e5ee633ce
+6 -2
View File
@@ -287,11 +287,15 @@ void Client::parseSnapshot(Packet& packet)
Events::InputCommand e; Events::InputCommand e;
e.PlayerID = packet.ReadPrimitive<EntityID>(); e.PlayerID = packet.ReadPrimitive<EntityID>();
EntityID player = packet.ReadPrimitive<EntityID>(); EntityID player = packet.ReadPrimitive<EntityID>();
std::string command = packet.ReadString();
float value = packet.ReadPrimitive<float>();
if (m_ServerIDToClientID.find(player) != m_ServerIDToClientID.end()) {
e.Player = EntityWrapper(m_World, m_ServerIDToClientID.at(player)); e.Player = EntityWrapper(m_World, m_ServerIDToClientID.at(player));
e.Command = packet.ReadString(); e.Command = command;
e.Value = packet.ReadPrimitive<float>(); e.Value = value;
m_EventBroker->Publish(e); m_EventBroker->Publish(e);
} }
}
// Read world state // Read world state
while (packet.DataReadSize() < packet.Size()) { while (packet.DataReadSize() < packet.Size()) {