mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-25 23:13:35 +00:00
Move to new branch
Added comments Added some comments and changed a variable name to be less ambiguous.
This commit is contained in:
parent
ba5037300f
commit
9cf534dc0a
@ -99,22 +99,6 @@ Entity::~Entity() {
|
||||
m_Character->SaveXMLToDatabase();
|
||||
}
|
||||
|
||||
if (IsPlayer()) {
|
||||
Entity* zoneControl = EntityManager::Instance()->GetZoneControlEntity();
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) {
|
||||
script->OnPlayerExit(zoneControl, this);
|
||||
}
|
||||
|
||||
std::vector<Entity*> scriptedActs = EntityManager::Instance()->GetEntitiesByComponent(COMPONENT_TYPE_SCRIPTED_ACTIVITY);
|
||||
for (Entity* scriptEntity : scriptedActs) {
|
||||
if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(scriptEntity)) {
|
||||
script->OnPlayerExit(scriptEntity, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CancelAllTimers();
|
||||
CancelCallbackTimers();
|
||||
|
||||
|
@ -217,37 +217,42 @@ void EntityManager::UpdateEntities(const float deltaTime) {
|
||||
|
||||
m_EntitiesToKill.clear();
|
||||
|
||||
for (const auto& entry : m_EntitiesToDelete)
|
||||
for (const auto entry : m_EntitiesToDelete)
|
||||
{
|
||||
auto* entity = GetEntity(entry);
|
||||
// Get all this info first before we delete the player.
|
||||
auto entityToDelete = GetEntity(entry);
|
||||
|
||||
m_Entities.erase(entry);
|
||||
auto networkIdToErase = entityToDelete->GetNetworkId();
|
||||
|
||||
const auto& iter = std::find(m_EntitiesToGhost.begin(), m_EntitiesToGhost.end(), entity);
|
||||
const auto& ghostingToDelete = std::find(m_EntitiesToGhost.begin(), m_EntitiesToGhost.end(), entityToDelete);
|
||||
|
||||
if (iter != m_EntitiesToGhost.end())
|
||||
if (entityToDelete != nullptr)
|
||||
{
|
||||
m_EntitiesToGhost.erase(iter);
|
||||
}
|
||||
|
||||
if (entity != nullptr)
|
||||
{
|
||||
if (entity->GetNetworkId() != 0)
|
||||
// If we are a player run through the player destructor.
|
||||
if (entityToDelete->IsPlayer())
|
||||
{
|
||||
m_LostNetworkIds.push(entity->GetNetworkId());
|
||||
}
|
||||
|
||||
if (entity->IsPlayer())
|
||||
{
|
||||
delete dynamic_cast<Player*>(entity);
|
||||
delete dynamic_cast<Player*>(entityToDelete);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete entity;
|
||||
delete entityToDelete;
|
||||
}
|
||||
|
||||
entity = nullptr;
|
||||
entityToDelete = nullptr;
|
||||
|
||||
if (networkIdToErase != 0)
|
||||
{
|
||||
m_LostNetworkIds.push(networkIdToErase);
|
||||
}
|
||||
}
|
||||
|
||||
if (ghostingToDelete != m_EntitiesToGhost.end())
|
||||
{
|
||||
m_EntitiesToGhost.erase(ghostingToDelete);
|
||||
}
|
||||
|
||||
m_Entities.erase(entry);
|
||||
|
||||
}
|
||||
|
||||
m_EntitiesToDelete.clear();
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "dZoneManager.h"
|
||||
#include "CharacterComponent.h"
|
||||
#include "Mail.h"
|
||||
#include "CppScripts.h"
|
||||
|
||||
std::vector<Player*> Player::m_Players = {};
|
||||
|
||||
@ -329,5 +330,21 @@ Player::~Player()
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsPlayer()) {
|
||||
Entity* zoneControl = EntityManager::Instance()->GetZoneControlEntity();
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) {
|
||||
script->OnPlayerExit(zoneControl, this);
|
||||
}
|
||||
|
||||
std::vector<Entity*> scriptedActs = EntityManager::Instance()->GetEntitiesByComponent(COMPONENT_TYPE_SCRIPTED_ACTIVITY);
|
||||
for (Entity* scriptEntity : scriptedActs) {
|
||||
if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(scriptEntity)) {
|
||||
script->OnPlayerExit(scriptEntity, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_Players.erase(iter);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user