1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 06:47:45 +00:00

Basic director handling for instances, just the bare minimum so far

This commit is contained in:
Mordred 2018-02-06 00:01:23 +01:00
parent 7a4e72969a
commit 78606873ae
9 changed files with 95 additions and 59 deletions

View file

@ -156,12 +156,6 @@ namespace Common {
uint32_t sourceActorId;
};
enum RegionType : uint8_t
{
normal,
instance,
};
enum CharaLook : uint8_t
{
Race = 0x00,

View file

@ -150,7 +150,7 @@ namespace Packets {
EquipDisplayFlags = 0x01FA, // updated 4.2
CFAvailableContents = 0x01CF,
CFAvailableContents = 0x01FD, // updated 4.2
PrepareZoning = 0x027C, // updated 4.2
ActorGauge = 0x027D, // updated 4.2

View file

@ -1 +1,21 @@
#include "Director.h"
Core::Event::Director::Director( Core::Event::Director::DirectorType type, uint16_t contentId ) :
m_contentId( contentId ),
m_type( type ),
m_directorId( ( static_cast< uint32_t >( type ) << 16 ) | contentId ),
m_sequence( 0 ),
m_branch( 0 )
{
}
uint32_t Core::Event::Director::getDirectorId() const
{
return m_directorId;
}
uint16_t Core::Event::Director::getContentId() const
{
return m_contentId;
}

View file

@ -30,9 +30,17 @@ public:
DpsChallange = 0x800D
};
Director( DirectorType type, uint16_t contentId );
uint32_t getDirectorId() const;
uint16_t getContentId() const;
DirectorType getType() const;
uint8_t getSequence() const;
uint8_t getBranch() const;
private:
/*! Id of the content of the director */
uint16_t m_id;
uint16_t m_contentId;
/*! DirectorType | ContentId */
uint32_t m_directorId;
@ -49,11 +57,6 @@ private:
/*! type of the director */
DirectorType m_type;
uint32_t getDirectorId() const;
uint16_t getContentId() const;
DirectorType getType() const;
uint8_t getSequence() const;
uint8_t getBranch() const;
};

View file

@ -229,6 +229,11 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
{
break;
}
case 0x321: // Director init finish
{
player.getCurrentZone()->onInitDirector( player.getAsPlayer() );
break;
}
default:
{
g_log.debug( "[" + std::to_string( m_pSession->getId() ) + "] Unhandled action: " +

View file

@ -1,24 +1,33 @@
#include "InstanceContent.h"
#include <common/Common.h>
#include <common/Logging/Logger.h>
#include <common/Util/Util.h>
#include <common/Util/UtilMath.h>
#include <servers/sapphire_zone/Event/Director.h>
#include "Actor/Player.h"
#include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h"
extern Core::Logger g_log;
using namespace Core::Common;
using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server;
Core::InstanceContent::InstanceContent( boost::shared_ptr< Core::Data::InstanceContent > pInstanceContent,
uint32_t guId,
const std::string& internalName,
const std::string& contentName,
uint32_t instanceContentId )
: Zone( pInstanceContent->territoryType, guId, internalName, contentName ),
: Zone( static_cast< uint16_t >( pInstanceContent->territoryType ), guId, internalName, contentName ),
Director( Event::Director::InstanceContent, instanceContentId ),
m_instanceContentInfo( pInstanceContent ),
m_instanceContentId( instanceContentId ),
m_state( Created )
{
}
Core::InstanceContent::~InstanceContent()
@ -41,6 +50,10 @@ void Core::InstanceContent::onEnterTerritory( Entity::PlayerPtr pPlayer )
g_log.debug( "InstanceContent::onEnterTerritory: Zone#" + std::to_string( getGuId() ) + "|"
+ std::to_string( getInstanceContentId() ) +
+ ", Entity#" + std::to_string( pPlayer->getId() ) );
pPlayer->queuePacket(ActorControlPacket143( pPlayer->getId(), DirectorInit, getDirectorId(),
getInstanceContentId() ) );
pPlayer->setStateFlag( PlayerStateFlag::BoundByDuty );
}
void Core::InstanceContent::onLeaveTerritory( Entity::PlayerPtr pPlayer )
@ -48,9 +61,21 @@ void Core::InstanceContent::onLeaveTerritory( Entity::PlayerPtr pPlayer )
g_log.debug( "InstanceContent::onLeaveTerritory: Zone#" + std::to_string( getGuId() ) + "|"
+ std::to_string( getInstanceContentId() ) +
+ ", Entity#" + std::to_string( pPlayer->getId() ) );
pPlayer->queuePacket(ActorControlPacket143( pPlayer->getId(), DirectorClear, getDirectorId() ) );
pPlayer->unsetStateFlag( PlayerStateFlag::BoundByDuty );
}
void Core::InstanceContent::onUpdate( uint32_t currTime )
{
}
void Core::InstanceContent::onFinishLoading( Entity::PlayerPtr pPlayer )
{
}
void Core::InstanceContent::onInitDirector( Entity::PlayerPtr pPlayer )
{
}

View file

@ -2,13 +2,14 @@
#define SAPPHIRE_INSTANCECONTENT_H
#include "Zone.h"
#include "Event/Director.h"
#include "Forwards.h"
#include <common/Exd/ExdDataGenerated.h>
namespace Core
{
class InstanceContent : public Zone
class InstanceContent : public Zone, Event::Director
{
public:
enum InstanceContentState
@ -27,8 +28,11 @@ public:
void onEnterTerritory( Entity::PlayerPtr pPlayer ) override;
void onLeaveTerritory( Entity::PlayerPtr pPlayer ) override;
void onFinishLoading( Entity::PlayerPtr pPlayer ) override;
void onInitDirector( Entity::PlayerPtr pPlayer ) override;
void onUpdate( uint32_t currTime ) override;
Core::Data::ExdDataGenerated::InstanceContentPtr getInstanceContentInfo() const;
uint32_t getInstanceContentId() const;

View file

@ -41,20 +41,18 @@ namespace Core {
/**
* \brief
*/
Zone::Zone()
: m_territoryId( 0 )
, m_guId( 0 )
, m_type( Common::RegionType::normal )
, m_currentWeather( static_cast< uint8_t >( Common::Weather::FairSkies ) )
, m_weatherOverride( 0 )
, m_lastMobUpdate( 0 )
, m_currentFestivalId( 0 )
Zone::Zone() :
m_territoryId( 0 ),
m_guId( 0 ),
m_currentWeather( static_cast< uint8_t >( Common::Weather::FairSkies ) ),
m_weatherOverride( 0 ),
m_lastMobUpdate( 0 ),
m_currentFestivalId( 0 )
{
}
Zone::Zone( uint16_t territoryId, uint32_t guId, const std::string& internalName, const std::string& placeName )
: m_type( Common::RegionType::normal )
, m_currentWeather( static_cast< uint8_t >( Common::Weather::FairSkies ) )
Zone::Zone( uint16_t territoryId, uint32_t guId, const std::string& internalName, const std::string& placeName ) :
m_currentWeather( static_cast< uint8_t >( Common::Weather::FairSkies ) )
{
m_guId = guId;
@ -104,11 +102,6 @@ bool Zone::init()
return true;
}
bool Zone::isPrivateZone() const
{
return m_bPrivate;
}
void Zone::setWeatherOverride( uint8_t weather )
{
m_weatherOverride = weather;
@ -179,7 +172,7 @@ void Zone::loadCellCache()
"Look,"
"Models,"
"type "
"FROM battlenpc WHERE ZoneId = " + std::to_string(getTerritoryId() ) + ";" );
"FROM battlenpc WHERE ZoneId = " + std::to_string( getTerritoryId() ) + ";" );
std::vector< Entity::BattleNpcPtr > cache;
@ -395,26 +388,16 @@ void Zone::queueOutPacketForRange( Entity::Player& sourcePlayer, uint32_t range,
}
}
uint32_t Zone::getTerritoryId()
uint32_t Zone::getTerritoryId() const
{
return m_territoryId;
}
Common::RegionType Zone::getType() const
{
return m_type;
}
uint16_t Zone::getGuId() const
uint32_t Zone::getGuId() const
{
return m_guId;
}
bool Zone::isInstance() const
{
return m_type == Common::RegionType::instance;
}
const std::string& Zone::getName() const
{
return m_placeName;
@ -774,8 +757,9 @@ void Zone::updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell )
if( !pOwnPlayer->isLoadingComplete() )
continue;
// this is a hack to limit actor spawn in one packetset
count++;
if( count > 15 )
if( count > 12 )
break;
pActor->addInRangeActor( pCurAct );
@ -829,4 +813,14 @@ void Zone::onUpdate( uint32_t currTime )
}
void Zone::onFinishLoading( Entity::PlayerPtr pPlayer )
{
}
void Zone::onInitDirector( Entity::PlayerPtr pPlayer )
{
}
}

View file

@ -32,8 +32,6 @@ protected:
std::string m_placeName;
std::string m_internalName;
bool m_bPrivate;
std::unordered_map< int32_t, Entity::PlayerPtr > m_playerMap;
std::unordered_map< int32_t, Entity::BattleNpcPtr > m_BattleNpcMap;
std::unordered_map< int32_t, Entity::EventNpcPtr > m_EventNpcMap;
@ -44,8 +42,6 @@ protected:
CellCache** m_pCellCache[_sizeX];
Common::RegionType m_type;
uint8_t m_currentWeather;
uint8_t m_weatherOverride;
@ -64,8 +60,6 @@ public:
bool init();
bool isPrivateZone() const;
/*! overrides the zone's weather, set to 0 to unlock */
void setWeatherOverride( uint8_t weather );
@ -79,8 +73,10 @@ public:
CellCache* getCellCacheAndCreate( uint32_t cellx, uint32_t celly );
virtual void loadCellCache();
virtual uint32_t getTerritoryId();
virtual uint32_t getTerritoryId() const;
virtual void onEnterTerritory( Entity::PlayerPtr pPlayer );
virtual void onFinishLoading( Entity::PlayerPtr pPlayer );
virtual void onInitDirector( Entity::PlayerPtr pPlayer );
virtual void onLeaveTerritory( Entity::PlayerPtr pPlayer );
virtual void onUpdate( uint32_t currTime );
@ -100,14 +96,9 @@ public:
void queueOutPacketForRange( Entity::Player& sourcePlayer, uint32_t range, Network::Packets::GamePacketPtr pPacketEntry );
Common::RegionType getType() const;
uint16_t getGuId() const;
bool isInstance() const;
uint32_t getGuId() const;
const std::string& getName() const;
const std::string& getInternalName() const;
std::size_t getPopCount() const;