diff --git a/src/common/Common.h b/src/common/Common.h index 040a296d..15fb9800 100644 --- a/src/common/Common.h +++ b/src/common/Common.h @@ -156,12 +156,6 @@ namespace Common { uint32_t sourceActorId; }; - enum RegionType : uint8_t - { - normal, - instance, - }; - enum CharaLook : uint8_t { Race = 0x00, diff --git a/src/common/Network/PacketDef/Ipcs.h b/src/common/Network/PacketDef/Ipcs.h index c505904a..69e49cfe 100644 --- a/src/common/Network/PacketDef/Ipcs.h +++ b/src/common/Network/PacketDef/Ipcs.h @@ -150,7 +150,7 @@ namespace Packets { EquipDisplayFlags = 0x01FA, // updated 4.2 - CFAvailableContents = 0x01CF, + CFAvailableContents = 0x01FD, // updated 4.2 PrepareZoning = 0x027C, // updated 4.2 ActorGauge = 0x027D, // updated 4.2 diff --git a/src/servers/sapphire_zone/Event/Director.cpp b/src/servers/sapphire_zone/Event/Director.cpp index 79e7142b..f479e502 100644 --- a/src/servers/sapphire_zone/Event/Director.cpp +++ b/src/servers/sapphire_zone/Event/Director.cpp @@ -1 +1,21 @@ #include "Director.h" + +Core::Event::Director::Director( Core::Event::Director::DirectorType type, uint16_t contentId ) : + m_contentId( contentId ), + m_type( type ), + m_directorId( ( static_cast< uint32_t >( type ) << 16 ) | contentId ), + m_sequence( 0 ), + m_branch( 0 ) +{ + +} + +uint32_t Core::Event::Director::getDirectorId() const +{ + return m_directorId; +} + +uint16_t Core::Event::Director::getContentId() const +{ + return m_contentId; +} diff --git a/src/servers/sapphire_zone/Event/Director.h b/src/servers/sapphire_zone/Event/Director.h index 8a3c0245..c570acb6 100644 --- a/src/servers/sapphire_zone/Event/Director.h +++ b/src/servers/sapphire_zone/Event/Director.h @@ -30,9 +30,17 @@ public: DpsChallange = 0x800D }; + Director( DirectorType type, uint16_t contentId ); + + uint32_t getDirectorId() const; + uint16_t getContentId() const; + DirectorType getType() const; + uint8_t getSequence() const; + uint8_t getBranch() const; + private: /*! Id of the content of the director */ - uint16_t m_id; + uint16_t m_contentId; /*! DirectorType | ContentId */ uint32_t m_directorId; @@ -49,11 +57,6 @@ private: /*! type of the director */ DirectorType m_type; - uint32_t getDirectorId() const; - uint16_t getContentId() const; - DirectorType getType() const; - uint8_t getSequence() const; - uint8_t getBranch() const; }; diff --git a/src/servers/sapphire_zone/Network/Handlers/ActionHandler.cpp b/src/servers/sapphire_zone/Network/Handlers/ActionHandler.cpp index c8bbc0f9..7bbfa403 100644 --- a/src/servers/sapphire_zone/Network/Handlers/ActionHandler.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/ActionHandler.cpp @@ -229,6 +229,11 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in { break; } + case 0x321: // Director init finish + { + player.getCurrentZone()->onInitDirector( player.getAsPlayer() ); + break; + } default: { g_log.debug( "[" + std::to_string( m_pSession->getId() ) + "] Unhandled action: " + diff --git a/src/servers/sapphire_zone/Zone/InstanceContent.cpp b/src/servers/sapphire_zone/Zone/InstanceContent.cpp index 23eae2db..e6b9a7e2 100644 --- a/src/servers/sapphire_zone/Zone/InstanceContent.cpp +++ b/src/servers/sapphire_zone/Zone/InstanceContent.cpp @@ -1,24 +1,33 @@ #include "InstanceContent.h" +#include #include #include #include +#include #include "Actor/Player.h" +#include "Network/PacketWrappers/ActorControlPacket142.h" +#include "Network/PacketWrappers/ActorControlPacket143.h" + extern Core::Logger g_log; +using namespace Core::Common; +using namespace Core::Network::Packets; +using namespace Core::Network::Packets::Server; + Core::InstanceContent::InstanceContent( boost::shared_ptr< Core::Data::InstanceContent > pInstanceContent, uint32_t guId, const std::string& internalName, const std::string& contentName, uint32_t instanceContentId ) - : Zone( pInstanceContent->territoryType, guId, internalName, contentName ), + : Zone( static_cast< uint16_t >( pInstanceContent->territoryType ), guId, internalName, contentName ), + Director( Event::Director::InstanceContent, instanceContentId ), m_instanceContentInfo( pInstanceContent ), m_instanceContentId( instanceContentId ), m_state( Created ) { - } Core::InstanceContent::~InstanceContent() @@ -41,6 +50,10 @@ void Core::InstanceContent::onEnterTerritory( Entity::PlayerPtr pPlayer ) g_log.debug( "InstanceContent::onEnterTerritory: Zone#" + std::to_string( getGuId() ) + "|" + std::to_string( getInstanceContentId() ) + + ", Entity#" + std::to_string( pPlayer->getId() ) ); + + pPlayer->queuePacket(ActorControlPacket143( pPlayer->getId(), DirectorInit, getDirectorId(), + getInstanceContentId() ) ); + pPlayer->setStateFlag( PlayerStateFlag::BoundByDuty ); } void Core::InstanceContent::onLeaveTerritory( Entity::PlayerPtr pPlayer ) @@ -48,9 +61,21 @@ void Core::InstanceContent::onLeaveTerritory( Entity::PlayerPtr pPlayer ) g_log.debug( "InstanceContent::onLeaveTerritory: Zone#" + std::to_string( getGuId() ) + "|" + std::to_string( getInstanceContentId() ) + + ", Entity#" + std::to_string( pPlayer->getId() ) ); + pPlayer->queuePacket(ActorControlPacket143( pPlayer->getId(), DirectorClear, getDirectorId() ) ); + pPlayer->unsetStateFlag( PlayerStateFlag::BoundByDuty ); } void Core::InstanceContent::onUpdate( uint32_t currTime ) { } + +void Core::InstanceContent::onFinishLoading( Entity::PlayerPtr pPlayer ) +{ + +} + +void Core::InstanceContent::onInitDirector( Entity::PlayerPtr pPlayer ) +{ + +} diff --git a/src/servers/sapphire_zone/Zone/InstanceContent.h b/src/servers/sapphire_zone/Zone/InstanceContent.h index 504b5a72..1c1705e6 100644 --- a/src/servers/sapphire_zone/Zone/InstanceContent.h +++ b/src/servers/sapphire_zone/Zone/InstanceContent.h @@ -2,13 +2,14 @@ #define SAPPHIRE_INSTANCECONTENT_H #include "Zone.h" +#include "Event/Director.h" #include "Forwards.h" #include namespace Core { -class InstanceContent : public Zone +class InstanceContent : public Zone, Event::Director { public: enum InstanceContentState @@ -27,8 +28,11 @@ public: void onEnterTerritory( Entity::PlayerPtr pPlayer ) override; void onLeaveTerritory( Entity::PlayerPtr pPlayer ) override; + void onFinishLoading( Entity::PlayerPtr pPlayer ) override; + void onInitDirector( Entity::PlayerPtr pPlayer ) override; void onUpdate( uint32_t currTime ) override; + Core::Data::ExdDataGenerated::InstanceContentPtr getInstanceContentInfo() const; uint32_t getInstanceContentId() const; diff --git a/src/servers/sapphire_zone/Zone/Zone.cpp b/src/servers/sapphire_zone/Zone/Zone.cpp index 249af19f..bb79c84c 100644 --- a/src/servers/sapphire_zone/Zone/Zone.cpp +++ b/src/servers/sapphire_zone/Zone/Zone.cpp @@ -41,20 +41,18 @@ namespace Core { /** * \brief */ -Zone::Zone() - : m_territoryId( 0 ) - , m_guId( 0 ) - , m_type( Common::RegionType::normal ) - , m_currentWeather( static_cast< uint8_t >( Common::Weather::FairSkies ) ) - , m_weatherOverride( 0 ) - , m_lastMobUpdate( 0 ) - , m_currentFestivalId( 0 ) +Zone::Zone() : + m_territoryId( 0 ), + m_guId( 0 ), + m_currentWeather( static_cast< uint8_t >( Common::Weather::FairSkies ) ), + m_weatherOverride( 0 ), + m_lastMobUpdate( 0 ), + m_currentFestivalId( 0 ) { } -Zone::Zone( uint16_t territoryId, uint32_t guId, const std::string& internalName, const std::string& placeName ) - : m_type( Common::RegionType::normal ) - , m_currentWeather( static_cast< uint8_t >( Common::Weather::FairSkies ) ) +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; @@ -104,11 +102,6 @@ bool Zone::init() return true; } -bool Zone::isPrivateZone() const -{ - return m_bPrivate; -} - void Zone::setWeatherOverride( uint8_t weather ) { m_weatherOverride = weather; @@ -179,7 +172,7 @@ void Zone::loadCellCache() "Look," "Models," "type " - "FROM battlenpc WHERE ZoneId = " + std::to_string(getTerritoryId() ) + ";" ); + "FROM battlenpc WHERE ZoneId = " + std::to_string( getTerritoryId() ) + ";" ); std::vector< Entity::BattleNpcPtr > cache; @@ -395,26 +388,16 @@ void Zone::queueOutPacketForRange( Entity::Player& sourcePlayer, uint32_t range, } } -uint32_t Zone::getTerritoryId() +uint32_t Zone::getTerritoryId() const { return m_territoryId; } -Common::RegionType Zone::getType() const -{ - return m_type; -} - -uint16_t Zone::getGuId() const +uint32_t Zone::getGuId() const { return m_guId; } -bool Zone::isInstance() const -{ - return m_type == Common::RegionType::instance; -} - const std::string& Zone::getName() const { return m_placeName; @@ -774,8 +757,9 @@ void Zone::updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell ) if( !pOwnPlayer->isLoadingComplete() ) continue; + // this is a hack to limit actor spawn in one packetset count++; - if( count > 15 ) + if( count > 12 ) break; pActor->addInRangeActor( pCurAct ); @@ -829,4 +813,14 @@ void Zone::onUpdate( uint32_t currTime ) } +void Zone::onFinishLoading( Entity::PlayerPtr pPlayer ) +{ + +} + +void Zone::onInitDirector( Entity::PlayerPtr pPlayer ) +{ + +} + } diff --git a/src/servers/sapphire_zone/Zone/Zone.h b/src/servers/sapphire_zone/Zone/Zone.h index ee2e3b89..1310a5bc 100644 --- a/src/servers/sapphire_zone/Zone/Zone.h +++ b/src/servers/sapphire_zone/Zone/Zone.h @@ -32,8 +32,6 @@ protected: std::string m_placeName; std::string m_internalName; - bool m_bPrivate; - std::unordered_map< int32_t, Entity::PlayerPtr > m_playerMap; std::unordered_map< int32_t, Entity::BattleNpcPtr > m_BattleNpcMap; std::unordered_map< int32_t, Entity::EventNpcPtr > m_EventNpcMap; @@ -44,8 +42,6 @@ protected: CellCache** m_pCellCache[_sizeX]; - Common::RegionType m_type; - uint8_t m_currentWeather; uint8_t m_weatherOverride; @@ -64,8 +60,6 @@ public: bool init(); - bool isPrivateZone() const; - /*! overrides the zone's weather, set to 0 to unlock */ void setWeatherOverride( uint8_t weather ); @@ -79,8 +73,10 @@ public: CellCache* getCellCacheAndCreate( uint32_t cellx, uint32_t celly ); virtual void loadCellCache(); - virtual uint32_t getTerritoryId(); + virtual uint32_t getTerritoryId() const; virtual void onEnterTerritory( Entity::PlayerPtr pPlayer ); + virtual void onFinishLoading( Entity::PlayerPtr pPlayer ); + virtual void onInitDirector( Entity::PlayerPtr pPlayer ); virtual void onLeaveTerritory( Entity::PlayerPtr pPlayer ); virtual void onUpdate( uint32_t currTime ); @@ -100,14 +96,9 @@ public: void queueOutPacketForRange( Entity::Player& sourcePlayer, uint32_t range, Network::Packets::GamePacketPtr pPacketEntry ); - Common::RegionType getType() const; - - uint16_t getGuId() const; - - bool isInstance() const; + uint32_t getGuId() const; const std::string& getName() const; - const std::string& getInternalName() const; std::size_t getPopCount() const;