Now publishes an EPlayerDisconnected event

This commit is contained in:
stiffly
2016-01-22 10:58:10 +01:00
parent 7a95880e10
commit fcc9d64e7a
3 changed files with 24 additions and 0 deletions
@@ -0,0 +1,18 @@
#ifndef Events_PlayerDisconnected
#define Events_PlayerDisconnected
#include "Core/EventBroker.h"
#include "Core/Entity.h"
namespace Events
{
struct PlayerDisconnected : public Event
{
unsigned int PlayerID;
EntityID Entity;
};
}
#endif
+1
View File
@@ -14,6 +14,7 @@
#include "../Network/Network.h"
#include "Input/EInputCommand.h"
#include "Core/EPlayerDamage.h"
#include "Network/EPlayerDisconnected.h"
class Server : public Network
{
+5
View File
@@ -223,6 +223,11 @@ void Server::disconnect(int i)
//broadcast("A player disconnected");
LOG_INFO("User %s disconnected/timed out", m_PlayerDefinitions[i].Name.c_str());
// Remove enteties and stuff (When we can remove entity, remove it and tell clients to remove the copy they have)
Events::PlayerDisconnected e;
e.Entity = m_PlayerDefinitions[i].EntityID;
e.PlayerID = i;
m_EventBroker->Publish(e);
m_PlayerDefinitions[i].Endpoint = boost::asio::ip::udp::endpoint();
m_PlayerDefinitions[i].EntityID = -1;
m_PlayerDefinitions[i].Name = "";