diff --git a/src/common/Common.h b/src/common/Common.h index 03be85bc..124e318d 100644 --- a/src/common/Common.h +++ b/src/common/Common.h @@ -582,7 +582,7 @@ namespace Common { GearSetEquipMsg = 0x321, - DisableCurrentFestival = 0x386, + SetFestival = 0x386, // param1: festival.exd index ToggleOrchestrionUnlock = 0x396, Dismount = 0x3A0, diff --git a/src/servers/sapphire_zone/Actor/PlayerEvent.cpp b/src/servers/sapphire_zone/Actor/PlayerEvent.cpp index 7aff9966..60761ef2 100644 --- a/src/servers/sapphire_zone/Actor/PlayerEvent.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerEvent.cpp @@ -16,7 +16,6 @@ #include "Action/EventAction.h" #include "Action/EventItemAction.h" -#include "Event/EventHandler.h" #include "Event/EventHandler.h" #include "Zone/Zone.h" diff --git a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp index 1d1d6512..71d8d8fe 100644 --- a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp +++ b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp @@ -134,6 +134,7 @@ void Core::DebugCommandHandler::help( char* data, Entity::Player& player, boost: void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command ) { auto pLog = g_fw.get< Logger >(); + auto pTerriMgr = g_fw.get< TerritoryMgr >(); auto pDb = g_fw.get< Db::DbWorkerPool< Db::CharaDbConnection > >(); std::string subCommand = ""; std::string params = ""; @@ -309,6 +310,17 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost: player.getCurrentZone()->setWeatherOverride( static_cast< Common::Weather >( weatherId ) ); } + else if( subCommand == "festival" ) + { + uint16_t festivalId; + sscanf( params.c_str(), "%hu", &festivalId ); + + pTerriMgr->setCurrentFestival( festivalId ); + } + else if( subCommand == "festivaldisable" ) + { + pTerriMgr->disableCurrentFestival(); + } else { player.sendUrgent( subCommand + " is not a valid SET command." ); @@ -829,21 +841,6 @@ void Core::DebugCommandHandler::instance( char* data, Entity::Player &player, bo instance->setBranch( branch ); } - else if( subCommand == "festival" ) - { - uint32_t festivalId; - sscanf( params.c_str(), "%d", &festivalId ); - - player.getCurrentZone()->setCurrentFestival( static_cast< uint16_t >( festivalId ) ); - } - else if( subCommand == "disablefestival" ) - { - Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorControl143 > actorControl( player.getId() ); - actorControl.data().category = Core::Common::ActorControlType::DisableCurrentFestival; - player.queuePacket( actorControl ); - - player.getCurrentZone()->setCurrentFestival( 0 ); - } else if ( subCommand == "qte_start" ) { auto instance = boost::dynamic_pointer_cast< InstanceContent >( player.getCurrentZone() ); diff --git a/src/servers/sapphire_zone/Zone/TerritoryMgr.cpp b/src/servers/sapphire_zone/Zone/TerritoryMgr.cpp index 500f2d93..b6ee10f4 100644 --- a/src/servers/sapphire_zone/Zone/TerritoryMgr.cpp +++ b/src/servers/sapphire_zone/Zone/TerritoryMgr.cpp @@ -356,5 +356,25 @@ Core::ZonePtr Core::TerritoryMgr::getLinkedInstance( uint32_t playerId ) const return nullptr; } +const uint16_t Core::TerritoryMgr::getCurrentFestival() const +{ + return m_currentFestival; +} + +void Core::TerritoryMgr::setCurrentFestival( uint16_t festivalId ) +{ + m_currentFestival = festivalId; + + for( const auto& zone : m_zoneSet ) + { + zone->setCurrentFestival( m_currentFestival ); + } +} + +void Core::TerritoryMgr::disableCurrentFestival() +{ + setCurrentFestival( 0 ); +} + diff --git a/src/servers/sapphire_zone/Zone/TerritoryMgr.h b/src/servers/sapphire_zone/Zone/TerritoryMgr.h index c6bcf796..c4602e5e 100644 --- a/src/servers/sapphire_zone/Zone/TerritoryMgr.h +++ b/src/servers/sapphire_zone/Zone/TerritoryMgr.h @@ -118,6 +118,10 @@ namespace Core /*! returns an instancePtr if the player is still bound to an isntance */ ZonePtr getLinkedInstance( uint32_t playerId ) const; + void setCurrentFestival( uint16_t festivalId ); + void disableCurrentFestival(); + const uint16_t getCurrentFestival() const; + private: using TerritoryTypeDetailCache = std::unordered_map< uint16_t, Data::TerritoryTypePtr >; using InstanceIdToZonePtrMap = std::unordered_map< uint32_t, ZonePtr >; @@ -154,6 +158,9 @@ namespace Core /*! set of ZonePtrs for quick iteration*/ std::set< ZonePtr > m_instanceZoneSet; + /*! id of current festival to set for public zones from festival.exd */ + uint16_t m_currentFestival; + public: /*! returns a list of instanceContent InstanceIds currently active */ InstanceIdList getInstanceContentIdList( uint16_t instanceContentId ) const; diff --git a/src/servers/sapphire_zone/Zone/Zone.cpp b/src/servers/sapphire_zone/Zone/Zone.cpp index ba5d5869..570de342 100644 --- a/src/servers/sapphire_zone/Zone/Zone.cpp +++ b/src/servers/sapphire_zone/Zone/Zone.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "Zone.h" #include "InstanceContent.h" @@ -136,8 +137,15 @@ uint16_t Core::Zone::getCurrentFestival() const void Core::Zone::setCurrentFestival( uint16_t festivalId ) { m_currentFestivalId = festivalId; -} + for( const auto& playerEntry : m_playerMap ) + { + auto player = playerEntry.second; + + ActorControlPacket143 enableFestival( player->getId(), SetFestival, m_currentFestivalId ); + playerEntry.second->queuePacket( enableFestival ); + } +} void Core::Zone::loadCellCache() {