Server now deletes the player on a new player spawn.

This commit is contained in:
stiffly
2016-02-11 23:52:55 +01:00
parent 70f4002d70
commit e24a84c52d
2 changed files with 7 additions and 7 deletions
+3 -2
View File
@@ -287,7 +287,8 @@ void Client::parseSnapshot(Packet& packet)
for (std::size_t i = 0; i < numInputCommands; ++i) {
Events::InputCommand e;
e.PlayerID = packet.ReadPrimitive<EntityID>();
e.Player = EntityWrapper(m_World, m_ServerIDToClientID.at(packet.ReadPrimitive<EntityID>()));
EntityID player = packet.ReadPrimitive<EntityID>();
e.Player = EntityWrapper(m_World, m_ServerIDToClientID.at(player));
e.Command = packet.ReadString();
e.Value = packet.ReadPrimitive<float>();
m_EventBroker->Publish(e);
@@ -349,7 +350,7 @@ void Client::parseSnapshot(Packet& packet)
m_World->SetParent(localEntityID, m_ServerIDToClientID.at(serverParentID));
}
}
// parseSpawnEvents();
parseSpawnEvents();
}
void Client::disconnect()
+4 -5
View File
@@ -71,18 +71,17 @@ bool PlayerSpawnSystem::OnInputCommand(const Events::InputCommand& e)
bool PlayerSpawnSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
{
// When a player is actually spawned (since the actual spawning is handled on the server)
if (!IsClient) {
return false;
}
// Check if a player already exists
// Hack should be moved.
if (m_PlayerEntities.count(e.PlayerID) != 0) {
// TODO: Disallow infinite respawning here
if (m_PlayerEntities[e.PlayerID].Valid()) {
m_World->DeleteEntity(m_PlayerEntities[e.PlayerID].ID);
}
}
if (!IsClient) {
return false;
}
// Store the player for future reference
m_PlayerEntities[e.PlayerID] = e.Player;