1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-25 11:07:45 +00:00

Apply clang-format to zone server

This commit is contained in:
Ay'yaruq Dotharl 2017-12-11 16:55:05 +11:00
parent 92594cdc1c
commit 72401d5e5e
No known key found for this signature in database
GPG key ID: 79D2BF33B8AD2918
92 changed files with 3882 additions and 4364 deletions

View file

@ -2,14 +2,12 @@
#include <Server_Common/Util/Util.h>
Core::Action::Action::Action()
{
}
Core::Action::Action::~Action()
{
}
uint16_t Core::Action::Action::getId() const

View file

@ -1,10 +1,11 @@
#ifndef _ACTION_H_
#define _ACTION_H_
#include <Server_Common/Common.h>
#include "../Forwards.h"
#include <Server_Common/Common.h>
namespace Core { namespace Action {
namespace Core {
namespace Action {
class Action
{
@ -33,9 +34,11 @@ namespace Core { namespace Action {
Entity::ActorPtr getActionSource() const;
// clang-format off
virtual void onStart() {};
virtual void onFinish() {};
virtual void onInterrupt() {};
// clang-format on
// update action, if returns true, action is done and has to be removed from the actor
virtual bool update();
@ -51,10 +54,9 @@ namespace Core { namespace Action {
Entity::ActorPtr m_pTarget;
bool m_bInterrupt;
};
}
}
} // namespace Action
} // namespace Core
#endif

View file

@ -1,15 +1,15 @@
#include "ActionCast.h"
#include <Server_Common/Common.h>
#include <Server_Common/Util/Util.h>
#include <Server_Common/Util/UtilMath.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Util/Util.h>
#include <Server_Common/Util/UtilMath.h>
#include "Actor/Player.h"
#include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Actor/Player.h"
#include "Script/ScriptManager.h"
using namespace Core::Common;
@ -59,7 +59,6 @@ void Core::Action::ActionCast::onStart()
m_pSource->sendToInRangeSet( castPacket, true );
m_pSource->getAsPlayer()->setStateFlag( PlayerStateFlag::Casting );
m_pSource->getAsPlayer()->sendStateFlags();
}
void Core::Action::ActionCast::onFinish()
@ -89,12 +88,11 @@ void Core::Action::ActionCast::onInterrupt()
m_pSource->getAsPlayer()->unsetStateFlag( PlayerStateFlag::Casting );
m_pSource->getAsPlayer()->sendStateFlags();
auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt,
0x219, 1, m_id, 0 );
auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt, 0x219, 1, m_id, 0 );
// Note: When cast interrupt from taking too much damage, set the last value to 1. This enables the cast interrupt effect. Example:
// auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt, 0x219, 1, m_id, 0 );
// Note: When cast interrupt from taking too much damage, set the last value to 1. This enables the cast interrupt
// effect. Example: auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt, 0x219,
// 1, m_id, 0 );
m_pSource->sendToInRangeSet( control, true );
}

View file

@ -10,7 +10,6 @@ namespace Action {
class ActionCast : public Action
{
private:
public:
ActionCast();
~ActionCast();
@ -20,10 +19,9 @@ namespace Action {
void onStart() override;
void onFinish() override;
void onInterrupt() override;
};
}
}
} // namespace Action
} // namespace Core
#endif

View file

@ -1,13 +1,13 @@
#include <Server_Common/Util/Util.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Util/Util.h>
#include <Server_Common/Util/UtilMath.h>
#include "ActionCollision.h"
#include "Actor/Actor.h"
#include "Actor/Player.h"
#include <cmath>
#include <boost/make_shared.hpp>
#include <cmath>
using namespace Core::Entity;
using namespace Core::Common;
@ -51,8 +51,8 @@ bool ActionCollision::isActorApplicable( ActorPtr actorPtr, TargetFilter targetF
return ( actorApplicable && actorPtr->isAlive() );
}
std::set< Core::Entity::ActorPtr > ActionCollision::getActorsHitFromAction( FFXIVARR_POSITION3 aoePosition,
std::set< ActorPtr > actorsInRange,
std::set< Core::Entity::ActorPtr >
ActionCollision::getActorsHitFromAction( FFXIVARR_POSITION3 aoePosition, std::set< ActorPtr > actorsInRange,
boost::shared_ptr< Core::Data::ActionInfo > actionInfo,
TargetFilter targetFilter )
{
@ -71,11 +71,11 @@ std::set< Core::Entity::ActorPtr > ActionCollision::getActorsHitFromAction( FFXI
assert( pActor );
// Don't bother wasting on collision if actor doesn't apply for it
if ( !isActorApplicable( pActor, targetFilter ) )
if( !isActorApplicable( pActor, targetFilter ) )
continue;
// Test our collision from actor with the area generated by the action from the AoE data
if ( radiusCollision( pActor->getPos(), aoePosition, actionInfo->aoe_width ) )
if( radiusCollision( pActor->getPos(), aoePosition, actionInfo->aoe_width ) )
{
// Add it to the actors collided with the area
actorsCollided.insert( pActor );
@ -89,10 +89,10 @@ std::set< Core::Entity::ActorPtr > ActionCollision::getActorsHitFromAction( FFXI
{
assert( pActor );
if ( !isActorApplicable( pActor, targetFilter ) )
if( !isActorApplicable( pActor, targetFilter ) )
continue;
if ( radiusCollision( pActor->getPos(), aoePosition, actionInfo->aoe_range ) )
if( radiusCollision( pActor->getPos(), aoePosition, actionInfo->aoe_range ) )
actorsCollided.insert( pActor );
}
break;
@ -103,10 +103,10 @@ std::set< Core::Entity::ActorPtr > ActionCollision::getActorsHitFromAction( FFXI
{
assert( pActor );
if ( !isActorApplicable( pActor, targetFilter ) )
if( !isActorApplicable( pActor, targetFilter ) )
continue;
if ( boxCollision( pActor->getPos(), aoePosition, actionInfo->aoe_width, actionInfo->aoe_range ) )
if( boxCollision( pActor->getPos(), aoePosition, actionInfo->aoe_width, actionInfo->aoe_range ) )
{
// todo: does this actually work?
@ -124,16 +124,16 @@ std::set< Core::Entity::ActorPtr > ActionCollision::getActorsHitFromAction( FFXI
return actorsCollided;
}
bool ActionCollision::radiusCollision( FFXIVARR_POSITION3 actorPosition, FFXIVARR_POSITION3 aoePosition, uint16_t radius )
bool ActionCollision::radiusCollision( FFXIVARR_POSITION3 actorPosition, FFXIVARR_POSITION3 aoePosition,
uint16_t radius )
{
return Core::Math::Util::distance( actorPosition.x, actorPosition.y, actorPosition.z,
aoePosition.x, aoePosition.y, aoePosition.z ) <= radius;
return Core::Math::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, uint16_t height )
bool ActionCollision::boxCollision( FFXIVARR_POSITION3 actorPosition, FFXIVARR_POSITION3 aoePosition, uint16_t width,
uint16_t height )
{
return actorPosition.x < aoePosition.x + width &&
actorPosition.x > aoePosition.x &&
actorPosition.y < aoePosition.y + height &&
actorPosition.y > aoePosition.y;
return actorPosition.x < aoePosition.x + width && actorPosition.x > aoePosition.x &&
actorPosition.y < aoePosition.y + height && actorPosition.y > aoePosition.y;
}

View file

@ -3,8 +3,8 @@
#include <Server_Common/Common.h>
#include "Actor/Actor.h"
#include "Action.h"
#include "Actor/Actor.h"
namespace Core {
namespace Entity {
@ -21,7 +21,6 @@ namespace Entity {
class ActionCollision
{
public:
static bool isActorApplicable( ActorPtr actorPtr, TargetFilter targetFilter );
static std::set< ActorPtr > getActorsHitFromAction( Common::FFXIVARR_POSITION3 aoePosition,
std::set< ActorPtr > actorsInRange,
@ -34,10 +33,9 @@ namespace Entity {
static bool boxCollision( Common::FFXIVARR_POSITION3 actorPosition, Common::FFXIVARR_POSITION3 aoePosition,
uint16_t width, uint16_t height );
};
}
}
} // namespace Entity
} // namespace Core
#endif

View file

@ -1,15 +1,15 @@
#include "ActionMount.h"
#include <Server_Common/Common.h>
#include <Server_Common/Util/Util.h>
#include <Server_Common/Util/UtilMath.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Util/Util.h>
#include <Server_Common/Util/UtilMath.h>
#include "Actor/Player.h"
#include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Actor/Player.h"
#include "Script/ScriptManager.h"
using namespace Core::Common;
@ -38,7 +38,6 @@ Core::Action::ActionMount::ActionMount( Entity::ActorPtr pActor, uint16_t mountI
Core::Action::ActionMount::~ActionMount()
{
}
void Core::Action::ActionMount::onStart()
@ -61,7 +60,6 @@ void Core::Action::ActionMount::onStart()
m_pSource->sendToInRangeSet( castPacket, true );
m_pSource->getAsPlayer()->setStateFlag( PlayerStateFlag::Casting );
m_pSource->getAsPlayer()->sendStateFlags();
}
void Core::Action::ActionMount::onFinish()
@ -102,12 +100,11 @@ void Core::Action::ActionMount::onInterrupt()
m_pSource->getAsPlayer()->unsetStateFlag( PlayerStateFlag::Casting );
m_pSource->getAsPlayer()->sendStateFlags();
auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt,
0x219, 1, m_id, 0 );
auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt, 0x219, 1, m_id, 0 );
// Note: When cast interrupt from taking too much damage, set the last value to 1. This enables the cast interrupt effect. Example:
// auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt, 0x219, 1, m_id, 0 );
// Note: When cast interrupt from taking too much damage, set the last value to 1. This enables the cast interrupt
// effect. Example: auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt, 0x219,
// 1, m_id, 0 );
m_pSource->sendToInRangeSet( control, true );
}

View file

@ -10,7 +10,6 @@ namespace Action {
class ActionMount : public Action
{
private:
public:
ActionMount();
~ActionMount();
@ -20,10 +19,9 @@ namespace Action {
void onStart() override;
void onFinish() override;
void onInterrupt() override;
};
}
}
} // namespace Action
} // namespace Core
#endif

View file

@ -1,12 +1,12 @@
#include "ActionTeleport.h"
#include <Server_Common/Util/Util.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Util/Util.h>
#include "Actor/Player.h"
#include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Actor/Player.h"
using namespace Core::Common;
using namespace Core::Network;
@ -26,7 +26,7 @@ Core::Action::ActionTeleport::ActionTeleport( Entity::ActorPtr pActor, uint16_t
m_startTime = 0;
m_id = 5;
m_handleActionType = HandleActionType::Teleport;
m_castTime = g_exdData.getActionInfo(5)->cast_time; // TODO: Add security checks.
m_castTime = g_exdData.getActionInfo( 5 )->cast_time; // TODO: Add security checks.
m_pSource = pActor;
m_bInterrupt = false;
m_targetAetheryte = targetZone;
@ -35,7 +35,6 @@ Core::Action::ActionTeleport::ActionTeleport( Entity::ActorPtr pActor, uint16_t
Core::Action::ActionTeleport::~ActionTeleport()
{
}
void Core::Action::ActionTeleport::onStart()
@ -55,7 +54,6 @@ void Core::Action::ActionTeleport::onStart()
m_pSource->sendToInRangeSet( castPacket, true );
m_pSource->getAsPlayer()->setStateFlag( PlayerStateFlag::Casting );
m_pSource->getAsPlayer()->sendStateFlags();
}
void Core::Action::ActionTeleport::onFinish()
@ -78,25 +76,25 @@ void Core::Action::ActionTeleport::onFinish()
pPlayer->sendStateFlags();
// TODO: not sure if this ever gets sent
//auto control = Network::Packets::Server::ActorControlPacket142( m_pSource->getId(), Common::ActorControlType::TeleportDone );
//m_pSource->sendToInRangeSet( control, false );
// auto control = Network::Packets::Server::ActorControlPacket142( m_pSource->getId(),
// Common::ActorControlType::TeleportDone
// ); m_pSource->sendToInRangeSet( control, false );
pPlayer->setZoningType( ZoneingType::Teleport );
ZoneChannelPacket< FFXIVIpcEffect > effectPacket( pPlayer->getId() );
effectPacket.data().targetId = pPlayer->getId();
effectPacket.data().actionAnimationId = 5;
//effectPacket.data().unknown_3 = 1;
// effectPacket.data().unknown_3 = 1;
effectPacket.data().actionTextId = 5;
effectPacket.data().unknown_5 = 1;
effectPacket.data().numEffects = 1;
effectPacket.data().rotation = static_cast< uint16_t >( 0x8000 * ( ( pPlayer->getRotation() + 3.1415926 ) ) / 3.1415926 );
effectPacket.data().rotation =
static_cast< uint16_t >( 0x8000 * ( ( pPlayer->getRotation() + 3.1415926 ) ) / 3.1415926 );
effectPacket.data().effectTarget = pPlayer->getId();
pPlayer->sendToInRangeSet( effectPacket, true );
pPlayer->teleport( m_targetAetheryte );
}
void Core::Action::ActionTeleport::onInterrupt()
@ -107,8 +105,6 @@ void Core::Action::ActionTeleport::onInterrupt()
m_pSource->getAsPlayer()->unsetStateFlag( PlayerStateFlag::Casting );
m_pSource->getAsPlayer()->sendStateFlags();
auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt,
0x219, 0x04, m_id, 0 );
auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt, 0x219, 0x04, m_id, 0 );
m_pSource->sendToInRangeSet( control, true );
}

View file

@ -22,10 +22,9 @@ namespace Action {
void onStart() override;
void onFinish() override;
void onInterrupt() override;
};
}
}
} // namespace Action
} // namespace Core
#endif

View file

@ -1,6 +1,6 @@
#include <Server_Common/Util/Util.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Util/Util.h>
#include "EventAction.h"
#include "Network/PacketWrappers/ActorControlPacket142.h"
@ -37,7 +37,6 @@ Core::Action::EventAction::EventAction( Entity::ActorPtr pActor, uint32_t eventI
Core::Action::EventAction::~EventAction()
{
}
void Core::Action::EventAction::onStart()
@ -47,8 +46,7 @@ void Core::Action::EventAction::onStart()
m_startTime = Util::getTimeMs();
auto control = ActorControlPacket142( m_pSource->getId(), Common::ActorControlType::CastStart,
1, m_id, 0x4000004E );
auto control = ActorControlPacket142( m_pSource->getId(), Common::ActorControlType::CastStart, 1, m_id, 0x4000004E );
if( m_pSource->isPlayer() )
{
@ -94,7 +92,6 @@ void Core::Action::EventAction::onFinish()
{
g_log.error( e.what() );
}
}
void Core::Action::EventAction::onInterrupt()
@ -105,8 +102,7 @@ void Core::Action::EventAction::onInterrupt()
try
{
auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt,
0x219, 0x04, m_id );
auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt, 0x219, 0x04, m_id );
if( m_pSource->isPlayer() )
{
@ -121,18 +117,15 @@ void Core::Action::EventAction::onInterrupt()
m_pSource->getAsPlayer()->queuePacket( control1 );
m_pSource->getAsPlayer()->queuePacket( control );
m_pSource->getAsPlayer()->eventFinish( m_eventId, 1 );
}
else
m_pSource->sendToInRangeSet( control );
if( m_onActionInterruptClb )
m_onActionInterruptClb( *m_pSource->getAsPlayer(), m_eventId, m_additional );
}
catch( std::exception& e )
{
g_log.error( e.what() );
}
}

View file

@ -16,8 +16,8 @@ namespace Action {
EventAction();
~EventAction();
EventAction( Entity::ActorPtr pActor, uint32_t eventId, uint16_t action,
ActionCallback finishRef, ActionCallback interruptRef, uint64_t additional );
EventAction( Entity::ActorPtr pActor, uint32_t eventId, uint16_t action, ActionCallback finishRef,
ActionCallback interruptRef, uint64_t additional );
void onStart() override;
void onFinish() override;
@ -29,10 +29,9 @@ namespace Action {
ActionCallback m_onActionFinishClb;
ActionCallback m_onActionInterruptClb;
};
}
}
} // namespace Action
} // namespace Core
#endif

View file

@ -1,8 +1,8 @@
#include "EventItemAction.h"
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Util/Util.h>
#include <Server_Common/Util/UtilMath.h>
#include <Server_Common/Logging/Logger.h>
#include <string.h>
@ -23,7 +23,8 @@ Core::Action::EventItemAction::EventItemAction()
}
Core::Action::EventItemAction::EventItemAction( Entity::ActorPtr pActor, uint32_t eventId, uint16_t action,
ActionCallback finishRef, ActionCallback interruptRef, uint64_t additional )
ActionCallback finishRef, ActionCallback interruptRef,
uint64_t additional )
{
m_additional = additional;
m_handleActionType = HandleActionType::Event;
@ -57,7 +58,6 @@ void Core::Action::EventItemAction::onStart()
m_pSource->sendToInRangeSet( castPacket, true );
m_pSource->getAsPlayer()->setStateFlag( PlayerStateFlag::Casting );
m_pSource->getAsPlayer()->sendStateFlags();
}
void Core::Action::EventItemAction::onFinish()
@ -70,7 +70,7 @@ void Core::Action::EventItemAction::onFinish()
GamePacketNew< FFXIVIpcEffect, ServerZoneIpcType > effectPacket( m_pSource->getId() );
effectPacket.data().targetId = static_cast< uint32_t >( m_additional );
effectPacket.data().actionAnimationId = 1;
// effectPacket.data().unknown_3 = 3;
// effectPacket.data().unknown_3 = 3;
effectPacket.data().actionTextId = m_id;
effectPacket.data().unknown_5 = 2;
effectPacket.data().numEffects = 1;
@ -88,7 +88,6 @@ void Core::Action::EventItemAction::onFinish()
{
g_log.error( e.what() );
}
}
void Core::Action::EventItemAction::onInterrupt()
@ -99,8 +98,7 @@ void Core::Action::EventItemAction::onInterrupt()
try
{
auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt,
0x219, 0x04, m_id );
auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt, 0x219, 0x04, m_id );
if( m_pSource->isPlayer() )
{
m_pSource->getAsPlayer()->unsetStateFlag( PlayerStateFlag::Casting );
@ -112,11 +110,9 @@ void Core::Action::EventItemAction::onInterrupt()
if( m_onActionInterruptClb )
m_onActionInterruptClb( *m_pSource->getAsPlayer(), m_eventId, m_additional );
}
catch( std::exception& e )
{
g_log.error( e.what() );
}
}

View file

@ -14,8 +14,8 @@ namespace Action {
EventItemAction();
~EventItemAction();
EventItemAction( Entity::ActorPtr pActor, uint32_t eventId, uint16_t action,
ActionCallback finishRef, ActionCallback interruptRef, uint64_t additional );
EventItemAction( Entity::ActorPtr pActor, uint32_t eventId, uint16_t action, ActionCallback finishRef,
ActionCallback interruptRef, uint64_t additional );
void onStart() override;
void onFinish() override;
@ -27,10 +27,9 @@ namespace Action {
ActionCallback m_onActionFinishClb;
ActionCallback m_onActionInterruptClb;
};
}
}
} // namespace Action
} // namespace Core
#endif

View file

@ -1,11 +1,11 @@
#include <Server_Common/Util/Util.h>
#include <Server_Common/Util/UtilMath.h>
#include <Server_Common/Network/PacketContainer.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Network/GamePacket.h>
#include <Server_Common/Network/PacketContainer.h>
#include <Server_Common/Util/Util.h>
#include <Server_Common/Util/UtilMath.h>
#include "Forwards.h"
#include "Action/Action.h"
#include "Forwards.h"
#include "Zone/Zone.h"
@ -15,13 +15,13 @@
#include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Network/PacketWrappers/UpdateHpMpTpPacket.h"
#include "StatusEffect/StatusEffect.h"
#include "Action/ActionCollision.h"
#include "Actor.h"
#include "Math/CalcBattle.h"
#include "Player.h"
#include "ServerZone.h"
#include "Session.h"
#include "Math/CalcBattle.h"
#include "Actor.h"
#include "Player.h"
#include "StatusEffect/StatusEffect.h"
extern Core::ServerZone g_serverZone;
extern Core::Data::ExdData g_exdData;
@ -243,12 +243,12 @@ void Core::Entity::Actor::die()
// if the actor is a player, the update needs to be send to himself too
bool selfNeedsUpdate = isPlayer();
sendToInRangeSet( ActorControlPacket142( m_id, SetStatus, static_cast< uint8_t >( ActorStatus::Dead ) ), selfNeedsUpdate );
sendToInRangeSet( ActorControlPacket142( m_id, SetStatus, static_cast< uint8_t >( ActorStatus::Dead ) ),
selfNeedsUpdate );
// TODO: not all actor show the death animation when they die, some quest npcs might just despawn
// although that might be handled by setting the HP to 1 and doing some script magic
sendToInRangeSet( ActorControlPacket142( m_id, DeathAnimation, 0, 0, 0, 0x20 ), selfNeedsUpdate );
}
/*!
@ -318,7 +318,6 @@ bool Core::Entity::Actor::checkAction()
m_pCurrentAction.reset();
return true;
}
/*!
@ -330,8 +329,7 @@ void Core::Entity::Actor::changeTarget( uint64_t targetId )
{
setTargetId( targetId );
sendToInRangeSet( ActorControlPacket144( m_id, SetTarget,
0, 0, 0, 0, targetId ) );
sendToInRangeSet( ActorControlPacket144( m_id, SetTarget, 0, 0, 0, 0, targetId ) );
}
/*!
@ -355,7 +353,8 @@ void Core::Entity::Actor::takeDamage( uint32_t damage )
{
if( damage >= m_hp )
{
switch( m_invincibilityType ) {
switch( m_invincibilityType )
{
case InvincibilityNone:
setHp( 0 );
die();
@ -455,12 +454,8 @@ Core::Entity::ActorPtr Core::Entity::Actor::getClosestActor()
for( const auto& pCurAct : m_inRangeActors )
{
float distance = Math::Util::distance( getPos().x,
getPos().y,
getPos().z,
pCurAct->getPos().x,
pCurAct->getPos().y,
pCurAct->getPos().z );
float distance = Math::Util::distance( getPos().x, getPos().y, getPos().z, pCurAct->getPos().x,
pCurAct->getPos().y, pCurAct->getPos().z );
if( distance < minDistance )
{
@ -495,7 +490,7 @@ void Core::Entity::Actor::sendToInRangeSet( Network::Packets::GamePacketPtr pPac
if( m_inRangePlayers.empty() )
return;
for( const auto &pCurAct : m_inRangePlayers )
for( const auto& pCurAct : m_inRangePlayers )
{
assert( pCurAct );
pPacket->setValAt< uint32_t >( 0x04, m_id );
@ -593,7 +588,7 @@ Get the current cell of a region the actor is in
\return Cell*
*/
Core::Cell * Core::Entity::Actor::getCell() const
Core::Cell* Core::Entity::Actor::getCell() const
{
return m_pCell;
}
@ -603,7 +598,7 @@ Set the current cell the actor is in
\param Cell* for the cell to be set
*/
void Core::Entity::Actor::setCell( Cell * pCell )
void Core::Entity::Actor::setCell( Cell* pCell )
{
m_pCell = pCell;
}
@ -635,7 +630,7 @@ void Core::Entity::Actor::autoAttack( ActorPtr pTarget )
effectPacket.data().targetId = pTarget->getId();
effectPacket.data().actionAnimationId = 0x366;
effectPacket.data().unknown_2 = variation;
// effectPacket.data().unknown_3 = 1;
// effectPacket.data().unknown_3 = 1;
effectPacket.data().actionTextId = 0x366;
effectPacket.data().numEffects = 1;
effectPacket.data().rotation = Math::Util::floatToUInt16Rot( getRotation() );
@ -660,8 +655,8 @@ ChaiScript Skill Handler.
\param GamePacketPtr to send
\param bool should be send to self?
*/
void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, uint64_t param1,
uint64_t param2, Entity::Actor& pTarget )
void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, uint64_t param1, uint64_t param2,
Entity::Actor& pTarget )
{
if( isPlayer() )
@ -685,7 +680,8 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
effectPacket.data().rotation = Math::Util::floatToUInt16Rot( getRotation() );
effectPacket.data().effectTarget = pTarget.getId();
// Todo: for each actor, calculate how much damage the calculated value should deal to them - 2-step damage calc. we only have 1-step
// 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 )
{
@ -699,16 +695,15 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
if( !actionInfoPtr->is_aoe )
{
// If action on this specific target is valid...
if ( isPlayer() && !ActionCollision::isActorApplicable( pTarget.shared_from_this(), TargetFilter::Enemies ) )
if( isPlayer() && !ActionCollision::isActorApplicable( pTarget.shared_from_this(), TargetFilter::Enemies ) )
break;
sendToInRangeSet( effectPacket, true );
if ( pTarget.isAlive() )
if( pTarget.isAlive() )
pTarget.onActionHostile( shared_from_this() );
pTarget.takeDamage( static_cast< uint32_t >( param1 ) );
}
else
{
@ -724,17 +719,17 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
// todo: send to range of what? ourselves? when mob script hits this is going to be lacking
sendToInRangeSet( effectPacket, true );
if( pHitActor->isAlive() )
pHitActor->onActionHostile( shared_from_this() );
pHitActor->takeDamage( static_cast< uint32_t >( param1 ) );
// Debug
if ( isPlayer() )
if( isPlayer() )
{
if ( pHitActor->isPlayer() )
getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) + " (" + pHitActor->getName() + ")" );
if( pHitActor->isPlayer() )
getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) + " (" +
pHitActor->getName() + ")" );
else
getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) );
}
@ -746,7 +741,8 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
case ActionEffectType::Heal:
{
uint32_t calculatedHeal = Math::CalcBattle::calculateHealValue( getAsPlayer(), static_cast< uint32_t >( param1 ) );
uint32_t calculatedHeal =
Math::CalcBattle::calculateHealValue( getAsPlayer(), static_cast< uint32_t >( param1 ) );
effectPacket.data().effects[0].value = calculatedHeal;
effectPacket.data().effects[0].effectType = ActionEffectType::Heal;
@ -780,7 +776,8 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
if( isPlayer() )
{
if( pHitActor->isPlayer() )
getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) + " (" + pHitActor->getName() + ")" );
getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) + " (" +
pHitActor->getName() + ")" );
else
getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) );
}
@ -817,7 +814,7 @@ void Core::Entity::Actor::addStatusEffect( StatusEffect::StatusEffectPtr pEffect
statusEffectAdd.data().max_hp = getMaxHp();
statusEffectAdd.data().max_mp = getMaxMp();
statusEffectAdd.data().max_something = 1;
//statusEffectAdd.data().unknown2 = 28;
// statusEffectAdd.data().unknown2 = 28;
statusEffectAdd.data().param = pEffect->getParam();
sendToInRangeSet( statusEffectAdd, isPlayer() );
@ -826,23 +823,23 @@ void Core::Entity::Actor::addStatusEffect( StatusEffect::StatusEffectPtr pEffect
/*! \param StatusEffectPtr to be applied to the actor */
void Core::Entity::Actor::addStatusEffectById( uint32_t id, int32_t duration, Entity::Actor& pSource, uint16_t param )
{
StatusEffect::StatusEffectPtr effect( new StatusEffect::StatusEffect( id, pSource.shared_from_this(),
shared_from_this(), duration, 3000 ) );
StatusEffect::StatusEffectPtr effect(
new StatusEffect::StatusEffect( id, pSource.shared_from_this(), shared_from_this(), duration, 3000 ) );
effect->setParam( param );
addStatusEffect( effect );
}
/*! \param StatusEffectPtr to be applied to the actor */
void Core::Entity::Actor::addStatusEffectByIdIfNotExist( uint32_t id, int32_t duration, Entity::Actor& pSource, uint16_t param )
void Core::Entity::Actor::addStatusEffectByIdIfNotExist( uint32_t id, int32_t duration, Entity::Actor& pSource,
uint16_t param )
{
if( hasStatusEffect( id ) )
return;
StatusEffect::StatusEffectPtr effect( new StatusEffect::StatusEffect( id, pSource.shared_from_this(),
shared_from_this(), duration, 3000 ) );
StatusEffect::StatusEffectPtr effect(
new StatusEffect::StatusEffect( id, pSource.shared_from_this(), shared_from_this(), duration, 3000 ) );
effect->setParam( param );
addStatusEffect( effect );
}
float Core::Entity::Actor::getRotation() const
@ -923,7 +920,8 @@ void Core::Entity::Actor::sendStatusEffectUpdate()
for( auto effectIt : m_statusEffectMap )
{
float timeLeft = static_cast< float >( effectIt.second->getDuration() -
( currentTimeMs - effectIt.second->getStartTimeMs() ) ) / 1000;
( currentTimeMs - effectIt.second->getStartTimeMs() ) ) /
1000;
statusEffectList.data().effect[slot].duration = timeLeft;
statusEffectList.data().effect[slot].effect_id = effectIt.second->getId();
statusEffectList.data().effect[slot].sourceActorId = effectIt.second->getSrcActorId();
@ -931,7 +929,6 @@ void Core::Entity::Actor::sendStatusEffectUpdate()
}
sendToInRangeSet( statusEffectList, isPlayer() );
}
void Core::Entity::Actor::updateStatusEffects()
@ -980,22 +977,22 @@ void Core::Entity::Actor::updateStatusEffects()
thisTickHeal += thisEffect.second;
break;
}
}
}
}
if( thisTickDmg != 0 )
{
takeDamage( thisTickDmg );
sendToInRangeSet( ActorControlPacket142( getId(), HPFloatingText, 0, static_cast< uint8_t >( ActionEffectType::Damage ), thisTickDmg ) );
sendToInRangeSet( ActorControlPacket142( getId(), HPFloatingText, 0,
static_cast< uint8_t >( ActionEffectType::Damage ), thisTickDmg ) );
}
if( thisTickHeal != 0 )
{
heal( thisTickDmg );
sendToInRangeSet( ActorControlPacket142( getId(), HPFloatingText, 0, static_cast< uint8_t >( ActionEffectType::Heal ), thisTickHeal ) );
sendToInRangeSet( ActorControlPacket142( getId(), HPFloatingText, 0,
static_cast< uint8_t >( ActionEffectType::Heal ), thisTickHeal ) );
}
}

View file

@ -5,22 +5,22 @@
#include <boost/enable_shared_from_this.hpp>
#include "Forwards.h"
#include <set>
#include <map>
#include <queue>
#include <set>
namespace Core {
namespace Entity {
/*!
\class Actor
\brief Base class for all actors
/*!
\class Actor
\brief Base class for all actors
\author Mordred
*/
class Actor : public boost::enable_shared_from_this< Actor >
{
public:
\author Mordred
*/
class Actor : public boost::enable_shared_from_this< Actor >
{
public:
enum ObjKind : uint8_t
{
None = 0x00,
@ -113,7 +113,7 @@ public:
} m_baseStats;
protected:
protected:
// TODO: The position class should probably be abolished and
// the FFXIV_POS struct used instead ( the functions in there
// could be moved to a FFXIV_POS_Helper namespace and rotation to
@ -167,15 +167,15 @@ protected:
/*! Status effects */
const uint8_t MAX_STATUS_EFFECTS = 30;
std::queue< uint8_t > m_statusEffectFreeSlotQueue;
std::vector< std::pair< uint8_t, uint32_t> > m_statusEffectList;
std::vector< std::pair< uint8_t, uint32_t > > m_statusEffectList;
std::map< uint8_t, StatusEffect::StatusEffectPtr > m_statusEffectMap;
public:
public:
Actor();
virtual ~Actor();
virtual void calculateStats() {};
virtual void calculateStats(){};
uint32_t getId() const;
@ -272,7 +272,8 @@ public:
void setStatus( ActorStatus status );
void handleScriptSkill( uint32_t type, uint16_t actionId, uint64_t param1, uint64_t param2, Entity::Actor& target );
void handleScriptSkill( uint32_t type, uint16_t actionId, uint64_t param1, uint64_t param2,
Entity::Actor& target );
virtual void autoAttack( ActorPtr pTarget );
@ -280,11 +281,11 @@ public:
virtual void despawn( ActorPtr pTarget ) {}
virtual void onRemoveInRangeActor( ActorPtr pActor ) {}
virtual void onDeath() {};
virtual void onDamageTaken( Actor& pSource ) {};
virtual void onActionHostile( Core::Entity::ActorPtr pSource ) {};
virtual void onActionFriendly( Actor& pSource ) {};
virtual void onTick() {};
virtual void onDeath(){};
virtual void onDamageTaken( Actor& pSource ){};
virtual void onActionHostile( Core::Entity::ActorPtr pSource ){};
virtual void onActionFriendly( Actor& pSource ){};
virtual void onTick(){};
virtual void changeTarget( uint64_t targetId );
virtual uint8_t getLevel() const;
@ -292,7 +293,7 @@ public:
virtual void takeDamage( uint32_t damage );
virtual void heal( uint32_t amount );
virtual bool checkAction();
virtual void update( int64_t currTime ) {};
virtual void update( int64_t currTime ){};
PlayerPtr getAsPlayer();
BattleNpcPtr getAsBattleNpc();
@ -332,16 +333,14 @@ public:
// set the current cell
void setCell( Cell* pCell );
// TODO: Why did i even declare them publicly here?!
std::set< ActorPtr > m_inRangeActors;
std::set< PlayerPtr > m_inRangePlayers;
std::map< uint32_t, ActorPtr > m_inRangeActorMap;
Core::Cell* m_pCell;
};
};
}
}
} // namespace Entity
} // namespace Core
#endif

View file

@ -1,20 +1,20 @@
#include <cmath>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <stdint.h>
#include <cmath>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Util/Util.h>
#include <Server_Common/Util/UtilMath.h>
#include "Player.h"
#include "BattleNpc.h"
#include "Player.h"
#include "Network/PacketWrappers/MoveActorPacket.h"
#include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/MoveActorPacket.h"
using namespace Core::Common;
using namespace Core::Network::Packets;
@ -34,16 +34,16 @@ Core::Entity::BattleNpc::BattleNpc()
Core::Entity::BattleNpc::~BattleNpc()
{
}
Core::Entity::BattleNpc::BattleNpc( uint16_t modelId, uint16_t nameid, const Common::FFXIVARR_POSITION3& spawnPos,
uint16_t bnpcBaseId, uint32_t type, uint8_t level, uint8_t behaviour,
uint32_t mobType ) : Actor()
uint32_t mobType ) :
Actor()
{
BattleNpc::m_nextID++;
m_id = BattleNpc::m_nextID;
//strcpy( m_name, pBNpc->m_name.c_str() );
// strcpy( m_name, pBNpc->m_name.c_str() );
m_pos = spawnPos;
m_posOrigin = spawnPos;
@ -65,7 +65,7 @@ Core::Entity::BattleNpc::BattleNpc( uint16_t modelId, uint16_t nameid, const Com
m_currentStance = Stance::Passive;
m_class = ClassJob::Gladiator;
m_level = level > uint8_t{0} ? level : uint8_t{70};
m_level = level > uint8_t{ 0 } ? level : uint8_t{ 70 };
m_modelId = modelId;
m_nameId = nameid;
@ -82,46 +82,44 @@ Core::Entity::BattleNpc::BattleNpc( uint16_t modelId, uint16_t nameid, const Com
m_invincibilityType = InvincibilityType::InvincibilityNone;
//m_type = static_cast< Common::ObjKind >( type );
// m_type = static_cast< Common::ObjKind >( type );
}
// spawn this player for pTarget
void Core::Entity::BattleNpc::spawn( PlayerPtr pTarget )
{
//GamePacketNew< FFXIVIpcActorSpawn > spawnPacket( getId(), pTarget->getId() );
// GamePacketNew< FFXIVIpcActorSpawn > spawnPacket( getId(), pTarget->getId() );
//spawnPacket.data().unknown_0 = 0;
//spawnPacket.data().ownerId = m_pOwner == nullptr ? INVALID_GAME_OBJECT_ID : m_pOwner->getId();
//spawnPacket.data().targetId = INVALID_GAME_OBJECT_ID & 0xFFFFFFFF;
//spawnPacket.data().hPCurr = m_hp;
//spawnPacket.data().hPMax = m_baseStats.max_hp;
//spawnPacket.data().level = m_level;
// spawnPacket.data().unknown_0 = 0;
// spawnPacket.data().ownerId = m_pOwner == nullptr ? INVALID_GAME_OBJECT_ID : m_pOwner->getId();
// spawnPacket.data().targetId = INVALID_GAME_OBJECT_ID & 0xFFFFFFFF;
// spawnPacket.data().hPCurr = m_hp;
// spawnPacket.data().hPMax = m_baseStats.max_hp;
// spawnPacket.data().level = m_level;
////spawnPacket.data().tPCurr = 1000;
//spawnPacket.data().model = m_modelId;
//spawnPacket.data().bnpcBaseId = m_bnpcBaseId;
//spawnPacket.data().nameId = m_nameId;
//spawnPacket.data().spawnIndex = pTarget->getSpawnIdForActorId( getId() );
//g_log.info(std::to_string(spawnPacket.data().spawnIndex) + " " + std::to_string(getId()));
//spawnPacket.data().status = static_cast< uint8_t >( m_status );
//spawnPacket.data().mobAgressive = m_behavior;
//spawnPacket.data().type = static_cast< uint8_t >( m_type );
//spawnPacket.data().mobTypeIcon = m_mobType;
//spawnPacket.data().unknown_33 = 5;
//spawnPacket.data().typeFlags = 4;
//spawnPacket.data().pos.x = m_pos.x;
//spawnPacket.data().pos.y = m_pos.y;
//spawnPacket.data().pos.z = m_pos.z;
//spawnPacket.data().rotation = Math::Util::floatToUInt16Rot( getRotation() );
// spawnPacket.data().model = m_modelId;
// spawnPacket.data().bnpcBaseId = m_bnpcBaseId;
// spawnPacket.data().nameId = m_nameId;
// spawnPacket.data().spawnIndex = pTarget->getSpawnIdForActorId( getId() );
// g_log.info(std::to_string(spawnPacket.data().spawnIndex) + " " + std::to_string(getId()));
// spawnPacket.data().status = static_cast< uint8_t >( m_status );
// spawnPacket.data().mobAgressive = m_behavior;
// spawnPacket.data().type = static_cast< uint8_t >( m_type );
// spawnPacket.data().mobTypeIcon = m_mobType;
// spawnPacket.data().unknown_33 = 5;
// spawnPacket.data().typeFlags = 4;
// spawnPacket.data().pos.x = m_pos.x;
// spawnPacket.data().pos.y = m_pos.y;
// spawnPacket.data().pos.z = m_pos.z;
// spawnPacket.data().rotation = Math::Util::floatToUInt16Rot( getRotation() );
////spawnPacket.data().unknown_B0[11] = 1;
////spawnPacket.data().unknown_B0[12] = 4;
////spawnPacket.data().unknown_B0[14] = 20;
//pTarget->queuePacket( spawnPacket );
// pTarget->queuePacket( spawnPacket );
ZoneChannelPacket< FFXIVIpcNpcSpawn > spawnPacket( getId(), pTarget->getId() );
spawnPacket.data().pos.x = m_pos.x;
spawnPacket.data().pos.y = m_pos.y;
spawnPacket.data().pos.z = m_pos.z;
@ -158,7 +156,6 @@ void Core::Entity::BattleNpc::despawn( ActorPtr pTarget )
ActorControlPacket143 controlPacket( m_id, DespawnZoneScreenMsg, 0x04, getId(), 0x01 );
pPlayer->queuePacket( controlPacket );
}
uint8_t Core::Entity::BattleNpc::getLevel() const
@ -224,12 +221,11 @@ void Core::Entity::BattleNpc::setOwner( PlayerPtr pPlayer )
}
else
{
ZoneChannelPacket< FFXIVIpcActorOwner > setOwnerPacket(getId(), INVALID_GAME_OBJECT_ID );
ZoneChannelPacket< FFXIVIpcActorOwner > setOwnerPacket( getId(), INVALID_GAME_OBJECT_ID );
setOwnerPacket.data().type = 0x01;
setOwnerPacket.data().actorId = INVALID_GAME_OBJECT_ID;
sendToInRangeSet( setOwnerPacket );
}
}
void Core::Entity::BattleNpc::sendPositionUpdate()
@ -241,8 +237,7 @@ void Core::Entity::BattleNpc::sendPositionUpdate()
bool Core::Entity::BattleNpc::moveTo( Common::FFXIVARR_POSITION3& pos )
{
if( Math::Util::distance( getPos().x, getPos().y, getPos().z,
pos.x, pos.y, pos.z ) <= 4 )
if( Math::Util::distance( getPos().x, getPos().y, getPos().z, pos.x, pos.y, pos.z ) <= 4 )
// reached destination
return true;
@ -270,12 +265,11 @@ bool Core::Entity::BattleNpc::moveTo( Common::FFXIVARR_POSITION3& pos )
tmpPos.z = getPos().z + z;
setPosition( tmpPos );
setRotation(newRot);
setRotation( newRot );
sendPositionUpdate();
return false;
}
void Core::Entity::BattleNpc::aggro( ActorPtr pActor )
@ -321,7 +315,6 @@ void Core::Entity::BattleNpc::hateListClear()
m_hateList.clear();
}
void Core::Entity::BattleNpc::hateListRemove( ActorPtr pActor )
{
auto it = m_hateList.begin();
@ -384,7 +377,7 @@ void Core::Entity::BattleNpc::hateListUpdate( ActorPtr pActor, int32_t hateAmoun
void Core::Entity::BattleNpc::onDeath()
{
//LuaManager->onMobDeath( this );
// LuaManager->onMobDeath( this );
setTimeOfDeath( static_cast< uint32_t >( time( nullptr ) ) );
setTargetId( INVALID_GAME_OBJECT_ID );
@ -410,7 +403,7 @@ void Core::Entity::BattleNpc::onDeath()
totalHate += pHateEntry->m_hateAmount;
}
//uint32_t plsBeHatedThisMuchAtLeast = totalHate / ( maxHate + 2 ) / clamp( m_hateList.size(), 1.0f, 1.5f );
// uint32_t plsBeHatedThisMuchAtLeast = totalHate / ( maxHate + 2 ) / clamp( m_hateList.size(), 1.0f, 1.5f );
for( auto& pHateEntry : m_hateList )
{
@ -427,21 +420,26 @@ void Core::Entity::BattleNpc::onDeath()
// todo: arbitrary numbers pulled out of my ass
if( m_level <= 14 )
exp = ( expNeeded / ( 100 - levelDiff) ) + cappedLevelDiff + ( cappedLevelDiff * ( ( rand() % ( cappedLevelDiff * 9 ) ) + 1 ) );
exp = ( expNeeded / ( 100 - levelDiff ) ) + cappedLevelDiff +
( cappedLevelDiff * ( ( rand() % ( cappedLevelDiff * 9 ) ) + 1 ) );
else if( m_level <= 24 )
exp = ( expNeeded / ( 150 - levelDiff) ) + cappedLevelDiff + ( cappedLevelDiff * ( ( rand() % ( cappedLevelDiff * 8 ) ) + 1 ) );
exp = ( expNeeded / ( 150 - levelDiff ) ) + cappedLevelDiff +
( cappedLevelDiff * ( ( rand() % ( cappedLevelDiff * 8 ) ) + 1 ) );
else if( m_level <= 34 )
exp = ( expNeeded / ( 350 - levelDiff ) ) + cappedLevelDiff + ( cappedLevelDiff * ( ( rand() % ( cappedLevelDiff * 7 ) ) + 1 ) );
exp = ( expNeeded / ( 350 - levelDiff ) ) + cappedLevelDiff +
( cappedLevelDiff * ( ( rand() % ( cappedLevelDiff * 7 ) ) + 1 ) );
else if( m_level <= 44 )
exp = ( expNeeded / ( 550 - levelDiff ) ) + cappedLevelDiff + ( cappedLevelDiff * ( ( rand() % ( cappedLevelDiff * 6 ) ) + 1 ) );
exp = ( expNeeded / ( 550 - levelDiff ) ) + cappedLevelDiff +
( cappedLevelDiff * ( ( rand() % ( cappedLevelDiff * 6 ) ) + 1 ) );
else if( m_level <= 50 )
exp = ( expNeeded / ( 750 - levelDiff ) ) + cappedLevelDiff + ( cappedLevelDiff * ( ( rand() % ( cappedLevelDiff * 5 ) ) + 1 ) );
exp = ( expNeeded / ( 750 - levelDiff ) ) + cappedLevelDiff +
( cappedLevelDiff * ( ( rand() % ( cappedLevelDiff * 5 ) ) + 1 ) );
else
exp = ( expNeeded / ( 1200 - levelDiff ) ) + cappedLevelDiff + ( cappedLevelDiff * ( ( rand() % ( cappedLevelDiff * 4 ) ) + 1 ) );
exp = ( expNeeded / ( 1200 - levelDiff ) ) + cappedLevelDiff +
( cappedLevelDiff * ( ( rand() % ( cappedLevelDiff * 4 ) ) + 1 ) );
// todo: this is actually retarded, we need real rand()
srand( static_cast< uint32_t > ( time( nullptr ) ) );
srand( static_cast< uint32_t >( time( nullptr ) ) );
auto pPlayer = pHateEntry->m_pActor->getAsPlayer();
pPlayer->gainExp( exp );
@ -467,7 +465,6 @@ Core::Entity::ActorPtr Core::Entity::BattleNpc::getClaimer() const
return m_pOwner;
}
// HACK: this is highly experimental code, will have to be changed eventually
// since there are different types of mobs... (stationary, moving...) likely to be
// handled by scripts entirely.
@ -482,8 +479,7 @@ void Core::Entity::BattleNpc::update( int64_t currTime )
}
updateStatusEffects();
float distance = Math::Util::distance( m_pos.x, m_pos.y, m_pos.z,
m_posOrigin.x, m_posOrigin.y, m_posOrigin.z );
float distance = Math::Util::distance( m_pos.x, m_pos.y, m_pos.z, m_posOrigin.x, m_posOrigin.y, m_posOrigin.z );
if( ( distance > 70 ) && m_mode != MODE_RETREAT )
{
@ -509,12 +505,10 @@ void Core::Entity::BattleNpc::update( int64_t currTime )
if( pClosestActor && pClosestActor->isAlive() )
{
distance = Math::Util::distance( getPos().x, getPos().y, getPos().z,
pClosestActor->getPos().x,
pClosestActor->getPos().y,
pClosestActor->getPos().z );
distance = Math::Util::distance( getPos().x, getPos().y, getPos().z, pClosestActor->getPos().x,
pClosestActor->getPos().y, pClosestActor->getPos().z );
//if( distance < 8 && getbehavior() == 2 )
// if( distance < 8 && getbehavior() == 2 )
// aggro( pClosestActor );
}
}
@ -532,10 +526,8 @@ void Core::Entity::BattleNpc::update( int64_t currTime )
if( pClosestActor != nullptr )
{
distance = Math::Util::distance( getPos().x, getPos().y, getPos().z,
pClosestActor->getPos().x,
pClosestActor->getPos().y,
pClosestActor->getPos().z );
distance = Math::Util::distance( getPos().x, getPos().y, getPos().z, pClosestActor->getPos().x,
pClosestActor->getPos().y, pClosestActor->getPos().z );
if( distance > 4 )
moveTo( pClosestActor->getPos() );
@ -554,11 +546,9 @@ void Core::Entity::BattleNpc::update( int64_t currTime )
setOwner( nullptr );
m_mode = MODE_RETREAT;
}
}
break;
}
}
uint32_t Core::Entity::BattleNpc::getTimeOfDeath() const
@ -570,4 +560,3 @@ void Core::Entity::BattleNpc::setTimeOfDeath( uint32_t tod )
{
m_timeOfDeath = tod;
}

View file

@ -6,30 +6,30 @@
namespace Core {
namespace Entity {
enum StateMode
{
enum StateMode
{
MODE_COMBAT,
MODE_RETREAT,
MODE_IDLE,
};
};
typedef struct
{
typedef struct
{
uint32_t m_hateAmount;
ActorPtr m_pActor;
} HateListEntry;
} HateListEntry;
// class for Mobs inheriting from Actor
class BattleNpc : public Actor
{
public:
// class for Mobs inheriting from Actor
class BattleNpc : public Actor
{
public:
BattleNpc();
~BattleNpc();
BattleNpc( uint16_t modelId, uint16_t nameid, const Common::FFXIVARR_POSITION3& spawnPos, uint16_t bnpcBaseId = 0,
uint32_t type = 2, uint8_t level = 0, uint8_t behaviour = 1, uint32_t mobType = 0 );
//BattleNpc( uint32_t modelId,
// BattleNpc( uint32_t modelId,
// uint32_t nameId,
// uint32_t bnpcBaseId,
// uint32_t level,
@ -90,8 +90,7 @@ public:
void setTimeOfDeath( uint32_t tod );
private:
private:
static uint32_t m_nextID;
StateMode m_mode;
Common::FFXIVARR_POSITION3 m_posOrigin;
@ -106,10 +105,9 @@ private:
ActorPtr m_pOwner;
uint32_t m_timeOfDeath;
uint32_t m_mobType;
};
};
}
}
} // namespace Entity
} // namespace Core
#endif

View file

@ -2,23 +2,20 @@
Core::Entity::BattleNpcTemplate::BattleNpcTemplate()
{
}
Core::Entity::BattleNpcTemplate::BattleNpcTemplate( std::string templateName, uint32_t bnpcBaseId,
uint32_t bnpcNameId, uint32_t modelId, std::string aiName ) :
Core::Entity::BattleNpcTemplate::BattleNpcTemplate( std::string templateName, uint32_t bnpcBaseId, uint32_t bnpcNameId,
uint32_t modelId, std::string aiName ) :
m_templateName( templateName ),
m_bnpcBaseId( bnpcBaseId ),
m_bnpcNameId( bnpcNameId ),
m_modelId( modelId ),
m_aiName( aiName )
{
}
Core::Entity::BattleNpcTemplate::~BattleNpcTemplate()
{
}
uint32_t Core::Entity::BattleNpcTemplate::getBnpcBaseId() const

View file

@ -14,7 +14,8 @@ namespace Entity {
{
public:
BattleNpcTemplate();
BattleNpcTemplate( std::string templateName, uint32_t bnpcBaseId, uint32_t bnpcNameId, uint32_t modelId, std::string aiName );
BattleNpcTemplate( std::string templateName, uint32_t bnpcBaseId, uint32_t bnpcNameId, uint32_t modelId,
std::string aiName );
~BattleNpcTemplate();
@ -28,11 +29,9 @@ namespace Entity {
uint32_t m_bnpcBaseId = 0;
uint32_t m_bnpcNameId = 0;
uint32_t m_modelId = 0;
};
}
}
} // namespace Entity
} // namespace Core
#endif

View file

@ -1,45 +1,45 @@
#include <Server_Common/Common.h>
#include <Server_Common/Config/XMLConfig.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Network/GamePacket.h>
#include <Server_Common/Network/PacketContainer.h>
#include <Server_Common/Util/Util.h>
#include <Server_Common/Util/UtilMath.h>
#include <Server_Common/Config/XMLConfig.h>
#include <Server_Common/Network/GamePacket.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Network/PacketContainer.h>
#include "Session.h"
#include "Player.h"
#include "BattleNpc.h"
#include "Player.h"
#include "Session.h"
#include "Zone/ZoneMgr.h"
#include "Zone/Zone.h"
#include "Zone/ZoneMgr.h"
#include "ServerZone.h"
#include "Network/GameConnection.h"
#include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/InitUIPacket.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Network/PacketWrappers/ChatPacket.h"
#include "Network/PacketWrappers/ModelEquipPacket.h"
#include "Network/PacketWrappers/ActorSpawnPacket.h"
#include "Network/PacketWrappers/UpdateHpMpTpPacket.h"
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
#include "Network/PacketWrappers/ChatPacket.h"
#include "Network/PacketWrappers/InitUIPacket.h"
#include "Network/PacketWrappers/ModelEquipPacket.h"
#include "Network/PacketWrappers/PlayerSpawnPacket.h"
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Network/PacketWrappers/UpdateHpMpTpPacket.h"
#include "Script/ScriptManager.h"
#include "Inventory/Item.h"
#include "Inventory/Inventory.h"
#include "Event/Event.h"
#include "Action/Action.h"
#include "Action/EventAction.h"
#include "Action/EventItemAction.h"
#include "Zone/ZonePosition.h"
#include "Math/CalcStats.h"
#include "Event/Event.h"
#include "Inventory/Inventory.h"
#include "Math/CalcBattle.h"
#include "Math/CalcStats.h"
#include "Zone/ZonePosition.h"
#include <boost/make_shared.hpp>
extern Core::Logger g_log;
@ -157,7 +157,7 @@ Core::Common::OnlineStatus Core::Entity::Player::getOnlineStatus()
OnlineStatus status = OnlineStatus::Online;
//if( hasStateFlag( Common::PlayerStateFlag::NewAdventurer ) )
// if( hasStateFlag( Common::PlayerStateFlag::NewAdventurer ) )
if( m_onlineStatus & newMask )
status = OnlineStatus::NewAdventurer;
@ -182,7 +182,8 @@ Core::Common::OnlineStatus Core::Entity::Player::getOnlineStatus()
if( hasStateFlag( PlayerStateFlag::WatchingCutscene ) || hasStateFlag( PlayerStateFlag::WatchingCutscene1 ) )
status = OnlineStatus::ViewingCutscene;
// TODO: add all the logic for returning the proper online status, there probably is a better way for this alltogether
// TODO: add all the logic for returning the proper online status, there probably is a better way for this
// alltogether
return status;
}
@ -216,8 +217,7 @@ void Core::Entity::Player::calculateStats()
auto tribeInfoIt = g_exdData.m_tribeInfoMap.find( tribe );
auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find( level );
if( tribeInfoIt == g_exdData.m_tribeInfoMap.end() ||
classInfoIt == g_exdData.m_classJobInfoMap.end() ||
if( tribeInfoIt == g_exdData.m_tribeInfoMap.end() || classInfoIt == g_exdData.m_classJobInfoMap.end() ||
paramGrowthInfoIt == g_exdData.m_paramGrowthInfoMap.end() )
return;
@ -228,12 +228,18 @@ void Core::Entity::Player::calculateStats()
// TODO: put formula somewhere else...
float base = Math::CalcStats::calculateBaseStat( getAsPlayer() );
m_baseStats.str = static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_str ) / 100 ) + tribeInfo.mod_str );
m_baseStats.dex = static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_dex ) / 100 ) + tribeInfo.mod_dex );
m_baseStats.vit = static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_vit ) / 100 ) + tribeInfo.mod_vit );
m_baseStats.inte = static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_int ) / 100 ) + tribeInfo.mod_int );
m_baseStats.mnd = static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_mnd ) / 100 ) + tribeInfo.mod_mnd );
m_baseStats.pie = static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_pie ) / 100 ) + tribeInfo.mod_pie );
m_baseStats.str =
static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_str ) / 100 ) + tribeInfo.mod_str );
m_baseStats.dex =
static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_dex ) / 100 ) + tribeInfo.mod_dex );
m_baseStats.vit =
static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_vit ) / 100 ) + tribeInfo.mod_vit );
m_baseStats.inte =
static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_int ) / 100 ) + tribeInfo.mod_int );
m_baseStats.mnd =
static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_mnd ) / 100 ) + tribeInfo.mod_mnd );
m_baseStats.pie =
static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_pie ) / 100 ) + tribeInfo.mod_pie );
m_baseStats.skillSpeed = paramGrowthInfo.base_secondary;
m_baseStats.spellSpeed = paramGrowthInfo.base_secondary;
@ -253,13 +259,10 @@ void Core::Entity::Player::calculateStats()
if( m_hp > m_baseStats.max_hp )
m_hp = m_baseStats.max_hp;
m_baseStats.determination = static_cast< uint32_t >( base );
}
void Core::Entity::Player::setAutoattack(bool mode)
void Core::Entity::Player::setAutoattack( bool mode )
{
m_bAutoattack = mode;
m_lastAttack = Util::getTimeMs();
@ -325,8 +328,8 @@ void Core::Entity::Player::teleport( uint16_t aetheryteId, uint8_t type )
rot = z_pos->getTargetRotation();
}
sendDebug( "Teleport: " + data->placename + " " + data->placename_aethernet +
"(" + std::to_string( data->levelId ) + ")" );
sendDebug( "Teleport: " + data->placename + " " + data->placename_aethernet + "(" + std::to_string( data->levelId ) +
")" );
// TODO: this should be simplified and a type created in server_common/common.h.
if( type == 1 ) // teleport
@ -349,14 +352,12 @@ void Core::Entity::Player::teleport( uint16_t aetheryteId, uint8_t type )
}
m_queuedZoneing = boost::make_shared< QueuedZoning >( data->target_zone, pos, Util::getTimeMs(), rot );
}
void Core::Entity::Player::forceZoneing( uint32_t zoneId )
{
m_queuedZoneing = boost::make_shared< QueuedZoning >( zoneId, getPos(), Util::getTimeMs(), 0.f );
//performZoning( zoneId, Common::ZoneingType::None, getPos() );
// performZoning( zoneId, Common::ZoneingType::None, getPos() );
}
void Core::Entity::Player::returnToHomepoint()
@ -371,7 +372,6 @@ void Core::Entity::Player::setZone( uint32_t zoneId )
auto pZone = g_zoneMgr.getZone( zoneId );
if( !pZone /*|| ( ( pZone == m_pCurrentZone ) && m_lastPing )*/ )
{
g_log.error( "Zone " + std::to_string( zoneId ) + " not found on this server." );
@ -397,7 +397,7 @@ void Core::Entity::Player::setZone( uint32_t zoneId )
if( isLogin() )
{
queuePacket(ActorControlPacket143( getId(), SetCharaGearParamUI, m_equipDisplayFlags, 1 ) );
queuePacket( ActorControlPacket143( getId(), SetCharaGearParamUI, m_equipDisplayFlags, 1 ) );
}
// set flags, will be reset automatically by zoning ( only on client side though )
@ -517,7 +517,6 @@ void Core::Entity::Player::registerAetheryte( uint8_t aetheryteId )
m_aetheryte[index] |= value;
queuePacket( ActorControlPacket143( getId(), LearnTeleport, aetheryteId, 1 ) );
}
bool Core::Entity::Player::isAetheryteRegistered( uint8_t aetheryteId ) const
@ -529,7 +528,7 @@ bool Core::Entity::Player::isAetheryteRegistered( uint8_t aetheryteId ) const
return ( m_aetheryte[index] & value ) != 0;
}
uint8_t * Core::Entity::Player::getDiscoveryBitmask()
uint8_t* Core::Entity::Player::getDiscoveryBitmask()
{
return m_discovery;
}
@ -561,9 +560,6 @@ void Core::Entity::Player::discover( int16_t map_id, int16_t sub_id )
uint32_t exp = ( g_exdData.m_paramGrowthInfoMap[level].needed_exp * 5 / 100 );
gainExp( exp );
}
bool Core::Entity::Player::isNewAdventurer() const
@ -573,11 +569,11 @@ bool Core::Entity::Player::isNewAdventurer() const
void Core::Entity::Player::setNewAdventurer( bool state )
{
//if( !state )
// if( !state )
//{
// unsetStateFlag( PlayerStateFlag::NewAdventurer );
//}
//else
// else
//{
// setStateFlag( PlayerStateFlag::NewAdventurer );
//}
@ -596,7 +592,7 @@ void Core::Entity::Player::changePosition( float x, float y, float z, float o )
pos.x = x;
pos.y = y;
pos.z = z;
m_queuedZoneing = boost::make_shared<QueuedZoning>( getZoneId(), pos, Util::getTimeMs(), o );
m_queuedZoneing = boost::make_shared< QueuedZoning >( getZoneId(), pos, Util::getTimeMs(), o );
}
void Core::Entity::Player::learnAction( uint8_t actionId )
@ -657,11 +653,11 @@ void Core::Entity::Player::gainExp( uint32_t amount )
setExp( amount );
gainLevel();
queuePacket( ActorControlPacket143( getId(), UpdateUiExp, static_cast< uint8_t >( getClass() ), amount ) );
}
else
{
queuePacket( ActorControlPacket143( getId(), UpdateUiExp, static_cast< uint8_t >( getClass() ), currentExp + amount ) );
queuePacket(
ActorControlPacket143( getId(), UpdateUiExp, static_cast< uint8_t >( getClass() ), currentExp + amount ) );
setExp( currentExp + amount );
}
@ -680,8 +676,8 @@ void Core::Entity::Player::gainLevel()
m_mp = getMaxMp();
ZoneChannelPacket< FFXIVIpcStatusEffectList > effectListPacket( getId() );
effectListPacket.data().classId = static_cast< uint8_t > ( getClass() );
effectListPacket.data().classId1 = static_cast< uint8_t > ( getClass() );
effectListPacket.data().classId = static_cast< uint8_t >( getClass() );
effectListPacket.data().classId1 = static_cast< uint8_t >( getClass() );
effectListPacket.data().level = getLevel();
effectListPacket.data().current_hp = getMaxHp();
effectListPacket.data().current_mp = getMaxMp();
@ -690,18 +686,17 @@ void Core::Entity::Player::gainLevel()
effectListPacket.data().max_mp = getMaxMp();
sendToInRangeSet( effectListPacket, true );
sendToInRangeSet( ActorControlPacket142( getId(), LevelUpEffect, static_cast< uint8_t >( getClass() ),
getLevel(), getLevel() - 1 ), true );
sendToInRangeSet( ActorControlPacket142( getId(), LevelUpEffect, static_cast< uint8_t >( getClass() ), getLevel(),
getLevel() - 1 ),
true );
ZoneChannelPacket< FFXIVIpcUpdateClassInfo > classInfoPacket( getId() );
classInfoPacket.data().classId = static_cast< uint8_t > ( getClass() );
classInfoPacket.data().classId1 = static_cast< uint8_t > ( getClass() );
classInfoPacket.data().classId = static_cast< uint8_t >( getClass() );
classInfoPacket.data().classId1 = static_cast< uint8_t >( getClass() );
classInfoPacket.data().level = getLevel();
classInfoPacket.data().nextLevelIndex = getLevel();
classInfoPacket.data().currentExp = getExp();
queuePacket( classInfoPacket );
}
void Core::Entity::Player::unlock()
@ -713,7 +708,7 @@ void Core::Entity::Player::sendStatusUpdate( bool toSelf )
{
// CGamePacket* pPE = new CGamePacket(0x140, 0x0128, getId(), getId());
//pPE->setInt8At(0x20, static_cast<uint8_t>(getClass()));
// pPE->setInt8At(0x20, static_cast<uint8_t>(getClass()));
// pPE->setInt8At(0x21, getLevel());
// pPE->setInt8At(0x22, getLevel());
@ -733,7 +728,6 @@ void Core::Entity::Player::sendStatusUpdate( bool toSelf )
// sendToInRangeSet(pPE, toSelf);
sendToInRangeSet( UpdateHpMpTpPacket( shared_from_this() ), true );
}
uint8_t Core::Entity::Player::getLevel() const
@ -767,7 +761,7 @@ bool Core::Entity::Player::isInCombat() const
void Core::Entity::Player::setInCombat( bool mode )
{
//m_lastAttack = GetTickCount();
// m_lastAttack = GetTickCount();
m_bInCombat = mode;
}
@ -796,7 +790,8 @@ void Core::Entity::Player::setClassJob( Common::ClassJob classJob )
void Core::Entity::Player::setLevel( uint8_t level )
{
uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( static_cast< uint8_t >( getClass() ) )].exp_idx;
uint8_t classJobIndex =
g_exdData.m_classJobInfoMap[static_cast< uint8_t >( static_cast< uint8_t >( getClass() ) )].exp_idx;
m_classArray[classJobIndex] = level;
}
@ -872,9 +867,7 @@ void Core::Entity::Player::setLookAt( uint8_t index, uint8_t value )
// spawn this player for pTarget
void Core::Entity::Player::spawn( Entity::PlayerPtr pTarget )
{
g_log.debug( "[" + std::to_string( pTarget->getId() ) + "] Spawning " +
getName() + " for " +
pTarget->getName() );
g_log.debug( "[" + std::to_string( pTarget->getId() ) + "] Spawning " + getName() + " for " + pTarget->getName() );
PlayerSpawnPacket spawnActor( *getAsPlayer(), *pTarget );
pTarget->queuePacket( spawnActor );
@ -946,14 +939,13 @@ const uint8_t* Core::Entity::Player::getStateFlags() const
return m_stateFlags;
}
bool Core::Entity::Player::actionHasCastTime( uint32_t actionId ) //TODO: Add logic for special cases
bool Core::Entity::Player::actionHasCastTime( uint32_t actionId ) // TODO: Add logic for special cases
{
auto actionInfoPtr = g_exdData.getActionInfo( actionId );
if( actionInfoPtr->is_instant )
return false;
return actionInfoPtr->cast_time != 0;
}
bool Core::Entity::Player::hasStateFlag( Common::PlayerStateFlag flag ) const
@ -976,7 +968,6 @@ void Core::Entity::Player::setStateFlag( Common::PlayerStateFlag flag )
Util::valueToFlagByteIndexValue( iFlag, value, index );
m_stateFlags[index] |= value;
}
void Core::Entity::Player::setStateFlags( std::vector< Common::PlayerStateFlag > flags )
@ -1010,7 +1001,6 @@ void Core::Entity::Player::unsetStateFlag( Common::PlayerStateFlag flag )
Util::valueToFlagByteIndexValue( iFlag, value, index );
m_stateFlags[index] ^= value;
}
void Core::Entity::Player::update( int64_t currTime )
@ -1022,7 +1012,7 @@ void Core::Entity::Player::update( int64_t currTime )
Common::FFXIVARR_POSITION3 targetPos = m_queuedZoneing->m_targetPosition;
if( getCurrentZone()->getId() != m_queuedZoneing->m_targetZone )
{
performZoning( m_queuedZoneing->m_targetZone, targetPos, m_queuedZoneing->m_targetRotation);
performZoning( m_queuedZoneing->m_targetZone, targetPos, m_queuedZoneing->m_targetRotation );
}
else
{
@ -1055,7 +1045,8 @@ void Core::Entity::Player::update( int64_t currTime )
{
auto mainWeap = m_pInventory->getItemAt( Inventory::GearSet0, Inventory::EquipSlot::MainHand );
// @TODO i dislike this, iterating over all in range actors when you already know the id of the actor you need...
// @TODO i dislike this, iterating over all in range actors when you already know the id of the actor you
// need...
for( auto actor : m_inRangeActors )
{
if( actor->getId() == m_targetId && actor->isAlive() && mainWeap )
@ -1065,14 +1056,11 @@ void Core::Entity::Player::update( int64_t currTime )
uint32_t range = 7;
// default autoattack range for ranged classes
if( getClass() == ClassJob::Machinist ||
getClass() == ClassJob::Bard ||
getClass() == ClassJob::Archer )
if( getClass() == ClassJob::Machinist || getClass() == ClassJob::Bard || getClass() == ClassJob::Archer )
range = 25;
if( Math::Util::distance(getPos().x, getPos().y, getPos().z,
actor->getPos().x, actor->getPos().y, actor->getPos().z) <= range )
if( Math::Util::distance( getPos().x, getPos().y, getPos().z, actor->getPos().x, actor->getPos().y,
actor->getPos().z ) <= range )
{
if( ( currTime - m_lastAttack ) > mainWeap->getDelay() )
@ -1080,7 +1068,6 @@ void Core::Entity::Player::update( int64_t currTime )
m_lastAttack = currTime;
autoAttack( actor );
}
}
}
}
@ -1111,10 +1098,9 @@ void Core::Entity::Player::freePlayerSpawnId( uint32_t actorId )
freeActorSpawnPacket.data().actorId = actorId;
freeActorSpawnPacket.data().spawnId = spawnId;
queuePacket( freeActorSpawnPacket );
}
uint8_t * Core::Entity::Player::getAetheryteArray()
uint8_t* Core::Entity::Player::getAetheryteArray()
{
return m_aetheryte;
}
@ -1219,7 +1205,6 @@ void Core::Entity::Player::queuePacket( Network::Packets::GamePacketPtr pPacket
if( pZoneCon )
pZoneCon->queueOutPacket( pPacket );
}
void Core::Entity::Player::queueChatPacket( Network::Packets::GamePacketPtr pPacket )
@ -1245,7 +1230,7 @@ void Core::Entity::Player::setLoadingComplete( bool bComplete )
m_bLoadingComplete = bComplete;
}
void Core::Entity::Player::performZoning( uint16_t zoneId, const Common::FFXIVARR_POSITION3 &pos, float rotation )
void Core::Entity::Player::performZoning( uint16_t zoneId, const Common::FFXIVARR_POSITION3& pos, float rotation )
{
m_pos = pos;
m_zoneId = zoneId;
@ -1292,17 +1277,17 @@ uint8_t Core::Entity::Player::getSearchSelectClass() const
return m_searchSelectClass;
}
void Core::Entity::Player::sendNotice( const std::string& message ) //Purple Text
void Core::Entity::Player::sendNotice( const std::string& message ) // Purple Text
{
queuePacket( ServerNoticePacket( getId(), message ) );
}
void Core::Entity::Player::sendUrgent( const std::string& message ) //Red Text
void Core::Entity::Player::sendUrgent( const std::string& message ) // Red Text
{
queuePacket( ChatPacket( *getAsPlayer(), ChatType::ServerUrgent, message ) );
}
void Core::Entity::Player::sendDebug( const std::string& message ) //Grey Text
void Core::Entity::Player::sendDebug( const std::string& message ) // Grey Text
{
queuePacket( ChatPacket( *getAsPlayer(), ChatType::ServerDebug, message ) );
}
@ -1317,7 +1302,6 @@ void Core::Entity::Player::updateHowtosSeen( uint32_t howToId )
m_howTo[index] |= value;
}
void Core::Entity::Player::onMobAggro( BattleNpcPtr pBNpc )
{
hateListAdd( pBNpc );
@ -1342,7 +1326,6 @@ void Core::Entity::Player::hateListAdd( BattleNpcPtr pBNpc )
m_freeHateSlotQueue.pop();
m_actorIdTohateSlotMap[pBNpc->getId()] = hateId;
sendHateList();
}
void Core::Entity::Player::hateListRemove( BattleNpcPtr pBNpc )
@ -1430,7 +1413,7 @@ void Core::Entity::Player::setTitle( uint16_t titleId )
uint8_t value;
Util::valueToFlagByteIndexValue( titleId, value, index );
if ( ( m_titleList[index] & value ) == 0 ) // Player doesn't have title - bail
if( ( m_titleList[index] & value ) == 0 ) // Player doesn't have title - bail
return;
m_activeTitle = titleId;
@ -1454,7 +1437,9 @@ uint8_t Core::Entity::Player::getEquipDisplayFlags() const
void Core::Entity::Player::mount( uint32_t id )
{
m_mount = id;
sendToInRangeSet( ActorControlPacket142( getId(), ActorControlType::SetStatus, static_cast< uint8_t >( Entity::Actor::ActorStatus::Mounted )), true );
sendToInRangeSet( ActorControlPacket142( getId(), ActorControlType::SetStatus,
static_cast< uint8_t >( Entity::Actor::ActorStatus::Mounted ) ),
true );
sendToInRangeSet( ActorControlPacket143( getId(), 0x39e, 12 ), true ); //?
ZoneChannelPacket< FFXIVIpcMount > mountPacket( getId() );
@ -1465,7 +1450,8 @@ void Core::Entity::Player::mount( uint32_t id )
void Core::Entity::Player::dismount()
{
sendToInRangeSet( ActorControlPacket142( getId(), ActorControlType::SetStatus,
static_cast< uint8_t >( Entity::Actor::ActorStatus::Idle )), true );
static_cast< uint8_t >( Entity::Actor::ActorStatus::Idle ) ),
true );
sendToInRangeSet( ActorControlPacket143( getId(), ActorControlType::Dismount, 1 ), true );
m_mount = 0;
}
@ -1478,21 +1464,18 @@ uint8_t Core::Entity::Player::getCurrentMount() const
void Core::Entity::Player::autoAttack( ActorPtr pTarget )
{
auto mainWeap = m_pInventory->getItemAt( Inventory::GearSet0,
Inventory::EquipSlot::MainHand );
auto mainWeap = m_pInventory->getItemAt( Inventory::GearSet0, Inventory::EquipSlot::MainHand );
pTarget->onActionHostile( shared_from_this() );
//uint64_t tick = Util::getTimeMs();
//srand(static_cast< uint32_t >(tick));
// uint64_t tick = Util::getTimeMs();
// srand(static_cast< uint32_t >(tick));
uint32_t damage = static_cast< uint32_t >( mainWeap->getAutoAttackDmg() );
uint32_t variation = 0 + rand() % 3;
if( getClass() == ClassJob::Machinist ||
getClass() == ClassJob::Bard ||
getClass() == ClassJob::Archer )
if( getClass() == ClassJob::Machinist || getClass() == ClassJob::Bard || getClass() == ClassJob::Archer )
{
ZoneChannelPacket< FFXIVIpcEffect > effectPacket(getId());
ZoneChannelPacket< FFXIVIpcEffect > effectPacket( getId() );
effectPacket.data().targetId = pTarget->getId();
effectPacket.data().actionAnimationId = 8;
// effectPacket.data().unknown_2 = variation;
@ -1500,7 +1483,7 @@ void Core::Entity::Player::autoAttack( ActorPtr pTarget )
effectPacket.data().unknown_61 = 1;
effectPacket.data().unknown_62 = 1;
effectPacket.data().actionTextId = 8;
effectPacket.data().rotation = Math::Util::floatToUInt16Rot(getRotation());
effectPacket.data().rotation = Math::Util::floatToUInt16Rot( getRotation() );
effectPacket.data().effectTargetId = pTarget->getId();
effectPacket.data().effectTarget = pTarget->getId();
effectPacket.data().effects[0].value = damage;
@ -1508,12 +1491,12 @@ void Core::Entity::Player::autoAttack( ActorPtr pTarget )
effectPacket.data().effects[0].hitSeverity = Common::ActionHitSeverityType::NormalDamage;
effectPacket.data().effects[0].unknown_3 = 7;
sendToInRangeSet(effectPacket, true);
sendToInRangeSet( effectPacket, true );
}
else
{
ZoneChannelPacket< FFXIVIpcEffect > effectPacket(getId());
ZoneChannelPacket< FFXIVIpcEffect > effectPacket( getId() );
effectPacket.data().targetId = pTarget->getId();
effectPacket.data().actionAnimationId = 7;
// effectPacket.data().unknown_2 = variation;
@ -1521,21 +1504,19 @@ void Core::Entity::Player::autoAttack( ActorPtr pTarget )
effectPacket.data().unknown_61 = 1;
effectPacket.data().unknown_62 = 1;
effectPacket.data().actionTextId = 7;
effectPacket.data().rotation = Math::Util::floatToUInt16Rot(getRotation());
effectPacket.data().rotation = Math::Util::floatToUInt16Rot( getRotation() );
effectPacket.data().effectTarget = pTarget->getId();
effectPacket.data().effects[0].value = damage;
effectPacket.data().effects[0].effectType = Common::ActionEffectType::Damage;
effectPacket.data().effects[0].hitSeverity = Common::ActionHitSeverityType::NormalDamage;
effectPacket.data().effects[0].unknown_3 = 71;
sendToInRangeSet(effectPacket, true);
sendToInRangeSet( effectPacket, true );
}
pTarget->takeDamage(damage);
pTarget->takeDamage( damage );
}
/////////////////////////////
// Content Finder
/////////////////////////////
@ -1559,7 +1540,7 @@ uint32_t Core::Entity::Player::getCFPenaltyMinutes() const
return 0;
auto deltaTime = endTimestamp - currentTimestamp;
return static_cast< uint32_t > ( ceil( static_cast< float > (deltaTime) / 60 ) );
return static_cast< uint32_t >( ceil( static_cast< float >( deltaTime ) / 60 ) );
}
void Core::Entity::Player::setCFPenaltyMinutes( uint32_t minutes )
@ -1587,7 +1568,7 @@ uint16_t Core::Entity::Player::getItemLevel() const
void Core::Entity::Player::setEorzeaTimeOffset( uint64_t timestamp )
{
// TODO: maybe change to persistent?
ZoneChannelPacket< FFXIVIpcEorzeaTimeOffset > packet ( getId() );
ZoneChannelPacket< FFXIVIpcEorzeaTimeOffset > packet( getId() );
packet.data().timestamp = timestamp;
// Send to single player

View file

@ -14,27 +14,30 @@ namespace Core {
namespace Entity {
struct QueuedZoning
{
struct QueuedZoning
{
uint16_t m_targetZone;
Common::FFXIVARR_POSITION3 m_targetPosition;
float m_targetRotation;
uint64_t m_queueTime;
QueuedZoning( uint16_t targetZone, const Common::FFXIVARR_POSITION3& targetPosition, uint64_t queuedTime, float targetRotation )
: m_targetZone( targetZone )
, m_targetPosition( targetPosition )
, m_queueTime( queuedTime )
, m_targetRotation( targetRotation ) {}
};
QueuedZoning( uint16_t targetZone, const Common::FFXIVARR_POSITION3& targetPosition, uint64_t queuedTime,
float targetRotation ) :
m_targetZone( targetZone ),
m_targetPosition( targetPosition ),
m_queueTime( queuedTime ),
m_targetRotation( targetRotation )
{
}
};
/** Class representing the Player
* Inheriting from Actor
*
*/
class Player : public Actor
{
public:
/** Class representing the Player
* Inheriting from Actor
*
*/
class Player : public Actor
{
public:
/*! Contructor */
Player();
@ -46,21 +49,25 @@ public:
// EventHandlers
//////////////////////////////////////////////////////////////////////////////////////////////////////
/*! start an event action */
void eventActionStart( uint32_t eventId, uint32_t action, ActionCallback finishCallback, ActionCallback interruptCallback, uint64_t additional );
void eventActionStart( uint32_t eventId, uint32_t action, ActionCallback finishCallback,
ActionCallback interruptCallback, uint64_t additional );
/*! start an event item action */
void eventItemActionStart( uint32_t eventId, uint32_t action, ActionCallback finishCallback, ActionCallback interruptCallback, uint64_t additional );
void eventItemActionStart( uint32_t eventId, uint32_t action, ActionCallback finishCallback,
ActionCallback interruptCallback, uint64_t additional );
/*! start/register a normal event */
void eventStart( uint64_t actorId, uint32_t eventId, uint8_t eventParam, uint8_t eventParam1, uint32_t eventParam2 );
void eventStart( uint64_t actorId, uint32_t eventId, uint8_t eventParam, uint8_t eventParam1,
uint32_t eventParam2 );
/*! play a subevent */
void eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags, uint32_t eventParam2, uint32_t eventParam3 );
/*! play a subevent */
void eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags,
uint32_t eventParam2, uint32_t eventParam3, Scripting::EventReturnCallback eventReturnCallback );
void eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags, uint32_t eventParam2, uint32_t eventParam3,
Scripting::EventReturnCallback eventReturnCallback );
/*! play a subevent */
void eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags, uint32_t eventParam2, uint32_t eventParam3,
uint32_t eventParam4, Scripting::EventReturnCallback eventReturnCallback );
/*! play a subevent */
void eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags,
uint32_t eventParam2, uint32_t eventParam3, uint32_t eventParam4, Scripting::EventReturnCallback eventReturnCallback );
/*! play a subevent */
void eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags, Scripting::EventReturnCallback eventReturnCallback );
Scripting::EventReturnCallback eventReturnCallback );
/*! play a subevent */
void eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags );
/*! finish / unregister an event */
@ -78,8 +85,6 @@ public:
void checkEvent( uint32_t eventId );
// Events
//////////////////////////////////////////////////////////////////////////////////////////////////////
/*! Event to be called when zoning process gets triggered */
@ -97,7 +102,6 @@ public:
/*! Event to be called upon Bnpc kill */
void onMobKill( uint16_t nameId );
// Quest
//////////////////////////////////////////////////////////////////////////////////////////////////////
/*! load data for currently active quests */
@ -163,7 +167,6 @@ public:
uint8_t getQuestBitFlag40( uint16_t questId );
uint8_t getQuestBitFlag48( uint16_t questId );
void setQuestUI8A( uint16_t questId, uint8_t val );
void setQuestUI8B( uint16_t questId, uint8_t val );
void setQuestUI8C( uint16_t questId, uint8_t val );
@ -354,7 +357,6 @@ public:
void calculateStats() override;
void sendStats();
// Aetheryte / Action / Attribute bitmasks
//////////////////////////////////////////////////////////////////////////////////////////////////////
/*! register aetheryte aetheryteId and send update */
@ -394,7 +396,6 @@ public:
/*! return a const pointer to the mount guide bitmask array */
const uint8_t* getMountGuideBitmask() const;
// Spawn handling
//////////////////////////////////////////////////////////////////////////////////////////////////////
/*! initialize the spawnId queue */
@ -468,7 +469,7 @@ public:
/*! set the loading complete bool */
void setLoadingComplete( bool bComplete );
/*! mark this player for zoning, notify worldserver */
void performZoning(uint16_t zoneId, const Common::FFXIVARR_POSITION3& pos, float rotation);
void performZoning( uint16_t zoneId, const Common::FFXIVARR_POSITION3& pos, float rotation );
/*! return true if the player is marked for zoning */
bool isMarkedForZoning() const;
@ -538,7 +539,7 @@ public:
void setMarkedForRemoval();
bool isMarkedForRemoval() const;
private:
private:
uint32_t m_lastWrite;
uint32_t m_lastPing;
@ -550,8 +551,7 @@ private:
bool m_markedForRemoval;
private:
private:
uint8_t m_voice;
uint64_t m_modelMainWeapon;
@ -640,9 +640,9 @@ private:
uint32_t m_cfPenaltyUntil; // unix time
uint8_t m_mount;
};
};
}
}
} // namespace Entity
} // namespace Core
#endif

View file

@ -1,8 +1,8 @@
#include <Server_Common/Common.h>
#include <Server_Common/Network/GamePacket.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Network/PacketContainer.h>
#include <Server_Common/Config/XMLConfig.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Network/GamePacket.h>
#include <Server_Common/Network/PacketContainer.h>
#include "Player.h"
@ -12,16 +12,15 @@
#include "Network/GameConnection.h"
#include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/EventFinishPacket.h"
#include "Network/PacketWrappers/EventPlayPacket.h"
#include "Network/PacketWrappers/EventStartPacket.h"
#include "Network/PacketWrappers/InitUIPacket.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Network/PacketWrappers/EventStartPacket.h"
#include "Network/PacketWrappers/EventPlayPacket.h"
#include "Network/PacketWrappers/EventFinishPacket.h"
#include "Action/EventAction.h"
#include "Action/EventItemAction.h"
#include "Event/Event.h"
#include "Event/Event.h"
#include "ServerZone.h"
@ -74,9 +73,7 @@ void Core::Entity::Player::checkEvent( uint32_t eventId )
eventFinish( eventId, 1 );
}
void Core::Entity::Player::eventStart( uint64_t actorId, uint32_t eventId,
uint8_t eventType, uint8_t eventParam1,
void Core::Entity::Player::eventStart( uint64_t actorId, uint32_t eventId, uint8_t eventType, uint8_t eventParam1,
uint32_t eventParam2 )
{
Event::EventPtr newEvent( new Event::Event( actorId, eventId, eventType, eventParam1, eventParam2 ) );
@ -88,18 +85,16 @@ void Core::Entity::Player::eventStart( uint64_t actorId, uint32_t eventId,
EventStartPacket eventStart( getId(), actorId, eventId, eventType, eventParam1, eventParam2 );
queuePacket( eventStart );
}
void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene,
uint32_t flags, uint32_t eventParam2,
void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags, uint32_t eventParam2,
uint32_t eventParam3 )
{
eventPlay( eventId, scene, flags, eventParam2, eventParam3, nullptr );
}
void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene,
uint32_t flags, Scripting::EventReturnCallback eventCallback )
void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags,
Scripting::EventReturnCallback eventCallback )
{
eventPlay( eventId, scene, flags, 0, 0, eventCallback );
}
@ -109,15 +104,14 @@ void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene, uint32_t
eventPlay( eventId, scene, flags, 0, 0, nullptr );
}
void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene,
uint32_t flags, uint32_t eventParam2,
void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags, uint32_t eventParam2,
uint32_t eventParam3, Scripting::EventReturnCallback eventCallback )
{
if( flags & 0x02 )
{
setStateFlag( PlayerStateFlag::WatchingCutscene );
sendToInRangeSet( ActorControlPacket142( getId(), SetStatusIcon,
static_cast< uint8_t >( getOnlineStatus() ) ), true );
sendToInRangeSet( ActorControlPacket142( getId(), SetStatusIcon, static_cast< uint8_t >( getOnlineStatus() ) ),
true );
}
auto pEvent = getEvent( eventId );
@ -135,21 +129,20 @@ void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene,
pEvent->setPlayedScene( true );
pEvent->setEventReturnCallback( eventCallback );
EventPlayPacket eventPlay( getId(), pEvent->getActorId(), pEvent->getId(),
scene, flags, eventParam2, eventParam3 );
EventPlayPacket eventPlay( getId(), pEvent->getActorId(), pEvent->getId(), scene, flags, eventParam2, eventParam3 );
queuePacket( eventPlay );
}
void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene,
uint32_t flags, uint32_t eventParam2,
uint32_t eventParam3, uint32_t eventParam4, Scripting::EventReturnCallback eventCallback )
void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags, uint32_t eventParam2,
uint32_t eventParam3, uint32_t eventParam4,
Scripting::EventReturnCallback eventCallback )
{
if( flags & 0x02 )
{
setStateFlag( PlayerStateFlag::WatchingCutscene );
sendToInRangeSet( ActorControlPacket142( getId(), SetStatusIcon,
static_cast< uint8_t >( getOnlineStatus() ) ), true );
sendToInRangeSet( ActorControlPacket142( getId(), SetStatusIcon, static_cast< uint8_t >( getOnlineStatus() ) ),
true );
}
auto pEvent = getEvent( eventId );
@ -167,8 +160,8 @@ void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene,
pEvent->setPlayedScene( true );
pEvent->setEventReturnCallback( eventCallback );
EventPlayPacket eventPlay( getId(), pEvent->getActorId(), pEvent->getId(),
scene, flags, eventParam2, eventParam3, eventParam4 );
EventPlayPacket eventPlay( getId(), pEvent->getActorId(), pEvent->getId(), scene, flags, eventParam2, eventParam3,
eventParam4 );
queuePacket( eventPlay );
}
@ -204,7 +197,8 @@ void Core::Entity::Player::eventFinish( uint32_t eventId, uint32_t freePlayer )
if( it.second->hasPlayedScene() == false )
{
// TODO: not happy with this, this is also prone to break wit more than one remaining event in there
queuePacket( EventFinishPacket( getId(), it.second->getId(), it.second->getEventType(), it.second->getEventParam3() ) );
queuePacket( EventFinishPacket( getId(), it.second->getId(), it.second->getEventType(),
it.second->getEventParam3() ) );
removeEvent( it.second->getId() );
}
}
@ -221,8 +215,8 @@ void Core::Entity::Player::eventFinish( uint32_t eventId, uint32_t freePlayer )
if( hasStateFlag( PlayerStateFlag::WatchingCutscene ) )
{
unsetStateFlag( PlayerStateFlag::WatchingCutscene );
sendToInRangeSet( ActorControlPacket142( getId(), SetStatusIcon,
static_cast< uint8_t >( getOnlineStatus() ) ), true );
sendToInRangeSet( ActorControlPacket142( getId(), SetStatusIcon, static_cast< uint8_t >( getOnlineStatus() ) ),
true );
}
removeEvent( pEvent->getId() );
@ -234,14 +228,11 @@ void Core::Entity::Player::eventFinish( uint32_t eventId, uint32_t freePlayer )
}
}
void Core::Entity::Player::eventActionStart( uint32_t eventId,
uint32_t action,
ActionCallback finishCallback,
ActionCallback interruptCallback,
uint64_t additional )
void Core::Entity::Player::eventActionStart( uint32_t eventId, uint32_t action, ActionCallback finishCallback,
ActionCallback interruptCallback, uint64_t additional )
{
Action::ActionPtr pEventAction( new Action::EventAction( shared_from_this(), eventId, action,
finishCallback, interruptCallback, additional ) );
Action::ActionPtr pEventAction(
new Action::EventAction( shared_from_this(), eventId, action, finishCallback, interruptCallback, additional ) );
setCurrentAction( pEventAction );
auto pEvent = getEvent( eventId );
@ -263,15 +254,11 @@ void Core::Entity::Player::eventActionStart( uint32_t eventId,
pEventAction->onStart();
}
void Core::Entity::Player::eventItemActionStart( uint32_t eventId,
uint32_t action,
ActionCallback finishCallback,
ActionCallback interruptCallback,
uint64_t additional )
void Core::Entity::Player::eventItemActionStart( uint32_t eventId, uint32_t action, ActionCallback finishCallback,
ActionCallback interruptCallback, uint64_t additional )
{
Action::ActionPtr pEventItemAction( new Action::EventItemAction( shared_from_this(), eventId, action,
finishCallback, interruptCallback, additional ) );
Action::ActionPtr pEventItemAction( new Action::EventItemAction( shared_from_this(), eventId, action, finishCallback,
interruptCallback, additional ) );
setCurrentAction( pEventItemAction );
@ -290,20 +277,16 @@ void Core::Entity::Player::onLogin()
void Core::Entity::Player::onZoneStart()
{
}
void Core::Entity::Player::onZoneDone()
{
}
void Core::Entity::Player::onDeath()
{
}
// TODO: slightly ugly here and way too static. Needs too be done properly
void Core::Entity::Player::onTick()
{

View file

@ -1,12 +1,12 @@
#include <Server_Common/Common.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Network/GamePacket.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Network/GamePacket.h>
#include "Player.h"
#include "Zone/ZoneMgr.h"
#include "Zone/Zone.h"
#include "Zone/ZoneMgr.h"
#include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h"
@ -38,45 +38,37 @@ void Core::Entity::Player::equipWeapon( ItemPtr pItem )
switch( pItem->getCategory() )
{
case ItemUICategory::PugilistsArm:
if( currentClass != ClassJob::Pugilist &&
currentClass != ClassJob::Monk )
if( currentClass != ClassJob::Pugilist && currentClass != ClassJob::Monk )
setClassJob( ClassJob::Pugilist );
break;
case ItemUICategory::GladiatorsArm:
if( currentClass != ClassJob::Gladiator &&
currentClass != ClassJob::Paladin )
if( currentClass != ClassJob::Gladiator && currentClass != ClassJob::Paladin )
setClassJob( ClassJob::Gladiator );
break;
case ItemUICategory::MaraudersArm:
if( currentClass != ClassJob::Marauder &&
currentClass != ClassJob::Warrior )
if( currentClass != ClassJob::Marauder && currentClass != ClassJob::Warrior )
setClassJob( ClassJob::Marauder );
break;
case ItemUICategory::ArchersArm:
if( currentClass != ClassJob::Archer &&
currentClass != ClassJob::Bard )
if( currentClass != ClassJob::Archer && currentClass != ClassJob::Bard )
setClassJob( ClassJob::Archer );
break;
case ItemUICategory::LancersArm:
if( currentClass != ClassJob::Lancer &&
currentClass != ClassJob::Dragoon )
if( currentClass != ClassJob::Lancer && currentClass != ClassJob::Dragoon )
setClassJob( ClassJob::Lancer );
break;
case ItemUICategory::OnehandedThaumaturgesArm:
case ItemUICategory::TwohandedThaumaturgesArm:
if( currentClass != ClassJob::Thaumaturge &&
currentClass != ClassJob::Blackmage )
if( currentClass != ClassJob::Thaumaturge && currentClass != ClassJob::Blackmage )
setClassJob( ClassJob::Thaumaturge );
break;
case ItemUICategory::OnehandedConjurersArm:
case ItemUICategory::TwohandedConjurersArm:
if( currentClass != ClassJob::Conjurer &&
currentClass != ClassJob::Whitemage )
if( currentClass != ClassJob::Conjurer && currentClass != ClassJob::Whitemage )
setClassJob( ClassJob::Conjurer );
break;
case ItemUICategory::ArcanistsGrimoire:
if( currentClass != ClassJob::Arcanist &&
currentClass != ClassJob::Summoner &&
if( currentClass != ClassJob::Arcanist && currentClass != ClassJob::Summoner &&
currentClass != ClassJob::Scholar )
setClassJob( ClassJob::Arcanist );
break;
@ -89,7 +81,7 @@ void Core::Entity::Player::equipWeapon( ItemPtr pItem )
void Core::Entity::Player::equipItem( Inventory::EquipSlot equipSlotId, ItemPtr pItem, bool sendUpdate )
{
//g_log.debug( "Equipping into slot " + std::to_string( equipSlotId ) );
// g_log.debug( "Equipping into slot " + std::to_string( equipSlotId ) );
uint64_t model = pItem->getModelId1();
uint64_t model2 = pItem->getModelId2();
@ -115,7 +107,6 @@ void Core::Entity::Player::equipItem( Inventory::EquipSlot equipSlotId, ItemPtr
default: // any other slot
m_modelEquip[static_cast< uint8_t >( equipSlotId )] = static_cast< uint32_t >( model );
break;
}
if( sendUpdate )
@ -169,7 +160,6 @@ void Core::Entity::Player::removeCurrency( uint8_t type, uint32_t amount )
queuePacket( invUpPacket );
}
uint32_t Core::Entity::Player::getCrystal( uint8_t type ) const
{
return m_pInventory->getCrystal( static_cast< Inventory::CrystalType >( type ) );
@ -228,4 +218,3 @@ void Core::Entity::Player::sendInventory() const
{
m_pInventory->send();
}

View file

@ -1,16 +1,16 @@
#include <Server_Common/Common.h>
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include <Server_Common/Network/GamePacket.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Network/GamePacket.h>
#include <Server_Common/Network/PacketContainer.h>
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include "Network/GameConnection.h"
#include "Network/PacketWrappers/QuestMessagePacket.h"
#include "Server_Zone/Session.h"
#include "Player.h"
#include "Server_Zone/Inventory/Inventory.h"
#include "Server_Zone/Session.h"
extern Core::Data::ExdData g_exdData;
@ -27,7 +27,6 @@ void Core::Entity::Player::finishQuest( uint16_t questId )
updateQuestsCompleted( questId );
sendQuestTracker();
}
void Core::Entity::Player::unfinishQuest( uint16_t questId )
@ -72,7 +71,6 @@ void Core::Entity::Player::removeQuest( uint16_t questId )
}
sendQuestTracker();
}
bool Core::Entity::Player::hasQuest( uint16_t questId )
@ -742,7 +740,7 @@ void Core::Entity::Player::setQuestUI16C( uint16_t questId, uint16_t val )
{
boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[idx];
// pNewQuest->d.UI16C = val;
// pNewQuest->d.UI16C = val;
updateQuest( questId, pNewQuest->c.sequence );
}
@ -845,8 +843,6 @@ void Core::Entity::Player::setQuestBitFlag48( uint16_t questId, uint8_t val )
}
}
uint8_t Core::Entity::Player::getQuestSeq( uint16_t questId )
{
int8_t idx = getQuestIndex( questId );
@ -870,7 +866,6 @@ void Core::Entity::Player::updateQuest( uint16_t questId, uint8_t sequence )
pe_qa.data().slot = index;
pe_qa.data().questInfo = *pNewQuest;
queuePacket( pe_qa );
}
else
{
@ -911,7 +906,6 @@ void Core::Entity::Player::updateQuest( uint16_t questId, uint8_t sequence )
insertQuest( questId, idx, sequence );
sendQuestTracker();
}
}
@ -934,7 +928,7 @@ void Core::Entity::Player::setQuestTracker( uint16_t index, int16_t flag )
{
if( flag == 0 )
{
//remove
// remove
for( uint8_t ii = 0; ii < 5; ii++ )
{
if( m_questTracking[ii] == index )
@ -946,7 +940,7 @@ void Core::Entity::Player::setQuestTracker( uint16_t index, int16_t flag )
}
else
{
//add
// add
for( uint8_t ii = 0; ii < 5; ii++ )
{
if( m_questTracking[ii] == -1 )
@ -956,10 +950,8 @@ void Core::Entity::Player::setQuestTracker( uint16_t index, int16_t flag )
}
}
}
}
void Core::Entity::Player::sendQuestInfo()
{
ZoneChannelPacket< FFXIVIpcQuestActiveList > pe_qa( getId() );
@ -972,7 +964,6 @@ void Core::Entity::Player::sendQuestInfo()
auto& quest = pe_qa.data().activeQuests[i];
quest = *m_activeQuests[i];
}
}
@ -985,12 +976,12 @@ void Core::Entity::Player::sendQuestInfo()
sendQuestTracker();
}
void Core::Entity::Player::sendQuestMessage( uint32_t questId, int8_t msgId, uint8_t type, uint32_t var1, uint32_t var2 )
void Core::Entity::Player::sendQuestMessage( uint32_t questId, int8_t msgId, uint8_t type, uint32_t var1,
uint32_t var2 )
{
queuePacket( QuestMessagePacket( getAsPlayer(), questId, msgId, type, var1, var2 ) );
}
void Core::Entity::Player::updateQuestsCompleted( uint32_t questId )
{
uint8_t index = questId / 8;
@ -1009,7 +1000,6 @@ void Core::Entity::Player::removeQuestsCompleted( uint32_t questId )
uint8_t value = 0x80 >> bitIndex;
m_questCompleteFlags[index] ^= value;
}
bool Core::Entity::Player::giveQuestRewards( uint32_t questId, uint32_t optionalChoice )
@ -1017,14 +1007,14 @@ bool Core::Entity::Player::giveQuestRewards( uint32_t questId, uint32_t optional
uint32_t playerLevel = getLevel();
auto questInfo = g_exdData.getQuestInfo( questId );
if( !questInfo )
return false;
auto paramGrowth = g_exdData.m_paramGrowthInfoMap[questInfo->quest_level];
// TODO: use the correct formula, this one is wrong
uint32_t exp = ( questInfo->reward_exp_factor * paramGrowth.quest_exp_mod * ( 45 + 5 * questInfo->quest_level) ) / 100;
uint32_t exp =
( questInfo->reward_exp_factor * paramGrowth.quest_exp_mod * ( 45 + 5 * questInfo->quest_level ) ) / 100;
exp = exp + ( questInfo->reward_exp_factor / 100 ) * 10000;
exp = questInfo->reward_exp_factor;
@ -1060,8 +1050,7 @@ bool Core::Entity::Player::giveQuestRewards( uint32_t questId, uint32_t optional
return true;
}
boost::shared_ptr<QuestActive> Core::Entity::Player::getQuestActive( uint16_t index )
boost::shared_ptr< QuestActive > Core::Entity::Player::getQuestActive( uint16_t index )
{
return m_activeQuests[index];
}

View file

@ -1,13 +1,12 @@
#include <Server_Common/Common.h>
#include <Server_Common/Config/XMLConfig.h>
#include <Server_Common/Database/DatabaseDef.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Network/GamePacket.h>
#include <Server_Common/Network/PacketContainer.h>
#include <Server_Common/Util/Util.h>
#include <Server_Common/Util/UtilMath.h>
#include <Server_Common/Config/XMLConfig.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Network/PacketContainer.h>
#include <Server_Common/Common.h>
#include <Server_Common/Database/DatabaseDef.h>
#include <set>
#include <stdio.h>
@ -16,24 +15,22 @@
#include "Player.h"
#include "Zone/ZoneMgr.h"
#include "Zone/Zone.h"
#include "Zone/ZoneMgr.h"
#include "ServerZone.h"
#include "Forwards.h"
#include "Inventory/Inventory.h"
#include "Network/GameConnection.h"
#include "Network/PacketWrappers/InitUIPacket.h"
#include "Inventory/Inventory.h"
extern Core::Logger g_log;
extern Core::ServerZone g_serverZone;
extern Core::ZoneMgr g_zoneMgr;
extern Core::Data::ExdData g_exdData;
using namespace Core::Common;
using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server;
@ -183,7 +180,7 @@ bool Core::Entity::Player::load( uint32_t charId, SessionPtr pSession )
// first login, run the script event
if( m_bNewGame )
{
//g_scriptMgr.onPlayerFirstEnterWorld( pPlayer );
// g_scriptMgr.onPlayerFirstEnterWorld( pPlayer );
m_bNewGame = false;
m_hp = getMaxHp();
m_mp = getMaxMp();
@ -243,12 +240,9 @@ bool Core::Entity::Player::loadActiveQuests()
m_questIdToQuestIdx[pActiveQuest->c.questId] = slotId;
m_questIdxToQuestId[slotId] = pActiveQuest->c.questId;
}
return true;
}
bool Core::Entity::Player::loadClassData()
@ -288,7 +282,6 @@ bool Core::Entity::Player::loadSearchInfo()
return true;
}
void Core::Entity::Player::updateSql()
{
@ -354,7 +347,7 @@ void Core::Entity::Player::updateSql()
stmt->setInt( 35, 0 ); // RestPoint
stmt->setInt( 36, 0 ); // ActiveTitle
std::vector< uint8_t > titleListVec( sizeof ( m_titleList ) );
std::vector< uint8_t > titleListVec( sizeof( m_titleList ) );
stmt->setBinary( 37, titleListVec );
std::vector< uint8_t > achievementVec( 16 );
@ -421,14 +414,13 @@ void Core::Entity::Player::updateSql()
////// Class
updateDbClass();
}
void Core::Entity::Player::updateDbClass() const
{
uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( getClass() )].exp_idx;
//Exp = ?, Lvl = ? WHERE CharacterId = ? AND ClassIdx = ?
// Exp = ?, Lvl = ? WHERE CharacterId = ? AND ClassIdx = ?
auto stmtS = g_charaDb.getPreparedStatement( Db::CHARA_CLASS_UP );
stmtS->setInt( 1, getExp() );
stmtS->setInt( 2, getLevel() );
@ -473,10 +465,9 @@ void Core::Entity::Player::updateDbAllQuests() const
stmtS3->setInt( 7, m_activeQuests[i]->c.UI8E );
stmtS3->setInt( 8, m_activeQuests[i]->c.UI8F );
stmtS3->setInt( 9, m_activeQuests[i]->c.padding1 );
stmtS3->setInt( 10, m_id);
stmtS3->setInt( 10, m_id );
stmtS3->setInt( 11, m_activeQuests[i]->c.questId );
g_charaDb.execute( stmtS3 );
}
}

View file

@ -3,5 +3,4 @@
#include "../Forwards.h"
#endif

View file

@ -8,13 +8,12 @@
namespace Core {
class DebugCommandHandler;
class DebugCommandHandler;
class DebugCommand
{
public:
using pFunc = void ( DebugCommandHandler::* )( char *, Entity::Player&, boost::shared_ptr< DebugCommand > );
class DebugCommand
{
public:
using pFunc = void ( DebugCommandHandler::* )( char*, Entity::Player&, boost::shared_ptr< DebugCommand > );
// String for the command
std::string m_commandName;
@ -36,29 +35,15 @@ namespace Core {
m_gmLevel = uLevel;
}
~DebugCommand()
{
~DebugCommand() {}
}
const std::string& getName() const { return m_commandName; }
const std::string& getName() const
{
return m_commandName;
}
const std::string& getHelpText() const { return m_helpText; }
const std::string& getHelpText() const
{
return m_helpText;
}
uint8_t getRequiredGmLevel() const
{
return m_gmLevel;
}
};
}
uint8_t getRequiredGmLevel() const { return m_gmLevel; }
};
} // namespace Core
#endif

View file

@ -1,37 +1,36 @@
#include <boost/lexical_cast.hpp>
#include <Server_Common/Common.h>
#include <Server_Common/Version.h>
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Network/CommonNetwork.h>
#include <Server_Common/Util/UtilMath.h>
#include <Server_Common/Network/PacketContainer.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Database/DatabaseDef.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Network/CommonNetwork.h>
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Network/PacketContainer.h>
#include <Server_Common/Util/UtilMath.h>
#include <Server_Common/Version.h>
#include "DebugCommand.h"
#include "DebugCommandHandler.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Network/GameConnection.h"
#include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/InitUIPacket.h"
#include "Network/GameConnection.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Script/ScriptManager.h"
#include "Actor/Player.h"
#include "Actor/BattleNpc.h"
#include "Actor/Player.h"
#include "Zone/Zone.h"
#include "ServerZone.h"
#include "StatusEffect/StatusEffect.h"
#include "Session.h"
#include "StatusEffect/StatusEffect.h"
#include <boost/make_shared.hpp>
#include <cinttypes>
extern Core::Scripting::ScriptManager g_scriptMgr;
@ -70,11 +69,11 @@ void Core::DebugCommandHandler::registerCommand( const std::string& n, DebugComm
}
// try to retrieve the command in question, execute if found
void Core::DebugCommandHandler::execCommand( char * data, Entity::Player& player )
void Core::DebugCommandHandler::execCommand( char* data, Entity::Player& player )
{
// define callback pointer
void ( DebugCommandHandler::*pf )( char *, Entity::Player&, boost::shared_ptr< DebugCommand > );
void ( DebugCommandHandler::*pf )( char*, Entity::Player&, boost::shared_ptr< DebugCommand > );
std::string commandString;
@ -108,16 +107,13 @@ void Core::DebugCommandHandler::execCommand( char * data, Entity::Player& player
( this->*pf )( data, player, ( *it ).second );
return;
}
}
///////////////////////////////////////////////////////////////////////////////////////
// Definition of the commands
///////////////////////////////////////////////////////////////////////////////////////
void Core::DebugCommandHandler::scriptReload( char * data, Entity::Player& player,
void Core::DebugCommandHandler::scriptReload( char* data, Entity::Player& player,
boost::shared_ptr< DebugCommand > command )
{
g_scriptMgr.reload();
@ -127,16 +123,16 @@ void Core::DebugCommandHandler::scriptReload( char * data, Entity::Player& playe
void Core::DebugCommandHandler::help( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
{
player.sendDebug( "Registered debug commands:" );
for ( auto cmd : m_commandMap )
for( auto cmd : m_commandMap )
{
if ( player.getGmRank( ) >= cmd.second->m_gmLevel )
if( player.getGmRank() >= cmd.second->m_gmLevel )
{
player.sendDebug( " - " + cmd.first + " - " + cmd.second->getHelpText( ) );
player.sendDebug( " - " + cmd.first + " - " + cmd.second->getHelpText() );
}
}
}
void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
void Core::DebugCommandHandler::set( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
{
std::string subCommand = "";
std::string params = "";
@ -156,9 +152,7 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost:
if( command->getName().length() + 1 + pos + 1 < strlen( data ) )
params = std::string( data + command->getName().length() + 1 + pos + 1 );
g_log.debug( "[" + std::to_string( player.getId() ) + "] " +
"subCommand " + subCommand + " params: " + params );
g_log.debug( "[" + std::to_string( player.getId() ) + "] " + "subCommand " + subCommand + " params: " + params );
if( ( ( subCommand == "pos" ) || ( subCommand == "posr" ) ) && ( params != "" ) )
{
@ -175,21 +169,18 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost:
}
if( subCommand == "pos" )
player.setPosition( static_cast< float >( posX ),
static_cast< float >( posY ),
static_cast< float >( posZ ) );
player.setPosition( static_cast< float >( posX ), static_cast< float >( posY ), static_cast< float >( posZ ) );
else
player.setPosition( player.getPos().x + static_cast< float >( posX ),
player.getPos().y + static_cast< float >( posY ),
player.getPos().z + static_cast< float >( posZ ) );
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorSetPos >
setActorPosPacket( player.getId() );
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorSetPos > setActorPosPacket(
player.getId() );
setActorPosPacket.data().x = player.getPos().x;
setActorPosPacket.data().y = player.getPos().y;
setActorPosPacket.data().z = player.getPos().z;
player.queuePacket( setActorPosPacket );
}
else if( ( subCommand == "tele" ) && ( params != "" ) )
{
@ -204,7 +195,8 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost:
int32_t discover_id;
sscanf( params.c_str(), "%i %i", &map_id, &discover_id );
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcDiscovery > discoveryPacket( player.getId() );
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcDiscovery > discoveryPacket(
player.getId() );
discoveryPacket.data().map_id = map_id;
discoveryPacket.data().map_part_id = discover_id;
player.queuePacket( discoveryPacket );
@ -220,13 +212,12 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost:
std::string query2 = "UPDATE IGNORE `discoveryinfo` SET `discover_id` = '" + std::to_string( discover_id ) +
"' WHERE `discoveryinfo`.`id` = " + std::to_string( pos_id ) + ";";
std::string query1 = "INSERT IGNORE INTO `discoveryinfo` (`id`, `map_id`, `discover_id`) VALUES ('" + std::to_string( pos_id ) +
"', '" + std::to_string( map_id ) +
"', '" + std::to_string( discover_id ) + "')";
std::string query1 = "INSERT IGNORE INTO `discoveryinfo` (`id`, `map_id`, `discover_id`) VALUES ('" +
std::to_string( pos_id ) + "', '" + std::to_string( map_id ) + "', '" +
std::to_string( discover_id ) + "')";
g_charaDb.execute( query1 );
g_charaDb.execute( query2 );
}
else if( subCommand == "discovery_reset" )
@ -240,22 +231,22 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost:
sscanf( params.c_str(), "%d", &id );
if( player.getLevelForClass( static_cast< Common::ClassJob > ( id ) ) == 0 )
if( player.getLevelForClass( static_cast< Common::ClassJob >( id ) ) == 0 )
{
player.setLevelForClass( 1, static_cast< Common::ClassJob > ( id ) );
player.setClassJob( static_cast< Common::ClassJob > ( id ) );
player.setLevelForClass( 1, static_cast< Common::ClassJob >( id ) );
player.setClassJob( static_cast< Common::ClassJob >( id ) );
}
else
player.setClassJob( static_cast< Common::ClassJob > ( id ) );
player.setClassJob( static_cast< Common::ClassJob >( id ) );
}
else if ( subCommand == "cfpenalty" )
else if( subCommand == "cfpenalty" )
{
int32_t minutes;
sscanf( params.c_str(), "%d", &minutes );
player.setCFPenaltyMinutes( minutes );
}
else if ( subCommand == "eorzeatime" )
else if( subCommand == "eorzeatime" )
{
uint64_t timestamp;
sscanf( params.c_str(), "%" SCNu64, &timestamp );
@ -263,7 +254,7 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost:
player.setEorzeaTimeOffset( timestamp );
player.sendNotice( "Eorzea time offset: " + std::to_string( timestamp ) );
}
else if ( subCommand == "model" )
else if( subCommand == "model" )
{
uint32_t slot;
uint32_t val;
@ -273,7 +264,7 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost:
player.sendModel();
player.sendDebug( "Model updated" );
}
else if ( subCommand == "mount" )
else if( subCommand == "mount" )
{
int32_t id;
sscanf( params.c_str(), "%d", &id );
@ -285,10 +276,9 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost:
{
player.sendUrgent( subCommand + " is not a valid SET command." );
}
}
void Core::DebugCommandHandler::add( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
void Core::DebugCommandHandler::add( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
{
std::string subCommand;
std::string params = "";
@ -311,9 +301,7 @@ void Core::DebugCommandHandler::add( char * data, Entity::Player& player, boost:
if( command->getName().length() + 1 + pos + 1 < strlen( data ) )
params = std::string( data + command->getName().length() + 1 + pos + 1 );
g_log.debug( "[" + std::to_string( player.getId() ) + "] " +
"subCommand " + subCommand + " params: " + params );
g_log.debug( "[" + std::to_string( player.getId() ) + "] " + "subCommand " + subCommand + " params: " + params );
if( subCommand == "status" )
{
@ -323,7 +311,8 @@ void Core::DebugCommandHandler::add( char * data, Entity::Player& player, boost:
sscanf( params.c_str(), "%d %d %hu", &id, &duration, &param );
StatusEffect::StatusEffectPtr effect( new StatusEffect::StatusEffect( id, player.getAsPlayer(), player.getAsPlayer(), duration, 3000 ) );
StatusEffect::StatusEffectPtr effect(
new StatusEffect::StatusEffect( id, player.getAsPlayer(), player.getAsPlayer(), duration, 3000 ) );
effect->setParam( param );
player.addStatusEffect( effect );
@ -347,14 +336,14 @@ void Core::DebugCommandHandler::add( char * data, Entity::Player& player, boost:
auto pZone = player.getCurrentZone();
pBNpc->setCurrentZone( pZone );
pZone->pushActor( pBNpc );
}
else if( subCommand == "op" )
{
// temporary research packet
int32_t opcode;
sscanf( params.c_str(), "%x", &opcode );
Network::Packets::GamePacketPtr pPe( new Network::Packets::GamePacket( opcode, 0x30, player.getId(), player.getId() ) );
Network::Packets::GamePacketPtr pPe(
new Network::Packets::GamePacket( opcode, 0x30, player.getId(), player.getId() ) );
player.queuePacket( pPe );
}
else if( subCommand == "actrl" )
@ -371,11 +360,13 @@ void Core::DebugCommandHandler::add( char * data, Entity::Player& player, boost:
int32_t param6;
int32_t playerId;
sscanf( params.c_str(), "%x %x %x %x %x %x %x %x", &opcode, &param1, &param2, &param3, &param4, &param5, &param6, &playerId );
sscanf( params.c_str(), "%x %x %x %x %x %x %x %x", &opcode, &param1, &param2, &param3, &param4, &param5, &param6,
&playerId );
player.sendNotice( "Injecting ACTOR_CONTROL " + std::to_string( opcode ) );
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorControl143 > actorControl( playerId, player.getId() );
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorControl143 > actorControl(
playerId, player.getId() );
actorControl.data().category = opcode;
actorControl.data().param1 = param1;
actorControl.data().param2 = param2;
@ -385,27 +376,25 @@ void Core::DebugCommandHandler::add( char * data, Entity::Player& player, boost:
actorControl.data().param6 = param6;
player.queuePacket( actorControl );
/*sscanf(params.c_str(), "%x %x %x %x %x %x %x", &opcode, &param1, &param2, &param3, &param4, &param5, &param6,
&playerId);
/*sscanf(params.c_str(), "%x %x %x %x %x %x %x", &opcode, &param1, &param2, &param3, &param4, &param5, &param6, &playerId);
Network::Packets::Server::ServerNoticePacket noticePacket( player, "Injecting ACTOR_CONTROL " + std::to_string( opcode ) );
Network::Packets::Server::ServerNoticePacket noticePacket( player, "Injecting ACTOR_CONTROL " + std::to_string(
opcode ) );
player.queuePacket( noticePacket );
Network::Packets::Server::ActorControlPacket143 controlPacket( player, opcode,
param1, param2, param3, param4, param5, param6, playerId );
player.queuePacket( controlPacket );*/
}
else
{
player.sendUrgent( subCommand + " is not a valid ADD command." );
}
}
void Core::DebugCommandHandler::get( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
void Core::DebugCommandHandler::get( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
{
std::string subCommand;
std::string params = "";
@ -425,45 +414,41 @@ void Core::DebugCommandHandler::get( char * data, Entity::Player& player, boost:
if( command->getName().length() + 1 + pos + 1 < strlen( data ) )
params = std::string( data + command->getName().length() + 1 + pos + 1 );
g_log.debug( "[" + std::to_string( player.getId() ) + "] " +
"subCommand " + subCommand + " params: " + params );
g_log.debug( "[" + std::to_string( player.getId() ) + "] " + "subCommand " + subCommand + " params: " + params );
if( ( subCommand == "pos" ) )
{
int16_t map_id = g_exdData.m_zoneInfoMap[player.getCurrentZone()->getId()].map_id;
player.sendNotice( "Pos:\n" +
std::to_string( player.getPos().x ) + "\n" +
std::to_string( player.getPos().y ) + "\n" +
std::to_string( player.getPos().z ) + "\n" +
std::to_string( player.getRotation() ) + "\nMapId: " +
std::to_string( map_id ) + "\nZoneID: " +
std::to_string( player.getCurrentZone()->getId() ) + "\n" );
player.sendNotice( "Pos:\n" + std::to_string( player.getPos().x ) + "\n" + std::to_string( player.getPos().y ) +
"\n" + std::to_string( player.getPos().z ) + "\n" + std::to_string( player.getRotation() ) +
"\nMapId: " + std::to_string( map_id ) +
"\nZoneID: " + std::to_string( player.getCurrentZone()->getId() ) + "\n" );
}
else
{
player.sendUrgent( subCommand + " is not a valid GET command." );
}
}
void Core::DebugCommandHandler::injectPacket( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
void Core::DebugCommandHandler::injectPacket( char* data, Entity::Player& player,
boost::shared_ptr< DebugCommand > command )
{
auto pSession = g_serverZone.getSession( player.getId() );
if( pSession )
pSession->getZoneConnection()->injectPacket( data + 7, player );
}
void Core::DebugCommandHandler::injectChatPacket( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
void Core::DebugCommandHandler::injectChatPacket( char* data, Entity::Player& player,
boost::shared_ptr< DebugCommand > command )
{
auto pSession = g_serverZone.getSession( player.getId() );
if( pSession )
pSession->getChatConnection()->injectPacket( data + 8, player );
}
void Core::DebugCommandHandler::nudge( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
void Core::DebugCommandHandler::nudge( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
{
std::string subCommand;
@ -489,7 +474,6 @@ void Core::DebugCommandHandler::nudge( char * data, Entity::Player& player, boos
{
pos.y -= offset;
player.sendNotice( "nudge: Placing down " + std::to_string( offset ) + " yalms" );
}
else
{
@ -500,8 +484,8 @@ void Core::DebugCommandHandler::nudge( char * data, Entity::Player& player, boos
}
if( offset != 0 )
{
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorSetPos >
setActorPosPacket( player.getId() );
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorSetPos > setActorPosPacket(
player.getId() );
setActorPosPacket.data().x = player.getPos().x;
setActorPosPacket.data().y = player.getPos().y;
setActorPosPacket.data().z = player.getPos().z;
@ -510,14 +494,16 @@ void Core::DebugCommandHandler::nudge( char * data, Entity::Player& player, boos
}
}
void Core::DebugCommandHandler::serverInfo( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
void Core::DebugCommandHandler::serverInfo( char* data, Entity::Player& player,
boost::shared_ptr< DebugCommand > command )
{
player.sendDebug( "SapphireServer " + Version::VERSION + "\nRev: " + Version::GIT_HASH );
player.sendDebug( "Compiled: " __DATE__ " " __TIME__ );
player.sendDebug( "Sessions: " + std::to_string( g_serverZone.getSessionCount() ) );
}
void Core::DebugCommandHandler::unlockCharacter( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
void Core::DebugCommandHandler::unlockCharacter( char* data, Entity::Player& player,
boost::shared_ptr< DebugCommand > command )
{
player.unlock( );
player.unlock();
}

View file

@ -4,12 +4,11 @@
#include <map>
#include "DebugCommand.h"
#include <Server_Common/Common.h>
#include "Forwards.h"
#include <Server_Common/Common.h>
namespace Core {
// handler for in game commands
class DebugCommandHandler
{
@ -25,27 +24,26 @@ public:
void registerCommand( const std::string& n, DebugCommand::pFunc, const std::string& hText, uint8_t uLevel );
// execute command if registered
void execCommand( char * data, Entity::Player& player );
void execCommand( char* data, Entity::Player& player );
// help command
void help( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
// command handler callbacks
void set( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void get( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void add( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
//void debug( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void scriptReload( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void set( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void get( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void add( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
// void debug( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void scriptReload( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void injectPacket( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void injectChatPacket( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void injectPacket( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void injectChatPacket( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void nudge( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void serverInfo( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void serverInfo( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void unlockCharacter( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void targetInfo( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
};
}
} // namespace Core
#endif

View file

@ -1,7 +1,8 @@
#include "Event.h"
Core::Event::Event::Event( uint64_t actorId, uint32_t eventId, uint8_t eventType, uint8_t eventParam2, uint32_t eventParam3 )
: m_actorId( actorId ),
Core::Event::Event::Event( uint64_t actorId, uint32_t eventId, uint8_t eventType, uint8_t eventParam2,
uint32_t eventParam3 ) :
m_actorId( actorId ),
m_eventId( eventId ),
m_playedScene( false )
{
@ -61,7 +62,6 @@ void Core::Event::Event::setEventReturnCallback( Scripting::EventReturnCallback
m_callback = callback;
}
bool Core::Event::Event::hasPlayedScene() const
{
return m_playedScene;

View file

@ -4,7 +4,7 @@
#include "../Forwards.h"
namespace Core {
namespace Event {
namespace Event {
class Event
{
@ -73,6 +73,6 @@ namespace Core {
Scripting::EventReturnCallback m_callback;
};
}
}
} // namespace Event
} // namespace Core
#endif

View file

@ -5,12 +5,12 @@
#include <string>
namespace Core {
namespace Event {
namespace Event {
std::string getEventName( uint32_t eventId );
uint32_t mapEventActorToRealActor( uint32_t eventActorId );
}
}
} // namespace Event
} // namespace Core
#endif

View file

@ -5,51 +5,45 @@
#include <vector>
#define TYPE_FORWARD( x ) \
class x; \
typedef boost::shared_ptr< x > x ## Ptr; \
typedef std::vector< x > x ## PtrList;
class x; \
typedef boost::shared_ptr< x > x##Ptr; \
typedef std::vector< x > x##PtrList;
namespace Core
{
TYPE_FORWARD( Cell );
TYPE_FORWARD( Zone );
TYPE_FORWARD( Item );
TYPE_FORWARD( ItemContainer );
TYPE_FORWARD( Inventory );
TYPE_FORWARD( Session );
TYPE_FORWARD( XMLConfig );
TYPE_FORWARD( ZonePosition )
namespace Core {
TYPE_FORWARD( Cell );
TYPE_FORWARD( Zone );
TYPE_FORWARD( Item );
TYPE_FORWARD( ItemContainer );
TYPE_FORWARD( Inventory );
TYPE_FORWARD( Session );
TYPE_FORWARD( XMLConfig );
TYPE_FORWARD( ZonePosition )
namespace StatusEffect
{
namespace StatusEffect {
TYPE_FORWARD( StatusEffect );
TYPE_FORWARD( StatusEffectContainer );
}
} // namespace StatusEffect
namespace Entity
{
namespace Entity {
TYPE_FORWARD( Actor );
TYPE_FORWARD( Player );
TYPE_FORWARD( BattleNpc );
TYPE_FORWARD( BattleNpcTemplate );
}
} // namespace Entity
namespace Event
{
namespace Event {
TYPE_FORWARD( Event );
}
}
namespace Action
{
namespace Action {
TYPE_FORWARD( Action );
TYPE_FORWARD( ActionTeleport );
TYPE_FORWARD( ActionCast );
TYPE_FORWARD( ActionMount );
TYPE_FORWARD( EventAction );
}
} // namespace Action
namespace Network
{
namespace Network {
TYPE_FORWARD( Hive );
TYPE_FORWARD( Acceptor );
TYPE_FORWARD( Connection );
@ -57,25 +51,21 @@ namespace Core
TYPE_FORWARD( SessionConnection );
TYPE_FORWARD( CustomMsgClientConnection );
namespace Packets
{
namespace Packets {
TYPE_FORWARD( GamePacket );
}
}
} // namespace Network
namespace ContentFinder
{
namespace ContentFinder {
TYPE_FORWARD( ContentFinder );
}
namespace Scripting
{
typedef std::function< void( Entity::Player&, uint32_t, uint16_t, uint16_t, uint16_t ) > EventReturnCallback;
}
typedef std::function< void( Entity::Player&, uint32_t, uint64_t ) > ActionCallback;
}
namespace Scripting {
typedef std::function< void( Entity::Player&, uint32_t, uint16_t, uint16_t, uint16_t ) > EventReturnCallback;
}
typedef std::function< void( Entity::Player&, uint32_t, uint64_t ) > ActionCallback;
} // namespace Core
#endif

View file

@ -1,19 +1,19 @@
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include <Server_Common/Common.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include "Inventory.h"
#include "Actor/Player.h"
#include "ItemContainer.h"
#include "Item.h"
#include "ItemContainer.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/clamp.hpp>
#include <boost/lexical_cast.hpp>
#include "../Forwards.h"
#include "Network/PacketWrappers/ActorControlPacket143.h"
@ -35,8 +35,9 @@ Core::Inventory::Inventory( Core::Entity::Player* pOwner )
// shortcut for setting up inventory
// TODO: use a loop to set theese up?
auto setupContainer = []( InventoryMap& map, InventoryType type )
{ map[type] = ItemContainerPtr( new ItemContainer( type ) ); };
auto setupContainer = []( InventoryMap& map, InventoryType type ) {
map[type] = ItemContainerPtr( new ItemContainer( type ) );
};
// main bags
setupContainer( m_inventoryMap, Bag0 );
@ -52,8 +53,8 @@ Core::Inventory::Inventory( Core::Entity::Player* pOwner )
// crystals??
setupContainer( m_inventoryMap, Crystal );
//m_inventoryMap[0x07D3] = ItemContainerPtr( new ItemContainer( UNKNOWN_0 ) );
//m_inventoryMap[0x07D8] = ItemContainerPtr( new ItemContainer( UNKNOWN_1 ) );
// m_inventoryMap[0x07D3] = ItemContainerPtr( new ItemContainer( UNKNOWN_0 ) );
// m_inventoryMap[0x07D8] = ItemContainerPtr( new ItemContainer( UNKNOWN_1 ) );
// armory weapons - 0
setupContainer( m_inventoryMap, ArmoryMain );
@ -61,41 +62,40 @@ Core::Inventory::Inventory( Core::Entity::Player* pOwner )
// armory offhand - 1
setupContainer( m_inventoryMap, ArmoryOff );
//armory head - 2
// armory head - 2
setupContainer( m_inventoryMap, ArmoryHead );
//armory body - 3
// armory body - 3
setupContainer( m_inventoryMap, ArmoryBody );
//armory hand - 4
// armory hand - 4
setupContainer( m_inventoryMap, ArmoryHand );
//armory waist - 5
// armory waist - 5
setupContainer( m_inventoryMap, ArmoryWaist );
//armory legs - 6
// armory legs - 6
setupContainer( m_inventoryMap, ArmoryLegs );
//armory feet - 7
// armory feet - 7
setupContainer( m_inventoryMap, ArmoryFeet );
//neck
// neck
setupContainer( m_inventoryMap, ArmotyNeck );
//earring
// earring
setupContainer( m_inventoryMap, ArmoryEar );
//wrist
// wrist
setupContainer( m_inventoryMap, ArmoryWrist );
//armory rings - 11
// armory rings - 11
setupContainer( m_inventoryMap, ArmoryRing );
//soul crystals - 13
// soul crystals - 13
setupContainer( m_inventoryMap, ArmorySoulCrystal );
}
Core::Inventory::~Inventory()
{
}
@ -157,17 +157,13 @@ Core::ItemPtr Core::Inventory::createItem( uint32_t catalogId, uint8_t quantity
pItem->setCategory( static_cast< ItemUICategory >( itemInfo->ui_category ) );
g_charaDb.execute( "INSERT INTO charaglobalitem ( CharacterId, itemId, catalogId, stack, flags ) VALUES ( " +
std::to_string( m_pOwner->getId() ) + ", " +
std::to_string( pItem->getUId() ) + ", " +
std::to_string( pItem->getId() ) + ", " +
std::to_string( itemAmount ) + ", " +
std::to_string( m_pOwner->getId() ) + ", " + std::to_string( pItem->getUId() ) + ", " +
std::to_string( pItem->getId() ) + ", " + std::to_string( itemAmount ) + ", " +
std::to_string( flags ) + ");" );
return pItem;
}
uint32_t Core::Inventory::getCurrency( CurrencyType type )
{
@ -177,7 +173,6 @@ uint32_t Core::Inventory::getCurrency( CurrencyType type )
return 0;
return currItem->getStackSize();
}
uint32_t Core::Inventory::getCrystal( CrystalType type )
@ -189,7 +184,6 @@ uint32_t Core::Inventory::getCrystal( CrystalType type )
return 0;
return currItem->getStackSize();
}
bool Core::Inventory::addCrystal( CrystalType type, uint32_t amount )
@ -211,7 +205,6 @@ bool Core::Inventory::addCrystal( CrystalType type, uint32_t amount )
updateItemDb( currItem );
return true;
}
bool Core::Inventory::addCurrency( CurrencyType type, uint32_t amount )
@ -233,7 +226,6 @@ bool Core::Inventory::addCurrency( CurrencyType type, uint32_t amount )
updateItemDb( currItem );
return true;
}
void Core::Inventory::updateCurrencyDb()
@ -262,7 +254,6 @@ void Core::Inventory::updateCurrencyDb()
g_charaDb.execute( query );
}
void Core::Inventory::updateCrystalDb()
{
int32_t firstItemPos = -1;
@ -311,18 +302,10 @@ void Core::Inventory::updateBagDb( InventoryType type )
bool Core::Inventory::isArmory( uint16_t containerId )
{
return
containerId == ArmoryBody ||
containerId == ArmoryEar ||
containerId == ArmoryFeet ||
containerId == ArmoryHand ||
containerId == ArmoryHead ||
containerId == ArmoryLegs ||
containerId == ArmoryMain ||
containerId == ArmoryOff ||
containerId == ArmoryRing ||
containerId == ArmoryWaist ||
containerId == ArmoryWrist;
return containerId == ArmoryBody || containerId == ArmoryEar || containerId == ArmoryFeet ||
containerId == ArmoryHand || containerId == ArmoryHead || containerId == ArmoryLegs ||
containerId == ArmoryMain || containerId == ArmoryOff || containerId == ArmoryRing ||
containerId == ArmoryWaist || containerId == ArmoryWrist;
}
uint16_t Core::Inventory::getArmoryToEquipSlot( uint8_t slotId )
@ -364,14 +347,11 @@ uint16_t Core::Inventory::getArmoryToEquipSlot( uint8_t slotId )
return 0;
}
bool Core::Inventory::isEquipment( uint16_t containerId )
{
return containerId == GearSet0;
}
void Core::Inventory::updateMannequinDb( InventoryType type )
{
std::string query = "UPDATE charaitemgearset SET ";
@ -393,7 +373,6 @@ void Core::Inventory::updateMannequinDb( InventoryType type )
g_charaDb.execute( query );
}
void Core::Inventory::updateItemDb( Core::ItemPtr pItem ) const
{
g_charaDb.execute( "UPDATE charaglobalitem SET stack = " + std::to_string( pItem->getStackSize() ) + " " +
@ -441,7 +420,7 @@ bool Core::Inventory::removeCrystal( CrystalType type, uint32_t amount )
bool Core::Inventory::isOneHandedWeapon( ItemUICategory weaponCategory )
{
switch ( weaponCategory )
switch( weaponCategory )
{
case ItemUICategory::AlchemistsPrimaryTool:
case ItemUICategory::ArmorersPrimaryTool:
@ -469,7 +448,6 @@ bool Core::Inventory::isObtainable( uint32_t catalogId, uint8_t quantity )
return true;
}
int16_t Core::Inventory::addItem( uint16_t inventoryId, int8_t slotId, uint32_t catalogId, uint8_t quantity )
{
@ -483,13 +461,13 @@ int16_t Core::Inventory::addItem( uint16_t inventoryId, int8_t slotId, uint32_t
int8_t rSlotId = -1;
//if( itemInfo->stack_size > 1 )
// if( itemInfo->stack_size > 1 )
//{
// auto itemList = this->getSlotsOfItemsInInventory( catalogId );
// // TODO: this is a stacked item so we need to see if the item is already in inventory and
// // check how much free space we have on existing stacks before looking for empty slots.
//}
//else
// else
{
auto freeSlot = this->getFreeBagSlot();
inventoryId = freeSlot.first;
@ -506,8 +484,8 @@ int16_t Core::Inventory::addItem( uint16_t inventoryId, int8_t slotId, uint32_t
m_inventoryMap[inventoryId]->setItem( rSlotId, item );
g_charaDb.execute( "UPDATE charaiteminventory SET container_" + std::to_string( rSlotId ) + " = " + std::to_string( item->getUId() ) +
" WHERE storageId = " + std::to_string( inventoryId ) +
g_charaDb.execute( "UPDATE charaiteminventory SET container_" + std::to_string( rSlotId ) + " = " +
std::to_string( item->getUId() ) + " WHERE storageId = " + std::to_string( inventoryId ) +
" AND CharacterId = " + std::to_string( m_pOwner->getId() ) );
ZoneChannelPacket< FFXIVIpcUpdateInventorySlot > invUpPacket( m_pOwner->getId() );
@ -519,12 +497,11 @@ int16_t Core::Inventory::addItem( uint16_t inventoryId, int8_t slotId, uint32_t
invUpPacket.data().condition = 30000;
m_pOwner->queuePacket( invUpPacket );
m_pOwner->queuePacket( ActorControlPacket143( m_pOwner->getId(), ItemObtainIcon, catalogId, item->getStackSize() ) );
m_pOwner->queuePacket(
ActorControlPacket143( m_pOwner->getId(), ItemObtainIcon, catalogId, item->getStackSize() ) );
}
return rSlotId;
}
void Core::Inventory::moveItem( uint16_t fromInventoryId, uint8_t fromSlotId, uint16_t toInventoryId, uint8_t toSlot )
@ -557,8 +534,6 @@ void Core::Inventory::moveItem( uint16_t fromInventoryId, uint8_t fromSlotId, ui
m_pOwner->unequipItem( static_cast< EquipSlot >( fromSlotId ), tmpItem );
updateMannequinDb( static_cast< InventoryType >( fromInventoryId ) );
}
}
bool Core::Inventory::updateContainer( uint16_t containerId, uint8_t slotId, ItemPtr pItem )
@ -605,13 +580,11 @@ void Core::Inventory::swapItem( uint16_t fromInventoryId, uint8_t fromSlotId, ui
// An item is being moved from bag0-3 to equippment, meaning
// the swapped out item will be placed in the matching armory.
if( isEquipment( toInventoryId )
&& !isEquipment( fromInventoryId )
&& !isArmory( fromInventoryId ) )
if( isEquipment( toInventoryId ) && !isEquipment( fromInventoryId ) && !isArmory( fromInventoryId ) )
{
updateContainer( fromInventoryId, fromSlotId, nullptr );
fromInventoryId = getArmoryToEquipSlot( toSlot );
fromSlotId = static_cast < uint8_t >( m_inventoryMap[fromInventoryId]->getFreeSlot() );
fromSlotId = static_cast< uint8_t >( m_inventoryMap[fromInventoryId]->getFreeSlot() );
}
auto containerTypeFrom = getContainerType( fromInventoryId );
@ -650,7 +623,8 @@ void Core::Inventory::discardItem( uint16_t fromInventoryId, uint8_t fromSlotId
Core::ItemPtr Core::Inventory::loadItem( uint64_t uId )
{
// load actual item
auto itemRes = g_charaDb.query( "SELECT catalogId, stack, flags FROM charaglobalitem WHERE itemId = " + std::to_string( uId ) + ";" );
auto itemRes = g_charaDb.query(
"SELECT catalogId, stack, flags FROM charaglobalitem WHERE itemId = " + std::to_string( uId ) + ";" );
if( !itemRes->next() )
return nullptr;
@ -658,12 +632,8 @@ Core::ItemPtr Core::Inventory::loadItem( uint64_t uId )
{
auto itemInfo = g_exdData.getItemInfo( itemRes->getUInt( 1 ) );
bool isHq = itemRes->getUInt( 3 ) == 1 ? true : false;
ItemPtr pItem( new Item( uId,
itemInfo->id,
itemInfo->model_primary,
itemInfo->model_secondary,
static_cast< ItemUICategory >( itemInfo->ui_category ),
isHq ) );
ItemPtr pItem( new Item( uId, itemInfo->id, itemInfo->model_primary, itemInfo->model_secondary,
static_cast< ItemUICategory >( itemInfo->ui_category ), isHq ) );
pItem->setStackSize( itemRes->getUInt( 2 ) );
return pItem;
@ -682,8 +652,10 @@ bool Core::Inventory::load()
"container_4, container_5, container_6, container_7, "
"container_8, container_9, container_10, container_11, "
"container_12, container_13 "
"FROM charaitemgearset " \
"WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) + " " \
"FROM charaitemgearset "
"WHERE CharacterId = " +
std::to_string( m_pOwner->getId() ) +
" "
"ORDER BY storageId ASC;" );
while( res->next() )
@ -716,8 +688,10 @@ bool Core::Inventory::load()
"container_20, container_21, container_22, container_23, container_24, "
"container_25, container_26, container_27, container_28, container_29, "
"container_30, container_31, container_32, container_33, container_34 "
"FROM charaiteminventory " \
"WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) + " " \
"FROM charaiteminventory "
"WHERE CharacterId = " +
std::to_string( m_pOwner->getId() ) +
" "
"ORDER BY storageId ASC;" );
while( bagRes->next() )
@ -738,15 +712,16 @@ bool Core::Inventory::load()
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
// Load Currency
auto curRes = g_charaDb.query( "SELECT storageId, "
"container_0, container_1, container_2, container_3, container_4, "
"container_5, container_6, container_7, container_8, container_9, "
"container_10, container_11 "
"FROM charaitemcurrency " \
"WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) + " " \
"FROM charaitemcurrency "
"WHERE CharacterId = " +
std::to_string( m_pOwner->getId() ) +
" "
"ORDER BY storageId ASC;" );
while( curRes->next() )
@ -767,7 +742,6 @@ bool Core::Inventory::load()
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
// Load Crystals
auto crystalRes = g_charaDb.query( "SELECT storageId, "
@ -775,8 +749,10 @@ bool Core::Inventory::load()
"container_5, container_6, container_7, container_8, container_9, "
"container_10, container_11, container_12, container_13, container_14, "
"container_15, container_16, container_17 "
"FROM charaitemcrystal " \
"WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) + " " \
"FROM charaitemcrystal "
"WHERE CharacterId = " +
std::to_string( m_pOwner->getId() ) +
" "
"ORDER BY storageId ASC;" );
while( crystalRes->next() )
@ -800,7 +776,6 @@ bool Core::Inventory::load()
return true;
}
void Core::Inventory::send()
{
InventoryMap::iterator it;
@ -848,10 +823,7 @@ void Core::Inventory::send()
containerInfoPacket.data().numItems = it->second->getEntryCount();
containerInfoPacket.data().containerId = it->second->getId();
m_pOwner->queuePacket( containerInfoPacket );
}
}
uint16_t Core::Inventory::calculateEquippedGearItemLevel()
@ -862,16 +834,16 @@ uint16_t Core::Inventory::calculateEquippedGearItemLevel()
auto it = gearSetMap.begin();
while ( it != gearSetMap.end() )
while( it != gearSetMap.end() )
{
auto currItem = it->second;
if ( currItem )
if( currItem )
{
iLvlResult += currItem->getItemLevel();
// If item is weapon and isn't one-handed
if ( currItem->isWeapon() && !isOneHandedWeapon( currItem->getCategory() ) )
if( currItem->isWeapon() && !isOneHandedWeapon( currItem->getCategory() ) )
{
iLvlResult += currItem->getItemLevel();
}
@ -887,7 +859,6 @@ uint16_t Core::Inventory::calculateEquippedGearItemLevel()
return boost::algorithm::clamp( iLvlResult / 12, 0, 9999 );
}
uint8_t Core::Inventory::getFreeSlotsInBags()
{
uint8_t slots = 0;
@ -898,7 +869,6 @@ uint8_t Core::Inventory::getFreeSlotsInBags()
return slots;
}
Core::Inventory::ContainerType Core::Inventory::getContainerType( uint32_t containerId )
{
if( containerId < 5 )

View file

@ -1,11 +1,10 @@
#ifndef INVENTORY_H_
#define INVENTORY_H_
#include <map>
#include <Server_Common/Common.h>
#include "../Forwards.h"
#include <Server_Common/Common.h>
#include <map>
namespace Core
{
namespace Core {
class ItemContainer;
@ -37,10 +36,10 @@ public:
Currency = 2000,
Crystal = 2001,
//UNKNOWN_0 = 2003,
// UNKNOWN_0 = 2003,
KeyItem = 2004,
DamagedGear = 2007,
//UNKNOWN_1 = 2008,
// UNKNOWN_1 = 2008,
ArmoryOff = 3200,
ArmoryHead = 3201,
@ -193,11 +192,10 @@ public:
uint32_t getNextUId();
private:
Entity::Player* m_pOwner;
InventoryMap m_inventoryMap;
};
}
} // namespace Core
#endif

View file

@ -1,22 +1,19 @@
#include "Item.h"
#include <Server_Common/Common.h>
#include <Server_Common/Exd/ExdData.h>
#include "Item.h"
extern Core::Data::ExdData g_exdData;
Core::Item::Item()
{
}
Core::Item::Item( uint32_t catalogId ) :
m_id( catalogId ),
m_isHq( false )
Core::Item::Item( uint32_t catalogId ) : m_id( catalogId ), m_isHq( false )
{
}
Core::Item::Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t model2, Common::ItemUICategory categoryId, bool isHq ) :
Core::Item::Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t model2, Common::ItemUICategory categoryId,
bool isHq ) :
m_id( catalogId ),
m_uId( uId ),
m_category( static_cast< Common::ItemUICategory >( categoryId ) ),
@ -35,7 +32,6 @@ Core::Item::Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t mo
Core::Item::~Item()
{
}
float Core::Item::getAutoAttackDmg() const
@ -70,7 +66,7 @@ uint16_t Core::Item::getWeaponDmg() const
bool Core::Item::isWeapon() const
{
return (m_weaponDmg != 0);
return ( m_weaponDmg != 0 );
}
uint32_t Core::Item::getId() const

View file

@ -11,7 +11,8 @@ class Item
public:
Item();
Item( uint32_t catalogId );
Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t model2, Common::ItemUICategory categoryId, bool isHq = false );
Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t model2, Common::ItemUICategory categoryId,
bool isHq = false );
~Item();
uint32_t getId() const;
@ -54,7 +55,6 @@ public:
uint16_t getItemLevel() const;
protected:
uint32_t m_id;
@ -76,9 +76,8 @@ protected:
uint16_t m_weaponDmg;
float m_autoAttackDmg;
uint16_t m_itemLevel;
};
}
} // namespace Core
#endif

View file

@ -1,27 +1,22 @@
#include "../Forwards.h"
#include "ItemContainer.h"
#include "../Forwards.h"
#include <Server_Common/Common.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Database/DatabaseDef.h>
#include <Server_Common/Logging/Logger.h>
#include "Actor/Player.h"
#include "Item.h"
extern Core::Logger g_log;
Core::ItemContainer::ItemContainer( uint16_t locationId ) :
m_id( locationId ),
m_size( 25 )
Core::ItemContainer::ItemContainer( uint16_t locationId ) : m_id( locationId ), m_size( 25 )
{
}
Core::ItemContainer::~ItemContainer()
{
}
uint16_t Core::ItemContainer::getId() const
@ -52,12 +47,12 @@ void Core::ItemContainer::removeItem( uint8_t slotId )
}
}
Core::ItemMap & Core::ItemContainer::getItemMap()
Core::ItemMap& Core::ItemContainer::getItemMap()
{
return m_itemMap;
}
const Core::ItemMap & Core::ItemContainer::getItemMap() const
const Core::ItemMap& Core::ItemContainer::getItemMap() const
{
return m_itemMap;
}
@ -67,8 +62,7 @@ int16_t Core::ItemContainer::getFreeSlot()
for( uint8_t slotId = 0; slotId < m_size; slotId++ )
{
ItemMap::iterator it = m_itemMap.find( slotId );
if( it == m_itemMap.end() ||
it->second == nullptr )
if( it == m_itemMap.end() || it->second == nullptr )
return slotId;
}
return -1;

View file

@ -7,15 +7,14 @@
#include "../Forwards.h"
namespace Core
namespace Core {
typedef std::map< uint8_t, ItemPtr > ItemMap;
class ItemContainer
{
typedef std::map< uint8_t, ItemPtr > ItemMap;
class ItemContainer
{
public:
public:
ItemContainer( uint16_t locationId );
~ItemContainer();
@ -35,13 +34,13 @@ namespace Core
int16_t getFreeSlot();
private:
private:
uint16_t m_id;
uint8_t m_size;
ItemMap m_itemMap;
Entity::PlayerPtr m_pOwner;
};
};
}
} // namespace Core
#endif

View file

@ -1,12 +1,8 @@
#include "Linkshell.h"
Core::Linkshell::Linkshell( uint64_t id,
const std::string &name,
uint64_t masterId,
const std::set<uint64_t> &members,
const std::set<uint64_t> &leaders,
const std::set<uint64_t> &invites ) :
Core::Linkshell::Linkshell( uint64_t id, const std::string& name, uint64_t masterId,
const std::set< uint64_t >& members, const std::set< uint64_t >& leaders,
const std::set< uint64_t >& invites ) :
m_linkshellId( id ),
m_name( name ),
m_masterCharacterId( masterId ),
@ -14,7 +10,6 @@ Core::Linkshell::Linkshell( uint64_t id,
m_leaderIds( leaders ),
m_inviteIds( invites )
{
}
uint64_t Core::Linkshell::getId() const
@ -57,7 +52,7 @@ const std::set< uint64_t >& Core::Linkshell::getInviteIdList() const
return m_inviteIds;
}
std::set< uint64_t > &Core::Linkshell::getInviteIdList()
std::set< uint64_t >& Core::Linkshell::getInviteIdList()
{
return m_inviteIds;
}
@ -91,6 +86,3 @@ void Core::Linkshell::removeInvite( uint64_t memberId )
{
m_inviteIds.erase( memberId );
}

View file

@ -4,8 +4,7 @@
#include <Server_Common/Common.h>
#include <set>
namespace Core
{
namespace Core {
class Linkshell
{
@ -24,12 +23,8 @@ private:
std::set< uint64_t > m_inviteIds;
public:
Linkshell( uint64_t id,
const std::string& name,
uint64_t masterId,
const std::set< uint64_t >& members,
const std::set< uint64_t >& leaders,
const std::set< uint64_t >& invites );
Linkshell( uint64_t id, const std::string& name, uint64_t masterId, const std::set< uint64_t >& members,
const std::set< uint64_t >& leaders, const std::set< uint64_t >& invites );
uint64_t getId() const;
@ -54,9 +49,7 @@ public:
void addInvite( uint64_t memberId );
void removeInvite( uint64_t memberId );
};
}
#endif //SAPPHIRE_LINKSHELL_H
} // namespace Core
#endif // SAPPHIRE_LINKSHELL_H

View file

@ -9,7 +9,6 @@ extern Core::Logger g_log;
Core::LinkshellMgr::LinkshellMgr()
{
}
bool Core::LinkshellMgr::loadLinkshells()
@ -20,15 +19,13 @@ bool Core::LinkshellMgr::loadLinkshells()
"FROM infolinkshell "
"ORDER BY LinkshellId ASC;" );
while( res->next() )
{
uint64_t linkshellId = res->getUInt64( 1 );
uint32_t masterId = res->getUInt( 2 );
std::string name = res->getString( 4 );
auto func = []( std::set< uint64_t >& outList, std::vector< char >& inData )
{
auto func = []( std::set< uint64_t >& outList, std::vector< char >& inData ) {
if( inData.size() )
{
std::vector< uint64_t > list( inData.size() / 8 );
@ -54,11 +51,9 @@ bool Core::LinkshellMgr::loadLinkshells()
auto lsPtr = boost::make_shared< Linkshell >( linkshellId, name, masterId, members, leaders, invites );
m_linkshellIdMap[linkshellId] = lsPtr;
m_linkshellNameMap[name] = lsPtr;
}
return true;
}
Core::LinkshellPtr Core::LinkshellMgr::getLinkshellByName( const std::string& name )

View file

@ -4,8 +4,7 @@
#include <boost/shared_ptr.hpp>
#include <map>
namespace Core
{
namespace Core {
class Linkshell;
using LinkshellPtr = boost::shared_ptr< Linkshell >;
@ -24,5 +23,5 @@ public:
bool loadLinkshells();
};
}
#endif //CORE_LINKSHELLMGR_H
} // namespace Core
#endif // CORE_LINKSHELLMGR_H

View file

@ -1,11 +1,10 @@
#include <cmath>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Common.h>
#include "Actor/Actor.h"
#include "Actor/Player.h"
#include "CalcBattle.h"
#include <Server_Common/Common.h>
#include <Server_Common/Exd/ExdData.h>
using namespace Core::Math;
using namespace Core::Entity;
@ -33,8 +32,7 @@ uint32_t CalcBattle::calculateHealValue( PlayerPtr pPlayer, uint32_t potency )
auto classInfoIt = g_exdData.m_classJobInfoMap.find( static_cast< uint8_t >( pPlayer->getClass() ) );
auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find( pPlayer->getLevel() );
if ( classInfoIt == g_exdData.m_classJobInfoMap.end() ||
paramGrowthInfoIt == g_exdData.m_paramGrowthInfoMap.end())
if( classInfoIt == g_exdData.m_classJobInfoMap.end() || paramGrowthInfoIt == g_exdData.m_paramGrowthInfoMap.end() )
return 0;
auto jobModVal = classInfoIt->second;

View file

@ -1,8 +1,8 @@
#ifndef _CALCBATTLE_H
#define _CALCBATTLE_H
#include <Server_Common/Common.h>
#include "Actor/Actor.h"
#include <Server_Common/Common.h>
using namespace Core::Entity;
@ -15,10 +15,9 @@ namespace Math {
static uint32_t calculateHealValue( PlayerPtr pPlayer, uint32_t potency );
private:
};
}
}
} // namespace Math
} // namespace Core
#endif

View file

@ -1,13 +1,12 @@
#include <cmath>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Common.h>
#include "Actor/Actor.h"
#include "Actor/Player.h"
#include <Server_Common/Common.h>
#include <Server_Common/Exd/ExdData.h>
#include "CalcStats.h"
using namespace Core::Math;
using namespace Core::Entity;
@ -38,12 +37,12 @@ float CalcStats::calculateBaseStat( PlayerPtr pPlayer )
uint8_t level = pPlayer->getLevel();
// SB Base Stat Formula (Aligned)
if ( level > 60 )
if( level > 60 )
{
base = static_cast< float >( ( ( ( level == 61 ) ? 224 : 220 ) + ( level - 61 ) * 8) );
base = static_cast< float >( ( ( ( level == 61 ) ? 224 : 220 ) + ( level - 61 ) * 8 ) );
}
// HW Base Stat Formula (Aligned)
else if ( level > 50 )
else if( level > 50 )
base = 1.63f * level + 121.02f;
// ARR Base Stat Formula (Off by one in several cases)
else
@ -58,14 +57,14 @@ float CalcStats::calculateBaseStat( PlayerPtr pPlayer )
uint32_t CalcStats::calculateMaxHp( PlayerPtr pPlayer )
{
// TODO: Replace ApproxBaseHP with something that can get us an accurate BaseHP.
// Is there any way to pull reliable BaseHP without having to manually use a pet for every level, and using the values from a table?
// More info here: https://docs.google.com/spreadsheets/d/1de06KGT0cNRUvyiXNmjNgcNvzBCCQku7jte5QxEQRbs/edit?usp=sharing
// Is there any way to pull reliable BaseHP without having to manually use a pet for every level, and using the
// values from a table? More info here:
// https://docs.google.com/spreadsheets/d/1de06KGT0cNRUvyiXNmjNgcNvzBCCQku7jte5QxEQRbs/edit?usp=sharing
auto classInfoIt = g_exdData.m_classJobInfoMap.find( static_cast< uint8_t >( pPlayer->getClass() ) );
auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find( pPlayer->getLevel() );
if ( classInfoIt == g_exdData.m_classJobInfoMap.end() ||
paramGrowthInfoIt == g_exdData.m_paramGrowthInfoMap.end() )
if( classInfoIt == g_exdData.m_classJobInfoMap.end() || paramGrowthInfoIt == g_exdData.m_paramGrowthInfoMap.end() )
return 0;
uint8_t level = pPlayer->getLevel();
@ -78,14 +77,15 @@ uint32_t CalcStats::calculateMaxHp( PlayerPtr pPlayer )
// These values are not precise.
if ( level >= 60 )
if( level >= 60 )
approxBaseHp = static_cast< float >( 2600 + ( level - 60 ) * 100 );
else if ( level >= 50 )
else if( level >= 50 )
approxBaseHp = 1700 + ( ( level - 50 ) * ( 1700 * 1.04325f ) );
else
approxBaseHp = paramGrowthInfoIt->second.mp_const * 0.7667f;
uint16_t result = static_cast< uint16_t >( floor( jobModHp * ( approxBaseHp / 100.0f ) ) + floor( hpMod / 100.0f * ( vitStat - baseStat ) ) );
uint16_t result = static_cast< uint16_t >( floor( jobModHp * ( approxBaseHp / 100.0f ) ) +
floor( hpMod / 100.0f * ( vitStat - baseStat ) ) );
return result;
}
@ -98,8 +98,7 @@ uint32_t CalcStats::calculateMaxMp( PlayerPtr pPlayer )
auto classInfoIt = g_exdData.m_classJobInfoMap.find( static_cast< uint8_t >( pPlayer->getClass() ) );
auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find( pPlayer->getLevel() );
if ( classInfoIt == g_exdData.m_classJobInfoMap.end() ||
paramGrowthInfoIt == g_exdData.m_paramGrowthInfoMap.end() )
if( classInfoIt == g_exdData.m_classJobInfoMap.end() || paramGrowthInfoIt == g_exdData.m_paramGrowthInfoMap.end() )
return 0;
float baseStat = calculateBaseStat( pPlayer );
@ -108,7 +107,8 @@ uint32_t CalcStats::calculateMaxMp( PlayerPtr pPlayer )
uint16_t jobModMp = classInfoIt->second.mod_mpcpgp;
uint16_t baseMp = paramGrowthInfoIt->second.mp_const;
uint16_t result = static_cast< uint16_t >( floor( floor( piety - baseStat ) * ( pietyScalar / 100 ) + baseMp ) * jobModMp / 100 );
uint16_t result =
static_cast< uint16_t >( floor( floor( piety - baseStat ) * ( pietyScalar / 100 ) + baseMp ) * jobModMp / 100 );
return result;
}

View file

@ -1,8 +1,8 @@
#ifndef _CALCSTATS_H
#define _CALCSTATS_H
#include <Server_Common/Common.h>
#include "Actor/Actor.h"
#include <Server_Common/Common.h>
using namespace Core::Entity;
@ -17,10 +17,9 @@ namespace Math {
static uint32_t calculateMaxHp( PlayerPtr pPlayer );
private:
};
}
}
} // namespace Math
} // namespace Core
#endif

View file

@ -1,20 +1,20 @@
#include <Server_Common/Common.h>
#include <Server_Common/Network/CommonNetwork.h>
#include <Server_Common/Util/Util.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Network/PacketContainer.h>
#include <Server_Common/Network/CommonNetwork.h>
#include <Server_Common/Network/GamePacketParser.h>
#include <Server_Common/Network/PacketContainer.h>
#include <Server_Common/Util/Util.h>
#include <boost/format.hpp>
#include "GameConnection.h"
#include "Actor/Player.h"
#include "DebugCommand/DebugCommandHandler.h"
#include "Forwards.h"
#include "Network/PacketWrappers/InitUIPacket.h"
#include "ServerZone.h"
#include "Session.h"
#include "Zone/Zone.h"
#include "Network/PacketWrappers/InitUIPacket.h"
#include "DebugCommand/DebugCommandHandler.h"
#include "Actor/Player.h"
#include "Forwards.h"
extern Core::DebugCommandHandler g_gameCommandMgr;
extern Core::Logger g_log;
@ -24,20 +24,17 @@ using namespace Core::Common;
using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server;
Core::Network::GameConnection::GameConnection( Core::Network::HivePtr pHive,
Core::Network::AcceptorPtr pAcceptor )
: Connection( pHive )
, m_pAcceptor( pAcceptor )
, m_conType( ConnectionType::None )
Core::Network::GameConnection::GameConnection( Core::Network::HivePtr pHive, Core::Network::AcceptorPtr pAcceptor ) :
Connection( pHive ),
m_pAcceptor( pAcceptor ),
m_conType( ConnectionType::None )
{
auto setZoneHandler = [=]( uint16_t opcode, std::string handlerName, GameConnection::Handler pHandler )
{
auto setZoneHandler = [=]( uint16_t opcode, std::string handlerName, GameConnection::Handler pHandler ) {
m_zoneHandlerMap[opcode] = pHandler;
m_zoneHandlerStrMap[opcode] = handlerName;
};
auto setChatHandler = [=]( uint16_t opcode, std::string handlerName, GameConnection::Handler pHandler )
{
auto setChatHandler = [=]( uint16_t opcode, std::string handlerName, GameConnection::Handler pHandler ) {
m_chatHandlerMap[opcode] = pHandler;
m_chatHandlerStrMap[opcode] = handlerName;
};
@ -46,18 +43,22 @@ Core::Network::GameConnection::GameConnection( Core::Network::HivePtr pHive,
setZoneHandler( ClientZoneIpcType::InitHandler, "InitHandler", &GameConnection::initHandler );
setZoneHandler( ClientZoneIpcType::ChatHandler, "ChatHandler", &GameConnection::chatHandler );
setZoneHandler( ClientZoneIpcType::FinishLoadingHandler, "FinishLoadingHandler", &GameConnection::finishLoadingHandler );
setZoneHandler( ClientZoneIpcType::FinishLoadingHandler, "FinishLoadingHandler",
&GameConnection::finishLoadingHandler );
setZoneHandler( ClientZoneIpcType::PlayTimeHandler, "PlayTimeHandler", &GameConnection::playTimeHandler );
setZoneHandler( ClientZoneIpcType::LogoutHandler, "LogoutHandler", &GameConnection::logoutHandler );
setZoneHandler( ClientZoneIpcType::SocialListHandler, "SocialListHandler", &GameConnection::socialListHandler );
setZoneHandler( ClientZoneIpcType::SetSearchInfoHandler, "SetSearchInfoHandler", &GameConnection::setSearchInfoHandler );
setZoneHandler( ClientZoneIpcType::ReqSearchInfoHandler, "ReqSearchInfoHandler", &GameConnection::reqSearchInfoHandler );
setZoneHandler( ClientZoneIpcType::SetSearchInfoHandler, "SetSearchInfoHandler",
&GameConnection::setSearchInfoHandler );
setZoneHandler( ClientZoneIpcType::ReqSearchInfoHandler, "ReqSearchInfoHandler",
&GameConnection::reqSearchInfoHandler );
setZoneHandler( ClientZoneIpcType::BlackListHandler, "BlackListHandler", &GameConnection::blackListHandler );
setZoneHandler( ClientZoneIpcType::LinkshellListHandler, "LinkshellListHandler", &GameConnection::linkshellListHandler );
setZoneHandler( ClientZoneIpcType::LinkshellListHandler, "LinkshellListHandler",
&GameConnection::linkshellListHandler );
setZoneHandler( ClientZoneIpcType::FcInfoReqHandler, "FcInfoReqHandler", &GameConnection::fcInfoReqHandler );
@ -71,9 +72,11 @@ Core::Network::GameConnection::GameConnection( Core::Network::HivePtr pHive,
setZoneHandler( ClientZoneIpcType::GMCommand1, "GMCommand1", &GameConnection::gm1Handler );
setZoneHandler( ClientZoneIpcType::GMCommand2, "GMCommand2", &GameConnection::gm2Handler );
setZoneHandler( ClientZoneIpcType::UpdatePositionHandler,"UpdatePositionHandler", &GameConnection::updatePositionHandler );
setZoneHandler( ClientZoneIpcType::UpdatePositionHandler, "UpdatePositionHandler",
&GameConnection::updatePositionHandler );
setZoneHandler( ClientZoneIpcType::InventoryModifyHandler,"InventoryModifyHandler", &GameConnection::inventoryModifyHandler );
setZoneHandler( ClientZoneIpcType::InventoryModifyHandler, "InventoryModifyHandler",
&GameConnection::inventoryModifyHandler );
setZoneHandler( ClientZoneIpcType::TalkEventHandler, "EventHandler", &GameConnection::eventHandler );
setZoneHandler( ClientZoneIpcType::EmoteEventHandler, "EventHandler", &GameConnection::eventHandler );
@ -90,21 +93,20 @@ Core::Network::GameConnection::GameConnection( Core::Network::HivePtr pHive,
setZoneHandler( ClientZoneIpcType::CFDutyInfoHandler, "CFDutyInfoRequest", &GameConnection::cfDutyInfoRequest );
setZoneHandler( ClientZoneIpcType::CFRegisterDuty, "CFRegisterDuty", &GameConnection::cfRegisterDuty );
setZoneHandler( ClientZoneIpcType::CFRegisterRoulette, "CFRegisterRoulette", &GameConnection::cfRegisterRoulette );
setZoneHandler( ClientZoneIpcType::CFCommenceHandler, "CFDutyAccepted", &GameConnection::cfDutyAccepted);
setZoneHandler( ClientZoneIpcType::CFCommenceHandler, "CFDutyAccepted", &GameConnection::cfDutyAccepted );
setZoneHandler( ClientZoneIpcType::ReqEquipDisplayFlagsChange, "ReqEquipDisplayFlagsChange", &GameConnection::reqEquipDisplayFlagsHandler );
setZoneHandler( ClientZoneIpcType::ReqEquipDisplayFlagsChange, "ReqEquipDisplayFlagsChange",
&GameConnection::reqEquipDisplayFlagsHandler );
setZoneHandler( ClientZoneIpcType::PerformNoteHandler, "PerformNoteHandler", &GameConnection::performNoteHandler );
setChatHandler( ClientChatIpcType::TellReq, "TellReq", &GameConnection::tellHandler);
setChatHandler( ClientChatIpcType::TellReq, "TellReq", &GameConnection::tellHandler );
}
Core::Network::GameConnection::~GameConnection() = default;
// overwrite the parents onConnect for our game socket needs
void Core::Network::GameConnection::OnAccept( const std::string & host, uint16_t port )
void Core::Network::GameConnection::OnAccept( const std::string& host, uint16_t port )
{
GameConnectionPtr connection( new GameConnection( m_hive, m_pAcceptor ) );
m_pAcceptor->Accept( connection );
@ -112,14 +114,13 @@ void Core::Network::GameConnection::OnAccept( const std::string & host, uint16_t
g_log.info( "Connect from " + m_socket.remote_endpoint().address().to_string() );
}
void Core::Network::GameConnection::OnDisconnect()
{
g_log.debug( "GameConnection DISCONNECT" );
m_pSession = nullptr;
}
void Core::Network::GameConnection::OnRecv( std::vector< uint8_t > & buffer )
void Core::Network::GameConnection::OnRecv( std::vector< uint8_t >& buffer )
{
// This is assumed packet always start with valid FFXIVARR_PACKET_HEADER for now.
@ -142,8 +143,8 @@ void Core::Network::GameConnection::OnRecv( std::vector< uint8_t > & buffer )
// Dissect packet list
std::vector< Packets::FFXIVARR_PACKET_RAW > packetList;
const auto packetResult = Packets::getPackets( buffer, sizeof( struct FFXIVARR_PACKET_HEADER ),
packetHeader, packetList );
const auto packetResult =
Packets::getPackets( buffer, sizeof( struct FFXIVARR_PACKET_HEADER ), packetHeader, packetList );
if( packetResult == Incomplete )
{
@ -163,7 +164,7 @@ void Core::Network::GameConnection::OnRecv( std::vector< uint8_t > & buffer )
handlePackets( packetHeader, packetList );
}
void Core::Network::GameConnection::OnError( const boost::system::error_code & error )
void Core::Network::GameConnection::OnError( const boost::system::error_code& error )
{
g_log.debug( "GameConnection ERROR: " + error.message() );
}
@ -189,25 +190,24 @@ void Core::Network::GameConnection::handleZonePacket( const Packets::GamePacket&
auto itStr = m_zoneHandlerStrMap.find( pPacket.getSubType() );
std::string name = itStr != m_zoneHandlerStrMap.end() ? itStr->second : "unknown";
// dont display packet notification if it is a ping or pos update, don't want the spam
if( pPacket.getSubType() != PingHandler &&
pPacket.getSubType() != UpdatePositionHandler )
if( pPacket.getSubType() != PingHandler && pPacket.getSubType() != UpdatePositionHandler )
g_log.debug( sessionStr + " Handling Zone IPC : " + name + "( " +
boost::str( boost::format( "%|04X|" ) %
static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) + " )" );
g_log.debug(
sessionStr + " Handling Zone IPC : " + name + "( " +
boost::str( boost::format( "%|04X|" ) % static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) +
" )" );
( this->*( it->second ) )( pPacket, *m_pSession->getPlayer() );
}
else
{
g_log.debug( sessionStr + " Undefined Zone IPC : Unknown ( " +
boost::str( boost::format( "%|04X|" ) %
static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) + " )" );
boost::str( boost::format( "%|04X|" ) % static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) +
" )" );
g_log.debug( "\n" + pPacket.toString() );
}
}
void Core::Network::GameConnection::handleChatPacket( const Packets::GamePacket& pPacket )
{
auto it = m_chatHandlerMap.find( pPacket.getSubType() );
@ -221,16 +221,16 @@ void Core::Network::GameConnection::handleChatPacket( const Packets::GamePacket&
// dont display packet notification if it is a ping or pos update, don't want the spam
g_log.debug( sessionStr + " Handling Chat IPC : " + name + "( " +
boost::str( boost::format( "%|04X|" ) %
static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) + " )" );
boost::str( boost::format( "%|04X|" ) % static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) +
" )" );
( this->*( it->second ) )( pPacket, *m_pSession->getPlayer() );
}
else
{
g_log.debug( sessionStr + " Undefined Chat IPC : Unknown ( " +
boost::str( boost::format( "%|04X|" ) %
static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) + " )" );
boost::str( boost::format( "%|04X|" ) % static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) +
" )" );
g_log.debug( pPacket.toString() );
}
}
@ -250,12 +250,11 @@ void Core::Network::GameConnection::handlePacket( Core::Network::Packets::GamePa
handleChatPacket( *pPacket );
break;
}
}
void Core::Network::GameConnection::sendPackets( Packets::PacketContainer* pPacket )
{
//g_log.Log(LoggingSeverity::info, pPacket->toString());
// g_log.Log(LoggingSeverity::info, pPacket->toString());
std::vector< uint8_t > sendBuffer;
pPacket->fillSendBuffer( sendBuffer );
@ -297,7 +296,6 @@ void Core::Network::GameConnection::processOutQueue()
if( totalSize > 0 )
sendPackets( &pRP );
}
void Core::Network::GameConnection::sendSinglePacket( Packets::GamePacket* pPacket )
@ -314,7 +312,7 @@ void Core::Network::GameConnection::injectPacket( const std::string& packetpath,
memset( packet, 0, 0x11570 );
// get the packet name / path from the command arguments
FILE *fp = nullptr;
FILE* fp = nullptr;
fp = fopen( packetpath.c_str(), "rb" );
if( fp == nullptr )
{
@ -326,7 +324,7 @@ void Core::Network::GameConnection::injectPacket( const std::string& packetpath,
fseek( fp, 0, SEEK_END );
int32_t size = ftell( fp );
rewind( fp );
if ( fread( packet, sizeof( char ), size, fp ) != size )
if( fread( packet, sizeof( char ), size, fp ) != size )
{
g_log.error( "Packet " + packetpath + " did not read full size: " + std::to_string( size ) );
return;
@ -356,7 +354,8 @@ void Core::Network::GameConnection::injectPacket( const std::string& packetpath,
}
}
void Core::Network::GameConnection::handlePackets( const Core::Network::Packets::FFXIVARR_PACKET_HEADER& ipcHeader,
void Core::Network::GameConnection::handlePackets(
const Core::Network::Packets::FFXIVARR_PACKET_HEADER& ipcHeader,
const std::vector< Core::Network::Packets::FFXIVARR_PACKET_RAW >& packetData )
{
// if a session is set, update the last time it recieved a game packet
@ -369,7 +368,7 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
{
case 1:
{
char* id = ( char* ) &( inPacket.data[4] );
char* id = (char*)&( inPacket.data[4] );
uint32_t playerId = boost::lexical_cast< uint32_t >( id );
auto pCon = boost::static_pointer_cast< GameConnection, Connection >( shared_from_this() );
@ -387,10 +386,10 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
}
session = g_serverZone.getSession( playerId );
}
//TODO: Catch more things in lobby and send real errors
// TODO: Catch more things in lobby and send real errors
else if( !session->isValid() || ( session->getPlayer() && session->getPlayer()->getLastPing() != 0 ) )
{
g_log.error( "[" + std::string(id) + "] Session INVALID, disconnecting" );
g_log.error( "[" + std::string( id ) + "] Session INVALID, disconnecting" );
Disconnect();
return;
}
@ -400,7 +399,7 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
m_pSession = session;
GamePacket pPe( 0x00, 0x18, 0, 0, 0x07 );
//pPe.setValAt< uint32_t >( 0x10, 0xE0000005 );
// pPe.setValAt< uint32_t >( 0x10, 0xE0000005 );
pPe.setValAt< uint32_t >( 0x10, 0xE0037603 );
pPe.setValAt< uint32_t >( 0x14, static_cast< uint32_t >( time( nullptr ) ) );
sendSinglePacket( &pPe );
@ -428,7 +427,6 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
}
break;
}
case 3: // game packet
{
@ -438,8 +436,8 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
}
case 7: // keep alive
{
uint32_t id = *( uint32_t* ) &inPacket.data[0];
uint32_t timeStamp = *( uint32_t* ) &inPacket.data[4];
uint32_t id = *(uint32_t*)&inPacket.data[0];
uint32_t timeStamp = *(uint32_t*)&inPacket.data[4];
GamePacket pPe( 0x00, 0x18, 0, 0, 0x08 );
pPe.setValAt< uint32_t >( 0x10, id );
@ -453,6 +451,5 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
break;
}
}
}
}

View file

@ -1,9 +1,9 @@
#ifndef GAMECONNECTION_H
#define GAMECONNECTION_H
#include <Server_Common/Network/Connection.h>
#include <Server_Common/Network/Acceptor.h>
#include <Server_Common/Network/CommonNetwork.h>
#include <Server_Common/Network/Connection.h>
#include <Server_Common/Network/GamePacket.h>
#include <Server_Common/Util/LockedQueue.h>
@ -14,19 +14,19 @@
namespace Core {
namespace Network {
enum ConnectionType : uint8_t
{
enum ConnectionType : uint8_t
{
Zone = 1,
Chat = 2,
Lobby = 3,
None
};
};
class GameConnection : public Connection
{
class GameConnection : public Connection
{
private:
typedef void ( GameConnection::* Handler )( const Packets::GamePacket& inPacket, Entity::Player& player );
private:
typedef void ( GameConnection::*Handler )( const Packets::GamePacket& inPacket, Entity::Player& player );
using HandlerMap = std::map< uint16_t, Handler >;
using HandlerStrMap = std::map< uint16_t, std::string >;
@ -46,7 +46,7 @@ private:
LockedQueue< Packets::GamePacketPtr > m_inQueue;
LockedQueue< Packets::GamePacketPtr > m_outQueue;
public:
public:
ConnectionType m_conType;
GameConnection( HivePtr pHive, AcceptorPtr pAcceptor );
@ -54,13 +54,13 @@ public:
~GameConnection();
// overwrite the parents onConnect for our game socket needs
void OnAccept( const std::string & host, uint16_t port ) override;
void OnAccept( const std::string& host, uint16_t port ) override;
void OnDisconnect() override;
void OnRecv( std::vector< uint8_t > & buffer ) override;
void OnRecv( std::vector< uint8_t >& buffer ) override;
void OnError( const boost::system::error_code & error ) override;
void OnError( const boost::system::error_code& error ) override;
void handlePackets( const Packets::FFXIVARR_PACKET_HEADER& ipcHeader,
const std::vector< Packets::FFXIVARR_PACKET_RAW >& packetData );
@ -107,7 +107,6 @@ public:
DECLARE_HANDLER( cfRegisterRoulette );
DECLARE_HANDLER( cfDutyAccepted );
DECLARE_HANDLER( skillHandler );
DECLARE_HANDLER( gm1Handler );
@ -118,13 +117,9 @@ public:
DECLARE_HANDLER( performNoteHandler );
DECLARE_HANDLER( tellHandler );
};
};
}
}
} // namespace Network
} // namespace Core
#endif

View file

@ -1,39 +1,39 @@
#include <Server_Common/Common.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Network/CommonNetwork.h>
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Network/PacketContainer.h>
#include <boost/format.hpp>
#include "Network/GameConnection.h"
#include "ServerZone.h"
#include "Session.h"
#include "Zone/Zone.h"
#include "Zone/ZonePosition.h"
#include "ServerZone.h"
#include "Zone/ZoneMgr.h"
#include "Zone/ZonePosition.h"
#include "Network/PacketWrappers/InitUIPacket.h"
#include "Network/PacketWrappers/PingPacket.h"
#include "Network/PacketWrappers/MoveActorPacket.h"
#include "Network/PacketWrappers/ChatPacket.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Network/PacketWrappers/EventStartPacket.h"
#include "Network/PacketWrappers/ChatPacket.h"
#include "Network/PacketWrappers/EventFinishPacket.h"
#include "Network/PacketWrappers/EventStartPacket.h"
#include "Network/PacketWrappers/InitUIPacket.h"
#include "Network/PacketWrappers/MoveActorPacket.h"
#include "Network/PacketWrappers/PingPacket.h"
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "DebugCommand/DebugCommandHandler.h"
#include "Actor/Player.h"
#include "Inventory/Inventory.h"
#include "Forwards.h"
#include "Event/EventHelper.h"
#include "Action/Action.h"
#include "Action/ActionTeleport.h"
#include "Actor/Player.h"
#include "DebugCommand/DebugCommandHandler.h"
#include "Event/EventHelper.h"
#include "Forwards.h"
#include "Inventory/Inventory.h"
extern Core::Logger g_log;
extern Core::ServerZone g_serverZone;
@ -45,8 +45,7 @@ using namespace Core::Common;
using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server;
void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& inPacket,
Entity::Player& player )
void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
{
uint16_t commandId = inPacket.getValAt< uint16_t >( 0x20 );
uint64_t param1 = inPacket.getValAt< uint64_t >( 0x24 );
@ -55,21 +54,19 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
uint32_t param2 = inPacket.getValAt< uint32_t >( 0x2C );
uint64_t param3 = inPacket.getValAt< uint64_t >( 0x38 );
g_log.debug( "[" + std::to_string( m_pSession->getId() ) + "] Incoming action: " +
boost::str( boost::format( "%|04X|" ) % ( uint32_t ) ( commandId & 0xFFFF ) ) +
"\nparam1: " + boost::str( boost::format( "%|016X|" ) % ( uint64_t ) ( param1 & 0xFFFFFFFFFFFFFFF ) ) +
"\nparam2: " + boost::str( boost::format( "%|08X|" ) % ( uint32_t ) ( param2 & 0xFFFFFFFF ) ) +
"\nparam3: " + boost::str( boost::format( "%|016X|" ) % ( uint64_t ) ( param3 & 0xFFFFFFFFFFFFFFF ) )
);
g_log.debug( "[" + std::to_string( m_pSession->getId() ) +
"] Incoming action: " + boost::str( boost::format( "%|04X|" ) % ( uint32_t )( commandId & 0xFFFF ) ) +
"\nparam1: " + boost::str( boost::format( "%|016X|" ) % ( uint64_t )( param1 & 0xFFFFFFFFFFFFFFF ) ) +
"\nparam2: " + boost::str( boost::format( "%|08X|" ) % ( uint32_t )( param2 & 0xFFFFFFFF ) ) +
"\nparam3: " + boost::str( boost::format( "%|016X|" ) % ( uint64_t )( param3 & 0xFFFFFFFFFFFFFFF ) ) );
//g_log.Log(LoggingSeverity::debug, "[" + std::to_string(m_pSession->getId()) + "] " + pInPacket->toString());
// g_log.Log(LoggingSeverity::debug, "[" + std::to_string(m_pSession->getId()) + "] " + pInPacket->toString());
switch( commandId )
{
case 0x01: // Toggle sheathe
{
if ( param11 == 1 )
if( param11 == 1 )
player.setStance( Entity::Actor::Stance::Active );
else
{
@ -83,7 +80,7 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
}
case 0x02: // Toggle auto-attack
{
if ( param11 == 1 )
if( param11 == 1 )
{
player.setAutoattack( true );
player.setStance( Entity::Actor::Stance::Active );
@ -148,7 +145,7 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
}
case 0xC8: // return dead
{
switch ( static_cast < ResurrectType >( param1 ) )
switch( static_cast< ResurrectType >( param1 ) )
{
case ResurrectType::RaiseSpell:
// todo: handle raise case (set position to raiser, apply weakness status, set hp/mp/tp as well as packet)
@ -160,7 +157,6 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
default:
break;
}
}
case 0xC9: // Finish zoning
{
@ -182,7 +178,10 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
player.setStatus( Entity::Actor::ActorStatus::Idle );
player.sendToInRangeSet( ActorControlPacket143( player.getId(), ZoneIn, 0x01, 0x01, 0, 111 ), true );
player.sendToInRangeSet( ActorControlPacket142( player.getId(), SetStatus, static_cast< uint8_t >( Entity::Actor::ActorStatus::Idle ) ), true );
player.sendToInRangeSet(
ActorControlPacket142( player.getId(), SetStatus,
static_cast< uint8_t >( Entity::Actor::ActorStatus::Idle ) ),
true );
}
else
player.sendToInRangeSet( ActorControlPacket143( player.getId(), ZoneIn, 0x01, 0x00, 0, 111 ), true );
@ -210,11 +209,14 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
auto fromAetheryte = g_exdData.getAetheryteInfo( g_exdData.m_zoneInfoMap[player.getZoneId()].aetheryte_index );
// calculate cost - does not apply for favorite points or homepoints neither checks for aether tickets
auto cost = static_cast< uint16_t > ( ( sqrt( pow( fromAetheryte->map_coord_x - targetAetheryte->map_coord_x, 2 ) +
pow( fromAetheryte->map_coord_y - targetAetheryte->map_coord_y, 2 ) ) / 2 ) + 100 );
auto cost =
static_cast< uint16_t >( ( sqrt( pow( fromAetheryte->map_coord_x - targetAetheryte->map_coord_x, 2 ) +
pow( fromAetheryte->map_coord_y - targetAetheryte->map_coord_y, 2 ) ) /
2 ) +
100 );
// cap at 999 gil
cost = cost > uint16_t{999} ? uint16_t{999} : cost;
cost = cost > uint16_t{ 999 } ? uint16_t{ 999 } : cost;
bool insufficientGil = player.getCurrency( Inventory::CurrencyType::Gil ) < cost;
// todo: figure out what param1 really does
@ -222,7 +224,8 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
if( !insufficientGil )
{
Action::ActionTeleportPtr pActionTeleport( new Action::ActionTeleport( player.getAsPlayer(), param11, cost ) );
Action::ActionTeleportPtr pActionTeleport(
new Action::ActionTeleport( player.getAsPlayer(), param11, cost ) );
player.setCurrentAction( pActionTeleport );
}
}
@ -235,7 +238,7 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
default:
{
g_log.debug( "[" + std::to_string( m_pSession->getId() ) + "] Unhandled action: " +
boost::str( boost::format( "%|04X|" ) % (uint32_t) ( commandId & 0xFFFF ) ) );
boost::str( boost::format( "%|04X|" ) % ( uint32_t )( commandId & 0xFFFF ) ) );
break;
}
}

View file

@ -1,17 +1,17 @@
#include <Server_Common/Common.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Network/CommonNetwork.h>
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Network/PacketContainer.h>
#include "Actor/Player.h"
#include "Network/GameConnection.h"
#include "Session.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
#include "Actor/Player.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Session.h"
#include "Forwards.h"
@ -21,14 +21,12 @@ using namespace Core::Common;
using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server;
void Core::Network::GameConnection::cfDutyInfoRequest( const Packets::GamePacket& inPacket,
Entity::Player& player )
void Core::Network::GameConnection::cfDutyInfoRequest( const Packets::GamePacket& inPacket, Entity::Player& player )
{
ZoneChannelPacket< FFXIVIpcCFDutyInfo > dutyInfoPacket( player.getId() );
auto penaltyMinutes = player.getCFPenaltyMinutes();
if (penaltyMinutes > 255)
if( penaltyMinutes > 255 )
{
// cap it since it's uint8_t in packets
penaltyMinutes = 255;
@ -39,11 +37,9 @@ void Core::Network::GameConnection::cfDutyInfoRequest( const Packets::GamePacket
ZoneChannelPacket< FFXIVIpcCFPlayerInNeed > inNeedsPacket( player.getId() );
queueOutPacket( inNeedsPacket );
}
void Core::Network::GameConnection::cfRegisterDuty( const Packets::GamePacket& inPacket,
Entity::Player& player)
void Core::Network::GameConnection::cfRegisterDuty( const Packets::GamePacket& inPacket, Entity::Player& player )
{
// TODO use for loop for this
auto contentId1 = inPacket.getValAt< uint16_t >( 46 );
@ -52,12 +48,12 @@ void Core::Network::GameConnection::cfRegisterDuty( const Packets::GamePacket& i
auto contentId4 = inPacket.getValAt< uint16_t >( 52 );
auto contentId5 = inPacket.getValAt< uint16_t >( 54 );
player.sendDebug("Duty register request");
player.sendDebug("ContentId1" + std::to_string(contentId1));
player.sendDebug("ContentId2" + std::to_string(contentId2));
player.sendDebug("ContentId3" + std::to_string(contentId3));
player.sendDebug("ContentId4" + std::to_string(contentId4));
player.sendDebug("ContentId5" + std::to_string(contentId5));
player.sendDebug( "Duty register request" );
player.sendDebug( "ContentId1" + std::to_string( contentId1 ) );
player.sendDebug( "ContentId2" + std::to_string( contentId2 ) );
player.sendDebug( "ContentId3" + std::to_string( contentId3 ) );
player.sendDebug( "ContentId4" + std::to_string( contentId4 ) );
player.sendDebug( "ContentId5" + std::to_string( contentId5 ) );
// let's cancel it because otherwise you can't register it again
ZoneChannelPacket< FFXIVIpcCFNotify > cfCancelPacket( player.getId() );
@ -66,14 +62,12 @@ void Core::Network::GameConnection::cfRegisterDuty( const Packets::GamePacket& i
queueOutPacket( cfCancelPacket );
}
void Core::Network::GameConnection::cfRegisterRoulette( const Packets::GamePacket& inPacket,
Entity::Player& player)
void Core::Network::GameConnection::cfRegisterRoulette( const Packets::GamePacket& inPacket, Entity::Player& player )
{
player.sendDebug("Roulette register");
player.sendDebug( "Roulette register" );
}
void Core::Network::GameConnection::cfDutyAccepted( const Packets::GamePacket& inPacket,
Entity::Player& player)
void Core::Network::GameConnection::cfDutyAccepted( const Packets::GamePacket& inPacket, Entity::Player& player )
{
player.sendDebug("TODO: Duty accept");
player.sendDebug( "TODO: Duty accept" );
}

View file

@ -6,19 +6,19 @@
#include <boost/format.hpp>
#include "Actor/Player.h"
#include "Event/EventHelper.h"
#include "Forwards.h"
#include "Network/GameConnection.h"
#include "Session.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Network/PacketWrappers/EventStartPacket.h"
#include "Network/PacketWrappers/EventFinishPacket.h"
#include "Network/PacketWrappers/EventStartPacket.h"
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Script/ScriptManager.h"
#include "Actor/Player.h"
#include "Forwards.h"
#include "Event/EventHelper.h"
#include "Session.h"
extern Core::Scripting::ScriptManager g_scriptMgr;
@ -26,21 +26,20 @@ using namespace Core::Common;
using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server;
void Core::Network::GameConnection::eventHandler( const Packets::GamePacket& inPacket,
Entity::Player& player )
void Core::Network::GameConnection::eventHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
{
uint16_t eventHandlerId = inPacket.getValAt< uint16_t >( 0x12 );
// we need to abort the event in case it has not been scripted so the player wont be locked up
auto abortEventFunc = []( Core::Entity::Player& player, uint64_t actorId, uint32_t eventId )
{
auto abortEventFunc = []( Core::Entity::Player& player, uint64_t actorId, uint32_t eventId ) {
player.queuePacket( EventStartPacket( player.getId(), actorId, eventId, 1, 0, 0 ) );
player.queuePacket( EventFinishPacket( player.getId(), eventId, 1, 0 ) );
// this isn't ideal as it will also reset any other status that might be active
player.queuePacket( PlayerStateFlagsPacket( player, PlayerStateFlagList{} ) );
};
std::string eventIdStr = boost::str( boost::format( "%|04X|" ) % static_cast< uint32_t >( eventHandlerId & 0xFFFF ) );
std::string eventIdStr =
boost::str( boost::format( "%|04X|" ) % static_cast< uint32_t >( eventHandlerId & 0xFFFF ) );
player.sendDebug( "---------------------------------------" );
player.sendDebug( "EventHandler ( " + eventIdStr + " )" );
@ -70,7 +69,6 @@ void Core::Network::GameConnection::eventHandler( const Packets::GamePacket& inP
break;
}
case ClientZoneIpcType::WithinRangeEventHandler:
{
uint32_t eventId = inPacket.getValAt< uint32_t >( 0x24 );
@ -144,14 +142,8 @@ void Core::Network::GameConnection::eventHandler( const Packets::GamePacket& inP
linkshellEvent.data().unknown1 = 0x15a;
player.queuePacket( linkshellEvent );
// abortEventFunc( pPlayer, 0, eventId );
// abortEventFunc( pPlayer, 0, eventId );
break;
}
}
}

View file

@ -1,39 +1,39 @@
#include <Server_Common/Common.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Network/CommonNetwork.h>
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Network/PacketContainer.h>
#include <boost/format.hpp>
#include "Network/GameConnection.h"
#include "ServerZone.h"
#include "Session.h"
#include "Zone/Zone.h"
#include "Zone/ZonePosition.h"
#include "ServerZone.h"
#include "Zone/ZoneMgr.h"
#include "Zone/ZonePosition.h"
#include "Network/PacketWrappers/InitUIPacket.h"
#include "Network/PacketWrappers/PingPacket.h"
#include "Network/PacketWrappers/MoveActorPacket.h"
#include "Network/PacketWrappers/ChatPacket.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Network/PacketWrappers/EventStartPacket.h"
#include "Network/PacketWrappers/ChatPacket.h"
#include "Network/PacketWrappers/EventFinishPacket.h"
#include "Network/PacketWrappers/EventStartPacket.h"
#include "Network/PacketWrappers/InitUIPacket.h"
#include "Network/PacketWrappers/MoveActorPacket.h"
#include "Network/PacketWrappers/PingPacket.h"
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "DebugCommand/DebugCommandHandler.h"
#include "Actor/Player.h"
#include "Inventory/Inventory.h"
#include "Forwards.h"
#include "Event/EventHelper.h"
#include "Action/Action.h"
#include "Action/ActionTeleport.h"
#include "Actor/Player.h"
#include "DebugCommand/DebugCommandHandler.h"
#include "Event/EventHelper.h"
#include "Forwards.h"
#include "Inventory/Inventory.h"
extern Core::Logger g_log;
extern Core::ServerZone g_serverZone;
@ -102,13 +102,11 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
uint32_t param2 = inPacket.getValAt< uint32_t >( 0x28 );
uint32_t param3 = inPacket.getValAt< uint32_t >( 0x38 );
g_log.debug( player.getName() + " used GM1 commandId: " + std::to_string( commandId ) +
", params: " + std::to_string( param1 ) + ", " +
std::to_string( param2 ) + ", " + std::to_string( param3 ) );
g_log.debug( player.getName() + " used GM1 commandId: " + std::to_string( commandId ) + ", params: " +
std::to_string( param1 ) + ", " + std::to_string( param2 ) + ", " + std::to_string( param3 ) );
Core::Entity::ActorPtr targetActor;
if( player.getId() == param3 )
{
targetActor = player.getAsPlayer();
@ -141,7 +139,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
player.sendNotice( "Race for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
targetPlayer->spawn( targetPlayer );
auto inRange = targetPlayer->getInRangeActors();
for ( auto actor : inRange )
for( auto actor : inRange )
{
targetPlayer->despawn( actor->getAsPlayer() );
targetPlayer->spawn( actor->getAsPlayer() );
@ -154,7 +152,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
player.sendNotice( "Tribe for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
targetPlayer->spawn( targetPlayer );
auto inRange = targetPlayer->getInRangeActors();
for ( auto actor : inRange )
for( auto actor : inRange )
{
targetPlayer->despawn( actor->getAsPlayer() );
targetPlayer->spawn( actor->getAsPlayer() );
@ -167,7 +165,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
player.sendNotice( "Sex for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
targetPlayer->spawn( targetPlayer );
auto inRange = targetActor->getInRangeActors();
for ( auto actor : inRange )
for( auto actor : inRange )
{
targetPlayer->despawn( actor->getAsPlayer() );
targetPlayer->spawn( actor->getAsPlayer() );
@ -189,23 +187,20 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
}
case GmCommand::Call:
{
if ( targetPlayer->getZoneId() != player.getZoneId() )
if( targetPlayer->getZoneId() != player.getZoneId() )
targetPlayer->setZone( player.getZoneId() );
targetPlayer->changePosition( player.getPos().x, player.getPos().y, player.getPos().z,
player.getRotation() );
targetPlayer->changePosition( player.getPos().x, player.getPos().y, player.getPos().z, player.getRotation() );
player.sendNotice( "Calling " + targetPlayer->getName() );
break;
}
case GmCommand::Inspect:
{
player.sendNotice( "Name: " + targetPlayer->getName() +
"\nGil: " + std::to_string( targetPlayer->getCurrency( 1 ) ) +
"\nZone: " + targetPlayer->getCurrentZone()->getName() +
"(" + std::to_string( targetPlayer->getZoneId() ) + ")" +
"\nClass: " + std::to_string( static_cast< uint8_t >( targetPlayer->getClass() ) ) +
"\nLevel: " + std::to_string( targetPlayer->getLevel() ) +
"\nExp: " + std::to_string( targetPlayer->getExp() ) +
player.sendNotice(
"Name: " + targetPlayer->getName() + "\nGil: " + std::to_string( targetPlayer->getCurrency( 1 ) ) +
"\nZone: " + targetPlayer->getCurrentZone()->getName() + "(" + std::to_string( targetPlayer->getZoneId() ) +
")" + "\nClass: " + std::to_string( static_cast< uint8_t >( targetPlayer->getClass() ) ) + "\nLevel: " +
std::to_string( targetPlayer->getLevel() ) + "\nExp: " + std::to_string( targetPlayer->getExp() ) +
"\nSearchMessage: " + targetPlayer->getSearchMessage() +
"\nPlayTime: " + std::to_string( targetPlayer->getPlayTime() ) );
break;
@ -236,8 +231,8 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
strcpy( searchInfoPacket.data().searchMessage, targetPlayer->getSearchMessage() );
targetPlayer->queuePacket( searchInfoPacket );
targetPlayer->sendToInRangeSet( ActorControlPacket142( player.getId(), SetStatusIcon,
static_cast< uint8_t >( player.getOnlineStatus() ) ),
targetPlayer->sendToInRangeSet(
ActorControlPacket142( player.getId(), SetStatusIcon, static_cast< uint8_t >( player.getOnlineStatus() ) ),
true );
player.sendNotice( "Icon for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
break;
@ -268,26 +263,24 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
}
case GmCommand::Inv:
{
if ( targetActor->getInvincibilityType() == Common::InvincibilityType::InvincibilityRefill )
if( targetActor->getInvincibilityType() == Common::InvincibilityType::InvincibilityRefill )
targetActor->setInvincibilityType( Common::InvincibilityType::InvincibilityNone );
else
targetActor->setInvincibilityType( Common::InvincibilityType::InvincibilityRefill );
player.sendNotice( "Invincibility for " + targetPlayer->getName() +
" was switched." );
player.sendNotice( "Invincibility for " + targetPlayer->getName() + " was switched." );
break;
}
case GmCommand::Orchestrion:
{
if ( param1 == 1 )
if( param1 == 1 )
{
if ( param2 == 0 )
if( param2 == 0 )
{
for ( uint8_t i = 0; i < 255; i++ )
for( uint8_t i = 0; i < 255; i++ )
targetActor->getAsPlayer()->learnSong( i, 0 );
player.sendNotice( "All Songs for " + targetPlayer->getName() +
" were turned on." );
player.sendNotice( "All Songs for " + targetPlayer->getName() + " were turned on." );
}
else
{
@ -326,16 +319,15 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
{
uint32_t gil = targetPlayer->getCurrency( 1 );
if ( gil < param1 )
if( gil < param1 )
{
player.sendUrgent( "Player does not have enough Gil(" + std::to_string( gil ) + ")" );
}
else
{
targetPlayer->removeCurrency( 1, param1 );
player.sendNotice( "Removed " + std::to_string( param1 ) +
" Gil from " + targetPlayer->getName() +
"(" + std::to_string( gil ) + " before)" );
player.sendNotice( "Removed " + std::to_string( param1 ) + " Gil from " + targetPlayer->getName() + "(" +
std::to_string( gil ) + " before)" );
}
break;
}
@ -367,29 +359,28 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
case GmCommand::GC:
{
targetPlayer->setGc( param1 );
player.sendNotice( "GC for " + targetPlayer->getName() +
" was set to " + std::to_string( targetPlayer->getGc() ) );
player.sendNotice( "GC for " + targetPlayer->getName() + " was set to " +
std::to_string( targetPlayer->getGc() ) );
break;
}
case GmCommand::GCRank:
{
targetPlayer->setGcRankAt( targetPlayer->getGc() - 1, param1 );
player.sendNotice( "GC Rank for " + targetPlayer->getName() +
" for GC " + std::to_string( targetPlayer->getGc() ) +
" was set to " + std::to_string( targetPlayer->getGcRankArray()[targetPlayer->getGc() - 1] ) );
player.sendNotice( "GC Rank for " + targetPlayer->getName() + " for GC " +
std::to_string( targetPlayer->getGc() ) + " was set to " +
std::to_string( targetPlayer->getGcRankArray()[targetPlayer->getGc() - 1] ) );
break;
}
case GmCommand::Aetheryte:
{
if ( param1 == 0 )
if( param1 == 0 )
{
if ( param2 == 0 )
if( param2 == 0 )
{
for ( uint8_t i = 0; i < 255; i++ )
for( uint8_t i = 0; i < 255; i++ )
targetActor->getAsPlayer()->registerAetheryte( i );
player.sendNotice( "All Aetherytes for " + targetPlayer->getName() +
" were turned on." );
player.sendNotice( "All Aetherytes for " + targetPlayer->getName() + " were turned on." );
}
else
{
@ -404,7 +395,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
case GmCommand::Teri:
{
auto zoneInfo = g_zoneMgr.getZone( param1 );
if ( !zoneInfo )
if( !zoneInfo )
{
player.sendUrgent( "Invalid zone " + std::to_string( param1 ) );
}
@ -412,16 +403,17 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
{
targetPlayer->setPosition( targetPlayer->getPos() );
targetPlayer->performZoning( param1, targetPlayer->getPos(), 0 );
player.sendNotice( targetPlayer->getName() + " was warped to zone " + std::to_string( param1 ) + " (" + zoneInfo->getName( ) + ")" );
player.sendNotice( targetPlayer->getName() + " was warped to zone " + std::to_string( param1 ) + " (" +
zoneInfo->getName() + ")" );
}
break;
}
case GmCommand::TeriInfo:
{
player.sendNotice( "ZoneId: " + std::to_string( player.getZoneId() ) + "\nName: " +
player.getCurrentZone()->getName() + "\nInternalName: " +
player.getCurrentZone()->getInternalName() + "\nPopCount: " +
std::to_string( player.getCurrentZone()->getPopCount() ) +
player.sendNotice( "ZoneId: " + std::to_string( player.getZoneId() ) +
"\nName: " + player.getCurrentZone()->getName() +
"\nInternalName: " + player.getCurrentZone()->getInternalName() +
"\nPopCount: " + std::to_string( player.getCurrentZone()->getPopCount() ) +
"\nCurrentWeather:" + std::to_string( player.getCurrentZone()->getCurrentWeather() ) +
"\nNextWeather:" + std::to_string( player.getCurrentZone()->getNextWeather() ) );
break;
@ -443,7 +435,6 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
player.sendUrgent( "GM1 Command not implemented: " + std::to_string( commandId ) );
break;
}
}
void Core::Network::GameConnection::gm2Handler( const Packets::GamePacket& inPacket, Entity::Player& player )
@ -490,8 +481,10 @@ void Core::Network::GameConnection::gm2Handler( const Packets::GamePacket& inPac
targetPlayer->setStatus( Entity::Actor::ActorStatus::Idle );
targetPlayer->sendToInRangeSet( ActorControlPacket143( player.getId(), ZoneIn, 0x01, 0x01, 0, 113 ), true );
targetPlayer->sendToInRangeSet( ActorControlPacket142( player.getId(), SetStatus,
static_cast< uint8_t >( Entity::Actor::ActorStatus::Idle ) ), true );
targetPlayer->sendToInRangeSet(
ActorControlPacket142( player.getId(), SetStatus,
static_cast< uint8_t >( Entity::Actor::ActorStatus::Idle ) ),
true );
player.sendNotice( "Raised " + targetPlayer->getName() );
break;
}
@ -510,5 +503,4 @@ void Core::Network::GameConnection::gm2Handler( const Packets::GamePacket& inPac
player.sendUrgent( "GM2 Command not implemented: " + std::to_string( commandId ) );
break;
}
}

View file

@ -1,29 +1,29 @@
#include <Server_Common/Common.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Network/CommonNetwork.h>
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Network/PacketContainer.h>
#include <boost/format.hpp>
#include "Network/GameConnection.h"
#include "ServerZone.h"
#include "Session.h"
#include "Zone/Zone.h"
#include "Zone/ZonePosition.h"
#include "ServerZone.h"
#include "Zone/ZoneMgr.h"
#include "Zone/ZonePosition.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "DebugCommand/DebugCommandHandler.h"
#include "Actor/Player.h"
#include "Inventory/Inventory.h"
#include "DebugCommand/DebugCommandHandler.h"
#include "Forwards.h"
#include "Inventory/Inventory.h"
extern Core::Logger g_log;
extern Core::ServerZone g_serverZone;
@ -35,7 +35,6 @@ using namespace Core::Common;
using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server;
void Core::Network::GameConnection::inventoryModifyHandler( const Packets::GamePacket& inPacket,
Entity::Player& player )
{
@ -51,7 +50,6 @@ void Core::Network::GameConnection::inventoryModifyHandler( const Packets::GameP
ackPacket.data().type = 7;
player.queuePacket( ackPacket );
g_log.debug( inPacket.toString() );
g_log.debug( "InventoryAction: " + std::to_string( action ) );
@ -79,19 +77,15 @@ void Core::Network::GameConnection::inventoryModifyHandler( const Packets::GameP
case 0x0C: // merge stack action
{
}
break;
case 0x0A: // split stack action
{
}
break;
default:
break;
}
}

View file

@ -1,42 +1,41 @@
#include <Server_Common/Common.h>
#include <Server_Common/Database/DatabaseDef.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Network/CommonNetwork.h>
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Network/PacketContainer.h>
#include <Server_Common/Network/PacketDef/Chat/ServerChatDef.h>
#include <Server_Common/Database/DatabaseDef.h>
#include <boost/format.hpp>
#include "Network/GameConnection.h"
#include "ServerZone.h"
#include "Session.h"
#include "Zone/Zone.h"
#include "Zone/ZonePosition.h"
#include "ServerZone.h"
#include "Zone/ZoneMgr.h"
#include "Zone/ZonePosition.h"
#include "Network/PacketWrappers/InitUIPacket.h"
#include "Network/PacketWrappers/PingPacket.h"
#include "Network/PacketWrappers/MoveActorPacket.h"
#include "Network/PacketWrappers/ChatPacket.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Network/PacketWrappers/EventStartPacket.h"
#include "Network/PacketWrappers/ChatPacket.h"
#include "Network/PacketWrappers/EventFinishPacket.h"
#include "Network/PacketWrappers/EventStartPacket.h"
#include "Network/PacketWrappers/InitUIPacket.h"
#include "Network/PacketWrappers/MoveActorPacket.h"
#include "Network/PacketWrappers/PingPacket.h"
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "DebugCommand/DebugCommandHandler.h"
#include "Actor/Player.h"
#include "Inventory/Inventory.h"
#include "Forwards.h"
#include "Event/EventHelper.h"
#include "Action/Action.h"
#include "Action/ActionTeleport.h"
#include "Actor/Player.h"
#include "DebugCommand/DebugCommandHandler.h"
#include "Event/EventHelper.h"
#include "Forwards.h"
#include "Inventory/Inventory.h"
extern Core::Logger g_log;
extern Core::ServerZone g_serverZone;
@ -48,16 +47,14 @@ using namespace Core::Common;
using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server;
void Core::Network::GameConnection::fcInfoReqHandler( const Packets::GamePacket& inPacket,
Entity::Player& player )
void Core::Network::GameConnection::fcInfoReqHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
{
GamePacketPtr pPe( new GamePacket( 0xDD, 0x78, player.getId(), player.getId() ) );
pPe->setValAt< uint8_t >( 0x48, 0x01 );
queueOutPacket( pPe );
}
void Core::Network::GameConnection::setSearchInfoHandler( const Packets::GamePacket& inPacket,
Entity::Player& player )
void Core::Network::GameConnection::setSearchInfoHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
{
uint32_t inval = inPacket.getValAt< uint32_t >( 0x20 );
uint32_t inval1 = inPacket.getValAt< uint32_t >( 0x24 );
@ -86,12 +83,12 @@ void Core::Network::GameConnection::setSearchInfoHandler( const Packets::GamePac
strcpy( searchInfoPacket.data().searchMessage, player.getSearchMessage() );
queueOutPacket( searchInfoPacket );
player.sendToInRangeSet( ActorControlPacket142( player.getId(), SetStatusIcon,
static_cast< uint8_t >( player.getOnlineStatus() ) ), true );
player.sendToInRangeSet(
ActorControlPacket142( player.getId(), SetStatusIcon, static_cast< uint8_t >( player.getOnlineStatus() ) ),
true );
}
void Core::Network::GameConnection::reqSearchInfoHandler( const Packets::GamePacket& inPacket,
Entity::Player& player )
void Core::Network::GameConnection::reqSearchInfoHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
{
ZoneChannelPacket< FFXIVIpcInitSearchInfo > searchInfoPacket( player.getId() );
searchInfoPacket.data().onlineStatusFlags = player.getOnlineStatusMask();
@ -100,15 +97,13 @@ void Core::Network::GameConnection::reqSearchInfoHandler( const Packets::GamePac
queueOutPacket( searchInfoPacket );
}
void Core::Network::GameConnection::linkshellListHandler( const Packets::GamePacket& inPacket,
Entity::Player& player )
void Core::Network::GameConnection::linkshellListHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
{
ZoneChannelPacket< FFXIVIpcLinkshellList > linkshellListPacket( player.getId() );
queueOutPacket( linkshellListPacket );
}
void Core::Network::GameConnection::updatePositionHandler( const Packets::GamePacket& inPacket,
Entity::Player& player )
void Core::Network::GameConnection::updatePositionHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
{
// if the player is marked for zoning we no longer want to update his pos
if( player.isMarkedForZoning() )
@ -142,13 +137,13 @@ void Core::Network::GameConnection::updatePositionHandler( const Packets::GamePa
uint16_t bit16 : 1;
} IPC_OP_019AB;
uint16_t flags = inPacket.getValAt<uint16_t>( 0x28 );
uint16_t flags = inPacket.getValAt< uint16_t >( 0x28 );
memcpy( &IPC_OP_019AB, &flags, 2 );
uint32_t flags1 = inPacket.getValAt<uint32_t>( 0x24 );
uint32_t flags1 = inPacket.getValAt< uint32_t >( 0x24 );
memcpy( &IPC_OP_019A, &flags1, 4 );
//g_log.Log(LoggingSeverity::debug, "" + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit1)
// g_log.Log(LoggingSeverity::debug, "" + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit1)
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit2)
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit3)
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit4)
@ -166,14 +161,14 @@ void Core::Network::GameConnection::updatePositionHandler( const Packets::GamePa
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit16)
// + " " + boost::lexical_cast<std::string>((int)flags));
//g_log.Log(LoggingSeverity::debug, "\n" + boost::lexical_cast<std::string>((int)IPC_OP_019A.specialMovement) + "\n"
// g_log.Log(LoggingSeverity::debug, "\n" + boost::lexical_cast<std::string>((int)IPC_OP_019A.specialMovement) + "\n"
// + boost::lexical_cast<std::string>((int)IPC_OP_019A.strafe) + "\n"
// + boost::lexical_cast<std::string>((int)IPC_OP_019A.moveBackward) + "\n"
// + boost::lexical_cast<std::string>((int)IPC_OP_019A.strafeRight));
//g_log.Log(LoggingSeverity::debug, pInPacket->toString());
// g_log.Log(LoggingSeverity::debug, pInPacket->toString());
//pInPacket->debugPrint();
// pInPacket->debugPrint();
bool bPosChanged = false;
if( ( player.getPos().x != inPacket.getValAt< float >( 0x2c ) ) ||
@ -184,8 +179,7 @@ void Core::Network::GameConnection::updatePositionHandler( const Packets::GamePa
return;
player.setRotation( inPacket.getValAt< float >( 0x20 ) );
player.setPosition( inPacket.getValAt< float >( 0x2c ),
inPacket.getValAt< float >( 0x30 ),
player.setPosition( inPacket.getValAt< float >( 0x2c ), inPacket.getValAt< float >( 0x30 ),
inPacket.getValAt< float >( 0x34 ) );
if( ( player.getCurrentAction() != nullptr ) && bPosChanged )
@ -278,18 +272,17 @@ void Core::Network::GameConnection::updatePositionHandler( const Packets::GamePa
MoveActorPacket movePacket( player, unk1, unk2, unk3, unk4 );
player.sendToInRangeSet( movePacket );
}
void Core::Network::GameConnection::reqEquipDisplayFlagsHandler( const Packets::GamePacket& inPacket,
Entity::Player& player )
{
g_log.info( "[" + std::to_string( player.getId() ) + "] Setting EquipDisplayFlags to " + std::to_string( inPacket.getValAt< uint8_t >( 0x20 ) ) );
g_log.info( "[" + std::to_string( player.getId() ) + "] Setting EquipDisplayFlags to " +
std::to_string( inPacket.getValAt< uint8_t >( 0x20 ) ) );
player.setEquipDisplayFlags( inPacket.getValAt< uint8_t >( 0x20 ) );
}
void Core::Network::GameConnection::zoneLineHandler( const Packets::GamePacket& inPacket,
Entity::Player& player )
void Core::Network::GameConnection::zoneLineHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
{
uint32_t zoneLineId = inPacket.getValAt< uint32_t >( 0x20 );
@ -313,7 +306,7 @@ void Core::Network::GameConnection::zoneLineHandler( const Packets::GamePacket&
ZoneChannelPacket< FFXIVIpcPrepareZoning > preparePacket( player.getId() );
preparePacket.data().targetZone = targetZone;
//ActorControlPacket143 controlPacket( pPlayer, ActorControlType::DespawnZoneScreenMsg,
// ActorControlPacket143 controlPacket( pPlayer, ActorControlType::DespawnZoneScreenMsg,
// 0x03, player.getId(), 0x01, targetZone );
player.queuePacket( preparePacket );
}
@ -327,18 +320,17 @@ void Core::Network::GameConnection::zoneLineHandler( const Packets::GamePacket&
targetZone = pZone->getId();
}
player.performZoning( targetZone, targetPos, rotation);
player.performZoning( targetZone, targetPos, rotation );
}
void Core::Network::GameConnection::discoveryHandler( const Packets::GamePacket& inPacket,
Entity::Player& player )
void Core::Network::GameConnection::discoveryHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
{
uint32_t ref_position_id = inPacket.getValAt< uint32_t >( 0x20 );
auto pQR = g_charaDb.query( "SELECT id, map_id, discover_id "
"FROM discoveryinfo "
"WHERE id = " + std::to_string( ref_position_id ) + ";" );
"WHERE id = " +
std::to_string( ref_position_id ) + ";" );
if( !pQR->next() )
{
@ -354,21 +346,16 @@ void Core::Network::GameConnection::discoveryHandler( const Packets::GamePacket&
player.sendNotice( "Discovery ref pos ID: " + std::to_string( ref_position_id ) );
player.discover( pQR->getUInt16( 2 ), pQR->getUInt16( 3 ) );
}
void Core::Network::GameConnection::playTimeHandler( const Packets::GamePacket& inPacket,
Entity::Player& player )
void Core::Network::GameConnection::playTimeHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
{
ZoneChannelPacket< FFXIVIpcPlayTime > playTimePacket( player.getId() );
playTimePacket.data().playTimeInMinutes = player.getPlayTime() / 60;
player.queuePacket( playTimePacket );
}
void Core::Network::GameConnection::initHandler( const Packets::GamePacket& inPacket,
Entity::Player& player )
void Core::Network::GameConnection::initHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
{
// init handler means this is a login procedure
player.setIsLogin( true );
@ -376,24 +363,19 @@ void Core::Network::GameConnection::initHandler( const Packets::GamePacket& inPa
player.setZone( player.getZoneId() );
}
void Core::Network::GameConnection::blackListHandler( const Packets::GamePacket& inPacket,
Entity::Player& player )
void Core::Network::GameConnection::blackListHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
{
uint8_t count = inPacket.getValAt< uint8_t >( 0x21 );
ZoneChannelPacket< FFXIVIpcBlackList > blackListPacket( player.getId() );
blackListPacket.data().sequence = count;
// TODO: Fill with actual blacklist data
//blackListPacket.data().entry[0].contentId = 1;
//sprintf( blackListPacket.data().entry[0].name, "Test Test" );
// blackListPacket.data().entry[0].contentId = 1;
// sprintf( blackListPacket.data().entry[0].name, "Test Test" );
queueOutPacket( blackListPacket );
}
void Core::Network::GameConnection::pingHandler( const Packets::GamePacket& inPacket,
Entity::Player& player )
void Core::Network::GameConnection::pingHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
{
int32_t inVal = inPacket.getValAt< int32_t >( 0x20 );
PingPacket pingPacket( player, inVal );
@ -402,9 +384,7 @@ void Core::Network::GameConnection::pingHandler( const Packets::GamePacket& inPa
player.setLastPing( static_cast< uint32_t >( time( nullptr ) ) );
}
void Core::Network::GameConnection::finishLoadingHandler( const Packets::GamePacket& inPacket,
Entity::Player& player )
void Core::Network::GameConnection::finishLoadingHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
{
// player is done zoning
player.setLoadingComplete( true );
@ -424,8 +404,7 @@ void Core::Network::GameConnection::finishLoadingHandler( const Packets::GamePac
player.getCurrentZone()->changeActorPosition( player.getAsPlayer() );
}
void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket& inPacket,
Entity::Player& player )
void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
{
uint8_t type = inPacket.getValAt< uint8_t >( 0x2A );
@ -453,18 +432,17 @@ void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket
listPacket.data().entries[0].zoneId = player.getCurrentZone()->getId();
listPacket.data().entries[0].zoneId1 = 0x0100;
// TODO: no idea what this does
//listPacket.data().entries[0].one = 1;
// listPacket.data().entries[0].one = 1;
memcpy( listPacket.data().entries[0].name, player.getName().c_str(), strlen( player.getName().c_str() ) );
// TODO: actually store and read language from somewhere
listPacket.data().entries[0].bytes1[0] = 0x01;//flags (lang)
listPacket.data().entries[0].bytes1[0] = 0x01; // flags (lang)
// TODO: these flags need to be figured out
//listPacket.data().entries[0].bytes1[1] = 0x00;//flags
// listPacket.data().entries[0].bytes1[1] = 0x00;//flags
listPacket.data().entries[0].onlineStatusMask = player.getOnlineStatusMask();
queueOutPacket( listPacket );
}
else if( type == 0x0b )
{ // friend list
@ -473,17 +451,14 @@ void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket
listPacket.data().type = 0x0B;
listPacket.data().sequence = count;
memset( listPacket.data().entries, 0, sizeof( listPacket.data().entries ) );
}
else if( type == 0x0e )
{ // player search result
// TODO: implement player search
}
}
void Core::Network::GameConnection::chatHandler( const Packets::GamePacket& inPacket,
Entity::Player& player )
void Core::Network::GameConnection::chatHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
{
std::string chatString( inPacket.getStringAt( 0x3a ) );
@ -493,13 +468,13 @@ void Core::Network::GameConnection::chatHandler( const Packets::GamePacket& inPa
if( chatString.at( 0 ) == '!' )
{
// execute game console command
g_gameCommandMgr.execCommand( const_cast< char * >( chatString.c_str() ) + 1, player );
g_gameCommandMgr.execCommand( const_cast< char* >( chatString.c_str() ) + 1, player );
return;
}
ChatType chatType = static_cast< ChatType >( inPacket.getValAt< uint8_t >( 0x38 ) );
//ToDo, need to implement sending GM chat types.
// ToDo, need to implement sending GM chat types.
ChatPacket chatPacket( player, chatType, chatString );
switch( chatType )
@ -525,15 +500,13 @@ void Core::Network::GameConnection::chatHandler( const Packets::GamePacket& inPa
break;
}
}
}
// TODO: this handler needs to be improved for timed logout, also the session should be instantly removed
// currently we wait for the session to just time out after logout, this can be a problem is the user tries to
// log right back in.
// Also the packet needs to be converted to an ipc structure
void Core::Network::GameConnection::logoutHandler( const Packets::GamePacket& inPacket,
Entity::Player& player )
void Core::Network::GameConnection::logoutHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
{
ZoneChannelPacket< FFXIVIpcLogout > logoutPacket( player.getId() );
logoutPacket.data().flags1 = 0x02;
@ -543,9 +516,7 @@ void Core::Network::GameConnection::logoutHandler( const Packets::GamePacket& in
player.setMarkedForRemoval();
}
void Core::Network::GameConnection::tellHandler( const Packets::GamePacket& inPacket,
Entity::Player& player )
void Core::Network::GameConnection::tellHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
{
std::string targetPcName = inPacket.getStringAt( 0x21 );
std::string msg = inPacket.getStringAt( 0x41 );
@ -591,15 +562,13 @@ void Core::Network::GameConnection::tellHandler( const Packets::GamePacket& inPa
strcpy( tellPacket.data().msg, msg.c_str() );
strcpy( tellPacket.data().receipientName, player.getName().c_str() );
// TODO: do these have a meaning?
//tellPacket.data().u1 = 0x92CD7337;
//tellPacket.data().u2a = 0x2E;
//tellPacket.data().u2b = 0x40;
// tellPacket.data().u1 = 0x92CD7337;
// tellPacket.data().u2a = 0x2E;
// tellPacket.data().u2b = 0x40;
pTargetPlayer->queueChatPacket( tellPacket );
}
void Core::Network::GameConnection::performNoteHandler( const Packets::GamePacket& inPacket,
Entity::Player& player )
void Core::Network::GameConnection::performNoteHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
{
GamePacketNew< FFXIVIpcPerformNote, ServerZoneIpcType > performPacket( player.getId() );

View file

@ -1,9 +1,9 @@
#include <Server_Common/Common.h>
#include <Server_Common/Network/CommonNetwork.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Network/CommonNetwork.h>
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Network/PacketContainer.h>
#include <Server_Common/Logging/Logger.h>
#include <boost/format.hpp>
@ -11,11 +11,11 @@
#include "Session.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Network/PacketWrappers/MoveActorPacket.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
@ -30,7 +30,6 @@
#include "Action/ActionMount.h"
#include "Script/ScriptManager.h"
extern Core::Scripting::ScriptManager g_scriptMgr;
extern Core::Data::ExdData g_exdData;
extern Core::Logger g_log;
@ -39,8 +38,7 @@ using namespace Core::Common;
using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server;
void Core::Network::GameConnection::skillHandler( const Packets::GamePacket& inPacket,
Entity::Player& player )
void Core::Network::GameConnection::skillHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
{
uint8_t type = inPacket.getValAt< uint32_t >( 0x21 );
@ -59,9 +57,8 @@ void Core::Network::GameConnection::skillHandler( const Packets::GamePacket& inP
{
std::string actionIdStr = boost::str( boost::format( "%|04X|" ) % action );
player.sendDebug( "---------------------------------------" );
player.sendDebug( "ActionHandler ( " + actionIdStr + " | " +
g_exdData.getActionInfo( action )->name +
" | " + std::to_string( targetId ) + " )" );
player.sendDebug( "ActionHandler ( " + actionIdStr + " | " + g_exdData.getActionInfo( action )->name + " | " +
std::to_string( targetId ) + " )" );
player.queuePacket( ActorControlPacket142( player.getId(), ActorControlType::ActionStart, 0x01, action ) );
@ -96,7 +93,6 @@ void Core::Network::GameConnection::skillHandler( const Packets::GamePacket& inP
}
else if( action < 2000000 ) // craft action
{
}
else if( action < 3000000 ) // item action
{
@ -109,7 +105,6 @@ void Core::Network::GameConnection::skillHandler( const Packets::GamePacket& inP
}
else if( action > 3000000 ) // unknown
{
}
break;
@ -124,7 +119,5 @@ void Core::Network::GameConnection::skillHandler( const Packets::GamePacket& inP
player.getCurrentAction()->onStart();
break;
}
}

View file

@ -1,35 +1,29 @@
#ifndef _ACTORCONTROL142_H
#define _ACTORCONTROL142_H
#include "Forwards.h"
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include "Forwards.h"
namespace Core {
namespace Network {
namespace Packets {
namespace Server {
namespace Packets {
namespace Server {
/**
* @brief The Ping response packet.
*/
class ActorControlPacket142 :
public ZoneChannelPacket< FFXIVIpcActorControl142 >
{
public:
ActorControlPacket142( uint32_t actorId,
uint16_t category,
uint32_t param1 = 0,
uint32_t param2 = 0,
uint32_t param3 = 0,
uint32_t param4 = 0,
uint32_t padding1 = 0 ) :
/**
* @brief The Ping response packet.
*/
class ActorControlPacket142 : public ZoneChannelPacket< FFXIVIpcActorControl142 >
{
public:
ActorControlPacket142( uint32_t actorId, uint16_t category, uint32_t param1 = 0, uint32_t param2 = 0,
uint32_t param3 = 0, uint32_t param4 = 0, uint32_t padding1 = 0 ) :
ZoneChannelPacket< FFXIVIpcActorControl142 >( actorId, actorId )
{
initialize( category, param1, param2, param3, param4 );
};
private:
private:
void initialize( uint16_t category, uint32_t param1, uint32_t param2, uint32_t param3, uint32_t param4 )
{
m_data.padding = 0;
@ -39,11 +33,11 @@ private:
m_data.param3 = param3;
m_data.param4 = param4;
};
};
};
}
}
}
}
} // namespace Server
} // namespace Packets
} // namespace Network
} // namespace Core
#endif /*_ACTORCONTROL142_H*/

View file

@ -1,38 +1,32 @@
#ifndef _ACTORCONTROL143_H
#define _ACTORCONTROL143_H
#include "Forwards.h"
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include "Forwards.h"
namespace Core {
namespace Network {
namespace Packets {
namespace Server {
namespace Packets {
namespace Server {
/**
* @brief The Ping response packet.
*/
class ActorControlPacket143 :
public ZoneChannelPacket< FFXIVIpcActorControl143 >
{
public:
ActorControlPacket143( uint32_t actorId,
uint16_t category,
uint32_t param1 = 0,
uint32_t param2 = 0,
uint32_t param3 = 0,
uint32_t param4 = 0,
uint32_t param5 = 0,
/**
* @brief The Ping response packet.
*/
class ActorControlPacket143 : public ZoneChannelPacket< FFXIVIpcActorControl143 >
{
public:
ActorControlPacket143( uint32_t actorId, 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 padding1 = 0 ) :
ZoneChannelPacket< FFXIVIpcActorControl143 >( actorId, actorId )
{
initialize( category, param1, param2, param3, param4, param5 );
};
private:
void initialize( uint16_t category, uint32_t param1, uint32_t param2, uint32_t param3, uint32_t param4, uint32_t param5 )
private:
void initialize( uint16_t category, uint32_t param1, uint32_t param2, uint32_t param3, uint32_t param4,
uint32_t param5 )
{
m_data.padding = 0;
m_data.category = category;
@ -42,11 +36,11 @@ private:
m_data.param4 = param4;
m_data.param5 = param5;
};
};
};
}
}
}
}
} // namespace Server
} // namespace Packets
} // namespace Network
} // namespace Core
#endif /*_ACTORCONTROL143_H*/

View file

@ -6,31 +6,26 @@
namespace Core {
namespace Network {
namespace Packets {
namespace Server {
namespace Packets {
namespace Server {
/**
* @brief The Ping response packet.
*/
class ActorControlPacket144 :
public ZoneChannelPacket< FFXIVIpcActorControl144 >
{
public:
ActorControlPacket144( uint32_t actorId,
uint16_t category,
uint32_t param1 = 0,
uint32_t param2 = 0,
uint32_t param3 = 0,
uint32_t param4 = 0,
uint64_t targetId = 0,
/**
* @brief The Ping response packet.
*/
class ActorControlPacket144 : public ZoneChannelPacket< FFXIVIpcActorControl144 >
{
public:
ActorControlPacket144( uint32_t actorId, uint16_t category, uint32_t param1 = 0, uint32_t param2 = 0,
uint32_t param3 = 0, uint32_t param4 = 0, uint64_t targetId = 0,
uint32_t padding1 = 0 ) :
ZoneChannelPacket< FFXIVIpcActorControl144 >( actorId, actorId )
{
initialize( category, param1, param2, param3, param4, targetId );
};
private:
void initialize( uint16_t category, uint32_t param1, uint32_t param2, uint32_t param3, uint32_t param4, uint64_t targetId )
private:
void initialize( uint16_t category, uint32_t param1, uint32_t param2, uint32_t param3, uint32_t param4,
uint64_t targetId )
{
m_data.padding = 0;
m_data.category = category;
@ -40,11 +35,11 @@ private:
m_data.param4 = param4;
m_data.targetId = targetId;
};
};
};
}
}
}
}
} // namespace Server
} // namespace Packets
} // namespace Network
} // namespace Core
#endif /*_ACTORCONTROL144_H*/

View file

@ -1,30 +1,29 @@
#ifndef _ACTORSPAWN_H
#define _ACTORSPAWN_H
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Util/UtilMath.h>
#include "Actor/Player.h"
#include "Forwards.h"
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Util/UtilMath.h>
namespace Core {
namespace Network {
namespace Packets {
namespace Server {
namespace Packets {
namespace Server {
/**
* @brief The packet sent to spawn an actor.
*/
class ActorSpawnPacket :
public GamePacketNew< FFXIVIpcActorSpawn, ServerZoneIpcType >
{
public:
/**
* @brief The packet sent to spawn an actor.
*/
class ActorSpawnPacket : public GamePacketNew< FFXIVIpcActorSpawn, ServerZoneIpcType >
{
public:
ActorSpawnPacket( Entity::PlayerPtr pPlayer, Entity::PlayerPtr pTarget ) :
GamePacketNew< FFXIVIpcActorSpawn, ServerZoneIpcType >( pPlayer->getId(), pTarget->getId() )
{
initialize( pPlayer, pTarget );
};
private:
private:
void initialize( Entity::PlayerPtr pPlayer, Entity::PlayerPtr pTarget )
{
// TODO: temporary gm rank
@ -75,17 +74,15 @@ private:
m_data.targetId = pPlayer->getTargetId();
m_data.type = 1;
m_data.unknown_33 = 4;
//m_data.unknown_38 = 0x70;
//m_data.unknown_60 = 3;
//m_data.unknown_61 = 7;
// m_data.unknown_38 = 0x70;
// m_data.unknown_60 = 3;
// m_data.unknown_61 = 7;
};
};
};
}
}
}
}
} // namespace Server
} // namespace Packets
} // namespace Network
} // namespace Core
#endif /*_ACTORSPAWN_H*/

View file

@ -1,41 +1,39 @@
#ifndef _CHATPACKET_H
#define _CHATPACKET_H
#include "Forwards.h"
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include "Forwards.h"
namespace Core {
namespace Network {
namespace Packets {
namespace Server {
namespace Packets {
namespace Server {
/**
* @brief The Chat packet.
*/
class ChatPacket :
public ZoneChannelPacket< FFXIVIpcChat >
{
public:
/**
* @brief The Chat packet.
*/
class ChatPacket : public ZoneChannelPacket< FFXIVIpcChat >
{
public:
ChatPacket( Entity::Player& player, Common::ChatType chatType, const std::string& msg ) :
ZoneChannelPacket< FFXIVIpcChat >( player.getId(), player.getId() )
{
initialize( player, chatType, msg );
};
private:
private:
void initialize( Entity::Player& player, Common::ChatType chatType, const std::string& msg )
{
m_data.chatType = chatType;
strcpy( m_data.name, player.getName().c_str() );
strcpy( m_data.msg, msg.c_str() );
};
};
};
}
}
}
}
} // namespace Server
} // namespace Packets
} // namespace Network
} // namespace Core
#endif /*_CHATPACKET_H*/

View file

@ -5,40 +5,34 @@
namespace Core {
namespace Network {
namespace Packets {
namespace Server {
namespace Packets {
namespace Server {
/**
* @brief The packet sent to finish an event.
*/
class EventFinishPacket : public ZoneChannelPacket< FFXIVIpcEventFinish >
{
public:
EventFinishPacket( uint32_t playerId,
uint32_t eventId,
uint8_t param1,
uint32_t param3 ) :
/**
* @brief The packet sent to finish an event.
*/
class EventFinishPacket : public ZoneChannelPacket< FFXIVIpcEventFinish >
{
public:
EventFinishPacket( uint32_t playerId, uint32_t eventId, uint8_t param1, uint32_t param3 ) :
ZoneChannelPacket< FFXIVIpcEventFinish >( playerId, playerId )
{
initialize( eventId, param1, param3 );
};
private:
void initialize( uint32_t eventId,
uint8_t param1,
uint32_t param3 )
private:
void initialize( uint32_t eventId, uint8_t param1, uint32_t param3 )
{
m_data.eventId = eventId;
m_data.param1 = param1;
m_data.param2 = 1;
m_data.param3 = param3;
};
};
};
}
}
}
}
} // namespace Server
} // namespace Packets
} // namespace Network
} // namespace Core
#endif /*_EVENTFINISH_H*/

View file

@ -1,41 +1,30 @@
#ifndef _EVENTPLAY_H
#define _EVENTPLAY_H
#include <Server_Common/Network/GamePacketNew.h>
#include "Forwards.h"
#include <Server_Common/Network/GamePacketNew.h>
namespace Core {
namespace Network {
namespace Packets {
namespace Server {
namespace Packets {
namespace Server {
/**
* @brief The packet sent to play an event.
*/
class EventPlayPacket : public ZoneChannelPacket< FFXIVIpcEventPlay >
{
public:
EventPlayPacket( uint32_t playerId,
uint64_t actorId,
uint32_t eventId,
uint16_t scene,
uint32_t flags,
uint8_t param3,
uint32_t param4 = 0,
uint32_t param5 = 0 ) :
/**
* @brief The packet sent to play an event.
*/
class EventPlayPacket : public ZoneChannelPacket< FFXIVIpcEventPlay >
{
public:
EventPlayPacket( uint32_t playerId, uint64_t actorId, uint32_t eventId, uint16_t scene, uint32_t flags,
uint8_t param3, uint32_t param4 = 0, uint32_t param5 = 0 ) :
ZoneChannelPacket< FFXIVIpcEventPlay >( playerId, playerId )
{
initialize( actorId, eventId, scene, flags, param3, param4, param5 );
};
private:
void initialize( uint64_t actorId,
uint32_t eventId,
uint16_t scene,
uint32_t flags,
uint8_t param3,
uint32_t param4,
uint32_t param5 )
private:
void initialize( uint64_t actorId, uint32_t eventId, uint16_t scene, uint32_t flags, uint8_t param3,
uint32_t param4, uint32_t param5 )
{
m_data.actorId = actorId;
m_data.eventId = eventId;
@ -45,11 +34,11 @@ private:
m_data.param4 = param4;
m_data.param5 = param5;
};
};
};
}
}
}
}
} // namespace Server
} // namespace Packets
} // namespace Network
} // namespace Core
#endif /*_EVENTPLAY_H*/

View file

@ -1,50 +1,41 @@
#ifndef _EVENTSTART_H
#define _EVENTSTART_H
#include <Server_Common/Network/GamePacketNew.h>
#include "Forwards.h"
#include <Server_Common/Network/GamePacketNew.h>
namespace Core {
namespace Network {
namespace Packets {
namespace Server {
namespace Packets {
namespace Server {
/**
* @brief The packet sent to start an event.
*/
class EventStartPacket : public ZoneChannelPacket< FFXIVIpcEventStart >
{
public:
EventStartPacket( uint32_t playerId,
uint64_t actorId,
uint32_t eventId,
uint8_t param1 = 0,
uint8_t param2 = 0,
uint32_t param3 = 0 ) :
/**
* @brief The packet sent to start an event.
*/
class EventStartPacket : public ZoneChannelPacket< FFXIVIpcEventStart >
{
public:
EventStartPacket( uint32_t playerId, uint64_t actorId, uint32_t eventId, uint8_t param1 = 0,
uint8_t param2 = 0, uint32_t param3 = 0 ) :
ZoneChannelPacket< FFXIVIpcEventStart >( playerId, playerId )
{
initialize( actorId, eventId, param1, param2, param3 );
};
private:
void initialize( uint64_t actorId,
uint32_t eventId,
uint8_t param1,
uint8_t param2,
uint32_t param3 )
private:
void initialize( uint64_t actorId, uint32_t eventId, uint8_t param1, uint8_t param2, uint32_t param3 )
{
m_data.actorId = actorId;
m_data.eventId = eventId;
m_data.param1 = param1;
m_data.param2 = param2;
m_data.param3 = param3;
};
};
};
}
}
}
}
} // namespace Server
} // namespace Packets
} // namespace Network
} // namespace Core
#endif /*_EVENTSTART_H*/

View file

@ -1,37 +1,37 @@
#ifndef _CORE_NETWORK_PACKETS_INITUIPACKET_H
#define _CORE_NETWORK_PACKETS_INITUIPACKET_H
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include "Actor/Player.h"
#include "Forwards.h"
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
namespace Core {
namespace Network {
namespace Packets {
namespace Server {
namespace Packets {
namespace Server {
/**
* @brief The Client UI Initialization packet. This must be sent to the client
* once upon connection to configure the UI.
*/
class InitUIPacket : public ZoneChannelPacket< FFXIVIpcInitUI >
{
public:
/**
* @brief The Client UI Initialization packet. This must be sent to the client
* once upon connection to configure the UI.
*/
class InitUIPacket : public ZoneChannelPacket< FFXIVIpcInitUI >
{
public:
InitUIPacket( Entity::Player& player ) :
ZoneChannelPacket< FFXIVIpcInitUI >( player.getId(), player.getId() )
{
initialize( player );
};
private:
private:
void initialize( Entity::Player& player )
{
m_data.contentId = player.getContentId();
// TODO: Support rested experience.
m_data.restedExp = 0;
//m_data.padding = 0x100;
// m_data.padding = 0x100;
m_data.charId = player.getId();
m_data.race = player.getLookAt( Common::CharaLook::Race );
m_data.tribe = player.getLookAt( Common::CharaLook::Tribe );
@ -43,17 +43,17 @@ private:
m_data.namedayDay = player.getBirthDay();
// TODO: Support grand company status.
m_data.grandCompany = static_cast< Common::GrandCompany >( player.getGc() );
//m_data.gcRank = GCRank::None;
// m_data.gcRank = GCRank::None;
// TODO: Support starting city.
//m_data.startCity = Town::Gridania;
// m_data.startCity = Town::Gridania;
m_data.homepoint = player.getHomepoint();
memset( &m_data.name[0], 0, sizeof( m_data.name ) );
strcpy( &m_data.name[0], player.getName().c_str() );
memcpy( m_data.aetheryte, player.getAetheryteArray(), sizeof ( m_data.aetheryte ) );
memcpy( m_data.aetheryte, player.getAetheryteArray(), sizeof( m_data.aetheryte ) );
// Set the class levels and exp.
for( uint8_t i = 0; i < 25; i++ )
@ -64,7 +64,7 @@ private:
memcpy( m_data.orchestrionMask, player.getOrchestrionBitmask(), sizeof( m_data.orchestrionMask ) );
memcpy( m_data.mountGuideMask, player.getMountGuideBitmask(), sizeof( m_data.mountGuideMask) );
memcpy( m_data.mountGuideMask, player.getMountGuideBitmask(), sizeof( m_data.mountGuideMask ) );
memcpy( m_data.unlockBitmask, player.getUnlockBitmask(), sizeof( m_data.unlockBitmask ) );
@ -75,19 +75,18 @@ private:
m_data.unknown_13 = 0x46;
m_data.expansion = 2;
//memset( m_data.unlockBitmask, 0xFF, sizeof( m_data.unlockBitmask ) );
//memset( m_data.unknown_0344, 0xFF, sizeof( m_data.unknown_0344 ) );
//memset( m_data.unknown_F4, 0xFF, sizeof( m_data.unknown_F4 ) );
//m_data.pos.x = player->getPos().getX();
//m_data.pos.y = player->getPos().getY();
//m_data.pos.z = player->getPos().getZ();
// memset( m_data.unlockBitmask, 0xFF, sizeof( m_data.unlockBitmask ) );
// memset( m_data.unknown_0344, 0xFF, sizeof( m_data.unknown_0344 ) );
// memset( m_data.unknown_F4, 0xFF, sizeof( m_data.unknown_F4 ) );
// m_data.pos.x = player->getPos().getX();
// m_data.pos.y = player->getPos().getY();
// m_data.pos.z = player->getPos().getZ();
};
};
};
}
}
}
}
} // namespace Server
} // namespace Packets
} // namespace Network
} // namespace Core
#endif /*_CORE_NETWORK_PACKETS_CINITUIPACKET_H*/

View file

@ -1,29 +1,28 @@
#ifndef _MODELEQUIPPACKET_H
#define _MODELEQUIPPACKET_H
#include <Server_Common/Network/GamePacketNew.h>
#include "Actor/Player.h"
#include "Forwards.h"
#include <Server_Common/Network/GamePacketNew.h>
namespace Core {
namespace Network {
namespace Packets {
namespace Server {
namespace Packets {
namespace Server {
/**
* @brief The update model packet.
*/
class ModelEquipPacket :
public ZoneChannelPacket< FFXIVIpcModelEquip >
{
public:
/**
* @brief The update model packet.
*/
class ModelEquipPacket : public ZoneChannelPacket< FFXIVIpcModelEquip >
{
public:
ModelEquipPacket( Entity::Player& player ) :
ZoneChannelPacket< FFXIVIpcModelEquip >( player.getId(), player.getId() )
{
initialize( player );
};
private:
private:
void initialize( Entity::Player& player )
{
m_data.mainWeapon = player.getModelMainWeapon();
@ -34,11 +33,11 @@ private:
m_data.models[3] = player.getModelForSlot( Inventory::EquipSlot::Legs );
m_data.models[4] = player.getModelForSlot( Inventory::EquipSlot::Feet );
};
};
};
}
}
}
}
} // namespace Server
} // namespace Packets
} // namespace Network
} // namespace Core
#endif /*_MODELEQUIPPACKET_H*/

View file

@ -1,33 +1,31 @@
#ifndef _MOVEACTORPACKET_H
#define _MOVEACTORPACKET_H
#include "Actor/Player.h"
#include "Forwards.h"
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include <Server_Common/Util/UtilMath.h>
#include "Actor/Player.h"
#include "Forwards.h"
namespace Core {
namespace Network {
namespace Packets {
namespace Server {
namespace Packets {
namespace Server {
/**
* @brief The Client UI Initialization packet. This must be sent to the client
* once upon connection to configure the UI.
*/
class MoveActorPacket :
public ZoneChannelPacket< FFXIVIpcActorMove >
{
public:
/**
* @brief The Client UI Initialization packet. This must be sent to the client
* once upon connection to configure the UI.
*/
class MoveActorPacket : public ZoneChannelPacket< FFXIVIpcActorMove >
{
public:
MoveActorPacket( Entity::Actor& actor, uint8_t unk1, uint8_t unk2, uint8_t unk3, uint16_t unk4 ) :
ZoneChannelPacket< FFXIVIpcActorMove >( actor.getId(), actor.getId() )
{
initialize( actor, unk1, unk2, unk3, unk4 );
};
private:
private:
void initialize( Entity::Actor& actor, uint8_t unk1, uint8_t unk2, uint8_t unk3, uint16_t unk4 )
{
@ -39,13 +37,12 @@ private:
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 );
};
};
};
}
}
}
}
} // namespace Server
} // namespace Packets
} // namespace Network
} // namespace Core
#endif /*_MOVEACTORPACKET_H*/

View file

@ -7,32 +7,31 @@
namespace Core {
namespace Network {
namespace Packets {
namespace Server {
namespace Packets {
namespace Server {
/**
* @brief The Ping response packet.
*/
class PingPacket :
public ZoneChannelPacket< FFXIVIpcPing >
{
public:
/**
* @brief The Ping response packet.
*/
class PingPacket : public ZoneChannelPacket< FFXIVIpcPing >
{
public:
PingPacket( Entity::Player& player, int32_t inVal ) :
ZoneChannelPacket< FFXIVIpcPing >( player.getId(), player.getId() )
{
initialize( player, inVal );
};
private:
private:
void initialize( Entity::Player& player, int32_t inVal )
{
m_data.timeInMilliseconds = 0x000014D00000000 + inVal;
};
};
};
}
}
}
}
} // namespace Server
} // namespace Packets
} // namespace Network
} // namespace Core
#endif /*_CORE_NETWORK_PACKETS_CPINGPACKET_H*/

View file

@ -1,25 +1,24 @@
#ifndef _PLAYERSPAWN_H
#define _PLAYERSPAWN_H
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Util/UtilMath.h>
#include "Actor/Player.h"
#include "Forwards.h"
#include "Inventory/Inventory.h"
#include "Inventory/Item.h"
#include "StatusEffect/StatusEffect.h"
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include <Server_Common/Util/UtilMath.h>
namespace Core {
namespace Network {
namespace Packets {
namespace Server {
namespace Packets {
namespace Server {
/**
* @brief The packet sent to spawn a player.
*/
class PlayerSpawnPacket :
public GamePacketNew< FFXIVIpcPlayerSpawn, ServerZoneIpcType >
class PlayerSpawnPacket : public GamePacketNew< FFXIVIpcPlayerSpawn, ServerZoneIpcType >
{
public:
PlayerSpawnPacket( Entity::Player& player, Entity::Player& target ) :
@ -33,10 +32,10 @@ namespace Server {
{
// todo: figure out unkown offsets
// TODO: temporary gm rank
//m_data.gmRank = 0xff;
// m_data.gmRank = 0xff;
m_data.classJob = static_cast< uint8_t >( player.getClass() );
//m_data.status = static_cast< uint8_t >( pPlayer->getStatus() );
// m_data.status = static_cast< uint8_t >( pPlayer->getStatus() );
m_data.hPCurr = player.getHp();
m_data.mPCurr = player.getMp();
@ -44,7 +43,7 @@ namespace Server {
m_data.hPMax = player.getMaxHp();
m_data.mPMax = player.getMaxMp();
//m_data.tPMax = 3000;
// m_data.tPMax = 3000;
m_data.level = player.getLevel();
m_data.gmRank = player.getGmRank();
m_data.pose = 0;
@ -68,15 +67,14 @@ namespace Server {
m_data.pos.z = player.getPos().z;
m_data.rotation = Math::Util::floatToUInt16Rot( player.getRotation() );
m_data.title = player.getTitle();
m_data.voice = player.getVoiceId();
m_data.currentMount = player.getCurrentMount();
m_data.onlineStatus = static_cast< uint8_t >( player.getOnlineStatus() );
//m_data.u23 = 0x04;
//m_data.u24 = 256;
// m_data.u23 = 0x04;
// m_data.u24 = 256;
m_data.state = static_cast< uint8_t >( player.getStatus() );
m_data.type = 1;
if( target.getId() == player.getId() )
@ -113,29 +111,30 @@ namespace Server {
m_data.currentMount = player.getCurrentMount();
m_data.targetId = player.getTargetId();
//m_data.type = 1;
//m_data.unknown_33 = 4;
//m_data.unknown_38 = 0x70;
//m_data.unknown_60 = 3;
//m_data.unknown_61 = 7;
// m_data.type = 1;
// m_data.unknown_33 = 4;
// m_data.unknown_38 = 0x70;
// m_data.unknown_60 = 3;
// m_data.unknown_61 = 7;
uint64_t currentTimeMs = Util::getTimeMs();
for( auto const& effect : player.getStatusEffectMap() )
{
m_data.effect[effect.first].effect_id = effect.second->getId();
m_data.effect[effect.first].duration = static_cast< float >( effect.second->getDuration() -
( currentTimeMs - effect.second->getStartTimeMs() ) ) / 1000;
m_data.effect[effect.first].duration =
static_cast< float >( effect.second->getDuration() -
( currentTimeMs - effect.second->getStartTimeMs() ) ) /
1000;
m_data.effect[effect.first].sourceActorId = effect.second->getSrcActorId();
m_data.effect[effect.first].unknown1 = effect.second->getParam();
}
};
};
}
}
}
}
} // namespace Server
} // namespace Packets
} // namespace Network
} // namespace Core
#endif /*_PlayerSpawn_H*/

View file

@ -1,22 +1,21 @@
#ifndef _PLAYERSTATE_H
#define _PLAYERSTATE_H
#include <Server_Common/Network/GamePacketNew.h>
#include "Actor/Player.h"
#include "Forwards.h"
#include <Server_Common/Network/GamePacketNew.h>
namespace Core {
namespace Network {
namespace Packets {
namespace Server {
namespace Packets {
namespace Server {
/**
* @brief Packet sent to set a players state, this impacts which actions he can perform.
*/
class PlayerStateFlagsPacket :
public ZoneChannelPacket< FFXIVIpcPlayerStateFlags >
{
public:
/**
* @brief Packet sent to set a players state, this impacts which actions he can perform.
*/
class PlayerStateFlagsPacket : public ZoneChannelPacket< FFXIVIpcPlayerStateFlags >
{
public:
PlayerStateFlagsPacket( Entity::Player& player ) :
ZoneChannelPacket< FFXIVIpcPlayerStateFlags >( player.getId(), player.getId() )
{
@ -43,16 +42,13 @@ public:
initialize( newFlags );
}
private:
void initialize( const uint8_t* flags )
{
memcpy( m_data.flags, flags, 7 );
private:
void initialize( const uint8_t* flags ) { memcpy( m_data.flags, flags, 7 ); };
};
};
}
}
}
}
} // namespace Server
} // namespace Packets
} // namespace Network
} // namespace Core
#endif /*_PLAYERSTATE_H*/

View file

@ -1,30 +1,29 @@
#ifndef _QUESTMESSAGE_H
#define _QUESTMESSAGE_H
#include <Server_Common/Network/GamePacketNew.h>
#include "Actor/Player.h"
#include "Forwards.h"
#include <Server_Common/Network/GamePacketNew.h>
namespace Core {
namespace Network {
namespace Packets {
namespace Server {
namespace Packets {
namespace Server {
/**
* @brief Packet to display a quest specific info message.
*/
class QuestMessagePacket :
public ZoneChannelPacket< FFXIVIpcQuestMessage >
{
public:
QuestMessagePacket( Entity::ActorPtr pActor, uint32_t questId, int8_t msgId,
uint8_t type = 0, uint32_t var1 = 0, uint32_t var2 = 0 ) :
/**
* @brief Packet to display a quest specific info message.
*/
class QuestMessagePacket : public ZoneChannelPacket< FFXIVIpcQuestMessage >
{
public:
QuestMessagePacket( Entity::ActorPtr pActor, uint32_t questId, int8_t msgId, uint8_t type = 0,
uint32_t var1 = 0, uint32_t var2 = 0 ) :
ZoneChannelPacket< FFXIVIpcQuestMessage >( pActor->getId(), pActor->getId() )
{
initialize( questId, msgId, type, var1, var2 );
};
private:
private:
void initialize( uint32_t questId, int8_t msgId, uint8_t type, uint32_t var1, uint32_t var2 )
{
m_data.questId = questId;
@ -33,11 +32,11 @@ private:
m_data.var1 = var1;
m_data.var2 = var2;
};
};
};
}
}
}
}
} // namespace Server
} // namespace Packets
} // namespace Network
} // namespace Core
#endif /* _QUESTMESSAGE_H */

View file

@ -1,38 +1,34 @@
#ifndef _SERVERNOTICEPACKET_H
#define _SERVERNOTICEPACKET_H
#include "Forwards.h"
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include "Forwards.h"
namespace Core {
namespace Network {
namespace Packets {
namespace Server {
namespace Packets {
namespace Server {
/**
* @brief The Ping response packet.
*/
class ServerNoticePacket :
public ZoneChannelPacket< FFXIVIpcServerNotice >
{
public:
/**
* @brief The Ping response packet.
*/
class ServerNoticePacket : public ZoneChannelPacket< FFXIVIpcServerNotice >
{
public:
ServerNoticePacket( uint32_t playerId, const std::string& message ) :
ZoneChannelPacket< FFXIVIpcServerNotice >( playerId, playerId )
{
initialize( message );
};
private:
void initialize( const std::string& message )
{
strcpy( m_data.message, message.c_str() );
private:
void initialize( const std::string& message ) { strcpy( m_data.message, message.c_str() ); };
};
};
}
}
}
}
} // namespace Server
} // namespace Packets
} // namespace Network
} // namespace Core
#endif /*_SERVERNOTICEPACKET_H*/

View file

@ -1,40 +1,39 @@
#ifndef _UPDATEHPMPTP_H
#define _UPDATEHPMPTP_H
#include <Server_Common/Network/GamePacketNew.h>
#include <Actor/Actor.h>
#include "Forwards.h"
#include <Actor/Actor.h>
#include <Server_Common/Network/GamePacketNew.h>
namespace Core {
namespace Network {
namespace Packets {
namespace Server {
namespace Packets {
namespace Server {
/**
* @brief The Ping response packet.
*/
class UpdateHpMpTpPacket :
public ZoneChannelPacket< FFXIVIpcUpdateHpMpTp >
{
public:
/**
* @brief The Ping response packet.
*/
class UpdateHpMpTpPacket : public ZoneChannelPacket< FFXIVIpcUpdateHpMpTp >
{
public:
UpdateHpMpTpPacket( Entity::ActorPtr pActor ) :
ZoneChannelPacket< FFXIVIpcUpdateHpMpTp >( pActor->getId(), pActor->getId() )
{
initialize( pActor );
};
private:
private:
void initialize( Entity::ActorPtr pActor )
{
m_data.hp = pActor->getHp();
m_data.mp = pActor->getMp();
m_data.tp = pActor->getTp();
};
};
};
}
}
}
}
} // namespace Server
} // namespace Packets
} // namespace Network
} // namespace Core
#endif /*_UPDATEHPMPTP_H*/

View file

@ -1,24 +1,24 @@
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Logging/Logger.h>
#include <chaiscript/chaiscript.hpp>
#include <Server_Common/Script/ChaiscriptStdLib.h>
#include "Zone/Zone.h"
#include "Actor/Player.h"
#include "Actor/BattleNpc.h"
#include "ServerZone.h"
#include "Actor/Player.h"
#include "Event/Event.h"
#include "Event/EventHelper.h"
#include "StatusEffect/StatusEffect.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Script/ScriptManager.h"
#include "ServerZone.h"
#include "StatusEffect/StatusEffect.h"
#include "Zone/Zone.h"
#include <boost/lexical_cast.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include <boost/format.hpp>
#include <boost/foreach.hpp>
#include <boost/format.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/make_shared.hpp>
#include <boost/shared_ptr.hpp>
extern Core::Logger g_log;
extern Core::Data::ExdData g_exdData;
@ -31,10 +31,9 @@ Core::Scripting::ScriptManager::ScriptManager()
Core::Scripting::ScriptManager::~ScriptManager()
{
}
void Core::Scripting::ScriptManager::loadDir( std::string dirname, std::set<std::string>& chaiFiles )
void Core::Scripting::ScriptManager::loadDir( std::string dirname, std::set< std::string >& chaiFiles )
{
g_log.info( "ScriptEngine: loading scripts from " + dirname );
@ -52,7 +51,6 @@ void Core::Scripting::ScriptManager::loadDir( std::string dirname, std::set<std:
chaiFiles.insert( i.string() );
}
}
}
void Core::Scripting::ScriptManager::onPlayerFirstEnterWorld( Entity::Player& player )
@ -61,7 +59,7 @@ void Core::Scripting::ScriptManager::onPlayerFirstEnterWorld( Entity::Player& pl
{
std::string test = m_onFirstEnterWorld( player );
}
catch( const std::exception &e )
catch( const std::exception& e )
{
std::string what = e.what();
g_log.Log( LoggingSeverity::error, what );
@ -86,19 +84,15 @@ const boost::shared_ptr< chaiscript::ChaiScript >& Core::Scripting::ScriptManage
return m_pChaiHandler;
}
bool Core::Scripting::ScriptManager::onTalk( Entity::Player& player, uint64_t actorId, uint32_t eventId )
{
std::string eventName = "onTalk";
std::string objName = Event::getEventName( eventId );
player.sendDebug( "Actor: " +
std::to_string( actorId ) + " -> " +
player.sendDebug( "Actor: " + std::to_string( actorId ) + " -> " +
std::to_string( Event::mapEventActorToRealActor( static_cast< uint32_t >( actorId ) ) ) +
" \neventId: " +
std::to_string( eventId ) +
" (0x" + boost::str( boost::format( "%|08X|" )
% static_cast< uint64_t >( eventId & 0xFFFFFFF ) ) + ")" );
" \neventId: " + std::to_string( eventId ) + " (0x" +
boost::str( boost::format( "%|08X|" ) % static_cast< uint64_t >( eventId & 0xFFFFFFF ) ) + ")" );
uint16_t eventType = eventId >> 16;
@ -110,15 +104,16 @@ bool Core::Scripting::ScriptManager::onTalk( Entity::Player& player, uint64_t ac
player.eventStart( actorId, eventId, Event::Event::Talk, 0, 0 );
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &,
uint32_t, Entity::Player&, uint64_t ) > >( eventName );
auto fn = m_pChaiHandler
->eval< std::function< void( chaiscript::Boxed_Value&, uint32_t, Entity::Player&, uint64_t ) > >(
eventName );
fn( obj, eventId, player, actorId );
player.checkEvent( eventId );
}
catch( std::exception& e )
{
player.sendDebug( e.what( ) );
player.sendDebug( e.what() );
if( eventType == Common::EventType::Quest )
{
@ -135,8 +130,8 @@ bool Core::Scripting::ScriptManager::onTalk( Entity::Player& player, uint64_t ac
return true;
}
bool Core::Scripting::ScriptManager::onEnterTerritory( Entity::Player& player, uint32_t eventId,
uint16_t param1, uint16_t param2 )
bool Core::Scripting::ScriptManager::onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1,
uint16_t param2 )
{
std::string eventName = "onEnterTerritory";
std::string objName = Event::getEventName( eventId );
@ -150,8 +145,9 @@ bool Core::Scripting::ScriptManager::onEnterTerritory( Entity::Player& player, u
player.eventStart( player.getId(), eventId, Event::Event::EnterTerritory, 0, player.getZoneId() );
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t,
Entity::Player&, uint16_t, uint16_t ) > >( eventName );
auto fn = m_pChaiHandler->eval<
std::function< void( chaiscript::Boxed_Value&, uint32_t, Entity::Player&, uint16_t, uint16_t ) > >(
eventName );
fn( obj, eventId, player, param1, param2 );
player.checkEvent( eventId );
@ -164,8 +160,8 @@ bool Core::Scripting::ScriptManager::onEnterTerritory( Entity::Player& player, u
return true;
}
bool Core::Scripting::ScriptManager::onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1,
float x, float y, float z )
bool Core::Scripting::ScriptManager::onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x,
float y, float z )
{
std::string eventName = "onWithinRange";
std::string objName = Event::getEventName( eventId );
@ -179,8 +175,9 @@ bool Core::Scripting::ScriptManager::onWithinRange( Entity::Player& player, uint
player.eventStart( player.getId(), eventId, Event::Event::WithinRange, 1, param1 );
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t, Entity::Player&, uint32_t,
float, float, float ) > >( eventName );
auto fn = m_pChaiHandler->eval<
std::function< void( chaiscript::Boxed_Value&, uint32_t, Entity::Player&, uint32_t, float, float, float ) > >(
eventName );
fn( obj, eventId, player, param1, x, y, z );
player.checkEvent( eventId );
@ -193,8 +190,8 @@ bool Core::Scripting::ScriptManager::onWithinRange( Entity::Player& player, uint
return true;
}
bool Core::Scripting::ScriptManager::onOutsideRange( Entity::Player& player, uint32_t eventId, uint32_t param1,
float x, float y, float z )
bool Core::Scripting::ScriptManager::onOutsideRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x,
float y, float z )
{
std::string eventName = "onOutsideRange";
std::string objName = Event::getEventName( eventId );
@ -208,8 +205,9 @@ bool Core::Scripting::ScriptManager::onOutsideRange( Entity::Player& player, uin
player.eventStart( player.getId(), eventId, Event::Event::OutsideRange, 1, param1 );
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t, Entity::Player&, uint32_t,
float, float, float ) > >( eventName );
auto fn = m_pChaiHandler->eval<
std::function< void( chaiscript::Boxed_Value&, uint32_t, Entity::Player&, uint32_t, float, float, float ) > >(
eventName );
fn( obj, eventId, player, param1, x, y, z );
player.checkEvent( eventId );
@ -222,8 +220,8 @@ bool Core::Scripting::ScriptManager::onOutsideRange( Entity::Player& player, uin
return true;
}
bool Core::Scripting::ScriptManager::onEmote( Entity::Player& player, uint64_t actorId,
uint32_t eventId, uint8_t emoteId )
bool Core::Scripting::ScriptManager::onEmote( Entity::Player& player, uint64_t actorId, uint32_t eventId,
uint8_t emoteId )
{
std::string eventName = "onEmote";
std::string objName = Event::getEventName( eventId );
@ -236,8 +234,10 @@ bool Core::Scripting::ScriptManager::onEmote( Entity::Player& player, uint64_t a
player.eventStart( actorId, eventId, Event::Event::Emote, 0, emoteId );
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t, Entity::Player&,
uint64_t, uint8_t ) > >( eventName );
auto fn =
m_pChaiHandler
->eval< std::function< void( chaiscript::Boxed_Value&, uint32_t, Entity::Player&, uint64_t, uint8_t ) > >(
eventName );
fn( obj, eventId, player, actorId, emoteId );
player.checkEvent( eventId );
@ -260,18 +260,14 @@ bool Core::Scripting::ScriptManager::onEmote( Entity::Player& player, uint64_t a
return true;
}
bool Core::Scripting::ScriptManager::onEventHandlerReturn( Entity::Player& player, uint32_t eventId,
uint16_t subEvent, uint16_t param1, uint16_t param2,
uint16_t param3 )
bool Core::Scripting::ScriptManager::onEventHandlerReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent,
uint16_t param1, uint16_t param2, uint16_t param3 )
{
player.sendDebug( "eventId: " +
std::to_string( eventId ) +
" ( 0x" + boost::str( boost::format( "%|08X|" ) % ( uint64_t ) ( eventId & 0xFFFFFFF ) ) + " ) " +
" scene: " + std::to_string( subEvent ) +
" p1: " + std::to_string( param1 ) +
" p2: " + std::to_string( param2 ) +
" p3: " + std::to_string( param3 ) );
player.sendDebug( "eventId: " + std::to_string( eventId ) + " ( 0x" +
boost::str( boost::format( "%|08X|" ) % ( uint64_t )( eventId & 0xFFFFFFF ) ) + " ) " +
" scene: " + std::to_string( subEvent ) + " p1: " + std::to_string( param1 ) +
" p2: " + std::to_string( param2 ) + " p3: " + std::to_string( param3 ) );
try
{
@ -311,8 +307,9 @@ bool Core::Scripting::ScriptManager::onEventHandlerTradeReturn( Entity::Player&
try
{
auto fn = m_pChaiHandler->eval< std::function< void( Entity::Player&, uint32_t,
uint16_t, uint16_t, uint32_t ) > >( eventName );
auto fn =
m_pChaiHandler->eval< std::function< void( Entity::Player&, uint32_t, uint16_t, uint16_t, uint32_t ) > >(
eventName );
fn( player, eventId, subEvent, param, catalogId );
}
catch( ... )
@ -323,8 +320,8 @@ bool Core::Scripting::ScriptManager::onEventHandlerTradeReturn( Entity::Player&
return true;
}
bool Core::Scripting::ScriptManager::onEventItem( Entity::Player& player, uint32_t eventItemId,
uint32_t eventId, uint32_t castTime, uint64_t targetId )
bool Core::Scripting::ScriptManager::onEventItem( Entity::Player& player, uint32_t eventItemId, uint32_t eventId,
uint32_t castTime, uint64_t targetId )
{
std::string eventName = "onEventItem";
std::string objName = Event::getEventName( eventId );
@ -337,8 +334,9 @@ bool Core::Scripting::ScriptManager::onEventItem( Entity::Player& player, uint32
player.eventStart( targetId, eventId, Event::Event::Item, 0, 0 );
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t, Entity::Player&,
uint32_t, uint32_t, uint64_t ) > >( eventName );
auto fn = m_pChaiHandler->eval<
std::function< void( chaiscript::Boxed_Value&, uint32_t, Entity::Player&, uint32_t, uint32_t, uint64_t ) > >(
eventName );
fn( obj, eventId, player, eventItemId, castTime, targetId );
}
catch( std::exception& e )
@ -348,14 +346,12 @@ bool Core::Scripting::ScriptManager::onEventItem( Entity::Player& player, uint32
}
return true;
}
bool Core::Scripting::ScriptManager::onMobKill( Entity::Player& player, uint16_t nameId )
{
std::string eventName = "onBnpcKill_" + std::to_string( nameId );
// loop through all active quests and try to call available onMobKill callbacks
for( size_t i = 0; i < 30; i++ )
{
@ -369,18 +365,18 @@ bool Core::Scripting::ScriptManager::onMobKill( Entity::Player& player, uint16_t
auto obj = m_pChaiHandler->eval( Event::getEventName( 0x00010000 | questId ) );
std::string objName = Event::getEventName( 0x00010000 | questId );
player.sendDebug("Calling: " + objName + "." + eventName);
player.sendDebug( "Calling: " + objName + "." + eventName );
try
{
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Player& ) > >(eventName);
auto fn =
m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value&, Entity::Player& ) > >( eventName );
fn( obj, player );
}
catch( std::exception& e )
{
g_log.info( e.what() );
}
}
}
@ -397,8 +393,9 @@ bool Core::Scripting::ScriptManager::onCastFinish( Entity::Player& player, Entit
std::string objName = "skillDef_" + std::to_string( actionId );
player.sendDebug( "Calling: " + objName + "." + eventName );
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Player&,
Entity::Actor& ) > >( eventName );
auto fn =
m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value&, Entity::Player&, Entity::Actor& ) > >(
eventName );
fn( obj, player, *pTarget );
}
catch( std::exception& e )
@ -421,7 +418,7 @@ bool Core::Scripting::ScriptManager::onStatusReceive( Entity::ActorPtr pActor, u
if( pActor->isPlayer() )
pActor->getAsPlayer()->sendDebug( "Calling: " + objName + "." + eventName );
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Actor&) > >( eventName );
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value&, Entity::Actor& ) > >( eventName );
fn( obj, *pActor );
}
catch( std::exception& e )
@ -445,8 +442,10 @@ bool Core::Scripting::ScriptManager::onStatusTick( Entity::ActorPtr pActor, Core
if( pActor->isPlayer() )
pActor->getAsPlayer()->sendDebug( "Calling: " + objName + "." + eventName );
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Actor&,
StatusEffect::StatusEffect& ) > >( eventName );
auto fn =
m_pChaiHandler
->eval< std::function< void( chaiscript::Boxed_Value&, Entity::Actor&, StatusEffect::StatusEffect& ) > >(
eventName );
fn( obj, *pActor, effect );
}
catch( std::exception& e )
@ -470,7 +469,7 @@ bool Core::Scripting::ScriptManager::onStatusTimeOut( Entity::ActorPtr pActor, u
if( pActor->isPlayer() )
pActor->getAsPlayer()->sendDebug( "Calling: " + objName + "." + eventName );
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Actor& ) > >( eventName );
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value&, Entity::Actor& ) > >( eventName );
fn( obj, *pActor );
}
catch( std::exception& e )
@ -498,6 +497,4 @@ bool Core::Scripting::ScriptManager::onZoneInit( ZonePtr pZone )
}
return true;
}

View file

@ -5,24 +5,19 @@
#include <mutex>
#include <set>
#include <Server_Common/Common.h>
#include "Forwards.h"
#include <Server_Common/Common.h>
namespace chaiscript
{
class ChaiScript;
namespace chaiscript {
class ChaiScript;
}
namespace Core
{
namespace Scripting
{
namespace Core {
namespace Scripting {
class ScriptManager
{
private:
boost::shared_ptr< chaiscript::ChaiScript > m_pChaiHandler;
std::function< std::string( Entity::Player& ) > m_onFirstEnterWorld;
@ -39,14 +34,16 @@ namespace Core
void onPlayerFirstEnterWorld( Entity::Player& player );
static bool registerBnpcTemplate( std::string templateName, uint32_t bnpcBaseId, uint32_t bnpcNameId, uint32_t modelId, std::string aiName );
static bool registerBnpcTemplate( std::string templateName, uint32_t bnpcBaseId, uint32_t bnpcNameId,
uint32_t modelId, std::string aiName );
bool onTalk( Entity::Player& player, uint64_t actorId, uint32_t eventId );
bool onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 );
bool onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z );
bool onOutsideRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z );
bool onEmote( Entity::Player& player, uint64_t actorId, uint32_t eventId, uint8_t emoteId );
bool onEventItem( Entity::Player& player, uint32_t eventItemId, uint32_t eventId, uint32_t castTime, uint64_t targetId );
bool onEventItem( Entity::Player& player, uint32_t eventItemId, uint32_t eventId, uint32_t castTime,
uint64_t targetId );
bool onMobKill( Entity::Player& player, uint16_t nameId );
@ -58,14 +55,13 @@ namespace Core
bool onZoneInit( ZonePtr pZone );
bool onEventHandlerReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param1, uint16_t param2, uint16_t param3 );
bool onEventHandlerTradeReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param, uint32_t catalogId );
void loadDir( std::string dirname, std::set<std::string>& chaiFiles );
bool onEventHandlerReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param1,
uint16_t param2, uint16_t param3 );
bool onEventHandlerTradeReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param,
uint32_t catalogId );
void loadDir( std::string dirname, std::set< std::string >& chaiFiles );
};
}
}
} // namespace Scripting
} // namespace Core
#endif

View file

@ -8,13 +8,13 @@
#include "Script/ScriptManager.h"
#include "Zone/Zone.h"
#include "Actor/Player.h"
#include "Actor/BattleNpc.h"
#include "Actor/Player.h"
#include "Event/Event.h"
#include "Event/EventHelper.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "StatusEffect/StatusEffect.h"
#include "Zone/Zone.h"
#include <boost/lexical_cast.hpp>
@ -34,7 +34,8 @@ int Core::Scripting::ScriptManager::init()
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::getTargetId ), "getTargetId" );
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::addStatusEffect ), "addStatusEffect" );
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::addStatusEffectById ), "addStatusEffectById" );
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::addStatusEffectByIdIfNotExist ), "addStatusEffectByIdIfNotExist" );
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::addStatusEffectByIdIfNotExist ),
"addStatusEffectByIdIfNotExist" );
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::takeDamage ), "takeDamage" );
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::forceZoneing ), "setZone" );
@ -137,13 +138,24 @@ int Core::Scripting::ScriptManager::init()
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestBitFlag40 ), "setQuestBitFlag40" );
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestBitFlag48 ), "setQuestBitFlag48" );
m_pChaiHandler->add(chaiscript::fun(&Entity::Player::giveQuestRewards), "giveQuestRewards");
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::giveQuestRewards ), "giveQuestRewards" );
m_pChaiHandler->add( chaiscript::fun< void, Entity::Player, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t >( &Entity::Player::eventPlay ), "eventPlay" );
m_pChaiHandler->add( chaiscript::fun< void, Entity::Player, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, EventReturnCallback >( &Entity::Player::eventPlay ), "eventPlay" );
m_pChaiHandler->add( chaiscript::fun< void, Entity::Player, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, EventReturnCallback >( &Entity::Player::eventPlay ), "eventPlay" );
m_pChaiHandler->add( chaiscript::fun< void, Entity::Player, uint32_t, uint32_t, uint32_t, EventReturnCallback >( &Entity::Player::eventPlay ), "eventPlay" );
m_pChaiHandler->add( chaiscript::fun< void, Entity::Player, uint32_t, uint32_t, uint32_t >( &Entity::Player::eventPlay ), "eventPlay" );
m_pChaiHandler->add( chaiscript::fun< void, Entity::Player, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t >(
&Entity::Player::eventPlay ),
"eventPlay" );
m_pChaiHandler->add(
chaiscript::fun< void, Entity::Player, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, EventReturnCallback >(
&Entity::Player::eventPlay ),
"eventPlay" );
m_pChaiHandler->add( chaiscript::fun< void, Entity::Player, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t,
uint32_t, EventReturnCallback >( &Entity::Player::eventPlay ),
"eventPlay" );
m_pChaiHandler->add( chaiscript::fun< void, Entity::Player, uint32_t, uint32_t, uint32_t, EventReturnCallback >(
&Entity::Player::eventPlay ),
"eventPlay" );
m_pChaiHandler->add(
chaiscript::fun< void, Entity::Player, uint32_t, uint32_t, uint32_t >( &Entity::Player::eventPlay ),
"eventPlay" );
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::eventActionStart ), "eventActionStart" );
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::eventItemActionStart ), "eventItemActionStart" );
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::changePosition ), "changePos" );
@ -172,7 +184,8 @@ int Core::Scripting::ScriptManager::init()
std::set< std::string > chaiFiles;
loadDir( g_serverZone.getConfig()->getValue< std::string >( "Settings.General.ScriptPath", "../scripts/chai" ), chaiFiles );
loadDir( g_serverZone.getConfig()->getValue< std::string >( "Settings.General.ScriptPath", "../scripts/chai" ),
chaiFiles );
uint16_t scriptCount = 0;
uint16_t errorCount = 0;
@ -190,18 +203,14 @@ int Core::Scripting::ScriptManager::init()
g_log.Log( LoggingSeverity::error, e.what() );
errorCount++;
}
}
g_log.info( "\tloaded " + std::to_string( scriptCount ) +
" scripts, " + std::to_string( errorCount ) + " errors." );
g_log.info( "\tloaded " + std::to_string( scriptCount ) + " scripts, " + std::to_string( errorCount ) + " errors." );
std::function<std::string( Entity::Player& ) > f =
m_pChaiHandler->eval< std::function<std::string( Entity::Player& ) > >( "onFirstEnterWorld" );
std::function< std::string( Entity::Player& ) > f =
m_pChaiHandler->eval< std::function< std::string( Entity::Player& ) > >( "onFirstEnterWorld" );
m_onFirstEnterWorld = f;
return true;
}

View file

@ -1,22 +1,21 @@
#include "ServerZone.h"
#include <Server_Common/Version.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Config/XMLConfig.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Version.h>
#include <MySqlBase.h>
#include <Connection.h>
#include <MySqlBase.h>
#include <Server_Common/Network/Connection.h>
#include <Server_Common/Network/Hive.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Network/PacketContainer.h>
#include <Server_Common/Database/DbLoader.h>
#include <Server_Common/Database/CharaDbConnection.h>
#include <Server_Common/Database/DbLoader.h>
#include <Server_Common/Database/DbWorkerPool.h>
#include <Server_Common/Database/PreparedStatement.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Network/PacketContainer.h>
#include "Network/GameConnection.h"
#include "Session.h"
@ -25,13 +24,13 @@
#include "DebugCommand/DebugCommandHandler.h"
#include "Script/ScriptManager.h"
#include "Linkshell/LinkshellMgr.h"
#include "Script/ScriptManager.h"
#include "Forwards.h"
#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
#include <boost/make_shared.hpp>
#include <boost/algorithm/string.hpp>
#include <thread>
Core::Logger g_log;
@ -42,8 +41,8 @@ Core::ZoneMgr g_zoneMgr;
Core::LinkshellMgr g_linkshellMgr;
Core::Db::DbWorkerPool< Core::Db::CharaDbConnection > g_charaDb;
Core::ServerZone::ServerZone( const std::string& configPath )
: m_configPath( configPath ),
Core::ServerZone::ServerZone( const std::string& configPath ) :
m_configPath( configPath ),
m_bRunning( true ),
m_lastDBPingTime( 0 )
{
@ -64,8 +63,8 @@ size_t Core::ServerZone::getSessionCount() const
return m_sessionMapById.size();
}
bool Core::ServerZone::registerBnpcTemplate( std::string templateName, uint32_t bnpcBaseId,
uint32_t bnpcNameId, uint32_t modelId, std::string aiName )
bool Core::ServerZone::registerBnpcTemplate( std::string templateName, uint32_t bnpcBaseId, uint32_t bnpcNameId,
uint32_t modelId, std::string aiName )
{
auto it = m_bnpcTemplates.find( templateName );
@ -76,7 +75,8 @@ bool Core::ServerZone::registerBnpcTemplate( std::string templateName, uint32_t
return false;
}
Entity::BattleNpcTemplatePtr pNpcTemplate( new Entity::BattleNpcTemplate( templateName, bnpcBaseId, bnpcNameId, modelId, aiName ) );
Entity::BattleNpcTemplatePtr pNpcTemplate(
new Entity::BattleNpcTemplate( templateName, bnpcBaseId, bnpcNameId, modelId, aiName ) );
m_bnpcTemplates[templateName] = pNpcTemplate;
return true;
@ -86,7 +86,7 @@ Core::Entity::BattleNpcTemplatePtr Core::ServerZone::getBnpcTemplate( std::strin
{
auto it = m_bnpcTemplates.find( templateName );
if (it != m_bnpcTemplates.end())
if( it != m_bnpcTemplates.end() )
return nullptr;
return it->second;
@ -102,7 +102,7 @@ bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] )
return false;
}
std::vector<std::string> args( argv + 1, argv + argc );
std::vector< std::string > args( argv + 1, argv + argc );
for( uint32_t i = 0; i + 1 < args.size(); i += 2 )
{
std::string arg( "" );
@ -239,12 +239,11 @@ void Core::ServerZone::run( int32_t argc, char* argv[] )
{
thread_entry.join();
}
}
void Core::ServerZone::printBanner() const
{
g_log.info("===========================================================" );
g_log.info( "===========================================================" );
g_log.info( "Sapphire Server Project " );
g_log.info( "Version: " + Version::VERSION );
g_log.info( "Git Hash: " + Version::GIT_HASH );
@ -273,7 +272,6 @@ void Core::ServerZone::mainLoop()
// else do it here.
if( !session->getPlayer()->getCurrentZone() )
session->update();
}
}
@ -283,7 +281,6 @@ void Core::ServerZone::mainLoop()
m_lastDBPingTime = currTime;
}
auto it = this->m_sessionMapById.begin();
for( ; it != this->m_sessionMapById.end(); )
{
@ -297,7 +294,7 @@ void Core::ServerZone::mainLoop()
it->second->close();
// if( it->second.unique() )
{
g_log.info("[" + std::to_string(it->second->getId() ) + "] Session removal" );
g_log.info( "[" + std::to_string( it->second->getId() ) + "] Session removal" );
it = this->m_sessionMapById.erase( it );
removeSession( pPlayer->getName() );
continue;
@ -307,7 +304,7 @@ void Core::ServerZone::mainLoop()
// remove sessions that simply timed out
if( diff > 20 )
{
g_log.info("[" + std::to_string(it->second->getId() ) + "] Session time out" );
g_log.info( "[" + std::to_string( it->second->getId() ) + "] Session time out" );
it->second->close();
// if( it->second.unique() )
{
@ -319,9 +316,7 @@ void Core::ServerZone::mainLoop()
{
++it;
}
}
}
}
@ -341,7 +336,7 @@ bool Core::ServerZone::createSession( uint32_t sessionId )
g_log.info( "[" + session_id_str + "] Creating new session" );
boost::shared_ptr<Session> newSession( new Session( sessionId ) );
boost::shared_ptr< Session > newSession( new Session( sessionId ) );
m_sessionMapById[sessionId] = newSession;
if( !newSession->loadPlayer() )
@ -353,7 +348,6 @@ bool Core::ServerZone::createSession( uint32_t sessionId )
m_sessionMapByName[newSession->getPlayer()->getName()] = newSession;
return true;
}
void Core::ServerZone::removeSession( uint32_t sessionId )
@ -372,7 +366,7 @@ void Core::ServerZone::updateSession( uint32_t id )
Core::SessionPtr Core::ServerZone::getSession( uint32_t id )
{
//std::lock_guard<std::mutex> lock( m_sessionMutex );
// std::lock_guard<std::mutex> lock( m_sessionMutex );
auto it = m_sessionMapById.find( id );
@ -384,12 +378,12 @@ Core::SessionPtr Core::ServerZone::getSession( uint32_t id )
Core::SessionPtr Core::ServerZone::getSession( std::string playerName )
{
//std::lock_guard<std::mutex> lock( m_sessionMutex );
// std::lock_guard<std::mutex> lock( m_sessionMutex );
auto it = m_sessionMapByName.find( playerName );
if (it != m_sessionMapByName.end())
return (it->second);
if( it != m_sessionMapByName.end() )
return ( it->second );
return nullptr;
}
@ -412,4 +406,3 @@ bool Core::ServerZone::isRunning() const
{
return m_bRunning;
}

View file

@ -4,17 +4,17 @@
#include <Server_Common/Common.h>
#include <boost/shared_ptr.hpp>
#include <mutex>
#include <map>
#include <mutex>
#include "Forwards.h"
#include "Actor/BattleNpcTemplate.h"
#include "Forwards.h"
namespace Core {
class ServerZone
{
public:
class ServerZone
{
public:
ServerZone( const std::string& configPath );
~ServerZone();
@ -35,8 +35,8 @@ namespace Core {
size_t getSessionCount() const;
bool registerBnpcTemplate( std::string templateName, uint32_t bnpcBaseId,
uint32_t bnpcNameId, uint32_t modelId, std::string aiName );
bool registerBnpcTemplate( std::string templateName, uint32_t bnpcBaseId, uint32_t bnpcNameId, uint32_t modelId,
std::string aiName );
Entity::BattleNpcTemplatePtr getBnpcTemplate( std::string templateName );
@ -46,9 +46,7 @@ namespace Core {
void printBanner() const;
private:
private:
uint16_t m_port;
std::string m_ip;
uint32_t m_lastDBPingTime;
@ -67,10 +65,8 @@ namespace Core {
std::map< uint32_t, uint32_t > m_zones;
std::map< std::string, Entity::BattleNpcTemplatePtr > m_bnpcTemplates;
};
};
}
} // namespace Core
#endif

View file

@ -1,22 +1,21 @@
#include <time.h>
#include <Server_Common/Util/Util.h>
#include <Server_Common/Network/PacketContainer.h>
#include "Network/GameConnection.h"
#include "Session.h"
#include <Server_Common/Network/PacketContainer.h>
#include <Server_Common/Util/Util.h>
#include "Actor/Player.h"
Core::Session::Session( uint32_t sessionId )
: m_sessionId( sessionId )
, m_lastDataTime( static_cast< uint32_t >( Util::getTimeSeconds() ) )
, m_lastSqlTime( static_cast< uint32_t >( Util::getTimeSeconds() ) )
, m_isValid( false )
Core::Session::Session( uint32_t sessionId ) :
m_sessionId( sessionId ),
m_lastDataTime( static_cast< uint32_t >( Util::getTimeSeconds() ) ),
m_lastSqlTime( static_cast< uint32_t >( Util::getTimeSeconds() ) ),
m_isValid( false )
{
// boost::posix_time::ptime now = boost::date_time::not_a_date_time;
// now = boost::posix_time::microsec_clock::universal_time();
}
Core::Session::~Session()
@ -45,7 +44,6 @@ Core::Network::GameConnectionPtr Core::Session::getChatConnection() const
return m_pChatConnection;
}
bool Core::Session::loadPlayer()
{
@ -60,7 +58,6 @@ bool Core::Session::loadPlayer()
m_isValid = true;
return true;
}
void Core::Session::close()
@ -130,11 +127,9 @@ void Core::Session::update()
m_pChatConnection->processInQueue();
m_pChatConnection->processOutQueue();
}
}
Core::Entity::PlayerPtr Core::Session::getPlayer() const
{
return m_pPlayer;
}

View file

@ -7,9 +7,9 @@
namespace Core {
class Session : public boost::enable_shared_from_this< Session >
{
public:
class Session : public boost::enable_shared_from_this< Session >
{
public:
Session( uint32_t sessionId );
~Session();
@ -38,7 +38,7 @@ namespace Core {
Entity::PlayerPtr getPlayer() const;
private:
private:
uint32_t m_sessionId;
Entity::PlayerPtr m_pPlayer;
@ -50,10 +50,8 @@ namespace Core {
Network::GameConnectionPtr m_pZoneConnection;
Network::GameConnectionPtr m_pChatConnection;
};
};
}
} // namespace Core
#endif

View file

@ -1,16 +1,15 @@
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Util/Util.h>
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include <Server_Common/Util/Util.h>
#include <boost/algorithm/string.hpp>
#include <algorithm>
#include <boost/algorithm/string.hpp>
#include "Actor/Actor.h"
#include "StatusEffect.h"
#include "Script/ScriptManager.h"
#include "StatusEffect.h"
extern Core::Logger g_log;
extern Core::Data::ExdData g_exdData;
@ -20,16 +19,15 @@ using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server;
extern Core::Scripting::ScriptManager g_scriptMgr;
Core::StatusEffect::StatusEffect::StatusEffect( uint32_t id, Entity::ActorPtr sourceActor, Entity::ActorPtr targetActor,
uint32_t duration, uint32_t tickRate )
: m_id( id )
, m_sourceActor( sourceActor )
, m_targetActor( targetActor )
, m_duration( duration )
, m_startTime( 0 )
, m_tickRate( tickRate )
, m_lastTick( 0 )
uint32_t duration, uint32_t tickRate ) :
m_id( id ),
m_sourceActor( sourceActor ),
m_targetActor( targetActor ),
m_duration( duration ),
m_startTime( 0 ),
m_tickRate( tickRate ),
m_lastTick( 0 )
{
auto& entry = g_exdData.m_statusEffectInfoMap[id];
m_name = entry.name;
@ -45,7 +43,6 @@ Core::StatusEffect::StatusEffect::StatusEffect( uint32_t id, Entity::ActorPtr so
boost::erase_all( m_name, ")" );
}
Core::StatusEffect::StatusEffect::~StatusEffect()
{
}
@ -55,7 +52,7 @@ void Core::StatusEffect::StatusEffect::registerTickEffect( uint8_t type, uint32_
m_currTickEffect = std::make_pair( type, param );
}
std::pair< uint8_t, uint32_t> Core::StatusEffect::StatusEffect::getTickEffect()
std::pair< uint8_t, uint32_t > Core::StatusEffect::StatusEffect::getTickEffect()
{
auto thisTick = m_currTickEffect;
m_currTickEffect = std::make_pair( 0, 0 );
@ -90,20 +87,20 @@ void Core::StatusEffect::StatusEffect::applyStatus()
// this is only right when an action is being used by the player
// else you probably need to use an actorcontrol
//GamePacketNew< FFXIVIpcEffect > effectPacket( m_sourceActor->getId() );
//effectPacket.data().targetId = m_sourceActor->getId();
//effectPacket.data().actionAnimationId = 3;
//effectPacket.data().unknown_3 = 1;
//effectPacket.data().actionTextId = 3;
//effectPacket.data().unknown_5 = 1;
//effectPacket.data().unknown_6 = 321;
//effectPacket.data().rotation = ( uint16_t ) ( 0x8000 * ( ( m_sourceActor->getPos().getR() + 3.1415926 ) ) / 3.1415926 );
//effectPacket.data().effectTargetId = m_sourceActor->getId();
//effectPacket.data().effects[4].unknown_1 = 17;
//effectPacket.data().effects[4].bonusPercent = 30;
//effectPacket.data().effects[4].param1 = m_id;
//effectPacket.data().effects[4].unknown_5 = 0x80;
//m_sourceActor->sendToInRangeSet( effectPacket, true );
// GamePacketNew< FFXIVIpcEffect > effectPacket( m_sourceActor->getId() );
// effectPacket.data().targetId = m_sourceActor->getId();
// effectPacket.data().actionAnimationId = 3;
// effectPacket.data().unknown_3 = 1;
// effectPacket.data().actionTextId = 3;
// effectPacket.data().unknown_5 = 1;
// effectPacket.data().unknown_6 = 321;
// effectPacket.data().rotation = ( uint16_t ) ( 0x8000 * ( ( m_sourceActor->getPos().getR() + 3.1415926 ) )
// / 3.1415926 ); effectPacket.data().effectTargetId = m_sourceActor->getId();
// effectPacket.data().effects[4].unknown_1 = 17;
// effectPacket.data().effects[4].bonusPercent = 30;
// effectPacket.data().effects[4].param1 = m_id;
// effectPacket.data().effects[4].unknown_5 = 0x80;
// m_sourceActor->sendToInRangeSet( effectPacket, true );
g_log.debug( "StatusEffect applied: " + m_name );
g_scriptMgr.onStatusReceive( m_targetActor, m_id );

View file

@ -5,17 +5,14 @@
#include "Forwards.h"
namespace Core
{
namespace StatusEffect
{
namespace Core {
namespace StatusEffect {
class StatusEffect
{
public:
StatusEffect( uint32_t id, Entity::ActorPtr sourceActor, Entity::ActorPtr targetActor,
uint32_t duration, uint32_t tickRate );
class StatusEffect
{
public:
StatusEffect( uint32_t id, Entity::ActorPtr sourceActor, Entity::ActorPtr targetActor, uint32_t duration,
uint32_t tickRate );
~StatusEffect();
@ -34,10 +31,10 @@ public:
void setLastTick( uint64_t lastTick );
void setParam( uint16_t param );
void registerTickEffect( uint8_t type, uint32_t param );
std::pair< uint8_t, uint32_t> getTickEffect();
std::pair< uint8_t, uint32_t > getTickEffect();
const std::string& getName() const;
private:
private:
uint32_t m_id;
Entity::ActorPtr m_sourceActor;
Entity::ActorPtr m_targetActor;
@ -47,11 +44,10 @@ private:
uint64_t m_lastTick;
uint16_t m_param;
std::string m_name;
std::pair< uint8_t, uint32_t> m_currTickEffect;
std::pair< uint8_t, uint32_t > m_currTickEffect;
};
};
}
}
} // namespace StatusEffect
} // namespace Core
#endif

View file

@ -5,167 +5,149 @@
#include "Forwards.h"
#include "Zone.h"
// TODO: the entire zone / areahandling is a bit outdated ( in parts i used this for the 1.0 iteration )
// likely this could be greatly improved or redone
namespace Core
namespace Core {
Cell::Cell() : m_bActive( false ), m_bLoaded( false ), m_playerCount( 0 ), m_bUnloadPending( false )
{
Cell::Cell()
: m_bActive(false)
, m_bLoaded(false)
, m_playerCount(0)
, m_bUnloadPending(false)
{
m_bForcedActive = false;
}
}
Cell::~Cell()
{
Cell::~Cell()
{
removeActors();
}
}
void Cell::init(uint32_t x, uint32_t y, ZonePtr pZone)
{
//Console->outDebOnly("[Region:%X] Initializing a new cell[%i/%i]", pRegion->getId(), x, y );
void Cell::init( uint32_t x, uint32_t y, ZonePtr pZone )
{
// Console->outDebOnly("[Region:%X] Initializing a new cell[%i/%i]", pRegion->getId(), x, y );
m_pZone = pZone;
m_posX = x;
m_posY = y;
m_actors.clear();
}
}
void Cell::loadActors(CellCache* pCC)
{
void Cell::loadActors( CellCache* pCC )
{
m_bLoaded = true;
assert(pCC);
assert( pCC );
for( auto entry : pCC->battleNpcCache )
{
entry->setCurrentZone( m_pZone );
m_pZone->pushActor( entry );
}
}
}
void Cell::addActor(Entity::ActorPtr pAct)
void Cell::addActor( Entity::ActorPtr pAct )
{
if( pAct->isPlayer() )
{
if(pAct->isPlayer())
{
//Console->outDebOnly("[Region:%X] Adding player %i to cell[%i/%i]", m_pZone->getId(), pAct->getId(), m_posX, m_posY);
// Console->outDebOnly("[Region:%X] Adding player %i to cell[%i/%i]", m_pZone->getId(), pAct->getId(), m_posX,
// m_posY);
++m_playerCount;
}
m_actors.insert(pAct);
}
m_actors.insert( pAct );
}
void Cell::removeActor(Entity::ActorPtr pAct)
void Cell::removeActor( Entity::ActorPtr pAct )
{
if( pAct->isPlayer() )
{
if(pAct->isPlayer())
{
//->outDebOnly("[Region:%X] Removing player %i from cell[%i/%i]", m_pZone->getId(), pAct->getId(), m_posX, m_posY);
//->outDebOnly("[Region:%X] Removing player %i from cell[%i/%i]", m_pZone->getId(), pAct->getId(), m_posX,
// m_posY);
--m_playerCount;
}
m_actors.erase(pAct);
}
m_actors.erase( pAct );
}
void Cell::setActivity(bool state)
{
if(!m_bActive && state)
void Cell::setActivity( bool state )
{
if( !m_bActive && state )
{
// Move all objects to active set.
for(auto itr = m_actors.begin(); itr != m_actors.end(); ++itr)
for( auto itr = m_actors.begin(); itr != m_actors.end(); ++itr )
{
}
if(m_bUnloadPending)
if( m_bUnloadPending )
{
cancelPendingUnload();
}
}
else if(m_bActive && !state)
else if( m_bActive && !state )
{
// Move all objects from active set.
for(auto itr = m_actors.begin(); itr != m_actors.end(); ++itr)
for( auto itr = m_actors.begin(); itr != m_actors.end(); ++itr )
{
}
}
m_bActive = state;
}
void Cell::removeActors()
{
//uint32_t ltime = getMSTime();
}
void Cell::removeActors()
{
// uint32_t ltime = getMSTime();
m_actors.clear();
//This time it's simpler! We just remove everything
Entity::ActorPtr pAct; //do this outside the loop!
for(auto itr = m_actors.begin(); itr != m_actors.end();)
// This time it's simpler! We just remove everything
Entity::ActorPtr pAct; // do this outside the loop!
for( auto itr = m_actors.begin(); itr != m_actors.end(); )
{
pAct = (*itr);
pAct = ( *itr );
itr++;
if(!pAct)
if( !pAct )
{
continue;
}
if(m_bUnloadPending)
if( m_bUnloadPending )
{
}
}
m_playerCount = 0;
m_bLoaded = false;
}
}
void Cell::queueUnloadPending()
{
if(m_bUnloadPending)
void Cell::queueUnloadPending()
{
if( m_bUnloadPending )
{
return;
}
m_bUnloadPending = true;
}
}
void Cell::cancelPendingUnload()
{
void Cell::cancelPendingUnload()
{
if(!m_bUnloadPending)
if( !m_bUnloadPending )
{
return;
}
}
}
void Cell::unload()
{
void Cell::unload()
{
assert(m_bUnloadPending);
if(m_bActive)
assert( m_bUnloadPending );
if( m_bActive )
{
return;
}
removeActors();
m_bUnloadPending = false;
}
}
} // namespace Core

View file

@ -9,19 +9,18 @@
namespace Core {
struct CellCache
{
struct CellCache
{
std::vector< Entity::BattleNpcPtr > battleNpcCache;
};
};
typedef std::set< Entity::ActorPtr > ActorSet;
typedef std::set< Entity::ActorPtr > ActorSet;
class Cell
{
class Cell
{
friend class Zone;
private:
private:
bool m_bForcedActive;
uint16_t m_posX;
uint16_t m_posY;
@ -33,96 +32,54 @@ namespace Core {
uint16_t m_playerCount;
ZonePtr m_pZone;
public:
public:
Cell();
~Cell();
void init(uint32_t x, uint32_t y, ZonePtr pZone);
void init( uint32_t x, uint32_t y, ZonePtr pZone );
void addActor(Entity::ActorPtr pAct);
void addActor( Entity::ActorPtr pAct );
void removeActor(Entity::ActorPtr pAct);
void removeActor( Entity::ActorPtr pAct );
void loadActors(CellCache* pCC);
void loadActors( CellCache* pCC );
bool hasActor(Entity::ActorPtr pAct)
{
return (m_actors.find(pAct) != m_actors.end());
}
bool hasActor( Entity::ActorPtr pAct ) { return ( m_actors.find( pAct ) != m_actors.end() ); }
bool hasPlayers() const
{
return ((m_playerCount > 0) ? true : false);
}
bool hasPlayers() const { return ( ( m_playerCount > 0 ) ? true : false ); }
size_t getActorCount() const
{
return m_actors.size();
}
size_t getActorCount() const { return m_actors.size(); }
void removeActors();
ActorSet::iterator begin()
{
return m_actors.begin();
}
ActorSet::iterator begin() { return m_actors.begin(); }
ActorSet::iterator end()
{
return m_actors.end();
}
ActorSet::iterator end() { return m_actors.end(); }
void setActivity(bool state);
void setActivity( bool state );
bool isActive() const
{
return m_bActive;
}
bool isActive() const { return m_bActive; }
bool isLoaded() const
{
return m_bLoaded;
}
bool isLoaded() const { return m_bLoaded; }
uint32_t getPlayerCount() const
{
return m_playerCount;
}
uint32_t getPlayerCount() const { return m_playerCount; }
bool isUnloadPending() const
{
return m_bUnloadPending;
}
bool isUnloadPending() const { return m_bUnloadPending; }
void setUnloadPending(bool up)
{
m_bUnloadPending = up;
}
void setUnloadPending( bool up ) { m_bUnloadPending = up; }
void queueUnloadPending();
void cancelPendingUnload();
void unload();
void setPermanentActivity(bool val)
{
m_bForcedActive = val;
}
void setPermanentActivity( bool val ) { m_bForcedActive = val; }
bool isForcedActive() const
{
return m_bForcedActive;
}
bool isForcedActive() const { return m_bForcedActive; }
uint16_t getPosX() const
{
return m_posX;
}
uint16_t getPosX() const { return m_posX; }
uint16_t getPosY() const
{
return m_posY;
}
};
uint16_t getPosY() const { return m_posY; }
};
}
} // namespace Core
#endif

View file

@ -3,23 +3,23 @@
#define TilesCount 32
#define TileSize 250.0f
#define _minY (-TilesCount*TileSize/2)
#define _minX (-TilesCount*TileSize/2)
#define _minY ( -TilesCount * TileSize / 2 )
#define _minX ( -TilesCount * TileSize / 2 )
#define _maxY (TilesCount*TileSize/2)
#define _maxX (TilesCount*TileSize/2)
#define _maxY ( TilesCount * TileSize / 2 )
#define _maxX ( TilesCount * TileSize / 2 )
#define CellsPerTile 4
#define _cellSize (TileSize/CellsPerTile)
#define _sizeX (TilesCount*CellsPerTile)
#define _sizeY (TilesCount*CellsPerTile)
#define _cellSize ( TileSize / CellsPerTile )
#define _sizeX ( TilesCount * CellsPerTile )
#define _sizeY ( TilesCount * CellsPerTile )
#define GetRelatCoord(Coord,CellCoord) ((_maxX-Coord)-CellCoord*_cellSize)
#define GetRelatCoord( Coord, CellCoord ) ( ( _maxX - Coord ) - CellCoord * _cellSize )
namespace Core {
class Zone;
template<class T>
template< class T >
class CellHandler
{
public:
@ -32,10 +32,7 @@ public:
T* createByCoords( float x, float y );
void remove( uint32_t x, uint32_t y );
bool allocated( uint32_t x, uint32_t y )
{
return m_pCells[x][y] != nullptr;
}
bool allocated( uint32_t x, uint32_t y ) { return m_pCells[x][y] != nullptr; }
static uint32_t getPosX( float x );
static uint32_t getPosY( float y );
@ -43,21 +40,18 @@ public:
protected:
void _init();
T *** m_pCells;
T*** m_pCells;
};
template <class T>
CellHandler<T>::CellHandler()
template< class T >
CellHandler< T >::CellHandler()
{
_init();
}
template <class T>
void CellHandler<T>::_init()
template< class T >
void CellHandler< T >::_init()
{
m_pCells = new T**[_sizeX];
@ -66,11 +60,10 @@ void CellHandler<T>::_init()
{
m_pCells[i] = nullptr;
}
}
template <class T>
CellHandler<T>::~CellHandler()
template< class T >
CellHandler< T >::~CellHandler()
{
if( m_pCells )
{
@ -94,8 +87,8 @@ CellHandler<T>::~CellHandler()
}
}
template <class T>
T* CellHandler<T>::create( uint32_t x, uint32_t y )
template< class T >
T* CellHandler< T >::create( uint32_t x, uint32_t y )
{
if( x >= _sizeX || y >= _sizeY )
{
@ -105,25 +98,25 @@ T* CellHandler<T>::create( uint32_t x, uint32_t y )
if( !m_pCells[x] )
{
m_pCells[x] = new T*[_sizeY];
memset( m_pCells[x], 0, sizeof( T* )*_sizeY );
memset( m_pCells[x], 0, sizeof( T* ) * _sizeY );
}
assert( m_pCells[x][y] == nullptr );
T *cls = new T;
T* cls = new T;
m_pCells[x][y] = cls;
return cls;
}
template <class T>
T* CellHandler<T>::createByCoords( float x, float y )
template< class T >
T* CellHandler< T >::createByCoords( float x, float y )
{
return create( getPosX( x ), getPosY( y ) );
}
template <class T>
void CellHandler<T>::remove( uint32_t x, uint32_t y )
template< class T >
void CellHandler< T >::remove( uint32_t x, uint32_t y )
{
if( x >= _sizeX || y >= _sizeY )
{
@ -137,14 +130,14 @@ void CellHandler<T>::remove( uint32_t x, uint32_t y )
assert( m_pCells[x][y] != nullptr );
T *cls = m_pCells[x][y];
T* cls = m_pCells[x][y];
m_pCells[x][y] = nullptr;
delete cls;
}
template <class T>
T* CellHandler<T>::getCell( uint32_t x, uint32_t y )
template< class T >
T* CellHandler< T >::getCell( uint32_t x, uint32_t y )
{
if( !m_pCells[x] )
{
@ -154,25 +147,25 @@ T* CellHandler<T>::getCell( uint32_t x, uint32_t y )
return m_pCells[x][y];
}
template <class T>
T* CellHandler<T>::getCellByCoords( float x, float y )
template< class T >
T* CellHandler< T >::getCellByCoords( float x, float y )
{
return getCell( getPosX( x ), getPosY( y ) );
}
template <class T>
uint32_t CellHandler<T>::getPosX( float x )
template< class T >
uint32_t CellHandler< T >::getPosX( float x )
{
assert( ( x >= _minX ) && ( x <= _maxX ) );
return ( uint32_t ) ( ( _maxX - x ) / _cellSize );
return ( uint32_t )( ( _maxX - x ) / _cellSize );
}
template <class T>
uint32_t CellHandler<T>::getPosY( float y )
template< class T >
uint32_t CellHandler< T >::getPosY( float y )
{
assert( ( y >= _minY ) && ( y <= _maxY ) );
return ( uint32_t ) ( ( _maxY - y ) / _cellSize );
return ( uint32_t )( ( _maxY - y ) / _cellSize );
}
}
} // namespace Core
#endif

View file

@ -1,30 +1,30 @@
#include <stdio.h>
#include <vector>
#include <Server_Common/Database/DatabaseDef.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Util/Util.h>
#include <Server_Common/Util/UtilMath.h>
#include <Server_Common/Network/CommonNetwork.h>
#include <Server_Common/Network/GamePacket.h>
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Network/CommonNetwork.h>
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include <Server_Common/Network/PacketContainer.h>
#include <Server_Common/Database/DatabaseDef.h>
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include <Server_Common/Util/Util.h>
#include <Server_Common/Util/UtilMath.h>
#include "Zone.h"
#include "ZoneMgr.h"
#include "Session.h"
#include "Actor/Actor.h"
#include "Actor/Player.h"
#include "Actor/BattleNpc.h"
#include "Actor/Player.h"
#include "Session.h"
#include "Forwards.h"
#include "Network/GameConnection.h"
#include "ServerZone.h"
#include "Script/ScriptManager.h"
#include "ServerZone.h"
#include "CellHandler.h"
@ -38,22 +38,22 @@ extern Core::Scripting::ScriptManager g_scriptMgr;
namespace Core {
/**
* \brief
*/
Zone::Zone()
: m_zoneId( 0 )
, m_layoutId( 0 )
, m_bPrivate( false )
, m_type( Common::RegionType::normal )
, m_currentWeather( static_cast< uint8_t >( Common::Weather::FairSkies ) )
, m_weatherOverride( 0 )
, m_lastMobUpdate( 0 )
* \brief
*/
Zone::Zone() :
m_zoneId( 0 ),
m_layoutId( 0 ),
m_bPrivate( false ),
m_type( Common::RegionType::normal ),
m_currentWeather( static_cast< uint8_t >( Common::Weather::FairSkies ) ),
m_weatherOverride( 0 ),
m_lastMobUpdate( 0 )
{
}
Zone::Zone( uint16_t zoneId, uint32_t layoutId, std::string name, std::string interName, bool bPrivate = false )
: m_type( Common::RegionType::normal )
, m_currentWeather( static_cast< uint8_t >( Common::Weather::FairSkies ) )
Zone::Zone( uint16_t zoneId, uint32_t layoutId, std::string name, std::string interName, bool bPrivate = false ) :
m_type( Common::RegionType::normal ),
m_currentWeather( static_cast< uint8_t >( Common::Weather::FairSkies ) )
{
m_layoutId = layoutId;
@ -117,12 +117,12 @@ CellCache* Zone::getCellCacheAndCreate( uint32_t cellx, uint32_t celly )
if( m_pCellCache[cellx] == nullptr )
{
m_pCellCache[cellx] = new CellCache*[_sizeY];
memset(m_pCellCache[cellx], 0, sizeof( CellCache* ) * _sizeY);
memset( m_pCellCache[cellx], 0, sizeof( CellCache* ) * _sizeY );
}
if( m_pCellCache[cellx][celly] == nullptr )
{
//m_pCellCache[cellx][celly] = new CellCache;
// m_pCellCache[cellx][celly] = new CellCache;
}
return m_pCellCache[cellx][celly];
@ -150,7 +150,8 @@ void Zone::loadCellCache()
"Look,"
"Models,"
"type "
"FROM battlenpc WHERE ZoneId = " + std::to_string( getId() ) + ";" );
"FROM battlenpc WHERE ZoneId = " +
std::to_string( getId() ) + ";" );
std::vector< Entity::BattleNpcPtr > cache;
@ -179,14 +180,12 @@ void Zone::loadCellCache()
pos.x = posX;
pos.y = posY;
pos.z = posZ;
Entity::BattleNpcPtr pBNpc( new Entity::BattleNpc( modelId, nameId, pos,
sizeId, type, level, behaviour, mobType ) );
Entity::BattleNpcPtr pBNpc(
new Entity::BattleNpc( modelId, nameId, pos, sizeId, type, level, behaviour, mobType ) );
pBNpc->setRotation( static_cast< float >( rotation ) );
cache.push_back( pBNpc );
}
for( auto entry : cache )
{
// get cell position
@ -206,12 +205,11 @@ void Zone::loadCellCache()
// add the populace cache object to the cells list
m_pCellCache[cellX][cellY]->battleNpcCache.push_back( entry );
}
}
uint8_t Zone::getNextWeather()
{
auto zoneInfo = g_exdData.m_zoneInfoMap[ getLayoutId() ];
auto zoneInfo = g_exdData.m_zoneInfoMap[getLayoutId()];
uint32_t unixTime = static_cast< uint32_t >( time( nullptr ) );
// Get Eorzea hour for weather start
@ -227,7 +225,7 @@ uint8_t Zone::getNextWeather()
uint32_t step1 = ( calcBase << 0xB ) ^ calcBase;
uint32_t step2 = ( step1 >> 8 ) ^ step1;
uint8_t rate = static_cast< uint8_t >(step2 % 0x64);
uint8_t rate = static_cast< uint8_t >( step2 % 0x64 );
for( auto entry : zoneInfo.weather_rate_map )
{
@ -288,7 +286,6 @@ void Zone::pushActor( Entity::ActorPtr pActor )
m_sessionSet.insert( pSession );
m_playerMap[pPlayer->getId()] = pPlayer;
updateCellActivity( cx, cy, 2 );
}
else if( pActor->isMob() )
{
@ -296,9 +293,7 @@ void Zone::pushActor( Entity::ActorPtr pActor )
Entity::BattleNpcPtr pBNpc = pActor->getAsBattleNpc();
m_BattleNpcMap[pBNpc->getId()] = pBNpc;
pBNpc->setPosition( pBNpc->getPos() );
}
}
void Zone::removeActor( Entity::ActorPtr pActor )
@ -315,15 +310,14 @@ void Zone::removeActor( Entity::ActorPtr pActor )
g_log.debug( "[Zone:" + m_zoneCode + "] Removing player [" + std::to_string( pActor->getId() ) + "]" );
// If it's a player and he's inside boundaries - update his nearby cells
if( pActor->getPos().x <= _maxX && pActor->getPos().x >= _minX &&
pActor->getPos().z <= _maxY && pActor->getPos().z >= _minY )
if( pActor->getPos().x <= _maxX && pActor->getPos().x >= _minX && pActor->getPos().z <= _maxY &&
pActor->getPos().z >= _minY )
{
uint32_t x = getPosX( pActor->getPos().x );
uint32_t y = getPosY( pActor->getPos().z );
updateCellActivity( x, y, 3 );
}
m_playerMap.erase( pActor->getId() );
}
else if( pActor->isMob() )
m_BattleNpcMap.erase( pActor->getId() );
@ -341,19 +335,16 @@ void Zone::removeActor( Entity::ActorPtr pActor )
}
}
pActor->clearInRangeSet();
}
void Zone::queueOutPacketForRange( Entity::Player& sourcePlayer, uint32_t range, Network::Packets::GamePacketPtr pPacketEntry )
void Zone::queueOutPacketForRange( Entity::Player& sourcePlayer, uint32_t range,
Network::Packets::GamePacketPtr pPacketEntry )
{
for( auto it = m_playerMap.begin(); it != m_playerMap.end(); ++it )
{
float distance = Math::Util::distance( sourcePlayer.getPos().x,
sourcePlayer.getPos().y,
sourcePlayer.getPos().z,
( *it ).second->getPos().x,
( *it ).second->getPos().y,
( *it ).second->getPos().z );
float distance =
Math::Util::distance( sourcePlayer.getPos().x, sourcePlayer.getPos().y, sourcePlayer.getPos().z,
( *it ).second->getPos().x, ( *it ).second->getPos().y, ( *it ).second->getPos().z );
if( ( distance < range ) && sourcePlayer.getId() != ( *it ).second->getId() )
{
@ -402,9 +393,9 @@ std::size_t Zone::getPopCount() const
bool Zone::checkWeather()
{
if ( m_weatherOverride != 0 )
if( m_weatherOverride != 0 )
{
if ( m_weatherOverride != m_currentWeather )
if( m_weatherOverride != m_currentWeather )
{
m_currentWeather = m_weatherOverride;
g_log.debug( "[Zone:" + m_zoneCode + "] overriding weather to : " + std::to_string( m_weatherOverride ) );
@ -414,7 +405,7 @@ bool Zone::checkWeather()
else
{
auto nextWeather = getNextWeather();
if ( nextWeather != m_currentWeather )
if( nextWeather != m_currentWeather )
{
m_currentWeather = nextWeather;
g_log.debug( "[Zone:" + m_zoneCode + "] changing weather to : " + std::to_string( nextWeather ) );
@ -451,7 +442,6 @@ void Zone::updateBnpcs( int64_t tickCount )
}
}
for( auto entry : m_BattleNpcMap )
{
Entity::BattleNpcPtr pBNpc = entry.second;
@ -467,7 +457,6 @@ void Zone::updateBnpcs( int64_t tickCount )
}
pBNpc->update( tickCount );
}
}
}
@ -493,7 +482,8 @@ bool Zone::runZoneLogic()
}
// this session is not linked to this area anymore, remove it from zone session list
if( ( !pSession->getPlayer()->getCurrentZone() ) || ( pSession->getPlayer()->getCurrentZone() != shared_from_this() ) )
if( ( !pSession->getPlayer()->getCurrentZone() ) ||
( pSession->getPlayer()->getCurrentZone() != shared_from_this() ) )
{
g_log.debug( "[Zone:" + m_zoneCode + "] removing session " + std::to_string( pSession->getId() ) );
@ -506,8 +496,8 @@ bool Zone::runZoneLogic()
if( changedWeather )
{
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcWeatherChange >
weatherChangePacket( pSession->getPlayer()->getId() );
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcWeatherChange > weatherChangePacket(
pSession->getPlayer()->getId() );
weatherChangePacket.data().weatherId = m_currentWeather;
weatherChangePacket.data().delay = 5.0f;
pSession->getPlayer()->queuePacket( weatherChangePacket );
@ -576,21 +566,21 @@ void Zone::updateCellActivity( uint32_t x, uint32_t y, int32_t radius )
assert( !pCell->isLoaded() );
CellCache * pCC = getCellCacheAndCreate( posX, posY );
CellCache* pCC = getCellCacheAndCreate( posX, posY );
if( pCC )
pCell->loadActors( pCC );
}
}
else
{
//Cell is now active
// Cell is now active
if( isCellActive( posX, posY ) && !pCell->isActive() )
{
pCell->setActivity( true );
if( !pCell->isLoaded() )
{
CellCache * pCC = getCellCacheAndCreate( posX, posY );
CellCache* pCC = getCellCacheAndCreate( posX, posY );
if( pCC )
pCell->loadActors( pCC );
}
@ -613,17 +603,13 @@ void Zone::changeActorPosition( Entity::ActorPtr pActor )
Entity::ActorPtr pCurAct;
float fRange = 70.0f;
for( auto iter = pActor->m_inRangeActors.begin(); iter != pActor->m_inRangeActors.end();)
for( auto iter = pActor->m_inRangeActors.begin(); iter != pActor->m_inRangeActors.end(); )
{
pCurAct = *iter;
auto iter2 = iter++;
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 = Math::Util::distance( pCurAct->getPos().x, pCurAct->getPos().y, pCurAct->getPos().z,
pActor->getPos().x, pActor->getPos().y, pActor->getPos().z );
if( fRange > 0.0f && distance > fRange )
{
@ -676,8 +662,8 @@ void Zone::changeActorPosition( Entity::ActorPtr pActor )
if( pOldCell != nullptr )
{
// only do the second check if theres -/+ 2 difference
if( abs( ( int32_t ) cellX - ( int32_t ) pOldCell->m_posX ) > 2 ||
abs( ( int32_t ) cellY - ( int32_t ) pOldCell->m_posY ) > 2 )
if( abs( (int32_t)cellX - (int32_t)pOldCell->m_posX ) > 2 ||
abs( (int32_t)cellY - (int32_t)pOldCell->m_posY ) > 2 )
updateCellActivity( pOldCell->m_posX, pOldCell->m_posY, 2 );
}
}
@ -701,7 +687,6 @@ void Zone::changeActorPosition( Entity::ActorPtr pActor )
}
}
void Zone::updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell )
{
if( pCell == nullptr )
@ -721,12 +706,8 @@ void Zone::updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell )
if( !pCurAct )
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 = Math::Util::distance( pCurAct->getPos().x, pCurAct->getPos().y, pCurAct->getPos().z,
pActor->getPos().x, pActor->getPos().y, pActor->getPos().z );
// Add if we are not ourself and range == 0 or distance is withing range.
if( pCurAct != pActor && ( fRange == 0.0f || distance <= fRange ) )
@ -760,7 +741,6 @@ void Zone::updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell )
pActor->spawn( pPlayer );
}
}
else if( pActor->isMob() && pCurAct->isPlayer() && pActor->isAlive() )
{
@ -781,4 +761,4 @@ void Zone::updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell )
}
}
}
} // namespace Core

View file

@ -1,25 +1,24 @@
#ifndef _ZONE_H
#define _ZONE_H
#include <unordered_map>
#include <Server_Common/Common.h>
#include <unordered_map>
#include "Cell.h"
#include "CellHandler.h"
#include "Forwards.h"
#include <set>
#include <boost/enable_shared_from_this.hpp>
#include <set>
#include <stdio.h>
#include <string.h>
namespace Core {
namespace Entity
{
namespace Entity {
class Actor;
class Player;
}
} // namespace Entity
class Session;
@ -27,7 +26,9 @@ class ZonePosition;
typedef std::set< SessionPtr > SessionSet;
class Zone : public CellHandler< Cell >, public boost::enable_shared_from_this< Zone >
class Zone
: public CellHandler< Cell >
, public boost::enable_shared_from_this< Zone >
{
protected:
uint32_t m_zoneId;
@ -89,7 +90,8 @@ public:
void updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell );
void queueOutPacketForRange( Entity::Player& sourcePlayer, uint32_t range, Network::Packets::GamePacketPtr pPacketEntry );
void queueOutPacketForRange( Entity::Player& sourcePlayer, uint32_t range,
Network::Packets::GamePacketPtr pPacketEntry );
virtual uint32_t getId();
@ -108,9 +110,8 @@ public:
void updateBnpcs( int64_t tickCount );
bool runZoneLogic();
};
}
} // namespace Core
#endif

View file

@ -1,9 +1,9 @@
#include <src/servers/Server_Common/Logging/Logger.h>
#include <src/servers/Server_Common/Exd/ExdData.h>
#include <boost/lexical_cast.hpp>
#include <src/servers/Server_Common/Exd/ExdData.h>
#include <src/servers/Server_Common/Logging/Logger.h>
#include "ZoneMgr.h"
#include "Zone.h"
#include "ZoneMgr.h"
#include "ZonePosition.h"
#include <Server_Common/Database/DatabaseDef.h>
@ -13,12 +13,12 @@ extern Core::Data::ExdData g_exdData;
namespace Core {
ZoneMgr::ZoneMgr() = default;
ZoneMgr::ZoneMgr() = default;
ZoneMgr::~ZoneMgr() = default;
ZoneMgr::~ZoneMgr() = default;
void ZoneMgr::loadZonePositionMap()
{
void ZoneMgr::loadZonePositionMap()
{
auto pQR = g_charaDb.query( "SELECT id, target_zone_id, pos_x, pos_y, pos_z, pos_o, radius FROM zonepositions;" );
while( pQR->next() )
@ -34,20 +34,20 @@ namespace Core {
m_zonePositionMap[id] = ZonePositionPtr( new ZonePosition( id, targetZoneId, pos, radius, posO ) );
}
}
}
ZonePositionPtr ZoneMgr::getZonePosition( uint32_t zonePositionId )
{
ZonePositionPtr ZoneMgr::getZonePosition( uint32_t zonePositionId )
{
auto it = m_zonePositionMap.find( zonePositionId );
if( it != m_zonePositionMap.end() )
return it->second;
return nullptr;
}
}
bool ZoneMgr::createZones()
{
bool ZoneMgr::createZones()
{
loadZonePositionMap();
// find zone info from exd
@ -55,7 +55,6 @@ namespace Core {
{
uint32_t zoneId = zone.first;
auto info = zone.second;
g_log.Log( LoggingSeverity::info, std::to_string( info.id ) + "\t" + info.zone_str );
@ -65,18 +64,18 @@ namespace Core {
}
return true;
}
}
void ZoneMgr::updateZones()
{
void ZoneMgr::updateZones()
{
for( auto zone : m_zoneMap )
{
zone.second->runZoneLogic();
}
}
}
ZonePtr ZoneMgr::getZone( uint32_t zoneId )
{
ZonePtr ZoneMgr::getZone( uint32_t zoneId )
{
ZoneMap::iterator it;
it = m_zoneMap.find( zoneId );
@ -84,6 +83,6 @@ namespace Core {
return it->second;
return nullptr;
}
}
} // namespace Core

View file

@ -1,18 +1,17 @@
#ifndef _ZONEMGR_H
#define _ZONEMGR_H
#include <unordered_map>
#include <map>
#include "Forwards.h"
#include <map>
#include <unordered_map>
namespace Core {
using ZoneMap = std::unordered_map< uint32_t, ZonePtr >;
using ZoneMap = std::unordered_map< uint32_t, ZonePtr >;
class ZoneMgr
{
public:
class ZoneMgr
{
public:
ZoneMgr();
~ZoneMgr();
@ -26,14 +25,12 @@ namespace Core {
void updateZones();
private:
private:
ZoneMap m_zoneMap;
std::unordered_map<int32_t, ZonePositionPtr > m_zonePositionMap;
std::unordered_map< int32_t, ZonePositionPtr > m_zonePositionMap;
};
};
}
} // namespace Core
#endif

View file

@ -1,13 +1,11 @@
#include "ZonePosition.h"
Core::ZonePosition::ZonePosition()
: m_id(0)
, m_targetZoneId(0)
, m_radius(0)
Core::ZonePosition::ZonePosition() : m_id( 0 ), m_targetZoneId( 0 ), m_radius( 0 )
{
}
Core::ZonePosition::ZonePosition( uint32_t id, uint32_t targetZoneId, const Common::FFXIVARR_POSITION3& targetPosition, uint32_t radius, float rotation )
Core::ZonePosition::ZonePosition( uint32_t id, uint32_t targetZoneId, const Common::FFXIVARR_POSITION3& targetPosition,
uint32_t radius, float rotation )
{
m_id = id;
m_targetZoneId = targetZoneId;
@ -30,7 +28,7 @@ uint32_t Core::ZonePosition::getTargetZoneId() const
return m_targetZoneId;
}
const Core::Common::FFXIVARR_POSITION3 & Core::ZonePosition::getTargetPosition() const
const Core::Common::FFXIVARR_POSITION3& Core::ZonePosition::getTargetPosition() const
{
return m_targetPos;
}
@ -39,5 +37,3 @@ float Core::ZonePosition::getTargetRotation() const
{
return m_rotation;
}

View file

@ -16,7 +16,8 @@ protected:
public:
ZonePosition();
ZonePosition( uint32_t id, uint32_t targetZoneId, const Common::FFXIVARR_POSITION3& targetPosition, uint32_t radius, float rotation );
ZonePosition( uint32_t id, uint32_t targetZoneId, const Common::FFXIVARR_POSITION3& targetPosition, uint32_t radius,
float rotation );
virtual ~ZonePosition();
uint32_t getId() const;
@ -26,8 +27,7 @@ public:
const Common::FFXIVARR_POSITION3& getTargetPosition() const;
float getTargetRotation() const;
};
}
} // namespace Core
#endif