Now publishes an EPlayerDisconnected event
This commit is contained in:
@@ -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
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "../Network/Network.h"
|
||||
#include "Input/EInputCommand.h"
|
||||
#include "Core/EPlayerDamage.h"
|
||||
#include "Network/EPlayerDisconnected.h"
|
||||
|
||||
class Server : public Network
|
||||
{
|
||||
|
||||
@@ -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 = "";
|
||||
|
||||
Reference in New Issue
Block a user