mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 06:27:45 +00:00
General cleanup work
This commit is contained in:
parent
1a18f1a9ce
commit
b571be8b6f
28 changed files with 172 additions and 175 deletions
|
@ -190,9 +190,7 @@ namespace Sapphire::Network::Packets
|
|||
LandPriceUpdate = 0x0224, // updated 4.4
|
||||
LandInfoSign = 0x0225, // updated 4.4
|
||||
LandRename = 0x0226, // updated 4.4
|
||||
|
||||
HousingEstateGreeting = 0x0227, // updated 4.4
|
||||
|
||||
HousingUpdateLandFlagsSlot = 0x0228, // updated 4.4
|
||||
HousingLandFlags = 0x0229, // updated 4.4
|
||||
HousingShowEstateGuestAccess = 0x022A, // updated 4.4
|
||||
|
@ -200,7 +198,6 @@ namespace Sapphire::Network::Packets
|
|||
LandSetYardInitialize = 0x022C, // updated 4.4
|
||||
|
||||
HousingWardInfo = 0x022F, // updated 4.4
|
||||
|
||||
YardObjectMove = 0x0230, // updated 4.4
|
||||
|
||||
SharedEstateSettingsResponse = 0x023C, // updated 4.4
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <cmath>
|
||||
#include "UtilMath.h"
|
||||
|
||||
float Sapphire::Math::Util::distanceSq( float x, float y, float z, float x1, float y1, float z1 )
|
||||
float Sapphire::Util::distanceSq( float x, float y, float z, float x1, float y1, float z1 )
|
||||
{
|
||||
float deltaX = x - x1;
|
||||
float deltaY = y - y1;
|
||||
|
@ -10,24 +10,24 @@ float Sapphire::Math::Util::distanceSq( float x, float y, float z, float x1, flo
|
|||
return ( deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ );
|
||||
}
|
||||
|
||||
float Sapphire::Math::Util::distance( float x, float y, float z, float x1, float y1, float z1 )
|
||||
float Sapphire::Util::distance( float x, float y, float z, float x1, float y1, float z1 )
|
||||
{
|
||||
return sqrtf( distanceSq( x, y, z, x1, y1, z1 ) );
|
||||
}
|
||||
|
||||
float Sapphire::Math::Util::distance2DSq( float x, float y, float x1, float y1 )
|
||||
float Sapphire::Util::distance2DSq( float x, float y, float x1, float y1 )
|
||||
{
|
||||
float deltaX = x - x1;
|
||||
float deltaY = y - y1;
|
||||
return ( deltaX * deltaX + deltaY * deltaY );
|
||||
}
|
||||
|
||||
float Sapphire::Math::Util::distance2D( float x, float y, float x1, float y1 )
|
||||
float Sapphire::Util::distance2D( float x, float y, float x1, float y1 )
|
||||
{
|
||||
return sqrtf( distance2DSq( x, y, x1, y1 ) );
|
||||
}
|
||||
|
||||
float Sapphire::Math::Util::calcAngTo( float x, float y, float x1, float y1 )
|
||||
float Sapphire::Util::calcAngTo( float x, float y, float x1, float y1 )
|
||||
{
|
||||
float dx = x - x1;
|
||||
float dy = y - y1;
|
||||
|
@ -41,7 +41,7 @@ float Sapphire::Math::Util::calcAngTo( float x, float y, float x1, float y1 )
|
|||
}
|
||||
}
|
||||
|
||||
float Sapphire::Math::Util::calcAngFrom( float x, float y, float x1, float y1 )
|
||||
float Sapphire::Util::calcAngFrom( float x, float y, float x1, float y1 )
|
||||
{
|
||||
float dx = x - x1;
|
||||
float dy = y - y1;
|
||||
|
@ -55,17 +55,17 @@ float Sapphire::Math::Util::calcAngFrom( float x, float y, float x1, float y1 )
|
|||
}
|
||||
}
|
||||
|
||||
uint16_t Sapphire::Math::Util::floatToUInt16( float val )
|
||||
uint16_t Sapphire::Util::floatToUInt16( float val )
|
||||
{
|
||||
return static_cast< uint16_t >( 0x8000 + val * 32.767f );
|
||||
}
|
||||
|
||||
uint16_t Sapphire::Math::Util::floatToUInt16Rot( float val )
|
||||
uint16_t Sapphire::Util::floatToUInt16Rot( float val )
|
||||
{
|
||||
return static_cast< uint16_t >( 0x8000 * ( ( val + PI ) ) / PI );
|
||||
}
|
||||
|
||||
uint8_t Sapphire::Math::Util::floatToUInt8Rot( float val )
|
||||
uint8_t Sapphire::Util::floatToUInt8Rot( float val )
|
||||
{
|
||||
return static_cast< uint8_t >( 0x80 * ( ( val + PI ) ) / PI );
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#define PI 3.14159265358979323846f
|
||||
|
||||
namespace Sapphire::Math::Util
|
||||
namespace Sapphire::Util
|
||||
{
|
||||
|
||||
float distanceSq( float x, float y, float z, float x1, float y1, float z1 );
|
||||
|
|
|
@ -83,6 +83,7 @@ public:
|
|||
}
|
||||
|
||||
}
|
||||
return LandPurchaseResult::ERR_INTERNAL;
|
||||
};
|
||||
|
||||
player.playScene( getId(), 0, HIDE_HOTBAR, 0, 0, callback );
|
||||
|
|
|
@ -129,8 +129,8 @@ std::set< Sapphire::Entity::ActorPtr > ActionCollision::getActorsHitFromAction(
|
|||
bool
|
||||
ActionCollision::radiusCollision( FFXIVARR_POSITION3 actorPosition, FFXIVARR_POSITION3 aoePosition, uint16_t radius )
|
||||
{
|
||||
return Sapphire::Math::Util::distance( actorPosition.x, actorPosition.y, actorPosition.z,
|
||||
aoePosition.x, aoePosition.y, aoePosition.z ) <= radius;
|
||||
return Sapphire::Util::distance( actorPosition.x, actorPosition.y, actorPosition.z,
|
||||
aoePosition.x, aoePosition.y, aoePosition.z ) <= radius;
|
||||
}
|
||||
|
||||
bool ActionCollision::boxCollision( FFXIVARR_POSITION3 actorPosition, FFXIVARR_POSITION3 aoePosition, uint16_t width,
|
||||
|
|
|
@ -75,7 +75,7 @@ void Sapphire::Action::ActionMount::onFinish()
|
|||
pPlayer->unsetStateFlag( PlayerStateFlag::Casting );
|
||||
|
||||
auto effectPacket = std::make_shared< Server::EffectPacket >( getId(), pPlayer->getId(), 4 );
|
||||
effectPacket->setRotation( Math::Util::floatToUInt16Rot( pPlayer->getRot() ) );
|
||||
effectPacket->setRotation( Util::floatToUInt16Rot( pPlayer->getRot() ) );
|
||||
|
||||
Server::EffectEntry effectEntry{};
|
||||
effectEntry.effectType = ActionEffectType::Mount;
|
||||
|
|
|
@ -87,7 +87,7 @@ void Sapphire::Action::ActionTeleport::onFinish()
|
|||
pPlayer->setZoningType( ZoneingType::Teleport );
|
||||
|
||||
auto effectPacket = std::make_shared< Server::EffectPacket >( getId(), pPlayer->getId(), 5 );
|
||||
effectPacket->setRotation( Math::Util::floatToUInt16Rot( pPlayer->getRot() ) );
|
||||
effectPacket->setRotation( Util::floatToUInt16Rot( pPlayer->getRot() ) );
|
||||
|
||||
|
||||
pPlayer->sendToInRangeSet( effectPacket, true );
|
||||
|
|
|
@ -73,7 +73,7 @@ void Sapphire::Action::EventItemAction::onFinish()
|
|||
{
|
||||
auto effectPacket = std::make_shared< Server::EffectPacket >( m_pSource->getId(), m_additional, m_id );
|
||||
effectPacket->setAnimationId( 1 );
|
||||
effectPacket->setRotation( Math::Util::floatToUInt16Rot( m_pSource->getRot() ) );
|
||||
effectPacket->setRotation( Util::floatToUInt16Rot( m_pSource->getRot() ) );
|
||||
|
||||
m_pSource->getAsPlayer()->unsetStateFlag( Common::PlayerStateFlag::Casting );
|
||||
m_pSource->sendToInRangeSet( effectPacket, true );
|
||||
|
|
|
@ -268,12 +268,8 @@ Sapphire::Entity::ActorPtr Sapphire::Entity::Actor::getClosestActor()
|
|||
|
||||
for( const auto& pCurAct : m_inRangeActor )
|
||||
{
|
||||
float distance = Math::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 )
|
||||
{
|
||||
|
|
|
@ -239,7 +239,7 @@ position
|
|||
bool Sapphire::Entity::Chara::face( const Common::FFXIVARR_POSITION3& p )
|
||||
{
|
||||
float oldRot = getRot();
|
||||
float rot = Math::Util::calcAngFrom( getPos().x, getPos().z, p.x, p.z );
|
||||
float rot = Util::calcAngFrom( getPos().x, getPos().z, p.x, p.z );
|
||||
float newRot = PI - rot + ( PI / 2 );
|
||||
|
||||
m_pCell = nullptr;
|
||||
|
@ -403,7 +403,7 @@ void Sapphire::Entity::Chara::autoAttack( CharaPtr pTarget )
|
|||
uint32_t variation = static_cast< uint32_t >( 0 + rand() % 4 );
|
||||
|
||||
auto effectPacket = std::make_shared< Server::EffectPacket >( getId(), pTarget->getId(), 0x336 );
|
||||
effectPacket->setRotation( Math::Util::floatToUInt16Rot( getRot() ) );
|
||||
effectPacket->setRotation( Util::floatToUInt16Rot( getRot() ) );
|
||||
|
||||
Server::EffectEntry effectEntry{};
|
||||
effectEntry.value = damage;
|
||||
|
@ -443,7 +443,7 @@ void Sapphire::Entity::Chara::handleScriptSkill( uint32_t type, uint16_t actionI
|
|||
// Prepare packet. This is seemingly common for all packets in the action handler.
|
||||
|
||||
auto effectPacket = std::make_shared< Server::EffectPacket >( getId(), target.getId(), actionId );
|
||||
effectPacket->setRotation( Math::Util::floatToUInt16Rot( getRot() ) );
|
||||
effectPacket->setRotation( Util::floatToUInt16Rot( getRot() ) );
|
||||
|
||||
// Todo: for each actor, calculate how much damage the calculated value should deal to them - 2-step damage calc. we only have 1-step
|
||||
switch( type )
|
||||
|
|
|
@ -137,7 +137,7 @@ void Sapphire::Entity::EventObject::spawn( Sapphire::Entity::PlayerPtr pTarget )
|
|||
eobjStatePacket->data().scale = getScale();
|
||||
eobjStatePacket->data().actorId = getId();
|
||||
eobjStatePacket->data().housingLink = getHousingLink();
|
||||
eobjStatePacket->data().rotation = Math::Util::floatToUInt16Rot( getRot() );
|
||||
eobjStatePacket->data().rotation = Util::floatToUInt16Rot( getRot() );
|
||||
pTarget->queuePacket( eobjStatePacket );
|
||||
}
|
||||
|
||||
|
|
|
@ -1020,7 +1020,7 @@ void Sapphire::Entity::Player::update( int64_t currTime )
|
|||
else
|
||||
{
|
||||
auto setActorPosPacket = makeZonePacket< FFXIVIpcActorSetPos >( getId() );
|
||||
setActorPosPacket->data().r16 = Math::Util::floatToUInt16Rot( m_queuedZoneing->m_targetRotation );
|
||||
setActorPosPacket->data().r16 = Util::floatToUInt16Rot( m_queuedZoneing->m_targetRotation );
|
||||
setActorPosPacket->data().waitForLoad = 0x04;
|
||||
setActorPosPacket->data().x = targetPos.x;
|
||||
setActorPosPacket->data().y = targetPos.y;
|
||||
|
@ -1064,8 +1064,8 @@ void Sapphire::Entity::Player::update( int64_t currTime )
|
|||
range = 25;
|
||||
|
||||
|
||||
if( Math::Util::distance( getPos().x, getPos().y, getPos().z,
|
||||
actor->getPos().x, actor->getPos().y, actor->getPos().z ) <= range )
|
||||
if( Util::distance( getPos().x, getPos().y, getPos().z,
|
||||
actor->getPos().x, actor->getPos().y, actor->getPos().z ) <= range )
|
||||
{
|
||||
|
||||
if( ( currTime - m_lastAttack ) > mainWeap->getDelay() )
|
||||
|
@ -1438,7 +1438,7 @@ void Sapphire::Entity::Player::autoAttack( CharaPtr pTarget )
|
|||
if( getClass() == ClassJob::Machinist || getClass() == ClassJob::Bard || getClass() == ClassJob::Archer )
|
||||
{
|
||||
auto effectPacket = std::make_shared< Server::EffectPacket >( getId(), pTarget->getId(), 8 );
|
||||
effectPacket->setRotation( Math::Util::floatToUInt16Rot( getRot() ) );
|
||||
effectPacket->setRotation( Util::floatToUInt16Rot( getRot() ) );
|
||||
|
||||
Server::EffectEntry entry;
|
||||
entry.value = damage;
|
||||
|
@ -1452,7 +1452,7 @@ void Sapphire::Entity::Player::autoAttack( CharaPtr pTarget )
|
|||
else
|
||||
{
|
||||
auto effectPacket = std::make_shared< Server::EffectPacket >( getId(), pTarget->getId(), 7 );
|
||||
effectPacket->setRotation( Math::Util::floatToUInt16Rot( getRot() ) );
|
||||
effectPacket->setRotation( Util::floatToUInt16Rot( getRot() ) );
|
||||
|
||||
Server::EffectEntry entry;
|
||||
entry.value = damage;
|
||||
|
|
|
@ -666,7 +666,7 @@ void Sapphire::DebugCommandHandler::nudge( char* data, Entity::Player& player, s
|
|||
setActorPosPacket->data().x = player.getPos().x;
|
||||
setActorPosPacket->data().y = player.getPos().y;
|
||||
setActorPosPacket->data().z = player.getPos().z;
|
||||
setActorPosPacket->data().r16 = Math::Util::floatToUInt16Rot( player.getRot() );
|
||||
setActorPosPacket->data().r16 = Util::floatToUInt16Rot( player.getRot() );
|
||||
player.queuePacket( setActorPosPacket );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,8 @@ x ## Ptr make_ ## x( Args &&...args ) { \
|
|||
return std::make_shared< x >( std::forward< Args >( args ) ... ); }\
|
||||
typedef std::vector< x > x ## PtrList;
|
||||
|
||||
namespace Sapphire {
|
||||
namespace Sapphire
|
||||
{
|
||||
TYPE_FORWARD( Cell );
|
||||
TYPE_FORWARD( Zone );
|
||||
TYPE_FORWARD( HousingZone );
|
||||
|
@ -27,6 +28,7 @@ TYPE_FORWARD( ItemContainer );
|
|||
TYPE_FORWARD( Session );
|
||||
TYPE_FORWARD( ZonePosition );
|
||||
TYPE_FORWARD( Land )
|
||||
TYPE_FORWARD( Linkshell )
|
||||
|
||||
namespace World::Territory::Housing
|
||||
{
|
||||
|
@ -38,12 +40,14 @@ namespace World::Manager
|
|||
TYPE_FORWARD( HousingMgr );
|
||||
}
|
||||
|
||||
namespace StatusEffect {
|
||||
namespace StatusEffect
|
||||
{
|
||||
TYPE_FORWARD( StatusEffect );
|
||||
TYPE_FORWARD( StatusEffectContainer );
|
||||
}
|
||||
|
||||
namespace Entity {
|
||||
namespace Entity
|
||||
{
|
||||
TYPE_FORWARD( Actor );
|
||||
TYPE_FORWARD( Chara );
|
||||
TYPE_FORWARD( Player );
|
||||
|
@ -52,12 +56,14 @@ TYPE_FORWARD( BNpcTemplate );
|
|||
TYPE_FORWARD( BNpc );
|
||||
}
|
||||
|
||||
namespace Event {
|
||||
namespace Event
|
||||
{
|
||||
TYPE_FORWARD( Director );
|
||||
TYPE_FORWARD( EventHandler );
|
||||
}
|
||||
|
||||
namespace Action {
|
||||
namespace Action
|
||||
{
|
||||
TYPE_FORWARD( Action );
|
||||
TYPE_FORWARD( ActionTeleport );
|
||||
TYPE_FORWARD( ActionCast );
|
||||
|
@ -66,7 +72,8 @@ TYPE_FORWARD( EventAction );
|
|||
TYPE_FORWARD( EventItemAction );
|
||||
}
|
||||
|
||||
namespace Network {
|
||||
namespace Network
|
||||
{
|
||||
TYPE_FORWARD( Hive );
|
||||
TYPE_FORWARD( Acceptor );
|
||||
TYPE_FORWARD( Connection );
|
||||
|
@ -74,17 +81,20 @@ TYPE_FORWARD( GameConnection );
|
|||
TYPE_FORWARD( SessionConnection );
|
||||
TYPE_FORWARD( CustomMsgClientConnection );
|
||||
|
||||
namespace Packets {
|
||||
namespace Packets
|
||||
{
|
||||
TYPE_FORWARD( GamePacket );
|
||||
TYPE_FORWARD( FFXIVPacketBase );
|
||||
}
|
||||
}
|
||||
|
||||
namespace ContentFinder {
|
||||
namespace ContentFinder
|
||||
{
|
||||
TYPE_FORWARD( ContentFinder );
|
||||
}
|
||||
|
||||
namespace Scripting {
|
||||
namespace Scripting
|
||||
{
|
||||
class NativeScriptMgr;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include "Linkshell.h"
|
||||
|
||||
|
||||
Sapphire::Linkshell::Linkshell( uint64_t id,
|
||||
const std::string& name,
|
||||
uint64_t masterId,
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
#include <Logging/Logger.h>
|
||||
#include <Database/DatabaseDef.h>
|
||||
|
||||
#include "Linkshell.h"
|
||||
#include "Linkshell/Linkshell.h"
|
||||
#include "Framework.h"
|
||||
#include "LinkshellMgr.h"
|
||||
|
||||
extern Sapphire::Framework g_fw;
|
||||
|
||||
Sapphire::LinkshellMgr::LinkshellMgr()
|
||||
Sapphire::World::Manager::LinkshellMgr::LinkshellMgr()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool Sapphire::LinkshellMgr::loadLinkshells()
|
||||
bool Sapphire::World::Manager::LinkshellMgr::loadLinkshells()
|
||||
{
|
||||
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
auto res = pDb->query( "SELECT LinkshellId, MasterCharacterId, CharacterIdList, "
|
||||
|
@ -61,7 +60,7 @@ bool Sapphire::LinkshellMgr::loadLinkshells()
|
|||
|
||||
}
|
||||
|
||||
Sapphire::LinkshellPtr Sapphire::LinkshellMgr::getLinkshellByName( const std::string& name )
|
||||
Sapphire::LinkshellPtr Sapphire::World::Manager::LinkshellMgr::getLinkshellByName( const std::string& name )
|
||||
{
|
||||
auto it = m_linkshellNameMap.find( name );
|
||||
if( it == m_linkshellNameMap.end() )
|
||||
|
@ -70,7 +69,7 @@ Sapphire::LinkshellPtr Sapphire::LinkshellMgr::getLinkshellByName( const std::st
|
|||
return it->second;
|
||||
}
|
||||
|
||||
Sapphire::LinkshellPtr Sapphire::LinkshellMgr::getLinkshellById( uint64_t lsId )
|
||||
Sapphire::LinkshellPtr Sapphire::World::Manager::LinkshellMgr::getLinkshellById( uint64_t lsId )
|
||||
{
|
||||
auto it = m_linkshellIdMap.find( lsId );
|
||||
if( it == m_linkshellIdMap.end() )
|
|
@ -1,14 +1,12 @@
|
|||
#ifndef CORE_LINKSHELLMGR_H
|
||||
#define CORE_LINKSHELLMGR_H
|
||||
#ifndef SAPPHIRE_LINKSHELLMGR_H
|
||||
#define SAPPHIRE_LINKSHELLMGR_H
|
||||
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include "ForwardsZone.h"
|
||||
|
||||
namespace Sapphire
|
||||
namespace Sapphire::World::Manager
|
||||
{
|
||||
class Linkshell;
|
||||
|
||||
using LinkshellPtr = std::shared_ptr< Linkshell >;
|
||||
|
||||
class LinkshellMgr
|
||||
{
|
||||
|
@ -27,4 +25,4 @@ namespace Sapphire
|
|||
};
|
||||
|
||||
}
|
||||
#endif //CORE_LINKSHELLMGR_H
|
||||
#endif //SAPPHIRE_LINKSHELLMGR_H
|
|
@ -297,7 +297,8 @@ Sapphire::ZonePtr Sapphire::World::Manager::TerritoryMgr::findOrCreateHousingInt
|
|||
auto housingMgr = g_fw.get< Manager::HousingMgr >();
|
||||
|
||||
auto parentZone = std::dynamic_pointer_cast< HousingZone >(
|
||||
getZoneByLandSetId( housingMgr->toLandSetId( landIdent.territoryTypeId, landIdent.wardNum ) ) );
|
||||
getZoneByLandSetId( housingMgr->toLandSetId( static_cast< uint16_t >( landIdent.territoryTypeId ),
|
||||
static_cast< uint8_t >( landIdent.wardNum ) ) ) );
|
||||
|
||||
if( !parentZone )
|
||||
return nullptr;
|
||||
|
|
|
@ -29,14 +29,14 @@ namespace Sapphire::Network::Packets::Server
|
|||
void initialize( Entity::Chara& actor, uint8_t unk1, uint8_t unk2, uint8_t unk3, uint16_t unk4 )
|
||||
{
|
||||
|
||||
m_data.rotation = Math::Util::floatToUInt8Rot( actor.getRot() );
|
||||
m_data.rotation = Util::floatToUInt8Rot( actor.getRot() );
|
||||
m_data.unknown_1 = unk1;
|
||||
m_data.unknown_2 = unk2;
|
||||
m_data.unknown_3 = unk3;
|
||||
m_data.unknown_4 = unk4;
|
||||
m_data.posX = Math::Util::floatToUInt16( actor.getPos().x );
|
||||
m_data.posY = Math::Util::floatToUInt16( actor.getPos().y );
|
||||
m_data.posZ = Math::Util::floatToUInt16( actor.getPos().z );
|
||||
m_data.posX = Util::floatToUInt16( actor.getPos().x );
|
||||
m_data.posY = Util::floatToUInt16( actor.getPos().y );
|
||||
m_data.posZ = Util::floatToUInt16( actor.getPos().z );
|
||||
|
||||
};
|
||||
};
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace Sapphire::Network::Packets::Server
|
|||
m_data.pos.x = bnpc.getPos().x;
|
||||
m_data.pos.y = bnpc.getPos().y;
|
||||
m_data.pos.z = bnpc.getPos().z;
|
||||
m_data.rotation = Math::Util::floatToUInt16Rot( bnpc.getRot() );
|
||||
m_data.rotation = Util::floatToUInt16Rot( bnpc.getRot() );
|
||||
|
||||
m_data.enemyType = bnpc.getEnemyType();
|
||||
m_data.mainWeaponModel = bnpc.getWeaponMain();
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace Sapphire::Network::Packets::Server
|
|||
m_data.pos.x = player.getPos().x;
|
||||
m_data.pos.y = player.getPos().y;
|
||||
m_data.pos.z = player.getPos().z;
|
||||
m_data.rotation = Math::Util::floatToUInt16Rot( player.getRot() );
|
||||
m_data.rotation = Util::floatToUInt16Rot( player.getRot() );
|
||||
|
||||
|
||||
m_data.title = player.getTitle();
|
||||
|
|
|
@ -121,7 +121,7 @@ void Sapphire::Scripting::ScriptMgr::watchDirectories()
|
|||
}
|
||||
|
||||
bool Sapphire::Scripting::ScriptMgr::loadDir( const std::string& dirname, std::set< std::string >& files,
|
||||
const std::string& ext )
|
||||
const std::string& ext )
|
||||
{
|
||||
|
||||
auto pLog = g_fw.get< Logger >();
|
||||
|
@ -190,19 +190,17 @@ bool Sapphire::Scripting::ScriptMgr::onTalk( Entity::Player& player, uint64_t ac
|
|||
}
|
||||
else
|
||||
{
|
||||
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId & 0xFFFF0000 );
|
||||
script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId & 0xFFFF0000 );
|
||||
if( !script )
|
||||
return false;
|
||||
|
||||
script->onTalk( eventId, player, actorId );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Sapphire::Scripting::ScriptMgr::onEnterTerritory( Entity::Player& player, uint32_t eventId,
|
||||
uint16_t param1, uint16_t param2 )
|
||||
uint16_t param1, uint16_t param2 )
|
||||
{
|
||||
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId );
|
||||
if( !script )
|
||||
|
@ -212,7 +210,7 @@ bool Sapphire::Scripting::ScriptMgr::onEnterTerritory( Entity::Player& player, u
|
|||
}
|
||||
|
||||
bool Sapphire::Scripting::ScriptMgr::onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1,
|
||||
float x, float y, float z )
|
||||
float x, float y, float z )
|
||||
{
|
||||
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId );
|
||||
if( !script )
|
||||
|
@ -222,7 +220,7 @@ bool Sapphire::Scripting::ScriptMgr::onWithinRange( Entity::Player& player, uint
|
|||
}
|
||||
|
||||
bool Sapphire::Scripting::ScriptMgr::onOutsideRange( Entity::Player& player, uint32_t eventId, uint32_t param1,
|
||||
float x, float y, float z )
|
||||
float x, float y, float z )
|
||||
{
|
||||
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId );
|
||||
if( !script )
|
||||
|
@ -232,7 +230,7 @@ bool Sapphire::Scripting::ScriptMgr::onOutsideRange( Entity::Player& player, uin
|
|||
}
|
||||
|
||||
bool Sapphire::Scripting::ScriptMgr::onEmote( Entity::Player& player, uint64_t actorId,
|
||||
uint32_t eventId, uint8_t emoteId )
|
||||
uint32_t eventId, uint8_t emoteId )
|
||||
{
|
||||
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId );
|
||||
if( !script )
|
||||
|
@ -242,15 +240,15 @@ bool Sapphire::Scripting::ScriptMgr::onEmote( Entity::Player& player, uint64_t a
|
|||
}
|
||||
|
||||
bool Sapphire::Scripting::ScriptMgr::onEventHandlerReturn( Entity::Player& player, uint32_t eventId,
|
||||
uint16_t subEvent, uint16_t param1, uint16_t param2,
|
||||
uint16_t param3 )
|
||||
uint16_t subEvent, uint16_t param1, uint16_t param2,
|
||||
uint16_t param3 )
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Sapphire::Scripting::ScriptMgr::onEventHandlerTradeReturn( Entity::Player& player, uint32_t eventId,
|
||||
uint16_t subEvent, uint16_t param, uint32_t catalogId )
|
||||
uint16_t subEvent, uint16_t param, uint32_t catalogId )
|
||||
{
|
||||
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId );
|
||||
if( script )
|
||||
|
@ -263,7 +261,7 @@ bool Sapphire::Scripting::ScriptMgr::onEventHandlerTradeReturn( Entity::Player&
|
|||
}
|
||||
|
||||
bool Sapphire::Scripting::ScriptMgr::onEventItem( Entity::Player& player, uint32_t eventItemId,
|
||||
uint32_t eventId, uint32_t castTime, uint64_t targetId )
|
||||
uint32_t eventId, uint32_t castTime, uint64_t targetId )
|
||||
{
|
||||
std::string eventName = "onEventItem";
|
||||
std::string objName = Event::getEventName( eventId );
|
||||
|
@ -402,7 +400,7 @@ bool Sapphire::Scripting::ScriptMgr::onInstanceUpdate( InstanceContentPtr instan
|
|||
}
|
||||
|
||||
bool Sapphire::Scripting::ScriptMgr::onInstanceEnterTerritory( InstanceContentPtr instance, Entity::Player& player,
|
||||
uint32_t eventId, uint16_t param1, uint16_t param2 )
|
||||
uint32_t eventId, uint16_t param1, uint16_t param2 )
|
||||
{
|
||||
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::InstanceContentScript >( instance->getDirectorId() );
|
||||
if( script )
|
||||
|
|
|
@ -22,9 +22,10 @@
|
|||
#include "Session.h"
|
||||
|
||||
#include "Manager/TerritoryMgr.h"
|
||||
#include "Manager/LinkshellMgr.h"
|
||||
|
||||
#include "Script/ScriptMgr.h"
|
||||
#include "Linkshell/LinkshellMgr.h"
|
||||
|
||||
|
||||
extern Sapphire::Framework g_fw;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ Housing::HousingInteriorTerritory::~HousingInteriorTerritory()
|
|||
|
||||
bool Housing::HousingInteriorTerritory::init()
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Housing::HousingInteriorTerritory::onPlayerZoneIn( Entity::Player& player )
|
||||
|
|
|
@ -296,7 +296,7 @@ void Sapphire::Land::update( uint32_t currTime )
|
|||
if( m_nextDrop < currTime && m_minPrice < m_currentPrice )
|
||||
{
|
||||
m_nextDrop = currTime + 21600;
|
||||
m_currentPrice = ( m_currentPrice / 100 ) * 99.58;
|
||||
m_currentPrice = static_cast< uint32_t >( ( m_currentPrice / 100 ) * 99.58f );
|
||||
updateLandDb();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,8 @@ Sapphire::Zone::Zone() :
|
|||
{
|
||||
}
|
||||
|
||||
Sapphire::Zone::Zone( uint16_t territoryTypeId, uint32_t guId, const std::string& internalName, const std::string& placeName ) :
|
||||
Sapphire::Zone::Zone( uint16_t territoryTypeId, uint32_t guId,
|
||||
const std::string& internalName, const std::string& placeName ) :
|
||||
m_currentWeather( Weather::FairSkies ),
|
||||
m_nextEObjId( 0x400D0000 )
|
||||
{
|
||||
|
@ -278,7 +279,7 @@ void Sapphire::Zone::removeActor( Entity::ActorPtr pActor )
|
|||
}
|
||||
|
||||
void Sapphire::Zone::queuePacketForRange( Entity::Player& sourcePlayer, uint32_t range,
|
||||
Network::Packets::FFXIVPacketBasePtr pPacketEntry )
|
||||
Network::Packets::FFXIVPacketBasePtr pPacketEntry )
|
||||
{
|
||||
auto pTeriMgr = g_fw.get< TerritoryMgr >();
|
||||
if( pTeriMgr->isPrivateTerritory( getTerritoryTypeId() ) )
|
||||
|
@ -288,12 +289,8 @@ void Sapphire::Zone::queuePacketForRange( Entity::Player& sourcePlayer, uint32_t
|
|||
for( auto entry : m_playerMap )
|
||||
{
|
||||
auto player = entry.second;
|
||||
float distance = Math::Util::distance( sourcePlayer.getPos().x,
|
||||
sourcePlayer.getPos().y,
|
||||
sourcePlayer.getPos().z,
|
||||
player->getPos().x,
|
||||
player->getPos().y,
|
||||
player->getPos().z );
|
||||
float distance = Util::distance( sourcePlayer.getPos().x, sourcePlayer.getPos().y, sourcePlayer.getPos().z,
|
||||
player->getPos().x, player->getPos().y, player->getPos().z );
|
||||
|
||||
if( ( distance < range ) && sourcePlayer.getId() != player->getId() )
|
||||
{
|
||||
|
@ -307,8 +304,8 @@ void Sapphire::Zone::queuePacketForRange( Entity::Player& sourcePlayer, uint32_t
|
|||
}
|
||||
|
||||
void Sapphire::Zone::queuePacketForZone( Entity::Player& sourcePlayer,
|
||||
Network::Packets::FFXIVPacketBasePtr pPacketEntry,
|
||||
bool forSelf )
|
||||
Network::Packets::FFXIVPacketBasePtr pPacketEntry,
|
||||
bool forSelf )
|
||||
{
|
||||
auto pTeriMgr = g_fw.get< TerritoryMgr >();
|
||||
if( pTeriMgr->isPrivateTerritory( getTerritoryTypeId() ) )
|
||||
|
@ -648,8 +645,8 @@ void Sapphire::Zone::updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell )
|
|||
if( !pCurAct || pCurAct == pActor )
|
||||
continue;
|
||||
|
||||
float distance = Math::Util::distance( pCurAct->getPos().x, pCurAct->getPos().y, pCurAct->getPos().z,
|
||||
pActor->getPos().x, pActor->getPos().y, pActor->getPos().z );
|
||||
float distance = Util::distance( pCurAct->getPos().x, pCurAct->getPos().y, pCurAct->getPos().z,
|
||||
pActor->getPos().x, pActor->getPos().y, pActor->getPos().z );
|
||||
|
||||
bool isInRange = ( fRange == 0.0f || distance <= fRange );
|
||||
bool isInRangeSet = pActor->isInRangeSet( pCurAct );
|
||||
|
@ -750,8 +747,8 @@ uint32_t Sapphire::Zone::getNextEObjId()
|
|||
}
|
||||
|
||||
Sapphire::Entity::EventObjectPtr Sapphire::Zone::registerEObj( const std::string& name, uint32_t objectId, uint32_t mapLink,
|
||||
uint8_t state, FFXIVARR_POSITION3 pos, float scale,
|
||||
float rotation )
|
||||
uint8_t state, FFXIVARR_POSITION3 pos, float scale,
|
||||
float rotation )
|
||||
{
|
||||
auto eObj = Entity::make_EventObject( getNextEObjId(), objectId, mapLink, state, pos, rotation, name );
|
||||
eObj->setScale( scale );
|
||||
|
|
|
@ -19,136 +19,136 @@
|
|||
namespace Sapphire
|
||||
{
|
||||
|
||||
class Session;
|
||||
class Session;
|
||||
|
||||
class ZonePosition;
|
||||
class ZonePosition;
|
||||
|
||||
using SessionSet = std::set< SessionPtr >;
|
||||
using FestivalPair = std::pair< uint16_t, uint16_t >;
|
||||
using SessionSet = std::set< SessionPtr >;
|
||||
using FestivalPair = std::pair< uint16_t, uint16_t >;
|
||||
|
||||
namespace Data
|
||||
{
|
||||
struct InstanceContent;
|
||||
struct TerritoryType;
|
||||
}
|
||||
namespace Data
|
||||
{
|
||||
struct InstanceContent;
|
||||
struct TerritoryType;
|
||||
}
|
||||
|
||||
class Zone : public CellHandler< Cell >, public std::enable_shared_from_this< Zone >
|
||||
{
|
||||
protected:
|
||||
uint32_t m_territoryTypeId;
|
||||
uint32_t m_guId;
|
||||
class Zone : public CellHandler< Cell >, public std::enable_shared_from_this< Zone >
|
||||
{
|
||||
protected:
|
||||
uint32_t m_territoryTypeId;
|
||||
uint32_t m_guId;
|
||||
|
||||
std::string m_placeName;
|
||||
std::string m_internalName;
|
||||
std::string m_placeName;
|
||||
std::string m_internalName;
|
||||
|
||||
std::unordered_map< int32_t, Entity::PlayerPtr > m_playerMap;
|
||||
std::unordered_map< int32_t, Entity::BNpcPtr > m_bNpcMap;
|
||||
std::unordered_map< int32_t, Entity::EventObjectPtr > m_eventObjects;
|
||||
std::unordered_map< int32_t, Entity::PlayerPtr > m_playerMap;
|
||||
std::unordered_map< int32_t, Entity::BNpcPtr > m_bNpcMap;
|
||||
std::unordered_map< int32_t, Entity::EventObjectPtr > m_eventObjects;
|
||||
|
||||
SessionSet m_sessionSet;
|
||||
SessionSet m_sessionSet;
|
||||
|
||||
Common::Weather m_currentWeather;
|
||||
Common::Weather m_weatherOverride;
|
||||
Common::Weather m_currentWeather;
|
||||
Common::Weather m_weatherOverride;
|
||||
|
||||
uint64_t m_lastMobUpdate;
|
||||
uint64_t m_lastMobUpdate;
|
||||
|
||||
FestivalPair m_currentFestival;
|
||||
FestivalPair m_currentFestival;
|
||||
|
||||
std::shared_ptr< Data::TerritoryType > m_territoryTypeInfo;
|
||||
std::shared_ptr< Data::TerritoryType > m_territoryTypeInfo;
|
||||
|
||||
std::map< uint8_t, int32_t > m_weatherRateMap;
|
||||
std::map< uint8_t, int32_t > m_weatherRateMap;
|
||||
|
||||
uint32_t m_nextEObjId;
|
||||
uint32_t m_nextEObjId;
|
||||
|
||||
public:
|
||||
Zone();
|
||||
public:
|
||||
Zone();
|
||||
|
||||
Zone( uint16_t territoryTypeId, uint32_t guId, const std::string& internalName, const std::string& placeName );
|
||||
Zone( uint16_t territoryTypeId, uint32_t guId, const std::string& internalName, const std::string& placeName );
|
||||
|
||||
virtual ~Zone();
|
||||
virtual ~Zone();
|
||||
|
||||
/*! overrides the zone's weather, set to 0 to unlock */
|
||||
void setWeatherOverride( Common::Weather weather );
|
||||
/*! overrides the zone's weather, set to 0 to unlock */
|
||||
void setWeatherOverride( Common::Weather weather );
|
||||
|
||||
Common::Weather getCurrentWeather() const;
|
||||
Common::Weather getCurrentWeather() const;
|
||||
|
||||
const FestivalPair& getCurrentFestival() const;
|
||||
const FestivalPair& getCurrentFestival() const;
|
||||
|
||||
void setCurrentFestival( uint16_t festivalId, uint16_t additionalFestivalId = 0 );
|
||||
void setCurrentFestival( uint16_t festivalId, uint16_t additionalFestivalId = 0 );
|
||||
|
||||
virtual bool init();
|
||||
virtual bool init();
|
||||
|
||||
virtual void loadCellCache();
|
||||
virtual void loadCellCache();
|
||||
|
||||
virtual uint32_t getTerritoryTypeId() const;
|
||||
virtual uint32_t getTerritoryTypeId() const;
|
||||
|
||||
virtual void onBeforePlayerZoneIn( Entity::Player& player ) {};
|
||||
virtual void onBeforePlayerZoneIn( Entity::Player& player ) {};
|
||||
|
||||
virtual void onPlayerZoneIn( Entity::Player& player );
|
||||
virtual void onPlayerZoneIn( Entity::Player& player );
|
||||
|
||||
virtual void onFinishLoading( Entity::Player& player );
|
||||
virtual void onFinishLoading( Entity::Player& player );
|
||||
|
||||
virtual void onInitDirector( Entity::Player& player );
|
||||
virtual void onInitDirector( Entity::Player& player );
|
||||
|
||||
virtual void onDirectorSync( Entity::Player& player ) {};
|
||||
virtual void onDirectorSync( Entity::Player& player ) {};
|
||||
|
||||
virtual void onLeaveTerritory( Entity::Player& player );
|
||||
virtual void onLeaveTerritory( Entity::Player& player );
|
||||
|
||||
virtual void onUpdate( uint32_t currTime );
|
||||
virtual void onUpdate( uint32_t currTime );
|
||||
|
||||
virtual void onRegisterEObj( Entity::EventObjectPtr object ) {};
|
||||
virtual void onRegisterEObj( Entity::EventObjectPtr object ) {};
|
||||
|
||||
virtual void onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 );
|
||||
virtual void onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 );
|
||||
|
||||
Common::Weather getNextWeather();
|
||||
Common::Weather getNextWeather();
|
||||
|
||||
void pushActor( Entity::ActorPtr pActor );
|
||||
void pushActor( Entity::ActorPtr pActor );
|
||||
|
||||
void removeActor( Entity::ActorPtr pActor );
|
||||
void removeActor( Entity::ActorPtr pActor );
|
||||
|
||||
void updateActorPosition( Entity::Actor& pActor );
|
||||
void updateActorPosition( Entity::Actor& pActor );
|
||||
|
||||
bool isCellActive( uint32_t x, uint32_t y );
|
||||
bool isCellActive( uint32_t x, uint32_t y );
|
||||
|
||||
void updateCellActivity( uint32_t x, uint32_t y, int32_t radius );
|
||||
void updateCellActivity( uint32_t x, uint32_t y, int32_t radius );
|
||||
|
||||
void updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell );
|
||||
void updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell );
|
||||
|
||||
void queuePacketForRange( Entity::Player& sourcePlayer, uint32_t range,
|
||||
Network::Packets::FFXIVPacketBasePtr pPacketEntry );
|
||||
void queuePacketForRange( Entity::Player& sourcePlayer, uint32_t range,
|
||||
Network::Packets::FFXIVPacketBasePtr pPacketEntry );
|
||||
|
||||
void queuePacketForZone( Entity::Player& sourcePlayer, Network::Packets::FFXIVPacketBasePtr pPacketEntry,
|
||||
bool forSelf = false );
|
||||
void queuePacketForZone( Entity::Player& sourcePlayer, Network::Packets::FFXIVPacketBasePtr pPacketEntry,
|
||||
bool forSelf = false );
|
||||
|
||||
uint32_t getGuId() const;
|
||||
uint32_t getGuId() const;
|
||||
|
||||
uint32_t getNextEObjId();
|
||||
uint32_t getNextEObjId();
|
||||
|
||||
const std::string& getName() const;
|
||||
const std::string& getName() const;
|
||||
|
||||
const std::string& getInternalName() const;
|
||||
const std::string& getInternalName() const;
|
||||
|
||||
std::size_t getPopCount() const;
|
||||
std::size_t getPopCount() const;
|
||||
|
||||
void loadWeatherRates();
|
||||
void loadWeatherRates();
|
||||
|
||||
bool checkWeather();
|
||||
//void updateBnpcs( int64_t tickCount );
|
||||
bool checkWeather();
|
||||
//void updateBnpcs( int64_t tickCount );
|
||||
|
||||
bool update( uint32_t currTime );
|
||||
bool update( uint32_t currTime );
|
||||
|
||||
void updateSessions( bool changedWeather );
|
||||
void updateSessions( bool changedWeather );
|
||||
|
||||
Entity::EventObjectPtr registerEObj( const std::string& name, uint32_t objectId, uint32_t mapLink,
|
||||
uint8_t state, Common::FFXIVARR_POSITION3 pos, float scale, float rotation );
|
||||
Entity::EventObjectPtr registerEObj( const std::string& name, uint32_t objectId, uint32_t mapLink,
|
||||
uint8_t state, Common::FFXIVARR_POSITION3 pos, float scale, float rotation );
|
||||
|
||||
void registerEObj( Entity::EventObjectPtr object );
|
||||
void registerEObj( Entity::EventObjectPtr object );
|
||||
|
||||
Entity::EventObjectPtr getEObj( uint32_t objId );
|
||||
Entity::EventObjectPtr getEObj( uint32_t objId );
|
||||
|
||||
InstanceContentPtr getAsInstanceContent();
|
||||
InstanceContentPtr getAsInstanceContent();
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "Script/ScriptMgr.h"
|
||||
#include <Database/ZoneDbConnection.h>
|
||||
#include <Database/DbWorkerPool.h>
|
||||
#include "Linkshell/LinkshellMgr.h"
|
||||
#include "Manager/LinkshellMgr.h"
|
||||
#include "Manager/TerritoryMgr.h"
|
||||
#include "Manager/HousingMgr.h"
|
||||
#include "DebugCommand/DebugCommandHandler.h"
|
||||
|
@ -28,13 +28,13 @@ bool setupFramework()
|
|||
auto pExdData = std::make_shared< Data::ExdDataGenerated >();
|
||||
auto pScript = std::make_shared< Scripting::ScriptMgr >();
|
||||
auto pDb = std::make_shared< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
auto pLsMgr = std::make_shared< LinkshellMgr >();
|
||||
auto pHousingMgr = std::make_shared< Manager::HousingMgr >();
|
||||
auto pTeriMgr = std::make_shared< Manager::TerritoryMgr >();
|
||||
auto pDebugCom = std::make_shared< DebugCommandHandler >();
|
||||
auto pConfig = std::make_shared< ConfigMgr >();
|
||||
auto pPlayerMgr = std::make_shared< Manager::PlayerMgr >();
|
||||
auto pShopMgr = std::make_shared< Manager::ShopMgr >();
|
||||
auto pLsMgr = std::make_shared< Manager::LinkshellMgr >();
|
||||
auto pTeriMgr = std::make_shared< Manager::TerritoryMgr >();
|
||||
auto pHousingMgr = std::make_shared< Manager::HousingMgr >();
|
||||
|
||||
pLogger->setLogPath( "log/SapphireZone" );
|
||||
pLogger->init();
|
||||
|
@ -44,7 +44,7 @@ bool setupFramework()
|
|||
g_fw.set< Data::ExdDataGenerated >( pExdData );
|
||||
g_fw.set< Scripting::ScriptMgr >( pScript );
|
||||
g_fw.set< Db::DbWorkerPool< Db::ZoneDbConnection > >( pDb );
|
||||
g_fw.set< LinkshellMgr >( pLsMgr );
|
||||
g_fw.set< Manager::LinkshellMgr >( pLsMgr );
|
||||
g_fw.set< Manager::HousingMgr >( pHousingMgr );
|
||||
g_fw.set< Manager::TerritoryMgr >( pTeriMgr );
|
||||
g_fw.set< DebugCommandHandler >( pDebugCom );
|
||||
|
|
Loading…
Add table
Reference in a new issue