1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-01 08:27:46 +00:00

proper festival handling (woah)

This commit is contained in:
Adam 2018-03-20 20:30:05 +11:00
parent d95aaba887
commit d7006574ac
6 changed files with 49 additions and 18 deletions

View file

@ -582,7 +582,7 @@ namespace Common {
GearSetEquipMsg = 0x321,
DisableCurrentFestival = 0x386,
SetFestival = 0x386, // param1: festival.exd index
ToggleOrchestrionUnlock = 0x396,
Dismount = 0x3A0,

View file

@ -16,7 +16,6 @@
#include "Action/EventAction.h"
#include "Action/EventItemAction.h"
#include "Event/EventHandler.h"
#include "Event/EventHandler.h"
#include "Zone/Zone.h"

View file

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

View file

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

View file

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

View file

@ -12,6 +12,7 @@
#include <Network/PacketDef/Zone/ServerZoneDef.h>
#include <Network/PacketContainer.h>
#include <Database/DatabaseDef.h>
#include <Network/PacketWrappers/ActorControlPacket143.h>
#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()
{