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> #include <Server_Common/Util/Util.h>
Core::Action::Action::Action() Core::Action::Action::Action()
{ {
} }
Core::Action::Action::~Action() Core::Action::Action::~Action()
{ {
} }
uint16_t Core::Action::Action::getId() const uint16_t Core::Action::Action::getId() const

View file

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

View file

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

View file

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

View file

@ -1,13 +1,13 @@
#include <Server_Common/Util/Util.h>
#include <Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Util/Util.h>
#include <Server_Common/Util/UtilMath.h> #include <Server_Common/Util/UtilMath.h>
#include "ActionCollision.h" #include "ActionCollision.h"
#include "Actor/Actor.h" #include "Actor/Actor.h"
#include "Actor/Player.h" #include "Actor/Player.h"
#include <cmath>
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include <cmath>
using namespace Core::Entity; using namespace Core::Entity;
using namespace Core::Common; using namespace Core::Common;
@ -51,8 +51,8 @@ bool ActionCollision::isActorApplicable( ActorPtr actorPtr, TargetFilter targetF
return ( actorApplicable && actorPtr->isAlive() ); return ( actorApplicable && actorPtr->isAlive() );
} }
std::set< Core::Entity::ActorPtr > ActionCollision::getActorsHitFromAction( FFXIVARR_POSITION3 aoePosition, std::set< Core::Entity::ActorPtr >
std::set< ActorPtr > actorsInRange, ActionCollision::getActorsHitFromAction( FFXIVARR_POSITION3 aoePosition, std::set< ActorPtr > actorsInRange,
boost::shared_ptr< Core::Data::ActionInfo > actionInfo, boost::shared_ptr< Core::Data::ActionInfo > actionInfo,
TargetFilter targetFilter ) TargetFilter targetFilter )
{ {
@ -124,16 +124,16 @@ std::set< Core::Entity::ActorPtr > ActionCollision::getActorsHitFromAction( FFXI
return actorsCollided; 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, return Core::Math::Util::distance( actorPosition.x, actorPosition.y, actorPosition.z, aoePosition.x, aoePosition.y,
aoePosition.x, aoePosition.y, aoePosition.z ) <= radius; 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 && return actorPosition.x < aoePosition.x + width && actorPosition.x > aoePosition.x &&
actorPosition.x > aoePosition.x && actorPosition.y < aoePosition.y + height && actorPosition.y > aoePosition.y;
actorPosition.y < aoePosition.y + height &&
actorPosition.y > aoePosition.y;
} }

View file

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

View file

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

View file

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

View file

@ -1,12 +1,12 @@
#include "ActionTeleport.h" #include "ActionTeleport.h"
#include <Server_Common/Util/Util.h>
#include <Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Logging/Logger.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/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Actor/Player.h"
using namespace Core::Common; using namespace Core::Common;
using namespace Core::Network; using namespace Core::Network;
@ -35,7 +35,6 @@ Core::Action::ActionTeleport::ActionTeleport( Entity::ActorPtr pActor, uint16_t
Core::Action::ActionTeleport::~ActionTeleport() Core::Action::ActionTeleport::~ActionTeleport()
{ {
} }
void Core::Action::ActionTeleport::onStart() void Core::Action::ActionTeleport::onStart()
@ -55,7 +54,6 @@ void Core::Action::ActionTeleport::onStart()
m_pSource->sendToInRangeSet( castPacket, true ); m_pSource->sendToInRangeSet( castPacket, true );
m_pSource->getAsPlayer()->setStateFlag( PlayerStateFlag::Casting ); m_pSource->getAsPlayer()->setStateFlag( PlayerStateFlag::Casting );
m_pSource->getAsPlayer()->sendStateFlags(); m_pSource->getAsPlayer()->sendStateFlags();
} }
void Core::Action::ActionTeleport::onFinish() void Core::Action::ActionTeleport::onFinish()
@ -78,8 +76,9 @@ void Core::Action::ActionTeleport::onFinish()
pPlayer->sendStateFlags(); pPlayer->sendStateFlags();
// TODO: not sure if this ever gets sent // TODO: not sure if this ever gets sent
//auto control = Network::Packets::Server::ActorControlPacket142( m_pSource->getId(), Common::ActorControlType::TeleportDone ); // auto control = Network::Packets::Server::ActorControlPacket142( m_pSource->getId(),
//m_pSource->sendToInRangeSet( control, false ); // Common::ActorControlType::TeleportDone
// ); m_pSource->sendToInRangeSet( control, false );
pPlayer->setZoningType( ZoneingType::Teleport ); pPlayer->setZoningType( ZoneingType::Teleport );
@ -90,13 +89,12 @@ void Core::Action::ActionTeleport::onFinish()
effectPacket.data().actionTextId = 5; effectPacket.data().actionTextId = 5;
effectPacket.data().unknown_5 = 1; effectPacket.data().unknown_5 = 1;
effectPacket.data().numEffects = 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(); effectPacket.data().effectTarget = pPlayer->getId();
pPlayer->sendToInRangeSet( effectPacket, true ); pPlayer->sendToInRangeSet( effectPacket, true );
pPlayer->teleport( m_targetAetheryte ); pPlayer->teleport( m_targetAetheryte );
} }
void Core::Action::ActionTeleport::onInterrupt() void Core::Action::ActionTeleport::onInterrupt()
@ -107,8 +105,6 @@ void Core::Action::ActionTeleport::onInterrupt()
m_pSource->getAsPlayer()->unsetStateFlag( PlayerStateFlag::Casting ); m_pSource->getAsPlayer()->unsetStateFlag( PlayerStateFlag::Casting );
m_pSource->getAsPlayer()->sendStateFlags(); m_pSource->getAsPlayer()->sendStateFlags();
auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt, auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt, 0x219, 0x04, m_id, 0 );
0x219, 0x04, m_id, 0 );
m_pSource->sendToInRangeSet( control, true ); m_pSource->sendToInRangeSet( control, true );
} }

View file

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

View file

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

View file

@ -1,8 +1,8 @@
#include "EventItemAction.h" #include "EventItemAction.h"
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Util/Util.h> #include <Server_Common/Util/Util.h>
#include <Server_Common/Util/UtilMath.h> #include <Server_Common/Util/UtilMath.h>
#include <Server_Common/Logging/Logger.h>
#include <string.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, 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_additional = additional;
m_handleActionType = HandleActionType::Event; m_handleActionType = HandleActionType::Event;
@ -57,7 +58,6 @@ void Core::Action::EventItemAction::onStart()
m_pSource->sendToInRangeSet( castPacket, true ); m_pSource->sendToInRangeSet( castPacket, true );
m_pSource->getAsPlayer()->setStateFlag( PlayerStateFlag::Casting ); m_pSource->getAsPlayer()->setStateFlag( PlayerStateFlag::Casting );
m_pSource->getAsPlayer()->sendStateFlags(); m_pSource->getAsPlayer()->sendStateFlags();
} }
void Core::Action::EventItemAction::onFinish() void Core::Action::EventItemAction::onFinish()
@ -88,7 +88,6 @@ void Core::Action::EventItemAction::onFinish()
{ {
g_log.error( e.what() ); g_log.error( e.what() );
} }
} }
void Core::Action::EventItemAction::onInterrupt() void Core::Action::EventItemAction::onInterrupt()
@ -99,8 +98,7 @@ void Core::Action::EventItemAction::onInterrupt()
try try
{ {
auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt, auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt, 0x219, 0x04, m_id );
0x219, 0x04, m_id );
if( m_pSource->isPlayer() ) if( m_pSource->isPlayer() )
{ {
m_pSource->getAsPlayer()->unsetStateFlag( PlayerStateFlag::Casting ); m_pSource->getAsPlayer()->unsetStateFlag( PlayerStateFlag::Casting );
@ -112,11 +110,9 @@ void Core::Action::EventItemAction::onInterrupt()
if( m_onActionInterruptClb ) if( m_onActionInterruptClb )
m_onActionInterruptClb( *m_pSource->getAsPlayer(), m_eventId, m_additional ); m_onActionInterruptClb( *m_pSource->getAsPlayer(), m_eventId, m_additional );
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
g_log.error( e.what() ); g_log.error( e.what() );
} }
} }

View file

@ -14,8 +14,8 @@ namespace Action {
EventItemAction(); EventItemAction();
~EventItemAction(); ~EventItemAction();
EventItemAction( Entity::ActorPtr pActor, uint32_t eventId, uint16_t action, EventItemAction( Entity::ActorPtr pActor, uint32_t eventId, uint16_t action, ActionCallback finishRef,
ActionCallback finishRef, ActionCallback interruptRef, uint64_t additional ); ActionCallback interruptRef, uint64_t additional );
void onStart() override; void onStart() override;
void onFinish() override; void onFinish() override;
@ -27,10 +27,9 @@ namespace Action {
ActionCallback m_onActionFinishClb; ActionCallback m_onActionFinishClb;
ActionCallback m_onActionInterruptClb; ActionCallback m_onActionInterruptClb;
}; };
} } // namespace Action
} } // namespace Core
#endif #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/Exd/ExdData.h>
#include <Server_Common/Network/GamePacket.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 "Action/Action.h"
#include "Forwards.h"
#include "Zone/Zone.h" #include "Zone/Zone.h"
@ -15,13 +15,13 @@
#include "Network/PacketWrappers/ActorControlPacket144.h" #include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Network/PacketWrappers/UpdateHpMpTpPacket.h" #include "Network/PacketWrappers/UpdateHpMpTpPacket.h"
#include "StatusEffect/StatusEffect.h"
#include "Action/ActionCollision.h" #include "Action/ActionCollision.h"
#include "Actor.h"
#include "Math/CalcBattle.h"
#include "Player.h"
#include "ServerZone.h" #include "ServerZone.h"
#include "Session.h" #include "Session.h"
#include "Math/CalcBattle.h" #include "StatusEffect/StatusEffect.h"
#include "Actor.h"
#include "Player.h"
extern Core::ServerZone g_serverZone; extern Core::ServerZone g_serverZone;
extern Core::Data::ExdData g_exdData; 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 // if the actor is a player, the update needs to be send to himself too
bool selfNeedsUpdate = isPlayer(); 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 // 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 // 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 ); sendToInRangeSet( ActorControlPacket142( m_id, DeathAnimation, 0, 0, 0, 0x20 ), selfNeedsUpdate );
} }
/*! /*!
@ -318,7 +318,6 @@ bool Core::Entity::Actor::checkAction()
m_pCurrentAction.reset(); m_pCurrentAction.reset();
return true; return true;
} }
/*! /*!
@ -330,8 +329,7 @@ void Core::Entity::Actor::changeTarget( uint64_t targetId )
{ {
setTargetId( targetId ); setTargetId( targetId );
sendToInRangeSet( ActorControlPacket144( m_id, SetTarget, sendToInRangeSet( ActorControlPacket144( m_id, SetTarget, 0, 0, 0, 0, targetId ) );
0, 0, 0, 0, targetId ) );
} }
/*! /*!
@ -355,7 +353,8 @@ void Core::Entity::Actor::takeDamage( uint32_t damage )
{ {
if( damage >= m_hp ) if( damage >= m_hp )
{ {
switch( m_invincibilityType ) { switch( m_invincibilityType )
{
case InvincibilityNone: case InvincibilityNone:
setHp( 0 ); setHp( 0 );
die(); die();
@ -455,12 +454,8 @@ Core::Entity::ActorPtr Core::Entity::Actor::getClosestActor()
for( const auto& pCurAct : m_inRangeActors ) for( const auto& pCurAct : m_inRangeActors )
{ {
float distance = Math::Util::distance( getPos().x, float distance = Math::Util::distance( getPos().x, getPos().y, getPos().z, pCurAct->getPos().x,
getPos().y, pCurAct->getPos().y, pCurAct->getPos().z );
getPos().z,
pCurAct->getPos().x,
pCurAct->getPos().y,
pCurAct->getPos().z );
if( distance < minDistance ) if( distance < minDistance )
{ {
@ -660,8 +655,8 @@ ChaiScript Skill Handler.
\param GamePacketPtr to send \param GamePacketPtr to send
\param bool should be send to self? \param bool should be send to self?
*/ */
void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, uint64_t param1, void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, uint64_t param1, uint64_t param2,
uint64_t param2, Entity::Actor& pTarget ) Entity::Actor& pTarget )
{ {
if( isPlayer() ) 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().rotation = Math::Util::floatToUInt16Rot( getRotation() );
effectPacket.data().effectTarget = pTarget.getId(); 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 ) switch( type )
{ {
@ -708,7 +704,6 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
pTarget.onActionHostile( shared_from_this() ); pTarget.onActionHostile( shared_from_this() );
pTarget.takeDamage( static_cast< uint32_t >( param1 ) ); pTarget.takeDamage( static_cast< uint32_t >( param1 ) );
} }
else else
{ {
@ -724,7 +719,6 @@ 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 // todo: send to range of what? ourselves? when mob script hits this is going to be lacking
sendToInRangeSet( effectPacket, true ); sendToInRangeSet( effectPacket, true );
if( pHitActor->isAlive() ) if( pHitActor->isAlive() )
pHitActor->onActionHostile( shared_from_this() ); pHitActor->onActionHostile( shared_from_this() );
@ -734,7 +728,8 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
if( isPlayer() ) if( isPlayer() )
{ {
if( pHitActor->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 else
getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) ); 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: 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].value = calculatedHeal;
effectPacket.data().effects[0].effectType = ActionEffectType::Heal; 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( isPlayer() )
{ {
if( pHitActor->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 else
getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) ); getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) );
} }
@ -826,23 +823,23 @@ void Core::Entity::Actor::addStatusEffect( StatusEffect::StatusEffectPtr pEffect
/*! \param StatusEffectPtr to be applied to the actor */ /*! \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 ) 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(), StatusEffect::StatusEffectPtr effect(
shared_from_this(), duration, 3000 ) ); new StatusEffect::StatusEffect( id, pSource.shared_from_this(), shared_from_this(), duration, 3000 ) );
effect->setParam( param ); effect->setParam( param );
addStatusEffect( effect ); addStatusEffect( effect );
} }
/*! \param StatusEffectPtr to be applied to the actor */ /*! \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 ) ) if( hasStatusEffect( id ) )
return; return;
StatusEffect::StatusEffectPtr effect( new StatusEffect::StatusEffect( id, pSource.shared_from_this(), StatusEffect::StatusEffectPtr effect(
shared_from_this(), duration, 3000 ) ); new StatusEffect::StatusEffect( id, pSource.shared_from_this(), shared_from_this(), duration, 3000 ) );
effect->setParam( param ); effect->setParam( param );
addStatusEffect( effect ); addStatusEffect( effect );
} }
float Core::Entity::Actor::getRotation() const float Core::Entity::Actor::getRotation() const
@ -923,7 +920,8 @@ void Core::Entity::Actor::sendStatusEffectUpdate()
for( auto effectIt : m_statusEffectMap ) for( auto effectIt : m_statusEffectMap )
{ {
float timeLeft = static_cast< float >( effectIt.second->getDuration() - 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].duration = timeLeft;
statusEffectList.data().effect[slot].effect_id = effectIt.second->getId(); statusEffectList.data().effect[slot].effect_id = effectIt.second->getId();
statusEffectList.data().effect[slot].sourceActorId = effectIt.second->getSrcActorId(); statusEffectList.data().effect[slot].sourceActorId = effectIt.second->getSrcActorId();
@ -931,7 +929,6 @@ void Core::Entity::Actor::sendStatusEffectUpdate()
} }
sendToInRangeSet( statusEffectList, isPlayer() ); sendToInRangeSet( statusEffectList, isPlayer() );
} }
void Core::Entity::Actor::updateStatusEffects() void Core::Entity::Actor::updateStatusEffects()
@ -980,22 +977,22 @@ void Core::Entity::Actor::updateStatusEffects()
thisTickHeal += thisEffect.second; thisTickHeal += thisEffect.second;
break; break;
} }
} }
} }
} }
if( thisTickDmg != 0 ) if( thisTickDmg != 0 )
{ {
takeDamage( thisTickDmg ); 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 ) if( thisTickHeal != 0 )
{ {
heal( thisTickDmg ); 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,9 +5,9 @@
#include <boost/enable_shared_from_this.hpp> #include <boost/enable_shared_from_this.hpp>
#include "Forwards.h" #include "Forwards.h"
#include <set>
#include <map> #include <map>
#include <queue> #include <queue>
#include <set>
namespace Core { namespace Core {
namespace Entity { namespace Entity {
@ -272,7 +272,8 @@ public:
void setStatus( ActorStatus status ); 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 ); virtual void autoAttack( ActorPtr pTarget );
@ -332,16 +333,14 @@ public:
// set the current cell // set the current cell
void setCell( Cell* pCell ); void setCell( Cell* pCell );
// TODO: Why did i even declare them publicly here?! // TODO: Why did i even declare them publicly here?!
std::set< ActorPtr > m_inRangeActors; std::set< ActorPtr > m_inRangeActors;
std::set< PlayerPtr > m_inRangePlayers; std::set< PlayerPtr > m_inRangePlayers;
std::map< uint32_t, ActorPtr > m_inRangeActorMap; std::map< uint32_t, ActorPtr > m_inRangeActorMap;
Core::Cell* m_pCell; Core::Cell* m_pCell;
}; };
} } // namespace Entity
} } // namespace Core
#endif #endif

View file

@ -1,20 +1,20 @@
#include <cmath>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <stdint.h>
#include <cmath>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Util/Util.h> #include <Server_Common/Util/Util.h>
#include <Server_Common/Util/UtilMath.h> #include <Server_Common/Util/UtilMath.h>
#include "Player.h"
#include "BattleNpc.h" #include "BattleNpc.h"
#include "Player.h"
#include "Network/PacketWrappers/MoveActorPacket.h"
#include "Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/MoveActorPacket.h"
using namespace Core::Common; using namespace Core::Common;
using namespace Core::Network::Packets; using namespace Core::Network::Packets;
@ -34,12 +34,12 @@ Core::Entity::BattleNpc::BattleNpc()
Core::Entity::BattleNpc::~BattleNpc() Core::Entity::BattleNpc::~BattleNpc()
{ {
} }
Core::Entity::BattleNpc::BattleNpc( uint16_t modelId, uint16_t nameid, const Common::FFXIVARR_POSITION3& spawnPos, 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, uint16_t bnpcBaseId, uint32_t type, uint8_t level, uint8_t behaviour,
uint32_t mobType ) : Actor() uint32_t mobType ) :
Actor()
{ {
BattleNpc::m_nextID++; BattleNpc::m_nextID++;
m_id = BattleNpc::m_nextID; m_id = BattleNpc::m_nextID;
@ -83,7 +83,6 @@ Core::Entity::BattleNpc::BattleNpc( uint16_t modelId, uint16_t nameid, const Com
m_invincibilityType = InvincibilityType::InvincibilityNone; m_invincibilityType = InvincibilityType::InvincibilityNone;
// m_type = static_cast< Common::ObjKind >( type ); // m_type = static_cast< Common::ObjKind >( type );
} }
// spawn this player for pTarget // spawn this player for pTarget
@ -121,7 +120,6 @@ void Core::Entity::BattleNpc::spawn( PlayerPtr pTarget )
ZoneChannelPacket< FFXIVIpcNpcSpawn > spawnPacket( getId(), pTarget->getId() ); ZoneChannelPacket< FFXIVIpcNpcSpawn > spawnPacket( getId(), pTarget->getId() );
spawnPacket.data().pos.x = m_pos.x; spawnPacket.data().pos.x = m_pos.x;
spawnPacket.data().pos.y = m_pos.y; spawnPacket.data().pos.y = m_pos.y;
spawnPacket.data().pos.z = m_pos.z; 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 ); ActorControlPacket143 controlPacket( m_id, DespawnZoneScreenMsg, 0x04, getId(), 0x01 );
pPlayer->queuePacket( controlPacket ); pPlayer->queuePacket( controlPacket );
} }
uint8_t Core::Entity::BattleNpc::getLevel() const uint8_t Core::Entity::BattleNpc::getLevel() const
@ -229,7 +226,6 @@ void Core::Entity::BattleNpc::setOwner( PlayerPtr pPlayer )
setOwnerPacket.data().actorId = INVALID_GAME_OBJECT_ID; setOwnerPacket.data().actorId = INVALID_GAME_OBJECT_ID;
sendToInRangeSet( setOwnerPacket ); sendToInRangeSet( setOwnerPacket );
} }
} }
void Core::Entity::BattleNpc::sendPositionUpdate() void Core::Entity::BattleNpc::sendPositionUpdate()
@ -241,8 +237,7 @@ void Core::Entity::BattleNpc::sendPositionUpdate()
bool Core::Entity::BattleNpc::moveTo( Common::FFXIVARR_POSITION3& pos ) bool Core::Entity::BattleNpc::moveTo( Common::FFXIVARR_POSITION3& pos )
{ {
if( Math::Util::distance( getPos().x, getPos().y, getPos().z, if( Math::Util::distance( getPos().x, getPos().y, getPos().z, pos.x, pos.y, pos.z ) <= 4 )
pos.x, pos.y, pos.z ) <= 4 )
// reached destination // reached destination
return true; return true;
@ -275,7 +270,6 @@ bool Core::Entity::BattleNpc::moveTo( Common::FFXIVARR_POSITION3& pos )
sendPositionUpdate(); sendPositionUpdate();
return false; return false;
} }
void Core::Entity::BattleNpc::aggro( ActorPtr pActor ) void Core::Entity::BattleNpc::aggro( ActorPtr pActor )
@ -321,7 +315,6 @@ void Core::Entity::BattleNpc::hateListClear()
m_hateList.clear(); m_hateList.clear();
} }
void Core::Entity::BattleNpc::hateListRemove( ActorPtr pActor ) void Core::Entity::BattleNpc::hateListRemove( ActorPtr pActor )
{ {
auto it = m_hateList.begin(); auto it = m_hateList.begin();
@ -427,18 +420,23 @@ void Core::Entity::BattleNpc::onDeath()
// todo: arbitrary numbers pulled out of my ass // todo: arbitrary numbers pulled out of my ass
if( m_level <= 14 ) 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 ) 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 ) 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 ) 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 ) 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 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() // todo: this is actually retarded, we need real rand()
srand( static_cast< uint32_t >( time( nullptr ) ) ); srand( static_cast< uint32_t >( time( nullptr ) ) );
@ -467,7 +465,6 @@ Core::Entity::ActorPtr Core::Entity::BattleNpc::getClaimer() const
return m_pOwner; return m_pOwner;
} }
// HACK: this is highly experimental code, will have to be changed eventually // HACK: this is highly experimental code, will have to be changed eventually
// since there are different types of mobs... (stationary, moving...) likely to be // since there are different types of mobs... (stationary, moving...) likely to be
// handled by scripts entirely. // handled by scripts entirely.
@ -482,8 +479,7 @@ void Core::Entity::BattleNpc::update( int64_t currTime )
} }
updateStatusEffects(); updateStatusEffects();
float distance = Math::Util::distance( m_pos.x, m_pos.y, m_pos.z, float distance = Math::Util::distance( m_pos.x, m_pos.y, m_pos.z, m_posOrigin.x, m_posOrigin.y, m_posOrigin.z );
m_posOrigin.x, m_posOrigin.y, m_posOrigin.z );
if( ( distance > 70 ) && m_mode != MODE_RETREAT ) if( ( distance > 70 ) && m_mode != MODE_RETREAT )
{ {
@ -509,10 +505,8 @@ void Core::Entity::BattleNpc::update( int64_t currTime )
if( pClosestActor && pClosestActor->isAlive() ) if( pClosestActor && pClosestActor->isAlive() )
{ {
distance = Math::Util::distance( getPos().x, getPos().y, getPos().z, distance = Math::Util::distance( getPos().x, getPos().y, getPos().z, pClosestActor->getPos().x,
pClosestActor->getPos().x, pClosestActor->getPos().y, pClosestActor->getPos().z );
pClosestActor->getPos().y,
pClosestActor->getPos().z );
// if( distance < 8 && getbehavior() == 2 ) // if( distance < 8 && getbehavior() == 2 )
// aggro( pClosestActor ); // aggro( pClosestActor );
@ -532,10 +526,8 @@ void Core::Entity::BattleNpc::update( int64_t currTime )
if( pClosestActor != nullptr ) if( pClosestActor != nullptr )
{ {
distance = Math::Util::distance( getPos().x, getPos().y, getPos().z, distance = Math::Util::distance( getPos().x, getPos().y, getPos().z, pClosestActor->getPos().x,
pClosestActor->getPos().x, pClosestActor->getPos().y, pClosestActor->getPos().z );
pClosestActor->getPos().y,
pClosestActor->getPos().z );
if( distance > 4 ) if( distance > 4 )
moveTo( pClosestActor->getPos() ); moveTo( pClosestActor->getPos() );
@ -554,11 +546,9 @@ void Core::Entity::BattleNpc::update( int64_t currTime )
setOwner( nullptr ); setOwner( nullptr );
m_mode = MODE_RETREAT; m_mode = MODE_RETREAT;
} }
} }
break; break;
} }
} }
uint32_t Core::Entity::BattleNpc::getTimeOfDeath() const uint32_t Core::Entity::BattleNpc::getTimeOfDeath() const
@ -570,4 +560,3 @@ void Core::Entity::BattleNpc::setTimeOfDeath( uint32_t tod )
{ {
m_timeOfDeath = tod; m_timeOfDeath = tod;
} }

View file

@ -91,7 +91,6 @@ public:
void setTimeOfDeath( uint32_t tod ); void setTimeOfDeath( uint32_t tod );
private: private:
static uint32_t m_nextID; static uint32_t m_nextID;
StateMode m_mode; StateMode m_mode;
Common::FFXIVARR_POSITION3 m_posOrigin; Common::FFXIVARR_POSITION3 m_posOrigin;
@ -106,10 +105,9 @@ private:
ActorPtr m_pOwner; ActorPtr m_pOwner;
uint32_t m_timeOfDeath; uint32_t m_timeOfDeath;
uint32_t m_mobType; uint32_t m_mobType;
}; };
} } // namespace Entity
} } // namespace Core
#endif #endif

View file

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

View file

@ -14,7 +14,8 @@ namespace Entity {
{ {
public: public:
BattleNpcTemplate(); 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(); ~BattleNpcTemplate();
@ -28,11 +29,9 @@ namespace Entity {
uint32_t m_bnpcBaseId = 0; uint32_t m_bnpcBaseId = 0;
uint32_t m_bnpcNameId = 0; uint32_t m_bnpcNameId = 0;
uint32_t m_modelId = 0; uint32_t m_modelId = 0;
}; };
} } // namespace Entity
} } // namespace Core
#endif #endif

View file

@ -1,45 +1,45 @@
#include <Server_Common/Common.h> #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/Util.h>
#include <Server_Common/Util/UtilMath.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 "BattleNpc.h"
#include "Player.h"
#include "Session.h"
#include "Zone/ZoneMgr.h"
#include "Zone/Zone.h" #include "Zone/Zone.h"
#include "Zone/ZoneMgr.h"
#include "ServerZone.h" #include "ServerZone.h"
#include "Network/GameConnection.h" #include "Network/GameConnection.h"
#include "Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.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/ActorSpawnPacket.h"
#include "Network/PacketWrappers/UpdateHpMpTpPacket.h" #include "Network/PacketWrappers/ChatPacket.h"
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h" #include "Network/PacketWrappers/InitUIPacket.h"
#include "Network/PacketWrappers/ModelEquipPacket.h"
#include "Network/PacketWrappers/PlayerSpawnPacket.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 "Script/ScriptManager.h"
#include "Inventory/Item.h" #include "Inventory/Item.h"
#include "Inventory/Inventory.h"
#include "Event/Event.h"
#include "Action/Action.h" #include "Action/Action.h"
#include "Action/EventAction.h" #include "Action/EventAction.h"
#include "Action/EventItemAction.h" #include "Action/EventItemAction.h"
#include "Zone/ZonePosition.h" #include "Event/Event.h"
#include "Math/CalcStats.h" #include "Inventory/Inventory.h"
#include "Math/CalcBattle.h" #include "Math/CalcBattle.h"
#include "Math/CalcStats.h"
#include "Zone/ZonePosition.h"
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
extern Core::Logger g_log; extern Core::Logger g_log;
@ -182,7 +182,8 @@ Core::Common::OnlineStatus Core::Entity::Player::getOnlineStatus()
if( hasStateFlag( PlayerStateFlag::WatchingCutscene ) || hasStateFlag( PlayerStateFlag::WatchingCutscene1 ) ) if( hasStateFlag( PlayerStateFlag::WatchingCutscene ) || hasStateFlag( PlayerStateFlag::WatchingCutscene1 ) )
status = OnlineStatus::ViewingCutscene; 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; return status;
} }
@ -216,8 +217,7 @@ void Core::Entity::Player::calculateStats()
auto tribeInfoIt = g_exdData.m_tribeInfoMap.find( tribe ); auto tribeInfoIt = g_exdData.m_tribeInfoMap.find( tribe );
auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find( level ); auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find( level );
if( tribeInfoIt == g_exdData.m_tribeInfoMap.end() || if( tribeInfoIt == g_exdData.m_tribeInfoMap.end() || classInfoIt == g_exdData.m_classJobInfoMap.end() ||
classInfoIt == g_exdData.m_classJobInfoMap.end() ||
paramGrowthInfoIt == g_exdData.m_paramGrowthInfoMap.end() ) paramGrowthInfoIt == g_exdData.m_paramGrowthInfoMap.end() )
return; return;
@ -228,12 +228,18 @@ void Core::Entity::Player::calculateStats()
// TODO: put formula somewhere else... // TODO: put formula somewhere else...
float base = Math::CalcStats::calculateBaseStat( getAsPlayer() ); 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.str =
m_baseStats.dex = static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_dex ) / 100 ) + tribeInfo.mod_dex ); static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_str ) / 100 ) + tribeInfo.mod_str );
m_baseStats.vit = static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_vit ) / 100 ) + tribeInfo.mod_vit ); m_baseStats.dex =
m_baseStats.inte = static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_int ) / 100 ) + tribeInfo.mod_int ); static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_dex ) / 100 ) + tribeInfo.mod_dex );
m_baseStats.mnd = static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_mnd ) / 100 ) + tribeInfo.mod_mnd ); m_baseStats.vit =
m_baseStats.pie = static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_pie ) / 100 ) + tribeInfo.mod_pie ); 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.skillSpeed = paramGrowthInfo.base_secondary;
m_baseStats.spellSpeed = paramGrowthInfo.base_secondary; m_baseStats.spellSpeed = paramGrowthInfo.base_secondary;
@ -253,12 +259,9 @@ void Core::Entity::Player::calculateStats()
if( m_hp > m_baseStats.max_hp ) if( m_hp > m_baseStats.max_hp )
m_hp = m_baseStats.max_hp; m_hp = m_baseStats.max_hp;
m_baseStats.determination = static_cast< uint32_t >( base ); 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_bAutoattack = mode;
@ -325,8 +328,8 @@ void Core::Entity::Player::teleport( uint16_t aetheryteId, uint8_t type )
rot = z_pos->getTargetRotation(); rot = z_pos->getTargetRotation();
} }
sendDebug( "Teleport: " + data->placename + " " + data->placename_aethernet + sendDebug( "Teleport: " + data->placename + " " + data->placename_aethernet + "(" + std::to_string( data->levelId ) +
"(" + std::to_string( data->levelId ) + ")" ); ")" );
// TODO: this should be simplified and a type created in server_common/common.h. // TODO: this should be simplified and a type created in server_common/common.h.
if( type == 1 ) // teleport if( type == 1 ) // teleport
@ -349,8 +352,6 @@ void Core::Entity::Player::teleport( uint16_t aetheryteId, uint8_t type )
} }
m_queuedZoneing = boost::make_shared< QueuedZoning >( data->target_zone, pos, Util::getTimeMs(), rot ); m_queuedZoneing = boost::make_shared< QueuedZoning >( data->target_zone, pos, Util::getTimeMs(), rot );
} }
void Core::Entity::Player::forceZoneing( uint32_t zoneId ) void Core::Entity::Player::forceZoneing( uint32_t zoneId )
@ -371,7 +372,6 @@ void Core::Entity::Player::setZone( uint32_t zoneId )
auto pZone = g_zoneMgr.getZone( zoneId ); auto pZone = g_zoneMgr.getZone( zoneId );
if( !pZone /*|| ( ( pZone == m_pCurrentZone ) && m_lastPing )*/ ) if( !pZone /*|| ( ( pZone == m_pCurrentZone ) && m_lastPing )*/ )
{ {
g_log.error( "Zone " + std::to_string( zoneId ) + " not found on this server." ); g_log.error( "Zone " + std::to_string( zoneId ) + " not found on this server." );
@ -517,7 +517,6 @@ void Core::Entity::Player::registerAetheryte( uint8_t aetheryteId )
m_aetheryte[index] |= value; m_aetheryte[index] |= value;
queuePacket( ActorControlPacket143( getId(), LearnTeleport, aetheryteId, 1 ) ); queuePacket( ActorControlPacket143( getId(), LearnTeleport, aetheryteId, 1 ) );
} }
bool Core::Entity::Player::isAetheryteRegistered( uint8_t aetheryteId ) const bool Core::Entity::Player::isAetheryteRegistered( uint8_t aetheryteId ) const
@ -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 ); uint32_t exp = ( g_exdData.m_paramGrowthInfoMap[level].needed_exp * 5 / 100 );
gainExp( exp ); gainExp( exp );
} }
bool Core::Entity::Player::isNewAdventurer() const bool Core::Entity::Player::isNewAdventurer() const
@ -657,11 +653,11 @@ void Core::Entity::Player::gainExp( uint32_t amount )
setExp( amount ); setExp( amount );
gainLevel(); gainLevel();
queuePacket( ActorControlPacket143( getId(), UpdateUiExp, static_cast< uint8_t >( getClass() ), amount ) ); queuePacket( ActorControlPacket143( getId(), UpdateUiExp, static_cast< uint8_t >( getClass() ), amount ) );
} }
else 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 ); setExp( currentExp + amount );
} }
@ -690,9 +686,9 @@ void Core::Entity::Player::gainLevel()
effectListPacket.data().max_mp = getMaxMp(); effectListPacket.data().max_mp = getMaxMp();
sendToInRangeSet( effectListPacket, true ); sendToInRangeSet( effectListPacket, true );
sendToInRangeSet( ActorControlPacket142( getId(), LevelUpEffect, static_cast< uint8_t >( getClass() ), sendToInRangeSet( ActorControlPacket142( getId(), LevelUpEffect, static_cast< uint8_t >( getClass() ), getLevel(),
getLevel(), getLevel() - 1 ), true ); getLevel() - 1 ),
true );
ZoneChannelPacket< FFXIVIpcUpdateClassInfo > classInfoPacket( getId() ); ZoneChannelPacket< FFXIVIpcUpdateClassInfo > classInfoPacket( getId() );
classInfoPacket.data().classId = static_cast< uint8_t >( getClass() ); classInfoPacket.data().classId = static_cast< uint8_t >( getClass() );
@ -701,7 +697,6 @@ void Core::Entity::Player::gainLevel()
classInfoPacket.data().nextLevelIndex = getLevel(); classInfoPacket.data().nextLevelIndex = getLevel();
classInfoPacket.data().currentExp = getExp(); classInfoPacket.data().currentExp = getExp();
queuePacket( classInfoPacket ); queuePacket( classInfoPacket );
} }
void Core::Entity::Player::unlock() void Core::Entity::Player::unlock()
@ -733,7 +728,6 @@ void Core::Entity::Player::sendStatusUpdate( bool toSelf )
// sendToInRangeSet(pPE, toSelf); // sendToInRangeSet(pPE, toSelf);
sendToInRangeSet( UpdateHpMpTpPacket( shared_from_this() ), true ); sendToInRangeSet( UpdateHpMpTpPacket( shared_from_this() ), true );
} }
uint8_t Core::Entity::Player::getLevel() const uint8_t Core::Entity::Player::getLevel() const
@ -796,7 +790,8 @@ void Core::Entity::Player::setClassJob( Common::ClassJob classJob )
void Core::Entity::Player::setLevel( uint8_t level ) 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; m_classArray[classJobIndex] = level;
} }
@ -872,9 +867,7 @@ void Core::Entity::Player::setLookAt( uint8_t index, uint8_t value )
// spawn this player for pTarget // spawn this player for pTarget
void Core::Entity::Player::spawn( Entity::PlayerPtr pTarget ) void Core::Entity::Player::spawn( Entity::PlayerPtr pTarget )
{ {
g_log.debug( "[" + std::to_string( pTarget->getId() ) + "] Spawning " + g_log.debug( "[" + std::to_string( pTarget->getId() ) + "] Spawning " + getName() + " for " + pTarget->getName() );
getName() + " for " +
pTarget->getName() );
PlayerSpawnPacket spawnActor( *getAsPlayer(), *pTarget ); PlayerSpawnPacket spawnActor( *getAsPlayer(), *pTarget );
pTarget->queuePacket( spawnActor ); pTarget->queuePacket( spawnActor );
@ -953,7 +946,6 @@ bool Core::Entity::Player::actionHasCastTime( uint32_t actionId ) //TODO: Add lo
return false; return false;
return actionInfoPtr->cast_time != 0; return actionInfoPtr->cast_time != 0;
} }
bool Core::Entity::Player::hasStateFlag( Common::PlayerStateFlag flag ) const 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 ); Util::valueToFlagByteIndexValue( iFlag, value, index );
m_stateFlags[index] |= value; m_stateFlags[index] |= value;
} }
void Core::Entity::Player::setStateFlags( std::vector< Common::PlayerStateFlag > flags ) 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 ); Util::valueToFlagByteIndexValue( iFlag, value, index );
m_stateFlags[index] ^= value; m_stateFlags[index] ^= value;
} }
void Core::Entity::Player::update( int64_t currTime ) void Core::Entity::Player::update( int64_t currTime )
@ -1055,7 +1045,8 @@ void Core::Entity::Player::update( int64_t currTime )
{ {
auto mainWeap = m_pInventory->getItemAt( Inventory::GearSet0, Inventory::EquipSlot::MainHand ); 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 ) for( auto actor : m_inRangeActors )
{ {
if( actor->getId() == m_targetId && actor->isAlive() && mainWeap ) if( actor->getId() == m_targetId && actor->isAlive() && mainWeap )
@ -1065,14 +1056,11 @@ void Core::Entity::Player::update( int64_t currTime )
uint32_t range = 7; uint32_t range = 7;
// default autoattack range for ranged classes // default autoattack range for ranged classes
if( getClass() == ClassJob::Machinist || if( getClass() == ClassJob::Machinist || getClass() == ClassJob::Bard || getClass() == ClassJob::Archer )
getClass() == ClassJob::Bard ||
getClass() == ClassJob::Archer )
range = 25; range = 25;
if( Math::Util::distance( getPos().x, getPos().y, getPos().z, actor->getPos().x, actor->getPos().y,
if( Math::Util::distance(getPos().x, getPos().y, getPos().z, actor->getPos().z ) <= range )
actor->getPos().x, actor->getPos().y, actor->getPos().z) <= range )
{ {
if( ( currTime - m_lastAttack ) > mainWeap->getDelay() ) if( ( currTime - m_lastAttack ) > mainWeap->getDelay() )
@ -1080,7 +1068,6 @@ void Core::Entity::Player::update( int64_t currTime )
m_lastAttack = currTime; m_lastAttack = currTime;
autoAttack( actor ); autoAttack( actor );
} }
} }
} }
} }
@ -1111,7 +1098,6 @@ void Core::Entity::Player::freePlayerSpawnId( uint32_t actorId )
freeActorSpawnPacket.data().actorId = actorId; freeActorSpawnPacket.data().actorId = actorId;
freeActorSpawnPacket.data().spawnId = spawnId; freeActorSpawnPacket.data().spawnId = spawnId;
queuePacket( freeActorSpawnPacket ); queuePacket( freeActorSpawnPacket );
} }
uint8_t* Core::Entity::Player::getAetheryteArray() uint8_t* Core::Entity::Player::getAetheryteArray()
@ -1219,7 +1205,6 @@ void Core::Entity::Player::queuePacket( Network::Packets::GamePacketPtr pPacket
if( pZoneCon ) if( pZoneCon )
pZoneCon->queueOutPacket( pPacket ); pZoneCon->queueOutPacket( pPacket );
} }
void Core::Entity::Player::queueChatPacket( Network::Packets::GamePacketPtr pPacket ) void Core::Entity::Player::queueChatPacket( Network::Packets::GamePacketPtr pPacket )
@ -1317,7 +1302,6 @@ void Core::Entity::Player::updateHowtosSeen( uint32_t howToId )
m_howTo[index] |= value; m_howTo[index] |= value;
} }
void Core::Entity::Player::onMobAggro( BattleNpcPtr pBNpc ) void Core::Entity::Player::onMobAggro( BattleNpcPtr pBNpc )
{ {
hateListAdd( pBNpc ); hateListAdd( pBNpc );
@ -1342,7 +1326,6 @@ void Core::Entity::Player::hateListAdd( BattleNpcPtr pBNpc )
m_freeHateSlotQueue.pop(); m_freeHateSlotQueue.pop();
m_actorIdTohateSlotMap[pBNpc->getId()] = hateId; m_actorIdTohateSlotMap[pBNpc->getId()] = hateId;
sendHateList(); sendHateList();
} }
void Core::Entity::Player::hateListRemove( BattleNpcPtr pBNpc ) void Core::Entity::Player::hateListRemove( BattleNpcPtr pBNpc )
@ -1454,7 +1437,9 @@ uint8_t Core::Entity::Player::getEquipDisplayFlags() const
void Core::Entity::Player::mount( uint32_t id ) void Core::Entity::Player::mount( uint32_t id )
{ {
m_mount = 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 ); //? sendToInRangeSet( ActorControlPacket143( getId(), 0x39e, 12 ), true ); //?
ZoneChannelPacket< FFXIVIpcMount > mountPacket( getId() ); ZoneChannelPacket< FFXIVIpcMount > mountPacket( getId() );
@ -1465,7 +1450,8 @@ void Core::Entity::Player::mount( uint32_t id )
void Core::Entity::Player::dismount() void Core::Entity::Player::dismount()
{ {
sendToInRangeSet( ActorControlPacket142( getId(), ActorControlType::SetStatus, 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 ); sendToInRangeSet( ActorControlPacket143( getId(), ActorControlType::Dismount, 1 ), true );
m_mount = 0; m_mount = 0;
} }
@ -1478,8 +1464,7 @@ uint8_t Core::Entity::Player::getCurrentMount() const
void Core::Entity::Player::autoAttack( ActorPtr pTarget ) void Core::Entity::Player::autoAttack( ActorPtr pTarget )
{ {
auto mainWeap = m_pInventory->getItemAt( Inventory::GearSet0, auto mainWeap = m_pInventory->getItemAt( Inventory::GearSet0, Inventory::EquipSlot::MainHand );
Inventory::EquipSlot::MainHand );
pTarget->onActionHostile( shared_from_this() ); pTarget->onActionHostile( shared_from_this() );
// uint64_t tick = Util::getTimeMs(); // uint64_t tick = Util::getTimeMs();
@ -1488,9 +1473,7 @@ void Core::Entity::Player::autoAttack( ActorPtr pTarget )
uint32_t damage = static_cast< uint32_t >( mainWeap->getAutoAttackDmg() ); uint32_t damage = static_cast< uint32_t >( mainWeap->getAutoAttackDmg() );
uint32_t variation = 0 + rand() % 3; uint32_t variation = 0 + rand() % 3;
if( getClass() == ClassJob::Machinist || if( getClass() == ClassJob::Machinist || getClass() == ClassJob::Bard || getClass() == ClassJob::Archer )
getClass() == ClassJob::Bard ||
getClass() == ClassJob::Archer )
{ {
ZoneChannelPacket< FFXIVIpcEffect > effectPacket( getId() ); ZoneChannelPacket< FFXIVIpcEffect > effectPacket( getId() );
effectPacket.data().targetId = pTarget->getId(); effectPacket.data().targetId = pTarget->getId();
@ -1532,10 +1515,8 @@ void Core::Entity::Player::autoAttack( ActorPtr pTarget )
} }
pTarget->takeDamage( damage ); pTarget->takeDamage( damage );
} }
///////////////////////////// /////////////////////////////
// Content Finder // Content Finder
///////////////////////////// /////////////////////////////

View file

@ -21,11 +21,14 @@ struct QueuedZoning
float m_targetRotation; float m_targetRotation;
uint64_t m_queueTime; uint64_t m_queueTime;
QueuedZoning( uint16_t targetZone, const Common::FFXIVARR_POSITION3& targetPosition, uint64_t queuedTime, float targetRotation ) QueuedZoning( uint16_t targetZone, const Common::FFXIVARR_POSITION3& targetPosition, uint64_t queuedTime,
: m_targetZone( targetZone ) float targetRotation ) :
, m_targetPosition( targetPosition ) m_targetZone( targetZone ),
, m_queueTime( queuedTime ) m_targetPosition( targetPosition ),
, m_targetRotation( targetRotation ) {} m_queueTime( queuedTime ),
m_targetRotation( targetRotation )
{
}
}; };
/** Class representing the Player /** Class representing the Player
@ -46,21 +49,25 @@ public:
// EventHandlers // EventHandlers
////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////
/*! start an event action */ /*! 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 */ /*! 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 */ /*! 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 */ /*! play a subevent */
void eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags, uint32_t eventParam2, uint32_t eventParam3 ); void eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags, uint32_t eventParam2, uint32_t eventParam3 );
/*! play a subevent */ /*! play a subevent */
void eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags, void eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags, uint32_t eventParam2, uint32_t eventParam3,
uint32_t eventParam2, uint32_t eventParam3, Scripting::EventReturnCallback eventReturnCallback ); 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 */ /*! play a subevent */
void eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags, void eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags,
uint32_t eventParam2, uint32_t eventParam3, uint32_t eventParam4, Scripting::EventReturnCallback eventReturnCallback ); Scripting::EventReturnCallback eventReturnCallback );
/*! play a subevent */
void eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags, Scripting::EventReturnCallback eventReturnCallback );
/*! play a subevent */ /*! play a subevent */
void eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags ); void eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags );
/*! finish / unregister an event */ /*! finish / unregister an event */
@ -78,8 +85,6 @@ public:
void checkEvent( uint32_t eventId ); void checkEvent( uint32_t eventId );
// Events // Events
////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////
/*! Event to be called when zoning process gets triggered */ /*! Event to be called when zoning process gets triggered */
@ -97,7 +102,6 @@ public:
/*! Event to be called upon Bnpc kill */ /*! Event to be called upon Bnpc kill */
void onMobKill( uint16_t nameId ); void onMobKill( uint16_t nameId );
// Quest // Quest
////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////
/*! load data for currently active quests */ /*! load data for currently active quests */
@ -163,7 +167,6 @@ public:
uint8_t getQuestBitFlag40( uint16_t questId ); uint8_t getQuestBitFlag40( uint16_t questId );
uint8_t getQuestBitFlag48( uint16_t questId ); uint8_t getQuestBitFlag48( uint16_t questId );
void setQuestUI8A( uint16_t questId, uint8_t val ); void setQuestUI8A( uint16_t questId, uint8_t val );
void setQuestUI8B( uint16_t questId, uint8_t val ); void setQuestUI8B( uint16_t questId, uint8_t val );
void setQuestUI8C( uint16_t questId, uint8_t val ); void setQuestUI8C( uint16_t questId, uint8_t val );
@ -354,7 +357,6 @@ public:
void calculateStats() override; void calculateStats() override;
void sendStats(); void sendStats();
// Aetheryte / Action / Attribute bitmasks // Aetheryte / Action / Attribute bitmasks
////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////
/*! register aetheryte aetheryteId and send update */ /*! register aetheryte aetheryteId and send update */
@ -394,7 +396,6 @@ public:
/*! return a const pointer to the mount guide bitmask array */ /*! return a const pointer to the mount guide bitmask array */
const uint8_t* getMountGuideBitmask() const; const uint8_t* getMountGuideBitmask() const;
// Spawn handling // Spawn handling
////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////
/*! initialize the spawnId queue */ /*! initialize the spawnId queue */
@ -551,7 +552,6 @@ private:
bool m_markedForRemoval; bool m_markedForRemoval;
private: private:
uint8_t m_voice; uint8_t m_voice;
uint64_t m_modelMainWeapon; uint64_t m_modelMainWeapon;
@ -642,7 +642,7 @@ private:
uint8_t m_mount; uint8_t m_mount;
}; };
} } // namespace Entity
} } // namespace Core
#endif #endif

View file

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

View file

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

View file

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

View file

@ -1,13 +1,12 @@
#include <Server_Common/Common.h> #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/GamePacket.h>
#include <Server_Common/Network/PacketContainer.h>
#include <Server_Common/Util/Util.h> #include <Server_Common/Util/Util.h>
#include <Server_Common/Util/UtilMath.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 <set>
#include <stdio.h> #include <stdio.h>
@ -16,24 +15,22 @@
#include "Player.h" #include "Player.h"
#include "Zone/ZoneMgr.h"
#include "Zone/Zone.h" #include "Zone/Zone.h"
#include "Zone/ZoneMgr.h"
#include "ServerZone.h" #include "ServerZone.h"
#include "Forwards.h" #include "Forwards.h"
#include "Inventory/Inventory.h"
#include "Network/GameConnection.h" #include "Network/GameConnection.h"
#include "Network/PacketWrappers/InitUIPacket.h" #include "Network/PacketWrappers/InitUIPacket.h"
#include "Inventory/Inventory.h"
extern Core::Logger g_log; extern Core::Logger g_log;
extern Core::ServerZone g_serverZone; extern Core::ServerZone g_serverZone;
extern Core::ZoneMgr g_zoneMgr; extern Core::ZoneMgr g_zoneMgr;
extern Core::Data::ExdData g_exdData; extern Core::Data::ExdData g_exdData;
using namespace Core::Common; using namespace Core::Common;
using namespace Core::Network::Packets; using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server; using namespace Core::Network::Packets::Server;
@ -243,12 +240,9 @@ bool Core::Entity::Player::loadActiveQuests()
m_questIdToQuestIdx[pActiveQuest->c.questId] = slotId; m_questIdToQuestIdx[pActiveQuest->c.questId] = slotId;
m_questIdxToQuestId[slotId] = pActiveQuest->c.questId; m_questIdxToQuestId[slotId] = pActiveQuest->c.questId;
} }
return true; return true;
} }
bool Core::Entity::Player::loadClassData() bool Core::Entity::Player::loadClassData()
@ -288,7 +282,6 @@ bool Core::Entity::Player::loadSearchInfo()
return true; return true;
} }
void Core::Entity::Player::updateSql() void Core::Entity::Player::updateSql()
{ {
@ -421,7 +414,6 @@ void Core::Entity::Player::updateSql()
////// Class ////// Class
updateDbClass(); updateDbClass();
} }
void Core::Entity::Player::updateDbClass() const void Core::Entity::Player::updateDbClass() const
@ -476,7 +468,6 @@ void Core::Entity::Player::updateDbAllQuests() const
stmtS3->setInt( 10, m_id ); stmtS3->setInt( 10, m_id );
stmtS3->setInt( 11, m_activeQuests[i]->c.questId ); stmtS3->setInt( 11, m_activeQuests[i]->c.questId );
g_charaDb.execute( stmtS3 ); g_charaDb.execute( stmtS3 );
} }
} }

View file

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

View file

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

View file

@ -1,37 +1,36 @@
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <Server_Common/Common.h> #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/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 "DebugCommand.h"
#include "DebugCommandHandler.h" #include "DebugCommandHandler.h"
#include "Network/PacketWrappers/ServerNoticePacket.h" #include "Network/GameConnection.h"
#include "Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/InitUIPacket.h" #include "Network/PacketWrappers/InitUIPacket.h"
#include "Network/GameConnection.h" #include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Script/ScriptManager.h" #include "Script/ScriptManager.h"
#include "Actor/Player.h"
#include "Actor/BattleNpc.h" #include "Actor/BattleNpc.h"
#include "Actor/Player.h"
#include "Zone/Zone.h" #include "Zone/Zone.h"
#include "ServerZone.h" #include "ServerZone.h"
#include "StatusEffect/StatusEffect.h"
#include "Session.h" #include "Session.h"
#include "StatusEffect/StatusEffect.h"
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include <cinttypes> #include <cinttypes>
extern Core::Scripting::ScriptManager g_scriptMgr; extern Core::Scripting::ScriptManager g_scriptMgr;
@ -108,11 +107,8 @@ void Core::DebugCommandHandler::execCommand( char * data, Entity::Player& player
( this->*pf )( data, player, ( *it ).second ); ( this->*pf )( data, player, ( *it ).second );
return; return;
} }
} }
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////
// Definition of the commands // Definition of the commands
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////
@ -156,9 +152,7 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost:
if( command->getName().length() + 1 + pos + 1 < strlen( data ) ) if( command->getName().length() + 1 + pos + 1 < strlen( data ) )
params = std::string( data + command->getName().length() + 1 + pos + 1 ); params = std::string( data + command->getName().length() + 1 + pos + 1 );
g_log.debug( "[" + std::to_string( player.getId() ) + "] " + g_log.debug( "[" + std::to_string( player.getId() ) + "] " + "subCommand " + subCommand + " params: " + params );
"subCommand " + subCommand + " params: " + params );
if( ( ( subCommand == "pos" ) || ( subCommand == "posr" ) ) && ( params != "" ) ) if( ( ( subCommand == "pos" ) || ( subCommand == "posr" ) ) && ( params != "" ) )
{ {
@ -175,21 +169,18 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost:
} }
if( subCommand == "pos" ) if( subCommand == "pos" )
player.setPosition( static_cast< float >( posX ), player.setPosition( static_cast< float >( posX ), static_cast< float >( posY ), static_cast< float >( posZ ) );
static_cast< float >( posY ),
static_cast< float >( posZ ) );
else else
player.setPosition( player.getPos().x + static_cast< float >( posX ), player.setPosition( player.getPos().x + static_cast< float >( posX ),
player.getPos().y + static_cast< float >( posY ), player.getPos().y + static_cast< float >( posY ),
player.getPos().z + static_cast< float >( posZ ) ); player.getPos().z + static_cast< float >( posZ ) );
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorSetPos > Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorSetPos > setActorPosPacket(
setActorPosPacket( player.getId() ); player.getId() );
setActorPosPacket.data().x = player.getPos().x; setActorPosPacket.data().x = player.getPos().x;
setActorPosPacket.data().y = player.getPos().y; setActorPosPacket.data().y = player.getPos().y;
setActorPosPacket.data().z = player.getPos().z; setActorPosPacket.data().z = player.getPos().z;
player.queuePacket( setActorPosPacket ); player.queuePacket( setActorPosPacket );
} }
else if( ( subCommand == "tele" ) && ( params != "" ) ) else if( ( subCommand == "tele" ) && ( params != "" ) )
{ {
@ -204,7 +195,8 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost:
int32_t discover_id; int32_t discover_id;
sscanf( params.c_str(), "%i %i", &map_id, &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_id = map_id;
discoveryPacket.data().map_part_id = discover_id; discoveryPacket.data().map_part_id = discover_id;
player.queuePacket( discoveryPacket ); 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 ) + std::string query2 = "UPDATE IGNORE `discoveryinfo` SET `discover_id` = '" + std::to_string( discover_id ) +
"' WHERE `discoveryinfo`.`id` = " + std::to_string( pos_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::string query1 = "INSERT IGNORE INTO `discoveryinfo` (`id`, `map_id`, `discover_id`) VALUES ('" +
"', '" + std::to_string( map_id ) + std::to_string( pos_id ) + "', '" + std::to_string( map_id ) + "', '" +
"', '" + std::to_string( discover_id ) + "')"; std::to_string( discover_id ) + "')";
g_charaDb.execute( query1 ); g_charaDb.execute( query1 );
g_charaDb.execute( query2 ); g_charaDb.execute( query2 );
} }
else if( subCommand == "discovery_reset" ) else if( subCommand == "discovery_reset" )
@ -285,7 +276,6 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost:
{ {
player.sendUrgent( subCommand + " is not a valid SET command." ); 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 )
@ -311,9 +301,7 @@ void Core::DebugCommandHandler::add( char * data, Entity::Player& player, boost:
if( command->getName().length() + 1 + pos + 1 < strlen( data ) ) if( command->getName().length() + 1 + pos + 1 < strlen( data ) )
params = std::string( data + command->getName().length() + 1 + pos + 1 ); params = std::string( data + command->getName().length() + 1 + pos + 1 );
g_log.debug( "[" + std::to_string( player.getId() ) + "] " + g_log.debug( "[" + std::to_string( player.getId() ) + "] " + "subCommand " + subCommand + " params: " + params );
"subCommand " + subCommand + " params: " + params );
if( subCommand == "status" ) 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 ); 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 ); effect->setParam( param );
player.addStatusEffect( effect ); player.addStatusEffect( effect );
@ -347,14 +336,14 @@ void Core::DebugCommandHandler::add( char * data, Entity::Player& player, boost:
auto pZone = player.getCurrentZone(); auto pZone = player.getCurrentZone();
pBNpc->setCurrentZone( pZone ); pBNpc->setCurrentZone( pZone );
pZone->pushActor( pBNpc ); pZone->pushActor( pBNpc );
} }
else if( subCommand == "op" ) else if( subCommand == "op" )
{ {
// temporary research packet // temporary research packet
int32_t opcode; int32_t opcode;
sscanf( params.c_str(), "%x", &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 ); player.queuePacket( pPe );
} }
else if( subCommand == "actrl" ) else if( subCommand == "actrl" )
@ -371,11 +360,13 @@ void Core::DebugCommandHandler::add( char * data, Entity::Player& player, boost:
int32_t param6; int32_t param6;
int32_t playerId; 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 ) ); 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().category = opcode;
actorControl.data().param1 = param1; actorControl.data().param1 = param1;
actorControl.data().param2 = param2; actorControl.data().param2 = param2;
@ -385,24 +376,22 @@ void Core::DebugCommandHandler::add( char * data, Entity::Player& player, boost:
actorControl.data().param6 = param6; actorControl.data().param6 = param6;
player.queuePacket( actorControl ); 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 ); player.queuePacket( noticePacket );
Network::Packets::Server::ActorControlPacket143 controlPacket( player, opcode, Network::Packets::Server::ActorControlPacket143 controlPacket( player, opcode,
param1, param2, param3, param4, param5, param6, playerId ); param1, param2, param3, param4, param5, param6, playerId );
player.queuePacket( controlPacket );*/ player.queuePacket( controlPacket );*/
} }
else else
{ {
player.sendUrgent( subCommand + " is not a valid ADD command." ); 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 )
@ -425,38 +414,34 @@ void Core::DebugCommandHandler::get( char * data, Entity::Player& player, boost:
if( command->getName().length() + 1 + pos + 1 < strlen( data ) ) if( command->getName().length() + 1 + pos + 1 < strlen( data ) )
params = std::string( data + command->getName().length() + 1 + pos + 1 ); params = std::string( data + command->getName().length() + 1 + pos + 1 );
g_log.debug( "[" + std::to_string( player.getId() ) + "] " + g_log.debug( "[" + std::to_string( player.getId() ) + "] " + "subCommand " + subCommand + " params: " + params );
"subCommand " + subCommand + " params: " + params );
if( ( subCommand == "pos" ) ) if( ( subCommand == "pos" ) )
{ {
int16_t map_id = g_exdData.m_zoneInfoMap[player.getCurrentZone()->getId()].map_id; int16_t map_id = g_exdData.m_zoneInfoMap[player.getCurrentZone()->getId()].map_id;
player.sendNotice( "Pos:\n" + player.sendNotice( "Pos:\n" + std::to_string( player.getPos().x ) + "\n" + std::to_string( player.getPos().y ) +
std::to_string( player.getPos().x ) + "\n" + "\n" + std::to_string( player.getPos().z ) + "\n" + std::to_string( player.getRotation() ) +
std::to_string( player.getPos().y ) + "\n" + "\nMapId: " + std::to_string( map_id ) +
std::to_string( player.getPos().z ) + "\n" + "\nZoneID: " + std::to_string( player.getCurrentZone()->getId() ) + "\n" );
std::to_string( player.getRotation() ) + "\nMapId: " +
std::to_string( map_id ) + "\nZoneID: " +
std::to_string( player.getCurrentZone()->getId() ) + "\n" );
} }
else else
{ {
player.sendUrgent( subCommand + " is not a valid GET command." ); 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() ); auto pSession = g_serverZone.getSession( player.getId() );
if( pSession ) if( pSession )
pSession->getZoneConnection()->injectPacket( data + 7, player ); 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() ); auto pSession = g_serverZone.getSession( player.getId() );
if( pSession ) if( pSession )
@ -489,7 +474,6 @@ void Core::DebugCommandHandler::nudge( char * data, Entity::Player& player, boos
{ {
pos.y -= offset; pos.y -= offset;
player.sendNotice( "nudge: Placing down " + std::to_string( offset ) + " yalms" ); player.sendNotice( "nudge: Placing down " + std::to_string( offset ) + " yalms" );
} }
else else
{ {
@ -500,8 +484,8 @@ void Core::DebugCommandHandler::nudge( char * data, Entity::Player& player, boos
} }
if( offset != 0 ) if( offset != 0 )
{ {
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorSetPos > Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorSetPos > setActorPosPacket(
setActorPosPacket( player.getId() ); player.getId() );
setActorPosPacket.data().x = player.getPos().x; setActorPosPacket.data().x = player.getPos().x;
setActorPosPacket.data().y = player.getPos().y; setActorPosPacket.data().y = player.getPos().y;
setActorPosPacket.data().z = player.getPos().z; 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( "SapphireServer " + Version::VERSION + "\nRev: " + Version::GIT_HASH );
player.sendDebug( "Compiled: " __DATE__ " " __TIME__ ); player.sendDebug( "Compiled: " __DATE__ " " __TIME__ );
player.sendDebug( "Sessions: " + std::to_string( g_serverZone.getSessionCount() ) ); 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 <map>
#include "DebugCommand.h" #include "DebugCommand.h"
#include <Server_Common/Common.h>
#include "Forwards.h" #include "Forwards.h"
#include <Server_Common/Common.h>
namespace Core { namespace Core {
// handler for in game commands // handler for in game commands
class DebugCommandHandler class DebugCommandHandler
{ {
@ -44,8 +43,7 @@ public:
void unlockCharacter( 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 ); void targetInfo( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
}; };
} } // namespace Core
#endif #endif

View file

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

View file

@ -73,6 +73,6 @@ namespace Core {
Scripting::EventReturnCallback m_callback; Scripting::EventReturnCallback m_callback;
}; };
} } // namespace Event
} } // namespace Core
#endif #endif

View file

@ -11,6 +11,6 @@ namespace Core {
uint32_t mapEventActorToRealActor( uint32_t eventActorId ); uint32_t mapEventActorToRealActor( uint32_t eventActorId );
} } // namespace Event
} } // namespace Core
#endif #endif

View file

@ -9,8 +9,7 @@ class x; \
typedef boost::shared_ptr< x > x##Ptr; \ typedef boost::shared_ptr< x > x##Ptr; \
typedef std::vector< x > x##PtrList; typedef std::vector< x > x##PtrList;
namespace Core namespace Core {
{
TYPE_FORWARD( Cell ); TYPE_FORWARD( Cell );
TYPE_FORWARD( Zone ); TYPE_FORWARD( Zone );
TYPE_FORWARD( Item ); TYPE_FORWARD( Item );
@ -20,36 +19,31 @@ namespace Core
TYPE_FORWARD( XMLConfig ); TYPE_FORWARD( XMLConfig );
TYPE_FORWARD( ZonePosition ) TYPE_FORWARD( ZonePosition )
namespace StatusEffect namespace StatusEffect {
{
TYPE_FORWARD( StatusEffect ); TYPE_FORWARD( StatusEffect );
TYPE_FORWARD( StatusEffectContainer ); TYPE_FORWARD( StatusEffectContainer );
} } // namespace StatusEffect
namespace Entity namespace Entity {
{
TYPE_FORWARD( Actor ); TYPE_FORWARD( Actor );
TYPE_FORWARD( Player ); TYPE_FORWARD( Player );
TYPE_FORWARD( BattleNpc ); TYPE_FORWARD( BattleNpc );
TYPE_FORWARD( BattleNpcTemplate ); TYPE_FORWARD( BattleNpcTemplate );
} } // namespace Entity
namespace Event namespace Event {
{
TYPE_FORWARD( Event ); TYPE_FORWARD( Event );
} }
namespace Action namespace Action {
{
TYPE_FORWARD( Action ); TYPE_FORWARD( Action );
TYPE_FORWARD( ActionTeleport ); TYPE_FORWARD( ActionTeleport );
TYPE_FORWARD( ActionCast ); TYPE_FORWARD( ActionCast );
TYPE_FORWARD( ActionMount ); TYPE_FORWARD( ActionMount );
TYPE_FORWARD( EventAction ); TYPE_FORWARD( EventAction );
} } // namespace Action
namespace Network namespace Network {
{
TYPE_FORWARD( Hive ); TYPE_FORWARD( Hive );
TYPE_FORWARD( Acceptor ); TYPE_FORWARD( Acceptor );
TYPE_FORWARD( Connection ); TYPE_FORWARD( Connection );
@ -57,25 +51,21 @@ namespace Core
TYPE_FORWARD( SessionConnection ); TYPE_FORWARD( SessionConnection );
TYPE_FORWARD( CustomMsgClientConnection ); TYPE_FORWARD( CustomMsgClientConnection );
namespace Packets namespace Packets {
{
TYPE_FORWARD( GamePacket ); TYPE_FORWARD( GamePacket );
} }
} } // namespace Network
namespace ContentFinder namespace ContentFinder {
{
TYPE_FORWARD( ContentFinder ); TYPE_FORWARD( ContentFinder );
} }
namespace Scripting 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, uint16_t, uint16_t, uint16_t ) > EventReturnCallback;
} }
typedef std::function< void( Entity::Player&, uint32_t, uint64_t ) > ActionCallback; typedef std::function< void( Entity::Player&, uint32_t, uint64_t ) > ActionCallback;
} } // namespace Core
#endif #endif

View file

@ -1,19 +1,19 @@
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include <Server_Common/Common.h> #include <Server_Common/Common.h>
#include <Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include "Inventory.h" #include "Inventory.h"
#include "Actor/Player.h" #include "Actor/Player.h"
#include "ItemContainer.h"
#include "Item.h" #include "Item.h"
#include "ItemContainer.h"
#include "Network/PacketWrappers/ServerNoticePacket.h" #include "Network/PacketWrappers/ServerNoticePacket.h"
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/clamp.hpp> #include <boost/algorithm/clamp.hpp>
#include <boost/lexical_cast.hpp>
#include "../Forwards.h" #include "../Forwards.h"
#include "Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
@ -35,8 +35,9 @@ Core::Inventory::Inventory( Core::Entity::Player* pOwner )
// shortcut for setting up inventory // shortcut for setting up inventory
// TODO: use a loop to set theese up? // TODO: use a loop to set theese up?
auto setupContainer = []( InventoryMap& map, InventoryType type ) auto setupContainer = []( InventoryMap& map, InventoryType type ) {
{ map[type] = ItemContainerPtr( new ItemContainer( type ) ); }; map[type] = ItemContainerPtr( new ItemContainer( type ) );
};
// main bags // main bags
setupContainer( m_inventoryMap, Bag0 ); setupContainer( m_inventoryMap, Bag0 );
@ -95,7 +96,6 @@ Core::Inventory::Inventory( Core::Entity::Player* pOwner )
setupContainer( m_inventoryMap, ArmorySoulCrystal ); setupContainer( m_inventoryMap, ArmorySoulCrystal );
} }
Core::Inventory::~Inventory() 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 ) ); pItem->setCategory( static_cast< ItemUICategory >( itemInfo->ui_category ) );
g_charaDb.execute( "INSERT INTO charaglobalitem ( CharacterId, itemId, catalogId, stack, flags ) VALUES ( " + g_charaDb.execute( "INSERT INTO charaglobalitem ( CharacterId, itemId, catalogId, stack, flags ) VALUES ( " +
std::to_string( m_pOwner->getId() ) + ", " + std::to_string( m_pOwner->getId() ) + ", " + std::to_string( pItem->getUId() ) + ", " +
std::to_string( pItem->getUId() ) + ", " + std::to_string( pItem->getId() ) + ", " + std::to_string( itemAmount ) + ", " +
std::to_string( pItem->getId() ) + ", " +
std::to_string( itemAmount ) + ", " +
std::to_string( flags ) + ");" ); std::to_string( flags ) + ");" );
return pItem; return pItem;
} }
uint32_t Core::Inventory::getCurrency( CurrencyType type ) uint32_t Core::Inventory::getCurrency( CurrencyType type )
{ {
@ -177,7 +173,6 @@ uint32_t Core::Inventory::getCurrency( CurrencyType type )
return 0; return 0;
return currItem->getStackSize(); return currItem->getStackSize();
} }
uint32_t Core::Inventory::getCrystal( CrystalType type ) uint32_t Core::Inventory::getCrystal( CrystalType type )
@ -189,7 +184,6 @@ uint32_t Core::Inventory::getCrystal( CrystalType type )
return 0; return 0;
return currItem->getStackSize(); return currItem->getStackSize();
} }
bool Core::Inventory::addCrystal( CrystalType type, uint32_t amount ) bool Core::Inventory::addCrystal( CrystalType type, uint32_t amount )
@ -211,7 +205,6 @@ bool Core::Inventory::addCrystal( CrystalType type, uint32_t amount )
updateItemDb( currItem ); updateItemDb( currItem );
return true; return true;
} }
bool Core::Inventory::addCurrency( CurrencyType type, uint32_t amount ) bool Core::Inventory::addCurrency( CurrencyType type, uint32_t amount )
@ -233,7 +226,6 @@ bool Core::Inventory::addCurrency( CurrencyType type, uint32_t amount )
updateItemDb( currItem ); updateItemDb( currItem );
return true; return true;
} }
void Core::Inventory::updateCurrencyDb() void Core::Inventory::updateCurrencyDb()
@ -262,7 +254,6 @@ void Core::Inventory::updateCurrencyDb()
g_charaDb.execute( query ); g_charaDb.execute( query );
} }
void Core::Inventory::updateCrystalDb() void Core::Inventory::updateCrystalDb()
{ {
int32_t firstItemPos = -1; int32_t firstItemPos = -1;
@ -311,18 +302,10 @@ void Core::Inventory::updateBagDb( InventoryType type )
bool Core::Inventory::isArmory( uint16_t containerId ) bool Core::Inventory::isArmory( uint16_t containerId )
{ {
return return containerId == ArmoryBody || containerId == ArmoryEar || containerId == ArmoryFeet ||
containerId == ArmoryBody || containerId == ArmoryHand || containerId == ArmoryHead || containerId == ArmoryLegs ||
containerId == ArmoryEar || containerId == ArmoryMain || containerId == ArmoryOff || containerId == ArmoryRing ||
containerId == ArmoryFeet || containerId == ArmoryWaist || containerId == ArmoryWrist;
containerId == ArmoryHand ||
containerId == ArmoryHead ||
containerId == ArmoryLegs ||
containerId == ArmoryMain ||
containerId == ArmoryOff ||
containerId == ArmoryRing ||
containerId == ArmoryWaist ||
containerId == ArmoryWrist;
} }
uint16_t Core::Inventory::getArmoryToEquipSlot( uint8_t slotId ) uint16_t Core::Inventory::getArmoryToEquipSlot( uint8_t slotId )
@ -364,14 +347,11 @@ uint16_t Core::Inventory::getArmoryToEquipSlot( uint8_t slotId )
return 0; return 0;
} }
bool Core::Inventory::isEquipment( uint16_t containerId ) bool Core::Inventory::isEquipment( uint16_t containerId )
{ {
return containerId == GearSet0; return containerId == GearSet0;
} }
void Core::Inventory::updateMannequinDb( InventoryType type ) void Core::Inventory::updateMannequinDb( InventoryType type )
{ {
std::string query = "UPDATE charaitemgearset SET "; std::string query = "UPDATE charaitemgearset SET ";
@ -393,7 +373,6 @@ void Core::Inventory::updateMannequinDb( InventoryType type )
g_charaDb.execute( query ); g_charaDb.execute( query );
} }
void Core::Inventory::updateItemDb( Core::ItemPtr pItem ) const void Core::Inventory::updateItemDb( Core::ItemPtr pItem ) const
{ {
g_charaDb.execute( "UPDATE charaglobalitem SET stack = " + std::to_string( pItem->getStackSize() ) + " " + g_charaDb.execute( "UPDATE charaglobalitem SET stack = " + std::to_string( pItem->getStackSize() ) + " " +
@ -469,7 +448,6 @@ bool Core::Inventory::isObtainable( uint32_t catalogId, uint8_t quantity )
return true; return true;
} }
int16_t Core::Inventory::addItem( uint16_t inventoryId, int8_t slotId, uint32_t catalogId, uint8_t quantity ) int16_t Core::Inventory::addItem( uint16_t inventoryId, int8_t slotId, uint32_t catalogId, uint8_t quantity )
{ {
@ -506,8 +484,8 @@ int16_t Core::Inventory::addItem( uint16_t inventoryId, int8_t slotId, uint32_t
m_inventoryMap[inventoryId]->setItem( rSlotId, item ); m_inventoryMap[inventoryId]->setItem( rSlotId, item );
g_charaDb.execute( "UPDATE charaiteminventory SET container_" + std::to_string( rSlotId ) + " = " + std::to_string( item->getUId() ) + g_charaDb.execute( "UPDATE charaiteminventory SET container_" + std::to_string( rSlotId ) + " = " +
" WHERE storageId = " + std::to_string( inventoryId ) + std::to_string( item->getUId() ) + " WHERE storageId = " + std::to_string( inventoryId ) +
" AND CharacterId = " + std::to_string( m_pOwner->getId() ) ); " AND CharacterId = " + std::to_string( m_pOwner->getId() ) );
ZoneChannelPacket< FFXIVIpcUpdateInventorySlot > invUpPacket( 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; invUpPacket.data().condition = 30000;
m_pOwner->queuePacket( invUpPacket ); 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; return rSlotId;
} }
void Core::Inventory::moveItem( uint16_t fromInventoryId, uint8_t fromSlotId, uint16_t toInventoryId, uint8_t toSlot ) 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 ); m_pOwner->unequipItem( static_cast< EquipSlot >( fromSlotId ), tmpItem );
updateMannequinDb( static_cast< InventoryType >( fromInventoryId ) ); updateMannequinDb( static_cast< InventoryType >( fromInventoryId ) );
} }
} }
bool Core::Inventory::updateContainer( uint16_t containerId, uint8_t slotId, ItemPtr pItem ) bool Core::Inventory::updateContainer( uint16_t containerId, uint8_t slotId, ItemPtr pItem )
@ -605,9 +580,7 @@ void Core::Inventory::swapItem( uint16_t fromInventoryId, uint8_t fromSlotId, ui
// An item is being moved from bag0-3 to equippment, meaning // An item is being moved from bag0-3 to equippment, meaning
// the swapped out item will be placed in the matching armory. // the swapped out item will be placed in the matching armory.
if( isEquipment( toInventoryId ) if( isEquipment( toInventoryId ) && !isEquipment( fromInventoryId ) && !isArmory( fromInventoryId ) )
&& !isEquipment( fromInventoryId )
&& !isArmory( fromInventoryId ) )
{ {
updateContainer( fromInventoryId, fromSlotId, nullptr ); updateContainer( fromInventoryId, fromSlotId, nullptr );
fromInventoryId = getArmoryToEquipSlot( toSlot ); fromInventoryId = getArmoryToEquipSlot( toSlot );
@ -650,7 +623,8 @@ void Core::Inventory::discardItem( uint16_t fromInventoryId, uint8_t fromSlotId
Core::ItemPtr Core::Inventory::loadItem( uint64_t uId ) Core::ItemPtr Core::Inventory::loadItem( uint64_t uId )
{ {
// load actual item // 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() ) if( !itemRes->next() )
return nullptr; return nullptr;
@ -658,12 +632,8 @@ Core::ItemPtr Core::Inventory::loadItem( uint64_t uId )
{ {
auto itemInfo = g_exdData.getItemInfo( itemRes->getUInt( 1 ) ); auto itemInfo = g_exdData.getItemInfo( itemRes->getUInt( 1 ) );
bool isHq = itemRes->getUInt( 3 ) == 1 ? true : false; bool isHq = itemRes->getUInt( 3 ) == 1 ? true : false;
ItemPtr pItem( new Item( uId, ItemPtr pItem( new Item( uId, itemInfo->id, itemInfo->model_primary, itemInfo->model_secondary,
itemInfo->id, static_cast< ItemUICategory >( itemInfo->ui_category ), isHq ) );
itemInfo->model_primary,
itemInfo->model_secondary,
static_cast< ItemUICategory >( itemInfo->ui_category ),
isHq ) );
pItem->setStackSize( itemRes->getUInt( 2 ) ); pItem->setStackSize( itemRes->getUInt( 2 ) );
return pItem; return pItem;
@ -682,8 +652,10 @@ bool Core::Inventory::load()
"container_4, container_5, container_6, container_7, " "container_4, container_5, container_6, container_7, "
"container_8, container_9, container_10, container_11, " "container_8, container_9, container_10, container_11, "
"container_12, container_13 " "container_12, container_13 "
"FROM charaitemgearset " \ "FROM charaitemgearset "
"WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) + " " \ "WHERE CharacterId = " +
std::to_string( m_pOwner->getId() ) +
" "
"ORDER BY storageId ASC;" ); "ORDER BY storageId ASC;" );
while( res->next() ) while( res->next() )
@ -716,8 +688,10 @@ bool Core::Inventory::load()
"container_20, container_21, container_22, container_23, container_24, " "container_20, container_21, container_22, container_23, container_24, "
"container_25, container_26, container_27, container_28, container_29, " "container_25, container_26, container_27, container_28, container_29, "
"container_30, container_31, container_32, container_33, container_34 " "container_30, container_31, container_32, container_33, container_34 "
"FROM charaiteminventory " \ "FROM charaiteminventory "
"WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) + " " \ "WHERE CharacterId = " +
std::to_string( m_pOwner->getId() ) +
" "
"ORDER BY storageId ASC;" ); "ORDER BY storageId ASC;" );
while( bagRes->next() ) while( bagRes->next() )
@ -738,15 +712,16 @@ bool Core::Inventory::load()
} }
} }
/////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////
// Load Currency // Load Currency
auto curRes = g_charaDb.query( "SELECT storageId, " auto curRes = g_charaDb.query( "SELECT storageId, "
"container_0, container_1, container_2, container_3, container_4, " "container_0, container_1, container_2, container_3, container_4, "
"container_5, container_6, container_7, container_8, container_9, " "container_5, container_6, container_7, container_8, container_9, "
"container_10, container_11 " "container_10, container_11 "
"FROM charaitemcurrency " \ "FROM charaitemcurrency "
"WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) + " " \ "WHERE CharacterId = " +
std::to_string( m_pOwner->getId() ) +
" "
"ORDER BY storageId ASC;" ); "ORDER BY storageId ASC;" );
while( curRes->next() ) while( curRes->next() )
@ -767,7 +742,6 @@ bool Core::Inventory::load()
} }
} }
/////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////
// Load Crystals // Load Crystals
auto crystalRes = g_charaDb.query( "SELECT storageId, " 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_5, container_6, container_7, container_8, container_9, "
"container_10, container_11, container_12, container_13, container_14, " "container_10, container_11, container_12, container_13, container_14, "
"container_15, container_16, container_17 " "container_15, container_16, container_17 "
"FROM charaitemcrystal " \ "FROM charaitemcrystal "
"WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) + " " \ "WHERE CharacterId = " +
std::to_string( m_pOwner->getId() ) +
" "
"ORDER BY storageId ASC;" ); "ORDER BY storageId ASC;" );
while( crystalRes->next() ) while( crystalRes->next() )
@ -800,7 +776,6 @@ bool Core::Inventory::load()
return true; return true;
} }
void Core::Inventory::send() void Core::Inventory::send()
{ {
InventoryMap::iterator it; InventoryMap::iterator it;
@ -848,10 +823,7 @@ void Core::Inventory::send()
containerInfoPacket.data().numItems = it->second->getEntryCount(); containerInfoPacket.data().numItems = it->second->getEntryCount();
containerInfoPacket.data().containerId = it->second->getId(); containerInfoPacket.data().containerId = it->second->getId();
m_pOwner->queuePacket( containerInfoPacket ); m_pOwner->queuePacket( containerInfoPacket );
} }
} }
uint16_t Core::Inventory::calculateEquippedGearItemLevel() uint16_t Core::Inventory::calculateEquippedGearItemLevel()
@ -887,7 +859,6 @@ uint16_t Core::Inventory::calculateEquippedGearItemLevel()
return boost::algorithm::clamp( iLvlResult / 12, 0, 9999 ); return boost::algorithm::clamp( iLvlResult / 12, 0, 9999 );
} }
uint8_t Core::Inventory::getFreeSlotsInBags() uint8_t Core::Inventory::getFreeSlotsInBags()
{ {
uint8_t slots = 0; uint8_t slots = 0;
@ -898,7 +869,6 @@ uint8_t Core::Inventory::getFreeSlotsInBags()
return slots; return slots;
} }
Core::Inventory::ContainerType Core::Inventory::getContainerType( uint32_t containerId ) Core::Inventory::ContainerType Core::Inventory::getContainerType( uint32_t containerId )
{ {
if( containerId < 5 ) if( containerId < 5 )

View file

@ -1,11 +1,10 @@
#ifndef INVENTORY_H_ #ifndef INVENTORY_H_
#define INVENTORY_H_ #define INVENTORY_H_
#include <map>
#include <Server_Common/Common.h>
#include "../Forwards.h" #include "../Forwards.h"
#include <Server_Common/Common.h>
#include <map>
namespace Core namespace Core {
{
class ItemContainer; class ItemContainer;
@ -193,11 +192,10 @@ public:
uint32_t getNextUId(); uint32_t getNextUId();
private: private:
Entity::Player* m_pOwner; Entity::Player* m_pOwner;
InventoryMap m_inventoryMap; InventoryMap m_inventoryMap;
}; };
} } // namespace Core
#endif #endif

View file

@ -1,22 +1,19 @@
#include "Item.h"
#include <Server_Common/Common.h> #include <Server_Common/Common.h>
#include <Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include "Item.h"
extern Core::Data::ExdData g_exdData; extern Core::Data::ExdData g_exdData;
Core::Item::Item() Core::Item::Item()
{ {
} }
Core::Item::Item( uint32_t catalogId ) : Core::Item::Item( uint32_t catalogId ) : m_id( catalogId ), m_isHq( false )
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_id( catalogId ),
m_uId( uId ), m_uId( uId ),
m_category( static_cast< Common::ItemUICategory >( categoryId ) ), 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() Core::Item::~Item()
{ {
} }
float Core::Item::getAutoAttackDmg() const float Core::Item::getAutoAttackDmg() const

View file

@ -11,7 +11,8 @@ class Item
public: public:
Item(); Item();
Item( uint32_t catalogId ); 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(); ~Item();
uint32_t getId() const; uint32_t getId() const;
@ -54,7 +55,6 @@ public:
uint16_t getItemLevel() const; uint16_t getItemLevel() const;
protected: protected:
uint32_t m_id; uint32_t m_id;
@ -76,9 +76,8 @@ protected:
uint16_t m_weaponDmg; uint16_t m_weaponDmg;
float m_autoAttackDmg; float m_autoAttackDmg;
uint16_t m_itemLevel; uint16_t m_itemLevel;
}; };
} } // namespace Core
#endif #endif

View file

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

View file

@ -7,8 +7,7 @@
#include "../Forwards.h" #include "../Forwards.h"
namespace Core namespace Core {
{
typedef std::map< uint8_t, ItemPtr > ItemMap; typedef std::map< uint8_t, ItemPtr > ItemMap;
@ -42,6 +41,6 @@ namespace Core
Entity::PlayerPtr m_pOwner; Entity::PlayerPtr m_pOwner;
}; };
} } // namespace Core
#endif #endif

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,13 +1,12 @@
#include <cmath> #include <cmath>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Common.h>
#include "Actor/Actor.h" #include "Actor/Actor.h"
#include "Actor/Player.h" #include "Actor/Player.h"
#include <Server_Common/Common.h>
#include <Server_Common/Exd/ExdData.h>
#include "CalcStats.h" #include "CalcStats.h"
using namespace Core::Math; using namespace Core::Math;
using namespace Core::Entity; using namespace Core::Entity;
@ -58,14 +57,14 @@ float CalcStats::calculateBaseStat( PlayerPtr pPlayer )
uint32_t CalcStats::calculateMaxHp( PlayerPtr pPlayer ) uint32_t CalcStats::calculateMaxHp( PlayerPtr pPlayer )
{ {
// TODO: Replace ApproxBaseHP with something that can get us an accurate BaseHP. // 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? // Is there any way to pull reliable BaseHP without having to manually use a pet for every level, and using the
// More info here: https://docs.google.com/spreadsheets/d/1de06KGT0cNRUvyiXNmjNgcNvzBCCQku7jte5QxEQRbs/edit?usp=sharing // 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 classInfoIt = g_exdData.m_classJobInfoMap.find( static_cast< uint8_t >( pPlayer->getClass() ) );
auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find( pPlayer->getLevel() ); auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find( pPlayer->getLevel() );
if ( classInfoIt == g_exdData.m_classJobInfoMap.end() || if( classInfoIt == g_exdData.m_classJobInfoMap.end() || paramGrowthInfoIt == g_exdData.m_paramGrowthInfoMap.end() )
paramGrowthInfoIt == g_exdData.m_paramGrowthInfoMap.end() )
return 0; return 0;
uint8_t level = pPlayer->getLevel(); uint8_t level = pPlayer->getLevel();
@ -85,7 +84,8 @@ uint32_t CalcStats::calculateMaxHp( PlayerPtr pPlayer )
else else
approxBaseHp = paramGrowthInfoIt->second.mp_const * 0.7667f; 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; 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 classInfoIt = g_exdData.m_classJobInfoMap.find( static_cast< uint8_t >( pPlayer->getClass() ) );
auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find( pPlayer->getLevel() ); auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find( pPlayer->getLevel() );
if ( classInfoIt == g_exdData.m_classJobInfoMap.end() || if( classInfoIt == g_exdData.m_classJobInfoMap.end() || paramGrowthInfoIt == g_exdData.m_paramGrowthInfoMap.end() )
paramGrowthInfoIt == g_exdData.m_paramGrowthInfoMap.end() )
return 0; return 0;
float baseStat = calculateBaseStat( pPlayer ); float baseStat = calculateBaseStat( pPlayer );
@ -108,7 +107,8 @@ uint32_t CalcStats::calculateMaxMp( PlayerPtr pPlayer )
uint16_t jobModMp = classInfoIt->second.mod_mpcpgp; uint16_t jobModMp = classInfoIt->second.mod_mpcpgp;
uint16_t baseMp = paramGrowthInfoIt->second.mp_const; 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; return result;
} }

View file

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

View file

@ -1,20 +1,20 @@
#include <Server_Common/Common.h> #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/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/GamePacketParser.h>
#include <Server_Common/Network/PacketContainer.h>
#include <Server_Common/Util/Util.h>
#include <boost/format.hpp> #include <boost/format.hpp>
#include "GameConnection.h" #include "GameConnection.h"
#include "Actor/Player.h"
#include "DebugCommand/DebugCommandHandler.h"
#include "Forwards.h"
#include "Network/PacketWrappers/InitUIPacket.h"
#include "ServerZone.h" #include "ServerZone.h"
#include "Session.h" #include "Session.h"
#include "Zone/Zone.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::DebugCommandHandler g_gameCommandMgr;
extern Core::Logger g_log; extern Core::Logger g_log;
@ -24,20 +24,17 @@ using namespace Core::Common;
using namespace Core::Network::Packets; using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server; using namespace Core::Network::Packets::Server;
Core::Network::GameConnection::GameConnection( Core::Network::HivePtr pHive, Core::Network::GameConnection::GameConnection( Core::Network::HivePtr pHive, Core::Network::AcceptorPtr pAcceptor ) :
Core::Network::AcceptorPtr pAcceptor ) Connection( pHive ),
: Connection( pHive ) m_pAcceptor( pAcceptor ),
, m_pAcceptor( pAcceptor ) m_conType( ConnectionType::None )
, 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_zoneHandlerMap[opcode] = pHandler;
m_zoneHandlerStrMap[opcode] = handlerName; 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_chatHandlerMap[opcode] = pHandler;
m_chatHandlerStrMap[opcode] = handlerName; m_chatHandlerStrMap[opcode] = handlerName;
}; };
@ -46,18 +43,22 @@ Core::Network::GameConnection::GameConnection( Core::Network::HivePtr pHive,
setZoneHandler( ClientZoneIpcType::InitHandler, "InitHandler", &GameConnection::initHandler ); setZoneHandler( ClientZoneIpcType::InitHandler, "InitHandler", &GameConnection::initHandler );
setZoneHandler( ClientZoneIpcType::ChatHandler, "ChatHandler", &GameConnection::chatHandler ); 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::PlayTimeHandler, "PlayTimeHandler", &GameConnection::playTimeHandler );
setZoneHandler( ClientZoneIpcType::LogoutHandler, "LogoutHandler", &GameConnection::logoutHandler ); setZoneHandler( ClientZoneIpcType::LogoutHandler, "LogoutHandler", &GameConnection::logoutHandler );
setZoneHandler( ClientZoneIpcType::SocialListHandler, "SocialListHandler", &GameConnection::socialListHandler ); setZoneHandler( ClientZoneIpcType::SocialListHandler, "SocialListHandler", &GameConnection::socialListHandler );
setZoneHandler( ClientZoneIpcType::SetSearchInfoHandler, "SetSearchInfoHandler", &GameConnection::setSearchInfoHandler ); setZoneHandler( ClientZoneIpcType::SetSearchInfoHandler, "SetSearchInfoHandler",
setZoneHandler( ClientZoneIpcType::ReqSearchInfoHandler, "ReqSearchInfoHandler", &GameConnection::reqSearchInfoHandler ); &GameConnection::setSearchInfoHandler );
setZoneHandler( ClientZoneIpcType::ReqSearchInfoHandler, "ReqSearchInfoHandler",
&GameConnection::reqSearchInfoHandler );
setZoneHandler( ClientZoneIpcType::BlackListHandler, "BlackListHandler", &GameConnection::blackListHandler ); setZoneHandler( ClientZoneIpcType::BlackListHandler, "BlackListHandler", &GameConnection::blackListHandler );
setZoneHandler( ClientZoneIpcType::LinkshellListHandler, "LinkshellListHandler", &GameConnection::linkshellListHandler ); setZoneHandler( ClientZoneIpcType::LinkshellListHandler, "LinkshellListHandler",
&GameConnection::linkshellListHandler );
setZoneHandler( ClientZoneIpcType::FcInfoReqHandler, "FcInfoReqHandler", &GameConnection::fcInfoReqHandler ); 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::GMCommand1, "GMCommand1", &GameConnection::gm1Handler );
setZoneHandler( ClientZoneIpcType::GMCommand2, "GMCommand2", &GameConnection::gm2Handler ); 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::TalkEventHandler, "EventHandler", &GameConnection::eventHandler );
setZoneHandler( ClientZoneIpcType::EmoteEventHandler, "EventHandler", &GameConnection::eventHandler ); setZoneHandler( ClientZoneIpcType::EmoteEventHandler, "EventHandler", &GameConnection::eventHandler );
@ -92,17 +95,16 @@ Core::Network::GameConnection::GameConnection( Core::Network::HivePtr pHive,
setZoneHandler( ClientZoneIpcType::CFRegisterRoulette, "CFRegisterRoulette", &GameConnection::cfRegisterRoulette ); 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 ); setZoneHandler( ClientZoneIpcType::PerformNoteHandler, "PerformNoteHandler", &GameConnection::performNoteHandler );
setChatHandler( ClientChatIpcType::TellReq, "TellReq", &GameConnection::tellHandler ); setChatHandler( ClientChatIpcType::TellReq, "TellReq", &GameConnection::tellHandler );
} }
Core::Network::GameConnection::~GameConnection() = default; Core::Network::GameConnection::~GameConnection() = default;
// overwrite the parents onConnect for our game socket needs // 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 )
{ {
@ -112,7 +114,6 @@ void Core::Network::GameConnection::OnAccept( const std::string & host, uint16_t
g_log.info( "Connect from " + m_socket.remote_endpoint().address().to_string() ); g_log.info( "Connect from " + m_socket.remote_endpoint().address().to_string() );
} }
void Core::Network::GameConnection::OnDisconnect() void Core::Network::GameConnection::OnDisconnect()
{ {
g_log.debug( "GameConnection DISCONNECT" ); g_log.debug( "GameConnection DISCONNECT" );
@ -142,8 +143,8 @@ void Core::Network::GameConnection::OnRecv( std::vector< uint8_t > & buffer )
// Dissect packet list // Dissect packet list
std::vector< Packets::FFXIVARR_PACKET_RAW > packetList; std::vector< Packets::FFXIVARR_PACKET_RAW > packetList;
const auto packetResult = Packets::getPackets( buffer, sizeof( struct FFXIVARR_PACKET_HEADER ), const auto packetResult =
packetHeader, packetList ); Packets::getPackets( buffer, sizeof( struct FFXIVARR_PACKET_HEADER ), packetHeader, packetList );
if( packetResult == Incomplete ) if( packetResult == Incomplete )
{ {
@ -189,25 +190,24 @@ void Core::Network::GameConnection::handleZonePacket( const Packets::GamePacket&
auto itStr = m_zoneHandlerStrMap.find( pPacket.getSubType() ); auto itStr = m_zoneHandlerStrMap.find( pPacket.getSubType() );
std::string name = itStr != m_zoneHandlerStrMap.end() ? itStr->second : "unknown"; 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 // dont display packet notification if it is a ping or pos update, don't want the spam
if( pPacket.getSubType() != PingHandler && if( pPacket.getSubType() != PingHandler && pPacket.getSubType() != UpdatePositionHandler )
pPacket.getSubType() != UpdatePositionHandler )
g_log.debug( sessionStr + " Handling Zone IPC : " + name + "( " + g_log.debug(
boost::str( boost::format( "%|04X|" ) % sessionStr + " Handling Zone IPC : " + name + "( " +
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() ); ( this->*( it->second ) )( pPacket, *m_pSession->getPlayer() );
} }
else else
{ {
g_log.debug( sessionStr + " Undefined Zone IPC : Unknown ( " + g_log.debug( sessionStr + " Undefined Zone IPC : Unknown ( " +
boost::str( boost::format( "%|04X|" ) % boost::str( boost::format( "%|04X|" ) % static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) +
static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) + " )" ); " )" );
g_log.debug( "\n" + pPacket.toString() ); g_log.debug( "\n" + pPacket.toString() );
} }
} }
void Core::Network::GameConnection::handleChatPacket( const Packets::GamePacket& pPacket ) void Core::Network::GameConnection::handleChatPacket( const Packets::GamePacket& pPacket )
{ {
auto it = m_chatHandlerMap.find( pPacket.getSubType() ); 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 // 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 + "( " + g_log.debug( sessionStr + " Handling Chat IPC : " + name + "( " +
boost::str( boost::format( "%|04X|" ) % boost::str( boost::format( "%|04X|" ) % static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) +
static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) + " )" ); " )" );
( this->*( it->second ) )( pPacket, *m_pSession->getPlayer() ); ( this->*( it->second ) )( pPacket, *m_pSession->getPlayer() );
} }
else else
{ {
g_log.debug( sessionStr + " Undefined Chat IPC : Unknown ( " + g_log.debug( sessionStr + " Undefined Chat IPC : Unknown ( " +
boost::str( boost::format( "%|04X|" ) % boost::str( boost::format( "%|04X|" ) % static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) +
static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) + " )" ); " )" );
g_log.debug( pPacket.toString() ); g_log.debug( pPacket.toString() );
} }
} }
@ -250,7 +250,6 @@ void Core::Network::GameConnection::handlePacket( Core::Network::Packets::GamePa
handleChatPacket( *pPacket ); handleChatPacket( *pPacket );
break; break;
} }
} }
void Core::Network::GameConnection::sendPackets( Packets::PacketContainer* pPacket ) void Core::Network::GameConnection::sendPackets( Packets::PacketContainer* pPacket )
@ -297,7 +296,6 @@ void Core::Network::GameConnection::processOutQueue()
if( totalSize > 0 ) if( totalSize > 0 )
sendPackets( &pRP ); sendPackets( &pRP );
} }
void Core::Network::GameConnection::sendSinglePacket( Packets::GamePacket* pPacket ) void Core::Network::GameConnection::sendSinglePacket( Packets::GamePacket* pPacket )
@ -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 ) const std::vector< Core::Network::Packets::FFXIVARR_PACKET_RAW >& packetData )
{ {
// if a session is set, update the last time it recieved a game packet // if a session is set, update the last time it recieved a game packet
@ -428,7 +427,6 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
} }
break; break;
} }
case 3: // game packet case 3: // game packet
{ {
@ -453,6 +451,5 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
break; break;
} }
} }
} }
} }

View file

@ -1,9 +1,9 @@
#ifndef GAMECONNECTION_H #ifndef GAMECONNECTION_H
#define GAMECONNECTION_H #define GAMECONNECTION_H
#include <Server_Common/Network/Connection.h>
#include <Server_Common/Network/Acceptor.h> #include <Server_Common/Network/Acceptor.h>
#include <Server_Common/Network/CommonNetwork.h> #include <Server_Common/Network/CommonNetwork.h>
#include <Server_Common/Network/Connection.h>
#include <Server_Common/Network/GamePacket.h> #include <Server_Common/Network/GamePacket.h>
#include <Server_Common/Util/LockedQueue.h> #include <Server_Common/Util/LockedQueue.h>
@ -107,7 +107,6 @@ public:
DECLARE_HANDLER( cfRegisterRoulette ); DECLARE_HANDLER( cfRegisterRoulette );
DECLARE_HANDLER( cfDutyAccepted ); DECLARE_HANDLER( cfDutyAccepted );
DECLARE_HANDLER( skillHandler ); DECLARE_HANDLER( skillHandler );
DECLARE_HANDLER( gm1Handler ); DECLARE_HANDLER( gm1Handler );
@ -118,13 +117,9 @@ public:
DECLARE_HANDLER( performNoteHandler ); DECLARE_HANDLER( performNoteHandler );
DECLARE_HANDLER( tellHandler ); DECLARE_HANDLER( tellHandler );
}; };
} // namespace Network
} // namespace Core
}
}
#endif #endif

View file

@ -1,39 +1,39 @@
#include <Server_Common/Common.h> #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/CommonNetwork.h>
#include <Server_Common/Network/GamePacketNew.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/PacketContainer.h>
#include <boost/format.hpp> #include <boost/format.hpp>
#include "Network/GameConnection.h" #include "Network/GameConnection.h"
#include "ServerZone.h"
#include "Session.h" #include "Session.h"
#include "Zone/Zone.h" #include "Zone/Zone.h"
#include "Zone/ZonePosition.h"
#include "ServerZone.h"
#include "Zone/ZoneMgr.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/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/ActorControlPacket144.h" #include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Network/PacketWrappers/EventStartPacket.h" #include "Network/PacketWrappers/ChatPacket.h"
#include "Network/PacketWrappers/EventFinishPacket.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/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/Action.h"
#include "Action/ActionTeleport.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::Logger g_log;
extern Core::ServerZone g_serverZone; extern Core::ServerZone g_serverZone;
@ -45,8 +45,7 @@ using namespace Core::Common;
using namespace Core::Network::Packets; using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server; using namespace Core::Network::Packets::Server;
void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
Entity::Player& player )
{ {
uint16_t commandId = inPacket.getValAt< uint16_t >( 0x20 ); uint16_t commandId = inPacket.getValAt< uint16_t >( 0x20 );
uint64_t param1 = inPacket.getValAt< uint64_t >( 0x24 ); uint64_t param1 = inPacket.getValAt< uint64_t >( 0x24 );
@ -55,13 +54,11 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
uint32_t param2 = inPacket.getValAt< uint32_t >( 0x2C ); uint32_t param2 = inPacket.getValAt< uint32_t >( 0x2C );
uint64_t param3 = inPacket.getValAt< uint64_t >( 0x38 ); uint64_t param3 = inPacket.getValAt< uint64_t >( 0x38 );
g_log.debug( "[" + std::to_string( m_pSession->getId() ) + "] Incoming action: " + g_log.debug( "[" + std::to_string( m_pSession->getId() ) +
boost::str( boost::format( "%|04X|" ) % ( uint32_t ) ( commandId & 0xFFFF ) ) + "] Incoming action: " + boost::str( boost::format( "%|04X|" ) % ( uint32_t )( commandId & 0xFFFF ) ) +
"\nparam1: " + boost::str( boost::format( "%|016X|" ) % ( uint64_t )( param1 & 0xFFFFFFFFFFFFFFF ) ) + "\nparam1: " + boost::str( boost::format( "%|016X|" ) % ( uint64_t )( param1 & 0xFFFFFFFFFFFFFFF ) ) +
"\nparam2: " + boost::str( boost::format( "%|08X|" ) % ( uint32_t )( param2 & 0xFFFFFFFF ) ) + "\nparam2: " + boost::str( boost::format( "%|08X|" ) % ( uint32_t )( param2 & 0xFFFFFFFF ) ) +
"\nparam3: " + boost::str( boost::format( "%|016X|" ) % ( uint64_t ) ( param3 & 0xFFFFFFFFFFFFFFF ) ) "\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());
@ -160,7 +157,6 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
default: default:
break; break;
} }
} }
case 0xC9: // Finish zoning case 0xC9: // Finish zoning
{ {
@ -182,7 +178,10 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
player.setStatus( Entity::Actor::ActorStatus::Idle ); player.setStatus( Entity::Actor::ActorStatus::Idle );
player.sendToInRangeSet( ActorControlPacket143( player.getId(), ZoneIn, 0x01, 0x01, 0, 111 ), true ); 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 else
player.sendToInRangeSet( ActorControlPacket143( player.getId(), ZoneIn, 0x01, 0x00, 0, 111 ), true ); player.sendToInRangeSet( ActorControlPacket143( player.getId(), ZoneIn, 0x01, 0x00, 0, 111 ), true );
@ -210,8 +209,11 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
auto fromAetheryte = g_exdData.getAetheryteInfo( g_exdData.m_zoneInfoMap[player.getZoneId()].aetheryte_index ); 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 // 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 ) + auto cost =
pow( fromAetheryte->map_coord_y - targetAetheryte->map_coord_y, 2 ) ) / 2 ) + 100 ); 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 // cap at 999 gil
cost = cost > uint16_t{ 999 } ? uint16_t{ 999 } : cost; cost = cost > uint16_t{ 999 } ? uint16_t{ 999 } : cost;
@ -222,7 +224,8 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
if( !insufficientGil ) 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 ); player.setCurrentAction( pActionTeleport );
} }
} }

View file

@ -1,17 +1,17 @@
#include <Server_Common/Common.h> #include <Server_Common/Common.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Network/CommonNetwork.h> #include <Server_Common/Network/CommonNetwork.h>
#include <Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Network/PacketContainer.h> #include <Server_Common/Network/PacketContainer.h>
#include "Actor/Player.h"
#include "Network/GameConnection.h" #include "Network/GameConnection.h"
#include "Session.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/ActorControlPacket144.h" #include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h" #include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
#include "Actor/Player.h" #include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Session.h"
#include "Forwards.h" #include "Forwards.h"
@ -21,9 +21,7 @@ using namespace Core::Common;
using namespace Core::Network::Packets; using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server; 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() ); ZoneChannelPacket< FFXIVIpcCFDutyInfo > dutyInfoPacket( player.getId() );
@ -39,11 +37,9 @@ void Core::Network::GameConnection::cfDutyInfoRequest( const Packets::GamePacket
ZoneChannelPacket< FFXIVIpcCFPlayerInNeed > inNeedsPacket( player.getId() ); ZoneChannelPacket< FFXIVIpcCFPlayerInNeed > inNeedsPacket( player.getId() );
queueOutPacket( inNeedsPacket ); queueOutPacket( inNeedsPacket );
} }
void Core::Network::GameConnection::cfRegisterDuty( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::cfRegisterDuty( const Packets::GamePacket& inPacket, Entity::Player& player )
Entity::Player& player)
{ {
// TODO use for loop for this // TODO use for loop for this
auto contentId1 = inPacket.getValAt< uint16_t >( 46 ); auto contentId1 = inPacket.getValAt< uint16_t >( 46 );
@ -66,14 +62,12 @@ void Core::Network::GameConnection::cfRegisterDuty( const Packets::GamePacket& i
queueOutPacket( cfCancelPacket ); queueOutPacket( cfCancelPacket );
} }
void Core::Network::GameConnection::cfRegisterRoulette( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::cfRegisterRoulette( const Packets::GamePacket& inPacket, Entity::Player& player )
Entity::Player& player)
{ {
player.sendDebug( "Roulette register" ); player.sendDebug( "Roulette register" );
} }
void Core::Network::GameConnection::cfDutyAccepted( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::cfDutyAccepted( const Packets::GamePacket& inPacket, Entity::Player& player )
Entity::Player& player)
{ {
player.sendDebug( "TODO: Duty accept" ); player.sendDebug( "TODO: Duty accept" );
} }

View file

@ -6,19 +6,19 @@
#include <boost/format.hpp> #include <boost/format.hpp>
#include "Actor/Player.h"
#include "Event/EventHelper.h"
#include "Forwards.h"
#include "Network/GameConnection.h" #include "Network/GameConnection.h"
#include "Session.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/ActorControlPacket144.h" #include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Network/PacketWrappers/EventStartPacket.h"
#include "Network/PacketWrappers/EventFinishPacket.h" #include "Network/PacketWrappers/EventFinishPacket.h"
#include "Network/PacketWrappers/EventStartPacket.h"
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h" #include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Script/ScriptManager.h" #include "Script/ScriptManager.h"
#include "Actor/Player.h" #include "Session.h"
#include "Forwards.h"
#include "Event/EventHelper.h"
extern Core::Scripting::ScriptManager g_scriptMgr; extern Core::Scripting::ScriptManager g_scriptMgr;
@ -26,21 +26,20 @@ using namespace Core::Common;
using namespace Core::Network::Packets; using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server; using namespace Core::Network::Packets::Server;
void Core::Network::GameConnection::eventHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::eventHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
Entity::Player& player )
{ {
uint16_t eventHandlerId = inPacket.getValAt< uint16_t >( 0x12 ); 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 // 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( EventStartPacket( player.getId(), actorId, eventId, 1, 0, 0 ) );
player.queuePacket( EventFinishPacket( player.getId(), eventId, 1, 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 // this isn't ideal as it will also reset any other status that might be active
player.queuePacket( PlayerStateFlagsPacket( player, PlayerStateFlagList{} ) ); 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( "---------------------------------------" );
player.sendDebug( "EventHandler ( " + eventIdStr + " )" ); player.sendDebug( "EventHandler ( " + eventIdStr + " )" );
@ -70,7 +69,6 @@ void Core::Network::GameConnection::eventHandler( const Packets::GamePacket& inP
break; break;
} }
case ClientZoneIpcType::WithinRangeEventHandler: case ClientZoneIpcType::WithinRangeEventHandler:
{ {
uint32_t eventId = inPacket.getValAt< uint32_t >( 0x24 ); uint32_t eventId = inPacket.getValAt< uint32_t >( 0x24 );
@ -147,11 +145,5 @@ void Core::Network::GameConnection::eventHandler( const Packets::GamePacket& inP
// abortEventFunc( pPlayer, 0, eventId ); // abortEventFunc( pPlayer, 0, eventId );
break; break;
} }
} }
} }

View file

@ -1,39 +1,39 @@
#include <Server_Common/Common.h> #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/CommonNetwork.h>
#include <Server_Common/Network/GamePacketNew.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/PacketContainer.h>
#include <boost/format.hpp> #include <boost/format.hpp>
#include "Network/GameConnection.h" #include "Network/GameConnection.h"
#include "ServerZone.h"
#include "Session.h" #include "Session.h"
#include "Zone/Zone.h" #include "Zone/Zone.h"
#include "Zone/ZonePosition.h"
#include "ServerZone.h"
#include "Zone/ZoneMgr.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/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/ActorControlPacket144.h" #include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Network/PacketWrappers/EventStartPacket.h" #include "Network/PacketWrappers/ChatPacket.h"
#include "Network/PacketWrappers/EventFinishPacket.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/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/Action.h"
#include "Action/ActionTeleport.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::Logger g_log;
extern Core::ServerZone g_serverZone; 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 param2 = inPacket.getValAt< uint32_t >( 0x28 );
uint32_t param3 = inPacket.getValAt< uint32_t >( 0x38 ); uint32_t param3 = inPacket.getValAt< uint32_t >( 0x38 );
g_log.debug( player.getName() + " used GM1 commandId: " + std::to_string( commandId ) + g_log.debug( player.getName() + " used GM1 commandId: " + std::to_string( commandId ) + ", params: " +
", params: " + std::to_string( param1 ) + ", " + std::to_string( param1 ) + ", " + std::to_string( param2 ) + ", " + std::to_string( param3 ) );
std::to_string( param2 ) + ", " + std::to_string( param3 ) );
Core::Entity::ActorPtr targetActor; Core::Entity::ActorPtr targetActor;
if( player.getId() == param3 ) if( player.getId() == param3 )
{ {
targetActor = player.getAsPlayer(); targetActor = player.getAsPlayer();
@ -192,20 +190,17 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
if( targetPlayer->getZoneId() != player.getZoneId() ) if( targetPlayer->getZoneId() != player.getZoneId() )
targetPlayer->setZone( player.getZoneId() ); targetPlayer->setZone( player.getZoneId() );
targetPlayer->changePosition( player.getPos().x, player.getPos().y, player.getPos().z, targetPlayer->changePosition( player.getPos().x, player.getPos().y, player.getPos().z, player.getRotation() );
player.getRotation() );
player.sendNotice( "Calling " + targetPlayer->getName() ); player.sendNotice( "Calling " + targetPlayer->getName() );
break; break;
} }
case GmCommand::Inspect: case GmCommand::Inspect:
{ {
player.sendNotice( "Name: " + targetPlayer->getName() + player.sendNotice(
"\nGil: " + std::to_string( targetPlayer->getCurrency( 1 ) ) + "Name: " + targetPlayer->getName() + "\nGil: " + std::to_string( targetPlayer->getCurrency( 1 ) ) +
"\nZone: " + targetPlayer->getCurrentZone()->getName() + "\nZone: " + targetPlayer->getCurrentZone()->getName() + "(" + std::to_string( targetPlayer->getZoneId() ) +
"(" + std::to_string( targetPlayer->getZoneId() ) + ")" + ")" + "\nClass: " + std::to_string( static_cast< uint8_t >( targetPlayer->getClass() ) ) + "\nLevel: " +
"\nClass: " + std::to_string( static_cast< uint8_t >( targetPlayer->getClass() ) ) + std::to_string( targetPlayer->getLevel() ) + "\nExp: " + std::to_string( targetPlayer->getExp() ) +
"\nLevel: " + std::to_string( targetPlayer->getLevel() ) +
"\nExp: " + std::to_string( targetPlayer->getExp() ) +
"\nSearchMessage: " + targetPlayer->getSearchMessage() + "\nSearchMessage: " + targetPlayer->getSearchMessage() +
"\nPlayTime: " + std::to_string( targetPlayer->getPlayTime() ) ); "\nPlayTime: " + std::to_string( targetPlayer->getPlayTime() ) );
break; break;
@ -236,8 +231,8 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
strcpy( searchInfoPacket.data().searchMessage, targetPlayer->getSearchMessage() ); strcpy( searchInfoPacket.data().searchMessage, targetPlayer->getSearchMessage() );
targetPlayer->queuePacket( searchInfoPacket ); targetPlayer->queuePacket( searchInfoPacket );
targetPlayer->sendToInRangeSet( ActorControlPacket142( player.getId(), SetStatusIcon, targetPlayer->sendToInRangeSet(
static_cast< uint8_t >( player.getOnlineStatus() ) ), ActorControlPacket142( player.getId(), SetStatusIcon, static_cast< uint8_t >( player.getOnlineStatus() ) ),
true ); true );
player.sendNotice( "Icon for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) ); player.sendNotice( "Icon for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
break; break;
@ -273,8 +268,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
else else
targetActor->setInvincibilityType( Common::InvincibilityType::InvincibilityRefill ); targetActor->setInvincibilityType( Common::InvincibilityType::InvincibilityRefill );
player.sendNotice( "Invincibility for " + targetPlayer->getName() + player.sendNotice( "Invincibility for " + targetPlayer->getName() + " was switched." );
" was switched." );
break; break;
} }
case GmCommand::Orchestrion: case GmCommand::Orchestrion:
@ -286,8 +280,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
for( uint8_t i = 0; i < 255; i++ ) for( uint8_t i = 0; i < 255; i++ )
targetActor->getAsPlayer()->learnSong( i, 0 ); targetActor->getAsPlayer()->learnSong( i, 0 );
player.sendNotice( "All Songs for " + targetPlayer->getName() + player.sendNotice( "All Songs for " + targetPlayer->getName() + " were turned on." );
" were turned on." );
} }
else else
{ {
@ -333,9 +326,8 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
else else
{ {
targetPlayer->removeCurrency( 1, param1 ); targetPlayer->removeCurrency( 1, param1 );
player.sendNotice( "Removed " + std::to_string( param1 ) + player.sendNotice( "Removed " + std::to_string( param1 ) + " Gil from " + targetPlayer->getName() + "(" +
" Gil from " + targetPlayer->getName() + std::to_string( gil ) + " before)" );
"(" + std::to_string( gil ) + " before)" );
} }
break; break;
} }
@ -367,16 +359,16 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
case GmCommand::GC: case GmCommand::GC:
{ {
targetPlayer->setGc( param1 ); targetPlayer->setGc( param1 );
player.sendNotice( "GC for " + targetPlayer->getName() + player.sendNotice( "GC for " + targetPlayer->getName() + " was set to " +
" was set to " + std::to_string( targetPlayer->getGc() ) ); std::to_string( targetPlayer->getGc() ) );
break; break;
} }
case GmCommand::GCRank: case GmCommand::GCRank:
{ {
targetPlayer->setGcRankAt( targetPlayer->getGc() - 1, param1 ); targetPlayer->setGcRankAt( targetPlayer->getGc() - 1, param1 );
player.sendNotice( "GC Rank for " + targetPlayer->getName() + player.sendNotice( "GC Rank for " + targetPlayer->getName() + " for GC " +
" for GC " + std::to_string( targetPlayer->getGc() ) + std::to_string( targetPlayer->getGc() ) + " was set to " +
" was set to " + std::to_string( targetPlayer->getGcRankArray()[targetPlayer->getGc() - 1] ) ); std::to_string( targetPlayer->getGcRankArray()[targetPlayer->getGc() - 1] ) );
break; break;
} }
case GmCommand::Aetheryte: case GmCommand::Aetheryte:
@ -388,8 +380,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
for( uint8_t i = 0; i < 255; i++ ) for( uint8_t i = 0; i < 255; i++ )
targetActor->getAsPlayer()->registerAetheryte( i ); targetActor->getAsPlayer()->registerAetheryte( i );
player.sendNotice( "All Aetherytes for " + targetPlayer->getName() + player.sendNotice( "All Aetherytes for " + targetPlayer->getName() + " were turned on." );
" were turned on." );
} }
else else
{ {
@ -412,16 +403,17 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
{ {
targetPlayer->setPosition( targetPlayer->getPos() ); targetPlayer->setPosition( targetPlayer->getPos() );
targetPlayer->performZoning( param1, targetPlayer->getPos(), 0 ); 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; break;
} }
case GmCommand::TeriInfo: case GmCommand::TeriInfo:
{ {
player.sendNotice( "ZoneId: " + std::to_string( player.getZoneId() ) + "\nName: " + player.sendNotice( "ZoneId: " + std::to_string( player.getZoneId() ) +
player.getCurrentZone()->getName() + "\nInternalName: " + "\nName: " + player.getCurrentZone()->getName() +
player.getCurrentZone()->getInternalName() + "\nPopCount: " + "\nInternalName: " + player.getCurrentZone()->getInternalName() +
std::to_string( player.getCurrentZone()->getPopCount() ) + "\nPopCount: " + std::to_string( player.getCurrentZone()->getPopCount() ) +
"\nCurrentWeather:" + std::to_string( player.getCurrentZone()->getCurrentWeather() ) + "\nCurrentWeather:" + std::to_string( player.getCurrentZone()->getCurrentWeather() ) +
"\nNextWeather:" + std::to_string( player.getCurrentZone()->getNextWeather() ) ); "\nNextWeather:" + std::to_string( player.getCurrentZone()->getNextWeather() ) );
break; break;
@ -443,7 +435,6 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
player.sendUrgent( "GM1 Command not implemented: " + std::to_string( commandId ) ); player.sendUrgent( "GM1 Command not implemented: " + std::to_string( commandId ) );
break; break;
} }
} }
void Core::Network::GameConnection::gm2Handler( const Packets::GamePacket& inPacket, Entity::Player& player ) 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->setStatus( Entity::Actor::ActorStatus::Idle );
targetPlayer->sendToInRangeSet( ActorControlPacket143( player.getId(), ZoneIn, 0x01, 0x01, 0, 113 ), true ); targetPlayer->sendToInRangeSet( ActorControlPacket143( player.getId(), ZoneIn, 0x01, 0x01, 0, 113 ), true );
targetPlayer->sendToInRangeSet( ActorControlPacket142( player.getId(), SetStatus, targetPlayer->sendToInRangeSet(
static_cast< uint8_t >( Entity::Actor::ActorStatus::Idle ) ), true ); ActorControlPacket142( player.getId(), SetStatus,
static_cast< uint8_t >( Entity::Actor::ActorStatus::Idle ) ),
true );
player.sendNotice( "Raised " + targetPlayer->getName() ); player.sendNotice( "Raised " + targetPlayer->getName() );
break; break;
} }
@ -510,5 +503,4 @@ void Core::Network::GameConnection::gm2Handler( const Packets::GamePacket& inPac
player.sendUrgent( "GM2 Command not implemented: " + std::to_string( commandId ) ); player.sendUrgent( "GM2 Command not implemented: " + std::to_string( commandId ) );
break; break;
} }
} }

View file

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

View file

@ -1,42 +1,41 @@
#include <Server_Common/Common.h> #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/CommonNetwork.h>
#include <Server_Common/Network/GamePacketNew.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/PacketContainer.h>
#include <Server_Common/Network/PacketDef/Chat/ServerChatDef.h> #include <Server_Common/Network/PacketDef/Chat/ServerChatDef.h>
#include <Server_Common/Database/DatabaseDef.h>
#include <boost/format.hpp> #include <boost/format.hpp>
#include "Network/GameConnection.h" #include "Network/GameConnection.h"
#include "ServerZone.h"
#include "Session.h" #include "Session.h"
#include "Zone/Zone.h" #include "Zone/Zone.h"
#include "Zone/ZonePosition.h"
#include "ServerZone.h"
#include "Zone/ZoneMgr.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/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/ActorControlPacket144.h" #include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Network/PacketWrappers/EventStartPacket.h" #include "Network/PacketWrappers/ChatPacket.h"
#include "Network/PacketWrappers/EventFinishPacket.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/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/Action.h"
#include "Action/ActionTeleport.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::Logger g_log;
extern Core::ServerZone g_serverZone; extern Core::ServerZone g_serverZone;
@ -48,16 +47,14 @@ using namespace Core::Common;
using namespace Core::Network::Packets; using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server; using namespace Core::Network::Packets::Server;
void Core::Network::GameConnection::fcInfoReqHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::fcInfoReqHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
Entity::Player& player )
{ {
GamePacketPtr pPe( new GamePacket( 0xDD, 0x78, player.getId(), player.getId() ) ); GamePacketPtr pPe( new GamePacket( 0xDD, 0x78, player.getId(), player.getId() ) );
pPe->setValAt< uint8_t >( 0x48, 0x01 ); pPe->setValAt< uint8_t >( 0x48, 0x01 );
queueOutPacket( pPe ); queueOutPacket( pPe );
} }
void Core::Network::GameConnection::setSearchInfoHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::setSearchInfoHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
Entity::Player& player )
{ {
uint32_t inval = inPacket.getValAt< uint32_t >( 0x20 ); uint32_t inval = inPacket.getValAt< uint32_t >( 0x20 );
uint32_t inval1 = inPacket.getValAt< uint32_t >( 0x24 ); 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() ); strcpy( searchInfoPacket.data().searchMessage, player.getSearchMessage() );
queueOutPacket( searchInfoPacket ); queueOutPacket( searchInfoPacket );
player.sendToInRangeSet( ActorControlPacket142( player.getId(), SetStatusIcon, player.sendToInRangeSet(
static_cast< uint8_t >( player.getOnlineStatus() ) ), true ); ActorControlPacket142( player.getId(), SetStatusIcon, static_cast< uint8_t >( player.getOnlineStatus() ) ),
true );
} }
void Core::Network::GameConnection::reqSearchInfoHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::reqSearchInfoHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
Entity::Player& player )
{ {
ZoneChannelPacket< FFXIVIpcInitSearchInfo > searchInfoPacket( player.getId() ); ZoneChannelPacket< FFXIVIpcInitSearchInfo > searchInfoPacket( player.getId() );
searchInfoPacket.data().onlineStatusFlags = player.getOnlineStatusMask(); searchInfoPacket.data().onlineStatusFlags = player.getOnlineStatusMask();
@ -100,15 +97,13 @@ void Core::Network::GameConnection::reqSearchInfoHandler( const Packets::GamePac
queueOutPacket( searchInfoPacket ); queueOutPacket( searchInfoPacket );
} }
void Core::Network::GameConnection::linkshellListHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::linkshellListHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
Entity::Player& player )
{ {
ZoneChannelPacket< FFXIVIpcLinkshellList > linkshellListPacket( player.getId() ); ZoneChannelPacket< FFXIVIpcLinkshellList > linkshellListPacket( player.getId() );
queueOutPacket( linkshellListPacket ); queueOutPacket( linkshellListPacket );
} }
void Core::Network::GameConnection::updatePositionHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::updatePositionHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
Entity::Player& player )
{ {
// if the player is marked for zoning we no longer want to update his pos // if the player is marked for zoning we no longer want to update his pos
if( player.isMarkedForZoning() ) if( player.isMarkedForZoning() )
@ -184,8 +179,7 @@ void Core::Network::GameConnection::updatePositionHandler( const Packets::GamePa
return; return;
player.setRotation( inPacket.getValAt< float >( 0x20 ) ); player.setRotation( inPacket.getValAt< float >( 0x20 ) );
player.setPosition( inPacket.getValAt< float >( 0x2c ), player.setPosition( inPacket.getValAt< float >( 0x2c ), inPacket.getValAt< float >( 0x30 ),
inPacket.getValAt< float >( 0x30 ),
inPacket.getValAt< float >( 0x34 ) ); inPacket.getValAt< float >( 0x34 ) );
if( ( player.getCurrentAction() != nullptr ) && bPosChanged ) if( ( player.getCurrentAction() != nullptr ) && bPosChanged )
@ -278,18 +272,17 @@ void Core::Network::GameConnection::updatePositionHandler( const Packets::GamePa
MoveActorPacket movePacket( player, unk1, unk2, unk3, unk4 ); MoveActorPacket movePacket( player, unk1, unk2, unk3, unk4 );
player.sendToInRangeSet( movePacket ); player.sendToInRangeSet( movePacket );
} }
void Core::Network::GameConnection::reqEquipDisplayFlagsHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::reqEquipDisplayFlagsHandler( const Packets::GamePacket& inPacket,
Entity::Player& player ) 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 ) ); player.setEquipDisplayFlags( inPacket.getValAt< uint8_t >( 0x20 ) );
} }
void Core::Network::GameConnection::zoneLineHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::zoneLineHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
Entity::Player& player )
{ {
uint32_t zoneLineId = inPacket.getValAt< uint32_t >( 0x20 ); uint32_t zoneLineId = inPacket.getValAt< uint32_t >( 0x20 );
@ -330,15 +323,14 @@ void Core::Network::GameConnection::zoneLineHandler( const Packets::GamePacket&
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 ); uint32_t ref_position_id = inPacket.getValAt< uint32_t >( 0x20 );
auto pQR = g_charaDb.query( "SELECT id, map_id, discover_id " auto pQR = g_charaDb.query( "SELECT id, map_id, discover_id "
"FROM discoveryinfo " "FROM discoveryinfo "
"WHERE id = " + std::to_string( ref_position_id ) + ";" ); "WHERE id = " +
std::to_string( ref_position_id ) + ";" );
if( !pQR->next() ) 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.sendNotice( "Discovery ref pos ID: " + std::to_string( ref_position_id ) );
player.discover( pQR->getUInt16( 2 ), pQR->getUInt16( 3 ) ); 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() ); ZoneChannelPacket< FFXIVIpcPlayTime > playTimePacket( player.getId() );
playTimePacket.data().playTimeInMinutes = player.getPlayTime() / 60; playTimePacket.data().playTimeInMinutes = player.getPlayTime() / 60;
player.queuePacket( playTimePacket ); 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 // init handler means this is a login procedure
player.setIsLogin( true ); player.setIsLogin( true );
@ -376,9 +363,7 @@ void Core::Network::GameConnection::initHandler( const Packets::GamePacket& inPa
player.setZone( player.getZoneId() ); 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 ); uint8_t count = inPacket.getValAt< uint8_t >( 0x21 );
@ -388,12 +373,9 @@ void Core::Network::GameConnection::blackListHandler( const Packets::GamePacket&
// blackListPacket.data().entry[0].contentId = 1; // blackListPacket.data().entry[0].contentId = 1;
// sprintf( blackListPacket.data().entry[0].name, "Test Test" ); // sprintf( blackListPacket.data().entry[0].name, "Test Test" );
queueOutPacket( blackListPacket ); 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 ); int32_t inVal = inPacket.getValAt< int32_t >( 0x20 );
PingPacket pingPacket( player, inVal ); 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 ) ) ); 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 is done zoning
player.setLoadingComplete( true ); player.setLoadingComplete( true );
@ -424,8 +404,7 @@ void Core::Network::GameConnection::finishLoadingHandler( const Packets::GamePac
player.getCurrentZone()->changeActorPosition( player.getAsPlayer() ); player.getCurrentZone()->changeActorPosition( player.getAsPlayer() );
} }
void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
Entity::Player& player )
{ {
uint8_t type = inPacket.getValAt< uint8_t >( 0x2A ); uint8_t type = inPacket.getValAt< uint8_t >( 0x2A );
@ -464,7 +443,6 @@ void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket
listPacket.data().entries[0].onlineStatusMask = player.getOnlineStatusMask(); listPacket.data().entries[0].onlineStatusMask = player.getOnlineStatusMask();
queueOutPacket( listPacket ); queueOutPacket( listPacket );
} }
else if( type == 0x0b ) else if( type == 0x0b )
{ // friend list { // friend list
@ -473,17 +451,14 @@ void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket
listPacket.data().type = 0x0B; listPacket.data().type = 0x0B;
listPacket.data().sequence = count; listPacket.data().sequence = count;
memset( listPacket.data().entries, 0, sizeof( listPacket.data().entries ) ); memset( listPacket.data().entries, 0, sizeof( listPacket.data().entries ) );
} }
else if( type == 0x0e ) else if( type == 0x0e )
{ // player search result { // player search result
// TODO: implement player search // TODO: implement player search
} }
} }
void Core::Network::GameConnection::chatHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::chatHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
Entity::Player& player )
{ {
std::string chatString( inPacket.getStringAt( 0x3a ) ); std::string chatString( inPacket.getStringAt( 0x3a ) );
@ -525,15 +500,13 @@ void Core::Network::GameConnection::chatHandler( const Packets::GamePacket& inPa
break; break;
} }
} }
} }
// TODO: this handler needs to be improved for timed logout, also the session should be instantly removed // 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 // 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. // log right back in.
// Also the packet needs to be converted to an ipc structure // Also the packet needs to be converted to an ipc structure
void Core::Network::GameConnection::logoutHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::logoutHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
Entity::Player& player )
{ {
ZoneChannelPacket< FFXIVIpcLogout > logoutPacket( player.getId() ); ZoneChannelPacket< FFXIVIpcLogout > logoutPacket( player.getId() );
logoutPacket.data().flags1 = 0x02; logoutPacket.data().flags1 = 0x02;
@ -543,9 +516,7 @@ void Core::Network::GameConnection::logoutHandler( const Packets::GamePacket& in
player.setMarkedForRemoval(); 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 targetPcName = inPacket.getStringAt( 0x21 );
std::string msg = inPacket.getStringAt( 0x41 ); std::string msg = inPacket.getStringAt( 0x41 );
@ -595,11 +566,9 @@ void Core::Network::GameConnection::tellHandler( const Packets::GamePacket& inPa
// tellPacket.data().u2a = 0x2E; // tellPacket.data().u2a = 0x2E;
// tellPacket.data().u2b = 0x40; // tellPacket.data().u2b = 0x40;
pTargetPlayer->queueChatPacket( tellPacket ); pTargetPlayer->queueChatPacket( tellPacket );
} }
void Core::Network::GameConnection::performNoteHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::performNoteHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
Entity::Player& player )
{ {
GamePacketNew< FFXIVIpcPerformNote, ServerZoneIpcType > performPacket( player.getId() ); GamePacketNew< FFXIVIpcPerformNote, ServerZoneIpcType > performPacket( player.getId() );

View file

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

View file

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

View file

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

View file

@ -12,17 +12,11 @@ namespace Server {
/** /**
* @brief The Ping response packet. * @brief The Ping response packet.
*/ */
class ActorControlPacket144 : class ActorControlPacket144 : public ZoneChannelPacket< FFXIVIpcActorControl144 >
public ZoneChannelPacket< FFXIVIpcActorControl144 >
{ {
public: public:
ActorControlPacket144( uint32_t actorId, ActorControlPacket144( uint32_t actorId, uint16_t category, uint32_t param1 = 0, uint32_t param2 = 0,
uint16_t category, uint32_t param3 = 0, uint32_t param4 = 0, uint64_t targetId = 0,
uint32_t param1 = 0,
uint32_t param2 = 0,
uint32_t param3 = 0,
uint32_t param4 = 0,
uint64_t targetId = 0,
uint32_t padding1 = 0 ) : uint32_t padding1 = 0 ) :
ZoneChannelPacket< FFXIVIpcActorControl144 >( actorId, actorId ) ZoneChannelPacket< FFXIVIpcActorControl144 >( actorId, actorId )
{ {
@ -30,7 +24,8 @@ public:
}; };
private: private:
void initialize( uint16_t category, uint32_t param1, uint32_t param2, uint32_t param3, uint32_t param4, uint64_t targetId ) 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.padding = 0;
m_data.category = category; m_data.category = category;
@ -42,9 +37,9 @@ private:
}; };
}; };
} } // namespace Server
} } // namespace Packets
} } // namespace Network
} } // namespace Core
#endif /*_ACTORCONTROL144_H*/ #endif /*_ACTORCONTROL144_H*/

View file

@ -1,10 +1,10 @@
#ifndef _ACTORSPAWN_H #ifndef _ACTORSPAWN_H
#define _ACTORSPAWN_H #define _ACTORSPAWN_H
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Util/UtilMath.h>
#include "Actor/Player.h" #include "Actor/Player.h"
#include "Forwards.h" #include "Forwards.h"
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Util/UtilMath.h>
namespace Core { namespace Core {
namespace Network { namespace Network {
@ -14,8 +14,7 @@ namespace Server {
/** /**
* @brief The packet sent to spawn an actor. * @brief The packet sent to spawn an actor.
*/ */
class ActorSpawnPacket : class ActorSpawnPacket : public GamePacketNew< FFXIVIpcActorSpawn, ServerZoneIpcType >
public GamePacketNew< FFXIVIpcActorSpawn, ServerZoneIpcType >
{ {
public: public:
ActorSpawnPacket( Entity::PlayerPtr pPlayer, Entity::PlayerPtr pTarget ) : ActorSpawnPacket( Entity::PlayerPtr pPlayer, Entity::PlayerPtr pTarget ) :
@ -78,14 +77,12 @@ private:
// m_data.unknown_38 = 0x70; // m_data.unknown_38 = 0x70;
// m_data.unknown_60 = 3; // m_data.unknown_60 = 3;
// m_data.unknown_61 = 7; // m_data.unknown_61 = 7;
}; };
}; };
} } // namespace Server
} } // namespace Packets
} } // namespace Network
} } // namespace Core
#endif /*_ACTORSPAWN_H*/ #endif /*_ACTORSPAWN_H*/

View file

@ -1,10 +1,9 @@
#ifndef _CHATPACKET_H #ifndef _CHATPACKET_H
#define _CHATPACKET_H #define _CHATPACKET_H
#include "Forwards.h"
#include <Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h> #include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include "Forwards.h"
namespace Core { namespace Core {
namespace Network { namespace Network {
@ -14,8 +13,7 @@ namespace Server {
/** /**
* @brief The Chat packet. * @brief The Chat packet.
*/ */
class ChatPacket : class ChatPacket : public ZoneChannelPacket< FFXIVIpcChat >
public ZoneChannelPacket< FFXIVIpcChat >
{ {
public: public:
ChatPacket( Entity::Player& player, Common::ChatType chatType, const std::string& msg ) : ChatPacket( Entity::Player& player, Common::ChatType chatType, const std::string& msg ) :
@ -33,9 +31,9 @@ private:
}; };
}; };
} } // namespace Server
} } // namespace Packets
} } // namespace Network
} } // namespace Core
#endif /*_CHATPACKET_H*/ #endif /*_CHATPACKET_H*/

View file

@ -14,31 +14,25 @@ namespace Server {
class EventFinishPacket : public ZoneChannelPacket< FFXIVIpcEventFinish > class EventFinishPacket : public ZoneChannelPacket< FFXIVIpcEventFinish >
{ {
public: public:
EventFinishPacket( uint32_t playerId, EventFinishPacket( uint32_t playerId, uint32_t eventId, uint8_t param1, uint32_t param3 ) :
uint32_t eventId,
uint8_t param1,
uint32_t param3 ) :
ZoneChannelPacket< FFXIVIpcEventFinish >( playerId, playerId ) ZoneChannelPacket< FFXIVIpcEventFinish >( playerId, playerId )
{ {
initialize( eventId, param1, param3 ); initialize( eventId, param1, param3 );
}; };
private: private:
void initialize( uint32_t eventId, void initialize( uint32_t eventId, uint8_t param1, uint32_t param3 )
uint8_t param1,
uint32_t param3 )
{ {
m_data.eventId = eventId; m_data.eventId = eventId;
m_data.param1 = param1; m_data.param1 = param1;
m_data.param2 = 1; m_data.param2 = 1;
m_data.param3 = param3; m_data.param3 = param3;
}; };
}; };
} } // namespace Server
} } // namespace Packets
} } // namespace Network
} } // namespace Core
#endif /*_EVENTFINISH_H*/ #endif /*_EVENTFINISH_H*/

View file

@ -1,8 +1,8 @@
#ifndef _EVENTPLAY_H #ifndef _EVENTPLAY_H
#define _EVENTPLAY_H #define _EVENTPLAY_H
#include <Server_Common/Network/GamePacketNew.h>
#include "Forwards.h" #include "Forwards.h"
#include <Server_Common/Network/GamePacketNew.h>
namespace Core { namespace Core {
namespace Network { namespace Network {
@ -15,27 +15,16 @@ namespace Server {
class EventPlayPacket : public ZoneChannelPacket< FFXIVIpcEventPlay > class EventPlayPacket : public ZoneChannelPacket< FFXIVIpcEventPlay >
{ {
public: public:
EventPlayPacket( uint32_t playerId, EventPlayPacket( uint32_t playerId, uint64_t actorId, uint32_t eventId, uint16_t scene, uint32_t flags,
uint64_t actorId, uint8_t param3, uint32_t param4 = 0, uint32_t param5 = 0 ) :
uint32_t eventId,
uint16_t scene,
uint32_t flags,
uint8_t param3,
uint32_t param4 = 0,
uint32_t param5 = 0 ) :
ZoneChannelPacket< FFXIVIpcEventPlay >( playerId, playerId ) ZoneChannelPacket< FFXIVIpcEventPlay >( playerId, playerId )
{ {
initialize( actorId, eventId, scene, flags, param3, param4, param5 ); initialize( actorId, eventId, scene, flags, param3, param4, param5 );
}; };
private: private:
void initialize( uint64_t actorId, void initialize( uint64_t actorId, uint32_t eventId, uint16_t scene, uint32_t flags, uint8_t param3,
uint32_t eventId, uint32_t param4, uint32_t param5 )
uint16_t scene,
uint32_t flags,
uint8_t param3,
uint32_t param4,
uint32_t param5 )
{ {
m_data.actorId = actorId; m_data.actorId = actorId;
m_data.eventId = eventId; m_data.eventId = eventId;
@ -47,9 +36,9 @@ private:
}; };
}; };
} } // namespace Server
} } // namespace Packets
} } // namespace Network
} } // namespace Core
#endif /*_EVENTPLAY_H*/ #endif /*_EVENTPLAY_H*/

View file

@ -1,8 +1,8 @@
#ifndef _EVENTSTART_H #ifndef _EVENTSTART_H
#define _EVENTSTART_H #define _EVENTSTART_H
#include <Server_Common/Network/GamePacketNew.h>
#include "Forwards.h" #include "Forwards.h"
#include <Server_Common/Network/GamePacketNew.h>
namespace Core { namespace Core {
namespace Network { namespace Network {
@ -15,36 +15,27 @@ namespace Server {
class EventStartPacket : public ZoneChannelPacket< FFXIVIpcEventStart > class EventStartPacket : public ZoneChannelPacket< FFXIVIpcEventStart >
{ {
public: public:
EventStartPacket( uint32_t playerId, EventStartPacket( uint32_t playerId, uint64_t actorId, uint32_t eventId, uint8_t param1 = 0,
uint64_t actorId, uint8_t param2 = 0, uint32_t param3 = 0 ) :
uint32_t eventId,
uint8_t param1 = 0,
uint8_t param2 = 0,
uint32_t param3 = 0 ) :
ZoneChannelPacket< FFXIVIpcEventStart >( playerId, playerId ) ZoneChannelPacket< FFXIVIpcEventStart >( playerId, playerId )
{ {
initialize( actorId, eventId, param1, param2, param3 ); initialize( actorId, eventId, param1, param2, param3 );
}; };
private: private:
void initialize( uint64_t actorId, void initialize( uint64_t actorId, uint32_t eventId, uint8_t param1, uint8_t param2, uint32_t param3 )
uint32_t eventId,
uint8_t param1,
uint8_t param2,
uint32_t param3 )
{ {
m_data.actorId = actorId; m_data.actorId = actorId;
m_data.eventId = eventId; m_data.eventId = eventId;
m_data.param1 = param1; m_data.param1 = param1;
m_data.param2 = param2; m_data.param2 = param2;
m_data.param3 = param3; m_data.param3 = param3;
}; };
}; };
} } // namespace Server
} } // namespace Packets
} } // namespace Network
} } // namespace Core
#endif /*_EVENTSTART_H*/ #endif /*_EVENTSTART_H*/

View file

@ -1,10 +1,10 @@
#ifndef _CORE_NETWORK_PACKETS_INITUIPACKET_H #ifndef _CORE_NETWORK_PACKETS_INITUIPACKET_H
#define _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 "Actor/Player.h"
#include "Forwards.h" #include "Forwards.h"
#include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
namespace Core { namespace Core {
namespace Network { namespace Network {
@ -81,13 +81,12 @@ private:
// m_data.pos.x = player->getPos().getX(); // m_data.pos.x = player->getPos().getX();
// m_data.pos.y = player->getPos().getY(); // m_data.pos.y = player->getPos().getY();
// m_data.pos.z = player->getPos().getZ(); // m_data.pos.z = player->getPos().getZ();
}; };
}; };
} } // namespace Server
} } // namespace Packets
} } // namespace Network
} } // namespace Core
#endif /*_CORE_NETWORK_PACKETS_CINITUIPACKET_H*/ #endif /*_CORE_NETWORK_PACKETS_CINITUIPACKET_H*/

View file

@ -1,9 +1,9 @@
#ifndef _MODELEQUIPPACKET_H #ifndef _MODELEQUIPPACKET_H
#define _MODELEQUIPPACKET_H #define _MODELEQUIPPACKET_H
#include <Server_Common/Network/GamePacketNew.h>
#include "Actor/Player.h" #include "Actor/Player.h"
#include "Forwards.h" #include "Forwards.h"
#include <Server_Common/Network/GamePacketNew.h>
namespace Core { namespace Core {
namespace Network { namespace Network {
@ -13,8 +13,7 @@ namespace Server {
/** /**
* @brief The update model packet. * @brief The update model packet.
*/ */
class ModelEquipPacket : class ModelEquipPacket : public ZoneChannelPacket< FFXIVIpcModelEquip >
public ZoneChannelPacket< FFXIVIpcModelEquip >
{ {
public: public:
ModelEquipPacket( Entity::Player& player ) : ModelEquipPacket( Entity::Player& player ) :
@ -36,9 +35,9 @@ private:
}; };
}; };
} } // namespace Server
} } // namespace Packets
} } // namespace Network
} } // namespace Core
#endif /*_MODELEQUIPPACKET_H*/ #endif /*_MODELEQUIPPACKET_H*/

View file

@ -1,12 +1,11 @@
#ifndef _MOVEACTORPACKET_H #ifndef _MOVEACTORPACKET_H
#define _MOVEACTORPACKET_H #define _MOVEACTORPACKET_H
#include "Actor/Player.h"
#include "Forwards.h"
#include <Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h> #include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include <Server_Common/Util/UtilMath.h> #include <Server_Common/Util/UtilMath.h>
#include "Actor/Player.h"
#include "Forwards.h"
namespace Core { namespace Core {
namespace Network { namespace Network {
@ -17,8 +16,7 @@ namespace Server {
* @brief The Client UI Initialization packet. This must be sent to the client * @brief The Client UI Initialization packet. This must be sent to the client
* once upon connection to configure the UI. * once upon connection to configure the UI.
*/ */
class MoveActorPacket : class MoveActorPacket : public ZoneChannelPacket< FFXIVIpcActorMove >
public ZoneChannelPacket< FFXIVIpcActorMove >
{ {
public: public:
MoveActorPacket( Entity::Actor& actor, uint8_t unk1, uint8_t unk2, uint8_t unk3, uint16_t unk4 ) : MoveActorPacket( 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.posX = Math::Util::floatToUInt16( actor.getPos().x );
m_data.posY = Math::Util::floatToUInt16( actor.getPos().y ); m_data.posY = Math::Util::floatToUInt16( actor.getPos().y );
m_data.posZ = Math::Util::floatToUInt16( actor.getPos().z ); m_data.posZ = Math::Util::floatToUInt16( actor.getPos().z );
}; };
}; };
} } // namespace Server
} } // namespace Packets
} } // namespace Network
} } // namespace Core
#endif /*_MOVEACTORPACKET_H*/ #endif /*_MOVEACTORPACKET_H*/

View file

@ -13,8 +13,7 @@ namespace Server {
/** /**
* @brief The Ping response packet. * @brief The Ping response packet.
*/ */
class PingPacket : class PingPacket : public ZoneChannelPacket< FFXIVIpcPing >
public ZoneChannelPacket< FFXIVIpcPing >
{ {
public: public:
PingPacket( Entity::Player& player, int32_t inVal ) : PingPacket( Entity::Player& player, int32_t inVal ) :
@ -30,9 +29,9 @@ private:
}; };
}; };
} } // namespace Server
} } // namespace Packets
} } // namespace Network
} } // namespace Core
#endif /*_CORE_NETWORK_PACKETS_CPINGPACKET_H*/ #endif /*_CORE_NETWORK_PACKETS_CPINGPACKET_H*/

View file

@ -1,14 +1,14 @@
#ifndef _PLAYERSPAWN_H #ifndef _PLAYERSPAWN_H
#define _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 "Actor/Player.h"
#include "Forwards.h" #include "Forwards.h"
#include "Inventory/Inventory.h" #include "Inventory/Inventory.h"
#include "Inventory/Item.h" #include "Inventory/Item.h"
#include "StatusEffect/StatusEffect.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 Core {
namespace Network { namespace Network {
@ -18,8 +18,7 @@ namespace Server {
/** /**
* @brief The packet sent to spawn a player. * @brief The packet sent to spawn a player.
*/ */
class PlayerSpawnPacket : class PlayerSpawnPacket : public GamePacketNew< FFXIVIpcPlayerSpawn, ServerZoneIpcType >
public GamePacketNew< FFXIVIpcPlayerSpawn, ServerZoneIpcType >
{ {
public: public:
PlayerSpawnPacket( Entity::Player& player, Entity::Player& target ) : PlayerSpawnPacket( Entity::Player& player, Entity::Player& target ) :
@ -68,7 +67,6 @@ namespace Server {
m_data.pos.z = player.getPos().z; m_data.pos.z = player.getPos().z;
m_data.rotation = Math::Util::floatToUInt16Rot( player.getRotation() ); m_data.rotation = Math::Util::floatToUInt16Rot( player.getRotation() );
m_data.title = player.getTitle(); m_data.title = player.getTitle();
m_data.voice = player.getVoiceId(); m_data.voice = player.getVoiceId();
m_data.currentMount = player.getCurrentMount(); m_data.currentMount = player.getCurrentMount();
@ -124,18 +122,19 @@ namespace Server {
for( auto const& effect : player.getStatusEffectMap() ) for( auto const& effect : player.getStatusEffectMap() )
{ {
m_data.effect[effect.first].effect_id = effect.second->getId(); m_data.effect[effect.first].effect_id = effect.second->getId();
m_data.effect[effect.first].duration = static_cast< float >( effect.second->getDuration() - m_data.effect[effect.first].duration =
( currentTimeMs - effect.second->getStartTimeMs() ) ) / 1000; 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].sourceActorId = effect.second->getSrcActorId();
m_data.effect[effect.first].unknown1 = effect.second->getParam(); m_data.effect[effect.first].unknown1 = effect.second->getParam();
} }
}; };
}; };
} } // namespace Server
} } // namespace Packets
} } // namespace Network
} } // namespace Core
#endif /*_PlayerSpawn_H*/ #endif /*_PlayerSpawn_H*/

View file

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

View file

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

View file

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

View file

@ -1,9 +1,9 @@
#ifndef _UPDATEHPMPTP_H #ifndef _UPDATEHPMPTP_H
#define _UPDATEHPMPTP_H #define _UPDATEHPMPTP_H
#include <Server_Common/Network/GamePacketNew.h>
#include <Actor/Actor.h>
#include "Forwards.h" #include "Forwards.h"
#include <Actor/Actor.h>
#include <Server_Common/Network/GamePacketNew.h>
namespace Core { namespace Core {
namespace Network { namespace Network {
@ -13,8 +13,7 @@ namespace Server {
/** /**
* @brief The Ping response packet. * @brief The Ping response packet.
*/ */
class UpdateHpMpTpPacket : class UpdateHpMpTpPacket : public ZoneChannelPacket< FFXIVIpcUpdateHpMpTp >
public ZoneChannelPacket< FFXIVIpcUpdateHpMpTp >
{ {
public: public:
UpdateHpMpTpPacket( Entity::ActorPtr pActor ) : UpdateHpMpTpPacket( Entity::ActorPtr pActor ) :
@ -32,9 +31,9 @@ private:
}; };
}; };
} } // namespace Server
} } // namespace Packets
} } // namespace Network
} } // namespace Core
#endif /*_UPDATEHPMPTP_H*/ #endif /*_UPDATEHPMPTP_H*/

View file

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

View file

@ -5,24 +5,19 @@
#include <mutex> #include <mutex>
#include <set> #include <set>
#include <Server_Common/Common.h>
#include "Forwards.h" #include "Forwards.h"
#include <Server_Common/Common.h>
namespace chaiscript {
namespace chaiscript
{
class ChaiScript; class ChaiScript;
} }
namespace Core namespace Core {
{ namespace Scripting {
namespace Scripting
{
class ScriptManager class ScriptManager
{ {
private: private:
boost::shared_ptr< chaiscript::ChaiScript > m_pChaiHandler; boost::shared_ptr< chaiscript::ChaiScript > m_pChaiHandler;
std::function< std::string( Entity::Player& ) > m_onFirstEnterWorld; std::function< std::string( Entity::Player& ) > m_onFirstEnterWorld;
@ -39,14 +34,16 @@ namespace Core
void onPlayerFirstEnterWorld( Entity::Player& player ); 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 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 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 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 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 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 ); bool onMobKill( Entity::Player& player, uint16_t nameId );
@ -58,14 +55,13 @@ namespace Core
bool onZoneInit( ZonePtr pZone ); 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 onEventHandlerReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param1,
bool onEventHandlerTradeReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param, uint32_t catalogId ); 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 ); void loadDir( std::string dirname, std::set< std::string >& chaiFiles );
}; };
} } // namespace Scripting
} } // namespace Core
#endif #endif

View file

@ -8,13 +8,13 @@
#include "Script/ScriptManager.h" #include "Script/ScriptManager.h"
#include "Zone/Zone.h"
#include "Actor/Player.h"
#include "Actor/BattleNpc.h" #include "Actor/BattleNpc.h"
#include "Actor/Player.h"
#include "Event/Event.h" #include "Event/Event.h"
#include "Event/EventHelper.h" #include "Event/EventHelper.h"
#include "Network/PacketWrappers/ServerNoticePacket.h" #include "Network/PacketWrappers/ServerNoticePacket.h"
#include "StatusEffect/StatusEffect.h" #include "StatusEffect/StatusEffect.h"
#include "Zone/Zone.h"
#include <boost/lexical_cast.hpp> #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::getTargetId ), "getTargetId" );
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::addStatusEffect ), "addStatusEffect" ); 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::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::Actor::takeDamage ), "takeDamage" );
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::forceZoneing ), "setZone" ); m_pChaiHandler->add( chaiscript::fun( &Entity::Player::forceZoneing ), "setZone" );
@ -139,11 +140,22 @@ int Core::Scripting::ScriptManager::init()
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 >(
m_pChaiHandler->add( chaiscript::fun< void, Entity::Player, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, EventReturnCallback >( &Entity::Player::eventPlay ), "eventPlay" ); &Entity::Player::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" ); "eventPlay" );
m_pChaiHandler->add( chaiscript::fun< void, Entity::Player, uint32_t, uint32_t, uint32_t, EventReturnCallback >( &Entity::Player::eventPlay ), "eventPlay" ); m_pChaiHandler->add(
m_pChaiHandler->add( chaiscript::fun< void, Entity::Player, uint32_t, uint32_t, uint32_t >( &Entity::Player::eventPlay ), "eventPlay" ); 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::eventActionStart ), "eventActionStart" );
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::eventItemActionStart ), "eventItemActionStart" ); m_pChaiHandler->add( chaiscript::fun( &Entity::Player::eventItemActionStart ), "eventItemActionStart" );
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::changePosition ), "changePos" ); m_pChaiHandler->add( chaiscript::fun( &Entity::Player::changePosition ), "changePos" );
@ -172,7 +184,8 @@ int Core::Scripting::ScriptManager::init()
std::set< std::string > chaiFiles; 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 scriptCount = 0;
uint16_t errorCount = 0; uint16_t errorCount = 0;
@ -190,18 +203,14 @@ int Core::Scripting::ScriptManager::init()
g_log.Log( LoggingSeverity::error, e.what() ); g_log.Log( LoggingSeverity::error, e.what() );
errorCount++; errorCount++;
} }
} }
g_log.info( "\tloaded " + std::to_string( scriptCount ) + g_log.info( "\tloaded " + std::to_string( scriptCount ) + " scripts, " + std::to_string( errorCount ) + " errors." );
" scripts, " + std::to_string( errorCount ) + " errors." );
std::function< std::string( Entity::Player& ) > f = std::function< std::string( Entity::Player& ) > f =
m_pChaiHandler->eval< std::function< std::string( Entity::Player& ) > >( "onFirstEnterWorld" ); m_pChaiHandler->eval< std::function< std::string( Entity::Player& ) > >( "onFirstEnterWorld" );
m_onFirstEnterWorld = f; m_onFirstEnterWorld = f;
return true; return true;
} }

View file

@ -1,22 +1,21 @@
#include "ServerZone.h" #include "ServerZone.h"
#include <Server_Common/Version.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Config/XMLConfig.h> #include <Server_Common/Config/XMLConfig.h>
#include <Server_Common/Logging/Logger.h>
#include <Server_Common/Version.h> #include <Server_Common/Version.h>
#include <MySqlBase.h>
#include <Connection.h> #include <Connection.h>
#include <MySqlBase.h>
#include <Server_Common/Network/Connection.h> #include <Server_Common/Network/Connection.h>
#include <Server_Common/Network/Hive.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/CharaDbConnection.h>
#include <Server_Common/Database/DbLoader.h>
#include <Server_Common/Database/DbWorkerPool.h> #include <Server_Common/Database/DbWorkerPool.h>
#include <Server_Common/Database/PreparedStatement.h> #include <Server_Common/Database/PreparedStatement.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Network/PacketContainer.h>
#include "Network/GameConnection.h" #include "Network/GameConnection.h"
#include "Session.h" #include "Session.h"
@ -25,13 +24,13 @@
#include "DebugCommand/DebugCommandHandler.h" #include "DebugCommand/DebugCommandHandler.h"
#include "Script/ScriptManager.h"
#include "Linkshell/LinkshellMgr.h" #include "Linkshell/LinkshellMgr.h"
#include "Script/ScriptManager.h"
#include "Forwards.h" #include "Forwards.h"
#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include <boost/algorithm/string.hpp>
#include <thread> #include <thread>
Core::Logger g_log; Core::Logger g_log;
@ -42,8 +41,8 @@ Core::ZoneMgr g_zoneMgr;
Core::LinkshellMgr g_linkshellMgr; Core::LinkshellMgr g_linkshellMgr;
Core::Db::DbWorkerPool< Core::Db::CharaDbConnection > g_charaDb; Core::Db::DbWorkerPool< Core::Db::CharaDbConnection > g_charaDb;
Core::ServerZone::ServerZone( const std::string& configPath ) Core::ServerZone::ServerZone( const std::string& configPath ) :
: m_configPath( configPath ), m_configPath( configPath ),
m_bRunning( true ), m_bRunning( true ),
m_lastDBPingTime( 0 ) m_lastDBPingTime( 0 )
{ {
@ -64,8 +63,8 @@ size_t Core::ServerZone::getSessionCount() const
return m_sessionMapById.size(); return m_sessionMapById.size();
} }
bool Core::ServerZone::registerBnpcTemplate( std::string templateName, uint32_t bnpcBaseId, bool Core::ServerZone::registerBnpcTemplate( std::string templateName, uint32_t bnpcBaseId, uint32_t bnpcNameId,
uint32_t bnpcNameId, uint32_t modelId, std::string aiName ) uint32_t modelId, std::string aiName )
{ {
auto it = m_bnpcTemplates.find( templateName ); auto it = m_bnpcTemplates.find( templateName );
@ -76,7 +75,8 @@ bool Core::ServerZone::registerBnpcTemplate( std::string templateName, uint32_t
return false; 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; m_bnpcTemplates[templateName] = pNpcTemplate;
return true; return true;
@ -239,7 +239,6 @@ void Core::ServerZone::run( int32_t argc, char* argv[] )
{ {
thread_entry.join(); thread_entry.join();
} }
} }
void Core::ServerZone::printBanner() const void Core::ServerZone::printBanner() const
@ -273,7 +272,6 @@ void Core::ServerZone::mainLoop()
// else do it here. // else do it here.
if( !session->getPlayer()->getCurrentZone() ) if( !session->getPlayer()->getCurrentZone() )
session->update(); session->update();
} }
} }
@ -283,7 +281,6 @@ void Core::ServerZone::mainLoop()
m_lastDBPingTime = currTime; m_lastDBPingTime = currTime;
} }
auto it = this->m_sessionMapById.begin(); auto it = this->m_sessionMapById.begin();
for( ; it != this->m_sessionMapById.end(); ) for( ; it != this->m_sessionMapById.end(); )
{ {
@ -319,9 +316,7 @@ void Core::ServerZone::mainLoop()
{ {
++it; ++it;
} }
} }
} }
} }
@ -353,7 +348,6 @@ bool Core::ServerZone::createSession( uint32_t sessionId )
m_sessionMapByName[newSession->getPlayer()->getName()] = newSession; m_sessionMapByName[newSession->getPlayer()->getName()] = newSession;
return true; return true;
} }
void Core::ServerZone::removeSession( uint32_t sessionId ) void Core::ServerZone::removeSession( uint32_t sessionId )
@ -412,4 +406,3 @@ bool Core::ServerZone::isRunning() const
{ {
return m_bRunning; return m_bRunning;
} }

View file

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

View file

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

View file

@ -50,10 +50,8 @@ namespace Core {
Network::GameConnectionPtr m_pZoneConnection; Network::GameConnectionPtr m_pZoneConnection;
Network::GameConnectionPtr m_pChatConnection; Network::GameConnectionPtr m_pChatConnection;
}; };
} } // namespace Core
#endif #endif

View file

@ -1,16 +1,15 @@
#include <Server_Common/Exd/ExdData.h> #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/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 <algorithm>
#include <boost/algorithm/string.hpp>
#include "Actor/Actor.h" #include "Actor/Actor.h"
#include "StatusEffect.h"
#include "Script/ScriptManager.h" #include "Script/ScriptManager.h"
#include "StatusEffect.h"
extern Core::Logger g_log; extern Core::Logger g_log;
extern Core::Data::ExdData g_exdData; extern Core::Data::ExdData g_exdData;
@ -20,16 +19,15 @@ using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server; using namespace Core::Network::Packets::Server;
extern Core::Scripting::ScriptManager g_scriptMgr; extern Core::Scripting::ScriptManager g_scriptMgr;
Core::StatusEffect::StatusEffect::StatusEffect( uint32_t id, Entity::ActorPtr sourceActor, Entity::ActorPtr targetActor, Core::StatusEffect::StatusEffect::StatusEffect( uint32_t id, Entity::ActorPtr sourceActor, Entity::ActorPtr targetActor,
uint32_t duration, uint32_t tickRate ) uint32_t duration, uint32_t tickRate ) :
: m_id( id ) m_id( id ),
, m_sourceActor( sourceActor ) m_sourceActor( sourceActor ),
, m_targetActor( targetActor ) m_targetActor( targetActor ),
, m_duration( duration ) m_duration( duration ),
, m_startTime( 0 ) m_startTime( 0 ),
, m_tickRate( tickRate ) m_tickRate( tickRate ),
, m_lastTick( 0 ) m_lastTick( 0 )
{ {
auto& entry = g_exdData.m_statusEffectInfoMap[id]; auto& entry = g_exdData.m_statusEffectInfoMap[id];
m_name = entry.name; m_name = entry.name;
@ -45,7 +43,6 @@ Core::StatusEffect::StatusEffect::StatusEffect( uint32_t id, Entity::ActorPtr so
boost::erase_all( m_name, ")" ); boost::erase_all( m_name, ")" );
} }
Core::StatusEffect::StatusEffect::~StatusEffect() Core::StatusEffect::StatusEffect::~StatusEffect()
{ {
} }
@ -97,8 +94,8 @@ void Core::StatusEffect::StatusEffect::applyStatus()
// effectPacket.data().actionTextId = 3; // effectPacket.data().actionTextId = 3;
// effectPacket.data().unknown_5 = 1; // effectPacket.data().unknown_5 = 1;
// effectPacket.data().unknown_6 = 321; // effectPacket.data().unknown_6 = 321;
//effectPacket.data().rotation = ( uint16_t ) ( 0x8000 * ( ( m_sourceActor->getPos().getR() + 3.1415926 ) ) / 3.1415926 ); // effectPacket.data().rotation = ( uint16_t ) ( 0x8000 * ( ( m_sourceActor->getPos().getR() + 3.1415926 ) )
//effectPacket.data().effectTargetId = m_sourceActor->getId(); // / 3.1415926 ); effectPacket.data().effectTargetId = m_sourceActor->getId();
// effectPacket.data().effects[4].unknown_1 = 17; // effectPacket.data().effects[4].unknown_1 = 17;
// effectPacket.data().effects[4].bonusPercent = 30; // effectPacket.data().effects[4].bonusPercent = 30;
// effectPacket.data().effects[4].param1 = m_id; // effectPacket.data().effects[4].param1 = m_id;

View file

@ -5,17 +5,14 @@
#include "Forwards.h" #include "Forwards.h"
namespace Core namespace Core {
{ namespace StatusEffect {
namespace StatusEffect
{
class StatusEffect class StatusEffect
{ {
public: public:
StatusEffect( uint32_t id, Entity::ActorPtr sourceActor, Entity::ActorPtr targetActor, StatusEffect( uint32_t id, Entity::ActorPtr sourceActor, Entity::ActorPtr targetActor, uint32_t duration,
uint32_t duration, uint32_t tickRate ); uint32_t tickRate );
~StatusEffect(); ~StatusEffect();
@ -48,10 +45,9 @@ private:
uint16_t m_param; uint16_t m_param;
std::string m_name; 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 #endif

View file

@ -5,18 +5,11 @@
#include "Forwards.h" #include "Forwards.h"
#include "Zone.h" #include "Zone.h"
// TODO: the entire zone / areahandling is a bit outdated ( in parts i used this for the 1.0 iteration ) // 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 // 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; m_bForcedActive = false;
} }
@ -47,7 +40,6 @@ namespace Core
entry->setCurrentZone( m_pZone ); entry->setCurrentZone( m_pZone );
m_pZone->pushActor( entry ); m_pZone->pushActor( entry );
} }
} }
@ -55,7 +47,8 @@ namespace Core
{ {
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_playerCount;
} }
@ -66,7 +59,8 @@ namespace Core
{ {
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_playerCount;
} }
@ -80,28 +74,22 @@ namespace Core
// Move all objects to active set. // 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(); cancelPendingUnload();
} }
} }
else if( m_bActive && !state ) else if( m_bActive && !state )
{ {
// Move all objects from active set. // 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; m_bActive = state;
} }
void Cell::removeActors() void Cell::removeActors()
{ {
@ -123,17 +111,13 @@ namespace Core
if( m_bUnloadPending ) if( m_bUnloadPending )
{ {
} }
} }
m_playerCount = 0; m_playerCount = 0;
m_bLoaded = false; m_bLoaded = false;
} }
void Cell::queueUnloadPending() void Cell::queueUnloadPending()
{ {
if( m_bUnloadPending ) if( m_bUnloadPending )
@ -142,7 +126,6 @@ namespace Core
} }
m_bUnloadPending = true; m_bUnloadPending = true;
} }
void Cell::cancelPendingUnload() void Cell::cancelPendingUnload()
@ -152,7 +135,6 @@ namespace Core
{ {
return; return;
} }
} }
void Cell::unload() void Cell::unload()
@ -168,4 +150,4 @@ namespace Core
m_bUnloadPending = false; m_bUnloadPending = false;
} }
} } // namespace Core

View file

@ -9,7 +9,6 @@
namespace Core { namespace Core {
struct CellCache struct CellCache
{ {
std::vector< Entity::BattleNpcPtr > battleNpcCache; std::vector< Entity::BattleNpcPtr > battleNpcCache;
@ -45,84 +44,42 @@ namespace Core {
void loadActors( CellCache* pCC ); void loadActors( CellCache* pCC );
bool hasActor(Entity::ActorPtr pAct) bool hasActor( Entity::ActorPtr pAct ) { return ( m_actors.find( pAct ) != m_actors.end() ); }
{
return (m_actors.find(pAct) != m_actors.end());
}
bool hasPlayers() const bool hasPlayers() const { return ( ( m_playerCount > 0 ) ? true : false ); }
{
return ((m_playerCount > 0) ? true : false);
}
size_t getActorCount() const size_t getActorCount() const { return m_actors.size(); }
{
return m_actors.size();
}
void removeActors(); void removeActors();
ActorSet::iterator begin() ActorSet::iterator begin() { return m_actors.begin(); }
{
return m_actors.begin();
}
ActorSet::iterator end() ActorSet::iterator end() { return m_actors.end(); }
{
return m_actors.end();
}
void setActivity( bool state ); void setActivity( bool state );
bool isActive() const bool isActive() const { return m_bActive; }
{
return m_bActive;
}
bool isLoaded() const bool isLoaded() const { return m_bLoaded; }
{
return m_bLoaded;
}
uint32_t getPlayerCount() const uint32_t getPlayerCount() const { return m_playerCount; }
{
return m_playerCount;
}
bool isUnloadPending() const bool isUnloadPending() const { return m_bUnloadPending; }
{
return m_bUnloadPending;
}
void setUnloadPending(bool up) void setUnloadPending( bool up ) { m_bUnloadPending = up; }
{
m_bUnloadPending = up;
}
void queueUnloadPending(); void queueUnloadPending();
void cancelPendingUnload(); void cancelPendingUnload();
void unload(); void unload();
void setPermanentActivity(bool val) void setPermanentActivity( bool val ) { m_bForcedActive = val; }
{
m_bForcedActive = val;
}
bool isForcedActive() const bool isForcedActive() const { return m_bForcedActive; }
{
return m_bForcedActive;
}
uint16_t getPosX() const uint16_t getPosX() const { return m_posX; }
{
return m_posX;
}
uint16_t getPosY() const uint16_t getPosY() const { return m_posY; }
{
return m_posY;
}
}; };
} } // namespace Core
#endif #endif

View file

@ -32,10 +32,7 @@ public:
T* createByCoords( float x, float y ); T* createByCoords( float x, float y );
void remove( uint32_t x, uint32_t y ); void remove( uint32_t x, uint32_t y );
bool allocated( uint32_t x, uint32_t y ) bool allocated( uint32_t x, uint32_t y ) { return m_pCells[x][y] != nullptr; }
{
return m_pCells[x][y] != nullptr;
}
static uint32_t getPosX( float x ); static uint32_t getPosX( float x );
static uint32_t getPosY( float y ); static uint32_t getPosY( float y );
@ -43,9 +40,7 @@ public:
protected: protected:
void _init(); void _init();
T*** m_pCells; T*** m_pCells;
}; };
template< class T > template< class T >
@ -55,7 +50,6 @@ CellHandler<T>::CellHandler()
_init(); _init();
} }
template< class T > template< class T >
void CellHandler< T >::_init() void CellHandler< T >::_init()
{ {
@ -66,7 +60,6 @@ void CellHandler<T>::_init()
{ {
m_pCells[i] = nullptr; m_pCells[i] = nullptr;
} }
} }
template< class T > template< class T >
@ -174,5 +167,5 @@ uint32_t CellHandler<T>::getPosY( float y )
return ( uint32_t )( ( _maxY - y ) / _cellSize ); return ( uint32_t )( ( _maxY - y ) / _cellSize );
} }
} } // namespace Core
#endif #endif

View file

@ -1,30 +1,30 @@
#include <stdio.h> #include <stdio.h>
#include <vector> #include <vector>
#include <Server_Common/Database/DatabaseDef.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include <Server_Common/Util/Util.h> #include <Server_Common/Network/CommonNetwork.h>
#include <Server_Common/Util/UtilMath.h>
#include <Server_Common/Network/GamePacket.h> #include <Server_Common/Network/GamePacket.h>
#include <Server_Common/Network/GamePacketNew.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/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 "Zone.h"
#include "ZoneMgr.h" #include "ZoneMgr.h"
#include "Session.h"
#include "Actor/Actor.h" #include "Actor/Actor.h"
#include "Actor/Player.h"
#include "Actor/BattleNpc.h" #include "Actor/BattleNpc.h"
#include "Actor/Player.h"
#include "Session.h"
#include "Forwards.h" #include "Forwards.h"
#include "Network/GameConnection.h" #include "Network/GameConnection.h"
#include "ServerZone.h"
#include "Script/ScriptManager.h" #include "Script/ScriptManager.h"
#include "ServerZone.h"
#include "CellHandler.h" #include "CellHandler.h"
@ -40,20 +40,20 @@ namespace Core {
/** /**
* \brief * \brief
*/ */
Zone::Zone() Zone::Zone() :
: m_zoneId( 0 ) m_zoneId( 0 ),
, m_layoutId( 0 ) m_layoutId( 0 ),
, m_bPrivate( false ) m_bPrivate( false ),
, m_type( Common::RegionType::normal ) m_type( Common::RegionType::normal ),
, m_currentWeather( static_cast< uint8_t >( Common::Weather::FairSkies ) ) m_currentWeather( static_cast< uint8_t >( Common::Weather::FairSkies ) ),
, m_weatherOverride( 0 ) m_weatherOverride( 0 ),
, m_lastMobUpdate( 0 ) m_lastMobUpdate( 0 )
{ {
} }
Zone::Zone( uint16_t zoneId, uint32_t layoutId, std::string name, std::string interName, bool bPrivate = false ) Zone::Zone( uint16_t zoneId, uint32_t layoutId, std::string name, std::string interName, bool bPrivate = false ) :
: m_type( Common::RegionType::normal ) m_type( Common::RegionType::normal ),
, m_currentWeather( static_cast< uint8_t >( Common::Weather::FairSkies ) ) m_currentWeather( static_cast< uint8_t >( Common::Weather::FairSkies ) )
{ {
m_layoutId = layoutId; m_layoutId = layoutId;
@ -150,7 +150,8 @@ void Zone::loadCellCache()
"Look," "Look,"
"Models," "Models,"
"type " "type "
"FROM battlenpc WHERE ZoneId = " + std::to_string( getId() ) + ";" ); "FROM battlenpc WHERE ZoneId = " +
std::to_string( getId() ) + ";" );
std::vector< Entity::BattleNpcPtr > cache; std::vector< Entity::BattleNpcPtr > cache;
@ -179,14 +180,12 @@ void Zone::loadCellCache()
pos.x = posX; pos.x = posX;
pos.y = posY; pos.y = posY;
pos.z = posZ; pos.z = posZ;
Entity::BattleNpcPtr pBNpc( new Entity::BattleNpc( modelId, nameId, pos, Entity::BattleNpcPtr pBNpc(
sizeId, type, level, behaviour, mobType ) ); new Entity::BattleNpc( modelId, nameId, pos, sizeId, type, level, behaviour, mobType ) );
pBNpc->setRotation( static_cast< float >( rotation ) ); pBNpc->setRotation( static_cast< float >( rotation ) );
cache.push_back( pBNpc ); cache.push_back( pBNpc );
} }
for( auto entry : cache ) for( auto entry : cache )
{ {
// get cell position // get cell position
@ -206,7 +205,6 @@ void Zone::loadCellCache()
// add the populace cache object to the cells list // add the populace cache object to the cells list
m_pCellCache[cellX][cellY]->battleNpcCache.push_back( entry ); m_pCellCache[cellX][cellY]->battleNpcCache.push_back( entry );
} }
} }
uint8_t Zone::getNextWeather() uint8_t Zone::getNextWeather()
@ -288,7 +286,6 @@ void Zone::pushActor( Entity::ActorPtr pActor )
m_sessionSet.insert( pSession ); m_sessionSet.insert( pSession );
m_playerMap[pPlayer->getId()] = pPlayer; m_playerMap[pPlayer->getId()] = pPlayer;
updateCellActivity( cx, cy, 2 ); updateCellActivity( cx, cy, 2 );
} }
else if( pActor->isMob() ) else if( pActor->isMob() )
{ {
@ -296,9 +293,7 @@ void Zone::pushActor( Entity::ActorPtr pActor )
Entity::BattleNpcPtr pBNpc = pActor->getAsBattleNpc(); Entity::BattleNpcPtr pBNpc = pActor->getAsBattleNpc();
m_BattleNpcMap[pBNpc->getId()] = pBNpc; m_BattleNpcMap[pBNpc->getId()] = pBNpc;
pBNpc->setPosition( pBNpc->getPos() ); pBNpc->setPosition( pBNpc->getPos() );
} }
} }
void Zone::removeActor( Entity::ActorPtr pActor ) 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() ) + "]" ); 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 it's a player and he's inside boundaries - update his nearby cells
if( pActor->getPos().x <= _maxX && pActor->getPos().x >= _minX && if( pActor->getPos().x <= _maxX && pActor->getPos().x >= _minX && pActor->getPos().z <= _maxY &&
pActor->getPos().z <= _maxY && pActor->getPos().z >= _minY ) pActor->getPos().z >= _minY )
{ {
uint32_t x = getPosX( pActor->getPos().x ); uint32_t x = getPosX( pActor->getPos().x );
uint32_t y = getPosY( pActor->getPos().z ); uint32_t y = getPosY( pActor->getPos().z );
updateCellActivity( x, y, 3 ); updateCellActivity( x, y, 3 );
} }
m_playerMap.erase( pActor->getId() ); m_playerMap.erase( pActor->getId() );
} }
else if( pActor->isMob() ) else if( pActor->isMob() )
m_BattleNpcMap.erase( pActor->getId() ); m_BattleNpcMap.erase( pActor->getId() );
@ -341,19 +335,16 @@ void Zone::removeActor( Entity::ActorPtr pActor )
} }
} }
pActor->clearInRangeSet(); 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 ) for( auto it = m_playerMap.begin(); it != m_playerMap.end(); ++it )
{ {
float distance = Math::Util::distance( sourcePlayer.getPos().x, float distance =
sourcePlayer.getPos().y, Math::Util::distance( sourcePlayer.getPos().x, sourcePlayer.getPos().y, sourcePlayer.getPos().z,
sourcePlayer.getPos().z, ( *it ).second->getPos().x, ( *it ).second->getPos().y, ( *it ).second->getPos().z );
( *it ).second->getPos().x,
( *it ).second->getPos().y,
( *it ).second->getPos().z );
if( ( distance < range ) && sourcePlayer.getId() != ( *it ).second->getId() ) if( ( distance < range ) && sourcePlayer.getId() != ( *it ).second->getId() )
{ {
@ -451,7 +442,6 @@ void Zone::updateBnpcs( int64_t tickCount )
} }
} }
for( auto entry : m_BattleNpcMap ) for( auto entry : m_BattleNpcMap )
{ {
Entity::BattleNpcPtr pBNpc = entry.second; Entity::BattleNpcPtr pBNpc = entry.second;
@ -467,7 +457,6 @@ void Zone::updateBnpcs( int64_t tickCount )
} }
pBNpc->update( 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 // 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() ) ); g_log.debug( "[Zone:" + m_zoneCode + "] removing session " + std::to_string( pSession->getId() ) );
@ -506,8 +496,8 @@ bool Zone::runZoneLogic()
if( changedWeather ) if( changedWeather )
{ {
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcWeatherChange > Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcWeatherChange > weatherChangePacket(
weatherChangePacket( pSession->getPlayer()->getId() ); pSession->getPlayer()->getId() );
weatherChangePacket.data().weatherId = m_currentWeather; weatherChangePacket.data().weatherId = m_currentWeather;
weatherChangePacket.data().delay = 5.0f; weatherChangePacket.data().delay = 5.0f;
pSession->getPlayer()->queuePacket( weatherChangePacket ); pSession->getPlayer()->queuePacket( weatherChangePacket );
@ -618,12 +608,8 @@ void Zone::changeActorPosition( Entity::ActorPtr pActor )
pCurAct = *iter; pCurAct = *iter;
auto iter2 = iter++; auto iter2 = iter++;
float distance = Math::Util::distance( pCurAct->getPos().x, float distance = Math::Util::distance( pCurAct->getPos().x, pCurAct->getPos().y, pCurAct->getPos().z,
pCurAct->getPos().y, pActor->getPos().x, pActor->getPos().y, pActor->getPos().z );
pCurAct->getPos().z,
pActor->getPos().x,
pActor->getPos().y,
pActor->getPos().z );
if( fRange > 0.0f && distance > fRange ) if( fRange > 0.0f && distance > fRange )
{ {
@ -701,7 +687,6 @@ void Zone::changeActorPosition( Entity::ActorPtr pActor )
} }
} }
void Zone::updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell ) void Zone::updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell )
{ {
if( pCell == nullptr ) if( pCell == nullptr )
@ -721,12 +706,8 @@ void Zone::updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell )
if( !pCurAct ) if( !pCurAct )
continue; continue;
float distance = Math::Util::distance( pCurAct->getPos().x, float distance = Math::Util::distance( pCurAct->getPos().x, pCurAct->getPos().y, pCurAct->getPos().z,
pCurAct->getPos().y, pActor->getPos().x, pActor->getPos().y, pActor->getPos().z );
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. // Add if we are not ourself and range == 0 or distance is withing range.
if( pCurAct != pActor && ( fRange == 0.0f || distance <= fRange ) ) if( pCurAct != pActor && ( fRange == 0.0f || distance <= fRange ) )
@ -760,7 +741,6 @@ void Zone::updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell )
pActor->spawn( pPlayer ); pActor->spawn( pPlayer );
} }
} }
else if( pActor->isMob() && pCurAct->isPlayer() && pActor->isAlive() ) 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 #ifndef _ZONE_H
#define _ZONE_H #define _ZONE_H
#include <unordered_map>
#include <Server_Common/Common.h> #include <Server_Common/Common.h>
#include <unordered_map>
#include "Cell.h" #include "Cell.h"
#include "CellHandler.h" #include "CellHandler.h"
#include "Forwards.h" #include "Forwards.h"
#include <set>
#include <boost/enable_shared_from_this.hpp> #include <boost/enable_shared_from_this.hpp>
#include <set>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
namespace Core { namespace Core {
namespace Entity namespace Entity {
{
class Actor; class Actor;
class Player; class Player;
} } // namespace Entity
class Session; class Session;
@ -27,7 +26,9 @@ class ZonePosition;
typedef std::set< SessionPtr > SessionSet; 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: protected:
uint32_t m_zoneId; uint32_t m_zoneId;
@ -89,7 +90,8 @@ public:
void updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell ); 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(); virtual uint32_t getId();
@ -108,9 +110,8 @@ public:
void updateBnpcs( int64_t tickCount ); void updateBnpcs( int64_t tickCount );
bool runZoneLogic(); bool runZoneLogic();
}; };
} } // namespace Core
#endif #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 <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 "Zone.h"
#include "ZoneMgr.h"
#include "ZonePosition.h" #include "ZonePosition.h"
#include <Server_Common/Database/DatabaseDef.h> #include <Server_Common/Database/DatabaseDef.h>
@ -55,7 +55,6 @@ namespace Core {
{ {
uint32_t zoneId = zone.first; uint32_t zoneId = zone.first;
auto info = zone.second; auto info = zone.second;
g_log.Log( LoggingSeverity::info, std::to_string( info.id ) + "\t" + info.zone_str ); g_log.Log( LoggingSeverity::info, std::to_string( info.id ) + "\t" + info.zone_str );
@ -86,4 +85,4 @@ namespace Core {
return nullptr; return nullptr;
} }
} } // namespace Core

View file

@ -1,10 +1,9 @@
#ifndef _ZONEMGR_H #ifndef _ZONEMGR_H
#define _ZONEMGR_H #define _ZONEMGR_H
#include <unordered_map>
#include <map>
#include "Forwards.h" #include "Forwards.h"
#include <map>
#include <unordered_map>
namespace Core { namespace Core {
@ -30,10 +29,8 @@ namespace Core {
ZoneMap m_zoneMap; ZoneMap m_zoneMap;
std::unordered_map< int32_t, ZonePositionPtr > m_zonePositionMap; std::unordered_map< int32_t, ZonePositionPtr > m_zonePositionMap;
}; };
} } // namespace Core
#endif #endif

View file

@ -1,13 +1,11 @@
#include "ZonePosition.h" #include "ZonePosition.h"
Core::ZonePosition::ZonePosition() Core::ZonePosition::ZonePosition() : m_id( 0 ), m_targetZoneId( 0 ), m_radius( 0 )
: 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_id = id;
m_targetZoneId = targetZoneId; m_targetZoneId = targetZoneId;
@ -39,5 +37,3 @@ float Core::ZonePosition::getTargetRotation() const
{ {
return m_rotation; return m_rotation;
} }

View file

@ -16,7 +16,8 @@ protected:
public: public:
ZonePosition(); 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(); virtual ~ZonePosition();
uint32_t getId() const; uint32_t getId() const;
@ -26,8 +27,7 @@ public:
const Common::FFXIVARR_POSITION3& getTargetPosition() const; const Common::FFXIVARR_POSITION3& getTargetPosition() const;
float getTargetRotation() const; float getTargetRotation() const;
}; };
} } // namespace Core
#endif #endif