mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-25 14:07:46 +00:00
Improved handling of actors in zones generally
This commit is contained in:
parent
c92ee8b7cd
commit
fcc27defef
3 changed files with 20 additions and 13 deletions
|
@ -3,6 +3,10 @@
|
||||||
#include "Actor/Chara.h"
|
#include "Actor/Chara.h"
|
||||||
#include "Forwards.h"
|
#include "Forwards.h"
|
||||||
#include "Zone.h"
|
#include "Zone.h"
|
||||||
|
#include <Logging/Logger.h>
|
||||||
|
|
||||||
|
#include "Framework.h"
|
||||||
|
extern Core::Framework g_fw;
|
||||||
|
|
||||||
// TODO: the entire zone / areahandling is a bit outdated ( in parts i used this for the 1.0 iteration )
|
// TODO: the entire zone / areahandling is a bit outdated ( in parts i used this for the 1.0 iteration )
|
||||||
// likely this could be greatly improved or redone
|
// likely this could be greatly improved or redone
|
||||||
|
@ -32,6 +36,8 @@ void Core::Cell::init( uint32_t x, uint32_t y, ZonePtr pZone )
|
||||||
|
|
||||||
void Core::Cell::addActor( Entity::ActorPtr pAct )
|
void Core::Cell::addActor( Entity::ActorPtr pAct )
|
||||||
{
|
{
|
||||||
|
auto pLog = g_fw.get< Core::Logger >();
|
||||||
|
pLog->debug( "Adding actor to cell in " + this->m_pZone->getName() );
|
||||||
if( pAct->isPlayer() )
|
if( pAct->isPlayer() )
|
||||||
++m_playerCount;
|
++m_playerCount;
|
||||||
|
|
||||||
|
@ -40,6 +46,8 @@ void Core::Cell::addActor( Entity::ActorPtr pAct )
|
||||||
|
|
||||||
void Core::Cell::removeActor( Entity::ActorPtr pAct )
|
void Core::Cell::removeActor( Entity::ActorPtr pAct )
|
||||||
{
|
{
|
||||||
|
auto pLog = g_fw.get< Core::Logger >();
|
||||||
|
pLog->debug( "Removing actor from cell in " + this->m_pZone->getName() );
|
||||||
if( pAct->isPlayer() )
|
if( pAct->isPlayer() )
|
||||||
--m_playerCount;
|
--m_playerCount;
|
||||||
|
|
||||||
|
|
|
@ -314,6 +314,7 @@ Core::TerritoryMgr::InstanceIdList Core::TerritoryMgr::getInstanceContentIdList(
|
||||||
bool Core::TerritoryMgr::movePlayer( uint32_t territoryId, Core::Entity::PlayerPtr pPlayer )
|
bool Core::TerritoryMgr::movePlayer( uint32_t territoryId, Core::Entity::PlayerPtr pPlayer )
|
||||||
{
|
{
|
||||||
auto pZone = getZoneByTerriId( territoryId );
|
auto pZone = getZoneByTerriId( territoryId );
|
||||||
|
assert( pZone );
|
||||||
return movePlayer( pZone, pPlayer );
|
return movePlayer( pZone, pPlayer );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,8 +334,8 @@ bool Core::TerritoryMgr::movePlayer( ZonePtr pZone, Core::Entity::PlayerPtr pPla
|
||||||
// mark character as zoning in progress
|
// mark character as zoning in progress
|
||||||
pPlayer->setLoadingComplete( false );
|
pPlayer->setLoadingComplete( false );
|
||||||
|
|
||||||
if( pPlayer->getLastPing() != 0 )
|
//if( pPlayer->getLastPing() != 0 )
|
||||||
pPlayer->getCurrentZone()->removeActor( pPlayer );
|
// pPlayer->getCurrentZone()->removeActor( pPlayer );
|
||||||
|
|
||||||
pPlayer->setCurrentZone( pZone );
|
pPlayer->setCurrentZone( pZone );
|
||||||
pZone->pushActor( pPlayer );
|
pZone->pushActor( pPlayer );
|
||||||
|
|
|
@ -225,15 +225,14 @@ void Core::Zone::pushActor( Entity::ActorPtr pActor )
|
||||||
|
|
||||||
void Core::Zone::removeActor( Entity::ActorPtr pActor )
|
void Core::Zone::removeActor( Entity::ActorPtr pActor )
|
||||||
{
|
{
|
||||||
|
float mx = pActor->getPos().x;
|
||||||
|
float my = pActor->getPos().z;
|
||||||
|
uint32_t cx = getPosX( mx );
|
||||||
|
uint32_t cy = getPosY( my );
|
||||||
|
|
||||||
/* TODO: have to wait and see if removal of this actually breaks anything
|
Cell* pCell = getCellPtr(cx, cy);
|
||||||
this however is potentially removing a player from a zone he does not belong to */
|
if( pCell && pCell->hasActor( pActor ) )
|
||||||
//auto pCell = pActor->getCellPtr();
|
pCell->removeActor( pActor );
|
||||||
//if( pCell )
|
|
||||||
//{
|
|
||||||
// pCell->removeActor( pActor );
|
|
||||||
// pCell = nullptr;
|
|
||||||
//}
|
|
||||||
|
|
||||||
if( pActor->isPlayer() )
|
if( pActor->isPlayer() )
|
||||||
{
|
{
|
||||||
|
@ -418,8 +417,7 @@ void Core::Zone::updateSessions( bool changedWeather )
|
||||||
// this session is not linked to this area anymore, remove it from zone session list
|
// this session is not linked to this area anymore, remove it from zone session list
|
||||||
if( ( !pPlayer->getCurrentZone() ) || ( pPlayer->getCurrentZone() != shared_from_this() ) )
|
if( ( !pPlayer->getCurrentZone() ) || ( pPlayer->getCurrentZone() != shared_from_this() ) )
|
||||||
{
|
{
|
||||||
if( pPlayer->getCellPtr() )
|
removeActor( pSession->getPlayer() );
|
||||||
removeActor( pSession->getPlayer() );
|
|
||||||
|
|
||||||
it = m_sessionSet.erase(it );
|
it = m_sessionSet.erase(it );
|
||||||
continue;
|
continue;
|
||||||
|
@ -543,7 +541,7 @@ void Core::Zone::updateActorPosition( Entity::Actor &actor )
|
||||||
if( pOldCell )
|
if( pOldCell )
|
||||||
{
|
{
|
||||||
auto pLog = g_fw.get< Logger >();
|
auto pLog = g_fw.get< Logger >();
|
||||||
pLog->debug( std::string( __FUNCTION__ ) + "removeActor" );
|
pLog->debug( std::string( __FUNCTION__ ) + " -> removeActor() ...moving cell..." );
|
||||||
pOldCell->removeActor( actor.shared_from_this() );
|
pOldCell->removeActor( actor.shared_from_this() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue