1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 14:57:44 +00:00

allow for multiple festivals to run at once

This commit is contained in:
NotAdam 2018-09-01 20:55:28 +10:00
parent 77d59fe664
commit d88efbf30d
8 changed files with 43 additions and 22 deletions

View file

@ -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;
};

View file

@ -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 );
}

View file

@ -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;

View file

@ -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" )
{

View file

@ -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 );
}
}

View file

@ -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 */

View file

@ -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 );
}
}

View file

@ -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();