diff --git a/src/servers/sapphire_zone/Actor/Actor.cpp b/src/servers/sapphire_zone/Actor/Actor.cpp index 0e9e9feb..7779a649 100644 --- a/src/servers/sapphire_zone/Actor/Actor.cpp +++ b/src/servers/sapphire_zone/Actor/Actor.cpp @@ -258,7 +258,7 @@ Sets the actors position and notifies the zone to propagate the change void Core::Entity::Actor::setPosition( const Common::FFXIVARR_POSITION3& pos ) { m_pos = pos; - m_pCurrentZone->updateActorPosition(*this); + m_pCurrentZone->updateActorPosition( *this ); } void Core::Entity::Actor::setPosition( float x, float y, float z ) @@ -266,7 +266,7 @@ void Core::Entity::Actor::setPosition( float x, float y, float z ) m_pos.x = x; m_pos.y = y; m_pos.z = z; - m_pCurrentZone->updateActorPosition(*this); + m_pCurrentZone->updateActorPosition( *this ); } /*! @@ -309,9 +309,7 @@ Change the current target and propagate to in range players void Core::Entity::Actor::changeTarget( uint64_t targetId ) { setTargetId( targetId ); - - sendToInRangeSet( ActorControlPacket144( m_id, SetTarget, - 0, 0, 0, 0, targetId ) ); + sendToInRangeSet( ActorControlPacket144( m_id, SetTarget, 0, 0, 0, 0, targetId ) ); } /*! @@ -495,12 +493,10 @@ void Core::Entity::Actor::addInRangeActor( ActorPtr pActor ) // if actor is a player, add it to the in range player set m_inRangePlayers.insert( pPlayer ); } - - m_inRangeActorMap[pActor->getId()] = pActor; } /*! -Remove a given actor from the fitting in range set according to type +Remove a given actor from the matching in range set according to type but also to the global actor map \param ActorPtr to remove @@ -519,11 +515,7 @@ void Core::Entity::Actor::removeInRangeActor( Actor& actor ) actor.despawn( getAsPlayer() ); if( actor.isPlayer() ) - { m_inRangePlayers.erase( actor.getAsPlayer() ); - } - - m_inRangeActorMap.erase( actor.getId() ); } /*! \return true if there is at least one actor in the in range set */ @@ -583,7 +575,6 @@ void Core::Entity::Actor::clearInRangeSet() { m_inRangeActors.clear(); m_inRangePlayers.clear(); - m_inRangeActorMap.clear(); } /*! \return ZonePtr to the current zone, nullptr if not set */ diff --git a/src/servers/sapphire_zone/Actor/Actor.h b/src/servers/sapphire_zone/Actor/Actor.h index 8c4df9a8..e65d1b0a 100644 --- a/src/servers/sapphire_zone/Actor/Actor.h +++ b/src/servers/sapphire_zone/Actor/Actor.h @@ -139,9 +139,8 @@ protected: std::vector< std::pair< uint8_t, uint32_t> > m_statusEffectList; std::map< uint8_t, StatusEffect::StatusEffectPtr > m_statusEffectMap; - std::set< ActorPtr > m_inRangeActors; - std::set< PlayerPtr > m_inRangePlayers; - std::map< uint32_t, ActorPtr > m_inRangeActorMap; + std::set< ActorPtr > m_inRangeActors; + std::set< PlayerPtr > m_inRangePlayers; public: Actor( ObjKind type ); @@ -194,11 +193,8 @@ public: ActorStats getStats() const; uint32_t getHp() const; - uint32_t getMp() const; - uint16_t getTp() const; - uint16_t getGp() const; Common::InvincibilityType getInvincibilityType() const; @@ -216,17 +212,13 @@ public: bool isAlive() const; virtual uint32_t getMaxHp() const; - virtual uint32_t getMaxMp() const; void resetHp(); - void resetMp(); void setHp( uint32_t hp ); - void setMp( uint32_t mp ); - void setGp( uint32_t gp ); void setInvincibilityType( Common::InvincibilityType type ); @@ -241,10 +233,8 @@ public: virtual void autoAttack( ActorPtr pTarget ); - virtual void spawn( PlayerPtr pTarget ) {} - virtual void despawn( PlayerPtr pTarget ) {} - virtual void onRemoveInRangeActor( Actor& pActor ) {} + virtual void onDeath() {}; virtual void onDamageTaken( Actor& pSource ) {}; virtual void onActionHostile( Actor& source ) {}; @@ -273,7 +263,7 @@ public: void sendToInRangeSet( Network::Packets::GamePacketPtr pPacket, bool bToSelf = false ); // add an actor to in range set - virtual void addInRangeActor( ActorPtr pActor ); + void addInRangeActor( ActorPtr pActor ); // remove an actor from the in range set void removeInRangeActor( Actor& pActor ); @@ -298,7 +288,7 @@ public: // set the current cell void setCell( Cell* pCell ); - Core::Cell* m_pCell; + Core::Cell* m_pCell; }; diff --git a/src/servers/sapphire_zone/Actor/GameObject.h b/src/servers/sapphire_zone/Actor/GameObject.h index ecfdc8a5..d1f70b3b 100644 --- a/src/servers/sapphire_zone/Actor/GameObject.h +++ b/src/servers/sapphire_zone/Actor/GameObject.h @@ -53,6 +53,9 @@ namespace Entity { explicit GameObject( ObjKind type ); virtual ~GameObject() {}; + virtual void spawn( PlayerPtr pTarget ) {} + virtual void despawn( PlayerPtr pTarget ) {} + uint32_t getId() const; ObjKind getObjKind() const; diff --git a/src/servers/sapphire_zone/Actor/InstanceObject.cpp b/src/servers/sapphire_zone/Actor/InstanceObject.cpp index a926d27c..a182b66b 100644 --- a/src/servers/sapphire_zone/Actor/InstanceObject.cpp +++ b/src/servers/sapphire_zone/Actor/InstanceObject.cpp @@ -9,8 +9,8 @@ Core::Entity::InstanceObject::InstanceObject( uint32_t objectId, uint32_t mapLin m_id = objectId; } -Core::Entity::InstanceObject::InstanceObject( uint32_t objectId, uint32_t mapLinkId, Common::FFXIVARR_POSITION3 pos ) - : InstanceObject( objectId, mapLinkId ) +Core::Entity::InstanceObject::InstanceObject( uint32_t objectId, uint32_t mapLinkId, Common::FFXIVARR_POSITION3 pos ) : + InstanceObject( objectId, mapLinkId ) { } diff --git a/src/servers/sapphire_zone/Zone/Zone.cpp b/src/servers/sapphire_zone/Zone/Zone.cpp index 18fe57fb..7d96e446 100644 --- a/src/servers/sapphire_zone/Zone/Zone.cpp +++ b/src/servers/sapphire_zone/Zone/Zone.cpp @@ -37,12 +37,11 @@ extern Core::Data::ExdDataGenerated g_exdDataGen; extern Core::Scripting::ScriptManager g_scriptMgr; extern Core::TerritoryMgr g_territoryMgr; -namespace Core { /** * \brief */ -Zone::Zone() : +Core::Zone::Zone() : m_territoryId( 0 ), m_guId( 0 ), m_currentWeather( static_cast< uint8_t >( Common::Weather::FairSkies ) ), @@ -52,7 +51,7 @@ Zone::Zone() : { } -Zone::Zone( uint16_t territoryId, uint32_t guId, const std::string& internalName, const std::string& placeName ) : +Core::Zone::Zone( uint16_t territoryId, uint32_t guId, const std::string& internalName, const std::string& placeName ) : m_currentWeather( static_cast< uint8_t >( Common::Weather::FairSkies ) ) { m_guId = guId; @@ -85,11 +84,11 @@ Zone::Zone( uint16_t territoryId, uint32_t guId, const std::string& internalName m_currentWeather = getNextWeather(); } -Zone::~Zone() +Core::Zone::~Zone() { } -bool Zone::init() +bool Core::Zone::init() { memset( m_pCellCache, 0, sizeof( CellCache* ) * _sizeX ); @@ -103,27 +102,27 @@ bool Zone::init() return true; } -void Zone::setWeatherOverride( uint8_t weather ) +void Core::Zone::setWeatherOverride( uint8_t weather ) { m_weatherOverride = weather; } -uint8_t Zone::getCurrentWeather() const +uint8_t Core::Zone::getCurrentWeather() const { return m_currentWeather; } -uint16_t Zone::getCurrentFestival() const +uint16_t Core::Zone::getCurrentFestival() const { return m_currentFestivalId; } -void Zone::setCurrentFestival( uint16_t festivalId ) +void Core::Zone::setCurrentFestival( uint16_t festivalId ) { m_currentFestivalId = festivalId; } -CellCache* Zone::getCellCacheList( uint32_t cellx, uint32_t celly ) +Core::CellCache* Core::Zone::getCellCacheList( uint32_t cellx, uint32_t celly ) { assert( cellx < _sizeX ); assert( celly < _sizeY ); @@ -133,7 +132,7 @@ CellCache* Zone::getCellCacheList( uint32_t cellx, uint32_t celly ) return m_pCellCache[cellx][celly]; } -CellCache* Zone::getCellCacheAndCreate( uint32_t cellx, uint32_t celly ) +Core::CellCache* Core::Zone::getCellCacheAndCreate( uint32_t cellx, uint32_t celly ) { assert( cellx < _sizeX ); assert( celly < _sizeY ); @@ -151,7 +150,7 @@ CellCache* Zone::getCellCacheAndCreate( uint32_t cellx, uint32_t celly ) return m_pCellCache[cellx][celly]; } -void Zone::loadCellCache() +void Core::Zone::loadCellCache() { auto pQR = g_charaDb.query( "SELECT Id," "Zoneid," @@ -228,7 +227,7 @@ void Zone::loadCellCache() } -uint8_t Zone::getNextWeather() +uint8_t Core::Zone::getNextWeather() { uint32_t unixTime = static_cast< uint32_t >( Util::getTimeSeconds() ); // Get Eorzea hour for weather start @@ -258,7 +257,7 @@ uint8_t Zone::getNextWeather() return 1; } -void Zone::pushActor( Entity::ActorPtr pActor ) +void Core::Zone::pushActor( Entity::ActorPtr pActor ) { float mx = pActor->getPos().x; float my = pActor->getPos().z; @@ -323,7 +322,7 @@ void Zone::pushActor( Entity::ActorPtr pActor ) } -void Zone::removeActor( Entity::ActorPtr pActor ) +void Core::Zone::removeActor( Entity::ActorPtr pActor ) { if( pActor->m_pCell ) @@ -357,7 +356,7 @@ void Zone::removeActor( Entity::ActorPtr pActor ) } -void Zone::queueOutPacketForRange( Entity::Player& sourcePlayer, uint32_t range, Network::Packets::GamePacketPtr pPacketEntry ) +void Core::Zone::queueOutPacketForRange( Entity::Player& sourcePlayer, uint32_t range, Network::Packets::GamePacketPtr pPacketEntry ) { if( g_territoryMgr.isPrivateTerritory( getTerritoryId() ) ) return; @@ -381,32 +380,32 @@ void Zone::queueOutPacketForRange( Entity::Player& sourcePlayer, uint32_t range, } } -uint32_t Zone::getTerritoryId() const +uint32_t Core::Zone::getTerritoryId() const { return m_territoryId; } -uint32_t Zone::getGuId() const +uint32_t Core::Zone::getGuId() const { return m_guId; } -const std::string& Zone::getName() const +const std::string& Core::Zone::getName() const { return m_placeName; } -const std::string& Zone::getInternalName() const +const std::string& Core::Zone::getInternalName() const { return m_internalName; } -std::size_t Zone::getPopCount() const +std::size_t Core::Zone::getPopCount() const { return m_playerMap.size(); } -bool Zone::checkWeather() +bool Core::Zone::checkWeather() { if ( m_weatherOverride != 0 ) { @@ -430,7 +429,7 @@ bool Zone::checkWeather() return false; } -void Zone::updateBnpcs( int64_t tickCount ) +void Core::Zone::updateBnpcs( int64_t tickCount ) { if( ( tickCount - m_lastMobUpdate ) > 250 ) { @@ -478,7 +477,7 @@ void Zone::updateBnpcs( int64_t tickCount ) } } -bool Zone::update( uint32_t currTime ) +bool Core::Zone::update( uint32_t currTime ) { int64_t tickCount = Util::getTimeMs(); @@ -530,7 +529,7 @@ bool Zone::update( uint32_t currTime ) return true; } -bool Zone::isCellActive( uint32_t x, uint32_t y ) +bool Core::Zone::isCellActive( uint32_t x, uint32_t y ) { uint32_t endX = ( ( x + 1 ) <= _sizeX ) ? x + 1 : ( _sizeX - 1 ); uint32_t endY = ( ( y + 1 ) <= _sizeY ) ? y + 1 : ( _sizeY - 1 ); @@ -555,7 +554,7 @@ bool Zone::isCellActive( uint32_t x, uint32_t y ) return false; } -void Zone::updateCellActivity( uint32_t x, uint32_t y, int32_t radius ) +void Core::Zone::updateCellActivity( uint32_t x, uint32_t y, int32_t radius ) { uint32_t endX = ( x + radius ) <= _sizeX ? x + radius : ( _sizeX - 1 ); @@ -609,7 +608,7 @@ void Zone::updateCellActivity( uint32_t x, uint32_t y, int32_t radius ) } } -void Zone::updateActorPosition( Entity::Actor &actor ) +void Core::Zone::updateActorPosition( Entity::Actor &actor ) { if( actor.getCurrentZone() != shared_from_this() ) @@ -676,7 +675,7 @@ void Zone::updateActorPosition( Entity::Actor &actor ) } -void Zone::updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell ) +void Core::Zone::updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell ) { if( pCell == nullptr ) return; @@ -756,36 +755,34 @@ void Zone::updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell ) } } -void Zone::onEnterTerritory( Entity::Player& player ) +void Core::Zone::onEnterTerritory( Entity::Player& player ) { g_log.debug( "Zone::onEnterTerritory: Zone#" + std::to_string( getGuId() ) + "|" + std::to_string( getTerritoryId() ) + + ", Entity#" + std::to_string( player.getId() ) ); } -void Zone::onLeaveTerritory( Entity::Player& player ) +void Core::Zone::onLeaveTerritory( Entity::Player& player ) { g_log.debug( "Zone::onLeaveTerritory: Zone#" + std::to_string( getGuId() ) + "|" + std::to_string( getTerritoryId() ) + + ", Entity#" + std::to_string( player.getId() ) ); } -void Zone::onUpdate( uint32_t currTime ) +void Core::Zone::onUpdate( uint32_t currTime ) { } -void Zone::onFinishLoading( Entity::Player& player ) +void Core::Zone::onFinishLoading( Entity::Player& player ) { } -void Zone::onInitDirector( Entity::Player& player ) +void Core::Zone::onInitDirector( Entity::Player& player ) { } -} - -void Core::Zone::registerInstanceObj( Core::Entity::InstanceObjectPtr object ) +void Core::Zone::registerInstanceObj( Entity::InstanceObjectPtr object ) { if( !object ) return;