1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-06 10:47:45 +00:00

Removed unused cell logic

This commit is contained in:
Mordred 2022-02-22 23:47:11 +01:00
parent a37046f0ec
commit 5a3b22a4a7
3 changed files with 6 additions and 74 deletions

View file

@ -10,9 +10,7 @@
Sapphire::Cell::Cell() : Sapphire::Cell::Cell() :
m_bActive( false ), m_bActive( false ),
m_bLoaded( false ), m_playerCount( 0 )
m_playerCount( 0 ),
m_bUnloadPending( false )
{ {
m_bForcedActive = false; m_bForcedActive = false;
} }
@ -22,9 +20,8 @@ Sapphire::Cell::~Cell()
removeActors(); removeActors();
} }
void Sapphire::Cell::init( uint32_t x, uint32_t y, TerritoryPtr pZone ) void Sapphire::Cell::init( uint32_t x, uint32_t y )
{ {
m_pZone = pZone;
m_posX = static_cast< uint16_t >( x ); m_posX = static_cast< uint16_t >( x );
m_posY = static_cast< uint16_t >( y ); m_posY = static_cast< uint16_t >( y );
@ -57,9 +54,6 @@ void Sapphire::Cell::setActivity( bool state )
//} //}
if( m_bUnloadPending )
cancelPendingUnload();
} }
else if( m_bActive && !state ) else if( m_bActive && !state )
{ {
@ -94,40 +88,17 @@ void Sapphire::Cell::removeActors()
continue; continue;
} }
if( m_bUnloadPending )
{
}
} }
m_playerCount = 0; m_playerCount = 0;
m_bLoaded = false;
}
void Sapphire::Cell::queueUnloadPending()
{
if( m_bUnloadPending )
return;
m_bUnloadPending = true;
}
void Sapphire::Cell::cancelPendingUnload()
{
if( !m_bUnloadPending )
return;
} }
void Sapphire::Cell::unload() void Sapphire::Cell::unload()
{ {
assert( m_bUnloadPending );
if( m_bActive ) if( m_bActive )
return; return;
removeActors(); removeActors();
m_bUnloadPending = false;
} }

View file

@ -18,18 +18,15 @@ private:
uint16_t m_posY; uint16_t m_posY;
ActorSet m_actors; ActorSet m_actors;
bool m_bActive; bool m_bActive;
bool m_bLoaded;
bool m_bUnloadPending;
uint16_t m_playerCount; uint16_t m_playerCount;
TerritoryPtr m_pZone;
public: public:
Cell(); Cell();
~Cell(); ~Cell();
void init( uint32_t x, uint32_t y, TerritoryPtr pZone ); void init( uint32_t x, uint32_t y );
void addActor( Entity::GameObjectPtr pAct ); void addActor( Entity::GameObjectPtr pAct );
@ -69,37 +66,8 @@ public:
return m_bActive; return m_bActive;
} }
bool isLoaded() const
{
return m_bLoaded;
}
uint32_t getPlayerCount() const
{
return m_playerCount;
}
bool isUnloadPending() const
{
return m_bUnloadPending;
}
void setUnloadPending( bool up )
{
m_bUnloadPending = up;
}
void queueUnloadPending();
void cancelPendingUnload();
void unload(); void unload();
void setPermanentActivity( bool val )
{
m_bForcedActive = val;
}
bool isForcedActive() const bool isForcedActive() const
{ {
return m_bForcedActive; return m_bForcedActive;

View file

@ -214,7 +214,7 @@ void Territory::pushActor( const Entity::GameObjectPtr& pActor )
if( !pCell ) if( !pCell )
{ {
pCell = create( cx, cy ); pCell = create( cx, cy );
pCell->init( cx, cy, shared_from_this() ); pCell->init( cx, cy );
} }
pCell->addActor( pActor ); pCell->addActor( pActor );
@ -565,12 +565,10 @@ void Territory::updateCellActivity( uint32_t x, uint32_t y, int32_t radius )
if( isCellActive( posX, posY ) ) if( isCellActive( posX, posY ) )
{ {
pCell = create( posX, posY ); pCell = create( posX, posY );
pCell->init( posX, posY, shared_from_this() ); pCell->init( posX, posY );
pCell->setActivity( true ); pCell->setActivity( true );
assert( !pCell->isLoaded() );
} }
} }
else else
@ -579,11 +577,6 @@ void Territory::updateCellActivity( uint32_t x, uint32_t y, int32_t radius )
if( isCellActive( posX, posY ) && !pCell->isActive() ) if( isCellActive( posX, posY ) && !pCell->isActive() )
{ {
pCell->setActivity( true ); pCell->setActivity( true );
if( !pCell->isLoaded() )
{
}
} }
else if( !isCellActive( posX, posY ) && pCell->isActive() ) else if( !isCellActive( posX, posY ) && pCell->isActive() )
pCell->setActivity( false ); pCell->setActivity( false );
@ -612,7 +605,7 @@ void Territory::updateActorPosition( Entity::GameObject& actor )
if( !pCell ) if( !pCell )
{ {
pCell = create( cellX, cellY ); pCell = create( cellX, cellY );
pCell->init( cellX, cellY, shared_from_this() ); pCell->init( cellX, cellY );
} }
// If object moved cell // If object moved cell