Server now deletes the player on a new player spawn.
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user