mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-25 05:57:45 +00:00
Another big batch of refactoring for readability.
This commit is contained in:
parent
4bee448f4b
commit
859f2329bb
21 changed files with 509 additions and 569 deletions
|
@ -518,7 +518,7 @@ void Action::Action::buildEffects()
|
|||
return;
|
||||
}
|
||||
|
||||
Network::Util::Packet::sendHudParam( *m_pSource->getAsPlayer() );
|
||||
Network::Util::Packet::sendHudParam( *m_pSource );
|
||||
|
||||
if( !hasLutEntry || m_hitActors.empty() )
|
||||
{
|
||||
|
|
|
@ -43,19 +43,19 @@
|
|||
#include <Task/ActionIntegrityTask.h>
|
||||
#include <Service.h>
|
||||
|
||||
using namespace Sapphire;
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire::Entity;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
using namespace Sapphire::Network::Packets::WorldPackets::Server;
|
||||
using namespace Sapphire::Network::ActorControl;
|
||||
using namespace Sapphire::World::Manager;
|
||||
|
||||
Sapphire::Entity::BNpc::BNpc() :
|
||||
Npc( ObjKind::BattleNpc )
|
||||
BNpc::BNpc() : Npc( ObjKind::BattleNpc )
|
||||
{
|
||||
}
|
||||
|
||||
Sapphire::Entity::BNpc::BNpc( uint32_t id, std::shared_ptr< Common::BNPCInstanceObject > pInfo, const Territory& zone ) :
|
||||
Npc( ObjKind::BattleNpc )
|
||||
BNpc::BNpc( uint32_t id, std::shared_ptr< Common::BNPCInstanceObject > pInfo, const Territory& zone ) : Npc( ObjKind::BattleNpc )
|
||||
{
|
||||
m_id = id;
|
||||
m_pInfo = pInfo;
|
||||
|
@ -167,7 +167,7 @@ Sapphire::Entity::BNpc::BNpc( uint32_t id, std::shared_ptr< Common::BNPCInstance
|
|||
|
||||
}
|
||||
|
||||
Sapphire::Entity::BNpc::BNpc( uint32_t id, std::shared_ptr< Common::BNPCInstanceObject > pInfo, const Territory& zone, uint32_t hp, Common::BNpcType type ) :
|
||||
BNpc::BNpc( uint32_t id, std::shared_ptr< Common::BNPCInstanceObject > pInfo, const Territory& zone, uint32_t hp, Common::BNpcType type ) :
|
||||
Npc( ObjKind::BattleNpc )
|
||||
{
|
||||
m_id = id;
|
||||
|
@ -269,54 +269,54 @@ Sapphire::Entity::BNpc::BNpc( uint32_t id, std::shared_ptr< Common::BNPCInstance
|
|||
calculateStats();
|
||||
}
|
||||
|
||||
Sapphire::Entity::BNpc::~BNpc() = default;
|
||||
BNpc::~BNpc() = default;
|
||||
|
||||
uint8_t Sapphire::Entity::BNpc::getAggressionMode() const
|
||||
uint8_t BNpc::getAggressionMode() const
|
||||
{
|
||||
return m_aggressionMode;
|
||||
}
|
||||
|
||||
float Sapphire::Entity::BNpc::getNaviTargetReachedDistance() const
|
||||
float BNpc::getNaviTargetReachedDistance() const
|
||||
{
|
||||
return m_naviTargetReachedDistance;
|
||||
}
|
||||
|
||||
uint8_t Sapphire::Entity::BNpc::getEnemyType() const
|
||||
uint8_t BNpc::getEnemyType() const
|
||||
{
|
||||
return m_enemyType;
|
||||
}
|
||||
|
||||
uint64_t Sapphire::Entity::BNpc::getWeaponMain() const
|
||||
uint64_t BNpc::getWeaponMain() const
|
||||
{
|
||||
return m_weaponMain;
|
||||
}
|
||||
|
||||
uint64_t Sapphire::Entity::BNpc::getWeaponSub() const
|
||||
uint64_t BNpc::getWeaponSub() const
|
||||
{
|
||||
return m_weaponSub;
|
||||
}
|
||||
|
||||
uint16_t Sapphire::Entity::BNpc::getModelChara() const
|
||||
uint16_t BNpc::getModelChara() const
|
||||
{
|
||||
return m_modelChara;
|
||||
}
|
||||
|
||||
uint8_t Sapphire::Entity::BNpc::getLevel() const
|
||||
uint8_t BNpc::getLevel() const
|
||||
{
|
||||
return m_level;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::BNpc::getBNpcBaseId() const
|
||||
uint32_t BNpc::getBNpcBaseId() const
|
||||
{
|
||||
return m_bNpcBaseId;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::BNpc::getBNpcNameId() const
|
||||
uint32_t BNpc::getBNpcNameId() const
|
||||
{
|
||||
return m_bNpcNameId;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::spawn( PlayerPtr pTarget )
|
||||
void BNpc::spawn( PlayerPtr pTarget )
|
||||
{
|
||||
m_lastRoamTargetReached = Util::getTimeSeconds();
|
||||
|
||||
|
@ -324,26 +324,23 @@ void Sapphire::Entity::BNpc::spawn( PlayerPtr pTarget )
|
|||
server.queueForPlayer( pTarget->getCharacterId(), std::make_shared< NpcSpawnPacket >( *this, *pTarget ) );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::despawn( PlayerPtr pTarget )
|
||||
void BNpc::despawn( PlayerPtr pTarget )
|
||||
{
|
||||
pTarget->freePlayerSpawnId( getId() );
|
||||
|
||||
auto& server = Common::Service< World::WorldServer >::ref();
|
||||
|
||||
server.queueForPlayer( pTarget->getCharacterId(), makeActorControlSelf( m_id, WarpStart, 0x04, getId(), 0x01 ) );
|
||||
Network::Util::Packet::sendActorControl( *pTarget, WarpStart, 4, getId(), 1 );
|
||||
}
|
||||
|
||||
Sapphire::Entity::BNpcState Sapphire::Entity::BNpc::getState() const
|
||||
BNpcState BNpc::getState() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::setState( BNpcState state )
|
||||
void BNpc::setState( BNpcState state )
|
||||
{
|
||||
m_state = state;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::BNpc::moveTo( const FFXIVARR_POSITION3& pos )
|
||||
bool BNpc::moveTo( const FFXIVARR_POSITION3& pos )
|
||||
{
|
||||
auto& teriMgr = Common::Service< World::Manager::TerritoryMgr >::ref();
|
||||
auto pZone = teriMgr.getTerritoryByGuId( getTerritoryId() );
|
||||
|
@ -380,7 +377,7 @@ bool Sapphire::Entity::BNpc::moveTo( const FFXIVARR_POSITION3& pos )
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::BNpc::moveTo( const Entity::Chara& targetChara )
|
||||
bool BNpc::moveTo( const Chara& targetChara )
|
||||
{
|
||||
|
||||
auto& teriMgr = Common::Service< World::Manager::TerritoryMgr >::ref();
|
||||
|
@ -418,7 +415,7 @@ bool Sapphire::Entity::BNpc::moveTo( const Entity::Chara& targetChara )
|
|||
return false;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::sendPositionUpdate()
|
||||
void BNpc::sendPositionUpdate()
|
||||
{
|
||||
uint8_t animationType = 2;
|
||||
|
||||
|
@ -429,7 +426,7 @@ void Sapphire::Entity::BNpc::sendPositionUpdate()
|
|||
server().queueForPlayers( getInRangePlayerIds(), movePacket );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::hateListClear()
|
||||
void BNpc::hateListClear()
|
||||
{
|
||||
for( auto& listEntry : m_hateList )
|
||||
{
|
||||
|
@ -439,7 +436,7 @@ void Sapphire::Entity::BNpc::hateListClear()
|
|||
m_hateList.clear();
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::BNpc::hateListGetValue( const Sapphire::Entity::CharaPtr& pChara )
|
||||
uint32_t BNpc::hateListGetValue( const Sapphire::Entity::CharaPtr& pChara )
|
||||
{
|
||||
for( const auto& listEntry : m_hateList )
|
||||
{
|
||||
|
@ -452,7 +449,7 @@ uint32_t Sapphire::Entity::BNpc::hateListGetValue( const Sapphire::Entity::Chara
|
|||
return 0;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::BNpc::hateListGetHighestValue()
|
||||
uint32_t BNpc::hateListGetHighestValue()
|
||||
{
|
||||
auto it = m_hateList.begin();
|
||||
uint32_t maxHate = 0;
|
||||
|
@ -473,7 +470,7 @@ uint32_t Sapphire::Entity::BNpc::hateListGetHighestValue()
|
|||
}
|
||||
|
||||
|
||||
Sapphire::Entity::CharaPtr Sapphire::Entity::BNpc::hateListGetHighest()
|
||||
CharaPtr BNpc::hateListGetHighest()
|
||||
{
|
||||
auto it = m_hateList.begin();
|
||||
uint32_t maxHate = 0;
|
||||
|
@ -493,7 +490,7 @@ Sapphire::Entity::CharaPtr Sapphire::Entity::BNpc::hateListGetHighest()
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::hateListAdd( const Sapphire::Entity::CharaPtr& pChara, int32_t hateAmount )
|
||||
void BNpc::hateListAdd( const CharaPtr& pChara, int32_t hateAmount )
|
||||
{
|
||||
auto hateEntry = std::make_shared< HateListEntry >();
|
||||
hateEntry->m_hateAmount = static_cast< uint32_t >( hateAmount );
|
||||
|
@ -507,14 +504,14 @@ void Sapphire::Entity::BNpc::hateListAdd( const Sapphire::Entity::CharaPtr& pCha
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::hateListAddDelayed( const Sapphire::Entity::CharaPtr& pChara, int32_t hateAmount )
|
||||
void BNpc::hateListAddDelayed( const CharaPtr& pChara, int32_t hateAmount )
|
||||
{
|
||||
auto& taskMgr = Common::Service< World::Manager::TaskMgr >::ref();
|
||||
auto delayedEmnityTask = std::make_shared< Sapphire::World::DelayedEmnityTask >( 5000, getAsBNpc(), pChara, hateAmount );
|
||||
auto delayedEmnityTask = std::make_shared< World::DelayedEmnityTask >( 5000, getAsBNpc(), pChara, hateAmount );
|
||||
taskMgr.queueTask( delayedEmnityTask );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::hateListUpdate( const Sapphire::Entity::CharaPtr& pChara, int32_t hateAmount )
|
||||
void BNpc::hateListUpdate( const CharaPtr& pChara, int32_t hateAmount )
|
||||
{
|
||||
bool hasEntry = false;
|
||||
|
||||
|
@ -547,7 +544,7 @@ void Sapphire::Entity::BNpc::hateListUpdate( const Sapphire::Entity::CharaPtr& p
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::hateListRemove( const Sapphire::Entity::CharaPtr& pChara )
|
||||
void BNpc::hateListRemove( const CharaPtr& pChara )
|
||||
{
|
||||
for( const auto& listEntry : m_hateList )
|
||||
{
|
||||
|
@ -565,23 +562,23 @@ void Sapphire::Entity::BNpc::hateListRemove( const Sapphire::Entity::CharaPtr& p
|
|||
}
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::BNpc::getTriggerOwnerId() const
|
||||
uint32_t BNpc::getTriggerOwnerId() const
|
||||
{
|
||||
return m_triggerOwnerId;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::setTriggerOwnerId( uint32_t triggerOwnerId )
|
||||
void BNpc::setTriggerOwnerId( uint32_t triggerOwnerId )
|
||||
{
|
||||
m_triggerOwnerId = triggerOwnerId;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::BNpc::hateListHasActor( const Sapphire::Entity::CharaPtr& pChara )
|
||||
bool BNpc::hateListHasActor( const Sapphire::Entity::CharaPtr& pChara )
|
||||
{
|
||||
return std::any_of( m_hateList.begin(), m_hateList.end(),
|
||||
[ pChara ]( const auto& entry ) { return entry->m_pChara == pChara; } );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::aggro( const Sapphire::Entity::CharaPtr& pChara )
|
||||
void BNpc::aggro( const Sapphire::Entity::CharaPtr& pChara )
|
||||
{
|
||||
auto& pRNGMgr = Common::Service< World::Manager::RNGMgr >::ref();
|
||||
auto variation = static_cast< uint32_t >( pRNGMgr.getRandGenerator< float >( 500, 1000 ).next() );
|
||||
|
@ -591,7 +588,7 @@ void Sapphire::Entity::BNpc::aggro( const Sapphire::Entity::CharaPtr& pChara )
|
|||
setStance( Stance::Active );
|
||||
m_state = BNpcState::Combat;
|
||||
|
||||
server().queueForPlayers( getInRangePlayerIds(), makeActorControl( getId(), ActorControlType::SetBattle, 1, 0, 0 ) );
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds(), getId(), SetBattle, 1 );
|
||||
|
||||
changeTarget( pChara->getId() );
|
||||
|
||||
|
@ -603,7 +600,7 @@ void Sapphire::Entity::BNpc::aggro( const Sapphire::Entity::CharaPtr& pChara )
|
|||
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::deaggro( const Sapphire::Entity::CharaPtr& pChara )
|
||||
void BNpc::deaggro( const CharaPtr& pChara )
|
||||
{
|
||||
if( !hateListHasActor( pChara ) )
|
||||
hateListRemove( pChara );
|
||||
|
@ -611,8 +608,8 @@ void Sapphire::Entity::BNpc::deaggro( const Sapphire::Entity::CharaPtr& pChara )
|
|||
if( pChara->isPlayer() )
|
||||
{
|
||||
PlayerPtr tmpPlayer = pChara->getAsPlayer();
|
||||
server().queueForPlayers( getInRangePlayerIds(), makeActorControl( getId(), ActorControlType::ToggleWeapon, 0, 1, 1 ) );
|
||||
server().queueForPlayers( getInRangePlayerIds(), makeActorControl( getId(), ActorControlType::SetBattle, 0, 0, 0 ) );
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds(), getId(), ToggleWeapon, 0, 1, 1 );
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds(), getId(), SetBattle );
|
||||
tmpPlayer->onMobDeaggro( *this );
|
||||
|
||||
if( getTriggerOwnerId() == pChara->getId() )
|
||||
|
@ -624,7 +621,7 @@ void Sapphire::Entity::BNpc::deaggro( const Sapphire::Entity::CharaPtr& pChara )
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::onTick()
|
||||
void BNpc::onTick()
|
||||
{
|
||||
Chara::onTick();
|
||||
if( m_state == BNpcState::Retreat )
|
||||
|
@ -633,7 +630,7 @@ void Sapphire::Entity::BNpc::onTick()
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::update( uint64_t tickCount )
|
||||
void BNpc::update( uint64_t tickCount )
|
||||
{
|
||||
auto& teriMgr = Common::Service< World::Manager::TerritoryMgr >::ref();
|
||||
auto pZone = teriMgr.getTerritoryByGuId( getTerritoryId() );
|
||||
|
@ -794,7 +791,7 @@ void Sapphire::Entity::BNpc::update( uint64_t tickCount )
|
|||
Chara::update( tickCount );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::restHp()
|
||||
void BNpc::restHp()
|
||||
{
|
||||
if( m_hp < getMaxHp() )
|
||||
{
|
||||
|
@ -809,7 +806,7 @@ void Sapphire::Entity::BNpc::restHp()
|
|||
sendHudParam();
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::onActionHostile( Sapphire::Entity::CharaPtr pSource )
|
||||
void BNpc::onActionHostile( CharaPtr pSource )
|
||||
{
|
||||
if( !hateListGetHighest() )
|
||||
aggro( pSource );
|
||||
|
@ -820,7 +817,7 @@ void Sapphire::Entity::BNpc::onActionHostile( Sapphire::Entity::CharaPtr pSource
|
|||
setOwner( pSource );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::onDeath()
|
||||
void BNpc::onDeath()
|
||||
{
|
||||
auto& playerMgr = Common::Service< World::Manager::PlayerMgr >::ref();
|
||||
auto& taskMgr = Common::Service< World::Manager::TaskMgr >::ref();
|
||||
|
@ -851,17 +848,17 @@ void Sapphire::Entity::BNpc::onDeath()
|
|||
hateListClear();
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::BNpc::getTimeOfDeath() const
|
||||
uint32_t BNpc::getTimeOfDeath() const
|
||||
{
|
||||
return m_timeOfDeath;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::setTimeOfDeath( uint32_t timeOfDeath )
|
||||
void BNpc::setTimeOfDeath( uint32_t timeOfDeath )
|
||||
{
|
||||
m_timeOfDeath = timeOfDeath;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::checkAggro()
|
||||
void BNpc::checkAggro()
|
||||
{
|
||||
// passive mobs should ignore players unless aggro'd
|
||||
if( m_aggressionMode == 1 )
|
||||
|
@ -925,7 +922,7 @@ void Sapphire::Entity::BNpc::checkAggro()
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::setOwner( const Sapphire::Entity::CharaPtr& m_pChara )
|
||||
void BNpc::setOwner( const CharaPtr& m_pChara )
|
||||
{
|
||||
m_pOwner = m_pChara;
|
||||
auto targetId = static_cast< uint32_t >( INVALID_GAME_OBJECT_ID );
|
||||
|
@ -937,35 +934,32 @@ void Sapphire::Entity::BNpc::setOwner( const Sapphire::Entity::CharaPtr& m_pChar
|
|||
setOwnerPacket->data().Id = targetId;
|
||||
server().queueForPlayers( getInRangePlayerIds(), setOwnerPacket );
|
||||
|
||||
if( m_pChara != nullptr && m_pChara->isPlayer() )
|
||||
{
|
||||
auto letter = makeActorControl( getId(), ActorControlType::SetHateLetter, 1, getId(), 0 );
|
||||
server().queueForPlayer( m_pChara->getAsPlayer()->getCharacterId(), letter );
|
||||
}
|
||||
if( m_pChara && m_pChara->isPlayer() )
|
||||
Network::Util::Packet::sendActorControl( *m_pChara->getAsPlayer(), SetHateLetter, 1, getId(), 0 );
|
||||
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::setLevelId( uint32_t levelId )
|
||||
void BNpc::setLevelId( uint32_t levelId )
|
||||
{
|
||||
m_levelId = levelId;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::BNpc::getLevelId() const
|
||||
uint32_t BNpc::getLevelId() const
|
||||
{
|
||||
return m_levelId;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::BNpc::hasFlag( uint32_t flag ) const
|
||||
bool BNpc::hasFlag( uint32_t flag ) const
|
||||
{
|
||||
return m_flags & flag;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::setFlag( uint32_t flag )
|
||||
void BNpc::setFlag( uint32_t flag )
|
||||
{
|
||||
m_flags |= flag;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::autoAttack( CharaPtr pTarget )
|
||||
void BNpc::autoAttack( CharaPtr pTarget )
|
||||
{
|
||||
auto& teriMgr = Common::Service< World::Manager::TerritoryMgr >::ref();
|
||||
auto pZone = teriMgr.getTerritoryByGuId( getTerritoryId() );
|
||||
|
@ -1001,7 +995,7 @@ void Sapphire::Entity::BNpc::autoAttack( CharaPtr pTarget )
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::calculateStats()
|
||||
void BNpc::calculateStats()
|
||||
{
|
||||
auto level = getLevel();
|
||||
auto job = static_cast< uint8_t >( getClass() );
|
||||
|
@ -1044,28 +1038,28 @@ void Sapphire::Entity::BNpc::calculateStats()
|
|||
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::BNpc::getRank() const
|
||||
uint32_t BNpc::getRank() const
|
||||
{
|
||||
return m_rank;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::BNpc::getBoundInstanceId() const
|
||||
uint32_t BNpc::getBoundInstanceId() const
|
||||
{
|
||||
return m_boundInstanceId;
|
||||
}
|
||||
|
||||
BNpcType Sapphire::Entity::BNpc::getBNpcType() const
|
||||
BNpcType BNpc::getBNpcType() const
|
||||
{
|
||||
return m_bnpcType;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::BNpc::getLayoutId() const
|
||||
uint32_t BNpc::getLayoutId() const
|
||||
{
|
||||
return m_layoutId;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::init()
|
||||
void BNpc::init()
|
||||
{
|
||||
m_maxHp = Sapphire::Math::CalcStats::calculateMaxHp( *getAsChara() );
|
||||
m_maxHp = Math::CalcStats::calculateMaxHp( *getAsChara() );
|
||||
m_hp = m_maxHp;
|
||||
}
|
||||
|
|
|
@ -13,11 +13,10 @@
|
|||
#include "Network/GameConnection.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket.h"
|
||||
#include "Network/PacketWrappers/ActorControlTargetPacket.h"
|
||||
#include "Network/PacketWrappers/RestingPacket.h"
|
||||
#include "Network/PacketWrappers/EffectPacket1.h"
|
||||
#include "Network/PacketWrappers/HudParamPacket.h"
|
||||
#include "Network/Util/PacketUtil.h"
|
||||
|
||||
#include "StatusEffect/StatusEffect.h"
|
||||
#include "Action/Action.h"
|
||||
#include "WorldServer.h"
|
||||
#include "Session.h"
|
||||
|
@ -28,13 +27,16 @@
|
|||
#include "Manager/MgrUtil.h"
|
||||
#include "Common.h"
|
||||
|
||||
using namespace Sapphire;
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire::Entity;
|
||||
using namespace Sapphire::World;
|
||||
using namespace Sapphire::World::Manager;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
using namespace Sapphire::Network::Packets::WorldPackets::Server;
|
||||
using namespace Sapphire::Network::ActorControl;
|
||||
|
||||
Sapphire::Entity::Chara::Chara( ObjKind type ) :
|
||||
Chara::Chara( ObjKind type ) :
|
||||
GameObject( type ),
|
||||
m_pose( 0 ),
|
||||
m_targetId( INVALID_GAME_OBJECT_ID64 ),
|
||||
|
@ -44,7 +46,7 @@ Sapphire::Entity::Chara::Chara( ObjKind type ) :
|
|||
|
||||
m_lastTickTime = 0;
|
||||
m_lastUpdate = 0;
|
||||
m_lastAttack = Util::getTimeMs();
|
||||
m_lastAttack = Common::Util::getTimeMs();
|
||||
|
||||
m_bonusStats.fill( 0 );
|
||||
|
||||
|
@ -55,76 +57,75 @@ Sapphire::Entity::Chara::Chara( ObjKind type ) :
|
|||
}
|
||||
}
|
||||
|
||||
Sapphire::Entity::Chara::~Chara()
|
||||
= default;
|
||||
Chara::~Chara() = default;
|
||||
|
||||
/*! \return the actors name */
|
||||
std::string Sapphire::Entity::Chara::getName() const
|
||||
std::string Chara::getName() const
|
||||
{
|
||||
return { m_name };
|
||||
}
|
||||
|
||||
|
||||
/*! \return current stance of the actors */
|
||||
Sapphire::Common::Stance Sapphire::Entity::Chara::getStance() const
|
||||
Stance Chara::getStance() const
|
||||
{
|
||||
return m_currentStance;
|
||||
}
|
||||
|
||||
/*! \return actor stats */
|
||||
const Sapphire::Entity::Chara::ActorStatsArray& Sapphire::Entity::Chara::getStats() const
|
||||
const Chara::ActorStatsArray& Chara::getStats() const
|
||||
{
|
||||
return m_baseStats;
|
||||
}
|
||||
|
||||
/*! \return current HP */
|
||||
uint32_t Sapphire::Entity::Chara::getHp() const
|
||||
uint32_t Chara::getHp() const
|
||||
{
|
||||
return m_hp;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::Chara::getHpPercent() const
|
||||
uint32_t Chara::getHpPercent() const
|
||||
{
|
||||
return ( m_hp * 100 ) / m_maxHp;
|
||||
}
|
||||
|
||||
/*! \return current MP */
|
||||
uint32_t Sapphire::Entity::Chara::getMp() const
|
||||
uint32_t Chara::getMp() const
|
||||
{
|
||||
return m_mp;
|
||||
}
|
||||
|
||||
/*! \return current TP */
|
||||
uint16_t Sapphire::Entity::Chara::getTp() const
|
||||
uint16_t Chara::getTp() const
|
||||
{
|
||||
return m_tp;
|
||||
}
|
||||
|
||||
/*! \return current GP */
|
||||
uint16_t Sapphire::Entity::Chara::getGp() const
|
||||
uint16_t Chara::getGp() const
|
||||
{
|
||||
return m_gp;
|
||||
}
|
||||
|
||||
/*! \return current invincibility type */
|
||||
InvincibilityType Sapphire::Entity::Chara::getInvincibilityType() const
|
||||
InvincibilityType Chara::getInvincibilityType() const
|
||||
{
|
||||
return m_invincibilityType;
|
||||
}
|
||||
|
||||
/*! \return current class or job */
|
||||
Sapphire::Common::ClassJob Sapphire::Entity::Chara::getClass() const
|
||||
ClassJob Chara::getClass() const
|
||||
{
|
||||
return m_class;
|
||||
}
|
||||
|
||||
/*! \param ClassJob to set */
|
||||
void Sapphire::Entity::Chara::setClass( Common::ClassJob classJob )
|
||||
void Chara::setClass( ClassJob classJob )
|
||||
{
|
||||
m_class = classJob;
|
||||
}
|
||||
|
||||
Sapphire::Common::Role Sapphire::Entity::Chara::getRole() const
|
||||
Role Chara::getRole() const
|
||||
{
|
||||
switch( getClass() )
|
||||
{
|
||||
|
@ -181,67 +182,67 @@ Sapphire::Common::Role Sapphire::Entity::Chara::getRole() const
|
|||
}
|
||||
|
||||
/*! \param Id of the target to set */
|
||||
void Sapphire::Entity::Chara::setTargetId( uint64_t targetId )
|
||||
void Chara::setTargetId( uint64_t targetId )
|
||||
{
|
||||
m_targetId = targetId;
|
||||
}
|
||||
|
||||
/*! \return Id of the current target */
|
||||
uint64_t Sapphire::Entity::Chara::getTargetId() const
|
||||
uint64_t Chara::getTargetId() const
|
||||
{
|
||||
return m_targetId;
|
||||
}
|
||||
|
||||
/*! \return True if the actor is alive */
|
||||
bool Sapphire::Entity::Chara::isAlive() const
|
||||
bool Chara::isAlive() const
|
||||
{
|
||||
return ( m_hp > 0 );
|
||||
}
|
||||
|
||||
/*! \return max hp for the actor */
|
||||
uint32_t Sapphire::Entity::Chara::getMaxHp() const
|
||||
uint32_t Chara::getMaxHp() const
|
||||
{
|
||||
return m_maxHp;
|
||||
}
|
||||
|
||||
/*! \return max mp for the actor */
|
||||
uint32_t Sapphire::Entity::Chara::getMaxMp() const
|
||||
uint32_t Chara::getMaxMp() const
|
||||
{
|
||||
return m_maxMp;
|
||||
}
|
||||
|
||||
/*! \return reset hp to current max hp */
|
||||
void Sapphire::Entity::Chara::resetHp()
|
||||
void Chara::resetHp()
|
||||
{
|
||||
m_hp = getMaxHp();
|
||||
}
|
||||
|
||||
/*! \return reset mp to current max mp */
|
||||
void Sapphire::Entity::Chara::resetMp()
|
||||
void Chara::resetMp()
|
||||
{
|
||||
m_mp = getMaxMp();
|
||||
}
|
||||
|
||||
/*! \param hp amount to set ( caps to maxHp ) */
|
||||
void Sapphire::Entity::Chara::setHp( uint32_t hp )
|
||||
void Chara::setHp( uint32_t hp )
|
||||
{
|
||||
m_hp = hp < getMaxHp() ? hp : getMaxHp();
|
||||
}
|
||||
|
||||
/*! \param mp amount to set ( caps to maxMp ) */
|
||||
void Sapphire::Entity::Chara::setMp( uint32_t mp )
|
||||
void Chara::setMp( uint32_t mp )
|
||||
{
|
||||
m_mp = mp < getMaxMp() ? mp : getMaxMp();
|
||||
}
|
||||
|
||||
/*! \param gp amount to set*/
|
||||
void Sapphire::Entity::Chara::setGp( uint32_t gp )
|
||||
void Chara::setGp( uint32_t gp )
|
||||
{
|
||||
m_gp = static_cast< uint16_t >( gp );
|
||||
}
|
||||
|
||||
/*! \param tp amount to set*/
|
||||
void Sapphire::Entity::Chara::setTp( uint32_t tp )
|
||||
void Chara::setTp( uint32_t tp )
|
||||
{
|
||||
m_tp = static_cast< uint16_t >( tp );
|
||||
}
|
||||
|
@ -253,13 +254,13 @@ void Sapphire::Entity::Chara::setInvincibilityType( Common::InvincibilityType ty
|
|||
}
|
||||
|
||||
/*! \return current status of the actor */
|
||||
Sapphire::Common::ActorStatus Sapphire::Entity::Chara::getStatus() const
|
||||
ActorStatus Chara::getStatus() const
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
|
||||
/*! \param status to set */
|
||||
void Sapphire::Entity::Chara::setStatus( ActorStatus status )
|
||||
void Chara::setStatus( ActorStatus status )
|
||||
{
|
||||
m_status = status;
|
||||
}
|
||||
|
@ -268,7 +269,7 @@ void Sapphire::Entity::Chara::setStatus( ActorStatus status )
|
|||
Performs necessary steps to mark an actor dead.
|
||||
Sets hp/mp/tp, sets status, plays animation and fires onDeath event
|
||||
*/
|
||||
void Sapphire::Entity::Chara::die()
|
||||
void Chara::die()
|
||||
{
|
||||
m_status = ActorStatus::Dead;
|
||||
m_hp = 0;
|
||||
|
@ -280,13 +281,8 @@ void Sapphire::Entity::Chara::die()
|
|||
|
||||
// if the actor is a player, the update needs to be send to himself too
|
||||
bool selfNeedsUpdate = isPlayer();
|
||||
|
||||
FFXIVPacketBasePtr packet = makeActorControl( m_id, SetStatus, static_cast< uint8_t >( ActorStatus::Dead ) );
|
||||
server().queueForPlayers( getInRangePlayerIds( selfNeedsUpdate ), packet );
|
||||
|
||||
FFXIVPacketBasePtr packet1 = makeActorControl( m_id, DeathAnimation, 0, 0, 0, 0 );
|
||||
server().queueForPlayers( getInRangePlayerIds( selfNeedsUpdate ), packet1 );
|
||||
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds( selfNeedsUpdate ), getId(), SetStatus, static_cast< uint8_t >( ActorStatus::Dead ) );
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds( selfNeedsUpdate ), getId(), DeathAnimation );
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -295,10 +291,10 @@ position
|
|||
|
||||
\param Position to look towards
|
||||
*/
|
||||
bool Sapphire::Entity::Chara::face( const Common::FFXIVARR_POSITION3& p )
|
||||
bool Chara::face( const FFXIVARR_POSITION3& p )
|
||||
{
|
||||
float oldRot = getRot();
|
||||
float rot = Util::calcAngFrom( getPos().x, getPos().z, p.x, p.z );
|
||||
float rot = Common::Util::calcAngFrom( getPos().x, getPos().z, p.x, p.z );
|
||||
float newRot = PI - rot + ( PI / 2 );
|
||||
|
||||
setRot( newRot );
|
||||
|
@ -312,12 +308,10 @@ Set and propagate the actor stance to in range players
|
|||
|
||||
\param stance to set
|
||||
*/
|
||||
void Sapphire::Entity::Chara::setStance( Stance stance )
|
||||
void Chara::setStance( Stance stance )
|
||||
{
|
||||
m_currentStance = stance;
|
||||
|
||||
FFXIVPacketBasePtr packet = makeActorControl( m_id, ToggleWeapon, stance, 1 );
|
||||
server().queueForPlayers( getInRangePlayerIds(), packet );
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds(), getId(), ToggleWeapon, stance, 1 );
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -326,7 +320,7 @@ and if fully performed, clean up again.
|
|||
|
||||
\return true if a queued action has been updated
|
||||
*/
|
||||
bool Sapphire::Entity::Chara::checkAction()
|
||||
bool Chara::checkAction()
|
||||
{
|
||||
|
||||
if( m_pCurrentAction == nullptr )
|
||||
|
@ -339,7 +333,7 @@ bool Sapphire::Entity::Chara::checkAction()
|
|||
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Chara::update( uint64_t tickCount )
|
||||
void Chara::update( uint64_t tickCount )
|
||||
{
|
||||
updateStatusEffects();
|
||||
|
||||
|
@ -358,17 +352,16 @@ Change the current target and propagate to in range players
|
|||
|
||||
\param target actor id
|
||||
*/
|
||||
void Sapphire::Entity::Chara::changeTarget( uint64_t targetId )
|
||||
void Chara::changeTarget( uint64_t targetId )
|
||||
{
|
||||
setTargetId( targetId );
|
||||
FFXIVPacketBasePtr packet = makeActorControlTarget( m_id, SetTarget, 0, 0, 0, 0, targetId );
|
||||
server().queueForPlayers( getInRangePlayerIds(), packet );
|
||||
Network::Util::Packet::sendActorControlTarget( getInRangePlayerIds(), getId(), ToggleWeapon, SetTarget, 0, 0, 0, 0, targetId );
|
||||
}
|
||||
|
||||
/*!
|
||||
Dummy function \return 0
|
||||
*/
|
||||
uint8_t Sapphire::Entity::Chara::getLevel() const
|
||||
uint8_t Chara::getLevel() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -382,7 +375,7 @@ magical dmg and take status effects into account
|
|||
|
||||
\param amount of damage to be taken
|
||||
*/
|
||||
void Sapphire::Entity::Chara::takeDamage( uint32_t damage )
|
||||
void Chara::takeDamage( uint32_t damage )
|
||||
{
|
||||
if( damage >= m_hp )
|
||||
{
|
||||
|
@ -413,7 +406,7 @@ in range
|
|||
|
||||
\param amount of hp to be healed
|
||||
*/
|
||||
void Sapphire::Entity::Chara::heal( uint32_t amount )
|
||||
void Chara::heal( uint32_t amount )
|
||||
{
|
||||
if( ( m_hp + amount ) > getMaxHp() )
|
||||
{
|
||||
|
@ -423,7 +416,7 @@ void Sapphire::Entity::Chara::heal( uint32_t amount )
|
|||
m_hp += amount;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Chara::restoreMP( uint32_t amount )
|
||||
void Chara::restoreMP( uint32_t amount )
|
||||
{
|
||||
if( ( m_mp + amount ) > getMaxMp() )
|
||||
{
|
||||
|
@ -440,20 +433,19 @@ so players can have their own version and we can abolish the param.
|
|||
|
||||
\param true if the update should also be sent to the actor ( player ) himself
|
||||
*/
|
||||
void Sapphire::Entity::Chara::sendHudParam()
|
||||
void Chara::sendHudParam()
|
||||
{
|
||||
FFXIVPacketBasePtr packet = makeHudParam( *this );
|
||||
server().queueForPlayers( getInRangePlayerIds( isPlayer() ), packet );
|
||||
Network::Util::Packet::sendHudParam( *this );
|
||||
}
|
||||
|
||||
/*! \return ActionPtr of the currently registered action, or nullptr */
|
||||
Sapphire::World::Action::ActionPtr Sapphire::Entity::Chara::getCurrentAction() const
|
||||
Action::ActionPtr Chara::getCurrentAction() const
|
||||
{
|
||||
return m_pCurrentAction;
|
||||
}
|
||||
|
||||
/*! \param ActionPtr of the action to be registered */
|
||||
void Sapphire::Entity::Chara::setCurrentAction( Sapphire::World::Action::ActionPtr pAction )
|
||||
void Chara::setCurrentAction( Action::ActionPtr pAction )
|
||||
{
|
||||
m_pCurrentAction = std::move( pAction );
|
||||
}
|
||||
|
@ -467,9 +459,9 @@ Will have to be extended for ranged attacks.
|
|||
|
||||
\param GameObjectPtr the autoAttack is performed on
|
||||
*/
|
||||
void Sapphire::Entity::Chara::autoAttack( CharaPtr pTarget )
|
||||
void Chara::autoAttack( CharaPtr pTarget )
|
||||
{
|
||||
uint64_t tick = Util::getTimeMs();
|
||||
uint64_t tick = Common::Util::getTimeMs();
|
||||
|
||||
// todo: this needs to use the auto attack delay for the equipped weapon
|
||||
if( ( tick - m_lastAttack ) > 2500 )
|
||||
|
@ -481,7 +473,7 @@ void Sapphire::Entity::Chara::autoAttack( CharaPtr pTarget )
|
|||
auto damage = static_cast< uint16_t >( 10 + rand() % 12 );
|
||||
|
||||
auto effectPacket = std::make_shared< EffectPacket1 >( getId(), pTarget->getId(), 7 );
|
||||
effectPacket->setRotation( Util::floatToUInt16Rot( getRot() ) );
|
||||
effectPacket->setRotation( Common::Util::floatToUInt16Rot( getRot() ) );
|
||||
|
||||
Common::CalcResultParam effectEntry{};
|
||||
effectEntry.Value = static_cast< int16_t >( damage );
|
||||
|
@ -497,9 +489,9 @@ void Sapphire::Entity::Chara::autoAttack( CharaPtr pTarget )
|
|||
}
|
||||
|
||||
/*! \param StatusEffectPtr to be applied to the actor */
|
||||
void Sapphire::Entity::Chara::addStatusEffect( StatusEffect::StatusEffectPtr pEffect )
|
||||
void Chara::addStatusEffect( StatusEffect::StatusEffectPtr pEffect )
|
||||
{
|
||||
auto& teriMgr = Common::Service< World::Manager::TerritoryMgr >::ref();
|
||||
auto& teriMgr = Common::Service< Manager::TerritoryMgr >::ref();
|
||||
auto pZone = teriMgr.getTerritoryByGuId( getTerritoryId() );
|
||||
|
||||
int8_t nextSlot = getStatusEffectFreeSlot();
|
||||
|
@ -542,7 +534,7 @@ void Sapphire::Entity::Chara::addStatusEffect( StatusEffect::StatusEffectPtr pEf
|
|||
}
|
||||
|
||||
/*! \param StatusEffectPtr to be applied to the actor */
|
||||
void Sapphire::Entity::Chara::addStatusEffectById( uint32_t id, int32_t duration, Entity::Chara& source, uint16_t param )
|
||||
void Chara::addStatusEffectById( uint32_t id, int32_t duration, Entity::Chara& source, uint16_t param )
|
||||
{
|
||||
auto effect = StatusEffect::make_StatusEffect( id, source.getAsChara(), getAsChara(), duration, 3000 );
|
||||
effect->setParam( param );
|
||||
|
@ -550,8 +542,7 @@ void Sapphire::Entity::Chara::addStatusEffectById( uint32_t id, int32_t duration
|
|||
}
|
||||
|
||||
/*! \param StatusEffectPtr to be applied to the actor */
|
||||
void Sapphire::Entity::Chara::addStatusEffectByIdIfNotExist( uint32_t id, int32_t duration, Entity::Chara& source,
|
||||
uint16_t param )
|
||||
void Chara::addStatusEffectByIdIfNotExist( uint32_t id, int32_t duration, Entity::Chara& source, uint16_t param )
|
||||
{
|
||||
if( hasStatusEffect( id ) )
|
||||
return;
|
||||
|
@ -562,7 +553,7 @@ void Sapphire::Entity::Chara::addStatusEffectByIdIfNotExist( uint32_t id, int32_
|
|||
|
||||
}
|
||||
|
||||
int8_t Sapphire::Entity::Chara::getStatusEffectFreeSlot()
|
||||
int8_t Chara::getStatusEffectFreeSlot()
|
||||
{
|
||||
int8_t freeEffectSlot = -1;
|
||||
|
||||
|
@ -575,12 +566,12 @@ int8_t Sapphire::Entity::Chara::getStatusEffectFreeSlot()
|
|||
return freeEffectSlot;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Chara::statusEffectFreeSlot( uint8_t slotId )
|
||||
void Chara::statusEffectFreeSlot( uint8_t slotId )
|
||||
{
|
||||
m_statusEffectFreeSlotQueue.push( slotId );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Chara::removeSingleStatusEffectById( uint32_t id )
|
||||
void Chara::removeSingleStatusEffectById( uint32_t id )
|
||||
{
|
||||
for( const auto& effectIt : m_statusEffectMap )
|
||||
{
|
||||
|
@ -592,7 +583,7 @@ void Sapphire::Entity::Chara::removeSingleStatusEffectById( uint32_t id )
|
|||
}
|
||||
}
|
||||
|
||||
std::map< uint8_t, Sapphire::StatusEffect::StatusEffectPtr >::iterator Sapphire::Entity::Chara::removeStatusEffect( uint8_t effectSlotId )
|
||||
std::map< uint8_t, StatusEffect::StatusEffectPtr >::iterator Chara::removeStatusEffect( uint8_t effectSlotId )
|
||||
{
|
||||
auto pEffectIt = m_statusEffectMap.find( effectSlotId );
|
||||
if( pEffectIt == m_statusEffectMap.end() )
|
||||
|
@ -603,46 +594,41 @@ std::map< uint8_t, Sapphire::StatusEffect::StatusEffectPtr >::iterator Sapphire:
|
|||
auto pEffect = pEffectIt->second;
|
||||
pEffect->removeStatus();
|
||||
|
||||
server().queueForPlayers( getInRangePlayerIds( isPlayer() ), makeActorControl( getId(), StatusEffectLose, pEffect->getId() ) );
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds( isPlayer() ), getId(), StatusEffectLose, pEffect->getId() );
|
||||
|
||||
auto it = m_statusEffectMap.erase( pEffectIt );
|
||||
|
||||
if( isPlayer() )
|
||||
server().queueForPlayers( getInRangePlayerIds( isPlayer() ), makeHudParam( *getAsPlayer() ) );
|
||||
else if( isBattleNpc() )
|
||||
server().queueForPlayers( getInRangePlayerIds( isPlayer() ), makeHudParam( *getAsBNpc() ) );
|
||||
|
||||
Network::Util::Packet::sendHudParam( *this );
|
||||
return it;
|
||||
}
|
||||
|
||||
std::map< uint8_t, Sapphire::StatusEffect::StatusEffectPtr > Sapphire::Entity::Chara::getStatusEffectMap() const
|
||||
std::map< uint8_t, StatusEffect::StatusEffectPtr > Chara::getStatusEffectMap() const
|
||||
{
|
||||
return m_statusEffectMap;
|
||||
}
|
||||
|
||||
const uint8_t* Sapphire::Entity::Chara::getLookArray() const
|
||||
const uint8_t* Chara::getLookArray() const
|
||||
{
|
||||
return m_customize;
|
||||
}
|
||||
|
||||
const uint32_t* Sapphire::Entity::Chara::getModelArray() const
|
||||
const uint32_t* Chara::getModelArray() const
|
||||
{
|
||||
return m_modelEquip;
|
||||
}
|
||||
|
||||
uint8_t Sapphire::Entity::Chara::getPose() const
|
||||
uint8_t Chara::getPose() const
|
||||
{
|
||||
return m_pose;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Chara::setPose( uint8_t pose )
|
||||
void Chara::setPose( uint8_t pose )
|
||||
{
|
||||
m_pose = pose;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Chara::sendStatusEffectUpdate()
|
||||
void Chara::sendStatusEffectUpdate()
|
||||
{
|
||||
uint64_t currentTimeMs = Util::getTimeMs();
|
||||
uint64_t currentTimeMs = Common::Util::getTimeMs();
|
||||
|
||||
|
||||
auto statusEffectList = makeZonePacket< FFXIVIpcStatus >( getId() );
|
||||
|
@ -660,9 +646,9 @@ void Sapphire::Entity::Chara::sendStatusEffectUpdate()
|
|||
server().queueForPlayers( getInRangePlayerIds( isPlayer() ), statusEffectList );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Chara::updateStatusEffects()
|
||||
void Chara::updateStatusEffects()
|
||||
{
|
||||
uint64_t currentTimeMs = Util::getTimeMs();
|
||||
uint64_t currentTimeMs = Common::Util::getTimeMs();
|
||||
|
||||
for( auto effectIt = m_statusEffectMap.begin(); effectIt != m_statusEffectMap.end(); )
|
||||
{
|
||||
|
@ -687,28 +673,28 @@ void Sapphire::Entity::Chara::updateStatusEffects()
|
|||
}
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::Chara::hasStatusEffect( uint32_t id )
|
||||
bool Chara::hasStatusEffect( uint32_t id )
|
||||
{
|
||||
return m_statusEffectMap.find( id ) != m_statusEffectMap.end();
|
||||
}
|
||||
|
||||
int64_t Sapphire::Entity::Chara::getLastUpdateTime() const
|
||||
int64_t Chara::getLastUpdateTime() const
|
||||
{
|
||||
return m_lastUpdate;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Chara::setLastComboActionId( uint32_t actionId )
|
||||
void Chara::setLastComboActionId( uint32_t actionId )
|
||||
{
|
||||
m_lastComboActionId = actionId;
|
||||
m_lastComboActionTime = Util::getTimeMs();
|
||||
m_lastComboActionTime = Common::Util::getTimeMs();
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::Chara::getLastComboActionId() const
|
||||
uint32_t Chara::getLastComboActionId() const
|
||||
{
|
||||
// initially check for the time passed first, if it's more than the threshold just return 0 for the combo
|
||||
// we can hide the implementation detail this way and it just works:tm: for anything that uses it
|
||||
|
||||
if( std::difftime( static_cast< time_t >( Util::getTimeMs() ),
|
||||
if( std::difftime( static_cast< time_t >( Common::Util::getTimeMs() ),
|
||||
static_cast< time_t >( m_lastComboActionTime ) ) > Common::MAX_COMBO_LENGTH )
|
||||
{
|
||||
return 0;
|
||||
|
@ -717,43 +703,42 @@ uint32_t Sapphire::Entity::Chara::getLastComboActionId() const
|
|||
return m_lastComboActionId;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::Chara::getDirectorId() const
|
||||
uint32_t Chara::getDirectorId() const
|
||||
{
|
||||
return m_directorId;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Chara::setDirectorId( uint32_t directorId )
|
||||
void Chara::setDirectorId( uint32_t directorId )
|
||||
{
|
||||
m_directorId = directorId;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::Chara::getAgentId() const
|
||||
uint32_t Chara::getAgentId() const
|
||||
{
|
||||
return m_agentId;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Chara::setAgentId( uint32_t agentId )
|
||||
void Chara::setAgentId( uint32_t agentId )
|
||||
{
|
||||
m_agentId = agentId;
|
||||
}
|
||||
|
||||
|
||||
float Sapphire::Entity::Chara::getRadius() const
|
||||
float Chara::getRadius() const
|
||||
{
|
||||
return m_radius;
|
||||
}
|
||||
|
||||
Sapphire::Common::BaseParam Sapphire::Entity::Chara::getPrimaryStat() const
|
||||
Common::BaseParam Chara::getPrimaryStat() const
|
||||
{
|
||||
auto& exdData = Common::Service< Data::ExdData >::ref();
|
||||
|
||||
auto classJob = exdData.getRow< Excel::ClassJob >( static_cast< uint16_t >( getClass() ) );
|
||||
assert( classJob );
|
||||
|
||||
return static_cast< Sapphire::Common::BaseParam >( classJob->data().Role );
|
||||
return static_cast< Common::BaseParam >( classJob->data().Role );
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::Chara::getStatValue( Sapphire::Common::BaseParam baseParam ) const
|
||||
uint32_t Chara::getStatValue( Common::BaseParam baseParam ) const
|
||||
{
|
||||
auto index = static_cast< uint32_t >( baseParam );
|
||||
assert( index < m_baseStats.size() );
|
||||
|
@ -761,7 +746,7 @@ uint32_t Sapphire::Entity::Chara::getStatValue( Sapphire::Common::BaseParam base
|
|||
return m_baseStats[ index ] + m_bonusStats[ index ];
|
||||
}
|
||||
|
||||
float Sapphire::Entity::Chara::getStatValueFloat( Common::BaseParam baseParam ) const
|
||||
float Chara::getStatValueFloat( Common::BaseParam baseParam ) const
|
||||
{
|
||||
auto index = static_cast< uint32_t >( baseParam );
|
||||
assert( index < m_baseStats.size() );
|
||||
|
@ -769,7 +754,7 @@ float Sapphire::Entity::Chara::getStatValueFloat( Common::BaseParam baseParam )
|
|||
return static_cast< float >( m_baseStats[ index ] + m_bonusStats[ index ] );
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::Chara::getBonusStat( Sapphire::Common::BaseParam baseParam ) const
|
||||
uint32_t Chara::getBonusStat( Common::BaseParam baseParam ) const
|
||||
{
|
||||
auto index = static_cast< uint32_t >( baseParam );
|
||||
assert( index < m_bonusStats.size() );
|
||||
|
@ -777,7 +762,7 @@ uint32_t Sapphire::Entity::Chara::getBonusStat( Sapphire::Common::BaseParam base
|
|||
return m_bonusStats[ index ];
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Chara::setStatValue( Common::BaseParam baseParam, uint32_t value )
|
||||
void Chara::setStatValue( Common::BaseParam baseParam, uint32_t value )
|
||||
{
|
||||
auto index = static_cast< uint32_t >( baseParam );
|
||||
assert( index < m_baseStats.size() );
|
||||
|
@ -785,7 +770,7 @@ void Sapphire::Entity::Chara::setStatValue( Common::BaseParam baseParam, uint32_
|
|||
m_baseStats[ index ] = value;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Chara::onTick()
|
||||
void Chara::onTick()
|
||||
{
|
||||
uint32_t thisTickDmg = 0;
|
||||
uint32_t thisTickHeal = 0;
|
||||
|
@ -812,16 +797,14 @@ void Sapphire::Entity::Chara::onTick()
|
|||
if( thisTickDmg != 0 )
|
||||
{
|
||||
takeDamage( thisTickDmg );
|
||||
server().queueForPlayers( getInRangePlayerIds( isPlayer() ), makeActorControl( getId(), HPFloatingText, 0,
|
||||
static_cast< uint8_t >( ActionEffectType::CALC_RESULT_TYPE_DAMAGE_HP ),
|
||||
thisTickDmg ) );
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds( isPlayer() ), getId(), HPFloatingText, 0,
|
||||
ActionEffectType::CALC_RESULT_TYPE_DAMAGE_HP, thisTickDmg );
|
||||
}
|
||||
|
||||
if( thisTickHeal != 0 )
|
||||
{
|
||||
heal( thisTickHeal );
|
||||
server().queueForPlayers( getInRangePlayerIds( isPlayer() ), makeActorControl( getId(), HPFloatingText, 0,
|
||||
static_cast< uint8_t >( ActionEffectType::CALC_RESULT_TYPE_RECOVER_HP ),
|
||||
thisTickHeal ) );
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds( isPlayer() ), getId(), HPFloatingText, 0,
|
||||
ActionEffectType::CALC_RESULT_TYPE_RECOVER_HP, thisTickHeal );
|
||||
}
|
||||
}
|
|
@ -3,12 +3,10 @@
|
|||
#include "Territory/InstanceContent.h"
|
||||
#include "Actor/Player.h"
|
||||
|
||||
#include "Network/PacketWrappers/ActorControlPacket.h"
|
||||
#include "Network/PacketWrappers/ActorControlTargetPacket.h"
|
||||
|
||||
#include <Logging/Logger.h>
|
||||
#include <Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
#include <Network/CommonActorControl.h>
|
||||
#include <Network/Util/PacketUtil.h>
|
||||
#include <Util/UtilMath.h>
|
||||
|
||||
#include <Service.h>
|
||||
|
@ -16,20 +14,19 @@
|
|||
#include <utility>
|
||||
#include "WorldServer.h"
|
||||
#include "Session.h"
|
||||
#include "Network/GameConnection.h"
|
||||
#include "Manager/MgrUtil.h"
|
||||
|
||||
|
||||
using namespace Sapphire;
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire::Entity;
|
||||
using namespace Sapphire::World::Manager;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
using namespace Sapphire::Network::Packets::WorldPackets::Server;
|
||||
using namespace Sapphire::Network::ActorControl;
|
||||
|
||||
Sapphire::Entity::EventObject::EventObject( uint32_t actorId, uint32_t objectId, uint32_t gimmickId, uint32_t instanceId,
|
||||
uint8_t initialState, Common::FFXIVARR_POSITION3 pos,
|
||||
float rotation, const std::string& givenName, uint8_t permissionInv ) :
|
||||
Sapphire::Entity::GameObject( ObjKind::EventObj ),
|
||||
EventObject::EventObject( uint32_t actorId, uint32_t objectId, uint32_t gimmickId, uint32_t instanceId, uint8_t initialState,
|
||||
FFXIVARR_POSITION3 pos, float rotation, const std::string& givenName, uint8_t permissionInv ) :
|
||||
GameObject( ObjKind::EventObj ),
|
||||
m_gimmickId( gimmickId ),
|
||||
m_instanceId( instanceId ),
|
||||
m_state( initialState ),
|
||||
|
@ -37,7 +34,7 @@ Sapphire::Entity::EventObject::EventObject( uint32_t actorId, uint32_t objectId,
|
|||
m_name( givenName ),
|
||||
m_housingLink( 0 ),
|
||||
m_permissionInvisibility( permissionInv ),
|
||||
m_ownerId( Common::INVALID_GAME_OBJECT_ID )
|
||||
m_ownerId( INVALID_GAME_OBJECT_ID )
|
||||
{
|
||||
m_id = actorId;
|
||||
m_pos.x = pos.x;
|
||||
|
@ -46,78 +43,77 @@ Sapphire::Entity::EventObject::EventObject( uint32_t actorId, uint32_t objectId,
|
|||
m_rot = rotation;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::EventObject::getGimmickId() const
|
||||
uint32_t EventObject::getGimmickId() const
|
||||
{
|
||||
return m_gimmickId;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::EventObject::getObjectId() const
|
||||
uint32_t EventObject::getObjectId() const
|
||||
{
|
||||
return m_objectId;
|
||||
}
|
||||
|
||||
float Sapphire::Entity::EventObject::getScale() const
|
||||
float EventObject::getScale() const
|
||||
{
|
||||
return m_scale;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::EventObject::setScale( float scale )
|
||||
void EventObject::setScale( float scale )
|
||||
{
|
||||
m_scale = scale;
|
||||
}
|
||||
|
||||
Sapphire::Entity::EventObject::OnTalkEventHandler Sapphire::Entity::EventObject::getOnTalkHandler() const
|
||||
EventObject::OnTalkEventHandler EventObject::getOnTalkHandler() const
|
||||
{
|
||||
return m_onTalkEventHandler;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::EventObject::setOnTalkHandler( Sapphire::Entity::EventObject::OnTalkEventHandler handler )
|
||||
void EventObject::setOnTalkHandler( EventObject::OnTalkEventHandler handler )
|
||||
{
|
||||
m_onTalkEventHandler = std::move( handler );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::EventObject::setGimmickId( uint32_t gimmickId )
|
||||
void EventObject::setGimmickId( uint32_t gimmickId )
|
||||
{
|
||||
m_gimmickId = gimmickId;
|
||||
}
|
||||
|
||||
uint8_t Sapphire::Entity::EventObject::getState() const
|
||||
uint8_t EventObject::getState() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::EventObject::setState( uint8_t state )
|
||||
void EventObject::setState( uint8_t state )
|
||||
{
|
||||
m_state = state;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::EventObject::setAnimationFlag( uint32_t flag, uint32_t animationFlag )
|
||||
void EventObject::setAnimationFlag( uint32_t flag, uint32_t animationFlag )
|
||||
{
|
||||
for( const auto& player : m_inRangePlayers )
|
||||
server().queueForPlayer( player->getCharacterId(), makeActorControl( getId(), EObjAnimation, flag, animationFlag ) );
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds(), getId(), EObjAnimation, flag, animationFlag );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::EventObject::setHousingLink( uint32_t housingLink )
|
||||
void EventObject::setHousingLink( uint32_t housingLink )
|
||||
{
|
||||
m_housingLink = housingLink;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::EventObject::getHousingLink() const
|
||||
uint32_t EventObject::getHousingLink() const
|
||||
{
|
||||
return m_housingLink;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::EventObject::setParentInstance( Sapphire::TerritoryPtr instance )
|
||||
void EventObject::setParentInstance( Sapphire::TerritoryPtr instance )
|
||||
{
|
||||
m_parentInstance = std::move( instance );
|
||||
}
|
||||
|
||||
Sapphire::TerritoryPtr Sapphire::Entity::EventObject::getParentInstance() const
|
||||
TerritoryPtr EventObject::getParentInstance() const
|
||||
{
|
||||
return m_parentInstance;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::EventObject::spawn( Sapphire::Entity::PlayerPtr pTarget )
|
||||
void EventObject::spawn( PlayerPtr pTarget )
|
||||
{
|
||||
auto spawnIndex = pTarget->getNextObjSpawnIndexForActorId( getId() );
|
||||
if( !pTarget->isObjSpawnIndexValid( spawnIndex ) )
|
||||
|
@ -149,34 +145,31 @@ void Sapphire::Entity::EventObject::spawn( Sapphire::Entity::PlayerPtr pTarget )
|
|||
}
|
||||
|
||||
|
||||
void Sapphire::Entity::EventObject::despawn( Sapphire::Entity::PlayerPtr pTarget )
|
||||
void EventObject::despawn( PlayerPtr pTarget )
|
||||
{
|
||||
Logger::debug( "despawn eobj#{0}", getId() );
|
||||
|
||||
pTarget->freeObjSpawnIndexForActorId( getId() );
|
||||
}
|
||||
|
||||
const std::string& Sapphire::Entity::EventObject::getName() const
|
||||
const std::string& EventObject::getName() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::EventObject::getInstanceId() const
|
||||
uint32_t EventObject::getInstanceId() const
|
||||
{
|
||||
return m_instanceId;
|
||||
}
|
||||
|
||||
uint8_t Sapphire::Entity::EventObject::getPermissionInvisibility() const
|
||||
uint8_t EventObject::getPermissionInvisibility() const
|
||||
{
|
||||
return m_permissionInvisibility;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::EventObject::setPermissionInvisibility( uint8_t permissionInvisibility )
|
||||
void EventObject::setPermissionInvisibility( uint8_t permissionInvisibility )
|
||||
{
|
||||
m_permissionInvisibility = permissionInvisibility;
|
||||
auto& server = Common::Service< World::WorldServer >::ref();
|
||||
auto inRangePlayerIds = getInRangePlayerIds();
|
||||
server.queueForPlayers( inRangePlayerIds, makeActorControl( getId(), DirectorEObjMod, permissionInvisibility ) );
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds(), getId(), DirectorEObjMod, permissionInvisibility );
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::EventObject::getOwnerId() const
|
||||
|
|
|
@ -23,41 +23,42 @@
|
|||
#include "StatusEffect/StatusEffect.h"
|
||||
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire::Entity;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
//using namespace Sapphire::Network::Packets::Server;
|
||||
|
||||
Sapphire::Entity::GameObject::GameObject( ObjKind type ) :
|
||||
GameObject::GameObject( ObjKind type ) :
|
||||
m_objKind( type )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::GameObject::getId() const
|
||||
uint32_t GameObject::getId() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::GameObject::setId( uint32_t id )
|
||||
void GameObject::setId( uint32_t id )
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
Sapphire::Common::ObjKind Sapphire::Entity::GameObject::getObjKind() const
|
||||
ObjKind GameObject::getObjKind() const
|
||||
{
|
||||
return m_objKind;
|
||||
}
|
||||
|
||||
Sapphire::Common::FFXIVARR_POSITION3& Sapphire::Entity::GameObject::getPos()
|
||||
FFXIVARR_POSITION3& GameObject::getPos()
|
||||
{
|
||||
return m_pos;
|
||||
}
|
||||
|
||||
const Sapphire::Common::FFXIVARR_POSITION3& Sapphire::Entity::GameObject::getPos() const
|
||||
const FFXIVARR_POSITION3& GameObject::getPos() const
|
||||
{
|
||||
return m_pos;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::GameObject::setPos( float x, float y, float z, bool broadcastUpdate )
|
||||
void GameObject::setPos( float x, float y, float z, bool broadcastUpdate )
|
||||
{
|
||||
m_pos.x = x;
|
||||
m_pos.y = y;
|
||||
|
@ -72,7 +73,7 @@ void Sapphire::Entity::GameObject::setPos( float x, float y, float z, bool broad
|
|||
|
||||
}
|
||||
|
||||
void Sapphire::Entity::GameObject::setPos( const Sapphire::Common::FFXIVARR_POSITION3& pos, bool broadcastUpdate )
|
||||
void GameObject::setPos( const FFXIVARR_POSITION3& pos, bool broadcastUpdate )
|
||||
{
|
||||
m_pos = pos;
|
||||
|
||||
|
@ -84,92 +85,92 @@ void Sapphire::Entity::GameObject::setPos( const Sapphire::Common::FFXIVARR_POSI
|
|||
}
|
||||
}
|
||||
|
||||
float Sapphire::Entity::GameObject::getRot() const
|
||||
float GameObject::getRot() const
|
||||
{
|
||||
return m_rot;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::GameObject::setRot( float rot )
|
||||
void GameObject::setRot( float rot )
|
||||
{
|
||||
m_rot = rot;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::GameObject::isChara() const
|
||||
bool GameObject::isChara() const
|
||||
{
|
||||
return isPlayer() || isBattleNpc() || isEventNpc() || isRetainer() || isCompanion();
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::GameObject::isPlayer() const
|
||||
bool GameObject::isPlayer() const
|
||||
{
|
||||
return m_objKind == ObjKind::Player;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::GameObject::isEventNpc() const
|
||||
bool GameObject::isEventNpc() const
|
||||
{
|
||||
return m_objKind == ObjKind::EventNpc;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::GameObject::isBattleNpc() const
|
||||
bool GameObject::isBattleNpc() const
|
||||
{
|
||||
return m_objKind == ObjKind::BattleNpc;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::GameObject::isRetainer() const
|
||||
bool GameObject::isRetainer() const
|
||||
{
|
||||
return m_objKind == ObjKind::Retainer;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::GameObject::isCompanion() const
|
||||
bool GameObject::isCompanion() const
|
||||
{
|
||||
return m_objKind == ObjKind::Companion;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::GameObject::isEventObj() const
|
||||
bool GameObject::isEventObj() const
|
||||
{
|
||||
return m_objKind == ObjKind::EventObj;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::GameObject::isHousingEventObj() const
|
||||
bool GameObject::isHousingEventObj() const
|
||||
{
|
||||
return m_objKind == ObjKind::Housing;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::GameObject::isAetheryte() const
|
||||
bool GameObject::isAetheryte() const
|
||||
{
|
||||
return m_objKind == ObjKind::Aetheryte;
|
||||
}
|
||||
|
||||
|
||||
/*! \return pointer to this instance as GameObjectPtr */
|
||||
Sapphire::Entity::CharaPtr Sapphire::Entity::GameObject::getAsChara()
|
||||
CharaPtr GameObject::getAsChara()
|
||||
{
|
||||
if( !isChara() )
|
||||
return nullptr;
|
||||
return std::dynamic_pointer_cast< Entity::Chara, Entity::GameObject >( shared_from_this() );
|
||||
return std::dynamic_pointer_cast< Chara, GameObject >( shared_from_this() );
|
||||
}
|
||||
|
||||
/*! \return pointer to this instance as PlayerPtr */
|
||||
Sapphire::Entity::PlayerPtr Sapphire::Entity::GameObject::getAsPlayer()
|
||||
PlayerPtr GameObject::getAsPlayer()
|
||||
{
|
||||
if( !isPlayer() )
|
||||
return nullptr;
|
||||
return std::dynamic_pointer_cast< Entity::Player, Entity::GameObject >( shared_from_this() );
|
||||
return std::dynamic_pointer_cast< Player, GameObject >( shared_from_this() );
|
||||
}
|
||||
|
||||
/*! \return pointer to this instance as EventObjPtr */
|
||||
Sapphire::Entity::EventObjectPtr Sapphire::Entity::GameObject::getAsEventObj()
|
||||
EventObjectPtr GameObject::getAsEventObj()
|
||||
{
|
||||
if( !isEventObj() )
|
||||
return nullptr;
|
||||
return std::dynamic_pointer_cast< Entity::EventObject, Entity::GameObject >( shared_from_this() );
|
||||
return std::dynamic_pointer_cast< EventObject, GameObject >( shared_from_this() );
|
||||
}
|
||||
|
||||
/*! \return pointer to this instance as BNpcPtr */
|
||||
Sapphire::Entity::BNpcPtr Sapphire::Entity::GameObject::getAsBNpc()
|
||||
BNpcPtr GameObject::getAsBNpc()
|
||||
{
|
||||
if( !isBattleNpc() )
|
||||
return nullptr;
|
||||
return std::dynamic_pointer_cast< Entity::BNpc, Entity::GameObject >( shared_from_this() );
|
||||
return std::dynamic_pointer_cast< BNpc, GameObject >( shared_from_this() );
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -178,7 +179,7 @@ but also to the global actor map
|
|||
|
||||
\param GameObjectPtr to add
|
||||
*/
|
||||
void Sapphire::Entity::GameObject::addInRangeActor( GameObjectPtr pActor )
|
||||
void GameObject::addInRangeActor( GameObjectPtr pActor )
|
||||
{
|
||||
|
||||
// if this is null, something went wrong
|
||||
|
@ -211,7 +212,7 @@ but also to the global actor map
|
|||
|
||||
\param GameObjectPtr to remove
|
||||
*/
|
||||
void Sapphire::Entity::GameObject::removeInRangeActor( GameObject& actor )
|
||||
void GameObject::removeInRangeActor( GameObject& actor )
|
||||
{
|
||||
// call virtual event
|
||||
onRemoveInRangeActor( actor );
|
||||
|
@ -232,12 +233,12 @@ void Sapphire::Entity::GameObject::removeInRangeActor( GameObject& actor )
|
|||
}
|
||||
|
||||
/*! \return true if there is at least one actor in the in range set */
|
||||
bool Sapphire::Entity::GameObject::hasInRangeActor() const
|
||||
bool GameObject::hasInRangeActor() const
|
||||
{
|
||||
return ( !m_inRangeActor.empty() );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::GameObject::removeFromInRange()
|
||||
void GameObject::removeFromInRange()
|
||||
{
|
||||
if( !hasInRangeActor() )
|
||||
return;
|
||||
|
@ -255,14 +256,14 @@ check if a given actor is in the actors in range set
|
|||
\param GameObjectPtr to be checked for
|
||||
\return true if the actor was found
|
||||
*/
|
||||
bool Sapphire::Entity::GameObject::isInRangeSet( GameObjectPtr pActor ) const
|
||||
bool GameObject::isInRangeSet( GameObjectPtr pActor ) const
|
||||
{
|
||||
return !( m_inRangeActor.find( pActor ) == m_inRangeActor.end() );
|
||||
}
|
||||
|
||||
|
||||
/*! \return GameObjectPtr of the closest actor in range, if none, nullptr */
|
||||
Sapphire::Entity::CharaPtr Sapphire::Entity::GameObject::getClosestChara()
|
||||
CharaPtr GameObject::getClosestChara()
|
||||
{
|
||||
if( m_inRangeActor.empty() )
|
||||
// no actors in range, don't bother
|
||||
|
@ -275,8 +276,7 @@ Sapphire::Entity::CharaPtr Sapphire::Entity::GameObject::getClosestChara()
|
|||
|
||||
for( const auto& pCurAct : m_inRangeActor )
|
||||
{
|
||||
float distance = Util::distance( getPos().x, getPos().y, getPos().z,
|
||||
pCurAct->getPos().x, pCurAct->getPos().y, pCurAct->getPos().z );
|
||||
float distance = Util::distance( getPos().x, getPos().y, getPos().z, pCurAct->getPos().x, pCurAct->getPos().y, pCurAct->getPos().z );
|
||||
|
||||
if( distance < minDistance )
|
||||
{
|
||||
|
@ -289,7 +289,7 @@ Sapphire::Entity::CharaPtr Sapphire::Entity::GameObject::getClosestChara()
|
|||
}
|
||||
|
||||
/*! Clear the whole in range set, this does no cleanup */
|
||||
void Sapphire::Entity::GameObject::clearInRangeSet()
|
||||
void GameObject::clearInRangeSet()
|
||||
{
|
||||
m_inRangeActor.clear();
|
||||
m_inRangePlayers.clear();
|
||||
|
@ -297,7 +297,7 @@ void Sapphire::Entity::GameObject::clearInRangeSet()
|
|||
}
|
||||
|
||||
/*! \return list of actors currently in range */
|
||||
std::set< Sapphire::Entity::GameObjectPtr > Sapphire::Entity::GameObject::getInRangeActors( bool includeSelf )
|
||||
std::set< GameObjectPtr > GameObject::getInRangeActors( bool includeSelf )
|
||||
{
|
||||
auto tempInRange = m_inRangeActor;
|
||||
|
||||
|
@ -307,7 +307,7 @@ std::set< Sapphire::Entity::GameObjectPtr > Sapphire::Entity::GameObject::getInR
|
|||
return tempInRange;
|
||||
}
|
||||
|
||||
std::set< uint64_t > Sapphire::Entity::GameObject::getInRangePlayerIds( bool includeSelf )
|
||||
std::set< uint64_t > GameObject::getInRangePlayerIds( bool includeSelf )
|
||||
{
|
||||
std::set< uint64_t > playerIds;
|
||||
for( auto& player : m_inRangePlayers )
|
||||
|
@ -319,22 +319,22 @@ std::set< uint64_t > Sapphire::Entity::GameObject::getInRangePlayerIds( bool inc
|
|||
return playerIds;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::GameObject::getTerritoryTypeId() const
|
||||
uint32_t GameObject::getTerritoryTypeId() const
|
||||
{
|
||||
return m_territoryTypeId;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::GameObject::setTerritoryTypeId( uint32_t territoryTypeId )
|
||||
void GameObject::setTerritoryTypeId( uint32_t territoryTypeId )
|
||||
{
|
||||
m_territoryTypeId = territoryTypeId;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::GameObject::getTerritoryId() const
|
||||
uint32_t GameObject::getTerritoryId() const
|
||||
{
|
||||
return m_territoryId;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::GameObject::setTerritoryId( uint32_t territoryId )
|
||||
void GameObject::setTerritoryId( uint32_t territoryId )
|
||||
{
|
||||
m_territoryId = territoryId;
|
||||
}
|
||||
|
@ -344,7 +344,7 @@ Get the current cellId of a region the actor is in
|
|||
|
||||
\return CellId
|
||||
*/
|
||||
Sapphire::Common::CellId Sapphire::Entity::GameObject::getCellId() const
|
||||
CellId GameObject::getCellId() const
|
||||
{
|
||||
return m_cellId;
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ Set the current cellId the actor is in
|
|||
|
||||
\param CellId for the cell to be set
|
||||
*/
|
||||
void Sapphire::Entity::GameObject::setCellId( Common::CellId cellId )
|
||||
void GameObject::setCellId( CellId cellId )
|
||||
{
|
||||
m_cellId = cellId;
|
||||
}
|
||||
|
|
|
@ -1,20 +1,14 @@
|
|||
#include <Network/PacketContainer.h>
|
||||
#include "Action/Action.h"
|
||||
#include "Territory/Territory.h"
|
||||
|
||||
#include "Player.h"
|
||||
#include "Npc.h"
|
||||
#include "Common.h"
|
||||
|
||||
using namespace Sapphire::Entity;
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
using namespace Sapphire::Network::Packets::WorldPackets::Server;
|
||||
|
||||
Sapphire::Entity::Npc::Npc( ObjKind type ) : Chara( type )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Sapphire::Entity::Npc::~Npc()
|
||||
Npc::Npc( ObjKind type ) : Chara( type )
|
||||
{
|
||||
}
|
||||
|
||||
Npc::~Npc()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -642,7 +642,7 @@ void Player::levelUp()
|
|||
m_mp = getMaxMp();
|
||||
|
||||
setLevel( getLevel() + 1 );
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds( true ), *this, LevelUpEffect, static_cast< uint8_t >( getClass() ), getLevel(), getLevel() - 1 );
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds( true ), getId(), LevelUpEffect, static_cast< uint8_t >( getClass() ), getLevel(), getLevel() - 1 );
|
||||
|
||||
auto& achvMgr = Common::Service< World::Manager::AchievementMgr >::ref();
|
||||
achvMgr.progressAchievementByType< Common::Achievement::Type::Classjob >( *this, static_cast< uint32_t >( getClass() ) );
|
||||
|
@ -718,7 +718,7 @@ void Player::setClassJob( Common::ClassJob classJob )
|
|||
m_tp = 0;
|
||||
|
||||
Network::Util::Packet::sendStatusUpdate( *this );
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds( true ), *this, ClassJobChange, 4 );
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds( true ), getId(), ClassJobChange, 4 );
|
||||
Network::Util::Packet::sendHudParam( *this );
|
||||
Service< World::Manager::MapMgr >::ref().updateQuests( *this );
|
||||
}
|
||||
|
@ -1193,7 +1193,7 @@ void Player::setTitle( uint16_t titleId )
|
|||
return;
|
||||
|
||||
m_activeTitle = titleId;
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds( true ), *this, SetTitle, titleId );
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds( true ), getId(), SetTitle, titleId );
|
||||
}
|
||||
|
||||
const Player::AchievementData& Player::getAchievementData() const
|
||||
|
@ -1258,7 +1258,7 @@ void Player::setCompanion( uint8_t id )
|
|||
|
||||
m_companionId = id;
|
||||
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds( true ), *this, ToggleCompanion, id );
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds( true ), getId(), ToggleCompanion, id );
|
||||
}
|
||||
|
||||
uint8_t Player::getCurrentCompanion() const
|
||||
|
@ -1826,7 +1826,7 @@ void Player::setFalling( bool state, const Common::FFXIVARR_POSITION3& pos, bool
|
|||
// no mercy on hated players
|
||||
takeDamage( damage );
|
||||
}
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds( true ), *this, SetFallDamage, damage );
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds( true ), getId(), SetFallDamage, damage );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,31 +6,30 @@
|
|||
#include "Actor/Player.h"
|
||||
|
||||
#include "Territory/Territory.h"
|
||||
#include "WorldServer.h"
|
||||
|
||||
#include "Action/EventAction.h"
|
||||
#include "Manager/PlayerMgr.h"
|
||||
#include "Service.h"
|
||||
#include <Network/PacketWrappers/RestingPacket.h>
|
||||
#include <Network/Util/PacketUtil.h>
|
||||
|
||||
using namespace Sapphire;
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire::Entity;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
using namespace Sapphire::Network::Packets::WorldPackets::Server;
|
||||
using namespace Sapphire::World::Manager;
|
||||
|
||||
void Sapphire::Entity::Player::addEvent( Event::EventHandlerPtr pEvent )
|
||||
void Player::addEvent( Event::EventHandlerPtr pEvent )
|
||||
{
|
||||
m_eventHandlerMap[ pEvent->getId() ] = pEvent;
|
||||
}
|
||||
|
||||
std::map< uint32_t, Sapphire::Event::EventHandlerPtr >& Sapphire::Entity::Player::getEventListRef()
|
||||
std::map< uint32_t, Event::EventHandlerPtr >& Player::getEventListRef()
|
||||
{
|
||||
return m_eventHandlerMap;
|
||||
}
|
||||
|
||||
Sapphire::Event::EventHandlerPtr Sapphire::Entity::Player::getEvent( uint32_t eventId ) const
|
||||
Event::EventHandlerPtr Player::getEvent( uint32_t eventId ) const
|
||||
{
|
||||
auto it = m_eventHandlerMap.find( eventId );
|
||||
if( it != m_eventHandlerMap.end() )
|
||||
|
@ -39,12 +38,12 @@ Sapphire::Event::EventHandlerPtr Sapphire::Entity::Player::getEvent( uint32_t ev
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
size_t Sapphire::Entity::Player::getEventCount()
|
||||
size_t Player::getEventCount()
|
||||
{
|
||||
return m_eventHandlerMap.size();
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::removeEvent( uint32_t eventId )
|
||||
void Player::removeEvent( uint32_t eventId )
|
||||
{
|
||||
auto it = m_eventHandlerMap.find( eventId );
|
||||
if( it != m_eventHandlerMap.end() )
|
||||
|
@ -55,13 +54,13 @@ void Sapphire::Entity::Player::removeEvent( uint32_t eventId )
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Sapphire::Entity::Player::onDeath()
|
||||
void Player::onDeath()
|
||||
{
|
||||
Service< World::Manager::PlayerMgr >::ref().onDeath( *this );
|
||||
}
|
||||
|
||||
// TODO: slightly ugly here and way too static. Needs too be done properly
|
||||
void Sapphire::Entity::Player::onTick()
|
||||
void Player::onTick()
|
||||
{
|
||||
Chara::onTick();
|
||||
// add 3 seconds to total play time
|
||||
|
@ -76,7 +75,7 @@ void Sapphire::Entity::Player::onTick()
|
|||
Network::Util::Packet::sendRestingUpdate( *this );
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::Player::performResting()
|
||||
bool Player::performResting()
|
||||
{
|
||||
bool sendUpdate = false;
|
||||
auto addHp = static_cast< uint32_t >( static_cast< float >( getMaxHp() ) * 0.1f + 1 );
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
|
||||
#include <Service.h>
|
||||
|
||||
using namespace Sapphire;
|
||||
using namespace Sapphire::Entity;
|
||||
using namespace Sapphire::World;
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire::World::Manager;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
|
@ -34,7 +37,7 @@ using namespace Sapphire::Network::Packets::WorldPackets::Server;
|
|||
using namespace Sapphire::Network::ActorControl;
|
||||
|
||||
|
||||
void Sapphire::Entity::Player::initInventory()
|
||||
void Player::initInventory()
|
||||
{
|
||||
const uint8_t inventorySize = 25;
|
||||
auto setupContainer = [ this ]( InventoryType type, uint8_t maxSize, const std::string& tableName,
|
||||
|
@ -103,9 +106,9 @@ void Sapphire::Entity::Player::initInventory()
|
|||
calculateItemLevel();
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::equipWeapon( const Item& item )
|
||||
void Player::equipWeapon( const Item& item )
|
||||
{
|
||||
auto& exdData = Common::Service< Sapphire::Data::ExdData >::ref();
|
||||
auto& exdData = Common::Service< Data::ExdData >::ref();
|
||||
|
||||
auto itemInfo = exdData.getRow< Excel::Item >( item.getId() );
|
||||
auto itemClassJob = itemInfo->data().Class;
|
||||
|
@ -119,9 +122,9 @@ void Sapphire::Entity::Player::equipWeapon( const Item& item )
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::equipSoulCrystal( const Item& item )
|
||||
void Player::equipSoulCrystal( const Item& item )
|
||||
{
|
||||
auto& exdData = Common::Service< Sapphire::Data::ExdData >::ref();
|
||||
auto& exdData = Common::Service< Data::ExdData >::ref();
|
||||
|
||||
auto itemInfo = exdData.getRow< Excel::Item >( item.getId() );
|
||||
auto itemClassJob = itemInfo->data().Class;
|
||||
|
@ -131,7 +134,7 @@ void Sapphire::Entity::Player::equipSoulCrystal( const Item& item )
|
|||
setClassJob( newClassJob );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::updateModels( GearSetSlot equipSlotId, const Sapphire::Item& item )
|
||||
void Player::updateModels( GearSetSlot equipSlotId, const Sapphire::Item& item )
|
||||
{
|
||||
uint64_t model = item.getModelId1();
|
||||
uint64_t model2 = item.getModelId2();
|
||||
|
@ -169,7 +172,7 @@ void Sapphire::Entity::Player::updateModels( GearSetSlot equipSlotId, const Sapp
|
|||
}
|
||||
}
|
||||
|
||||
Sapphire::Common::GearModelSlot Sapphire::Entity::Player::equipSlotToModelSlot( Common::GearSetSlot slot )
|
||||
Common::GearModelSlot Player::equipSlotToModelSlot( Common::GearSetSlot slot )
|
||||
{
|
||||
switch( slot )
|
||||
{
|
||||
|
@ -203,7 +206,7 @@ Sapphire::Common::GearModelSlot Sapphire::Entity::Player::equipSlotToModelSlot(
|
|||
}
|
||||
|
||||
// equip an item
|
||||
void Sapphire::Entity::Player::equipItem( Common::GearSetSlot equipSlotId, Item& item, bool sendUpdate )
|
||||
void Player::equipItem( Common::GearSetSlot equipSlotId, Item& item, bool sendUpdate )
|
||||
{
|
||||
switch( equipSlotId )
|
||||
{
|
||||
|
@ -233,7 +236,7 @@ void Sapphire::Entity::Player::equipItem( Common::GearSetSlot equipSlotId, Item&
|
|||
}
|
||||
|
||||
|
||||
void Sapphire::Entity::Player::unequipItem( Common::GearSetSlot equipSlotId, Item& item, bool sendUpdate )
|
||||
void Player::unequipItem( Common::GearSetSlot equipSlotId, Item& item, bool sendUpdate )
|
||||
{
|
||||
auto modelSlot = equipSlotToModelSlot( equipSlotId );
|
||||
if( modelSlot != GearModelSlot::ModelInvalid )
|
||||
|
@ -254,7 +257,7 @@ void Sapphire::Entity::Player::unequipItem( Common::GearSetSlot equipSlotId, Ite
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::unequipSoulCrystal()
|
||||
void Player::unequipSoulCrystal()
|
||||
{
|
||||
auto& exdData = Common::Service< Sapphire::Data::ExdData >::ref();
|
||||
|
||||
|
@ -263,7 +266,7 @@ void Sapphire::Entity::Player::unequipSoulCrystal()
|
|||
setClassJob( parentClass );
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::Player::currencyTypeToItem( Common::CurrencyType type ) const
|
||||
uint32_t Player::currencyTypeToItem( Common::CurrencyType type ) const
|
||||
{
|
||||
switch( type )
|
||||
{
|
||||
|
@ -301,7 +304,7 @@ uint32_t Sapphire::Entity::Player::currencyTypeToItem( Common::CurrencyType type
|
|||
}
|
||||
|
||||
// TODO: these next functions are so similar that they could likely be simplified
|
||||
void Sapphire::Entity::Player::addCurrency( CurrencyType type, uint32_t amount )
|
||||
void Player::addCurrency( CurrencyType type, uint32_t amount )
|
||||
{
|
||||
auto slot = static_cast< uint8_t >( static_cast< uint8_t >( type ) - 1 );
|
||||
auto currItem = m_storageMap[ Currency ]->getItem( slot );
|
||||
|
@ -339,7 +342,7 @@ void Sapphire::Entity::Player::addCurrency( CurrencyType type, uint32_t amount )
|
|||
server().queueForPlayer( getCharacterId(), invTransFinPacket );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::removeCurrency( Common::CurrencyType type, uint32_t amount )
|
||||
void Player::removeCurrency( Common::CurrencyType type, uint32_t amount )
|
||||
{
|
||||
|
||||
auto currItem = m_storageMap[ Currency ]->getItem( static_cast< uint8_t >( type ) - 1 );
|
||||
|
@ -373,7 +376,7 @@ void Sapphire::Entity::Player::removeCurrency( Common::CurrencyType type, uint32
|
|||
}
|
||||
|
||||
|
||||
void Sapphire::Entity::Player::addCrystal( Common::CrystalType type, uint32_t amount )
|
||||
void Player::addCrystal( Common::CrystalType type, uint32_t amount )
|
||||
{
|
||||
auto currItem = m_storageMap[ Crystal ]->getItem( static_cast< uint8_t >( type ) - 1 );
|
||||
|
||||
|
@ -412,7 +415,7 @@ void Sapphire::Entity::Player::addCrystal( Common::CrystalType type, uint32_t am
|
|||
server().queueForPlayer( getCharacterId(), makeActorControlSelf( getId(), ItemObtainIcon, static_cast< uint8_t >( type ) + 1, amount ) );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::removeCrystal( Common::CrystalType type, uint32_t amount )
|
||||
void Player::removeCrystal( Common::CrystalType type, uint32_t amount )
|
||||
{
|
||||
auto currItem = m_storageMap[ Crystal ]->getItem( static_cast< uint8_t >( type ) - 1 );
|
||||
|
||||
|
@ -446,9 +449,9 @@ void Sapphire::Entity::Player::removeCrystal( Common::CrystalType type, uint32_t
|
|||
server().queueForPlayer( getCharacterId(), invTransFinPacket );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::sendInventory()
|
||||
void Player::sendInventory()
|
||||
{
|
||||
auto& invMgr = Common::Service< World::Manager::InventoryMgr >::ref();
|
||||
auto& invMgr = Common::Service< Manager::InventoryMgr >::ref();
|
||||
|
||||
for( auto& it : m_storageMap )
|
||||
{
|
||||
|
@ -456,14 +459,14 @@ void Sapphire::Entity::Player::sendInventory()
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::sendGearInventory()
|
||||
void Player::sendGearInventory()
|
||||
{
|
||||
auto& invMgr = Common::Service< World::Manager::InventoryMgr >::ref();
|
||||
auto& invMgr = Common::Service< Manager::InventoryMgr >::ref();
|
||||
|
||||
invMgr.sendInventoryContainer( *this, m_storageMap[ GearSet0 ] );
|
||||
}
|
||||
|
||||
Sapphire::Entity::Player::InvSlotPairVec Sapphire::Entity::Player::getSlotsOfItemsInInventory( uint32_t catalogId )
|
||||
Player::InvSlotPairVec Player::getSlotsOfItemsInInventory( uint32_t catalogId )
|
||||
{
|
||||
InvSlotPairVec outVec;
|
||||
for( auto i : { Bag0, Bag1, Bag2, Bag3 } )
|
||||
|
@ -478,7 +481,7 @@ Sapphire::Entity::Player::InvSlotPairVec Sapphire::Entity::Player::getSlotsOfIte
|
|||
return outVec;
|
||||
}
|
||||
|
||||
Sapphire::Entity::Player::InvSlotPair Sapphire::Entity::Player::getFreeBagSlot()
|
||||
Player::InvSlotPair Player::getFreeBagSlot()
|
||||
{
|
||||
for( auto i : { Bag0, Bag1, Bag2, Bag3 } )
|
||||
{
|
||||
|
@ -491,7 +494,7 @@ Sapphire::Entity::Player::InvSlotPair Sapphire::Entity::Player::getFreeBagSlot()
|
|||
return std::make_pair( 0, -1 );
|
||||
}
|
||||
|
||||
Sapphire::Entity::Player::InvSlotPair Sapphire::Entity::Player::getFreeContainerSlot( uint32_t containerId )
|
||||
Player::InvSlotPair Player::getFreeContainerSlot( uint32_t containerId )
|
||||
{
|
||||
auto freeSlot = static_cast< int8_t >( m_storageMap[ containerId ]->getFreeSlot() );
|
||||
|
||||
|
@ -502,13 +505,13 @@ Sapphire::Entity::Player::InvSlotPair Sapphire::Entity::Player::getFreeContainer
|
|||
return std::make_pair( 0, -1 );
|
||||
}
|
||||
|
||||
Sapphire::ItemPtr Sapphire::Entity::Player::getItemAt( uint16_t containerId, uint16_t slotId )
|
||||
ItemPtr Player::getItemAt( uint16_t containerId, uint16_t slotId )
|
||||
{
|
||||
return m_storageMap[ containerId ]->getItem( slotId );
|
||||
}
|
||||
|
||||
|
||||
uint32_t Sapphire::Entity::Player::getCurrency( CurrencyType type )
|
||||
uint32_t Player::getCurrency( CurrencyType type )
|
||||
{
|
||||
|
||||
auto currItem = m_storageMap[ Currency ]->getItem( static_cast< uint8_t >( type ) - 1 );
|
||||
|
@ -520,7 +523,7 @@ uint32_t Sapphire::Entity::Player::getCurrency( CurrencyType type )
|
|||
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::Player::getCrystal( CrystalType type )
|
||||
uint32_t Player::getCrystal( CrystalType type )
|
||||
{
|
||||
|
||||
auto currItem = m_storageMap[ Crystal ]->getItem( static_cast< uint8_t >( type ) - 1 );
|
||||
|
@ -532,7 +535,7 @@ uint32_t Sapphire::Entity::Player::getCrystal( CrystalType type )
|
|||
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::writeInventory( InventoryType type )
|
||||
void Player::writeInventory( InventoryType type )
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
|
||||
|
@ -561,7 +564,7 @@ void Sapphire::Entity::Player::writeInventory( InventoryType type )
|
|||
db.execute( query );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::writeItem( Sapphire::ItemPtr pItem ) const
|
||||
void Player::writeItem( ItemPtr pItem ) const
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
auto stmt = db.getPreparedStatement( Db::CHARA_ITEMGLOBAL_UP );
|
||||
|
@ -577,7 +580,7 @@ void Sapphire::Entity::Player::writeItem( Sapphire::ItemPtr pItem ) const
|
|||
db.directExecute( stmt );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::writeCurrencyItem( CurrencyType type )
|
||||
void Player::writeCurrencyItem( CurrencyType type )
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
|
||||
|
@ -590,7 +593,7 @@ void Sapphire::Entity::Player::writeCurrencyItem( CurrencyType type )
|
|||
db.execute( query );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::deleteItemDb( Sapphire::ItemPtr item ) const
|
||||
void Player::deleteItemDb( ItemPtr item ) const
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
auto stmt = db.getPreparedStatement( Db::CHARA_ITEMGLOBAL_DELETE );
|
||||
|
@ -601,14 +604,14 @@ void Sapphire::Entity::Player::deleteItemDb( Sapphire::ItemPtr item ) const
|
|||
}
|
||||
|
||||
|
||||
bool Sapphire::Entity::Player::isObtainable( uint32_t catalogId, uint8_t quantity )
|
||||
bool Player::isObtainable( uint32_t catalogId, uint8_t quantity )
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Sapphire::ItemPtr Sapphire::Entity::Player::addItem( uint32_t catalogId, uint32_t quantity, bool isHq, bool silent, bool canMerge )
|
||||
ItemPtr Player::addItem( uint32_t catalogId, uint32_t quantity, bool isHq, bool silent, bool canMerge )
|
||||
{
|
||||
auto& exdData = Common::Service< Data::ExdData >::ref();
|
||||
auto itemInfo = exdData.getRow< Excel::Item >( catalogId );
|
||||
|
@ -741,7 +744,7 @@ Sapphire::ItemPtr Sapphire::Entity::Player::addItem( uint32_t catalogId, uint32_
|
|||
return item;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::Player::removeItem( uint32_t catalogId, uint32_t quantity, bool isHq )
|
||||
bool Player::removeItem( uint32_t catalogId, uint32_t quantity, bool isHq )
|
||||
{
|
||||
std::vector< uint16_t > bags = { Bag0, Bag1, Bag2, Bag3 };
|
||||
|
||||
|
@ -790,7 +793,7 @@ bool Sapphire::Entity::Player::removeItem( uint32_t catalogId, uint32_t quantity
|
|||
}
|
||||
|
||||
void
|
||||
Sapphire::Entity::Player::moveItem( uint16_t fromInventoryId, uint16_t fromSlotId, uint16_t toInventoryId, uint16_t toSlot )
|
||||
Player::moveItem( uint16_t fromInventoryId, uint16_t fromSlotId, uint16_t toInventoryId, uint16_t toSlot )
|
||||
{
|
||||
|
||||
auto tmpItem = m_storageMap[ fromInventoryId ]->getItem( fromSlotId );
|
||||
|
@ -819,9 +822,9 @@ Sapphire::Entity::Player::moveItem( uint16_t fromInventoryId, uint16_t fromSlotI
|
|||
sendStatusEffectUpdate(); // send if any equip is changed
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::Player::updateContainer( uint16_t storageId, uint16_t slotId, ItemPtr pItem )
|
||||
bool Player::updateContainer( uint16_t storageId, uint16_t slotId, ItemPtr pItem )
|
||||
{
|
||||
auto containerType = World::Manager::ItemMgr::getContainerType( storageId );
|
||||
auto containerType = Manager::ItemMgr::getContainerType( storageId );
|
||||
|
||||
auto pOldItem = getItemAt( storageId, slotId );
|
||||
m_storageMap[ storageId ]->setItem( slotId, pItem );
|
||||
|
@ -857,8 +860,7 @@ bool Sapphire::Entity::Player::updateContainer( uint16_t storageId, uint16_t slo
|
|||
return true;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::splitItem( uint16_t fromInventoryId, uint16_t fromSlotId,
|
||||
uint16_t toInventoryId, uint16_t toSlot, uint16_t itemCount )
|
||||
void Player::splitItem( uint16_t fromInventoryId, uint16_t fromSlotId, uint16_t toInventoryId, uint16_t toSlot, uint16_t itemCount )
|
||||
{
|
||||
if( itemCount == 0 )
|
||||
return;
|
||||
|
@ -890,8 +892,7 @@ void Sapphire::Entity::Player::splitItem( uint16_t fromInventoryId, uint16_t fro
|
|||
writeItem( fromItem );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::mergeItem( uint16_t fromInventoryId, uint16_t fromSlotId,
|
||||
uint16_t toInventoryId, uint16_t toSlot )
|
||||
void Player::mergeItem( uint16_t fromInventoryId, uint16_t fromSlotId, uint16_t toInventoryId, uint16_t toSlot )
|
||||
{
|
||||
auto fromItem = m_storageMap[ fromInventoryId ]->getItem( fromSlotId );
|
||||
auto toItem = m_storageMap[ toInventoryId ]->getItem( toSlot );
|
||||
|
@ -925,8 +926,7 @@ void Sapphire::Entity::Player::mergeItem( uint16_t fromInventoryId, uint16_t fro
|
|||
updateContainer( toInventoryId, toSlot, toItem );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::swapItem( uint16_t fromInventoryId, uint16_t fromSlotId,
|
||||
uint16_t toInventoryId, uint16_t toSlot )
|
||||
void Player::swapItem( uint16_t fromInventoryId, uint16_t fromSlotId, uint16_t toInventoryId, uint16_t toSlot )
|
||||
{
|
||||
auto fromItem = m_storageMap[ fromInventoryId ]->getItem( fromSlotId );
|
||||
auto toItem = m_storageMap[ toInventoryId ]->getItem( toSlot );
|
||||
|
@ -959,7 +959,7 @@ void Sapphire::Entity::Player::swapItem( uint16_t fromInventoryId, uint16_t from
|
|||
sendStatusEffectUpdate(); // send if any equip is changed
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::discardItem( uint16_t fromInventoryId, uint16_t fromSlotId )
|
||||
void Player::discardItem( uint16_t fromInventoryId, uint16_t fromSlotId )
|
||||
{
|
||||
// i am not entirely sure how this should be generated or if it even is important for us...
|
||||
uint32_t sequence = getNextInventorySequence();
|
||||
|
@ -988,7 +988,7 @@ void Sapphire::Entity::Player::discardItem( uint16_t fromInventoryId, uint16_t f
|
|||
server().queueForPlayer( getCharacterId(), invTransFinPacket );
|
||||
}
|
||||
|
||||
uint16_t Sapphire::Entity::Player::calculateItemLevel()
|
||||
uint16_t Player::calculateItemLevel()
|
||||
{
|
||||
uint32_t iLvlResult = 0;
|
||||
|
||||
|
@ -1020,7 +1020,7 @@ uint16_t Sapphire::Entity::Player::calculateItemLevel()
|
|||
return ilvl;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::calculateBonusStats()
|
||||
void Player::calculateBonusStats()
|
||||
{
|
||||
m_bonusStats.fill( 0 );
|
||||
|
||||
|
@ -1052,12 +1052,12 @@ void Sapphire::Entity::Player::calculateBonusStats()
|
|||
}
|
||||
|
||||
|
||||
Sapphire::ItemPtr Sapphire::Entity::Player::getEquippedWeapon()
|
||||
ItemPtr Player::getEquippedWeapon()
|
||||
{
|
||||
return m_storageMap[ GearSet0 ]->getItem( GearSetSlot::MainHand );
|
||||
}
|
||||
|
||||
uint16_t Sapphire::Entity::Player::getFreeSlotsInBags()
|
||||
uint16_t Player::getFreeSlotsInBags()
|
||||
{
|
||||
uint16_t slots = 0;
|
||||
for( uint8_t container : { Bag0, Bag1, Bag2, Bag3 } )
|
||||
|
@ -1068,7 +1068,7 @@ uint16_t Sapphire::Entity::Player::getFreeSlotsInBags()
|
|||
return slots;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::Player::collectHandInItems( std::vector< uint32_t > itemIds )
|
||||
bool Player::collectHandInItems( std::vector< uint32_t > itemIds )
|
||||
{
|
||||
// todo: figure out how the game gets the required stack count
|
||||
const auto& container = m_storageMap[ HandIn ];
|
||||
|
@ -1102,12 +1102,12 @@ bool Sapphire::Entity::Player::collectHandInItems( std::vector< uint32_t > itemI
|
|||
return true;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::Player::getNextInventorySequence()
|
||||
uint32_t Player::getNextInventorySequence()
|
||||
{
|
||||
return m_inventorySequence++;
|
||||
}
|
||||
|
||||
Sapphire::ItemPtr Sapphire::Entity::Player::dropInventoryItem( Sapphire::Common::InventoryType storageId, uint8_t slotId )
|
||||
ItemPtr Player::dropInventoryItem( Sapphire::Common::InventoryType storageId, uint8_t slotId )
|
||||
{
|
||||
auto& container = m_storageMap[ storageId ];
|
||||
|
||||
|
@ -1141,24 +1141,24 @@ Sapphire::ItemPtr Sapphire::Entity::Player::dropInventoryItem( Sapphire::Common:
|
|||
return item;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::addSoldItem( uint32_t itemId, uint8_t stackSize )
|
||||
void Player::addSoldItem( uint32_t itemId, uint8_t stackSize )
|
||||
{
|
||||
if( m_soldItems.size() > 10 )
|
||||
m_soldItems.pop_back();
|
||||
m_soldItems.emplace_front( itemId, stackSize );
|
||||
}
|
||||
|
||||
std::deque< std::pair< uint32_t, uint8_t > > *Sapphire::Entity::Player::getSoldItems()
|
||||
std::deque< std::pair< uint32_t, uint8_t > >* Player::getSoldItems()
|
||||
{
|
||||
return &m_soldItems;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::clearSoldItems()
|
||||
void Player::clearSoldItems()
|
||||
{
|
||||
m_soldItems.clear();
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::Player::getFreeInventoryContainerSlot( Inventory::InventoryContainerPair& containerPair ) const
|
||||
bool Player::getFreeInventoryContainerSlot( Inventory::InventoryContainerPair& containerPair ) const
|
||||
{
|
||||
for( auto bagId : { Bag0, Bag1, Bag2, Bag3 } )
|
||||
{
|
||||
|
@ -1182,8 +1182,7 @@ bool Sapphire::Entity::Player::getFreeInventoryContainerSlot( Inventory::Invento
|
|||
return false;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::insertInventoryItem( Sapphire::Common::InventoryType type, uint16_t slot,
|
||||
const Sapphire::ItemPtr item )
|
||||
void Player::insertInventoryItem( Common::InventoryType type, uint16_t slot, const ItemPtr item )
|
||||
{
|
||||
updateContainer( type, slot, item );
|
||||
|
||||
|
@ -1199,8 +1198,7 @@ void Sapphire::Entity::Player::insertInventoryItem( Sapphire::Common::InventoryT
|
|||
server().queueForPlayer( getCharacterId(), invTransFinPacket );
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::Player::findFirstItemWithId( uint32_t catalogId,
|
||||
Inventory::InventoryContainerPair& location, std::initializer_list< InventoryType > bags )
|
||||
bool Player::findFirstItemWithId( uint32_t catalogId, Inventory::InventoryContainerPair& location, std::initializer_list< InventoryType > bags )
|
||||
{
|
||||
for( auto bagId : bags )
|
||||
{
|
||||
|
|
|
@ -7,16 +7,18 @@
|
|||
|
||||
#include "Player.h"
|
||||
|
||||
|
||||
using namespace Sapphire;
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire::Entity;
|
||||
using namespace Sapphire::World;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
using namespace Sapphire::Network::Packets::WorldPackets::Server;
|
||||
|
||||
void Sapphire::Entity::Player::finishQuest( uint16_t questId, uint32_t optionalChoice )
|
||||
void Player::finishQuest( uint16_t questId, uint32_t optionalChoice )
|
||||
{
|
||||
removeQuest( questId );
|
||||
|
||||
auto& questMgr = Common::Service< World::Manager::QuestMgr >::ref();
|
||||
auto& questMgr = Common::Service< Manager::QuestMgr >::ref();
|
||||
|
||||
updateQuestsCompleted( questId );
|
||||
|
||||
|
@ -24,14 +26,14 @@ void Sapphire::Entity::Player::finishQuest( uint16_t questId, uint32_t optionalC
|
|||
questMgr.onCompleteQuest( *this, questId, optionalChoice );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::unfinishQuest( uint16_t questId )
|
||||
void Player::unfinishQuest( uint16_t questId )
|
||||
{
|
||||
removeQuestsCompleted( questId );
|
||||
auto& questMgr = Common::Service< World::Manager::QuestMgr >::ref();
|
||||
auto& questMgr = Common::Service< Manager::QuestMgr >::ref();
|
||||
questMgr.sendQuestsInfo( *this );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::removeQuest( uint16_t questId )
|
||||
void Player::removeQuest( uint16_t questId )
|
||||
{
|
||||
int8_t idx = getQuestIndex( questId );
|
||||
|
||||
|
@ -41,8 +43,8 @@ void Sapphire::Entity::Player::removeQuest( uint16_t questId )
|
|||
return;
|
||||
}
|
||||
|
||||
auto& questMgr = Common::Service< World::Manager::QuestMgr >::ref();
|
||||
auto& mapMgr = Common::Service< World::Manager::MapMgr >::ref();
|
||||
auto& questMgr = Common::Service< Manager::QuestMgr >::ref();
|
||||
auto& mapMgr = Common::Service< Manager::MapMgr >::ref();
|
||||
|
||||
m_quests[ idx ] = World::Quest();
|
||||
removeQuestTracking( idx );
|
||||
|
@ -53,7 +55,7 @@ void Sapphire::Entity::Player::removeQuest( uint16_t questId )
|
|||
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::removeQuestTracking( int8_t idx )
|
||||
void Player::removeQuestTracking( int8_t idx )
|
||||
{
|
||||
for( int32_t ii = 0; ii < 5; ii++ )
|
||||
{
|
||||
|
@ -62,12 +64,12 @@ void Sapphire::Entity::Player::removeQuestTracking( int8_t idx )
|
|||
}
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::Player::hasQuest( uint32_t questId )
|
||||
bool Player::hasQuest( uint32_t questId )
|
||||
{
|
||||
return ( getQuestIndex( static_cast< uint16_t >( questId ) ) > -1 );
|
||||
}
|
||||
|
||||
int8_t Sapphire::Entity::Player::getQuestIndex( uint16_t questId )
|
||||
int8_t Player::getQuestIndex( uint16_t questId )
|
||||
{
|
||||
for( size_t pos = 0; pos < 30; ++pos )
|
||||
{
|
||||
|
@ -77,7 +79,7 @@ int8_t Sapphire::Entity::Player::getQuestIndex( uint16_t questId )
|
|||
return -1;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::updateQuest( const World::Quest& quest )
|
||||
void Player::updateQuest( const World::Quest& quest )
|
||||
{
|
||||
auto& questMgr = Common::Service< World::Manager::QuestMgr >::ref();
|
||||
auto& mapMgr = Common::Service< World::Manager::MapMgr >::ref();
|
||||
|
@ -93,7 +95,7 @@ void Sapphire::Entity::Player::updateQuest( const World::Quest& quest )
|
|||
addQuest( quest );
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::Player::addQuest( const World::Quest& quest )
|
||||
bool Player::addQuest( const World::Quest& quest )
|
||||
{
|
||||
int8_t idx = getFreeQuestSlot();
|
||||
|
||||
|
@ -103,8 +105,8 @@ bool Sapphire::Entity::Player::addQuest( const World::Quest& quest )
|
|||
return false;
|
||||
}
|
||||
|
||||
auto& questMgr = Common::Service< World::Manager::QuestMgr >::ref();
|
||||
auto& mapMgr = Common::Service< World::Manager::MapMgr >::ref();
|
||||
auto& questMgr = Common::Service< Manager::QuestMgr >::ref();
|
||||
auto& mapMgr = Common::Service< Manager::MapMgr >::ref();
|
||||
|
||||
m_quests[ idx ] = quest;
|
||||
|
||||
|
@ -117,7 +119,7 @@ bool Sapphire::Entity::Player::addQuest( const World::Quest& quest )
|
|||
return true;
|
||||
}
|
||||
|
||||
std::optional< Sapphire::World::Quest > Sapphire::Entity::Player::getQuest( uint32_t questId )
|
||||
std::optional< World::Quest > Player::getQuest( uint32_t questId )
|
||||
{
|
||||
if( !hasQuest( questId ) )
|
||||
return std::nullopt;
|
||||
|
@ -128,7 +130,7 @@ std::optional< Sapphire::World::Quest > Sapphire::Entity::Player::getQuest( uint
|
|||
return { quest };
|
||||
}
|
||||
|
||||
int8_t Sapphire::Entity::Player::getFreeQuestSlot()
|
||||
int8_t Player::getFreeQuestSlot()
|
||||
{
|
||||
int8_t result = -1;
|
||||
for( int8_t idx = 0; idx < 30; idx++ )
|
||||
|
@ -141,7 +143,7 @@ int8_t Sapphire::Entity::Player::getFreeQuestSlot()
|
|||
return result;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::addQuestTracking( uint8_t idx )
|
||||
void Player::addQuestTracking( uint8_t idx )
|
||||
{
|
||||
for( int32_t ii = 0; ii < 5; ii++ )
|
||||
{
|
||||
|
@ -153,7 +155,7 @@ void Sapphire::Entity::Player::addQuestTracking( uint8_t idx )
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::updateQuestsCompleted( uint32_t questId )
|
||||
void Player::updateQuestsCompleted( uint32_t questId )
|
||||
{
|
||||
uint8_t index = questId / 8;
|
||||
uint8_t bitIndex = ( questId ) % 8;
|
||||
|
@ -163,7 +165,7 @@ void Sapphire::Entity::Player::updateQuestsCompleted( uint32_t questId )
|
|||
m_questCompleteFlags[ index ] |= value;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::Player::isQuestCompleted( uint32_t questId )
|
||||
bool Player::isQuestCompleted( uint32_t questId )
|
||||
{
|
||||
uint8_t index = questId / 8;
|
||||
uint8_t bitIndex = ( questId ) % 8;
|
||||
|
@ -173,7 +175,7 @@ bool Sapphire::Entity::Player::isQuestCompleted( uint32_t questId )
|
|||
return m_questCompleteFlags[ index ] & value;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::removeQuestsCompleted( uint32_t questId )
|
||||
void Player::removeQuestsCompleted( uint32_t questId )
|
||||
{
|
||||
uint8_t index = questId / 8;
|
||||
uint8_t bitIndex = ( questId ) % 8;
|
||||
|
@ -182,27 +184,27 @@ void Sapphire::Entity::Player::removeQuestsCompleted( uint32_t questId )
|
|||
|
||||
m_questCompleteFlags[ index ] ^= value;
|
||||
|
||||
Common::Service< World::Manager::MapMgr >::ref().updateQuests( *this );
|
||||
Common::Service< Manager::MapMgr >::ref().updateQuests( *this );
|
||||
}
|
||||
|
||||
Sapphire::World::Quest& Sapphire::Entity::Player::getQuestByIndex( uint16_t index )
|
||||
World::Quest& Player::getQuestByIndex( uint16_t index )
|
||||
{
|
||||
return m_quests[ index ];
|
||||
}
|
||||
|
||||
std::array< Sapphire::World::Quest, 30 >& Sapphire::Entity::Player::getQuestArrayRef()
|
||||
std::array< World::Quest, 30 >& Player::getQuestArrayRef()
|
||||
{
|
||||
return m_quests;
|
||||
}
|
||||
|
||||
int16_t Sapphire::Entity::Player::getQuestTracking( uint8_t index ) const
|
||||
int16_t Player::getQuestTracking( uint8_t index ) const
|
||||
{
|
||||
if( index < 0 || index >= 5 )
|
||||
return -1;
|
||||
return m_questTracking[ index ];
|
||||
}
|
||||
|
||||
Sapphire::Entity::Player::QuestComplete& Sapphire::Entity::Player::getQuestCompleteFlags()
|
||||
Player::QuestComplete& Player::getQuestCompleteFlags()
|
||||
{
|
||||
return m_questCompleteFlags;
|
||||
}
|
||||
|
|
|
@ -16,12 +16,14 @@
|
|||
|
||||
#include "WorldServer.h"
|
||||
|
||||
using namespace Sapphire;
|
||||
using namespace Sapphire::Entity;
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
using namespace Sapphire::Network::Packets::WorldPackets::Server;
|
||||
using namespace Sapphire::World::Manager;
|
||||
|
||||
bool Sapphire::Entity::Player::loadFromDb( uint64_t characterId )
|
||||
bool Player::loadFromDb( uint64_t characterId )
|
||||
{
|
||||
m_characterId = characterId;
|
||||
|
||||
|
@ -181,7 +183,7 @@ bool Sapphire::Entity::Player::loadFromDb( uint64_t characterId )
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::Player::loadActiveQuests()
|
||||
bool Player::loadActiveQuests()
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
auto stmt = db.getPreparedStatement( Db::ZoneDbStatements::CHARA_SEL_QUEST );
|
||||
|
@ -194,7 +196,6 @@ bool Sapphire::Entity::Player::loadActiveQuests()
|
|||
|
||||
while( res->next() )
|
||||
{
|
||||
|
||||
auto slotId = res->getUInt8( 2 );
|
||||
|
||||
auto quest = World::Quest( res->getUInt16( 3 ), res->getUInt8( 4 ), res->getUInt8( 5 ) );
|
||||
|
@ -205,14 +206,13 @@ bool Sapphire::Entity::Player::loadActiveQuests()
|
|||
quest.setUI8E( res->getUInt8( 10 ) );
|
||||
quest.setUI8F( res->getUInt8( 11 ) );
|
||||
m_quests[ slotId ] = quest;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::Player::loadAchievements()
|
||||
bool Player::loadAchievements()
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
auto stmt = db.getPreparedStatement( Db::ZoneDbStatements::CHARA_ACHIEV_SEL );
|
||||
|
@ -255,7 +255,7 @@ bool Sapphire::Entity::Player::loadAchievements()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::Player::loadClassData()
|
||||
bool Player::loadClassData()
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
// ClassIdx, Exp, Lvl
|
||||
|
@ -276,7 +276,7 @@ bool Sapphire::Entity::Player::loadClassData()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::Player::loadSearchInfo()
|
||||
bool Player::loadSearchInfo()
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
auto stmt = db.getPreparedStatement( Db::ZoneDbStatements::CHARA_SEL_SEARCHINFO );
|
||||
|
@ -301,7 +301,7 @@ bool Sapphire::Entity::Player::loadSearchInfo()
|
|||
}
|
||||
|
||||
|
||||
bool Sapphire::Entity::Player::loadHuntingLog()
|
||||
bool Player::loadHuntingLog()
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
auto stmt = db.getPreparedStatement( Db::ZoneDbStatements::CHARA_MONSTERNOTE_SEL );
|
||||
|
@ -324,7 +324,7 @@ bool Sapphire::Entity::Player::loadHuntingLog()
|
|||
return true;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::updateSql()
|
||||
void Player::updateSql()
|
||||
{
|
||||
////// Update player data
|
||||
updateDbChara();
|
||||
|
@ -354,7 +354,7 @@ void Sapphire::Entity::Player::updateSql()
|
|||
syncLastDBWrite();
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::updateDbChara() const
|
||||
void Player::updateDbChara() const
|
||||
{
|
||||
auto& db = Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
/*"Hp 1, Mp 2, Tp 3, Gp 4, Mode 5, Mount 6, InvincibleGM 7, Voice 8, "
|
||||
|
@ -482,7 +482,7 @@ void Sapphire::Entity::Player::updateDbChara() const
|
|||
db.execute( stmt );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::updateDbClass() const
|
||||
void Player::updateDbClass() const
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
auto& exdData = Common::Service< Data::ExdData >::ref();
|
||||
|
@ -497,7 +497,7 @@ void Sapphire::Entity::Player::updateDbClass() const
|
|||
db.execute( stmtS );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::updateDbMonsterNote()
|
||||
void Player::updateDbMonsterNote()
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
// Category_0-11
|
||||
|
@ -515,7 +515,7 @@ void Sapphire::Entity::Player::updateDbMonsterNote()
|
|||
db.execute( stmt );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::updateDbFriendList()
|
||||
void Player::updateDbFriendList()
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
|
||||
|
@ -533,7 +533,7 @@ void Sapphire::Entity::Player::updateDbFriendList()
|
|||
}
|
||||
|
||||
|
||||
void Sapphire::Entity::Player::updateDbBlacklist()
|
||||
void Player::updateDbBlacklist()
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
|
||||
|
@ -547,7 +547,7 @@ void Sapphire::Entity::Player::updateDbBlacklist()
|
|||
db.execute( stmt );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::updateDbAchievement()
|
||||
void Player::updateDbAchievement()
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
|
||||
|
@ -577,7 +577,7 @@ void Sapphire::Entity::Player::updateDbAchievement()
|
|||
}
|
||||
|
||||
|
||||
void Sapphire::Entity::Player::insertDbClass( const uint8_t classJobIndex, uint8_t level ) const
|
||||
void Player::insertDbClass( const uint8_t classJobIndex, uint8_t level ) const
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
auto stmtClass = db.getPreparedStatement( Db::CHARA_CLASS_INS );
|
||||
|
@ -588,7 +588,7 @@ void Sapphire::Entity::Player::insertDbClass( const uint8_t classJobIndex, uint8
|
|||
db.directExecute( stmtClass );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::updateDbSearchInfo() const
|
||||
void Player::updateDbSearchInfo() const
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
auto stmtS = db.getPreparedStatement( Db::CHARA_SEARCHINFO_UP_SELECTCLASS );
|
||||
|
@ -607,7 +607,7 @@ void Sapphire::Entity::Player::updateDbSearchInfo() const
|
|||
db.execute( stmtS2 );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::updateDbAllQuests() const
|
||||
void Player::updateDbAllQuests() const
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
for( int32_t i = 0; i < 30; i++ )
|
||||
|
@ -633,7 +633,7 @@ void Sapphire::Entity::Player::updateDbAllQuests() const
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::deleteDbQuest( uint16_t questId ) const
|
||||
void Player::deleteDbQuest( uint16_t questId ) const
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
auto stmt = db.getPreparedStatement( Db::CHARA_QUEST_DEL );
|
||||
|
@ -642,7 +642,7 @@ void Sapphire::Entity::Player::deleteDbQuest( uint16_t questId ) const
|
|||
db.execute( stmt );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::insertDbQuest( uint16_t questId, uint8_t index, uint8_t seq ) const
|
||||
void Player::insertDbQuest( uint16_t questId, uint8_t index, uint8_t seq ) const
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
auto stmt = db.getPreparedStatement( Db::CHARA_QUEST_INS );
|
||||
|
@ -661,7 +661,7 @@ void Sapphire::Entity::Player::insertDbQuest( uint16_t questId, uint8_t index, u
|
|||
db.execute( stmt );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::insertDbQuest( const World::Quest& quest, uint8_t index ) const
|
||||
void Player::insertDbQuest( const World::Quest& quest, uint8_t index ) const
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
auto stmt = db.getPreparedStatement( Db::CHARA_QUEST_INS );
|
||||
|
@ -680,7 +680,7 @@ void Sapphire::Entity::Player::insertDbQuest( const World::Quest& quest, uint8_t
|
|||
db.execute( stmt );
|
||||
}
|
||||
|
||||
Sapphire::ItemPtr Sapphire::Entity::Player::createItem( uint32_t catalogId, uint32_t quantity )
|
||||
ItemPtr Player::createItem( uint32_t catalogId, uint32_t quantity )
|
||||
{
|
||||
auto& exdData = Common::Service< Data::ExdData >::ref();
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
|
@ -707,7 +707,7 @@ Sapphire::ItemPtr Sapphire::Entity::Player::createItem( uint32_t catalogId, uint
|
|||
return pItem;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::Player::loadInventory()
|
||||
bool Player::loadInventory()
|
||||
{
|
||||
auto& itemMgr = Common::Service< World::Manager::ItemMgr >::ref();
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
|
@ -806,7 +806,7 @@ bool Sapphire::Entity::Player::loadInventory()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::Player::loadFriendList()
|
||||
bool Player::loadFriendList()
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
auto stmt = db.getPreparedStatement( Db::ZoneDbStatements::CHARA_FRIENDLIST_SEL );
|
||||
|
@ -831,7 +831,7 @@ bool Sapphire::Entity::Player::loadFriendList()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::Player::loadBlacklist()
|
||||
bool Player::loadBlacklist()
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
auto stmt = db.getPreparedStatement( Db::ZoneDbStatements::CHARA_BLACKLIST_SEL );
|
||||
|
@ -853,7 +853,7 @@ bool Sapphire::Entity::Player::loadBlacklist()
|
|||
}
|
||||
|
||||
|
||||
bool Sapphire::Entity::Player::syncLastDBWrite()
|
||||
bool Player::syncLastDBWrite()
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
auto res = db.query( "SELECT UNIX_TIMESTAMP(UPDATE_DATE) FROM charainfo WHERE characterid = " + std::to_string( m_characterId ) );
|
||||
|
|
|
@ -18,13 +18,15 @@
|
|||
|
||||
#include <WorldServer.h>
|
||||
|
||||
using namespace Sapphire;
|
||||
using namespace Sapphire::World;
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
using namespace Sapphire::Network::Packets::WorldPackets;
|
||||
using namespace Sapphire::Network::Packets::WorldPackets::Server;
|
||||
using namespace Sapphire::World::Manager;
|
||||
|
||||
void Sapphire::World::ContentFinder::update()
|
||||
void World::ContentFinder::update()
|
||||
{
|
||||
auto& exdData = Service< Data::ExdData >::ref();
|
||||
auto& server = Service< WorldServer >::ref();
|
||||
|
@ -114,19 +116,19 @@ void Sapphire::World::ContentFinder::update()
|
|||
|
||||
}
|
||||
|
||||
void Sapphire::World::ContentFinder::registerContentsRequest( Sapphire::Entity::Player &player, const std::vector< uint32_t >& contentIds )
|
||||
void World::ContentFinder::registerContentsRequest( Entity::Player &player, const std::vector< uint32_t >& contentIds )
|
||||
{
|
||||
queueForContent( player, contentIds );
|
||||
completeRegistration( player );
|
||||
}
|
||||
|
||||
void Sapphire::World::ContentFinder::registerContentRequest( Sapphire::Entity::Player &player, uint32_t contentId, uint8_t flags )
|
||||
void World::ContentFinder::registerContentRequest( Entity::Player &player, uint32_t contentId, uint8_t flags )
|
||||
{
|
||||
queueForContent( player, { contentId } );
|
||||
completeRegistration( player, flags );
|
||||
}
|
||||
|
||||
void Sapphire::World::ContentFinder::registerRandomContentRequest( Sapphire::Entity::Player &player, uint32_t randomContentTypeId )
|
||||
void World::ContentFinder::registerRandomContentRequest( Entity::Player &player, uint32_t randomContentTypeId )
|
||||
{
|
||||
auto& exdData = Service< Data::ExdData >::ref();
|
||||
auto contentListIds = exdData.getIdList< Excel::ContentFinderCondition >();
|
||||
|
@ -146,9 +148,8 @@ void Sapphire::World::ContentFinder::registerRandomContentRequest( Sapphire::Ent
|
|||
completeRegistration( player );
|
||||
}
|
||||
|
||||
void Sapphire::World::ContentFinder::completeRegistration( const Sapphire::Entity::Player &player, uint8_t flags )
|
||||
void World::ContentFinder::completeRegistration( const Entity::Player &player, uint8_t flags )
|
||||
{
|
||||
|
||||
auto& server = Service< WorldServer >::ref();
|
||||
auto queuedContent = m_queuedContent[ m_queuedPlayer[ player.getId() ]->getActiveRegisterId() ];
|
||||
|
||||
|
@ -182,7 +183,7 @@ void Sapphire::World::ContentFinder::completeRegistration( const Sapphire::Entit
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::World::ContentFinder::queueForContent( Sapphire::Entity::Player &player, const std::vector< uint32_t >& contentIds )
|
||||
void World::ContentFinder::queueForContent( Entity::Player &player, const std::vector< uint32_t >& contentIds )
|
||||
{
|
||||
for( auto contentId : contentIds )
|
||||
{
|
||||
|
@ -215,7 +216,7 @@ void Sapphire::World::ContentFinder::queueForContent( Sapphire::Entity::Player &
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::World::QueuedContent::queuePlayer( const std::shared_ptr< QueuedPlayer >& pQPlayer )
|
||||
void World::QueuedContent::queuePlayer( const std::shared_ptr< QueuedPlayer >& pQPlayer )
|
||||
{
|
||||
m_players.push_back( pQPlayer );
|
||||
m_partyMemberCount++;
|
||||
|
@ -241,7 +242,7 @@ void Sapphire::World::QueuedContent::queuePlayer( const std::shared_ptr< QueuedP
|
|||
}
|
||||
}
|
||||
|
||||
bool Sapphire::World::QueuedContent::withdrawPlayer( const std::shared_ptr< QueuedPlayer >& pQPlayer )
|
||||
bool World::QueuedContent::withdrawPlayer( const std::shared_ptr< QueuedPlayer >& pQPlayer )
|
||||
{
|
||||
auto preSize = m_players.size();
|
||||
auto it = m_players.begin();
|
||||
|
@ -282,12 +283,12 @@ bool Sapphire::World::QueuedContent::withdrawPlayer( const std::shared_ptr< Queu
|
|||
return true;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::World::ContentFinder::getNextRegisterId()
|
||||
uint32_t World::ContentFinder::getNextRegisterId()
|
||||
{
|
||||
return ++m_nextRegisterId;
|
||||
}
|
||||
|
||||
Sapphire::World::ContentFinder::QueuedContentPtrList Sapphire::World::ContentFinder::getMatchingContentList( Sapphire::Entity::Player &player, uint32_t contentFinderId )
|
||||
World::ContentFinder::QueuedContentPtrList World::ContentFinder::getMatchingContentList( Entity::Player &player, uint32_t contentFinderId )
|
||||
{
|
||||
QueuedContentPtrList outVec;
|
||||
for( auto& it : m_queuedContent )
|
||||
|
@ -361,7 +362,7 @@ Sapphire::World::ContentFinder::QueuedContentPtrList Sapphire::World::ContentFin
|
|||
return outVec;
|
||||
}
|
||||
|
||||
void Sapphire::World::ContentFinder::accept( Entity::Player& player )
|
||||
void World::ContentFinder::accept( Entity::Player& player )
|
||||
{
|
||||
auto& server = Service< WorldServer >::ref();
|
||||
auto& exdData = Service< Data::ExdData >::ref();
|
||||
|
@ -408,7 +409,7 @@ void Sapphire::World::ContentFinder::accept( Entity::Player& player )
|
|||
queuedContent->setState( Accepted );
|
||||
}
|
||||
|
||||
void Sapphire::World::ContentFinder::withdraw( Entity::Player& player )
|
||||
void World::ContentFinder::withdraw( Entity::Player& player )
|
||||
{
|
||||
auto& server = Service< WorldServer >::ref();
|
||||
auto& exdData = Service< Data::ExdData >::ref();
|
||||
|
@ -471,7 +472,7 @@ void Sapphire::World::ContentFinder::withdraw( Entity::Player& player )
|
|||
|
||||
}
|
||||
|
||||
std::shared_ptr< Sapphire::World::QueuedContent > Sapphire::World::ContentFinder::findContentByRegisterId( uint32_t registerId )
|
||||
std::shared_ptr< World::QueuedContent > World::ContentFinder::findContentByRegisterId( uint32_t registerId )
|
||||
{
|
||||
auto it = m_queuedContent.find( registerId );
|
||||
if( it != m_queuedContent.end() )
|
||||
|
@ -479,7 +480,7 @@ std::shared_ptr< Sapphire::World::QueuedContent > Sapphire::World::ContentFinder
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool Sapphire::World::ContentFinder::removeContentByRegisterId( uint32_t registerId )
|
||||
bool World::ContentFinder::removeContentByRegisterId( uint32_t registerId )
|
||||
{
|
||||
auto it = m_queuedContent.find( registerId );
|
||||
if( it == m_queuedContent.end() )
|
||||
|
@ -490,21 +491,21 @@ bool Sapphire::World::ContentFinder::removeContentByRegisterId( uint32_t registe
|
|||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
uint32_t Sapphire::World::QueuedContent::getInstanceId() const
|
||||
uint32_t World::QueuedContent::getInstanceId() const
|
||||
{
|
||||
return m_contentFinderId;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::World::QueuedContent::getRegisterId() const
|
||||
uint32_t World::QueuedContent::getRegisterId() const
|
||||
{
|
||||
return m_registerId;
|
||||
}
|
||||
|
||||
Sapphire::World::QueuedContent::QueuedContent( uint32_t registerId, uint32_t contentId ) :
|
||||
m_registerId( registerId ),
|
||||
m_contentFinderId( contentId ),
|
||||
m_state( QueuedContentState::MatchingInProgress ),
|
||||
m_contentPopTime( 0 )
|
||||
World::QueuedContent::QueuedContent( uint32_t registerId, uint32_t contentId ) :
|
||||
m_registerId( registerId ),
|
||||
m_contentFinderId( contentId ),
|
||||
m_state( QueuedContentState::MatchingInProgress ),
|
||||
m_contentPopTime( 0 )
|
||||
{
|
||||
// auto& exdData = Common::Service< Data::ExdData >::ref();
|
||||
// auto content = exdData.getRow< Excel::InstanceContent >( contentId );
|
||||
|
@ -512,7 +513,7 @@ Sapphire::World::QueuedContent::QueuedContent( uint32_t registerId, uint32_t con
|
|||
|
||||
}
|
||||
|
||||
uint8_t Sapphire::World::QueuedContent::getRoleCount( Sapphire::Common::Role role ) const
|
||||
uint8_t World::QueuedContent::getRoleCount( Common::Role role ) const
|
||||
{
|
||||
switch( role )
|
||||
{
|
||||
|
@ -533,12 +534,12 @@ uint8_t Sapphire::World::QueuedContent::getRoleCount( Sapphire::Common::Role rol
|
|||
return 0;
|
||||
}
|
||||
|
||||
Sapphire::World::QueuedContentState Sapphire::World::QueuedContent::getState() const
|
||||
World::QueuedContentState World::QueuedContent::getState() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
void Sapphire::World::QueuedContent::setState( Sapphire::World::QueuedContentState state )
|
||||
void World::QueuedContent::setState( World::QueuedContentState state )
|
||||
{
|
||||
m_state = state;
|
||||
}
|
||||
|
@ -546,7 +547,7 @@ void Sapphire::World::QueuedContent::setState( Sapphire::World::QueuedContentSta
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
Sapphire::World::QueuedPlayer::QueuedPlayer( const Entity::Player &player, uint8_t registerId )
|
||||
World::QueuedPlayer::QueuedPlayer( const Entity::Player &player, uint8_t registerId )
|
||||
{
|
||||
m_characterId = player.getCharacterId();
|
||||
m_classJob = static_cast< uint32_t >( player.getClass() );
|
||||
|
@ -556,27 +557,27 @@ Sapphire::World::QueuedPlayer::QueuedPlayer( const Entity::Player &player, uint8
|
|||
m_entityId = player.getId();
|
||||
}
|
||||
|
||||
Sapphire::Common::Role Sapphire::World::QueuedPlayer::getRole() const
|
||||
Common::Role World::QueuedPlayer::getRole() const
|
||||
{
|
||||
return m_role;
|
||||
}
|
||||
|
||||
void Sapphire::World::QueuedPlayer::setActiveRegisterId( uint8_t registerId )
|
||||
void World::QueuedPlayer::setActiveRegisterId( uint8_t registerId )
|
||||
{
|
||||
m_activeRegisterId = registerId;
|
||||
}
|
||||
|
||||
uint8_t Sapphire::World::QueuedPlayer::getActiveRegisterId() const
|
||||
uint8_t World::QueuedPlayer::getActiveRegisterId() const
|
||||
{
|
||||
return m_activeRegisterId;
|
||||
}
|
||||
|
||||
uint64_t Sapphire::World::QueuedPlayer::getCharacterId() const
|
||||
uint64_t World::QueuedPlayer::getCharacterId() const
|
||||
{
|
||||
return m_characterId;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::World::QueuedPlayer::getEntityId() const
|
||||
uint32_t World::QueuedPlayer::getEntityId() const
|
||||
{
|
||||
return m_entityId;
|
||||
}
|
||||
|
|
|
@ -5,17 +5,19 @@
|
|||
#include <Network/PacketWrappers/EventLogMessagePacket.h>
|
||||
#include <Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
#include <Network/CommonActorControl.h>
|
||||
#include "Network/PacketWrappers/ActorControlPacket.h"
|
||||
#include "Network/PacketWrappers/ActorControlSelfPacket.h"
|
||||
#include "Network/GameConnection.h"
|
||||
#include "Network/Util/PacketUtil.h"
|
||||
|
||||
#include "Actor/Player.h"
|
||||
|
||||
#include "Network/PacketWrappers/ActorControlPacket.h"
|
||||
#include "Network/PacketWrappers/ActorControlSelfPacket.h"
|
||||
#include <Logging/Logger.h>
|
||||
|
||||
#include <Service.h>
|
||||
#include "WorldServer.h"
|
||||
#include "Session.h"
|
||||
#include "Network/GameConnection.h"
|
||||
|
||||
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
|
@ -83,8 +85,7 @@ void Sapphire::Event::Director::sendEventLogMessage( Sapphire::Entity::Player& p
|
|||
|
||||
void Sapphire::Event::Director::sendDirectorClear( Sapphire::Entity::Player& player ) const
|
||||
{
|
||||
auto& server = Common::Service< World::WorldServer >::ref();
|
||||
server.queueForPlayer( player.getCharacterId(), makeActorControlSelf( player.getId(), DirectorClear, m_directorId ) );
|
||||
Network::Util::Packet::sendActorControlSelf( player, DirectorClear, m_directorId );
|
||||
}
|
||||
|
||||
void Sapphire::Event::Director::sendDirectorVars( Sapphire::Entity::Player& player ) const
|
||||
|
@ -102,8 +103,7 @@ void Sapphire::Event::Director::sendDirectorVars( Sapphire::Entity::Player& play
|
|||
void Sapphire::Event::Director::sendDirectorInit( Sapphire::Entity::Player& player ) const
|
||||
{
|
||||
Logger::debug( "[{}] directorInit: directorId#{}, contextId#{}", player.getId(), m_directorId, m_contextId );
|
||||
auto& server = Common::Service< World::WorldServer >::ref();
|
||||
server.queueForPlayer( player.getCharacterId(), makeActorControlSelf( player.getId(), DirectorInit, m_directorId, m_contextId ) );
|
||||
Network::Util::Packet::sendActorControlSelf( player, DirectorInit, m_directorId, m_contextId );
|
||||
}
|
||||
|
||||
Sapphire::Event::Director::DirectorType Sapphire::Event::Director::getType() const
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
#include <utility>
|
||||
|
||||
Sapphire::Event::EventHandler::EventHandler( uint64_t actorId, uint32_t eventId,
|
||||
EventType eventType, uint32_t eventParam ) :
|
||||
using namespace Sapphire;
|
||||
|
||||
Event::EventHandler::EventHandler( uint64_t actorId, uint32_t eventId, EventType eventType, uint32_t eventParam ) :
|
||||
m_actorId( actorId ),
|
||||
m_eventId( eventId ),
|
||||
m_eventType( eventType ),
|
||||
|
@ -15,107 +16,107 @@ Sapphire::Event::EventHandler::EventHandler( uint64_t actorId, uint32_t eventId,
|
|||
m_returnCallback = nullptr;
|
||||
}
|
||||
|
||||
uint64_t Sapphire::Event::EventHandler::getActorId() const
|
||||
uint64_t Event::EventHandler::getActorId() const
|
||||
{
|
||||
return m_actorId;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Event::EventHandler::getId() const
|
||||
uint32_t Event::EventHandler::getId() const
|
||||
{
|
||||
return m_eventId;
|
||||
}
|
||||
|
||||
uint8_t Sapphire::Event::EventHandler::getEventType() const
|
||||
uint8_t Event::EventHandler::getEventType() const
|
||||
{
|
||||
return m_eventType;
|
||||
}
|
||||
|
||||
uint16_t Sapphire::Event::EventHandler::getType() const
|
||||
uint16_t Event::EventHandler::getType() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
uint16_t Sapphire::Event::EventHandler::getEntryId() const
|
||||
uint16_t Event::EventHandler::getEntryId() const
|
||||
{
|
||||
return m_entryId;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Event::EventHandler::getEventParam() const
|
||||
uint32_t Event::EventHandler::getEventParam() const
|
||||
{
|
||||
return m_eventParam;
|
||||
}
|
||||
|
||||
Sapphire::Event::EventHandler::SceneReturnCallback Sapphire::Event::EventHandler::getEventReturnCallback() const
|
||||
Event::EventHandler::SceneReturnCallback Event::EventHandler::getEventReturnCallback() const
|
||||
{
|
||||
return m_returnCallback;
|
||||
}
|
||||
|
||||
void Sapphire::Event::EventHandler::setEventReturnCallback( SceneReturnCallback callback )
|
||||
void Event::EventHandler::setEventReturnCallback( SceneReturnCallback callback )
|
||||
{
|
||||
m_returnCallback = std::move( callback );
|
||||
}
|
||||
|
||||
Sapphire::Event::EventHandler::QuestSceneReturnCallback Sapphire::Event::EventHandler::getQuestEventReturnCallback() const
|
||||
Event::EventHandler::QuestSceneReturnCallback Event::EventHandler::getQuestEventReturnCallback() const
|
||||
{
|
||||
return m_questReturnCallback;
|
||||
}
|
||||
|
||||
void Sapphire::Event::EventHandler::setQuestEventReturnCallback( QuestSceneReturnCallback callback )
|
||||
void Event::EventHandler::setQuestEventReturnCallback( QuestSceneReturnCallback callback )
|
||||
{
|
||||
m_questReturnCallback = std::move( callback );
|
||||
}
|
||||
|
||||
Sapphire::Event::EventHandler::SceneChainCallback Sapphire::Event::EventHandler::getSceneChainCallback() const
|
||||
Event::EventHandler::SceneChainCallback Event::EventHandler::getSceneChainCallback() const
|
||||
{
|
||||
return m_chainCallback;
|
||||
}
|
||||
|
||||
void Sapphire::Event::EventHandler::setSceneChainCallback( Sapphire::Event::EventHandler::SceneChainCallback callback )
|
||||
void Event::EventHandler::setSceneChainCallback( Event::EventHandler::SceneChainCallback callback )
|
||||
{
|
||||
m_chainCallback = std::move( callback );
|
||||
}
|
||||
|
||||
Sapphire::Event::EventHandler::QuestSceneChainCallback Sapphire::Event::EventHandler::getQuestSceneChainCallback() const
|
||||
Event::EventHandler::QuestSceneChainCallback Event::EventHandler::getQuestSceneChainCallback() const
|
||||
{
|
||||
return m_questChainCallback;
|
||||
}
|
||||
|
||||
void Sapphire::Event::EventHandler::setQuestSceneChainCallback( Sapphire::Event::EventHandler::QuestSceneChainCallback callback )
|
||||
void Event::EventHandler::setQuestSceneChainCallback( Event::EventHandler::QuestSceneChainCallback callback )
|
||||
{
|
||||
m_questChainCallback = std::move( callback );
|
||||
}
|
||||
|
||||
Sapphire::Event::EventHandler::EventFinishCallback Sapphire::Event::EventHandler::getEventFinishCallback() const
|
||||
Event::EventHandler::EventFinishCallback Event::EventHandler::getEventFinishCallback() const
|
||||
{
|
||||
return m_finishCallback;
|
||||
}
|
||||
|
||||
void Sapphire::Event::EventHandler::setEventFinishCallback( EventFinishCallback callback )
|
||||
void Event::EventHandler::setEventFinishCallback( EventFinishCallback callback )
|
||||
{
|
||||
m_finishCallback = std::move( callback );
|
||||
}
|
||||
|
||||
bool Sapphire::Event::EventHandler::hasPlayedScene() const
|
||||
bool Event::EventHandler::hasPlayedScene() const
|
||||
{
|
||||
return m_playedScene;
|
||||
}
|
||||
|
||||
void Sapphire::Event::EventHandler::setPlayedScene( bool playedScene )
|
||||
void Event::EventHandler::setPlayedScene( bool playedScene )
|
||||
{
|
||||
m_playedScene = playedScene;
|
||||
}
|
||||
|
||||
bool Sapphire::Event::EventHandler::hasNestedEvent() const
|
||||
bool Event::EventHandler::hasNestedEvent() const
|
||||
{
|
||||
return m_pNestedEvent != nullptr;
|
||||
}
|
||||
|
||||
void Sapphire::Event::EventHandler::removeNestedEvent()
|
||||
void Event::EventHandler::removeNestedEvent()
|
||||
{
|
||||
m_pNestedEvent.reset();
|
||||
}
|
||||
|
||||
Sapphire::Event::ScenePlayParam *Sapphire::Event::EventHandler::getScenePlayParams()
|
||||
Event::ScenePlayParam* Event::EventHandler::getScenePlayParams()
|
||||
{
|
||||
return &m_scenePlayParams;
|
||||
}
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
#include <utility>
|
||||
|
||||
Sapphire::FreeCompany::FreeCompany( uint64_t id, std::string name, std::string tag, uint64_t masterId, uint64_t chatChannelId ) :
|
||||
using namespace Sapphire;
|
||||
|
||||
FreeCompany::FreeCompany( uint64_t id, std::string name, std::string tag, uint64_t masterId, uint64_t chatChannelId ) :
|
||||
m_id( id ),
|
||||
m_name( std::move( name ) ),
|
||||
m_tag( std::move( tag ) ),
|
||||
|
@ -12,211 +14,211 @@ Sapphire::FreeCompany::FreeCompany( uint64_t id, std::string name, std::string t
|
|||
|
||||
}
|
||||
|
||||
uint64_t Sapphire::FreeCompany::getId() const
|
||||
uint64_t FreeCompany::getId() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
const std::string& Sapphire::FreeCompany::getName() const
|
||||
const std::string& FreeCompany::getName() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
void Sapphire::FreeCompany::setName( std::string name )
|
||||
void FreeCompany::setName( std::string name )
|
||||
{
|
||||
m_name = std::move( name );
|
||||
}
|
||||
|
||||
const std::string& Sapphire::FreeCompany::getTag() const
|
||||
const std::string& FreeCompany::getTag() const
|
||||
{
|
||||
return m_tag;
|
||||
}
|
||||
|
||||
void Sapphire::FreeCompany::setTag( std::string tag )
|
||||
void FreeCompany::setTag( std::string tag )
|
||||
{
|
||||
m_tag = std::move( tag );
|
||||
}
|
||||
|
||||
uint64_t Sapphire::FreeCompany::getMasterId() const
|
||||
uint64_t FreeCompany::getMasterId() const
|
||||
{
|
||||
return m_masterCharacterId;
|
||||
}
|
||||
|
||||
void Sapphire::FreeCompany::setMasterId( uint64_t masterId )
|
||||
void FreeCompany::setMasterId( uint64_t masterId )
|
||||
{
|
||||
m_masterCharacterId = masterId;
|
||||
}
|
||||
|
||||
uint64_t Sapphire::FreeCompany::getCredit() const
|
||||
uint64_t FreeCompany::getCredit() const
|
||||
{
|
||||
return m_credit;
|
||||
}
|
||||
|
||||
void Sapphire::FreeCompany::setCredit( uint64_t credit )
|
||||
void FreeCompany::setCredit( uint64_t credit )
|
||||
{
|
||||
m_credit = credit;
|
||||
}
|
||||
|
||||
uint64_t Sapphire::FreeCompany::getCreditAccumulated() const
|
||||
uint64_t FreeCompany::getCreditAccumulated() const
|
||||
{
|
||||
return m_creditAccumulated;
|
||||
}
|
||||
|
||||
void Sapphire::FreeCompany::setCreditAccumulated( uint64_t credit )
|
||||
void FreeCompany::setCreditAccumulated( uint64_t credit )
|
||||
{
|
||||
m_creditAccumulated = credit;
|
||||
}
|
||||
|
||||
uint8_t Sapphire::FreeCompany::getRank() const
|
||||
uint8_t FreeCompany::getRank() const
|
||||
{
|
||||
return m_rank;
|
||||
}
|
||||
|
||||
void Sapphire::FreeCompany::setRank( uint8_t rank )
|
||||
void FreeCompany::setRank( uint8_t rank )
|
||||
{
|
||||
m_rank = rank;
|
||||
}
|
||||
|
||||
uint64_t Sapphire::FreeCompany::getPoints() const
|
||||
uint64_t FreeCompany::getPoints() const
|
||||
{
|
||||
return m_points;
|
||||
}
|
||||
|
||||
void Sapphire::FreeCompany::setPoints( uint64_t points )
|
||||
void FreeCompany::setPoints( uint64_t points )
|
||||
{
|
||||
m_points = points;
|
||||
}
|
||||
|
||||
uint64_t Sapphire::FreeCompany::getCrest() const
|
||||
uint64_t FreeCompany::getCrest() const
|
||||
{
|
||||
return m_crest;
|
||||
}
|
||||
|
||||
void Sapphire::FreeCompany::setCrest( uint64_t crest )
|
||||
void FreeCompany::setCrest( uint64_t crest )
|
||||
{
|
||||
m_crest = crest;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::FreeCompany::getCreateDate() const
|
||||
uint32_t FreeCompany::getCreateDate() const
|
||||
{
|
||||
return m_createDate;
|
||||
}
|
||||
|
||||
void Sapphire::FreeCompany::setCreateDate( uint32_t createDate )
|
||||
void FreeCompany::setCreateDate( uint32_t createDate )
|
||||
{
|
||||
m_createDate = createDate;
|
||||
}
|
||||
|
||||
uint8_t Sapphire::FreeCompany::getGrandCompany() const
|
||||
uint8_t FreeCompany::getGrandCompany() const
|
||||
{
|
||||
return m_gc;
|
||||
}
|
||||
|
||||
void Sapphire::FreeCompany::setGrandCompany( uint8_t gcIndex )
|
||||
void FreeCompany::setGrandCompany( uint8_t gcIndex )
|
||||
{
|
||||
if( gcIndex > 2 )
|
||||
return;
|
||||
m_gc = gcIndex;
|
||||
}
|
||||
|
||||
uint64_t Sapphire::FreeCompany::getGcReputation( uint8_t gcIndex ) const
|
||||
uint64_t FreeCompany::getGcReputation( uint8_t gcIndex ) const
|
||||
{
|
||||
if( gcIndex > 2 )
|
||||
return 0;
|
||||
return m_gcReputation[ gcIndex ];
|
||||
}
|
||||
|
||||
void Sapphire::FreeCompany::setGcReputation( uint8_t gcIndex, uint64_t reputation )
|
||||
void FreeCompany::setGcReputation( uint8_t gcIndex, uint64_t reputation )
|
||||
{
|
||||
if( gcIndex > 2 )
|
||||
return;
|
||||
m_gcReputation[ gcIndex ] = reputation;
|
||||
}
|
||||
|
||||
Sapphire::Common::FreeCompanyStatus Sapphire::FreeCompany::getFcStatus() const
|
||||
Common::FreeCompanyStatus FreeCompany::getFcStatus() const
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
|
||||
void Sapphire::FreeCompany::setFcStatus( Sapphire::Common::FreeCompanyStatus status )
|
||||
void FreeCompany::setFcStatus( Common::FreeCompanyStatus status )
|
||||
{
|
||||
m_status = status;
|
||||
}
|
||||
|
||||
const std::string& Sapphire::FreeCompany::getFcBoard() const
|
||||
const std::string& FreeCompany::getFcBoard() const
|
||||
{
|
||||
return m_fcBoard;
|
||||
}
|
||||
|
||||
void Sapphire::FreeCompany::setFcBoard( const std::string& board )
|
||||
void FreeCompany::setFcBoard( const std::string& board )
|
||||
{
|
||||
m_fcBoard = board;
|
||||
}
|
||||
|
||||
const std::string& Sapphire::FreeCompany::getFcMotto() const
|
||||
const std::string& FreeCompany::getFcMotto() const
|
||||
{
|
||||
return m_fcMotto;
|
||||
}
|
||||
|
||||
void Sapphire::FreeCompany::setFcMotto( const std::string& motto )
|
||||
void FreeCompany::setFcMotto( const std::string& motto )
|
||||
{
|
||||
m_fcMotto = motto;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::FreeCompany::getFcVersion() const
|
||||
uint32_t FreeCompany::getFcVersion() const
|
||||
{
|
||||
return m_fcVersion;
|
||||
}
|
||||
|
||||
void Sapphire::FreeCompany::setFcVersion( uint32_t version )
|
||||
void FreeCompany::setFcVersion( uint32_t version )
|
||||
{
|
||||
m_fcVersion = version;
|
||||
}
|
||||
|
||||
const std::array< uint64_t, 3 >& Sapphire::FreeCompany::getActiveActionIdArr() const
|
||||
const std::array< uint64_t, 3 >& FreeCompany::getActiveActionIdArr() const
|
||||
{
|
||||
return m_activeActionId;
|
||||
}
|
||||
|
||||
const std::array< uint64_t, 3 >& Sapphire::FreeCompany::getActiveActionTimeLeftArr() const
|
||||
const std::array< uint64_t, 3 >& FreeCompany::getActiveActionTimeLeftArr() const
|
||||
{
|
||||
return m_activeActionTimeLeft;
|
||||
}
|
||||
|
||||
const std::array< uint64_t, 15 >& Sapphire::FreeCompany::getActionStockArr() const
|
||||
const std::array< uint64_t, 15 >& FreeCompany::getActionStockArr() const
|
||||
{
|
||||
return m_actionStock;
|
||||
}
|
||||
|
||||
uint64_t Sapphire::FreeCompany::getChatChannel() const
|
||||
uint64_t FreeCompany::getChatChannel() const
|
||||
{
|
||||
return m_chatChannelId;
|
||||
}
|
||||
|
||||
const std::set< uint64_t >& Sapphire::FreeCompany::getMemberIdList() const
|
||||
const std::set< uint64_t >& FreeCompany::getMemberIdList() const
|
||||
{
|
||||
return m_memberIds;
|
||||
}
|
||||
|
||||
std::set< uint64_t >& Sapphire::FreeCompany::getMemberIdList()
|
||||
std::set< uint64_t >& FreeCompany::getMemberIdList()
|
||||
{
|
||||
return m_memberIds;
|
||||
}
|
||||
|
||||
void Sapphire::FreeCompany::addMember( uint64_t memberId, uint8_t hierarchyId, uint32_t lastLogout )
|
||||
void FreeCompany::addMember( uint64_t memberId, uint8_t hierarchyId, uint32_t lastLogout )
|
||||
{
|
||||
FcMember member{ memberId, hierarchyId, lastLogout };
|
||||
m_memberDetails[ memberId ] = member;
|
||||
m_memberIds.insert( memberId );
|
||||
}
|
||||
|
||||
void Sapphire::FreeCompany::removeMember( uint64_t memberId )
|
||||
void FreeCompany::removeMember( uint64_t memberId )
|
||||
{
|
||||
m_memberDetails.erase( memberId );
|
||||
m_memberIds.erase( memberId );
|
||||
}
|
||||
|
||||
void Sapphire::FreeCompany::setChatChannel( uint64_t chatChannelId )
|
||||
void FreeCompany::setChatChannel( uint64_t chatChannelId )
|
||||
{
|
||||
m_chatChannelId = chatChannelId;
|
||||
}
|
||||
|
|
|
@ -289,7 +289,6 @@ uint32_t HousingMgr::toLandSetId( int16_t territoryTypeId, int16_t wardId ) cons
|
|||
return ( static_cast< uint32_t >( territoryTypeId ) << 16 ) | wardId;
|
||||
}
|
||||
|
||||
|
||||
LandPtr HousingMgr::getLandByOwnerId( uint64_t id )
|
||||
{
|
||||
|
||||
|
@ -405,7 +404,7 @@ LandPurchaseResult HousingMgr::purchaseLand( Entity::Player& player, HousingZone
|
|||
pLand->setStatus( Common::HouseStatus::Sold );
|
||||
pLand->setLandType( Common::LandType::Private );
|
||||
|
||||
player.setLandFlags( Common::LandFlagsSlot::Private, 0x00, pLand->getLandIdent() );
|
||||
player.setLandFlags( Common::LandFlagsSlot::Private, 0, pLand->getLandIdent() );
|
||||
|
||||
sendLandFlagsSlot( player, Common::LandFlagsSlot::Private );
|
||||
|
||||
|
@ -433,7 +432,7 @@ bool HousingMgr::relinquishLand( Entity::Player& player, HousingZone& zone, uint
|
|||
|
||||
// can't relinquish when you are not the owner
|
||||
// TODO: actually use permissions here for FC houses
|
||||
if( !hasPermission( player, *pLand, 0 ) )
|
||||
if( !pLand || !hasPermission( player, *pLand, 0 ) )
|
||||
{
|
||||
Network::Util::Packet::sendActorControlSelf( player, ActorControl::LogMsg, 3304 );
|
||||
return false;
|
||||
|
@ -455,7 +454,7 @@ bool HousingMgr::relinquishLand( Entity::Player& player, HousingZone& zone, uint
|
|||
|
||||
Common::LandIdent ident { 0xFF, 0xFF, 0xFF, 0xFF };
|
||||
|
||||
player.setLandFlags( Common::LandFlagsSlot::Private, 0x00, ident );
|
||||
player.setLandFlags( Common::LandFlagsSlot::Private, 0, ident );
|
||||
|
||||
sendLandFlagsSlot( player, Common::LandFlagsSlot::Private );
|
||||
|
||||
|
@ -676,10 +675,7 @@ void HousingMgr::buildPresetEstate( Entity::Player& player, HousingZone& zone, u
|
|||
auto& server = Common::Service< World::WorldServer >::ref();
|
||||
|
||||
auto pLand = zone.getLand( plotNum );
|
||||
if( !pLand )
|
||||
return;
|
||||
|
||||
if( !hasPermission( player, *pLand, 0 ) )
|
||||
if( !pLand || !hasPermission( player, *pLand, 0 ) )
|
||||
return;
|
||||
|
||||
// create house
|
||||
|
@ -784,10 +780,7 @@ void HousingMgr::updateEstateGreeting( Entity::Player& player, const Common::Lan
|
|||
return;
|
||||
|
||||
auto land = hZone->getLand( static_cast< uint8_t >( ident.landId ) );
|
||||
if( !land )
|
||||
return;
|
||||
|
||||
if( !hasPermission( player, *land, 0 ) )
|
||||
if( !land || !hasPermission( player, *land, 0 ) )
|
||||
return;
|
||||
|
||||
auto house = land->getHouse();
|
||||
|
@ -813,10 +806,7 @@ void HousingMgr::requestEstateEditGuestAccess( Entity::Player& player, const Com
|
|||
return;
|
||||
|
||||
auto land = hZone->getLand( ident.landId );
|
||||
if( !land )
|
||||
return;
|
||||
|
||||
if( !hasPermission( player, *land, 0 ) )
|
||||
if( !land || !hasPermission( player, *land, 0 ) )
|
||||
return;
|
||||
|
||||
auto packet = makeZonePacket< FFXIVIpcHousingWelcome >( player.getId() );
|
||||
|
@ -880,10 +870,7 @@ void HousingMgr::sendEstateInventory( Entity::Player& player, uint16_t inventory
|
|||
targetLand = zone->getLand( plotNum );
|
||||
}
|
||||
|
||||
if( !targetLand )
|
||||
return;
|
||||
|
||||
if( !hasPermission( player, *targetLand, 0 ) )
|
||||
if( !targetLand || !hasPermission( player, *targetLand, 0 ) )
|
||||
return;
|
||||
|
||||
auto& containers = getEstateInventory( targetLand->getLandIdent() );
|
||||
|
@ -1018,10 +1005,7 @@ void HousingMgr::reqPlaceHousingItem( Entity::Player& player, uint16_t landId, u
|
|||
else
|
||||
return;
|
||||
|
||||
if( !land )
|
||||
return;
|
||||
|
||||
if( !hasPermission( player, *land, 0 ) )
|
||||
if( !land || !hasPermission( player, *land, 0 ) )
|
||||
return;
|
||||
|
||||
// todo: check item position and make sure it's not outside the plot
|
||||
|
@ -1275,10 +1259,7 @@ void HousingMgr::reqMoveHousingItem( Entity::Player& player, Common::LandIdent i
|
|||
auto hZone = std::dynamic_pointer_cast< HousingZone >( pTeri );
|
||||
auto land = hZone->getLand( static_cast< uint8_t >( ident.landId ) );
|
||||
|
||||
if( !land )
|
||||
return;
|
||||
|
||||
if( !hasPermission( player, *land, 0 ) )
|
||||
if( !land || !hasPermission( player, *land, 0 ) )
|
||||
return;
|
||||
|
||||
auto pZone = teriMgr.getTerritoryByGuId( player.getTerritoryId() );
|
||||
|
@ -1347,8 +1328,7 @@ bool HousingMgr::moveExternalItem( Entity::Player& player, Common::LandIdent ide
|
|||
auto& server = Common::Service< World::WorldServer >::ref();
|
||||
|
||||
auto land = terri.getLand( static_cast< uint8_t >( ident.landId ) );
|
||||
|
||||
if( !hasPermission( player, *land, 0 ) )
|
||||
if( !land || !hasPermission( player, *land, 0 ) )
|
||||
return false;
|
||||
|
||||
auto& containers = getEstateInventory( ident );
|
||||
|
@ -1390,11 +1370,7 @@ void HousingMgr::reqRemoveHousingItem( Entity::Player& player, uint16_t plot, ui
|
|||
auto hZone = std::dynamic_pointer_cast< HousingZone >( pTeri );
|
||||
|
||||
auto land = hZone->getLand( static_cast< uint8_t >( ident.landId ) );
|
||||
|
||||
if( !land )
|
||||
return;
|
||||
|
||||
if( !hasPermission( player, *land, 0 ) )
|
||||
if( !land || !hasPermission( player, *land, 0 ) )
|
||||
return;
|
||||
|
||||
removeInternalItem( player, *terri, containerId, slot, sendToStoreroom );
|
||||
|
@ -1402,10 +1378,7 @@ void HousingMgr::reqRemoveHousingItem( Entity::Player& player, uint16_t plot, ui
|
|||
else if( auto terri = std::dynamic_pointer_cast< HousingZone >( pZone ) )
|
||||
{
|
||||
auto land = terri->getLand( static_cast< uint8_t >( plot ) );
|
||||
if( !land )
|
||||
return;
|
||||
|
||||
if( !hasPermission( player, *land, 0 ) )
|
||||
if( !land || !hasPermission( player, *land, 0 ) )
|
||||
return;
|
||||
|
||||
auto containerType = static_cast< Common::InventoryType >( containerId );
|
||||
|
|
|
@ -91,8 +91,8 @@ void WarpMgr::requestWarp( Entity::Player& player, Common::WarpType warpType, Co
|
|||
{
|
||||
m_entityIdToWarpInfoMap[ player.getId() ] = { 0, warpType, targetPos, targetRot };
|
||||
|
||||
Network::Util::Packet::sendActorControlSelf( player.getInRangePlayerIds( true ), player, WarpStart, warpType, warpType, 0, player.getTerritoryTypeId(), 1 );
|
||||
Network::Util::Packet::sendActorControl( player.getInRangePlayerIds(), player, ActorDespawnEffect, warpType, player.getTerritoryTypeId() );
|
||||
Network::Util::Packet::sendActorControlSelf( player.getInRangePlayerIds( true ), player.getId(), WarpStart, warpType, warpType, 0, player.getTerritoryTypeId(), 1 );
|
||||
Network::Util::Packet::sendActorControl( player.getInRangePlayerIds(), player.getId(), ActorDespawnEffect, warpType, player.getTerritoryTypeId() );
|
||||
|
||||
auto& taskMgr = Common::Service< TaskMgr >::ref();
|
||||
taskMgr.queueTask( makeWarpTask( player, warpType, targetPos, targetRot, 1000 ) );
|
||||
|
@ -127,10 +127,10 @@ void WarpMgr::finishWarp( Entity::Player& player )
|
|||
auto warpFinishAnim = warpType - 1;
|
||||
|
||||
if( !player.getGmInvis() )
|
||||
Network::Util::Packet::sendActorControlSelf( player.getInRangePlayerIds(), player, Appear, warpFinishAnim, raiseAnim );
|
||||
Network::Util::Packet::sendActorControlSelf( player.getInRangePlayerIds(), player.getId(), Appear, warpFinishAnim, raiseAnim );
|
||||
|
||||
Network::Util::Packet::sendActorControlSelf( player, Appear, warpFinishAnim, raiseAnim );
|
||||
Network::Util::Packet::sendActorControl( player.getInRangePlayerIds( true ), player, SetStatus, static_cast< uint8_t >( Common::ActorStatus::Idle ) );
|
||||
Network::Util::Packet::sendActorControl( player.getInRangePlayerIds( true ), player.getId(), SetStatus, static_cast< uint8_t >( Common::ActorStatus::Idle ) );
|
||||
|
||||
player.removeCondition( PlayerCondition::BetweenAreas );
|
||||
|
||||
|
|
|
@ -418,7 +418,7 @@ void Sapphire::Network::GameConnection::commandHandler( const Packets::FFXIVARR_
|
|||
player.setStance( Stance::Passive );
|
||||
player.setAutoattack( false );
|
||||
}
|
||||
Network::Util::Packet::sendActorControl( player.getInRangePlayerIds(), player, ToggleWeapon, data.Arg0, 1 );
|
||||
Network::Util::Packet::sendActorControl( player.getInRangePlayerIds(), player.getId(), ToggleWeapon, data.Arg0, 1 );
|
||||
break;
|
||||
}
|
||||
case PacketCommand::AUTO_ATTACK: // Toggle auto-attack
|
||||
|
@ -431,7 +431,7 @@ void Sapphire::Network::GameConnection::commandHandler( const Packets::FFXIVARR_
|
|||
else
|
||||
player.setAutoattack( false );
|
||||
|
||||
Network::Util::Packet::sendActorControl( player.getInRangePlayerIds(), player, AutoAttack, data.Arg0, 1 );
|
||||
Network::Util::Packet::sendActorControl( player.getInRangePlayerIds(), player.getId(), AutoAttack, data.Arg0, 1 );
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -513,7 +513,7 @@ void Sapphire::Network::GameConnection::commandHandler( const Packets::FFXIVARR_
|
|||
if( !emoteData )
|
||||
return;
|
||||
|
||||
Network::Util::Packet::sendActorControlTarget( player.getInRangePlayerIds(), player, Emote, emoteId, 0, isSilent ? 1 : 0, 0, targetId );
|
||||
Network::Util::Packet::sendActorControlTarget( player.getInRangePlayerIds(), player.getId(), Emote, emoteId, 0, isSilent ? 1 : 0, 0, targetId );
|
||||
|
||||
bool isPersistent = emoteData->data().Mode != 0;
|
||||
|
||||
|
@ -524,7 +524,7 @@ void Sapphire::Network::GameConnection::commandHandler( const Packets::FFXIVARR_
|
|||
player.setPersistentEmote( emoteData->data().Mode );
|
||||
player.setStatus( ActorStatus::EmoteMode );
|
||||
|
||||
Network::Util::Packet::sendActorControl( player.getInRangePlayerIds( true ), player, SetStatus, static_cast< uint8_t >( ActorStatus::EmoteMode ),
|
||||
Network::Util::Packet::sendActorControl( player.getInRangePlayerIds( true ), player.getId(), SetStatus, static_cast< uint8_t >( ActorStatus::EmoteMode ),
|
||||
emoteData->data().IsEndEmoteMode ? 1 : 0 );
|
||||
}
|
||||
|
||||
|
@ -537,7 +537,7 @@ void Sapphire::Network::GameConnection::commandHandler( const Packets::FFXIVARR_
|
|||
}
|
||||
case PacketCommand::EMOTE_CANCEL: // emote
|
||||
{
|
||||
Network::Util::Packet::sendActorControl( player.getInRangePlayerIds(), player, EmoteModeInterrupt );
|
||||
Network::Util::Packet::sendActorControl( player.getInRangePlayerIds(), player.getId(), EmoteModeInterrupt );
|
||||
break;
|
||||
}
|
||||
case PacketCommand::EMOTE_MODE_CANCEL:
|
||||
|
@ -549,8 +549,8 @@ void Sapphire::Network::GameConnection::commandHandler( const Packets::FFXIVARR_
|
|||
|
||||
server().queueForPlayers( player.getInRangePlayerIds(), std::make_shared< MoveActorPacket >( player, player.getRot(), 2, 0, 0, 0x5A / 4 ) );
|
||||
|
||||
Network::Util::Packet::sendActorControl( player.getInRangePlayerIds(), player, EmoteModeInterrupt );
|
||||
Network::Util::Packet::sendActorControl( player.getInRangePlayerIds(), player, SetStatus, static_cast< uint8_t >( ActorStatus::Idle ) );
|
||||
Network::Util::Packet::sendActorControl( player.getInRangePlayerIds(), player.getId(), EmoteModeInterrupt );
|
||||
Network::Util::Packet::sendActorControl( player.getInRangePlayerIds(), player.getId(), SetStatus, static_cast< uint8_t >( ActorStatus::Idle ) );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -558,7 +558,7 @@ void Sapphire::Network::GameConnection::commandHandler( const Packets::FFXIVARR_
|
|||
case PacketCommand::POSE_EMOTE_WORK: // reapply pose
|
||||
{
|
||||
player.setPose( static_cast< uint8_t >( data.Arg1 ) );
|
||||
Network::Util::Packet::sendActorControl( player.getInRangePlayerIds( true ), player, SetPose, data.Arg0, data.Arg1 );
|
||||
Network::Util::Packet::sendActorControl( player.getInRangePlayerIds( true ), player.getId(), SetPose, data.Arg0, data.Arg1 );
|
||||
break;
|
||||
}
|
||||
case PacketCommand::POSE_EMOTE_CANCEL: // cancel pose
|
||||
|
|
|
@ -84,7 +84,7 @@ void Sapphire::Network::GameConnection::setProfileHandler( const Packets::FFXIVA
|
|||
strcpy( searchInfoPacket->data().SearchComment, player.getSearchMessage() );
|
||||
queueOutPacket( searchInfoPacket );
|
||||
|
||||
Network::Util::Packet::sendActorControl( player.getInRangePlayerIds( true ), player, SetStatusIcon, static_cast< uint8_t >( player.getOnlineStatus() ) );
|
||||
Network::Util::Packet::sendActorControl( player.getInRangePlayerIds( true ), player.getId(), SetStatusIcon, static_cast< uint8_t >( player.getOnlineStatus() ) );
|
||||
}
|
||||
|
||||
void Sapphire::Network::GameConnection::getProfileHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||
|
|
|
@ -69,10 +69,10 @@ void Util::Packet::sendBaseParams( Entity::Player& player )
|
|||
server().queueForPlayer( player.getCharacterId(), statPacket );
|
||||
}
|
||||
|
||||
void Util::Packet::sendHudParam( Entity::Player& player )
|
||||
void Util::Packet::sendHudParam( Entity::Chara& source )
|
||||
{
|
||||
auto hudParamPacket = makeHudParam( player );
|
||||
server().queueForPlayer( player.getCharacterId(), hudParamPacket );
|
||||
auto hudParamPacket = makeHudParam( source );
|
||||
server().queueForPlayers( source.getInRangePlayerIds( source.isPlayer() ), hudParamPacket );
|
||||
}
|
||||
|
||||
void Util::Packet::sendStatusUpdate( Entity::Player& player )
|
||||
|
@ -136,10 +136,10 @@ void Util::Packet::sendActorControlSelf( Entity::Player& player, uint16_t catego
|
|||
server().queueForPlayer( player.getCharacterId(), makeActorControlSelf( player.getId(), category, param1, param2, param3, param4, param5 ) );
|
||||
}
|
||||
|
||||
void Util::Packet::sendActorControlSelf( const std::set< uint64_t >& characterIds, Entity::Player& player, uint16_t category, uint32_t param1,
|
||||
void Util::Packet::sendActorControlSelf( const std::set< uint64_t >& characterIds, uint32_t srcId, uint16_t category, uint32_t param1,
|
||||
uint32_t param2, uint32_t param3, uint32_t param4, uint32_t param5 )
|
||||
{
|
||||
server().queueForPlayers( characterIds, makeActorControlSelf( player.getId(), category, param1, param2, param3, param4, param5 ) );
|
||||
server().queueForPlayers( characterIds, makeActorControlSelf( srcId, category, param1, param2, param3, param4, param5 ) );
|
||||
}
|
||||
|
||||
void Util::Packet::sendActorControl( Entity::Player& player, uint16_t category, uint32_t param1, uint32_t param2, uint32_t param3, uint32_t param4 )
|
||||
|
@ -147,10 +147,10 @@ void Util::Packet::sendActorControl( Entity::Player& player, uint16_t category,
|
|||
server().queueForPlayer( player.getCharacterId(), makeActorControl( player.getId(), category, param1, param2, param3, param4 ) );
|
||||
}
|
||||
|
||||
void Util::Packet::sendActorControl( const std::set< uint64_t >& characterIds, Entity::Player& player, uint16_t category, uint32_t param1,
|
||||
void Util::Packet::sendActorControl( const std::set< uint64_t >& characterIds, uint32_t srcId, uint16_t category, uint32_t param1,
|
||||
uint32_t param2, uint32_t param3, uint32_t param4 )
|
||||
{
|
||||
server().queueForPlayers( characterIds, makeActorControl( player.getId(), category, param1, param2, param3, param4 ) );
|
||||
server().queueForPlayers( characterIds, makeActorControl( srcId, category, param1, param2, param3, param4 ) );
|
||||
}
|
||||
|
||||
void Util::Packet::sendActorControlTarget( Entity::Player& player, uint16_t category, uint32_t param1, uint32_t param2, uint32_t param3,
|
||||
|
@ -159,10 +159,10 @@ void Util::Packet::sendActorControlTarget( Entity::Player& player, uint16_t cate
|
|||
server().queueForPlayer( player.getCharacterId(), makeActorControlTarget( player.getId(), category, param1, param2, param3, param4, param5, param6 ) );
|
||||
}
|
||||
|
||||
void Util::Packet::sendActorControlTarget( const std::set< uint64_t >& characterIds, Entity::Player& player, uint16_t category, uint32_t param1,
|
||||
void Util::Packet::sendActorControlTarget( const std::set< uint64_t >& characterIds, uint32_t srcId, uint16_t category, uint32_t param1,
|
||||
uint32_t param2, uint32_t param3, uint32_t param4, uint32_t param5, uint32_t param6 )
|
||||
{
|
||||
server().queueForPlayers( characterIds, makeActorControlTarget( player.getId(), category, param1, param2, param3, param4, param5, param6 ) );
|
||||
server().queueForPlayers( characterIds, makeActorControlTarget( srcId, category, param1, param2, param3, param4, param5, param6 ) );
|
||||
}
|
||||
|
||||
void Util::Packet::sendTitleList( Entity::Player& player )
|
||||
|
@ -243,13 +243,13 @@ void Util::Packet::sendMount( Entity::Player& player )
|
|||
auto inRangePlayerIds = player.getInRangePlayerIds( true );
|
||||
if( mountId != 0 )
|
||||
{
|
||||
Network::Util::Packet::sendActorControl( inRangePlayerIds, player, SetStatus, static_cast< uint8_t >( Common::ActorStatus::Mounted ) );
|
||||
Network::Util::Packet::sendActorControlSelf( inRangePlayerIds, player, 0x39e, 12 );
|
||||
Network::Util::Packet::sendActorControl( inRangePlayerIds, player.getId(), SetStatus, static_cast< uint8_t >( Common::ActorStatus::Mounted ) );
|
||||
Network::Util::Packet::sendActorControlSelf( inRangePlayerIds, player.getId(), 0x39e, 12 );
|
||||
}
|
||||
else
|
||||
{
|
||||
Network::Util::Packet::sendActorControl( inRangePlayerIds, player, SetStatus, static_cast< uint8_t >( Common::ActorStatus::Idle ) );
|
||||
Network::Util::Packet::sendActorControlSelf( inRangePlayerIds, player, Dismount, 1 );
|
||||
Network::Util::Packet::sendActorControl( inRangePlayerIds, player.getId(), SetStatus, static_cast< uint8_t >( Common::ActorStatus::Idle ) );
|
||||
Network::Util::Packet::sendActorControlSelf( inRangePlayerIds, player.getId(), Dismount, 1 );
|
||||
}
|
||||
auto mountPacket = makeZonePacket< FFXIVIpcMount >( player.getId() );
|
||||
mountPacket->data().id = mountId;
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Sapphire::Network::Util::Packet
|
|||
void sendConfigFlags( Entity::Player& player );
|
||||
void sendOnlineStatus( Entity::Player& player );
|
||||
void sendBaseParams( Entity::Player& player );
|
||||
void sendHudParam( Entity::Player& player );
|
||||
void sendHudParam( Entity::Chara& player );
|
||||
void sendStatusUpdate( Entity::Player& player );
|
||||
|
||||
void sendHuntingLog( Entity::Player& player );
|
||||
|
@ -55,17 +55,17 @@ namespace Sapphire::Network::Util::Packet
|
|||
void sendActorControlSelf( Entity::Player& player, uint16_t category, uint32_t param1 = 0, uint32_t param2 = 0, uint32_t param3 = 0,
|
||||
uint32_t param4 = 0, uint32_t param5 = 0 );
|
||||
|
||||
void sendActorControlSelf( const std::set< uint64_t >& characterIds, Entity::Player& player, uint16_t category, uint32_t param1 = 0,
|
||||
void sendActorControlSelf( const std::set< uint64_t >& characterIds, uint32_t srcId, uint16_t category, uint32_t param1 = 0,
|
||||
uint32_t param2 = 0, uint32_t param3 = 0, uint32_t param4 = 0, uint32_t param5 = 0 );
|
||||
|
||||
void sendActorControl( Entity::Player& player, uint16_t category, uint32_t param1 = 0, uint32_t param2 = 0, uint32_t param3 = 0, uint32_t param4 = 0 );
|
||||
|
||||
void sendActorControl( const std::set< uint64_t >& characterIds, Entity::Player& player, uint16_t category, uint32_t param1 = 0, uint32_t param2 = 0,
|
||||
void sendActorControl( const std::set< uint64_t >& characterIds, uint32_t srcId, uint16_t category, uint32_t param1 = 0, uint32_t param2 = 0,
|
||||
uint32_t param3 = 0, uint32_t param4 = 0 );
|
||||
|
||||
void sendActorControlTarget( Entity::Player& player, uint16_t category, uint32_t param1 = 0, uint32_t param2 = 0, uint32_t param3 = 0,
|
||||
uint32_t param4 = 0, uint32_t param5 = 0, uint32_t param6 = 0 );
|
||||
|
||||
void sendActorControlTarget( const std::set< uint64_t >& characterIds, Entity::Player& player, uint16_t category, uint32_t param1 = 0,
|
||||
void sendActorControlTarget( const std::set< uint64_t >& characterIds, uint32_t srcId, uint16_t category, uint32_t param1 = 0,
|
||||
uint32_t param2 = 0, uint32_t param3 = 0, uint32_t param4 = 0, uint32_t param5 = 0, uint32_t param6 = 0 );
|
||||
}
|
Loading…
Add table
Reference in a new issue