From e0d6c1024e00d970e9c74c89793a78f8f4fc647e Mon Sep 17 00:00:00 2001 From: NotAdam Date: Fri, 31 Aug 2018 22:57:33 +1000 Subject: [PATCH 1/7] item handin collection & fix quest abandon --- src/common/Network/CommonActorControl.h | 4 +++ .../quest/subquest/gridania/SubFst029.cpp | 17 ++++------ src/servers/sapphire_zone/Actor/Player.h | 7 ++++ .../sapphire_zone/Actor/PlayerInventory.cpp | 34 +++++++++++++++++++ .../Network/Handlers/ClientTriggerHandler.cpp | 4 +++ 5 files changed, 55 insertions(+), 11 deletions(-) diff --git a/src/common/Network/CommonActorControl.h b/src/common/Network/CommonActorControl.h index 3b96f952..2f8775c0 100644 --- a/src/common/Network/CommonActorControl.h +++ b/src/common/Network/CommonActorControl.h @@ -269,6 +269,10 @@ enum ClientTriggerType AchievementComp = 0x203, AchievementCatChat = 0x206, + QuestJournalUpdateQuestVisibility = 0x2BE, + QuestJournalClosed = 0x2BF, + + AbandonQuest = 0x320, DirectorInitFinish = 0x321, diff --git a/src/servers/Scripts/quest/subquest/gridania/SubFst029.cpp b/src/servers/Scripts/quest/subquest/gridania/SubFst029.cpp index b81f82ee..a38eb63e 100644 --- a/src/servers/Scripts/quest/subquest/gridania/SubFst029.cpp +++ b/src/servers/Scripts/quest/subquest/gridania/SubFst029.cpp @@ -36,29 +36,24 @@ private: static constexpr auto Seq1Actor0Npctradeok = 100; public: - SubFst029() : - EventScript( 65708 ) - { - }; + SubFst029() : EventScript( 65708 ) + {}; ~SubFst029() - { - }; + {}; void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override { auto actor = Event::mapEventActorToRealActor( static_cast< uint32_t >( actorId ) ); - //NOT SAFE - CRASH - - /*if( actor == SubFst029::Actor0 && !player.hasQuest( getId() ) ) + if( actor == SubFst029::Actor0 && !player.hasQuest( getId() ) ) { Scene00000( player ); } if( actor == SubFst029::Actor0 && player.getQuestSeq ( getId() ) == 255 ) { Scene00001( player ); - }*/ + } } private: @@ -80,7 +75,7 @@ private: player.playScene( getId(), 1, HIDE_HOTBAR, [ & ]( Entity::Player& player, const Event::SceneResult& result ) { - if( result.param2 == 1 ) + if( result.param2 == 1 && player.collectHandInItems( { Ritem0 } ) ) { Scene00100( player ); } diff --git a/src/servers/sapphire_zone/Actor/Player.h b/src/servers/sapphire_zone/Actor/Player.h index 43376fc7..328cee2a 100644 --- a/src/servers/sapphire_zone/Actor/Player.h +++ b/src/servers/sapphire_zone/Actor/Player.h @@ -360,6 +360,13 @@ public: /*! return the current amount of crystals of type */ uint32_t getCrystal( uint8_t type ) const; + /*! + * Collect real item handins from container + * @param itemIds a vector of each catalog id to collect + * @return true if all items were handed in + */ + bool collectHandInItems( std::vector< uint32_t > itemIds ); + // Class / Job / Exp ////////////////////////////////////////////////////////////////////////////////////////////////////// /*! returns the level of the currently active class / job */ diff --git a/src/servers/sapphire_zone/Actor/PlayerInventory.cpp b/src/servers/sapphire_zone/Actor/PlayerInventory.cpp index 52d7f943..07a95123 100644 --- a/src/servers/sapphire_zone/Actor/PlayerInventory.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerInventory.cpp @@ -781,3 +781,37 @@ uint8_t Core::Entity::Player::getFreeSlotsInBags() } return slots; } + +bool Core::Entity::Player::collectHandInItems( std::vector< uint32_t > itemIds ) +{ + // todo: figure out how the game gets the required stack count + auto& container = m_storageMap[HandIn]; + + std::vector< uint8_t > foundItems; + + auto itemMap = container->getItemMap(); + + for( auto& item : itemMap ) + { + for( auto needle : itemIds ) + { + if( item.second->getId() == needle ) + { + foundItems.push_back( item.first ); + break; + } + } + } + + // couldn't find all the items required + if( foundItems.size() != itemIds.size() ) + return false; + + // remove items + for( auto item : foundItems ) + { + container->removeItem( item ); + } + + return true; +} diff --git a/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp b/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp index 3282d68d..84406000 100644 --- a/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp @@ -256,6 +256,10 @@ void Core::Network::GameConnection::clientTriggerHandler( const Packets::FFXIVAR player.exitInstance(); break; } + case ClientTriggerType::AbandonQuest: + { + player.removeQuest( static_cast< uint16_t >( param1 ) ); + } default: From 23344c02e6e110a36200b0c8b01175de6fa6f66b Mon Sep 17 00:00:00 2001 From: NotAdam Date: Fri, 31 Aug 2018 23:02:45 +1000 Subject: [PATCH 2/7] incredible --- .../sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp b/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp index 84406000..14d2e611 100644 --- a/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp @@ -259,6 +259,7 @@ void Core::Network::GameConnection::clientTriggerHandler( const Packets::FFXIVAR case ClientTriggerType::AbandonQuest: { player.removeQuest( static_cast< uint16_t >( param1 ) ); + break; } From 8b00fe6012f8e83050350e1d1b1897706ad9e768 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Fri, 31 Aug 2018 23:25:53 +1000 Subject: [PATCH 3/7] sql cleanup/improvements, add some fields for durability/stain --- src/common/Database/CharaDbConnection.cpp | 8 +++++++ src/common/Database/CharaDbConnection.h | 2 ++ .../sapphire_zone/Actor/PlayerInventory.cpp | 21 +++++++++++++------ src/servers/sapphire_zone/Inventory/Item.cpp | 20 ++++++++++++++++++ src/servers/sapphire_zone/Inventory/Item.h | 8 +++++++ 5 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/common/Database/CharaDbConnection.cpp b/src/common/Database/CharaDbConnection.cpp index c8076af1..f89c61df 100644 --- a/src/common/Database/CharaDbConnection.cpp +++ b/src/common/Database/CharaDbConnection.cpp @@ -175,5 +175,13 @@ void Core::Db::CharaDbConnection::doPrepareStatements() "INSERT INTO charaglobalitem ( CharacterId, ItemId, catalogId, UPDATE_DATE ) VALUES ( ?, ?, ?, NOW() );", CONNECTION_BOTH ); + prepareStatement( CHARA_ITEMGLOBAL_UP, + "UPDATE charaglobalitem SET stack = ?, durability = ?, stain = ? WHERE ItemId = ?;", + CONNECTION_BOTH ); + + prepareStatement( CHARA_ITEMGLOBAL_DELETE, + "UPDATE charaglobalitem SET IS_DELETE = 1 WHERE ItemId = ?;", + CONNECTION_BOTH ); + } diff --git a/src/common/Database/CharaDbConnection.h b/src/common/Database/CharaDbConnection.h index d595158d..5a6a1f94 100644 --- a/src/common/Database/CharaDbConnection.h +++ b/src/common/Database/CharaDbConnection.h @@ -74,6 +74,8 @@ enum CharaDbStatements : CHARA_ITEMINV_INS, CHARA_ITEMGLOBAL_INS, + CHARA_ITEMGLOBAL_UP, + CHARA_ITEMGLOBAL_DELETE, MAX_STATEMENTS }; diff --git a/src/servers/sapphire_zone/Actor/PlayerInventory.cpp b/src/servers/sapphire_zone/Actor/PlayerInventory.cpp index 07a95123..09430f79 100644 --- a/src/servers/sapphire_zone/Actor/PlayerInventory.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerInventory.cpp @@ -428,15 +428,26 @@ void Core::Entity::Player::writeInventory( InventoryType type ) void Core::Entity::Player::writeItem( Core::ItemPtr pItem ) const { auto pDb = g_fw.get< Db::DbWorkerPool< Db::CharaDbConnection > >(); - pDb->execute( "UPDATE charaglobalitem SET stack = " + std::to_string( pItem->getStackSize() ) + " " + - // TODO: add other attributes - " WHERE itemId = " + std::to_string( pItem->getUId() ) ); + auto stmt = pDb->getPreparedStatement( Db::CHARA_ITEMGLOBAL_UP ); + + // todo: add more fields + stmt->setInt( 1, pItem->getStackSize() ); + stmt->setInt( 2, pItem->getDurability() ); + stmt->setInt( 3, pItem->getStain() ); + + stmt->setInt64( 4, pItem->getUId() ); + + pDb->directExecute( stmt ); } void Core::Entity::Player::deleteItemDb( Core::ItemPtr item ) const { auto pDb = g_fw.get< Db::DbWorkerPool< Db::CharaDbConnection > >(); - pDb->execute( "UPDATE charaglobalitem SET IS_DELETE = 1 WHERE itemId = " + std::to_string( item->getUId() ) ); + auto stmt = pDb->getPreparedStatement( Db::CHARA_ITEMGLOBAL_DELETE ); + + stmt->setInt64( 1, item->getUId() ); + + pDb->directExecute( stmt ); } @@ -464,8 +475,6 @@ Core::ItemPtr Core::Entity::Player::addItem( uint32_t catalogId, uint32_t quanti // used for item obtain notification uint32_t originalQuantity = quantity; - // todo: for now we're just going to add any items to main inv - std::pair< uint16_t, uint8_t > freeBagSlot; bool foundFreeSlot = false; diff --git a/src/servers/sapphire_zone/Inventory/Item.cpp b/src/servers/sapphire_zone/Inventory/Item.cpp index 08601604..97802d6f 100644 --- a/src/servers/sapphire_zone/Inventory/Item.cpp +++ b/src/servers/sapphire_zone/Inventory/Item.cpp @@ -132,3 +132,23 @@ uint32_t Core::Item::getMaxStackSize() const { return m_maxStackSize; } + +uint16_t Core::Item::getDurability() const +{ + return m_durability; +} + +void Core::Item::setDurability( uint16_t durability ) +{ + m_durability = durability; +} + +uint16_t Core::Item::getStain() const +{ + return m_stain; +} + +void Core::Item::setStain( uint16_t stain ) +{ + m_stain = stain; +} diff --git a/src/servers/sapphire_zone/Inventory/Item.h b/src/servers/sapphire_zone/Inventory/Item.h index 1f30fbf0..ba6c56c5 100644 --- a/src/servers/sapphire_zone/Inventory/Item.h +++ b/src/servers/sapphire_zone/Inventory/Item.h @@ -55,6 +55,12 @@ public: uint32_t getMaxStackSize() const; + uint16_t getDurability() const; + void setDurability( uint16_t durability ); + + uint16_t getStain() const; + void setStain( uint16_t stain ); + protected: uint32_t m_id; @@ -78,6 +84,8 @@ protected: uint16_t m_weaponDmg; float m_autoAttackDmg; uint16_t m_itemLevel; + uint16_t m_durability; + uint16_t m_stain; }; From 24c3c92b7f24916bcfd84948cedceeccd431773c Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sat, 1 Sep 2018 00:00:19 +1000 Subject: [PATCH 4/7] send stain/durability --- src/common/Network/PacketDef/Zone/ServerZoneDef.h | 2 +- src/servers/sapphire_zone/Actor/PlayerInventory.cpp | 3 ++- src/servers/sapphire_zone/Inventory/Item.cpp | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/common/Network/PacketDef/Zone/ServerZoneDef.h b/src/common/Network/PacketDef/Zone/ServerZoneDef.h index c894fdf1..c6b5f854 100644 --- a/src/common/Network/PacketDef/Zone/ServerZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ServerZoneDef.h @@ -969,7 +969,7 @@ struct FFXIVIpcItemInfo : uint8_t unknown2; uint16_t condition; uint16_t spiritBond; - uint16_t color; + uint16_t stain; uint32_t glamourCatalogId; uint16_t materia1; uint16_t materia2; diff --git a/src/servers/sapphire_zone/Actor/PlayerInventory.cpp b/src/servers/sapphire_zone/Actor/PlayerInventory.cpp index 09430f79..4f0aaf0f 100644 --- a/src/servers/sapphire_zone/Actor/PlayerInventory.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerInventory.cpp @@ -318,9 +318,10 @@ void Core::Entity::Player::sendInventory() itemInfoPacket->data().slot = itM->first; itemInfoPacket->data().quantity = itM->second->getStackSize(); itemInfoPacket->data().catalogId = itM->second->getId(); - itemInfoPacket->data().condition = 30000; + itemInfoPacket->data().condition = itM->second->getDurability(); itemInfoPacket->data().spiritBond = 0; itemInfoPacket->data().hqFlag = itM->second->isHq() ? 1 : 0; + itemInfoPacket->data().stain = itM->second->getStain(); queuePacket( itemInfoPacket ); } } diff --git a/src/servers/sapphire_zone/Inventory/Item.cpp b/src/servers/sapphire_zone/Inventory/Item.cpp index 97802d6f..6537aae1 100644 --- a/src/servers/sapphire_zone/Inventory/Item.cpp +++ b/src/servers/sapphire_zone/Inventory/Item.cpp @@ -12,7 +12,9 @@ Core::Item::Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t mo m_uId( uId ), m_model1( model1 ), m_model2( model2 ), - m_isHq( isHq ) + m_isHq( isHq ), + m_stain( 0 ), + m_durability( 30000 ) { auto pExdData = g_fw.get< Data::ExdDataGenerated >(); auto itemInfo = pExdData->get< Core::Data::Item >( catalogId ); From 77d59fe664d11840384289c2e86bcfdacaff5b5d Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sat, 1 Sep 2018 14:36:04 +1000 Subject: [PATCH 5/7] fix msvc builds? --- src/servers/Scripts/quest/subquest/gridania/SubFst029.cpp | 2 +- src/servers/sapphire_zone/Actor/PlayerInventory.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/servers/Scripts/quest/subquest/gridania/SubFst029.cpp b/src/servers/Scripts/quest/subquest/gridania/SubFst029.cpp index a38eb63e..fc94b032 100644 --- a/src/servers/Scripts/quest/subquest/gridania/SubFst029.cpp +++ b/src/servers/Scripts/quest/subquest/gridania/SubFst029.cpp @@ -75,7 +75,7 @@ private: player.playScene( getId(), 1, HIDE_HOTBAR, [ & ]( Entity::Player& player, const Event::SceneResult& result ) { - if( result.param2 == 1 && player.collectHandInItems( { Ritem0 } ) ) + if( result.param2 == 1 && player.collectHandInItems( { uint32_t{ Ritem0 } } ) ) { Scene00100( player ); } diff --git a/src/servers/sapphire_zone/Actor/PlayerInventory.cpp b/src/servers/sapphire_zone/Actor/PlayerInventory.cpp index 4f0aaf0f..eae0113a 100644 --- a/src/servers/sapphire_zone/Actor/PlayerInventory.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerInventory.cpp @@ -795,7 +795,7 @@ uint8_t Core::Entity::Player::getFreeSlotsInBags() bool Core::Entity::Player::collectHandInItems( std::vector< uint32_t > itemIds ) { // todo: figure out how the game gets the required stack count - auto& container = m_storageMap[HandIn]; + const auto& container = m_storageMap[ HandIn ]; std::vector< uint8_t > foundItems; From d88efbf30da02bf410f27f091d5bafc4e75909d1 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sat, 1 Sep 2018 20:55:28 +1000 Subject: [PATCH 6/7] 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(); From 0cffd5460643976fe9023bc8dc379a7b536391c9 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sat, 1 Sep 2018 21:34:48 +1000 Subject: [PATCH 7/7] cleanup old festival vars --- src/servers/sapphire_zone/Zone/Zone.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/servers/sapphire_zone/Zone/Zone.h b/src/servers/sapphire_zone/Zone/Zone.h index 447cd10a..43435a68 100644 --- a/src/servers/sapphire_zone/Zone/Zone.h +++ b/src/servers/sapphire_zone/Zone/Zone.h @@ -51,9 +51,7 @@ 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;