From 0946b0636e940d9e6040a21c2789ef3e395f0933 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sat, 1 Sep 2018 20:55:28 +1000 Subject: [PATCH] allow for multiple festivals to run at once --- .../Network/PacketDef/Zone/ServerZoneDef.h | 2 +- .../quest/subquest/gridania/SubFst029.cpp | 4 ++-- src/servers/sapphire_zone/Actor/Player.cpp | 3 ++- .../DebugCommand/DebugCommandHandler.cpp | 6 +++-- .../sapphire_zone/Zone/TerritoryMgr.cpp | 8 +++---- src/servers/sapphire_zone/Zone/TerritoryMgr.h | 22 +++++++++++++++---- src/servers/sapphire_zone/Zone/Zone.cpp | 11 +++++----- src/servers/sapphire_zone/Zone/Zone.h | 9 ++++++-- 8 files changed, 43 insertions(+), 22 deletions(-) diff --git a/src/common/Network/PacketDef/Zone/ServerZoneDef.h b/src/common/Network/PacketDef/Zone/ServerZoneDef.h index c6b5f854..54f3cc11 100644 --- a/src/common/Network/PacketDef/Zone/ServerZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ServerZoneDef.h @@ -685,7 +685,7 @@ struct FFXIVIpcInitZone : uint8_t bitmask; uint16_t unknown5; uint16_t festivalId; - uint16_t unknown7; + uint16_t additionalFestivalId; uint32_t unknown8; Common::FFXIVARR_POSITION3 pos; }; diff --git a/src/servers/Scripts/quest/subquest/gridania/SubFst029.cpp b/src/servers/Scripts/quest/subquest/gridania/SubFst029.cpp index fc94b032..8c180d4b 100644 --- a/src/servers/Scripts/quest/subquest/gridania/SubFst029.cpp +++ b/src/servers/Scripts/quest/subquest/gridania/SubFst029.cpp @@ -29,7 +29,7 @@ private: // Entities found in the script data of the quest static constexpr auto Actor0 = 1000430; - static constexpr auto Ritem0 = 4552; + static constexpr uint32_t Ritem0 = 4552; static constexpr auto Seq0Actor0 = 0; static constexpr auto Seq1Actor0 = 1; static constexpr auto Seq1Actor0Npctradeno = 99; @@ -75,7 +75,7 @@ private: player.playScene( getId(), 1, HIDE_HOTBAR, [ & ]( Entity::Player& player, const Event::SceneResult& result ) { - if( result.param2 == 1 && player.collectHandInItems( { uint32_t{ Ritem0 } } ) ) + if( result.param2 == 1 && player.collectHandInItems( { Ritem0 } ) ) { Scene00100( player ); } diff --git a/src/servers/sapphire_zone/Actor/Player.cpp b/src/servers/sapphire_zone/Actor/Player.cpp index 502e69c8..1747f4db 100644 --- a/src/servers/sapphire_zone/Actor/Player.cpp +++ b/src/servers/sapphire_zone/Actor/Player.cpp @@ -1590,7 +1590,8 @@ void Core::Entity::Player::sendZonePackets() initZonePacket->data().weatherId = static_cast< uint8_t >( getCurrentZone()->getCurrentWeather() ); initZonePacket->data().bitmask = 0x1; initZonePacket->data().unknown5 = 0x2A; - initZonePacket->data().festivalId = getCurrentZone()->getCurrentFestival(); + initZonePacket->data().festivalId = getCurrentZone()->getCurrentFestival().first; + initZonePacket->data().additionalFestivalId = getCurrentZone()->getCurrentFestival().second; initZonePacket->data().pos.x = getPos().x; initZonePacket->data().pos.y = getPos().y; initZonePacket->data().pos.z = getPos().z; diff --git a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp index 40c62bc9..31c3cc2a 100644 --- a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp +++ b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp @@ -313,9 +313,11 @@ void Core::DebugCommandHandler::set( char* data, Entity::Player& player, boost:: else if( subCommand == "festival" ) { uint16_t festivalId; - sscanf( params.c_str(), "%hu", &festivalId ); + uint16_t additionalId; - pTerriMgr->setCurrentFestival( festivalId ); + sscanf( params.c_str(), "%hu %hu", &festivalId, &additionalId ); + + pTerriMgr->setCurrentFestival( festivalId, additionalId ); } else if( subCommand == "festivaldisable" ) { diff --git a/src/servers/sapphire_zone/Zone/TerritoryMgr.cpp b/src/servers/sapphire_zone/Zone/TerritoryMgr.cpp index 105787eb..9d4c5e02 100644 --- a/src/servers/sapphire_zone/Zone/TerritoryMgr.cpp +++ b/src/servers/sapphire_zone/Zone/TerritoryMgr.cpp @@ -417,18 +417,18 @@ Core::ZonePtr Core::TerritoryMgr::getLinkedInstance( uint32_t playerId ) const return nullptr; } -const uint16_t Core::TerritoryMgr::getCurrentFestival() const +const std::pair< uint16_t, uint16_t >& Core::TerritoryMgr::getCurrentFestival() const { return m_currentFestival; } -void Core::TerritoryMgr::setCurrentFestival( uint16_t festivalId ) +void Core::TerritoryMgr::setCurrentFestival( uint16_t festivalId, uint16_t additionalFestival ) { - m_currentFestival = festivalId; + m_currentFestival = { festivalId, additionalFestival }; for( const auto& zone : m_zoneSet ) { - zone->setCurrentFestival( m_currentFestival ); + zone->setCurrentFestival( festivalId, additionalFestival ); } } diff --git a/src/servers/sapphire_zone/Zone/TerritoryMgr.h b/src/servers/sapphire_zone/Zone/TerritoryMgr.h index 8c31f310..665f029e 100644 --- a/src/servers/sapphire_zone/Zone/TerritoryMgr.h +++ b/src/servers/sapphire_zone/Zone/TerritoryMgr.h @@ -123,11 +123,23 @@ public: /*! returns an instancePtr if the player is still bound to an isntance */ ZonePtr getLinkedInstance( uint32_t playerId ) const; - void setCurrentFestival( uint16_t festivalId ); + /*! + * @brief Sets the current festival for every zone + * @param festivalId A valid festival id from festival.exd + * @param additionalFestival A valid festival id from festival.exd, this is shown in addition to the first festival + */ + void setCurrentFestival( uint16_t festivalId, uint16_t additionalFestival = 0 ); + /*! + * @brief Disables the current festival(s) in every zone + */ void disableCurrentFestival(); - const uint16_t getCurrentFestival() const; + /*! + * @brief Gets the current festival set on the server + * @return a pair with the 2 festivals currently active + */ + const std::pair< uint16_t, uint16_t >& getCurrentFestival() const; private: using TerritoryTypeDetailCache = std::unordered_map< uint16_t, Data::TerritoryTypePtr >; @@ -165,8 +177,10 @@ private: /*! 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; + /*! current festival(s) to set for public zones from festival.exd */ + std::pair< uint16_t, uint16_t > m_currentFestival; + + public: /*! returns a list of instanceContent InstanceIds currently active */ diff --git a/src/servers/sapphire_zone/Zone/Zone.cpp b/src/servers/sapphire_zone/Zone/Zone.cpp index 02c91ed5..c33f6613 100644 --- a/src/servers/sapphire_zone/Zone/Zone.cpp +++ b/src/servers/sapphire_zone/Zone/Zone.cpp @@ -52,7 +52,6 @@ Core::Zone::Zone() : m_currentWeather( Weather::FairSkies ), m_weatherOverride( Weather::None ), m_lastMobUpdate( 0 ), - m_currentFestivalId( 0 ), m_nextEObjId( 0x400D0000 ) { } @@ -129,20 +128,20 @@ Weather Core::Zone::getCurrentWeather() const return m_currentWeather; } -uint16_t Core::Zone::getCurrentFestival() const +const Core::FestivalPair& Core::Zone::getCurrentFestival() const { - return m_currentFestivalId; + return m_currentFestival; } -void Core::Zone::setCurrentFestival( uint16_t festivalId ) +void Core::Zone::setCurrentFestival( uint16_t festivalId, uint16_t additionalFestivalId ) { - m_currentFestivalId = festivalId; + m_currentFestival = { festivalId, additionalFestivalId }; for( const auto& playerEntry : m_playerMap ) { auto player = playerEntry.second; - auto enableFestival = makeActorControl143( player->getId(), SetFestival, m_currentFestivalId ); + auto enableFestival = makeActorControl143( player->getId(), SetFestival, festivalId, additionalFestivalId ); playerEntry.second->queuePacket( enableFestival ); } } diff --git a/src/servers/sapphire_zone/Zone/Zone.h b/src/servers/sapphire_zone/Zone/Zone.h index 7a1e69f4..447cd10a 100644 --- a/src/servers/sapphire_zone/Zone/Zone.h +++ b/src/servers/sapphire_zone/Zone/Zone.h @@ -23,6 +23,8 @@ class Session; class ZonePosition; using SessionSet = std::set< SessionPtr >; +using FestivalPair = std::pair< uint16_t, uint16_t >; + namespace Data { struct InstanceContent; struct TerritoryType; @@ -48,7 +50,10 @@ protected: uint64_t m_lastMobUpdate; + FestivalPair m_currentFestival; + uint16_t m_currentFestivalId; + uint16_t m_currentAdditionalFestivalId; boost::shared_ptr< Data::TerritoryType > m_territoryTypeInfo; std::map< uint8_t, int32_t > m_weatherRateMap; @@ -67,9 +72,9 @@ public: Common::Weather getCurrentWeather() const; - uint16_t getCurrentFestival() const; + const FestivalPair& getCurrentFestival() const; - void setCurrentFestival( uint16_t festivalId ); + void setCurrentFestival( uint16_t festivalId, uint16_t additionalFestivalId = 0 ); virtual bool init();