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:
parent
92594cdc1c
commit
72401d5e5e
92 changed files with 3882 additions and 4364 deletions
|
@ -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
|
||||||
|
|
|
@ -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,28 +34,29 @@ 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();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint16_t m_id;
|
uint16_t m_id;
|
||||||
Common::HandleActionType m_handleActionType;
|
Common::HandleActionType m_handleActionType;
|
||||||
|
|
||||||
uint64_t m_startTime;
|
uint64_t m_startTime;
|
||||||
uint32_t m_castTime;
|
uint32_t m_castTime;
|
||||||
|
|
||||||
Entity::ActorPtr m_pSource;
|
Entity::ActorPtr m_pSource;
|
||||||
Entity::ActorPtr m_pTarget;
|
Entity::ActorPtr m_pTarget;
|
||||||
|
|
||||||
bool m_bInterrupt;
|
bool m_bInterrupt;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace Action
|
||||||
}
|
} // namespace Core
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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,10 +51,10 @@ 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 )
|
||||||
{
|
{
|
||||||
std::set< ActorPtr > actorsCollided;
|
std::set< ActorPtr > actorsCollided;
|
||||||
|
|
||||||
|
@ -71,11 +71,11 @@ std::set< Core::Entity::ActorPtr > ActionCollision::getActorsHitFromAction( FFXI
|
||||||
assert( pActor );
|
assert( pActor );
|
||||||
|
|
||||||
// Don't bother wasting on collision if actor doesn't apply for it
|
// Don't bother wasting on collision if actor doesn't apply for it
|
||||||
if ( !isActorApplicable( pActor, targetFilter ) )
|
if( !isActorApplicable( pActor, targetFilter ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Test our collision from actor with the area generated by the action from the AoE data
|
// Test our collision from actor with the area generated by the action from the AoE data
|
||||||
if ( radiusCollision( pActor->getPos(), aoePosition, actionInfo->aoe_width ) )
|
if( radiusCollision( pActor->getPos(), aoePosition, actionInfo->aoe_width ) )
|
||||||
{
|
{
|
||||||
// Add it to the actors collided with the area
|
// Add it to the actors collided with the area
|
||||||
actorsCollided.insert( pActor );
|
actorsCollided.insert( pActor );
|
||||||
|
@ -89,10 +89,10 @@ std::set< Core::Entity::ActorPtr > ActionCollision::getActorsHitFromAction( FFXI
|
||||||
{
|
{
|
||||||
assert( pActor );
|
assert( pActor );
|
||||||
|
|
||||||
if ( !isActorApplicable( pActor, targetFilter ) )
|
if( !isActorApplicable( pActor, targetFilter ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( radiusCollision( pActor->getPos(), aoePosition, actionInfo->aoe_range ) )
|
if( radiusCollision( pActor->getPos(), aoePosition, actionInfo->aoe_range ) )
|
||||||
actorsCollided.insert( pActor );
|
actorsCollided.insert( pActor );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -103,10 +103,10 @@ std::set< Core::Entity::ActorPtr > ActionCollision::getActorsHitFromAction( FFXI
|
||||||
{
|
{
|
||||||
assert( pActor );
|
assert( pActor );
|
||||||
|
|
||||||
if ( !isActorApplicable( pActor, targetFilter ) )
|
if( !isActorApplicable( pActor, targetFilter ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( boxCollision( pActor->getPos(), aoePosition, actionInfo->aoe_width, actionInfo->aoe_range ) )
|
if( boxCollision( pActor->getPos(), aoePosition, actionInfo->aoe_width, actionInfo->aoe_range ) )
|
||||||
{
|
{
|
||||||
// todo: does this actually work?
|
// todo: does this actually work?
|
||||||
|
|
||||||
|
@ -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;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,25 +3,24 @@
|
||||||
|
|
||||||
#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 {
|
||||||
|
|
||||||
enum class TargetFilter
|
enum class TargetFilter
|
||||||
{
|
{
|
||||||
All, // All actors in the AoE are applicable for collision
|
All, // All actors in the AoE are applicable for collision
|
||||||
Players, // Only players
|
Players, // Only players
|
||||||
Allies, // Only allies (players, ally NPCs)
|
Allies, // Only allies (players, ally NPCs)
|
||||||
Party, // Only party members
|
Party, // Only party members
|
||||||
Enemies // Only enemies
|
Enemies // Only enemies
|
||||||
};
|
};
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -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 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -26,7 +26,7 @@ Core::Action::ActionTeleport::ActionTeleport( Entity::ActorPtr pActor, uint16_t
|
||||||
m_startTime = 0;
|
m_startTime = 0;
|
||||||
m_id = 5;
|
m_id = 5;
|
||||||
m_handleActionType = HandleActionType::Teleport;
|
m_handleActionType = HandleActionType::Teleport;
|
||||||
m_castTime = g_exdData.getActionInfo(5)->cast_time; // TODO: Add security checks.
|
m_castTime = g_exdData.getActionInfo( 5 )->cast_time; // TODO: Add security checks.
|
||||||
m_pSource = pActor;
|
m_pSource = pActor;
|
||||||
m_bInterrupt = false;
|
m_bInterrupt = false;
|
||||||
m_targetAetheryte = targetZone;
|
m_targetAetheryte = targetZone;
|
||||||
|
@ -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,25 +76,25 @@ 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 );
|
||||||
|
|
||||||
ZoneChannelPacket< FFXIVIpcEffect > effectPacket( pPlayer->getId() );
|
ZoneChannelPacket< FFXIVIpcEffect > effectPacket( pPlayer->getId() );
|
||||||
effectPacket.data().targetId = pPlayer->getId();
|
effectPacket.data().targetId = pPlayer->getId();
|
||||||
effectPacket.data().actionAnimationId = 5;
|
effectPacket.data().actionAnimationId = 5;
|
||||||
//effectPacket.data().unknown_3 = 1;
|
// effectPacket.data().unknown_3 = 1;
|
||||||
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 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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() );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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()
|
||||||
|
@ -70,7 +70,7 @@ void Core::Action::EventItemAction::onFinish()
|
||||||
GamePacketNew< FFXIVIpcEffect, ServerZoneIpcType > effectPacket( m_pSource->getId() );
|
GamePacketNew< FFXIVIpcEffect, ServerZoneIpcType > effectPacket( m_pSource->getId() );
|
||||||
effectPacket.data().targetId = static_cast< uint32_t >( m_additional );
|
effectPacket.data().targetId = static_cast< uint32_t >( m_additional );
|
||||||
effectPacket.data().actionAnimationId = 1;
|
effectPacket.data().actionAnimationId = 1;
|
||||||
// effectPacket.data().unknown_3 = 3;
|
// effectPacket.data().unknown_3 = 3;
|
||||||
effectPacket.data().actionTextId = m_id;
|
effectPacket.data().actionTextId = m_id;
|
||||||
effectPacket.data().unknown_5 = 2;
|
effectPacket.data().unknown_5 = 2;
|
||||||
effectPacket.data().numEffects = 1;
|
effectPacket.data().numEffects = 1;
|
||||||
|
@ -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() );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -75,12 +75,12 @@ bool Core::Entity::Actor::isMob() const
|
||||||
/*! \return list of actors currently in range */
|
/*! \return list of actors currently in range */
|
||||||
std::set< Core::Entity::ActorPtr > Core::Entity::Actor::getInRangeActors( bool includeSelf )
|
std::set< Core::Entity::ActorPtr > Core::Entity::Actor::getInRangeActors( bool includeSelf )
|
||||||
{
|
{
|
||||||
auto tempInRange = m_inRangeActors;
|
auto tempInRange = m_inRangeActors;
|
||||||
|
|
||||||
if( includeSelf )
|
if( includeSelf )
|
||||||
tempInRange.insert( shared_from_this() );
|
tempInRange.insert( shared_from_this() );
|
||||||
|
|
||||||
return tempInRange;
|
return tempInRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \return current stance of the actors */
|
/*! \return current stance of the actors */
|
||||||
|
@ -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,17 +353,18 @@ void Core::Entity::Actor::takeDamage( uint32_t damage )
|
||||||
{
|
{
|
||||||
if( damage >= m_hp )
|
if( damage >= m_hp )
|
||||||
{
|
{
|
||||||
switch( m_invincibilityType ) {
|
switch( m_invincibilityType )
|
||||||
case InvincibilityNone:
|
{
|
||||||
setHp( 0 );
|
case InvincibilityNone:
|
||||||
die();
|
setHp( 0 );
|
||||||
break;
|
die();
|
||||||
case InvincibilityRefill:
|
break;
|
||||||
resetHp();
|
case InvincibilityRefill:
|
||||||
break;
|
resetHp();
|
||||||
case InvincibilityStayAlive:
|
break;
|
||||||
setHp( 0 );
|
case InvincibilityStayAlive:
|
||||||
break;
|
setHp( 0 );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -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 )
|
||||||
{
|
{
|
||||||
|
@ -495,7 +490,7 @@ void Core::Entity::Actor::sendToInRangeSet( Network::Packets::GamePacketPtr pPac
|
||||||
if( m_inRangePlayers.empty() )
|
if( m_inRangePlayers.empty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for( const auto &pCurAct : m_inRangePlayers )
|
for( const auto& pCurAct : m_inRangePlayers )
|
||||||
{
|
{
|
||||||
assert( pCurAct );
|
assert( pCurAct );
|
||||||
pPacket->setValAt< uint32_t >( 0x04, m_id );
|
pPacket->setValAt< uint32_t >( 0x04, m_id );
|
||||||
|
@ -593,7 +588,7 @@ Get the current cell of a region the actor is in
|
||||||
|
|
||||||
\return Cell*
|
\return Cell*
|
||||||
*/
|
*/
|
||||||
Core::Cell * Core::Entity::Actor::getCell() const
|
Core::Cell* Core::Entity::Actor::getCell() const
|
||||||
{
|
{
|
||||||
return m_pCell;
|
return m_pCell;
|
||||||
}
|
}
|
||||||
|
@ -603,7 +598,7 @@ Set the current cell the actor is in
|
||||||
|
|
||||||
\param Cell* for the cell to be set
|
\param Cell* for the cell to be set
|
||||||
*/
|
*/
|
||||||
void Core::Entity::Actor::setCell( Cell * pCell )
|
void Core::Entity::Actor::setCell( Cell* pCell )
|
||||||
{
|
{
|
||||||
m_pCell = pCell;
|
m_pCell = pCell;
|
||||||
}
|
}
|
||||||
|
@ -635,7 +630,7 @@ void Core::Entity::Actor::autoAttack( ActorPtr pTarget )
|
||||||
effectPacket.data().targetId = pTarget->getId();
|
effectPacket.data().targetId = pTarget->getId();
|
||||||
effectPacket.data().actionAnimationId = 0x366;
|
effectPacket.data().actionAnimationId = 0x366;
|
||||||
effectPacket.data().unknown_2 = variation;
|
effectPacket.data().unknown_2 = variation;
|
||||||
// effectPacket.data().unknown_3 = 1;
|
// effectPacket.data().unknown_3 = 1;
|
||||||
effectPacket.data().actionTextId = 0x366;
|
effectPacket.data().actionTextId = 0x366;
|
||||||
effectPacket.data().numEffects = 1;
|
effectPacket.data().numEffects = 1;
|
||||||
effectPacket.data().rotation = Math::Util::floatToUInt16Rot( getRotation() );
|
effectPacket.data().rotation = Math::Util::floatToUInt16Rot( getRotation() );
|
||||||
|
@ -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 )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -699,16 +695,15 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
|
||||||
if( !actionInfoPtr->is_aoe )
|
if( !actionInfoPtr->is_aoe )
|
||||||
{
|
{
|
||||||
// If action on this specific target is valid...
|
// If action on this specific target is valid...
|
||||||
if ( isPlayer() && !ActionCollision::isActorApplicable( pTarget.shared_from_this(), TargetFilter::Enemies ) )
|
if( isPlayer() && !ActionCollision::isActorApplicable( pTarget.shared_from_this(), TargetFilter::Enemies ) )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
sendToInRangeSet( effectPacket, true );
|
sendToInRangeSet( effectPacket, true );
|
||||||
|
|
||||||
if ( pTarget.isAlive() )
|
if( pTarget.isAlive() )
|
||||||
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,17 +719,17 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
|
||||||
// todo: send to range of what? ourselves? when mob script hits this is going to be lacking
|
// 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() );
|
||||||
|
|
||||||
pHitActor->takeDamage( static_cast< uint32_t >( param1 ) );
|
pHitActor->takeDamage( static_cast< uint32_t >( param1 ) );
|
||||||
|
|
||||||
// Debug
|
// Debug
|
||||||
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() ) );
|
||||||
}
|
}
|
||||||
|
@ -817,7 +814,7 @@ void Core::Entity::Actor::addStatusEffect( StatusEffect::StatusEffectPtr pEffect
|
||||||
statusEffectAdd.data().max_hp = getMaxHp();
|
statusEffectAdd.data().max_hp = getMaxHp();
|
||||||
statusEffectAdd.data().max_mp = getMaxMp();
|
statusEffectAdd.data().max_mp = getMaxMp();
|
||||||
statusEffectAdd.data().max_something = 1;
|
statusEffectAdd.data().max_something = 1;
|
||||||
//statusEffectAdd.data().unknown2 = 28;
|
// statusEffectAdd.data().unknown2 = 28;
|
||||||
statusEffectAdd.data().param = pEffect->getParam();
|
statusEffectAdd.data().param = pEffect->getParam();
|
||||||
|
|
||||||
sendToInRangeSet( statusEffectAdd, isPlayer() );
|
sendToInRangeSet( statusEffectAdd, isPlayer() );
|
||||||
|
@ -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 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,343 +5,342 @@
|
||||||
#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 {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class Actor
|
\class Actor
|
||||||
\brief Base class for all actors
|
\brief Base class for all actors
|
||||||
|
|
||||||
\author Mordred
|
\author Mordred
|
||||||
*/
|
*/
|
||||||
class Actor : public boost::enable_shared_from_this< Actor >
|
class Actor : public boost::enable_shared_from_this< Actor >
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum ObjKind : uint8_t
|
|
||||||
{
|
{
|
||||||
None = 0x00,
|
public:
|
||||||
Player = 0x01,
|
enum ObjKind : uint8_t
|
||||||
BattleNpc = 0x02,
|
{
|
||||||
EventNpc = 0x03,
|
None = 0x00,
|
||||||
Treasure = 0x04,
|
Player = 0x01,
|
||||||
Aetheryte = 0x05,
|
BattleNpc = 0x02,
|
||||||
GatheringPoint = 0x06,
|
EventNpc = 0x03,
|
||||||
EventObj = 0x07,
|
Treasure = 0x04,
|
||||||
Mount = 0x08,
|
Aetheryte = 0x05,
|
||||||
Companion = 0x09,
|
GatheringPoint = 0x06,
|
||||||
Retainer = 0x0A,
|
EventObj = 0x07,
|
||||||
Area = 0x0B,
|
Mount = 0x08,
|
||||||
Housing = 0x0C,
|
Companion = 0x09,
|
||||||
Cutscene = 0x0D,
|
Retainer = 0x0A,
|
||||||
CardStand = 0x0E,
|
Area = 0x0B,
|
||||||
|
Housing = 0x0C,
|
||||||
|
Cutscene = 0x0D,
|
||||||
|
CardStand = 0x0E,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Stance : uint8_t
|
||||||
|
{
|
||||||
|
Passive = 0,
|
||||||
|
Active = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum DisplayFlags : uint16_t
|
||||||
|
{
|
||||||
|
ActiveStance = 0x001,
|
||||||
|
Invisible = 0x020,
|
||||||
|
HideHead = 0x040,
|
||||||
|
HideWeapon = 0x080,
|
||||||
|
Faded = 0x100,
|
||||||
|
Visor = 0x800,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum struct ActorStatus : uint8_t
|
||||||
|
{
|
||||||
|
Idle = 0x01,
|
||||||
|
Dead = 0x02,
|
||||||
|
Sitting = 0x03,
|
||||||
|
Mounted = 0x04,
|
||||||
|
Crafting = 0x05,
|
||||||
|
Gathering = 0x06,
|
||||||
|
Melding = 0x07,
|
||||||
|
SMachine = 0x08
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ActorStats
|
||||||
|
{
|
||||||
|
uint32_t max_mp = 0;
|
||||||
|
uint32_t max_hp = 0;
|
||||||
|
|
||||||
|
uint32_t str = 0;
|
||||||
|
uint32_t dex = 0;
|
||||||
|
uint32_t vit = 0;
|
||||||
|
uint32_t inte = 0;
|
||||||
|
uint32_t mnd = 0;
|
||||||
|
uint32_t pie = 0;
|
||||||
|
|
||||||
|
uint32_t tenacity = 0;
|
||||||
|
uint32_t attack = 0;
|
||||||
|
uint32_t defense = 0;
|
||||||
|
uint32_t accuracy = 0;
|
||||||
|
uint32_t spellSpeed = 0;
|
||||||
|
uint32_t magicDefense = 0;
|
||||||
|
uint32_t critHitRate = 0;
|
||||||
|
uint32_t resistSlash = 0;
|
||||||
|
uint32_t resistPierce = 0;
|
||||||
|
uint32_t resistBlunt = 0;
|
||||||
|
uint32_t attackPotMagic = 0;
|
||||||
|
uint32_t healingPotMagic = 0;
|
||||||
|
uint32_t determination = 0;
|
||||||
|
uint32_t skillSpeed = 0;
|
||||||
|
|
||||||
|
uint32_t resistSlow = 0;
|
||||||
|
uint32_t resistSilence = 0;
|
||||||
|
uint32_t resistBlind = 0;
|
||||||
|
uint32_t resistPoison = 0;
|
||||||
|
uint32_t resistStun = 0;
|
||||||
|
uint32_t resistSleep = 0;
|
||||||
|
uint32_t resistBind = 0;
|
||||||
|
uint32_t resistHeavy = 0;
|
||||||
|
|
||||||
|
uint32_t resistFire = 0;
|
||||||
|
uint32_t resistIce = 0;
|
||||||
|
uint32_t resistWind = 0;
|
||||||
|
uint32_t resistEarth = 0;
|
||||||
|
uint32_t resistLightning = 0;
|
||||||
|
uint32_t resistWater = 0;
|
||||||
|
|
||||||
|
} m_baseStats;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// TODO: The position class should probably be abolished and
|
||||||
|
// the FFXIV_POS struct used instead ( the functions in there
|
||||||
|
// could be moved to a FFXIV_POS_Helper namespace and rotation to
|
||||||
|
// its own member )
|
||||||
|
/*! Position of the actor */
|
||||||
|
Common::FFXIVARR_POSITION3 m_pos;
|
||||||
|
float m_rot;
|
||||||
|
/*! Name of the actor */
|
||||||
|
char m_name[34];
|
||||||
|
/*! Id of the zone the actor currently is in */
|
||||||
|
uint32_t m_zoneId;
|
||||||
|
/*! Id of the actor */
|
||||||
|
uint32_t m_id;
|
||||||
|
/*! Type of the actor */
|
||||||
|
ObjKind m_objKind;
|
||||||
|
/*! Ptr to the ZoneObj the actor belongs to */
|
||||||
|
ZonePtr m_pCurrentZone;
|
||||||
|
/*! Last tick time for the actor ( in ms ) */
|
||||||
|
uint64_t m_lastTickTime;
|
||||||
|
/*! Last time the actor performed an autoAttack ( in ms ) */
|
||||||
|
uint64_t m_lastAttack;
|
||||||
|
/*! Last time the actor was updated ( in ms ) */
|
||||||
|
uint64_t m_lastUpdate;
|
||||||
|
/*! Current stance of the actor */
|
||||||
|
Stance m_currentStance;
|
||||||
|
/*! Current staus of the actor */
|
||||||
|
ActorStatus m_status;
|
||||||
|
/*! Max HP of the actor ( based on job / class ) */
|
||||||
|
uint32_t m_maxHp;
|
||||||
|
/*! Max MP of the actor ( based on job / class ) */
|
||||||
|
uint32_t m_maxMp;
|
||||||
|
/*! Current HP of the actor */
|
||||||
|
uint32_t m_hp;
|
||||||
|
/*! Current MP of the actor */
|
||||||
|
uint32_t m_mp;
|
||||||
|
/*! Current TP of the actor */
|
||||||
|
uint16_t m_tp;
|
||||||
|
/*! Current GP of the actor */
|
||||||
|
uint16_t m_gp;
|
||||||
|
/*! Additional look info of the actor */
|
||||||
|
uint8_t m_customize[26];
|
||||||
|
/*! Current class of the actor */
|
||||||
|
Common::ClassJob m_class;
|
||||||
|
/*! Id of the currently selected target actor */
|
||||||
|
uint64_t m_targetId;
|
||||||
|
/*! Ptr to a queued action */
|
||||||
|
Action::ActionPtr m_pCurrentAction;
|
||||||
|
/*! Invincibility type */
|
||||||
|
Common::InvincibilityType m_invincibilityType;
|
||||||
|
|
||||||
|
/*! Status effects */
|
||||||
|
const uint8_t MAX_STATUS_EFFECTS = 30;
|
||||||
|
std::queue< uint8_t > m_statusEffectFreeSlotQueue;
|
||||||
|
std::vector< std::pair< uint8_t, uint32_t > > m_statusEffectList;
|
||||||
|
std::map< uint8_t, StatusEffect::StatusEffectPtr > m_statusEffectMap;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Actor();
|
||||||
|
|
||||||
|
virtual ~Actor();
|
||||||
|
|
||||||
|
virtual void calculateStats(){};
|
||||||
|
|
||||||
|
uint32_t getId() const;
|
||||||
|
|
||||||
|
/// Status effect functions
|
||||||
|
void addStatusEffect( StatusEffect::StatusEffectPtr pEffect );
|
||||||
|
void removeStatusEffect( uint8_t effectSlotId );
|
||||||
|
void removeSingleStatusEffectById( uint32_t id );
|
||||||
|
void updateStatusEffects();
|
||||||
|
|
||||||
|
bool hasStatusEffect( uint32_t id );
|
||||||
|
|
||||||
|
int8_t getStatusEffectFreeSlot();
|
||||||
|
void statusEffectFreeSlot( uint8_t slotId );
|
||||||
|
|
||||||
|
std::map< uint8_t, Core::StatusEffect::StatusEffectPtr > getStatusEffectMap() const;
|
||||||
|
|
||||||
|
void sendStatusEffectUpdate();
|
||||||
|
// add a status effect by id
|
||||||
|
void addStatusEffectById( uint32_t id, int32_t duration, Entity::Actor& pSource, uint16_t param = 0 );
|
||||||
|
|
||||||
|
// add a status effect by id if it doesn't exist
|
||||||
|
void addStatusEffectByIdIfNotExist( uint32_t id, int32_t duration, Entity::Actor& pSource, uint16_t param = 0 );
|
||||||
|
|
||||||
|
// remove a status effect by id
|
||||||
|
void removeSingleStatusEffectFromId( uint32_t id );
|
||||||
|
/// End Status Effect Functions
|
||||||
|
|
||||||
|
void setPosition( const Common::FFXIVARR_POSITION3& pos );
|
||||||
|
void setPosition( float x, float y, float z );
|
||||||
|
|
||||||
|
void setRotation( float rot );
|
||||||
|
|
||||||
|
float getRotation() const;
|
||||||
|
|
||||||
|
Common::FFXIVARR_POSITION3& getPos();
|
||||||
|
|
||||||
|
std::string getName() const;
|
||||||
|
|
||||||
|
bool isPlayer() const;
|
||||||
|
|
||||||
|
bool isMob() const;
|
||||||
|
|
||||||
|
std::set< ActorPtr > getInRangeActors( bool includeSelf = false );
|
||||||
|
|
||||||
|
bool face( const Common::FFXIVARR_POSITION3& p );
|
||||||
|
|
||||||
|
Stance getStance() const;
|
||||||
|
|
||||||
|
void setStance( Stance stance );
|
||||||
|
|
||||||
|
ActorStats getStats() const;
|
||||||
|
|
||||||
|
uint32_t getHp() const;
|
||||||
|
|
||||||
|
uint32_t getMp() const;
|
||||||
|
|
||||||
|
uint16_t getTp() const;
|
||||||
|
|
||||||
|
uint16_t getGp() const;
|
||||||
|
|
||||||
|
Common::InvincibilityType getInvincibilityType() const;
|
||||||
|
|
||||||
|
Common::ClassJob getClass() const;
|
||||||
|
|
||||||
|
uint8_t getClassAsInt() const;
|
||||||
|
|
||||||
|
void setClass( Common::ClassJob classJob );
|
||||||
|
|
||||||
|
void setTargetId( uint64_t targetId );
|
||||||
|
|
||||||
|
uint64_t getTargetId() const;
|
||||||
|
|
||||||
|
bool isAlive() const;
|
||||||
|
|
||||||
|
virtual uint32_t getMaxHp() const;
|
||||||
|
|
||||||
|
virtual uint32_t getMaxMp() const;
|
||||||
|
|
||||||
|
void resetHp();
|
||||||
|
|
||||||
|
void resetMp();
|
||||||
|
|
||||||
|
void setHp( uint32_t hp );
|
||||||
|
|
||||||
|
void setMp( uint32_t mp );
|
||||||
|
|
||||||
|
void setGp( uint32_t gp );
|
||||||
|
|
||||||
|
void setInvincibilityType( Common::InvincibilityType type );
|
||||||
|
|
||||||
|
void die();
|
||||||
|
|
||||||
|
ActorStatus getStatus() const;
|
||||||
|
|
||||||
|
void setStatus( ActorStatus status );
|
||||||
|
|
||||||
|
void handleScriptSkill( uint32_t type, uint16_t actionId, uint64_t param1, uint64_t param2,
|
||||||
|
Entity::Actor& target );
|
||||||
|
|
||||||
|
virtual void autoAttack( ActorPtr pTarget );
|
||||||
|
|
||||||
|
virtual void spawn( PlayerPtr pTarget ) {}
|
||||||
|
virtual void despawn( ActorPtr pTarget ) {}
|
||||||
|
|
||||||
|
virtual void onRemoveInRangeActor( ActorPtr pActor ) {}
|
||||||
|
virtual void onDeath(){};
|
||||||
|
virtual void onDamageTaken( Actor& pSource ){};
|
||||||
|
virtual void onActionHostile( Core::Entity::ActorPtr pSource ){};
|
||||||
|
virtual void onActionFriendly( Actor& pSource ){};
|
||||||
|
virtual void onTick(){};
|
||||||
|
|
||||||
|
virtual void changeTarget( uint64_t targetId );
|
||||||
|
virtual uint8_t getLevel() const;
|
||||||
|
virtual void sendStatusUpdate( bool toSelf = true );
|
||||||
|
virtual void takeDamage( uint32_t damage );
|
||||||
|
virtual void heal( uint32_t amount );
|
||||||
|
virtual bool checkAction();
|
||||||
|
virtual void update( int64_t currTime ){};
|
||||||
|
|
||||||
|
PlayerPtr getAsPlayer();
|
||||||
|
BattleNpcPtr getAsBattleNpc();
|
||||||
|
|
||||||
|
Action::ActionPtr getCurrentAction() const;
|
||||||
|
|
||||||
|
void setCurrentAction( Action::ActionPtr pAction );
|
||||||
|
|
||||||
|
///// IN RANGE LOGIC /////
|
||||||
|
|
||||||
|
// check if another actor is in the actors in range set
|
||||||
|
bool isInRangeSet( ActorPtr pActor ) const;
|
||||||
|
|
||||||
|
ActorPtr getClosestActor();
|
||||||
|
|
||||||
|
void sendToInRangeSet( Network::Packets::GamePacketPtr pPacket, bool bToSelf = false );
|
||||||
|
|
||||||
|
// add an actor to in range set
|
||||||
|
virtual void addInRangeActor( ActorPtr pActor );
|
||||||
|
|
||||||
|
// remove an actor from the in range set
|
||||||
|
void removeInRangeActor( ActorPtr pActor );
|
||||||
|
|
||||||
|
// return true if there is at least one actor in the in range set
|
||||||
|
bool hasInRangeActor() const;
|
||||||
|
|
||||||
|
// clear the whole in range set, this does no cleanup
|
||||||
|
virtual void clearInRangeSet();
|
||||||
|
|
||||||
|
ZonePtr getCurrentZone() const;
|
||||||
|
|
||||||
|
void setCurrentZone( ZonePtr currZone );
|
||||||
|
|
||||||
|
// get the current cell of a region the actor is in
|
||||||
|
Cell* getCell() const;
|
||||||
|
|
||||||
|
// set the current cell
|
||||||
|
void setCell( Cell* pCell );
|
||||||
|
|
||||||
|
// TODO: Why did i even declare them publicly here?!
|
||||||
|
std::set< ActorPtr > m_inRangeActors;
|
||||||
|
std::set< PlayerPtr > m_inRangePlayers;
|
||||||
|
std::map< uint32_t, ActorPtr > m_inRangeActorMap;
|
||||||
|
|
||||||
|
Core::Cell* m_pCell;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Stance : uint8_t
|
} // namespace Entity
|
||||||
{
|
} // namespace Core
|
||||||
Passive = 0,
|
|
||||||
Active = 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum DisplayFlags : uint16_t
|
|
||||||
{
|
|
||||||
ActiveStance = 0x001,
|
|
||||||
Invisible = 0x020,
|
|
||||||
HideHead = 0x040,
|
|
||||||
HideWeapon = 0x080,
|
|
||||||
Faded = 0x100,
|
|
||||||
Visor = 0x800,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum struct ActorStatus : uint8_t
|
|
||||||
{
|
|
||||||
Idle = 0x01,
|
|
||||||
Dead = 0x02,
|
|
||||||
Sitting = 0x03,
|
|
||||||
Mounted = 0x04,
|
|
||||||
Crafting = 0x05,
|
|
||||||
Gathering = 0x06,
|
|
||||||
Melding = 0x07,
|
|
||||||
SMachine = 0x08
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ActorStats
|
|
||||||
{
|
|
||||||
uint32_t max_mp = 0;
|
|
||||||
uint32_t max_hp = 0;
|
|
||||||
|
|
||||||
uint32_t str = 0;
|
|
||||||
uint32_t dex = 0;
|
|
||||||
uint32_t vit = 0;
|
|
||||||
uint32_t inte = 0;
|
|
||||||
uint32_t mnd = 0;
|
|
||||||
uint32_t pie = 0;
|
|
||||||
|
|
||||||
uint32_t tenacity = 0;
|
|
||||||
uint32_t attack = 0;
|
|
||||||
uint32_t defense = 0;
|
|
||||||
uint32_t accuracy = 0;
|
|
||||||
uint32_t spellSpeed = 0;
|
|
||||||
uint32_t magicDefense = 0;
|
|
||||||
uint32_t critHitRate = 0;
|
|
||||||
uint32_t resistSlash = 0;
|
|
||||||
uint32_t resistPierce = 0;
|
|
||||||
uint32_t resistBlunt = 0;
|
|
||||||
uint32_t attackPotMagic = 0;
|
|
||||||
uint32_t healingPotMagic = 0;
|
|
||||||
uint32_t determination = 0;
|
|
||||||
uint32_t skillSpeed = 0;
|
|
||||||
|
|
||||||
uint32_t resistSlow = 0;
|
|
||||||
uint32_t resistSilence = 0;
|
|
||||||
uint32_t resistBlind = 0;
|
|
||||||
uint32_t resistPoison = 0;
|
|
||||||
uint32_t resistStun = 0;
|
|
||||||
uint32_t resistSleep = 0;
|
|
||||||
uint32_t resistBind = 0;
|
|
||||||
uint32_t resistHeavy = 0;
|
|
||||||
|
|
||||||
uint32_t resistFire = 0;
|
|
||||||
uint32_t resistIce = 0;
|
|
||||||
uint32_t resistWind = 0;
|
|
||||||
uint32_t resistEarth = 0;
|
|
||||||
uint32_t resistLightning = 0;
|
|
||||||
uint32_t resistWater = 0;
|
|
||||||
|
|
||||||
} m_baseStats;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// TODO: The position class should probably be abolished and
|
|
||||||
// the FFXIV_POS struct used instead ( the functions in there
|
|
||||||
// could be moved to a FFXIV_POS_Helper namespace and rotation to
|
|
||||||
// its own member )
|
|
||||||
/*! Position of the actor */
|
|
||||||
Common::FFXIVARR_POSITION3 m_pos;
|
|
||||||
float m_rot;
|
|
||||||
/*! Name of the actor */
|
|
||||||
char m_name[34];
|
|
||||||
/*! Id of the zone the actor currently is in */
|
|
||||||
uint32_t m_zoneId;
|
|
||||||
/*! Id of the actor */
|
|
||||||
uint32_t m_id;
|
|
||||||
/*! Type of the actor */
|
|
||||||
ObjKind m_objKind;
|
|
||||||
/*! Ptr to the ZoneObj the actor belongs to */
|
|
||||||
ZonePtr m_pCurrentZone;
|
|
||||||
/*! Last tick time for the actor ( in ms ) */
|
|
||||||
uint64_t m_lastTickTime;
|
|
||||||
/*! Last time the actor performed an autoAttack ( in ms ) */
|
|
||||||
uint64_t m_lastAttack;
|
|
||||||
/*! Last time the actor was updated ( in ms ) */
|
|
||||||
uint64_t m_lastUpdate;
|
|
||||||
/*! Current stance of the actor */
|
|
||||||
Stance m_currentStance;
|
|
||||||
/*! Current staus of the actor */
|
|
||||||
ActorStatus m_status;
|
|
||||||
/*! Max HP of the actor ( based on job / class ) */
|
|
||||||
uint32_t m_maxHp;
|
|
||||||
/*! Max MP of the actor ( based on job / class ) */
|
|
||||||
uint32_t m_maxMp;
|
|
||||||
/*! Current HP of the actor */
|
|
||||||
uint32_t m_hp;
|
|
||||||
/*! Current MP of the actor */
|
|
||||||
uint32_t m_mp;
|
|
||||||
/*! Current TP of the actor */
|
|
||||||
uint16_t m_tp;
|
|
||||||
/*! Current GP of the actor */
|
|
||||||
uint16_t m_gp;
|
|
||||||
/*! Additional look info of the actor */
|
|
||||||
uint8_t m_customize[26];
|
|
||||||
/*! Current class of the actor */
|
|
||||||
Common::ClassJob m_class;
|
|
||||||
/*! Id of the currently selected target actor */
|
|
||||||
uint64_t m_targetId;
|
|
||||||
/*! Ptr to a queued action */
|
|
||||||
Action::ActionPtr m_pCurrentAction;
|
|
||||||
/*! Invincibility type */
|
|
||||||
Common::InvincibilityType m_invincibilityType;
|
|
||||||
|
|
||||||
/*! Status effects */
|
|
||||||
const uint8_t MAX_STATUS_EFFECTS = 30;
|
|
||||||
std::queue< uint8_t > m_statusEffectFreeSlotQueue;
|
|
||||||
std::vector< std::pair< uint8_t, uint32_t> > m_statusEffectList;
|
|
||||||
std::map< uint8_t, StatusEffect::StatusEffectPtr > m_statusEffectMap;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Actor();
|
|
||||||
|
|
||||||
virtual ~Actor();
|
|
||||||
|
|
||||||
virtual void calculateStats() {};
|
|
||||||
|
|
||||||
uint32_t getId() const;
|
|
||||||
|
|
||||||
/// Status effect functions
|
|
||||||
void addStatusEffect( StatusEffect::StatusEffectPtr pEffect );
|
|
||||||
void removeStatusEffect( uint8_t effectSlotId );
|
|
||||||
void removeSingleStatusEffectById( uint32_t id );
|
|
||||||
void updateStatusEffects();
|
|
||||||
|
|
||||||
bool hasStatusEffect( uint32_t id );
|
|
||||||
|
|
||||||
int8_t getStatusEffectFreeSlot();
|
|
||||||
void statusEffectFreeSlot( uint8_t slotId );
|
|
||||||
|
|
||||||
std::map< uint8_t, Core::StatusEffect::StatusEffectPtr > getStatusEffectMap() const;
|
|
||||||
|
|
||||||
void sendStatusEffectUpdate();
|
|
||||||
// add a status effect by id
|
|
||||||
void addStatusEffectById( uint32_t id, int32_t duration, Entity::Actor& pSource, uint16_t param = 0 );
|
|
||||||
|
|
||||||
// add a status effect by id if it doesn't exist
|
|
||||||
void addStatusEffectByIdIfNotExist( uint32_t id, int32_t duration, Entity::Actor& pSource, uint16_t param = 0 );
|
|
||||||
|
|
||||||
// remove a status effect by id
|
|
||||||
void removeSingleStatusEffectFromId( uint32_t id );
|
|
||||||
/// End Status Effect Functions
|
|
||||||
|
|
||||||
void setPosition( const Common::FFXIVARR_POSITION3& pos );
|
|
||||||
void setPosition( float x, float y, float z );
|
|
||||||
|
|
||||||
void setRotation( float rot );
|
|
||||||
|
|
||||||
float getRotation() const;
|
|
||||||
|
|
||||||
Common::FFXIVARR_POSITION3& getPos();
|
|
||||||
|
|
||||||
std::string getName() const;
|
|
||||||
|
|
||||||
bool isPlayer() const;
|
|
||||||
|
|
||||||
bool isMob() const;
|
|
||||||
|
|
||||||
std::set< ActorPtr > getInRangeActors( bool includeSelf = false );
|
|
||||||
|
|
||||||
bool face( const Common::FFXIVARR_POSITION3& p );
|
|
||||||
|
|
||||||
Stance getStance() const;
|
|
||||||
|
|
||||||
void setStance( Stance stance );
|
|
||||||
|
|
||||||
ActorStats getStats() const;
|
|
||||||
|
|
||||||
uint32_t getHp() const;
|
|
||||||
|
|
||||||
uint32_t getMp() const;
|
|
||||||
|
|
||||||
uint16_t getTp() const;
|
|
||||||
|
|
||||||
uint16_t getGp() const;
|
|
||||||
|
|
||||||
Common::InvincibilityType getInvincibilityType() const;
|
|
||||||
|
|
||||||
Common::ClassJob getClass() const;
|
|
||||||
|
|
||||||
uint8_t getClassAsInt() const;
|
|
||||||
|
|
||||||
void setClass( Common::ClassJob classJob );
|
|
||||||
|
|
||||||
void setTargetId( uint64_t targetId );
|
|
||||||
|
|
||||||
uint64_t getTargetId() const;
|
|
||||||
|
|
||||||
bool isAlive() const;
|
|
||||||
|
|
||||||
virtual uint32_t getMaxHp() const;
|
|
||||||
|
|
||||||
virtual uint32_t getMaxMp() const;
|
|
||||||
|
|
||||||
void resetHp();
|
|
||||||
|
|
||||||
void resetMp();
|
|
||||||
|
|
||||||
void setHp( uint32_t hp );
|
|
||||||
|
|
||||||
void setMp( uint32_t mp );
|
|
||||||
|
|
||||||
void setGp( uint32_t gp );
|
|
||||||
|
|
||||||
void setInvincibilityType( Common::InvincibilityType type );
|
|
||||||
|
|
||||||
void die();
|
|
||||||
|
|
||||||
ActorStatus getStatus() const;
|
|
||||||
|
|
||||||
void setStatus( ActorStatus status );
|
|
||||||
|
|
||||||
void handleScriptSkill( uint32_t type, uint16_t actionId, uint64_t param1, uint64_t param2, Entity::Actor& target );
|
|
||||||
|
|
||||||
virtual void autoAttack( ActorPtr pTarget );
|
|
||||||
|
|
||||||
virtual void spawn( PlayerPtr pTarget ) {}
|
|
||||||
virtual void despawn( ActorPtr pTarget ) {}
|
|
||||||
|
|
||||||
virtual void onRemoveInRangeActor( ActorPtr pActor ) {}
|
|
||||||
virtual void onDeath() {};
|
|
||||||
virtual void onDamageTaken( Actor& pSource ) {};
|
|
||||||
virtual void onActionHostile( Core::Entity::ActorPtr pSource ) {};
|
|
||||||
virtual void onActionFriendly( Actor& pSource ) {};
|
|
||||||
virtual void onTick() {};
|
|
||||||
|
|
||||||
virtual void changeTarget( uint64_t targetId );
|
|
||||||
virtual uint8_t getLevel() const;
|
|
||||||
virtual void sendStatusUpdate( bool toSelf = true );
|
|
||||||
virtual void takeDamage( uint32_t damage );
|
|
||||||
virtual void heal( uint32_t amount );
|
|
||||||
virtual bool checkAction();
|
|
||||||
virtual void update( int64_t currTime ) {};
|
|
||||||
|
|
||||||
PlayerPtr getAsPlayer();
|
|
||||||
BattleNpcPtr getAsBattleNpc();
|
|
||||||
|
|
||||||
Action::ActionPtr getCurrentAction() const;
|
|
||||||
|
|
||||||
void setCurrentAction( Action::ActionPtr pAction );
|
|
||||||
|
|
||||||
///// IN RANGE LOGIC /////
|
|
||||||
|
|
||||||
// check if another actor is in the actors in range set
|
|
||||||
bool isInRangeSet( ActorPtr pActor ) const;
|
|
||||||
|
|
||||||
ActorPtr getClosestActor();
|
|
||||||
|
|
||||||
void sendToInRangeSet( Network::Packets::GamePacketPtr pPacket, bool bToSelf = false );
|
|
||||||
|
|
||||||
// add an actor to in range set
|
|
||||||
virtual void addInRangeActor( ActorPtr pActor );
|
|
||||||
|
|
||||||
// remove an actor from the in range set
|
|
||||||
void removeInRangeActor( ActorPtr pActor );
|
|
||||||
|
|
||||||
// return true if there is at least one actor in the in range set
|
|
||||||
bool hasInRangeActor() const;
|
|
||||||
|
|
||||||
// clear the whole in range set, this does no cleanup
|
|
||||||
virtual void clearInRangeSet();
|
|
||||||
|
|
||||||
ZonePtr getCurrentZone() const;
|
|
||||||
|
|
||||||
void setCurrentZone( ZonePtr currZone );
|
|
||||||
|
|
||||||
// get the current cell of a region the actor is in
|
|
||||||
Cell* getCell() const;
|
|
||||||
|
|
||||||
// set the current cell
|
|
||||||
void setCell( Cell* pCell );
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: Why did i even declare them publicly here?!
|
|
||||||
std::set< ActorPtr > m_inRangeActors;
|
|
||||||
std::set< PlayerPtr > m_inRangePlayers;
|
|
||||||
std::map< uint32_t, ActorPtr > m_inRangeActorMap;
|
|
||||||
|
|
||||||
Core::Cell* m_pCell;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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,16 +34,16 @@ 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;
|
||||||
//strcpy( m_name, pBNpc->m_name.c_str() );
|
// strcpy( m_name, pBNpc->m_name.c_str() );
|
||||||
|
|
||||||
m_pos = spawnPos;
|
m_pos = spawnPos;
|
||||||
m_posOrigin = spawnPos;
|
m_posOrigin = spawnPos;
|
||||||
|
@ -65,7 +65,7 @@ Core::Entity::BattleNpc::BattleNpc( uint16_t modelId, uint16_t nameid, const Com
|
||||||
m_currentStance = Stance::Passive;
|
m_currentStance = Stance::Passive;
|
||||||
|
|
||||||
m_class = ClassJob::Gladiator;
|
m_class = ClassJob::Gladiator;
|
||||||
m_level = level > uint8_t{0} ? level : uint8_t{70};
|
m_level = level > uint8_t{ 0 } ? level : uint8_t{ 70 };
|
||||||
|
|
||||||
m_modelId = modelId;
|
m_modelId = modelId;
|
||||||
m_nameId = nameid;
|
m_nameId = nameid;
|
||||||
|
@ -82,46 +82,44 @@ 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
|
||||||
void Core::Entity::BattleNpc::spawn( PlayerPtr pTarget )
|
void Core::Entity::BattleNpc::spawn( PlayerPtr pTarget )
|
||||||
{
|
{
|
||||||
//GamePacketNew< FFXIVIpcActorSpawn > spawnPacket( getId(), pTarget->getId() );
|
// GamePacketNew< FFXIVIpcActorSpawn > spawnPacket( getId(), pTarget->getId() );
|
||||||
|
|
||||||
//spawnPacket.data().unknown_0 = 0;
|
// spawnPacket.data().unknown_0 = 0;
|
||||||
//spawnPacket.data().ownerId = m_pOwner == nullptr ? INVALID_GAME_OBJECT_ID : m_pOwner->getId();
|
// spawnPacket.data().ownerId = m_pOwner == nullptr ? INVALID_GAME_OBJECT_ID : m_pOwner->getId();
|
||||||
//spawnPacket.data().targetId = INVALID_GAME_OBJECT_ID & 0xFFFFFFFF;
|
// spawnPacket.data().targetId = INVALID_GAME_OBJECT_ID & 0xFFFFFFFF;
|
||||||
//spawnPacket.data().hPCurr = m_hp;
|
// spawnPacket.data().hPCurr = m_hp;
|
||||||
//spawnPacket.data().hPMax = m_baseStats.max_hp;
|
// spawnPacket.data().hPMax = m_baseStats.max_hp;
|
||||||
//spawnPacket.data().level = m_level;
|
// spawnPacket.data().level = m_level;
|
||||||
////spawnPacket.data().tPCurr = 1000;
|
////spawnPacket.data().tPCurr = 1000;
|
||||||
//spawnPacket.data().model = m_modelId;
|
// spawnPacket.data().model = m_modelId;
|
||||||
//spawnPacket.data().bnpcBaseId = m_bnpcBaseId;
|
// spawnPacket.data().bnpcBaseId = m_bnpcBaseId;
|
||||||
//spawnPacket.data().nameId = m_nameId;
|
// spawnPacket.data().nameId = m_nameId;
|
||||||
//spawnPacket.data().spawnIndex = pTarget->getSpawnIdForActorId( getId() );
|
// spawnPacket.data().spawnIndex = pTarget->getSpawnIdForActorId( getId() );
|
||||||
//g_log.info(std::to_string(spawnPacket.data().spawnIndex) + " " + std::to_string(getId()));
|
// g_log.info(std::to_string(spawnPacket.data().spawnIndex) + " " + std::to_string(getId()));
|
||||||
//spawnPacket.data().status = static_cast< uint8_t >( m_status );
|
// spawnPacket.data().status = static_cast< uint8_t >( m_status );
|
||||||
//spawnPacket.data().mobAgressive = m_behavior;
|
// spawnPacket.data().mobAgressive = m_behavior;
|
||||||
//spawnPacket.data().type = static_cast< uint8_t >( m_type );
|
// spawnPacket.data().type = static_cast< uint8_t >( m_type );
|
||||||
//spawnPacket.data().mobTypeIcon = m_mobType;
|
// spawnPacket.data().mobTypeIcon = m_mobType;
|
||||||
//spawnPacket.data().unknown_33 = 5;
|
// spawnPacket.data().unknown_33 = 5;
|
||||||
//spawnPacket.data().typeFlags = 4;
|
// spawnPacket.data().typeFlags = 4;
|
||||||
//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;
|
||||||
//spawnPacket.data().rotation = Math::Util::floatToUInt16Rot( getRotation() );
|
// spawnPacket.data().rotation = Math::Util::floatToUInt16Rot( getRotation() );
|
||||||
////spawnPacket.data().unknown_B0[11] = 1;
|
////spawnPacket.data().unknown_B0[11] = 1;
|
||||||
////spawnPacket.data().unknown_B0[12] = 4;
|
////spawnPacket.data().unknown_B0[12] = 4;
|
||||||
////spawnPacket.data().unknown_B0[14] = 20;
|
////spawnPacket.data().unknown_B0[14] = 20;
|
||||||
|
|
||||||
//pTarget->queuePacket( spawnPacket );
|
// pTarget->queuePacket( spawnPacket );
|
||||||
|
|
||||||
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
|
||||||
|
@ -224,12 +221,11 @@ void Core::Entity::BattleNpc::setOwner( PlayerPtr pPlayer )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ZoneChannelPacket< FFXIVIpcActorOwner > setOwnerPacket(getId(), INVALID_GAME_OBJECT_ID );
|
ZoneChannelPacket< FFXIVIpcActorOwner > setOwnerPacket( getId(), INVALID_GAME_OBJECT_ID );
|
||||||
setOwnerPacket.data().type = 0x01;
|
setOwnerPacket.data().type = 0x01;
|
||||||
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;
|
||||||
|
|
||||||
|
@ -270,12 +265,11 @@ bool Core::Entity::BattleNpc::moveTo( Common::FFXIVARR_POSITION3& pos )
|
||||||
tmpPos.z = getPos().z + z;
|
tmpPos.z = getPos().z + z;
|
||||||
|
|
||||||
setPosition( tmpPos );
|
setPosition( tmpPos );
|
||||||
setRotation(newRot);
|
setRotation( newRot );
|
||||||
|
|
||||||
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();
|
||||||
|
@ -384,7 +377,7 @@ void Core::Entity::BattleNpc::hateListUpdate( ActorPtr pActor, int32_t hateAmoun
|
||||||
|
|
||||||
void Core::Entity::BattleNpc::onDeath()
|
void Core::Entity::BattleNpc::onDeath()
|
||||||
{
|
{
|
||||||
//LuaManager->onMobDeath( this );
|
// LuaManager->onMobDeath( this );
|
||||||
|
|
||||||
setTimeOfDeath( static_cast< uint32_t >( time( nullptr ) ) );
|
setTimeOfDeath( static_cast< uint32_t >( time( nullptr ) ) );
|
||||||
setTargetId( INVALID_GAME_OBJECT_ID );
|
setTargetId( INVALID_GAME_OBJECT_ID );
|
||||||
|
@ -410,13 +403,13 @@ void Core::Entity::BattleNpc::onDeath()
|
||||||
totalHate += pHateEntry->m_hateAmount;
|
totalHate += pHateEntry->m_hateAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
//uint32_t plsBeHatedThisMuchAtLeast = totalHate / ( maxHate + 2 ) / clamp( m_hateList.size(), 1.0f, 1.5f );
|
// uint32_t plsBeHatedThisMuchAtLeast = totalHate / ( maxHate + 2 ) / clamp( m_hateList.size(), 1.0f, 1.5f );
|
||||||
|
|
||||||
for( auto& pHateEntry : m_hateList )
|
for( auto& pHateEntry : m_hateList )
|
||||||
{
|
{
|
||||||
// todo: this is pure retarded
|
// todo: this is pure retarded
|
||||||
// todo: check for companion
|
// todo: check for companion
|
||||||
if( pHateEntry->m_pActor->isPlayer() ) // && pHateEntry->m_hateAmount >= plsBeHatedThisMuchAtLeast )
|
if( pHateEntry->m_pActor->isPlayer() ) // && pHateEntry->m_hateAmount >= plsBeHatedThisMuchAtLeast )
|
||||||
{
|
{
|
||||||
uint8_t level = pHateEntry->m_pActor->getLevel();
|
uint8_t level = pHateEntry->m_pActor->getLevel();
|
||||||
auto levelDiff = static_cast< int32_t >( this->m_level ) - level;
|
auto levelDiff = static_cast< int32_t >( this->m_level ) - level;
|
||||||
|
@ -427,21 +420,26 @@ 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 ) ) );
|
||||||
|
|
||||||
auto pPlayer = pHateEntry->m_pActor->getAsPlayer();
|
auto pPlayer = pHateEntry->m_pActor->getAsPlayer();
|
||||||
pPlayer->gainExp( exp );
|
pPlayer->gainExp( exp );
|
||||||
|
@ -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,12 +505,10 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,110 +6,108 @@
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Entity {
|
namespace Entity {
|
||||||
|
|
||||||
enum StateMode
|
enum StateMode
|
||||||
{
|
{
|
||||||
MODE_COMBAT,
|
MODE_COMBAT,
|
||||||
MODE_RETREAT,
|
MODE_RETREAT,
|
||||||
MODE_IDLE,
|
MODE_IDLE,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint32_t m_hateAmount;
|
uint32_t m_hateAmount;
|
||||||
ActorPtr m_pActor;
|
ActorPtr m_pActor;
|
||||||
} HateListEntry;
|
} HateListEntry;
|
||||||
|
|
||||||
// class for Mobs inheriting from Actor
|
// class for Mobs inheriting from Actor
|
||||||
class BattleNpc : public Actor
|
class BattleNpc : public Actor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BattleNpc();
|
BattleNpc();
|
||||||
~BattleNpc();
|
~BattleNpc();
|
||||||
|
|
||||||
BattleNpc( uint16_t modelId, uint16_t nameid, const Common::FFXIVARR_POSITION3& spawnPos, uint16_t bnpcBaseId = 0,
|
BattleNpc( uint16_t modelId, uint16_t nameid, const Common::FFXIVARR_POSITION3& spawnPos, uint16_t bnpcBaseId = 0,
|
||||||
uint32_t type = 2, uint8_t level = 0, uint8_t behaviour = 1, uint32_t mobType = 0 );
|
uint32_t type = 2, uint8_t level = 0, uint8_t behaviour = 1, uint32_t mobType = 0 );
|
||||||
|
|
||||||
//BattleNpc( uint32_t modelId,
|
// BattleNpc( uint32_t modelId,
|
||||||
// uint32_t nameId,
|
// uint32_t nameId,
|
||||||
// uint32_t bnpcBaseId,
|
// uint32_t bnpcBaseId,
|
||||||
// uint32_t level,
|
// uint32_t level,
|
||||||
// const Common::FFXIVARR_POSITION3& spawnPos,
|
// const Common::FFXIVARR_POSITION3& spawnPos,
|
||||||
// uint32_t type = 2, uint32_t behaviour = 1, uint32_t mobType = 0 );
|
// uint32_t type = 2, uint32_t behaviour = 1, uint32_t mobType = 0 );
|
||||||
|
|
||||||
void initStatusEffectContainer();
|
void initStatusEffectContainer();
|
||||||
|
|
||||||
// send spawn packets to pTarget
|
// send spawn packets to pTarget
|
||||||
void spawn( PlayerPtr pTarget ) override;
|
void spawn( PlayerPtr pTarget ) override;
|
||||||
|
|
||||||
// send despawn packets to pTarget
|
// send despawn packets to pTarget
|
||||||
void despawn( ActorPtr pTarget ) override;
|
void despawn( ActorPtr pTarget ) override;
|
||||||
|
|
||||||
uint8_t getLevel() const override;
|
uint8_t getLevel() const override;
|
||||||
|
|
||||||
StateMode getMode() const;
|
StateMode getMode() const;
|
||||||
|
|
||||||
void setMode( StateMode mode );
|
void setMode( StateMode mode );
|
||||||
|
|
||||||
uint8_t getbehavior() const;
|
uint8_t getbehavior() const;
|
||||||
|
|
||||||
void hateListAdd( ActorPtr pActor, int32_t hateAmount );
|
void hateListAdd( ActorPtr pActor, int32_t hateAmount );
|
||||||
|
|
||||||
void hateListUpdate( ActorPtr pActor, int32_t hateAmount );
|
void hateListUpdate( ActorPtr pActor, int32_t hateAmount );
|
||||||
void hateListRemove( ActorPtr pActor );
|
void hateListRemove( ActorPtr pActor );
|
||||||
|
|
||||||
bool hateListHasActor( ActorPtr pActor );
|
bool hateListHasActor( ActorPtr pActor );
|
||||||
|
|
||||||
void resetPos();
|
void resetPos();
|
||||||
|
|
||||||
uint32_t getNameId() const;
|
uint32_t getNameId() const;
|
||||||
|
|
||||||
void hateListClear();
|
void hateListClear();
|
||||||
|
|
||||||
ActorPtr hateListGetHighest();
|
ActorPtr hateListGetHighest();
|
||||||
|
|
||||||
void aggro( ActorPtr pActor );
|
void aggro( ActorPtr pActor );
|
||||||
|
|
||||||
void deaggro( ActorPtr pActor );
|
void deaggro( ActorPtr pActor );
|
||||||
|
|
||||||
void setOwner( PlayerPtr pPlayer );
|
void setOwner( PlayerPtr pPlayer );
|
||||||
|
|
||||||
void onDeath() override;
|
void onDeath() override;
|
||||||
|
|
||||||
void onActionHostile( ActorPtr pSource ) override;
|
void onActionHostile( ActorPtr pSource ) override;
|
||||||
|
|
||||||
ActorPtr getClaimer() const;
|
ActorPtr getClaimer() const;
|
||||||
|
|
||||||
void sendPositionUpdate();
|
void sendPositionUpdate();
|
||||||
|
|
||||||
// return true if it reached the position
|
// return true if it reached the position
|
||||||
bool moveTo( Common::FFXIVARR_POSITION3& pos );
|
bool moveTo( Common::FFXIVARR_POSITION3& pos );
|
||||||
|
|
||||||
void update( int64_t currTime ) override;
|
void update( int64_t currTime ) override;
|
||||||
|
|
||||||
uint32_t getTimeOfDeath() const;
|
uint32_t getTimeOfDeath() const;
|
||||||
|
|
||||||
void setTimeOfDeath( uint32_t tod );
|
void setTimeOfDeath( uint32_t tod );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static uint32_t m_nextID;
|
||||||
|
StateMode m_mode;
|
||||||
|
Common::FFXIVARR_POSITION3 m_posOrigin;
|
||||||
|
uint8_t m_level;
|
||||||
|
uint16_t m_modelId;
|
||||||
|
uint16_t m_nameId;
|
||||||
|
uint16_t m_bnpcBaseId;
|
||||||
|
uint8_t m_behavior;
|
||||||
|
uint32_t m_unk1;
|
||||||
|
uint32_t m_unk2;
|
||||||
|
std::set< HateListEntry* > m_hateList;
|
||||||
|
ActorPtr m_pOwner;
|
||||||
|
uint32_t m_timeOfDeath;
|
||||||
|
uint32_t m_mobType;
|
||||||
|
};
|
||||||
|
|
||||||
static uint32_t m_nextID;
|
} // namespace Entity
|
||||||
StateMode m_mode;
|
} // namespace Core
|
||||||
Common::FFXIVARR_POSITION3 m_posOrigin;
|
|
||||||
uint8_t m_level;
|
|
||||||
uint16_t m_modelId;
|
|
||||||
uint16_t m_nameId;
|
|
||||||
uint16_t m_bnpcBaseId;
|
|
||||||
uint8_t m_behavior;
|
|
||||||
uint32_t m_unk1;
|
|
||||||
uint32_t m_unk2;
|
|
||||||
std::set< HateListEntry* > m_hateList;
|
|
||||||
ActorPtr m_pOwner;
|
|
||||||
uint32_t m_timeOfDeath;
|
|
||||||
uint32_t m_mobType;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
|
@ -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;
|
||||||
|
@ -54,24 +54,24 @@ using namespace Core::Network::Packets::Server;
|
||||||
|
|
||||||
// player constructor
|
// player constructor
|
||||||
Core::Entity::Player::Player() :
|
Core::Entity::Player::Player() :
|
||||||
Actor(),
|
Actor(),
|
||||||
m_lastWrite( 0 ),
|
m_lastWrite( 0 ),
|
||||||
m_lastPing( 0 ),
|
m_lastPing( 0 ),
|
||||||
m_bIsLogin( false ),
|
m_bIsLogin( false ),
|
||||||
m_contentId( 0 ),
|
m_contentId( 0 ),
|
||||||
m_modelMainWeapon( 0 ),
|
m_modelMainWeapon( 0 ),
|
||||||
m_modelSubWeapon( 0 ),
|
m_modelSubWeapon( 0 ),
|
||||||
m_homePoint( 0 ),
|
m_homePoint( 0 ),
|
||||||
m_startTown( 0 ),
|
m_startTown( 0 ),
|
||||||
m_townWarpFstFlags( 0 ),
|
m_townWarpFstFlags( 0 ),
|
||||||
m_playTime( 0 ),
|
m_playTime( 0 ),
|
||||||
m_bInCombat( false ),
|
m_bInCombat( false ),
|
||||||
m_bLoadingComplete( false ),
|
m_bLoadingComplete( false ),
|
||||||
m_bMarkedForZoning( false ),
|
m_bMarkedForZoning( false ),
|
||||||
m_zoningType( Common::ZoneingType::None ),
|
m_zoningType( Common::ZoneingType::None ),
|
||||||
m_bAutoattack( false ),
|
m_bAutoattack( false ),
|
||||||
m_markedForRemoval( false ),
|
m_markedForRemoval( false ),
|
||||||
m_mount( 0 )
|
m_mount( 0 )
|
||||||
{
|
{
|
||||||
m_id = 0;
|
m_id = 0;
|
||||||
m_objKind = ObjKind::Player;
|
m_objKind = ObjKind::Player;
|
||||||
|
@ -157,7 +157,7 @@ Core::Common::OnlineStatus Core::Entity::Player::getOnlineStatus()
|
||||||
|
|
||||||
OnlineStatus status = OnlineStatus::Online;
|
OnlineStatus status = OnlineStatus::Online;
|
||||||
|
|
||||||
//if( hasStateFlag( Common::PlayerStateFlag::NewAdventurer ) )
|
// if( hasStateFlag( Common::PlayerStateFlag::NewAdventurer ) )
|
||||||
if( m_onlineStatus & newMask )
|
if( m_onlineStatus & newMask )
|
||||||
status = OnlineStatus::NewAdventurer;
|
status = OnlineStatus::NewAdventurer;
|
||||||
|
|
||||||
|
@ -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,20 +228,26 @@ 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;
|
||||||
m_baseStats.accuracy = paramGrowthInfo.base_secondary;
|
m_baseStats.accuracy = paramGrowthInfo.base_secondary;
|
||||||
m_baseStats.critHitRate = paramGrowthInfo.base_secondary;
|
m_baseStats.critHitRate = paramGrowthInfo.base_secondary;
|
||||||
m_baseStats.attackPotMagic = paramGrowthInfo.base_secondary;
|
m_baseStats.attackPotMagic = paramGrowthInfo.base_secondary;
|
||||||
m_baseStats.healingPotMagic = paramGrowthInfo.base_secondary;
|
m_baseStats.healingPotMagic = paramGrowthInfo.base_secondary;
|
||||||
m_baseStats.tenacity = paramGrowthInfo.base_secondary;
|
m_baseStats.tenacity = paramGrowthInfo.base_secondary;
|
||||||
|
|
||||||
m_baseStats.max_mp = Math::CalcStats::calculateMaxMp( getAsPlayer() );
|
m_baseStats.max_mp = Math::CalcStats::calculateMaxMp( getAsPlayer() );
|
||||||
|
|
||||||
|
@ -253,13 +259,10 @@ 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;
|
||||||
m_lastAttack = Util::getTimeMs();
|
m_lastAttack = Util::getTimeMs();
|
||||||
|
@ -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,14 +352,12 @@ void Core::Entity::Player::teleport( uint16_t aetheryteId, uint8_t type )
|
||||||
}
|
}
|
||||||
|
|
||||||
m_queuedZoneing = boost::make_shared< QueuedZoning >( data->target_zone, pos, Util::getTimeMs(), rot );
|
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 )
|
||||||
{
|
{
|
||||||
m_queuedZoneing = boost::make_shared< QueuedZoning >( zoneId, getPos(), Util::getTimeMs(), 0.f );
|
m_queuedZoneing = boost::make_shared< QueuedZoning >( zoneId, getPos(), Util::getTimeMs(), 0.f );
|
||||||
//performZoning( zoneId, Common::ZoneingType::None, getPos() );
|
// performZoning( zoneId, Common::ZoneingType::None, getPos() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Entity::Player::returnToHomepoint()
|
void Core::Entity::Player::returnToHomepoint()
|
||||||
|
@ -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." );
|
||||||
|
@ -397,7 +397,7 @@ void Core::Entity::Player::setZone( uint32_t zoneId )
|
||||||
|
|
||||||
if( isLogin() )
|
if( isLogin() )
|
||||||
{
|
{
|
||||||
queuePacket(ActorControlPacket143( getId(), SetCharaGearParamUI, m_equipDisplayFlags, 1 ) );
|
queuePacket( ActorControlPacket143( getId(), SetCharaGearParamUI, m_equipDisplayFlags, 1 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// set flags, will be reset automatically by zoning ( only on client side though )
|
// set flags, will be reset automatically by zoning ( only on client side though )
|
||||||
|
@ -517,7 +517,6 @@ void Core::Entity::Player::registerAetheryte( uint8_t aetheryteId )
|
||||||
|
|
||||||
m_aetheryte[index] |= value;
|
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
|
||||||
|
@ -529,7 +528,7 @@ bool Core::Entity::Player::isAetheryteRegistered( uint8_t aetheryteId ) const
|
||||||
return ( m_aetheryte[index] & value ) != 0;
|
return ( m_aetheryte[index] & value ) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t * Core::Entity::Player::getDiscoveryBitmask()
|
uint8_t* Core::Entity::Player::getDiscoveryBitmask()
|
||||||
{
|
{
|
||||||
return m_discovery;
|
return m_discovery;
|
||||||
}
|
}
|
||||||
|
@ -561,9 +560,6 @@ void Core::Entity::Player::discover( int16_t map_id, int16_t sub_id )
|
||||||
uint32_t exp = ( g_exdData.m_paramGrowthInfoMap[level].needed_exp * 5 / 100 );
|
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
|
||||||
|
@ -573,11 +569,11 @@ bool Core::Entity::Player::isNewAdventurer() const
|
||||||
|
|
||||||
void Core::Entity::Player::setNewAdventurer( bool state )
|
void Core::Entity::Player::setNewAdventurer( bool state )
|
||||||
{
|
{
|
||||||
//if( !state )
|
// if( !state )
|
||||||
//{
|
//{
|
||||||
// unsetStateFlag( PlayerStateFlag::NewAdventurer );
|
// unsetStateFlag( PlayerStateFlag::NewAdventurer );
|
||||||
//}
|
//}
|
||||||
//else
|
// else
|
||||||
//{
|
//{
|
||||||
// setStateFlag( PlayerStateFlag::NewAdventurer );
|
// setStateFlag( PlayerStateFlag::NewAdventurer );
|
||||||
//}
|
//}
|
||||||
|
@ -596,7 +592,7 @@ void Core::Entity::Player::changePosition( float x, float y, float z, float o )
|
||||||
pos.x = x;
|
pos.x = x;
|
||||||
pos.y = y;
|
pos.y = y;
|
||||||
pos.z = z;
|
pos.z = z;
|
||||||
m_queuedZoneing = boost::make_shared<QueuedZoning>( getZoneId(), pos, Util::getTimeMs(), o );
|
m_queuedZoneing = boost::make_shared< QueuedZoning >( getZoneId(), pos, Util::getTimeMs(), o );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Entity::Player::learnAction( uint8_t actionId )
|
void Core::Entity::Player::learnAction( uint8_t actionId )
|
||||||
|
@ -652,16 +648,16 @@ void Core::Entity::Player::gainExp( uint32_t amount )
|
||||||
{
|
{
|
||||||
// levelup
|
// levelup
|
||||||
amount = ( currentExp + amount - neededExpToLevel ) > neededExpToLevelplus1 ?
|
amount = ( currentExp + amount - neededExpToLevel ) > neededExpToLevelplus1 ?
|
||||||
neededExpToLevelplus1 - 1 :
|
neededExpToLevelplus1 - 1 :
|
||||||
( currentExp + amount - neededExpToLevel );
|
( currentExp + amount - neededExpToLevel );
|
||||||
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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -680,8 +676,8 @@ void Core::Entity::Player::gainLevel()
|
||||||
m_mp = getMaxMp();
|
m_mp = getMaxMp();
|
||||||
|
|
||||||
ZoneChannelPacket< FFXIVIpcStatusEffectList > effectListPacket( getId() );
|
ZoneChannelPacket< FFXIVIpcStatusEffectList > effectListPacket( getId() );
|
||||||
effectListPacket.data().classId = static_cast< uint8_t > ( getClass() );
|
effectListPacket.data().classId = static_cast< uint8_t >( getClass() );
|
||||||
effectListPacket.data().classId1 = static_cast< uint8_t > ( getClass() );
|
effectListPacket.data().classId1 = static_cast< uint8_t >( getClass() );
|
||||||
effectListPacket.data().level = getLevel();
|
effectListPacket.data().level = getLevel();
|
||||||
effectListPacket.data().current_hp = getMaxHp();
|
effectListPacket.data().current_hp = getMaxHp();
|
||||||
effectListPacket.data().current_mp = getMaxMp();
|
effectListPacket.data().current_mp = getMaxMp();
|
||||||
|
@ -690,18 +686,17 @@ 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() );
|
||||||
classInfoPacket.data().classId1 = static_cast< uint8_t > ( getClass() );
|
classInfoPacket.data().classId1 = static_cast< uint8_t >( getClass() );
|
||||||
classInfoPacket.data().level = getLevel();
|
classInfoPacket.data().level = getLevel();
|
||||||
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()
|
||||||
|
@ -713,7 +708,7 @@ void Core::Entity::Player::sendStatusUpdate( bool toSelf )
|
||||||
{
|
{
|
||||||
// CGamePacket* pPE = new CGamePacket(0x140, 0x0128, getId(), getId());
|
// CGamePacket* pPE = new CGamePacket(0x140, 0x0128, getId(), getId());
|
||||||
|
|
||||||
//pPE->setInt8At(0x20, static_cast<uint8_t>(getClass()));
|
// pPE->setInt8At(0x20, static_cast<uint8_t>(getClass()));
|
||||||
|
|
||||||
// pPE->setInt8At(0x21, getLevel());
|
// pPE->setInt8At(0x21, getLevel());
|
||||||
// pPE->setInt8At(0x22, getLevel());
|
// pPE->setInt8At(0x22, getLevel());
|
||||||
|
@ -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
|
||||||
|
@ -767,7 +761,7 @@ bool Core::Entity::Player::isInCombat() const
|
||||||
|
|
||||||
void Core::Entity::Player::setInCombat( bool mode )
|
void Core::Entity::Player::setInCombat( bool mode )
|
||||||
{
|
{
|
||||||
//m_lastAttack = GetTickCount();
|
// m_lastAttack = GetTickCount();
|
||||||
m_bInCombat = mode;
|
m_bInCombat = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -796,14 +790,15 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Entity::Player::setLevelForClass( uint8_t level, Common::ClassJob classjob )
|
void Core::Entity::Player::setLevelForClass( uint8_t level, Common::ClassJob classjob )
|
||||||
{
|
{
|
||||||
uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( classjob )].exp_idx;
|
uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( classjob )].exp_idx;
|
||||||
m_classArray[classJobIndex] = level;
|
m_classArray[classJobIndex] = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Entity::Player::sendModel()
|
void Core::Entity::Player::sendModel()
|
||||||
|
@ -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 );
|
||||||
|
@ -946,14 +939,13 @@ const uint8_t* Core::Entity::Player::getStateFlags() const
|
||||||
return m_stateFlags;
|
return m_stateFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Core::Entity::Player::actionHasCastTime( uint32_t actionId ) //TODO: Add logic for special cases
|
bool Core::Entity::Player::actionHasCastTime( uint32_t actionId ) // TODO: Add logic for special cases
|
||||||
{
|
{
|
||||||
auto actionInfoPtr = g_exdData.getActionInfo( actionId );
|
auto actionInfoPtr = g_exdData.getActionInfo( actionId );
|
||||||
if( actionInfoPtr->is_instant )
|
if( actionInfoPtr->is_instant )
|
||||||
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 )
|
||||||
|
@ -1022,7 +1012,7 @@ void Core::Entity::Player::update( int64_t currTime )
|
||||||
Common::FFXIVARR_POSITION3 targetPos = m_queuedZoneing->m_targetPosition;
|
Common::FFXIVARR_POSITION3 targetPos = m_queuedZoneing->m_targetPosition;
|
||||||
if( getCurrentZone()->getId() != m_queuedZoneing->m_targetZone )
|
if( getCurrentZone()->getId() != m_queuedZoneing->m_targetZone )
|
||||||
{
|
{
|
||||||
performZoning( m_queuedZoneing->m_targetZone, targetPos, m_queuedZoneing->m_targetRotation);
|
performZoning( m_queuedZoneing->m_targetZone, targetPos, m_queuedZoneing->m_targetRotation );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -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,10 +1098,9 @@ 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()
|
||||||
{
|
{
|
||||||
return m_aetheryte;
|
return m_aetheryte;
|
||||||
}
|
}
|
||||||
|
@ -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 )
|
||||||
|
@ -1245,7 +1230,7 @@ void Core::Entity::Player::setLoadingComplete( bool bComplete )
|
||||||
m_bLoadingComplete = bComplete;
|
m_bLoadingComplete = bComplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Entity::Player::performZoning( uint16_t zoneId, const Common::FFXIVARR_POSITION3 &pos, float rotation )
|
void Core::Entity::Player::performZoning( uint16_t zoneId, const Common::FFXIVARR_POSITION3& pos, float rotation )
|
||||||
{
|
{
|
||||||
m_pos = pos;
|
m_pos = pos;
|
||||||
m_zoneId = zoneId;
|
m_zoneId = zoneId;
|
||||||
|
@ -1292,17 +1277,17 @@ uint8_t Core::Entity::Player::getSearchSelectClass() const
|
||||||
return m_searchSelectClass;
|
return m_searchSelectClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Entity::Player::sendNotice( const std::string& message ) //Purple Text
|
void Core::Entity::Player::sendNotice( const std::string& message ) // Purple Text
|
||||||
{
|
{
|
||||||
queuePacket( ServerNoticePacket( getId(), message ) );
|
queuePacket( ServerNoticePacket( getId(), message ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Entity::Player::sendUrgent( const std::string& message ) //Red Text
|
void Core::Entity::Player::sendUrgent( const std::string& message ) // Red Text
|
||||||
{
|
{
|
||||||
queuePacket( ChatPacket( *getAsPlayer(), ChatType::ServerUrgent, message ) );
|
queuePacket( ChatPacket( *getAsPlayer(), ChatType::ServerUrgent, message ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Entity::Player::sendDebug( const std::string& message ) //Grey Text
|
void Core::Entity::Player::sendDebug( const std::string& message ) // Grey Text
|
||||||
{
|
{
|
||||||
queuePacket( ChatPacket( *getAsPlayer(), ChatType::ServerDebug, message ) );
|
queuePacket( ChatPacket( *getAsPlayer(), ChatType::ServerDebug, message ) );
|
||||||
}
|
}
|
||||||
|
@ -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 )
|
||||||
|
@ -1430,7 +1413,7 @@ void Core::Entity::Player::setTitle( uint16_t titleId )
|
||||||
uint8_t value;
|
uint8_t value;
|
||||||
Util::valueToFlagByteIndexValue( titleId, value, index );
|
Util::valueToFlagByteIndexValue( titleId, value, index );
|
||||||
|
|
||||||
if ( ( m_titleList[index] & value ) == 0 ) // Player doesn't have title - bail
|
if( ( m_titleList[index] & value ) == 0 ) // Player doesn't have title - bail
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_activeTitle = titleId;
|
m_activeTitle = titleId;
|
||||||
|
@ -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,29 +1464,26 @@ 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();
|
||||||
//srand(static_cast< uint32_t >(tick));
|
// srand(static_cast< uint32_t >(tick));
|
||||||
|
|
||||||
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();
|
||||||
effectPacket.data().actionAnimationId = 8;
|
effectPacket.data().actionAnimationId = 8;
|
||||||
// effectPacket.data().unknown_2 = variation;
|
// effectPacket.data().unknown_2 = variation;
|
||||||
effectPacket.data().numEffects = 1;
|
effectPacket.data().numEffects = 1;
|
||||||
effectPacket.data().unknown_61 = 1;
|
effectPacket.data().unknown_61 = 1;
|
||||||
effectPacket.data().unknown_62 = 1;
|
effectPacket.data().unknown_62 = 1;
|
||||||
effectPacket.data().actionTextId = 8;
|
effectPacket.data().actionTextId = 8;
|
||||||
effectPacket.data().rotation = Math::Util::floatToUInt16Rot(getRotation());
|
effectPacket.data().rotation = Math::Util::floatToUInt16Rot( getRotation() );
|
||||||
effectPacket.data().effectTargetId = pTarget->getId();
|
effectPacket.data().effectTargetId = pTarget->getId();
|
||||||
effectPacket.data().effectTarget = pTarget->getId();
|
effectPacket.data().effectTarget = pTarget->getId();
|
||||||
effectPacket.data().effects[0].value = damage;
|
effectPacket.data().effects[0].value = damage;
|
||||||
|
@ -1508,12 +1491,12 @@ void Core::Entity::Player::autoAttack( ActorPtr pTarget )
|
||||||
effectPacket.data().effects[0].hitSeverity = Common::ActionHitSeverityType::NormalDamage;
|
effectPacket.data().effects[0].hitSeverity = Common::ActionHitSeverityType::NormalDamage;
|
||||||
effectPacket.data().effects[0].unknown_3 = 7;
|
effectPacket.data().effects[0].unknown_3 = 7;
|
||||||
|
|
||||||
sendToInRangeSet(effectPacket, true);
|
sendToInRangeSet( effectPacket, true );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
ZoneChannelPacket< FFXIVIpcEffect > effectPacket(getId());
|
ZoneChannelPacket< FFXIVIpcEffect > effectPacket( getId() );
|
||||||
effectPacket.data().targetId = pTarget->getId();
|
effectPacket.data().targetId = pTarget->getId();
|
||||||
effectPacket.data().actionAnimationId = 7;
|
effectPacket.data().actionAnimationId = 7;
|
||||||
// effectPacket.data().unknown_2 = variation;
|
// effectPacket.data().unknown_2 = variation;
|
||||||
|
@ -1521,21 +1504,19 @@ void Core::Entity::Player::autoAttack( ActorPtr pTarget )
|
||||||
effectPacket.data().unknown_61 = 1;
|
effectPacket.data().unknown_61 = 1;
|
||||||
effectPacket.data().unknown_62 = 1;
|
effectPacket.data().unknown_62 = 1;
|
||||||
effectPacket.data().actionTextId = 7;
|
effectPacket.data().actionTextId = 7;
|
||||||
effectPacket.data().rotation = Math::Util::floatToUInt16Rot(getRotation());
|
effectPacket.data().rotation = Math::Util::floatToUInt16Rot( getRotation() );
|
||||||
effectPacket.data().effectTarget = pTarget->getId();
|
effectPacket.data().effectTarget = pTarget->getId();
|
||||||
effectPacket.data().effects[0].value = damage;
|
effectPacket.data().effects[0].value = damage;
|
||||||
effectPacket.data().effects[0].effectType = Common::ActionEffectType::Damage;
|
effectPacket.data().effects[0].effectType = Common::ActionEffectType::Damage;
|
||||||
effectPacket.data().effects[0].hitSeverity = Common::ActionHitSeverityType::NormalDamage;
|
effectPacket.data().effects[0].hitSeverity = Common::ActionHitSeverityType::NormalDamage;
|
||||||
effectPacket.data().effects[0].unknown_3 = 71;
|
effectPacket.data().effects[0].unknown_3 = 71;
|
||||||
|
|
||||||
sendToInRangeSet(effectPacket, true);
|
sendToInRangeSet( effectPacket, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
pTarget->takeDamage(damage);
|
pTarget->takeDamage( damage );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// Content Finder
|
// Content Finder
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
|
@ -1559,7 +1540,7 @@ uint32_t Core::Entity::Player::getCFPenaltyMinutes() const
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
auto deltaTime = endTimestamp - currentTimestamp;
|
auto deltaTime = endTimestamp - currentTimestamp;
|
||||||
return static_cast< uint32_t > ( ceil( static_cast< float > (deltaTime) / 60 ) );
|
return static_cast< uint32_t >( ceil( static_cast< float >( deltaTime ) / 60 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Entity::Player::setCFPenaltyMinutes( uint32_t minutes )
|
void Core::Entity::Player::setCFPenaltyMinutes( uint32_t minutes )
|
||||||
|
@ -1587,7 +1568,7 @@ uint16_t Core::Entity::Player::getItemLevel() const
|
||||||
void Core::Entity::Player::setEorzeaTimeOffset( uint64_t timestamp )
|
void Core::Entity::Player::setEorzeaTimeOffset( uint64_t timestamp )
|
||||||
{
|
{
|
||||||
// TODO: maybe change to persistent?
|
// TODO: maybe change to persistent?
|
||||||
ZoneChannelPacket< FFXIVIpcEorzeaTimeOffset > packet ( getId() );
|
ZoneChannelPacket< FFXIVIpcEorzeaTimeOffset > packet( getId() );
|
||||||
packet.data().timestamp = timestamp;
|
packet.data().timestamp = timestamp;
|
||||||
|
|
||||||
// Send to single player
|
// Send to single player
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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()
|
||||||
{
|
{
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -89,7 +81,7 @@ void Core::Entity::Player::equipWeapon( ItemPtr pItem )
|
||||||
void Core::Entity::Player::equipItem( Inventory::EquipSlot equipSlotId, ItemPtr pItem, bool sendUpdate )
|
void Core::Entity::Player::equipItem( Inventory::EquipSlot equipSlotId, ItemPtr pItem, bool sendUpdate )
|
||||||
{
|
{
|
||||||
|
|
||||||
//g_log.debug( "Equipping into slot " + std::to_string( equipSlotId ) );
|
// g_log.debug( "Equipping into slot " + std::to_string( equipSlotId ) );
|
||||||
|
|
||||||
uint64_t model = pItem->getModelId1();
|
uint64_t model = pItem->getModelId1();
|
||||||
uint64_t model2 = pItem->getModelId2();
|
uint64_t model2 = pItem->getModelId2();
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 )
|
||||||
|
@ -408,7 +406,7 @@ uint16_t Core::Entity::Player::getQuestUI16A( uint16_t questId )
|
||||||
if( idx != -1 )
|
if( idx != -1 )
|
||||||
{
|
{
|
||||||
boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[idx];
|
boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[idx];
|
||||||
// value = pNewQuest->d.UI16A;
|
// value = pNewQuest->d.UI16A;
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
@ -421,7 +419,7 @@ uint16_t Core::Entity::Player::getQuestUI16B( uint16_t questId )
|
||||||
if( idx != -1 )
|
if( idx != -1 )
|
||||||
{
|
{
|
||||||
boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[idx];
|
boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[idx];
|
||||||
// value = pNewQuest->d.UI16B;
|
// value = pNewQuest->d.UI16B;
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
@ -434,7 +432,7 @@ uint16_t Core::Entity::Player::getQuestUI16C( uint16_t questId )
|
||||||
if( idx != -1 )
|
if( idx != -1 )
|
||||||
{
|
{
|
||||||
boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[idx];
|
boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[idx];
|
||||||
// value = pNewQuest->d.UI16C;
|
// value = pNewQuest->d.UI16C;
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
@ -447,7 +445,7 @@ uint32_t Core::Entity::Player::getQuestUI32A( uint16_t questId )
|
||||||
if( idx != -1 )
|
if( idx != -1 )
|
||||||
{
|
{
|
||||||
boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[idx];
|
boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[idx];
|
||||||
// value = pNewQuest->e.UI32A;
|
// value = pNewQuest->e.UI32A;
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
@ -713,7 +711,7 @@ void Core::Entity::Player::setQuestUI16A( uint16_t questId, uint16_t val )
|
||||||
{
|
{
|
||||||
boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[idx];
|
boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[idx];
|
||||||
|
|
||||||
// pNewQuest->d.UI16A = val;
|
// pNewQuest->d.UI16A = val;
|
||||||
|
|
||||||
updateQuest( questId, pNewQuest->c.sequence );
|
updateQuest( questId, pNewQuest->c.sequence );
|
||||||
}
|
}
|
||||||
|
@ -728,7 +726,7 @@ void Core::Entity::Player::setQuestUI16B( uint16_t questId, uint16_t val )
|
||||||
{
|
{
|
||||||
boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[idx];
|
boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[idx];
|
||||||
|
|
||||||
// pNewQuest->d.UI16B = val;
|
// pNewQuest->d.UI16B = val;
|
||||||
|
|
||||||
updateQuest( questId, pNewQuest->c.sequence );
|
updateQuest( questId, pNewQuest->c.sequence );
|
||||||
}
|
}
|
||||||
|
@ -742,7 +740,7 @@ void Core::Entity::Player::setQuestUI16C( uint16_t questId, uint16_t val )
|
||||||
{
|
{
|
||||||
boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[idx];
|
boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[idx];
|
||||||
|
|
||||||
// pNewQuest->d.UI16C = val;
|
// pNewQuest->d.UI16C = val;
|
||||||
|
|
||||||
updateQuest( questId, pNewQuest->c.sequence );
|
updateQuest( questId, pNewQuest->c.sequence );
|
||||||
}
|
}
|
||||||
|
@ -756,7 +754,7 @@ void Core::Entity::Player::setQuestUI32A( uint16_t questId, uint32_t val )
|
||||||
{
|
{
|
||||||
boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[idx];
|
boost::shared_ptr< QuestActive > pNewQuest = m_activeQuests[idx];
|
||||||
|
|
||||||
// pNewQuest->e.UI32A = val;
|
// pNewQuest->e.UI32A = val;
|
||||||
|
|
||||||
updateQuest( questId, pNewQuest->c.sequence );
|
updateQuest( questId, pNewQuest->c.sequence );
|
||||||
}
|
}
|
||||||
|
@ -845,8 +843,6 @@ void Core::Entity::Player::setQuestBitFlag48( uint16_t questId, uint8_t val )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t Core::Entity::Player::getQuestSeq( uint16_t questId )
|
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();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -934,7 +928,7 @@ void Core::Entity::Player::setQuestTracker( uint16_t index, int16_t flag )
|
||||||
{
|
{
|
||||||
if( flag == 0 )
|
if( flag == 0 )
|
||||||
{
|
{
|
||||||
//remove
|
// remove
|
||||||
for( uint8_t ii = 0; ii < 5; ii++ )
|
for( uint8_t ii = 0; ii < 5; ii++ )
|
||||||
{
|
{
|
||||||
if( m_questTracking[ii] == index )
|
if( m_questTracking[ii] == index )
|
||||||
|
@ -946,7 +940,7 @@ void Core::Entity::Player::setQuestTracker( uint16_t index, int16_t flag )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//add
|
// add
|
||||||
for( uint8_t ii = 0; ii < 5; ii++ )
|
for( uint8_t ii = 0; ii < 5; ii++ )
|
||||||
{
|
{
|
||||||
if( m_questTracking[ii] == -1 )
|
if( m_questTracking[ii] == -1 )
|
||||||
|
@ -956,10 +950,8 @@ void Core::Entity::Player::setQuestTracker( uint16_t index, int16_t flag )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Core::Entity::Player::sendQuestInfo()
|
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;
|
||||||
|
@ -1060,8 +1050,7 @@ bool Core::Entity::Player::giveQuestRewards( uint32_t questId, uint32_t optional
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<QuestActive> Core::Entity::Player::getQuestActive( uint16_t index )
|
boost::shared_ptr< QuestActive > Core::Entity::Player::getQuestActive( uint16_t index )
|
||||||
{
|
{
|
||||||
return m_activeQuests[index];
|
return m_activeQuests[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -183,7 +180,7 @@ bool Core::Entity::Player::load( uint32_t charId, SessionPtr pSession )
|
||||||
// first login, run the script event
|
// first login, run the script event
|
||||||
if( m_bNewGame )
|
if( m_bNewGame )
|
||||||
{
|
{
|
||||||
//g_scriptMgr.onPlayerFirstEnterWorld( pPlayer );
|
// g_scriptMgr.onPlayerFirstEnterWorld( pPlayer );
|
||||||
m_bNewGame = false;
|
m_bNewGame = false;
|
||||||
m_hp = getMaxHp();
|
m_hp = getMaxHp();
|
||||||
m_mp = getMaxMp();
|
m_mp = getMaxMp();
|
||||||
|
@ -198,8 +195,8 @@ bool Core::Entity::Player::load( uint32_t charId, SessionPtr pSession )
|
||||||
if( m_hp == 0 )
|
if( m_hp == 0 )
|
||||||
m_status = ActorStatus::Dead;
|
m_status = ActorStatus::Dead;
|
||||||
|
|
||||||
// if( m_bNewAdventurer )
|
// if( m_bNewAdventurer )
|
||||||
// setStateFlag( PlayerStateFlag::NewAdventurer );
|
// setStateFlag( PlayerStateFlag::NewAdventurer );
|
||||||
|
|
||||||
setStateFlag( PlayerStateFlag::BetweenAreas );
|
setStateFlag( PlayerStateFlag::BetweenAreas );
|
||||||
|
|
||||||
|
@ -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,29 +282,28 @@ bool Core::Entity::Player::loadSearchInfo()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Core::Entity::Player::updateSql()
|
void Core::Entity::Player::updateSql()
|
||||||
{
|
{
|
||||||
|
|
||||||
/*"Hp 1, Mp 2, Tp 3, Gp 4, Mode 5, Mount 6, InvincibleGM 7, Voice 8, "
|
/*"Hp 1, Mp 2, Tp 3, Gp 4, Mode 5, Mount 6, InvincibleGM 7, Voice 8, "
|
||||||
"Customize 9, ModelMainWeapon 10, ModelSubWeapon 11, ModelSystemWeapon 12, "
|
"Customize 9, ModelMainWeapon 10, ModelSubWeapon 11, ModelSystemWeapon 12, "
|
||||||
"ModelEquip 13, EmoteModeType 14, Language 15, IsNewGame 16, IsNewAdventurer 17, "
|
"ModelEquip 13, EmoteModeType 14, Language 15, IsNewGame 16, IsNewAdventurer 17, "
|
||||||
"TerritoryType 18, TerritoryId 19, PosX 20, PosY 21, PosZ 22, PosR 23, "
|
"TerritoryType 18, TerritoryId 19, PosX 20, PosY 21, PosZ 22, PosR 23, "
|
||||||
"OTerritoryType 24, OTerritoryId 25, OPosX 26, OPosY 27, OPosZ 28, OPosR 29, "
|
"OTerritoryType 24, OTerritoryId 25, OPosX 26, OPosY 27, OPosZ 28, OPosR 29, "
|
||||||
"Class 30, Status 31, TotalPlayTime 32, HomePoint 33, FavoritePoint 34, RestPoint 35, "
|
"Class 30, Status 31, TotalPlayTime 32, HomePoint 33, FavoritePoint 34, RestPoint 35, "
|
||||||
"ActiveTitle 36, TitleList 37, Achievement 38, Aetheryte 39, HowTo 40, Minions 41, Mounts 42, Orchestrion 43, "
|
"ActiveTitle 36, TitleList 37, Achievement 38, Aetheryte 39, HowTo 40, Minions 41, Mounts 42, Orchestrion 43, "
|
||||||
"EquippedMannequin 44, ConfigFlags 45, QuestCompleteFlags 46, OpeningSequence 47, "
|
"EquippedMannequin 44, ConfigFlags 45, QuestCompleteFlags 46, OpeningSequence 47, "
|
||||||
"QuestTracking 48, GrandCompany 49, GrandCompanyRank 50, Discovery 51, GMRank 52, Unlocks 53, "
|
"QuestTracking 48, GrandCompany 49, GrandCompanyRank 50, Discovery 51, GMRank 52, Unlocks 53, "
|
||||||
"CFPenaltyUntil 54"*/
|
"CFPenaltyUntil 54"*/
|
||||||
auto stmt = g_charaDb.getPreparedStatement( Db::CharaDbStatements::CHARA_UP );
|
auto stmt = g_charaDb.getPreparedStatement( Db::CharaDbStatements::CHARA_UP );
|
||||||
|
|
||||||
stmt->setInt( 1, getHp() );
|
stmt->setInt( 1, getHp() );
|
||||||
stmt->setInt( 2, getMp() );
|
stmt->setInt( 2, getMp() );
|
||||||
stmt->setInt( 3, 0 ); // TP
|
stmt->setInt( 3, 0 ); // TP
|
||||||
stmt->setInt( 4, 0 ); // GP
|
stmt->setInt( 4, 0 ); // GP
|
||||||
stmt->setInt( 5, 0 ); // Mode
|
stmt->setInt( 5, 0 ); // Mode
|
||||||
stmt->setInt( 6, m_mount ); // Mount
|
stmt->setInt( 6, m_mount ); // Mount
|
||||||
stmt->setInt( 7, 0 ); // InvicibleGM
|
stmt->setInt( 7, 0 ); // InvicibleGM
|
||||||
stmt->setInt( 8, m_voice );
|
stmt->setInt( 8, m_voice );
|
||||||
|
|
||||||
std::vector< uint8_t > customVec( sizeof( m_customize ) );
|
std::vector< uint8_t > customVec( sizeof( m_customize ) );
|
||||||
|
@ -331,7 +324,7 @@ void Core::Entity::Player::updateSql()
|
||||||
stmt->setInt( 16, static_cast< uint32_t >( m_bNewGame ) );
|
stmt->setInt( 16, static_cast< uint32_t >( m_bNewGame ) );
|
||||||
stmt->setInt( 17, static_cast< uint32_t >( m_bNewAdventurer ) );
|
stmt->setInt( 17, static_cast< uint32_t >( m_bNewAdventurer ) );
|
||||||
|
|
||||||
stmt->setInt( 18, 0 ); // TerritoryType
|
stmt->setInt( 18, 0 ); // TerritoryType
|
||||||
stmt->setInt( 19, m_zoneId ); // TerritoryId
|
stmt->setInt( 19, m_zoneId ); // TerritoryId
|
||||||
stmt->setDouble( 20, m_pos.x );
|
stmt->setDouble( 20, m_pos.x );
|
||||||
stmt->setDouble( 21, m_pos.y );
|
stmt->setDouble( 21, m_pos.y );
|
||||||
|
@ -351,10 +344,10 @@ void Core::Entity::Player::updateSql()
|
||||||
stmt->setInt( 33, m_homePoint );
|
stmt->setInt( 33, m_homePoint );
|
||||||
|
|
||||||
stmt->setBinary( 34, { 0, 0, 0 } ); // FavoritePoint
|
stmt->setBinary( 34, { 0, 0, 0 } ); // FavoritePoint
|
||||||
stmt->setInt( 35, 0 ); // RestPoint
|
stmt->setInt( 35, 0 ); // RestPoint
|
||||||
stmt->setInt( 36, 0 ); // ActiveTitle
|
stmt->setInt( 36, 0 ); // ActiveTitle
|
||||||
|
|
||||||
std::vector< uint8_t > titleListVec( sizeof ( m_titleList ) );
|
std::vector< uint8_t > titleListVec( sizeof( m_titleList ) );
|
||||||
stmt->setBinary( 37, titleListVec );
|
stmt->setBinary( 37, titleListVec );
|
||||||
|
|
||||||
std::vector< uint8_t > achievementVec( 16 );
|
std::vector< uint8_t > achievementVec( 16 );
|
||||||
|
@ -421,14 +414,13 @@ void Core::Entity::Player::updateSql()
|
||||||
|
|
||||||
////// Class
|
////// Class
|
||||||
updateDbClass();
|
updateDbClass();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Entity::Player::updateDbClass() const
|
void Core::Entity::Player::updateDbClass() const
|
||||||
{
|
{
|
||||||
uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( getClass() )].exp_idx;
|
uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( getClass() )].exp_idx;
|
||||||
|
|
||||||
//Exp = ?, Lvl = ? WHERE CharacterId = ? AND ClassIdx = ?
|
// Exp = ?, Lvl = ? WHERE CharacterId = ? AND ClassIdx = ?
|
||||||
auto stmtS = g_charaDb.getPreparedStatement( Db::CHARA_CLASS_UP );
|
auto stmtS = g_charaDb.getPreparedStatement( Db::CHARA_CLASS_UP );
|
||||||
stmtS->setInt( 1, getExp() );
|
stmtS->setInt( 1, getExp() );
|
||||||
stmtS->setInt( 2, getLevel() );
|
stmtS->setInt( 2, getLevel() );
|
||||||
|
@ -473,10 +465,9 @@ void Core::Entity::Player::updateDbAllQuests() const
|
||||||
stmtS3->setInt( 7, m_activeQuests[i]->c.UI8E );
|
stmtS3->setInt( 7, m_activeQuests[i]->c.UI8E );
|
||||||
stmtS3->setInt( 8, m_activeQuests[i]->c.UI8F );
|
stmtS3->setInt( 8, m_activeQuests[i]->c.UI8F );
|
||||||
stmtS3->setInt( 9, m_activeQuests[i]->c.padding1 );
|
stmtS3->setInt( 9, m_activeQuests[i]->c.padding1 );
|
||||||
stmtS3->setInt( 10, m_id);
|
stmtS3->setInt( 10, m_id );
|
||||||
stmtS3->setInt( 11, m_activeQuests[i]->c.questId );
|
stmtS3->setInt( 11, m_activeQuests[i]->c.questId );
|
||||||
g_charaDb.execute( stmtS3 );
|
g_charaDb.execute( stmtS3 );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,5 +3,4 @@
|
||||||
|
|
||||||
#include "../Forwards.h"
|
#include "../Forwards.h"
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -8,57 +8,42 @@
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
class DebugCommandHandler;
|
class DebugCommandHandler;
|
||||||
|
|
||||||
class DebugCommand
|
class DebugCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using pFunc = void ( DebugCommandHandler::* )( char*, Entity::Player&, boost::shared_ptr< DebugCommand > );
|
||||||
|
|
||||||
|
// String for the command
|
||||||
|
std::string m_commandName;
|
||||||
|
|
||||||
|
// command callback
|
||||||
|
pFunc m_pFunc;
|
||||||
|
|
||||||
|
// helptext
|
||||||
|
std::string m_helpText;
|
||||||
|
|
||||||
|
// userlevel needed to execute the command
|
||||||
|
uint8_t m_gmLevel;
|
||||||
|
|
||||||
|
DebugCommand( const std::string& n, pFunc functionPtr, const std::string& hText, uint8_t uLevel )
|
||||||
{
|
{
|
||||||
public:
|
m_commandName = n;
|
||||||
|
m_pFunc = functionPtr;
|
||||||
|
m_helpText = hText;
|
||||||
|
m_gmLevel = uLevel;
|
||||||
|
}
|
||||||
|
|
||||||
using pFunc = void ( DebugCommandHandler::* )( char *, Entity::Player&, boost::shared_ptr< DebugCommand > );
|
~DebugCommand() {}
|
||||||
|
|
||||||
// String for the command
|
const std::string& getName() const { return m_commandName; }
|
||||||
std::string m_commandName;
|
|
||||||
|
|
||||||
// command callback
|
const std::string& getHelpText() const { return m_helpText; }
|
||||||
pFunc m_pFunc;
|
|
||||||
|
|
||||||
// helptext
|
uint8_t getRequiredGmLevel() const { return m_gmLevel; }
|
||||||
std::string m_helpText;
|
};
|
||||||
|
|
||||||
// userlevel needed to execute the command
|
|
||||||
uint8_t m_gmLevel;
|
|
||||||
|
|
||||||
DebugCommand( const std::string& n, pFunc functionPtr, const std::string& hText, uint8_t uLevel )
|
|
||||||
{
|
|
||||||
m_commandName = n;
|
|
||||||
m_pFunc = functionPtr;
|
|
||||||
m_helpText = hText;
|
|
||||||
m_gmLevel = uLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
~DebugCommand()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string& getName() const
|
|
||||||
{
|
|
||||||
return m_commandName;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string& getHelpText() const
|
|
||||||
{
|
|
||||||
return m_helpText;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t getRequiredGmLevel() const
|
|
||||||
{
|
|
||||||
return m_gmLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
} // namespace Core
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -70,11 +69,11 @@ void Core::DebugCommandHandler::registerCommand( const std::string& n, DebugComm
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to retrieve the command in question, execute if found
|
// try to retrieve the command in question, execute if found
|
||||||
void Core::DebugCommandHandler::execCommand( char * data, Entity::Player& player )
|
void Core::DebugCommandHandler::execCommand( char* data, Entity::Player& player )
|
||||||
{
|
{
|
||||||
|
|
||||||
// define callback pointer
|
// define callback pointer
|
||||||
void ( DebugCommandHandler::*pf )( char *, Entity::Player&, boost::shared_ptr< DebugCommand > );
|
void ( DebugCommandHandler::*pf )( char*, Entity::Player&, boost::shared_ptr< DebugCommand > );
|
||||||
|
|
||||||
std::string commandString;
|
std::string commandString;
|
||||||
|
|
||||||
|
@ -108,16 +107,13 @@ 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
|
||||||
///////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void Core::DebugCommandHandler::scriptReload( char * data, Entity::Player& player,
|
void Core::DebugCommandHandler::scriptReload( char* data, Entity::Player& player,
|
||||||
boost::shared_ptr< DebugCommand > command )
|
boost::shared_ptr< DebugCommand > command )
|
||||||
{
|
{
|
||||||
g_scriptMgr.reload();
|
g_scriptMgr.reload();
|
||||||
|
@ -127,16 +123,16 @@ void Core::DebugCommandHandler::scriptReload( char * data, Entity::Player& playe
|
||||||
void Core::DebugCommandHandler::help( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
|
void Core::DebugCommandHandler::help( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
|
||||||
{
|
{
|
||||||
player.sendDebug( "Registered debug commands:" );
|
player.sendDebug( "Registered debug commands:" );
|
||||||
for ( auto cmd : m_commandMap )
|
for( auto cmd : m_commandMap )
|
||||||
{
|
{
|
||||||
if ( player.getGmRank( ) >= cmd.second->m_gmLevel )
|
if( player.getGmRank() >= cmd.second->m_gmLevel )
|
||||||
{
|
{
|
||||||
player.sendDebug( " - " + cmd.first + " - " + cmd.second->getHelpText( ) );
|
player.sendDebug( " - " + cmd.first + " - " + cmd.second->getHelpText() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
|
void Core::DebugCommandHandler::set( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
|
||||||
{
|
{
|
||||||
std::string subCommand = "";
|
std::string subCommand = "";
|
||||||
std::string params = "";
|
std::string params = "";
|
||||||
|
@ -156,9 +152,7 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost:
|
||||||
if( command->getName().length() + 1 + pos + 1 < strlen( data ) )
|
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 );
|
||||||
|
@ -218,15 +210,14 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost:
|
||||||
sscanf( params.c_str(), "%i %i %i", &pos_id, &map_id, &discover_id );
|
sscanf( params.c_str(), "%i %i %i", &pos_id, &map_id, &discover_id );
|
||||||
|
|
||||||
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" )
|
||||||
|
@ -236,26 +227,26 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost:
|
||||||
}
|
}
|
||||||
else if( subCommand == "classjob" )
|
else if( subCommand == "classjob" )
|
||||||
{
|
{
|
||||||
int32_t id;
|
int32_t id;
|
||||||
|
|
||||||
sscanf( params.c_str(), "%d", &id );
|
sscanf( params.c_str(), "%d", &id );
|
||||||
|
|
||||||
if( player.getLevelForClass( static_cast< Common::ClassJob > ( id ) ) == 0 )
|
if( player.getLevelForClass( static_cast< Common::ClassJob >( id ) ) == 0 )
|
||||||
{
|
{
|
||||||
player.setLevelForClass( 1, static_cast< Common::ClassJob > ( id ) );
|
player.setLevelForClass( 1, static_cast< Common::ClassJob >( id ) );
|
||||||
player.setClassJob( static_cast< Common::ClassJob > ( id ) );
|
player.setClassJob( static_cast< Common::ClassJob >( id ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
player.setClassJob( static_cast< Common::ClassJob > ( id ) );
|
player.setClassJob( static_cast< Common::ClassJob >( id ) );
|
||||||
}
|
}
|
||||||
else if ( subCommand == "cfpenalty" )
|
else if( subCommand == "cfpenalty" )
|
||||||
{
|
{
|
||||||
int32_t minutes;
|
int32_t minutes;
|
||||||
sscanf( params.c_str(), "%d", &minutes );
|
sscanf( params.c_str(), "%d", &minutes );
|
||||||
|
|
||||||
player.setCFPenaltyMinutes( minutes );
|
player.setCFPenaltyMinutes( minutes );
|
||||||
}
|
}
|
||||||
else if ( subCommand == "eorzeatime" )
|
else if( subCommand == "eorzeatime" )
|
||||||
{
|
{
|
||||||
uint64_t timestamp;
|
uint64_t timestamp;
|
||||||
sscanf( params.c_str(), "%" SCNu64, ×tamp );
|
sscanf( params.c_str(), "%" SCNu64, ×tamp );
|
||||||
|
@ -263,7 +254,7 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost:
|
||||||
player.setEorzeaTimeOffset( timestamp );
|
player.setEorzeaTimeOffset( timestamp );
|
||||||
player.sendNotice( "Eorzea time offset: " + std::to_string( timestamp ) );
|
player.sendNotice( "Eorzea time offset: " + std::to_string( timestamp ) );
|
||||||
}
|
}
|
||||||
else if ( subCommand == "model" )
|
else if( subCommand == "model" )
|
||||||
{
|
{
|
||||||
uint32_t slot;
|
uint32_t slot;
|
||||||
uint32_t val;
|
uint32_t val;
|
||||||
|
@ -273,7 +264,7 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost:
|
||||||
player.sendModel();
|
player.sendModel();
|
||||||
player.sendDebug( "Model updated" );
|
player.sendDebug( "Model updated" );
|
||||||
}
|
}
|
||||||
else if ( subCommand == "mount" )
|
else if( subCommand == "mount" )
|
||||||
{
|
{
|
||||||
int32_t id;
|
int32_t id;
|
||||||
sscanf( params.c_str(), "%d", &id );
|
sscanf( params.c_str(), "%d", &id );
|
||||||
|
@ -285,10 +276,9 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost:
|
||||||
{
|
{
|
||||||
player.sendUrgent( subCommand + " is not a valid SET command." );
|
player.sendUrgent( subCommand + " is not a valid SET command." );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::DebugCommandHandler::add( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
|
void Core::DebugCommandHandler::add( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
|
||||||
{
|
{
|
||||||
std::string subCommand;
|
std::string subCommand;
|
||||||
std::string params = "";
|
std::string params = "";
|
||||||
|
@ -311,9 +301,7 @@ void Core::DebugCommandHandler::add( char * data, Entity::Player& player, boost:
|
||||||
if( command->getName().length() + 1 + pos + 1 < strlen( data ) )
|
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, ¶m );
|
sscanf( params.c_str(), "%d %d %hu", &id, &duration, ¶m );
|
||||||
|
|
||||||
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, ¶m1, ¶m2, ¶m3, ¶m4, ¶m5, ¶m6, &playerId );
|
sscanf( params.c_str(), "%x %x %x %x %x %x %x %x", &opcode, ¶m1, ¶m2, ¶m3, ¶m4, ¶m5, ¶m6,
|
||||||
|
&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,27 +376,25 @@ 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, ¶m1, ¶m2, ¶m3, ¶m4, ¶m5, ¶m6,
|
||||||
|
&playerId);
|
||||||
|
|
||||||
/*sscanf(params.c_str(), "%x %x %x %x %x %x %x", &opcode, ¶m1, ¶m2, ¶m3, ¶m4, ¶m5, ¶m6, &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 )
|
||||||
{
|
{
|
||||||
std::string subCommand;
|
std::string subCommand;
|
||||||
std::string params = "";
|
std::string params = "";
|
||||||
|
@ -425,45 +414,41 @@ void Core::DebugCommandHandler::get( char * data, Entity::Player& player, boost:
|
||||||
if( command->getName().length() + 1 + pos + 1 < strlen( data ) )
|
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 )
|
||||||
pSession->getChatConnection()->injectPacket( data + 8, player );
|
pSession->getChatConnection()->injectPacket( data + 8, player );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::DebugCommandHandler::nudge( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
|
void Core::DebugCommandHandler::nudge( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
|
||||||
{
|
{
|
||||||
std::string subCommand;
|
std::string subCommand;
|
||||||
|
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
{
|
{
|
||||||
|
@ -25,27 +24,26 @@ public:
|
||||||
void registerCommand( const std::string& n, DebugCommand::pFunc, const std::string& hText, uint8_t uLevel );
|
void registerCommand( const std::string& n, DebugCommand::pFunc, const std::string& hText, uint8_t uLevel );
|
||||||
|
|
||||||
// execute command if registered
|
// execute command if registered
|
||||||
void execCommand( char * data, Entity::Player& player );
|
void execCommand( char* data, Entity::Player& player );
|
||||||
|
|
||||||
// help command
|
// help command
|
||||||
void help( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
|
void help( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
|
||||||
|
|
||||||
// command handler callbacks
|
// command handler callbacks
|
||||||
void set( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
|
void set( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
|
||||||
void get( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
|
void get( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
|
||||||
void add( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
|
void add( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
|
||||||
//void debug( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
|
// void debug( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
|
||||||
void scriptReload( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
|
void scriptReload( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
|
||||||
|
|
||||||
void injectPacket( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
|
void injectPacket( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
|
||||||
void injectChatPacket( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
|
void injectChatPacket( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
|
||||||
void nudge( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
|
void nudge( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
|
||||||
void serverInfo( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
|
void serverInfo( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
|
||||||
|
|
||||||
void unlockCharacter( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
|
void 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
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
#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_eventId( eventId ),
|
m_actorId( actorId ),
|
||||||
m_playedScene( false )
|
m_eventId( eventId ),
|
||||||
|
m_playedScene( false )
|
||||||
{
|
{
|
||||||
|
|
||||||
m_param1 = static_cast< uint16_t >( eventId );
|
m_param1 = static_cast< uint16_t >( eventId );
|
||||||
|
@ -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;
|
||||||
|
|
|
@ -4,75 +4,75 @@
|
||||||
#include "../Forwards.h"
|
#include "../Forwards.h"
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Event {
|
namespace Event {
|
||||||
|
|
||||||
class Event
|
class Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Event( uint64_t actorId, uint32_t eventId, uint8_t eventType, uint8_t eventParam2, uint32_t eventParam3 );
|
||||||
|
|
||||||
|
~Event() {}
|
||||||
|
|
||||||
|
uint64_t getActorId() const;
|
||||||
|
|
||||||
|
uint32_t getId() const;
|
||||||
|
|
||||||
|
uint32_t getParam1() const;
|
||||||
|
|
||||||
|
uint16_t getParam2() const;
|
||||||
|
|
||||||
|
uint8_t getEventType() const;
|
||||||
|
|
||||||
|
uint32_t getEventParam2() const;
|
||||||
|
|
||||||
|
uint32_t getEventParam3() const;
|
||||||
|
|
||||||
|
bool hasPlayedScene() const;
|
||||||
|
|
||||||
|
void setPlayedScene( bool playedScene );
|
||||||
|
|
||||||
|
Scripting::EventReturnCallback getEventReturnCallback() const;
|
||||||
|
|
||||||
|
void setEventReturnCallback( Scripting::EventReturnCallback callback );
|
||||||
|
|
||||||
|
enum EventType : uint8_t
|
||||||
{
|
{
|
||||||
public:
|
Talk = 1,
|
||||||
Event( uint64_t actorId, uint32_t eventId, uint8_t eventType, uint8_t eventParam2, uint32_t eventParam3 );
|
Emote = 2,
|
||||||
|
DistanceBelow = 3,
|
||||||
~Event() {}
|
DistanceOver = 4,
|
||||||
|
BattleReward = 5,
|
||||||
uint64_t getActorId() const;
|
Craft = 6,
|
||||||
|
Nest = 7,
|
||||||
uint32_t getId() const;
|
Item = 8,
|
||||||
|
Drop = 9,
|
||||||
uint32_t getParam1() const;
|
WithinRange = 10,
|
||||||
|
OutsideRange = 11,
|
||||||
uint16_t getParam2() const;
|
GameStart = 12,
|
||||||
|
GameProgress = 13,
|
||||||
uint8_t getEventType() const;
|
EnterTerritory = 15,
|
||||||
|
GameComeBack = 17,
|
||||||
uint32_t getEventParam2() const;
|
ActionResult = 18,
|
||||||
|
MateriaCraft = 19,
|
||||||
uint32_t getEventParam3() const;
|
Fishing = 20,
|
||||||
|
UI = 21,
|
||||||
bool hasPlayedScene() const;
|
Housing = 22,
|
||||||
|
Say = 23,
|
||||||
void setPlayedScene( bool playedScene );
|
TableGame = 24,
|
||||||
|
|
||||||
Scripting::EventReturnCallback getEventReturnCallback() const;
|
|
||||||
|
|
||||||
void setEventReturnCallback( Scripting::EventReturnCallback callback );
|
|
||||||
|
|
||||||
enum EventType : uint8_t
|
|
||||||
{
|
|
||||||
Talk = 1,
|
|
||||||
Emote = 2,
|
|
||||||
DistanceBelow = 3,
|
|
||||||
DistanceOver = 4,
|
|
||||||
BattleReward = 5,
|
|
||||||
Craft = 6,
|
|
||||||
Nest = 7,
|
|
||||||
Item = 8,
|
|
||||||
Drop = 9,
|
|
||||||
WithinRange = 10,
|
|
||||||
OutsideRange = 11,
|
|
||||||
GameStart = 12,
|
|
||||||
GameProgress = 13,
|
|
||||||
EnterTerritory = 15,
|
|
||||||
GameComeBack = 17,
|
|
||||||
ActionResult = 18,
|
|
||||||
MateriaCraft = 19,
|
|
||||||
Fishing = 20,
|
|
||||||
UI = 21,
|
|
||||||
Housing = 22,
|
|
||||||
Say = 23,
|
|
||||||
TableGame = 24,
|
|
||||||
};
|
|
||||||
|
|
||||||
protected:
|
|
||||||
uint64_t m_actorId;
|
|
||||||
uint32_t m_eventId;
|
|
||||||
uint32_t m_param1;
|
|
||||||
uint16_t m_param2;
|
|
||||||
uint8_t m_eventType;
|
|
||||||
uint8_t m_eventParam2;
|
|
||||||
uint32_t m_eventParam3;
|
|
||||||
bool m_playedScene;
|
|
||||||
Scripting::EventReturnCallback m_callback;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
protected:
|
||||||
}
|
uint64_t m_actorId;
|
||||||
|
uint32_t m_eventId;
|
||||||
|
uint32_t m_param1;
|
||||||
|
uint16_t m_param2;
|
||||||
|
uint8_t m_eventType;
|
||||||
|
uint8_t m_eventParam2;
|
||||||
|
uint32_t m_eventParam3;
|
||||||
|
bool m_playedScene;
|
||||||
|
Scripting::EventReturnCallback m_callback;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Event
|
||||||
|
} // namespace Core
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Event {
|
namespace Event {
|
||||||
|
|
||||||
std::string getEventName( uint32_t eventId );
|
std::string getEventName( uint32_t eventId );
|
||||||
|
|
||||||
uint32_t mapEventActorToRealActor( uint32_t eventActorId );
|
uint32_t mapEventActorToRealActor( uint32_t eventActorId );
|
||||||
|
|
||||||
}
|
} // namespace Event
|
||||||
}
|
} // namespace Core
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4,78 +4,68 @@
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#define TYPE_FORWARD( x ) \
|
#define TYPE_FORWARD( x ) \
|
||||||
class x; \
|
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 );
|
TYPE_FORWARD( ItemContainer );
|
||||||
TYPE_FORWARD( ItemContainer );
|
TYPE_FORWARD( Inventory );
|
||||||
TYPE_FORWARD( Inventory );
|
TYPE_FORWARD( Session );
|
||||||
TYPE_FORWARD( Session );
|
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
|
|
||||||
{
|
|
||||||
TYPE_FORWARD( Event );
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Action
|
|
||||||
{
|
|
||||||
TYPE_FORWARD( Action );
|
|
||||||
TYPE_FORWARD( ActionTeleport );
|
|
||||||
TYPE_FORWARD( ActionCast );
|
|
||||||
TYPE_FORWARD( ActionMount );
|
|
||||||
TYPE_FORWARD( EventAction );
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Network
|
|
||||||
{
|
|
||||||
TYPE_FORWARD( Hive );
|
|
||||||
TYPE_FORWARD( Acceptor );
|
|
||||||
TYPE_FORWARD( Connection );
|
|
||||||
TYPE_FORWARD( GameConnection );
|
|
||||||
TYPE_FORWARD( SessionConnection );
|
|
||||||
TYPE_FORWARD( CustomMsgClientConnection );
|
|
||||||
|
|
||||||
namespace Packets
|
|
||||||
{
|
|
||||||
TYPE_FORWARD( GamePacket );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace ContentFinder
|
|
||||||
{
|
|
||||||
TYPE_FORWARD( ContentFinder );
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Scripting
|
|
||||||
{
|
|
||||||
typedef std::function< void( Entity::Player&, uint32_t, uint16_t, uint16_t, uint16_t ) > EventReturnCallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef std::function< void( Entity::Player&, uint32_t, uint64_t ) > ActionCallback;
|
|
||||||
|
|
||||||
|
namespace Event {
|
||||||
|
TYPE_FORWARD( Event );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Action {
|
||||||
|
TYPE_FORWARD( Action );
|
||||||
|
TYPE_FORWARD( ActionTeleport );
|
||||||
|
TYPE_FORWARD( ActionCast );
|
||||||
|
TYPE_FORWARD( ActionMount );
|
||||||
|
TYPE_FORWARD( EventAction );
|
||||||
|
} // namespace Action
|
||||||
|
|
||||||
|
namespace Network {
|
||||||
|
TYPE_FORWARD( Hive );
|
||||||
|
TYPE_FORWARD( Acceptor );
|
||||||
|
TYPE_FORWARD( Connection );
|
||||||
|
TYPE_FORWARD( GameConnection );
|
||||||
|
TYPE_FORWARD( SessionConnection );
|
||||||
|
TYPE_FORWARD( CustomMsgClientConnection );
|
||||||
|
|
||||||
|
namespace Packets {
|
||||||
|
TYPE_FORWARD( GamePacket );
|
||||||
|
}
|
||||||
|
} // namespace Network
|
||||||
|
|
||||||
|
namespace ContentFinder {
|
||||||
|
TYPE_FORWARD( ContentFinder );
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Scripting {
|
||||||
|
typedef std::function< void( Entity::Player&, uint32_t, uint16_t, uint16_t, uint16_t ) > EventReturnCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef std::function< void( Entity::Player&, uint32_t, uint64_t ) > ActionCallback;
|
||||||
|
|
||||||
|
} // namespace Core
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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 );
|
||||||
|
@ -52,8 +53,8 @@ Core::Inventory::Inventory( Core::Entity::Player* pOwner )
|
||||||
|
|
||||||
// crystals??
|
// crystals??
|
||||||
setupContainer( m_inventoryMap, Crystal );
|
setupContainer( m_inventoryMap, Crystal );
|
||||||
//m_inventoryMap[0x07D3] = ItemContainerPtr( new ItemContainer( UNKNOWN_0 ) );
|
// m_inventoryMap[0x07D3] = ItemContainerPtr( new ItemContainer( UNKNOWN_0 ) );
|
||||||
//m_inventoryMap[0x07D8] = ItemContainerPtr( new ItemContainer( UNKNOWN_1 ) );
|
// m_inventoryMap[0x07D8] = ItemContainerPtr( new ItemContainer( UNKNOWN_1 ) );
|
||||||
|
|
||||||
// armory weapons - 0
|
// armory weapons - 0
|
||||||
setupContainer( m_inventoryMap, ArmoryMain );
|
setupContainer( m_inventoryMap, ArmoryMain );
|
||||||
|
@ -61,41 +62,40 @@ Core::Inventory::Inventory( Core::Entity::Player* pOwner )
|
||||||
// armory offhand - 1
|
// armory offhand - 1
|
||||||
setupContainer( m_inventoryMap, ArmoryOff );
|
setupContainer( m_inventoryMap, ArmoryOff );
|
||||||
|
|
||||||
//armory head - 2
|
// armory head - 2
|
||||||
setupContainer( m_inventoryMap, ArmoryHead );
|
setupContainer( m_inventoryMap, ArmoryHead );
|
||||||
|
|
||||||
//armory body - 3
|
// armory body - 3
|
||||||
setupContainer( m_inventoryMap, ArmoryBody );
|
setupContainer( m_inventoryMap, ArmoryBody );
|
||||||
|
|
||||||
//armory hand - 4
|
// armory hand - 4
|
||||||
setupContainer( m_inventoryMap, ArmoryHand );
|
setupContainer( m_inventoryMap, ArmoryHand );
|
||||||
|
|
||||||
//armory waist - 5
|
// armory waist - 5
|
||||||
setupContainer( m_inventoryMap, ArmoryWaist );
|
setupContainer( m_inventoryMap, ArmoryWaist );
|
||||||
|
|
||||||
//armory legs - 6
|
// armory legs - 6
|
||||||
setupContainer( m_inventoryMap, ArmoryLegs );
|
setupContainer( m_inventoryMap, ArmoryLegs );
|
||||||
|
|
||||||
//armory feet - 7
|
// armory feet - 7
|
||||||
setupContainer( m_inventoryMap, ArmoryFeet );
|
setupContainer( m_inventoryMap, ArmoryFeet );
|
||||||
|
|
||||||
//neck
|
// neck
|
||||||
setupContainer( m_inventoryMap, ArmotyNeck );
|
setupContainer( m_inventoryMap, ArmotyNeck );
|
||||||
|
|
||||||
//earring
|
// earring
|
||||||
setupContainer( m_inventoryMap, ArmoryEar );
|
setupContainer( m_inventoryMap, ArmoryEar );
|
||||||
|
|
||||||
//wrist
|
// wrist
|
||||||
setupContainer( m_inventoryMap, ArmoryWrist );
|
setupContainer( m_inventoryMap, ArmoryWrist );
|
||||||
|
|
||||||
//armory rings - 11
|
// armory rings - 11
|
||||||
setupContainer( m_inventoryMap, ArmoryRing );
|
setupContainer( m_inventoryMap, ArmoryRing );
|
||||||
|
|
||||||
//soul crystals - 13
|
// soul crystals - 13
|
||||||
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;
|
||||||
|
@ -304,25 +295,17 @@ void Core::Inventory::updateBagDb( InventoryType type )
|
||||||
}
|
}
|
||||||
|
|
||||||
query += " WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) +
|
query += " WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) +
|
||||||
" AND storageId = " + std::to_string( static_cast< uint16_t >( type ) );
|
" AND storageId = " + std::to_string( static_cast< uint16_t >( type ) );
|
||||||
|
|
||||||
g_charaDb.execute( query );
|
g_charaDb.execute( query );
|
||||||
}
|
}
|
||||||
|
|
||||||
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 ";
|
||||||
|
@ -387,18 +367,17 @@ void Core::Inventory::updateMannequinDb( InventoryType type )
|
||||||
}
|
}
|
||||||
|
|
||||||
query += " WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) +
|
query += " WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) +
|
||||||
" AND storageId = " + std::to_string( static_cast< uint16_t >( type ) );
|
" AND storageId = " + std::to_string( static_cast< uint16_t >( type ) );
|
||||||
|
|
||||||
g_log.Log( LoggingSeverity::debug, query );
|
g_log.Log( LoggingSeverity::debug, query );
|
||||||
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() ) + " " +
|
||||||
// TODO: add other attributes
|
// TODO: add other attributes
|
||||||
" WHERE itemId = " + std::to_string( pItem->getUId() ) );
|
" WHERE itemId = " + std::to_string( pItem->getUId() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Core::Inventory::removeCurrency( CurrencyType type, uint32_t amount )
|
bool Core::Inventory::removeCurrency( CurrencyType type, uint32_t amount )
|
||||||
|
@ -441,7 +420,7 @@ bool Core::Inventory::removeCrystal( CrystalType type, uint32_t amount )
|
||||||
|
|
||||||
bool Core::Inventory::isOneHandedWeapon( ItemUICategory weaponCategory )
|
bool Core::Inventory::isOneHandedWeapon( ItemUICategory weaponCategory )
|
||||||
{
|
{
|
||||||
switch ( weaponCategory )
|
switch( weaponCategory )
|
||||||
{
|
{
|
||||||
case ItemUICategory::AlchemistsPrimaryTool:
|
case ItemUICategory::AlchemistsPrimaryTool:
|
||||||
case ItemUICategory::ArmorersPrimaryTool:
|
case ItemUICategory::ArmorersPrimaryTool:
|
||||||
|
@ -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 )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -483,13 +461,13 @@ int16_t Core::Inventory::addItem( uint16_t inventoryId, int8_t slotId, uint32_t
|
||||||
|
|
||||||
int8_t rSlotId = -1;
|
int8_t rSlotId = -1;
|
||||||
|
|
||||||
//if( itemInfo->stack_size > 1 )
|
// if( itemInfo->stack_size > 1 )
|
||||||
//{
|
//{
|
||||||
// auto itemList = this->getSlotsOfItemsInInventory( catalogId );
|
// auto itemList = this->getSlotsOfItemsInInventory( catalogId );
|
||||||
// // TODO: this is a stacked item so we need to see if the item is already in inventory and
|
// // TODO: this is a stacked item so we need to see if the item is already in inventory and
|
||||||
// // check how much free space we have on existing stacks before looking for empty slots.
|
// // check how much free space we have on existing stacks before looking for empty slots.
|
||||||
//}
|
//}
|
||||||
//else
|
// else
|
||||||
{
|
{
|
||||||
auto freeSlot = this->getFreeBagSlot();
|
auto freeSlot = this->getFreeBagSlot();
|
||||||
inventoryId = freeSlot.first;
|
inventoryId = freeSlot.first;
|
||||||
|
@ -506,8 +484,8 @@ int16_t Core::Inventory::addItem( uint16_t inventoryId, int8_t slotId, uint32_t
|
||||||
|
|
||||||
m_inventoryMap[inventoryId]->setItem( rSlotId, item );
|
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 )
|
||||||
|
@ -569,26 +544,26 @@ bool Core::Inventory::updateContainer( uint16_t containerId, uint8_t slotId, Ite
|
||||||
|
|
||||||
switch( containerType )
|
switch( containerType )
|
||||||
{
|
{
|
||||||
case Armory:
|
case Armory:
|
||||||
case CurrencyCrystal:
|
case CurrencyCrystal:
|
||||||
case Bag:
|
case Bag:
|
||||||
{
|
{
|
||||||
updateBagDb( static_cast< InventoryType >( containerId ) );
|
updateBagDb( static_cast< InventoryType >( containerId ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case GearSet:
|
case GearSet:
|
||||||
{
|
{
|
||||||
if( pItem )
|
if( pItem )
|
||||||
m_pOwner->equipItem( static_cast< EquipSlot >( slotId ), pItem, true );
|
m_pOwner->equipItem( static_cast< EquipSlot >( slotId ), pItem, true );
|
||||||
else
|
else
|
||||||
m_pOwner->unequipItem( static_cast< EquipSlot >( slotId ), pItem );
|
m_pOwner->unequipItem( static_cast< EquipSlot >( slotId ), pItem );
|
||||||
|
|
||||||
updateMannequinDb( static_cast< InventoryType >( containerId ) );
|
updateMannequinDb( static_cast< InventoryType >( containerId ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -605,13 +580,11 @@ void Core::Inventory::swapItem( uint16_t fromInventoryId, uint8_t fromSlotId, ui
|
||||||
|
|
||||||
// An item is being moved from bag0-3 to equippment, meaning
|
// 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 );
|
||||||
fromSlotId = static_cast < uint8_t >( m_inventoryMap[fromInventoryId]->getFreeSlot() );
|
fromSlotId = static_cast< uint8_t >( m_inventoryMap[fromInventoryId]->getFreeSlot() );
|
||||||
}
|
}
|
||||||
|
|
||||||
auto containerTypeFrom = getContainerType( fromInventoryId );
|
auto containerTypeFrom = getContainerType( fromInventoryId );
|
||||||
|
@ -650,7 +623,8 @@ void Core::Inventory::discardItem( uint16_t fromInventoryId, uint8_t fromSlotId
|
||||||
Core::ItemPtr Core::Inventory::loadItem( uint64_t uId )
|
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()
|
||||||
|
@ -862,16 +834,16 @@ uint16_t Core::Inventory::calculateEquippedGearItemLevel()
|
||||||
|
|
||||||
auto it = gearSetMap.begin();
|
auto it = gearSetMap.begin();
|
||||||
|
|
||||||
while ( it != gearSetMap.end() )
|
while( it != gearSetMap.end() )
|
||||||
{
|
{
|
||||||
auto currItem = it->second;
|
auto currItem = it->second;
|
||||||
|
|
||||||
if ( currItem )
|
if( currItem )
|
||||||
{
|
{
|
||||||
iLvlResult += currItem->getItemLevel();
|
iLvlResult += currItem->getItemLevel();
|
||||||
|
|
||||||
// If item is weapon and isn't one-handed
|
// If item is weapon and isn't one-handed
|
||||||
if ( currItem->isWeapon() && !isOneHandedWeapon( currItem->getCategory() ) )
|
if( currItem->isWeapon() && !isOneHandedWeapon( currItem->getCategory() ) )
|
||||||
{
|
{
|
||||||
iLvlResult += currItem->getItemLevel();
|
iLvlResult += currItem->getItemLevel();
|
||||||
}
|
}
|
||||||
|
@ -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 )
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
@ -37,10 +36,10 @@ public:
|
||||||
|
|
||||||
Currency = 2000,
|
Currency = 2000,
|
||||||
Crystal = 2001,
|
Crystal = 2001,
|
||||||
//UNKNOWN_0 = 2003,
|
// UNKNOWN_0 = 2003,
|
||||||
KeyItem = 2004,
|
KeyItem = 2004,
|
||||||
DamagedGear = 2007,
|
DamagedGear = 2007,
|
||||||
//UNKNOWN_1 = 2008,
|
// UNKNOWN_1 = 2008,
|
||||||
|
|
||||||
ArmoryOff = 3200,
|
ArmoryOff = 3200,
|
||||||
ArmoryHead = 3201,
|
ArmoryHead = 3201,
|
||||||
|
@ -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
|
||||||
|
|
|
@ -1,28 +1,25 @@
|
||||||
|
#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,
|
||||||
m_id( catalogId ),
|
bool isHq ) :
|
||||||
m_uId( uId ),
|
m_id( catalogId ),
|
||||||
m_category( static_cast< Common::ItemUICategory >( categoryId ) ),
|
m_uId( uId ),
|
||||||
m_model1( model1 ),
|
m_category( static_cast< Common::ItemUICategory >( categoryId ) ),
|
||||||
m_model2( model2 ),
|
m_model1( model1 ),
|
||||||
m_isHq( isHq )
|
m_model2( model2 ),
|
||||||
|
m_isHq( isHq )
|
||||||
{
|
{
|
||||||
auto itemInfo = g_exdData.getItemInfo( catalogId );
|
auto itemInfo = g_exdData.getItemInfo( catalogId );
|
||||||
m_delayMs = itemInfo->delayMs;
|
m_delayMs = itemInfo->delayMs;
|
||||||
|
@ -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
|
||||||
|
@ -70,7 +66,7 @@ uint16_t Core::Item::getWeaponDmg() const
|
||||||
|
|
||||||
bool Core::Item::isWeapon() const
|
bool Core::Item::isWeapon() const
|
||||||
{
|
{
|
||||||
return (m_weaponDmg != 0);
|
return ( m_weaponDmg != 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Core::Item::getId() const
|
uint32_t Core::Item::getId() const
|
||||||
|
|
|
@ -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,31 +55,29 @@ public:
|
||||||
|
|
||||||
uint16_t getItemLevel() const;
|
uint16_t getItemLevel() const;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint32_t m_id;
|
uint32_t m_id;
|
||||||
|
|
||||||
uint64_t m_uId;
|
uint64_t m_uId;
|
||||||
|
|
||||||
Common::ItemUICategory m_category;
|
Common::ItemUICategory m_category;
|
||||||
|
|
||||||
uint32_t m_stackSize;
|
uint32_t m_stackSize;
|
||||||
std::vector< uint8_t > m_classJobList;
|
std::vector< uint8_t > m_classJobList;
|
||||||
|
|
||||||
uint64_t m_model1;
|
uint64_t m_model1;
|
||||||
uint64_t m_model2;
|
uint64_t m_model2;
|
||||||
|
|
||||||
bool m_isHq;
|
bool m_isHq;
|
||||||
|
|
||||||
uint16_t m_delayMs;
|
|
||||||
uint16_t m_physicalDmg;
|
|
||||||
uint16_t m_magicalDmg;
|
|
||||||
uint16_t m_weaponDmg;
|
|
||||||
float m_autoAttackDmg;
|
|
||||||
uint16_t m_itemLevel;
|
|
||||||
|
|
||||||
|
uint16_t m_delayMs;
|
||||||
|
uint16_t m_physicalDmg;
|
||||||
|
uint16_t m_magicalDmg;
|
||||||
|
uint16_t m_weaponDmg;
|
||||||
|
float m_autoAttackDmg;
|
||||||
|
uint16_t m_itemLevel;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace Core
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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
|
||||||
|
@ -52,12 +47,12 @@ void Core::ItemContainer::removeItem( uint8_t slotId )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::ItemMap & Core::ItemContainer::getItemMap()
|
Core::ItemMap& Core::ItemContainer::getItemMap()
|
||||||
{
|
{
|
||||||
return m_itemMap;
|
return m_itemMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Core::ItemMap & Core::ItemContainer::getItemMap() const
|
const Core::ItemMap& Core::ItemContainer::getItemMap() const
|
||||||
{
|
{
|
||||||
return m_itemMap;
|
return m_itemMap;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
|
|
@ -7,41 +7,40 @@
|
||||||
|
|
||||||
#include "../Forwards.h"
|
#include "../Forwards.h"
|
||||||
|
|
||||||
namespace Core
|
namespace Core {
|
||||||
|
|
||||||
|
typedef std::map< uint8_t, ItemPtr > ItemMap;
|
||||||
|
|
||||||
|
class ItemContainer
|
||||||
{
|
{
|
||||||
|
|
||||||
typedef std::map< uint8_t, ItemPtr > ItemMap;
|
public:
|
||||||
|
ItemContainer( uint16_t locationId );
|
||||||
|
~ItemContainer();
|
||||||
|
|
||||||
class ItemContainer
|
uint16_t getId() const;
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
uint8_t getEntryCount() const;
|
||||||
ItemContainer( uint16_t locationId );
|
|
||||||
~ItemContainer();
|
|
||||||
|
|
||||||
uint16_t getId() const;
|
void removeItem( uint8_t slotId );
|
||||||
|
|
||||||
uint8_t getEntryCount() const;
|
ItemMap& getItemMap();
|
||||||
|
|
||||||
void removeItem( uint8_t slotId );
|
const ItemMap& getItemMap() const;
|
||||||
|
|
||||||
ItemMap& getItemMap();
|
ItemPtr getItem( uint8_t slotId );
|
||||||
|
|
||||||
const ItemMap& getItemMap() const;
|
void setItem( uint8_t slotId, ItemPtr item );
|
||||||
|
|
||||||
ItemPtr getItem( uint8_t slotId );
|
int16_t getFreeSlot();
|
||||||
|
|
||||||
void setItem( uint8_t slotId, ItemPtr item );
|
private:
|
||||||
|
uint16_t m_id;
|
||||||
|
uint8_t m_size;
|
||||||
|
ItemMap m_itemMap;
|
||||||
|
Entity::PlayerPtr m_pOwner;
|
||||||
|
};
|
||||||
|
|
||||||
int16_t getFreeSlot();
|
} // namespace Core
|
||||||
|
|
||||||
private:
|
|
||||||
uint16_t m_id;
|
|
||||||
uint8_t m_size;
|
|
||||||
ItemMap m_itemMap;
|
|
||||||
Entity::PlayerPtr m_pOwner;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,20 +1,15 @@
|
||||||
#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,
|
const std::set< uint64_t >& invites ) :
|
||||||
uint64_t masterId,
|
m_linkshellId( id ),
|
||||||
const std::set<uint64_t> &members,
|
m_name( name ),
|
||||||
const std::set<uint64_t> &leaders,
|
m_masterCharacterId( masterId ),
|
||||||
const std::set<uint64_t> &invites ) :
|
m_memberIds( members ),
|
||||||
m_linkshellId( id ),
|
m_leaderIds( leaders ),
|
||||||
m_name( name ),
|
m_inviteIds( invites )
|
||||||
m_masterCharacterId( masterId ),
|
|
||||||
m_memberIds( members ),
|
|
||||||
m_leaderIds( leaders ),
|
|
||||||
m_inviteIds( invites )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Core::Linkshell::getId() const
|
uint64_t Core::Linkshell::getId() const
|
||||||
|
@ -57,7 +52,7 @@ const std::set< uint64_t >& Core::Linkshell::getInviteIdList() const
|
||||||
return m_inviteIds;
|
return m_inviteIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set< uint64_t > &Core::Linkshell::getInviteIdList()
|
std::set< uint64_t >& Core::Linkshell::getInviteIdList()
|
||||||
{
|
{
|
||||||
return m_inviteIds;
|
return m_inviteIds;
|
||||||
}
|
}
|
||||||
|
@ -91,6 +86,3 @@ void Core::Linkshell::removeInvite( uint64_t memberId )
|
||||||
{
|
{
|
||||||
m_inviteIds.erase( memberId );
|
m_inviteIds.erase( memberId );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -9,26 +9,23 @@ extern Core::Logger g_log;
|
||||||
|
|
||||||
Core::LinkshellMgr::LinkshellMgr()
|
Core::LinkshellMgr::LinkshellMgr()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Core::LinkshellMgr::loadLinkshells()
|
bool Core::LinkshellMgr::loadLinkshells()
|
||||||
{
|
{
|
||||||
|
|
||||||
auto res = g_charaDb.query( "SELECT LinkshellId, MasterCharacterId, CharacterIdList, "
|
auto res = g_charaDb.query( "SELECT LinkshellId, MasterCharacterId, CharacterIdList, "
|
||||||
"LinkshellName, LeaderIdList, InviteIdList "
|
"LinkshellName, LeaderIdList, InviteIdList "
|
||||||
"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 )
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
@ -38,12 +37,12 @@ float CalcStats::calculateBaseStat( PlayerPtr pPlayer )
|
||||||
uint8_t level = pPlayer->getLevel();
|
uint8_t level = pPlayer->getLevel();
|
||||||
|
|
||||||
// SB Base Stat Formula (Aligned)
|
// SB Base Stat Formula (Aligned)
|
||||||
if ( level > 60 )
|
if( level > 60 )
|
||||||
{
|
{
|
||||||
base = static_cast< float >( ( ( ( level == 61 ) ? 224 : 220 ) + ( level - 61 ) * 8) );
|
base = static_cast< float >( ( ( ( level == 61 ) ? 224 : 220 ) + ( level - 61 ) * 8 ) );
|
||||||
}
|
}
|
||||||
// HW Base Stat Formula (Aligned)
|
// HW Base Stat Formula (Aligned)
|
||||||
else if ( level > 50 )
|
else if( level > 50 )
|
||||||
base = 1.63f * level + 121.02f;
|
base = 1.63f * level + 121.02f;
|
||||||
// ARR Base Stat Formula (Off by one in several cases)
|
// ARR Base Stat Formula (Off by one in several cases)
|
||||||
else
|
else
|
||||||
|
@ -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();
|
||||||
|
@ -78,14 +77,15 @@ uint32_t CalcStats::calculateMaxHp( PlayerPtr pPlayer )
|
||||||
|
|
||||||
// These values are not precise.
|
// These values are not precise.
|
||||||
|
|
||||||
if ( level >= 60 )
|
if( level >= 60 )
|
||||||
approxBaseHp = static_cast< float >( 2600 + ( level - 60 ) * 100 );
|
approxBaseHp = static_cast< float >( 2600 + ( level - 60 ) * 100 );
|
||||||
else if ( level >= 50 )
|
else if( level >= 50 )
|
||||||
approxBaseHp = 1700 + ( ( level - 50 ) * ( 1700 * 1.04325f ) );
|
approxBaseHp = 1700 + ( ( level - 50 ) * ( 1700 * 1.04325f ) );
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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,87 +24,89 @@ 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
setZoneHandler( ClientZoneIpcType::PingHandler, "PingHandler", &GameConnection::pingHandler );
|
setZoneHandler( ClientZoneIpcType::PingHandler, "PingHandler", &GameConnection::pingHandler );
|
||||||
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 );
|
||||||
|
|
||||||
setZoneHandler( ClientZoneIpcType::ZoneLineHandler, "ZoneLineHandler", &GameConnection::zoneLineHandler );
|
setZoneHandler( ClientZoneIpcType::ZoneLineHandler, "ZoneLineHandler", &GameConnection::zoneLineHandler );
|
||||||
setZoneHandler( ClientZoneIpcType::ActionHandler, "ActionHandler", &GameConnection::actionHandler );
|
setZoneHandler( ClientZoneIpcType::ActionHandler, "ActionHandler", &GameConnection::actionHandler );
|
||||||
|
|
||||||
setZoneHandler( ClientZoneIpcType::DiscoveryHandler, "DiscoveryHandler", &GameConnection::discoveryHandler );
|
setZoneHandler( ClientZoneIpcType::DiscoveryHandler, "DiscoveryHandler", &GameConnection::discoveryHandler );
|
||||||
|
|
||||||
setZoneHandler( ClientZoneIpcType::SkillHandler, "SkillHandler", &GameConnection::skillHandler );
|
setZoneHandler( ClientZoneIpcType::SkillHandler, "SkillHandler", &GameConnection::skillHandler );
|
||||||
|
|
||||||
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 );
|
||||||
setZoneHandler( ClientZoneIpcType::WithinRangeEventHandler, "EventHandler", &GameConnection::eventHandler );
|
setZoneHandler( ClientZoneIpcType::WithinRangeEventHandler, "EventHandler", &GameConnection::eventHandler );
|
||||||
setZoneHandler( ClientZoneIpcType::OutOfRangeEventHandler, "EventHandler", &GameConnection::eventHandler );
|
setZoneHandler( ClientZoneIpcType::OutOfRangeEventHandler, "EventHandler", &GameConnection::eventHandler );
|
||||||
setZoneHandler( ClientZoneIpcType::EnterTeriEventHandler, "EventHandler", &GameConnection::eventHandler );
|
setZoneHandler( ClientZoneIpcType::EnterTeriEventHandler, "EventHandler", &GameConnection::eventHandler );
|
||||||
|
|
||||||
setZoneHandler( ClientZoneIpcType::ReturnEventHandler, "EventHandlerReturn", &GameConnection::eventHandler );
|
setZoneHandler( ClientZoneIpcType::ReturnEventHandler, "EventHandlerReturn", &GameConnection::eventHandler );
|
||||||
setZoneHandler( ClientZoneIpcType::TradeReturnEventHandler, "EventHandlerReturn", &GameConnection::eventHandler );
|
setZoneHandler( ClientZoneIpcType::TradeReturnEventHandler, "EventHandlerReturn", &GameConnection::eventHandler );
|
||||||
|
|
||||||
setZoneHandler( ClientZoneIpcType::LinkshellEventHandler, "LinkshellEventHandler", &GameConnection::eventHandler );
|
setZoneHandler( ClientZoneIpcType::LinkshellEventHandler, "LinkshellEventHandler", &GameConnection::eventHandler );
|
||||||
setZoneHandler( ClientZoneIpcType::LinkshellEventHandler1, "LinkshellEventHandler1", &GameConnection::eventHandler );
|
setZoneHandler( ClientZoneIpcType::LinkshellEventHandler1, "LinkshellEventHandler1", &GameConnection::eventHandler );
|
||||||
|
|
||||||
setZoneHandler( ClientZoneIpcType::CFDutyInfoHandler, "CFDutyInfoRequest", &GameConnection::cfDutyInfoRequest );
|
setZoneHandler( ClientZoneIpcType::CFDutyInfoHandler, "CFDutyInfoRequest", &GameConnection::cfDutyInfoRequest );
|
||||||
setZoneHandler( ClientZoneIpcType::CFRegisterDuty, "CFRegisterDuty", &GameConnection::cfRegisterDuty );
|
setZoneHandler( ClientZoneIpcType::CFRegisterDuty, "CFRegisterDuty", &GameConnection::cfRegisterDuty );
|
||||||
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 )
|
||||||
{
|
{
|
||||||
GameConnectionPtr connection( new GameConnection( m_hive, m_pAcceptor ) );
|
GameConnectionPtr connection( new GameConnection( m_hive, m_pAcceptor ) );
|
||||||
m_pAcceptor->Accept( connection );
|
m_pAcceptor->Accept( connection );
|
||||||
|
@ -112,14 +114,13 @@ void Core::Network::GameConnection::OnAccept( const std::string & host, uint16_t
|
||||||
g_log.info( "Connect from " + m_socket.remote_endpoint().address().to_string() );
|
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" );
|
||||||
m_pSession = nullptr;
|
m_pSession = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Network::GameConnection::OnRecv( std::vector< uint8_t > & buffer )
|
void Core::Network::GameConnection::OnRecv( std::vector< uint8_t >& buffer )
|
||||||
{
|
{
|
||||||
// This is assumed packet always start with valid FFXIVARR_PACKET_HEADER for now.
|
// This is assumed packet always start with valid FFXIVARR_PACKET_HEADER for now.
|
||||||
|
|
||||||
|
@ -142,8 +143,8 @@ void Core::Network::GameConnection::OnRecv( std::vector< uint8_t > & buffer )
|
||||||
|
|
||||||
// Dissect packet list
|
// 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 )
|
||||||
{
|
{
|
||||||
|
@ -163,7 +164,7 @@ void Core::Network::GameConnection::OnRecv( std::vector< uint8_t > & buffer )
|
||||||
handlePackets( packetHeader, packetList );
|
handlePackets( packetHeader, packetList );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Network::GameConnection::OnError( const boost::system::error_code & error )
|
void Core::Network::GameConnection::OnError( const boost::system::error_code& error )
|
||||||
{
|
{
|
||||||
g_log.debug( "GameConnection ERROR: " + error.message() );
|
g_log.debug( "GameConnection ERROR: " + error.message() );
|
||||||
}
|
}
|
||||||
|
@ -189,25 +190,24 @@ void Core::Network::GameConnection::handleZonePacket( const Packets::GamePacket&
|
||||||
auto itStr = m_zoneHandlerStrMap.find( pPacket.getSubType() );
|
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() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,20 +242,19 @@ void Core::Network::GameConnection::handlePacket( Core::Network::Packets::GamePa
|
||||||
|
|
||||||
switch( m_conType )
|
switch( m_conType )
|
||||||
{
|
{
|
||||||
case Network::ConnectionType::Zone:
|
case Network::ConnectionType::Zone:
|
||||||
handleZonePacket( *pPacket );
|
handleZonePacket( *pPacket );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Network::ConnectionType::Chat:
|
case Network::ConnectionType::Chat:
|
||||||
handleChatPacket( *pPacket );
|
handleChatPacket( *pPacket );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Network::GameConnection::sendPackets( Packets::PacketContainer* pPacket )
|
void Core::Network::GameConnection::sendPackets( Packets::PacketContainer* pPacket )
|
||||||
{
|
{
|
||||||
//g_log.Log(LoggingSeverity::info, pPacket->toString());
|
// g_log.Log(LoggingSeverity::info, pPacket->toString());
|
||||||
std::vector< uint8_t > sendBuffer;
|
std::vector< uint8_t > sendBuffer;
|
||||||
|
|
||||||
pPacket->fillSendBuffer( sendBuffer );
|
pPacket->fillSendBuffer( sendBuffer );
|
||||||
|
@ -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 )
|
||||||
|
@ -314,7 +312,7 @@ void Core::Network::GameConnection::injectPacket( const std::string& packetpath,
|
||||||
memset( packet, 0, 0x11570 );
|
memset( packet, 0, 0x11570 );
|
||||||
|
|
||||||
// get the packet name / path from the command arguments
|
// get the packet name / path from the command arguments
|
||||||
FILE *fp = nullptr;
|
FILE* fp = nullptr;
|
||||||
fp = fopen( packetpath.c_str(), "rb" );
|
fp = fopen( packetpath.c_str(), "rb" );
|
||||||
if( fp == nullptr )
|
if( fp == nullptr )
|
||||||
{
|
{
|
||||||
|
@ -326,7 +324,7 @@ void Core::Network::GameConnection::injectPacket( const std::string& packetpath,
|
||||||
fseek( fp, 0, SEEK_END );
|
fseek( fp, 0, SEEK_END );
|
||||||
int32_t size = ftell( fp );
|
int32_t size = ftell( fp );
|
||||||
rewind( fp );
|
rewind( fp );
|
||||||
if ( fread( packet, sizeof( char ), size, fp ) != size )
|
if( fread( packet, sizeof( char ), size, fp ) != size )
|
||||||
{
|
{
|
||||||
g_log.error( "Packet " + packetpath + " did not read full size: " + std::to_string( size ) );
|
g_log.error( "Packet " + packetpath + " did not read full size: " + std::to_string( size ) );
|
||||||
return;
|
return;
|
||||||
|
@ -356,8 +354,9 @@ 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 std::vector< Core::Network::Packets::FFXIVARR_PACKET_RAW >& packetData )
|
const Core::Network::Packets::FFXIVARR_PACKET_HEADER& ipcHeader,
|
||||||
|
const std::vector< Core::Network::Packets::FFXIVARR_PACKET_RAW >& packetData )
|
||||||
{
|
{
|
||||||
// if a session is set, update the last time it recieved a game packet
|
// if a session is set, update the last time it recieved a game packet
|
||||||
if( m_pSession )
|
if( m_pSession )
|
||||||
|
@ -369,7 +368,7 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
char* id = ( char* ) &( inPacket.data[4] );
|
char* id = (char*)&( inPacket.data[4] );
|
||||||
uint32_t playerId = boost::lexical_cast< uint32_t >( id );
|
uint32_t playerId = boost::lexical_cast< uint32_t >( id );
|
||||||
auto pCon = boost::static_pointer_cast< GameConnection, Connection >( shared_from_this() );
|
auto pCon = boost::static_pointer_cast< GameConnection, Connection >( shared_from_this() );
|
||||||
|
|
||||||
|
@ -387,10 +386,10 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
|
||||||
}
|
}
|
||||||
session = g_serverZone.getSession( playerId );
|
session = g_serverZone.getSession( playerId );
|
||||||
}
|
}
|
||||||
//TODO: Catch more things in lobby and send real errors
|
// TODO: Catch more things in lobby and send real errors
|
||||||
else if( !session->isValid() || ( session->getPlayer() && session->getPlayer()->getLastPing() != 0 ) )
|
else if( !session->isValid() || ( session->getPlayer() && session->getPlayer()->getLastPing() != 0 ) )
|
||||||
{
|
{
|
||||||
g_log.error( "[" + std::string(id) + "] Session INVALID, disconnecting" );
|
g_log.error( "[" + std::string( id ) + "] Session INVALID, disconnecting" );
|
||||||
Disconnect();
|
Disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -400,7 +399,7 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
|
||||||
m_pSession = session;
|
m_pSession = session;
|
||||||
|
|
||||||
GamePacket pPe( 0x00, 0x18, 0, 0, 0x07 );
|
GamePacket pPe( 0x00, 0x18, 0, 0, 0x07 );
|
||||||
//pPe.setValAt< uint32_t >( 0x10, 0xE0000005 );
|
// pPe.setValAt< uint32_t >( 0x10, 0xE0000005 );
|
||||||
pPe.setValAt< uint32_t >( 0x10, 0xE0037603 );
|
pPe.setValAt< uint32_t >( 0x10, 0xE0037603 );
|
||||||
pPe.setValAt< uint32_t >( 0x14, static_cast< uint32_t >( time( nullptr ) ) );
|
pPe.setValAt< uint32_t >( 0x14, static_cast< uint32_t >( time( nullptr ) ) );
|
||||||
sendSinglePacket( &pPe );
|
sendSinglePacket( &pPe );
|
||||||
|
@ -428,7 +427,6 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
case 3: // game packet
|
case 3: // game packet
|
||||||
{
|
{
|
||||||
|
@ -438,8 +436,8 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
|
||||||
}
|
}
|
||||||
case 7: // keep alive
|
case 7: // keep alive
|
||||||
{
|
{
|
||||||
uint32_t id = *( uint32_t* ) &inPacket.data[0];
|
uint32_t id = *(uint32_t*)&inPacket.data[0];
|
||||||
uint32_t timeStamp = *( uint32_t* ) &inPacket.data[4];
|
uint32_t timeStamp = *(uint32_t*)&inPacket.data[4];
|
||||||
|
|
||||||
GamePacket pPe( 0x00, 0x18, 0, 0, 0x08 );
|
GamePacket pPe( 0x00, 0x18, 0, 0, 0x08 );
|
||||||
pPe.setValAt< uint32_t >( 0x10, id );
|
pPe.setValAt< uint32_t >( 0x10, id );
|
||||||
|
@ -453,6 +451,5 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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>
|
||||||
|
|
||||||
|
@ -14,117 +14,112 @@
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Network {
|
namespace Network {
|
||||||
|
|
||||||
enum ConnectionType : uint8_t
|
enum ConnectionType : uint8_t
|
||||||
{
|
{
|
||||||
Zone = 1,
|
Zone = 1,
|
||||||
Chat = 2,
|
Chat = 2,
|
||||||
Lobby = 3,
|
Lobby = 3,
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
class GameConnection : public Connection
|
class GameConnection : public Connection
|
||||||
{
|
{
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef void ( GameConnection::* Handler )( const Packets::GamePacket& inPacket, Entity::Player& player );
|
typedef void ( GameConnection::*Handler )( const Packets::GamePacket& inPacket, Entity::Player& player );
|
||||||
|
|
||||||
using HandlerMap = std::map< uint16_t, Handler >;
|
using HandlerMap = std::map< uint16_t, Handler >;
|
||||||
using HandlerStrMap = std::map< uint16_t, std::string >;
|
using HandlerStrMap = std::map< uint16_t, std::string >;
|
||||||
|
|
||||||
AcceptorPtr m_pAcceptor;
|
AcceptorPtr m_pAcceptor;
|
||||||
|
|
||||||
// handler for game packets ( main type 0x03, connection type 1 )
|
// handler for game packets ( main type 0x03, connection type 1 )
|
||||||
HandlerMap m_zoneHandlerMap;
|
HandlerMap m_zoneHandlerMap;
|
||||||
HandlerStrMap m_zoneHandlerStrMap;
|
HandlerStrMap m_zoneHandlerStrMap;
|
||||||
|
|
||||||
// handler for game packets ( main type 0x03, connection type 2 )
|
// handler for game packets ( main type 0x03, connection type 2 )
|
||||||
HandlerMap m_chatHandlerMap;
|
HandlerMap m_chatHandlerMap;
|
||||||
HandlerStrMap m_chatHandlerStrMap;
|
HandlerStrMap m_chatHandlerStrMap;
|
||||||
|
|
||||||
SessionPtr m_pSession;
|
SessionPtr m_pSession;
|
||||||
|
|
||||||
LockedQueue< Packets::GamePacketPtr > m_inQueue;
|
LockedQueue< Packets::GamePacketPtr > m_inQueue;
|
||||||
LockedQueue< Packets::GamePacketPtr > m_outQueue;
|
LockedQueue< Packets::GamePacketPtr > m_outQueue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ConnectionType m_conType;
|
ConnectionType m_conType;
|
||||||
|
|
||||||
GameConnection( HivePtr pHive, AcceptorPtr pAcceptor );
|
GameConnection( HivePtr pHive, AcceptorPtr pAcceptor );
|
||||||
|
|
||||||
~GameConnection();
|
~GameConnection();
|
||||||
|
|
||||||
// overwrite the parents onConnect for our game socket needs
|
// overwrite the parents onConnect for our game socket needs
|
||||||
void OnAccept( const std::string & host, uint16_t port ) override;
|
void OnAccept( const std::string& host, uint16_t port ) override;
|
||||||
|
|
||||||
void OnDisconnect() override;
|
void OnDisconnect() override;
|
||||||
|
|
||||||
void OnRecv( std::vector< uint8_t > & buffer ) override;
|
void OnRecv( std::vector< uint8_t >& buffer ) override;
|
||||||
|
|
||||||
void OnError( const boost::system::error_code & error ) override;
|
void OnError( const boost::system::error_code& error ) override;
|
||||||
|
|
||||||
void handlePackets( const Packets::FFXIVARR_PACKET_HEADER& ipcHeader,
|
void handlePackets( const Packets::FFXIVARR_PACKET_HEADER& ipcHeader,
|
||||||
const std::vector< Packets::FFXIVARR_PACKET_RAW >& packetData );
|
const std::vector< Packets::FFXIVARR_PACKET_RAW >& packetData );
|
||||||
|
|
||||||
void queueInPacket( Packets::GamePacketPtr inPacket );
|
void queueInPacket( Packets::GamePacketPtr inPacket );
|
||||||
void queueOutPacket( Packets::GamePacketPtr outPacket );
|
void queueOutPacket( Packets::GamePacketPtr outPacket );
|
||||||
|
|
||||||
void processInQueue();
|
void processInQueue();
|
||||||
void processOutQueue();
|
void processOutQueue();
|
||||||
|
|
||||||
void handlePacket( Packets::GamePacketPtr pPacket );
|
void handlePacket( Packets::GamePacketPtr pPacket );
|
||||||
|
|
||||||
void handleZonePacket( const Packets::GamePacket& pPacket );
|
void handleZonePacket( const Packets::GamePacket& pPacket );
|
||||||
|
|
||||||
void handleChatPacket( const Packets::GamePacket& pPacket );
|
void handleChatPacket( const Packets::GamePacket& pPacket );
|
||||||
|
|
||||||
void sendPackets( Packets::PacketContainer* pPacket );
|
void sendPackets( Packets::PacketContainer* pPacket );
|
||||||
|
|
||||||
void sendSinglePacket( Packets::GamePacket* pPacket );
|
void sendSinglePacket( Packets::GamePacket* pPacket );
|
||||||
|
|
||||||
void injectPacket( const std::string& packetpath, Entity::Player& player );
|
void injectPacket( const std::string& packetpath, Entity::Player& player );
|
||||||
|
|
||||||
DECLARE_HANDLER( initHandler );
|
DECLARE_HANDLER( initHandler );
|
||||||
DECLARE_HANDLER( finishLoadingHandler );
|
DECLARE_HANDLER( finishLoadingHandler );
|
||||||
DECLARE_HANDLER( blackListHandler );
|
DECLARE_HANDLER( blackListHandler );
|
||||||
DECLARE_HANDLER( socialListHandler );
|
DECLARE_HANDLER( socialListHandler );
|
||||||
DECLARE_HANDLER( linkshellListHandler );
|
DECLARE_HANDLER( linkshellListHandler );
|
||||||
DECLARE_HANDLER( playTimeHandler );
|
DECLARE_HANDLER( playTimeHandler );
|
||||||
DECLARE_HANDLER( pingHandler );
|
DECLARE_HANDLER( pingHandler );
|
||||||
DECLARE_HANDLER( fcInfoReqHandler );
|
DECLARE_HANDLER( fcInfoReqHandler );
|
||||||
DECLARE_HANDLER( setSearchInfoHandler );
|
DECLARE_HANDLER( setSearchInfoHandler );
|
||||||
DECLARE_HANDLER( reqSearchInfoHandler );
|
DECLARE_HANDLER( reqSearchInfoHandler );
|
||||||
DECLARE_HANDLER( updatePositionHandler );
|
DECLARE_HANDLER( updatePositionHandler );
|
||||||
DECLARE_HANDLER( chatHandler );
|
DECLARE_HANDLER( chatHandler );
|
||||||
DECLARE_HANDLER( zoneLineHandler );
|
DECLARE_HANDLER( zoneLineHandler );
|
||||||
DECLARE_HANDLER( actionHandler );
|
DECLARE_HANDLER( actionHandler );
|
||||||
DECLARE_HANDLER( inventoryModifyHandler );
|
DECLARE_HANDLER( inventoryModifyHandler );
|
||||||
DECLARE_HANDLER( discoveryHandler );
|
DECLARE_HANDLER( discoveryHandler );
|
||||||
DECLARE_HANDLER( eventHandler );
|
DECLARE_HANDLER( eventHandler );
|
||||||
DECLARE_HANDLER( logoutHandler );
|
DECLARE_HANDLER( logoutHandler );
|
||||||
|
|
||||||
DECLARE_HANDLER( cfDutyInfoRequest );
|
DECLARE_HANDLER( cfDutyInfoRequest );
|
||||||
DECLARE_HANDLER( cfRegisterDuty );
|
DECLARE_HANDLER( cfRegisterDuty );
|
||||||
DECLARE_HANDLER( cfRegisterRoulette );
|
DECLARE_HANDLER( cfRegisterRoulette );
|
||||||
DECLARE_HANDLER( cfDutyAccepted );
|
DECLARE_HANDLER( cfDutyAccepted );
|
||||||
|
|
||||||
|
DECLARE_HANDLER( skillHandler );
|
||||||
|
|
||||||
DECLARE_HANDLER( skillHandler );
|
DECLARE_HANDLER( gm1Handler );
|
||||||
|
DECLARE_HANDLER( gm2Handler );
|
||||||
|
|
||||||
DECLARE_HANDLER( gm1Handler );
|
DECLARE_HANDLER( reqEquipDisplayFlagsHandler );
|
||||||
DECLARE_HANDLER( gm2Handler );
|
|
||||||
|
|
||||||
DECLARE_HANDLER( reqEquipDisplayFlagsHandler );
|
DECLARE_HANDLER( performNoteHandler );
|
||||||
|
|
||||||
DECLARE_HANDLER( performNoteHandler );
|
DECLARE_HANDLER( tellHandler );
|
||||||
|
};
|
||||||
DECLARE_HANDLER( tellHandler );
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
} // namespace Network
|
||||||
|
} // namespace Core
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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,198 +45,201 @@ 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 );
|
||||||
uint32_t param11 = inPacket.getValAt< uint32_t >( 0x24 );
|
uint32_t param11 = inPacket.getValAt< uint32_t >( 0x24 );
|
||||||
uint32_t param12 = inPacket.getValAt< uint32_t >( 0x28 );
|
uint32_t param12 = inPacket.getValAt< uint32_t >( 0x28 );
|
||||||
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());
|
switch( commandId )
|
||||||
|
{
|
||||||
|
case 0x01: // Toggle sheathe
|
||||||
|
{
|
||||||
|
if( param11 == 1 )
|
||||||
|
player.setStance( Entity::Actor::Stance::Active );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.setStance( Entity::Actor::Stance::Passive );
|
||||||
|
player.setAutoattack( false );
|
||||||
|
}
|
||||||
|
|
||||||
switch( commandId )
|
player.sendToInRangeSet( ActorControlPacket142( player.getId(), 0, param11, 1 ) );
|
||||||
{
|
|
||||||
case 0x01: // Toggle sheathe
|
|
||||||
{
|
|
||||||
if ( param11 == 1 )
|
|
||||||
player.setStance( Entity::Actor::Stance::Active );
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.setStance( Entity::Actor::Stance::Passive );
|
|
||||||
player.setAutoattack( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
player.sendToInRangeSet( ActorControlPacket142( player.getId(), 0, param11, 1 ) );
|
break;
|
||||||
|
}
|
||||||
|
case 0x02: // Toggle auto-attack
|
||||||
|
{
|
||||||
|
if( param11 == 1 )
|
||||||
|
{
|
||||||
|
player.setAutoattack( true );
|
||||||
|
player.setStance( Entity::Actor::Stance::Active );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
player.setAutoattack( false );
|
||||||
|
|
||||||
break;
|
player.sendToInRangeSet( ActorControlPacket142( player.getId(), 1, param11, 1 ) );
|
||||||
}
|
|
||||||
case 0x02: // Toggle auto-attack
|
|
||||||
{
|
|
||||||
if ( param11 == 1 )
|
|
||||||
{
|
|
||||||
player.setAutoattack( true );
|
|
||||||
player.setStance( Entity::Actor::Stance::Active );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
player.setAutoattack( false );
|
|
||||||
|
|
||||||
player.sendToInRangeSet( ActorControlPacket142( player.getId(), 1, param11, 1 ) );
|
break;
|
||||||
|
}
|
||||||
|
case 0x03: // Change target
|
||||||
|
{
|
||||||
|
|
||||||
break;
|
uint64_t targetId = inPacket.getValAt< uint64_t >( 0x24 );
|
||||||
}
|
player.changeTarget( targetId );
|
||||||
case 0x03: // Change target
|
break;
|
||||||
{
|
}
|
||||||
|
case 0x65:
|
||||||
|
{
|
||||||
|
player.dismount();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 0x68: // Remove status (clicking it off)
|
||||||
|
{
|
||||||
|
// todo: check if status can be removed by client from exd
|
||||||
|
player.removeSingleStatusEffectById( static_cast< uint32_t >( param1 ) );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 0x69: // Cancel cast
|
||||||
|
{
|
||||||
|
if( player.getCurrentAction() )
|
||||||
|
player.getCurrentAction()->setInterrupted();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 0x12E: // Set player title
|
||||||
|
{
|
||||||
|
player.setTitle( static_cast< uint16_t >( param1 ) );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 0x12F: // Get title list
|
||||||
|
{
|
||||||
|
ZoneChannelPacket< FFXIVIpcPlayerTitleList > titleListPacket( player.getId() );
|
||||||
|
memcpy( titleListPacket.data().titleList, player.getTitleList(), sizeof( titleListPacket.data().titleList ) );
|
||||||
|
|
||||||
uint64_t targetId = inPacket.getValAt< uint64_t >( 0x24 );
|
player.queuePacket( titleListPacket );
|
||||||
player.changeTarget( targetId );
|
break;
|
||||||
break;
|
}
|
||||||
}
|
case 0x133: // Update howtos seen
|
||||||
case 0x65:
|
{
|
||||||
{
|
uint32_t howToId = static_cast< uint32_t >( param1 );
|
||||||
player.dismount();
|
player.updateHowtosSeen( howToId );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x68: // Remove status (clicking it off)
|
case 0x1F4: // emote
|
||||||
{
|
{
|
||||||
// todo: check if status can be removed by client from exd
|
uint64_t targetId = player.getTargetId();
|
||||||
player.removeSingleStatusEffectById( static_cast< uint32_t >( param1 ) );
|
uint32_t emoteId = inPacket.getValAt< uint32_t >( 0x24 );
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 0x69: // Cancel cast
|
|
||||||
{
|
|
||||||
if( player.getCurrentAction() )
|
|
||||||
player.getCurrentAction()->setInterrupted();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 0x12E: // Set player title
|
|
||||||
{
|
|
||||||
player.setTitle( static_cast< uint16_t >( param1 ) );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 0x12F: // Get title list
|
|
||||||
{
|
|
||||||
ZoneChannelPacket< FFXIVIpcPlayerTitleList > titleListPacket( player.getId() );
|
|
||||||
memcpy( titleListPacket.data().titleList, player.getTitleList(), sizeof( titleListPacket.data().titleList ) );
|
|
||||||
|
|
||||||
player.queuePacket( titleListPacket );
|
player.sendToInRangeSet( ActorControlPacket144( player.getId(), Emote, emoteId, 0, 0, 0, targetId ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x133: // Update howtos seen
|
case 0xC8: // return dead
|
||||||
{
|
{
|
||||||
uint32_t howToId = static_cast< uint32_t >( param1 );
|
switch( static_cast< ResurrectType >( param1 ) )
|
||||||
player.updateHowtosSeen( howToId );
|
{
|
||||||
break;
|
case ResurrectType::RaiseSpell:
|
||||||
}
|
// todo: handle raise case (set position to raiser, apply weakness status, set hp/mp/tp as well as packet)
|
||||||
case 0x1F4: // emote
|
player.returnToHomepoint();
|
||||||
{
|
break;
|
||||||
uint64_t targetId = player.getTargetId();
|
case ResurrectType::Return:
|
||||||
uint32_t emoteId = inPacket.getValAt< uint32_t >( 0x24 );
|
player.returnToHomepoint();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 0xC9: // Finish zoning
|
||||||
|
{
|
||||||
|
switch( player.getZoningType() )
|
||||||
|
{
|
||||||
|
case ZoneingType::None:
|
||||||
|
player.sendToInRangeSet( ActorControlPacket143( player.getId(), ZoneIn, 0x01 ), true );
|
||||||
|
break;
|
||||||
|
case ZoneingType::Teleport:
|
||||||
|
player.sendToInRangeSet( ActorControlPacket143( player.getId(), ZoneIn, 0x01, 0, 0, 110 ), true );
|
||||||
|
break;
|
||||||
|
case ZoneingType::Return:
|
||||||
|
case ZoneingType::ReturnDead:
|
||||||
|
{
|
||||||
|
if( player.getStatus() == Entity::Actor::ActorStatus::Dead )
|
||||||
|
{
|
||||||
|
player.resetHp();
|
||||||
|
player.resetMp();
|
||||||
|
player.setStatus( Entity::Actor::ActorStatus::Idle );
|
||||||
|
|
||||||
player.sendToInRangeSet( ActorControlPacket144( player.getId(), Emote, emoteId, 0, 0, 0, targetId ) );
|
player.sendToInRangeSet( ActorControlPacket143( player.getId(), ZoneIn, 0x01, 0x01, 0, 111 ), true );
|
||||||
break;
|
player.sendToInRangeSet(
|
||||||
}
|
ActorControlPacket142( player.getId(), SetStatus,
|
||||||
case 0xC8: // return dead
|
static_cast< uint8_t >( Entity::Actor::ActorStatus::Idle ) ),
|
||||||
{
|
true );
|
||||||
switch ( static_cast < ResurrectType >( param1 ) )
|
}
|
||||||
{
|
else
|
||||||
case ResurrectType::RaiseSpell:
|
player.sendToInRangeSet( ActorControlPacket143( player.getId(), ZoneIn, 0x01, 0x00, 0, 111 ), true );
|
||||||
// todo: handle raise case (set position to raiser, apply weakness status, set hp/mp/tp as well as packet)
|
}
|
||||||
player.returnToHomepoint();
|
break;
|
||||||
break;
|
case ZoneingType::FadeIn:
|
||||||
case ResurrectType::Return:
|
break;
|
||||||
player.returnToHomepoint();
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
player.setZoningType( Common::ZoneingType::None );
|
||||||
case 0xC9: // Finish zoning
|
|
||||||
{
|
|
||||||
switch( player.getZoningType() )
|
|
||||||
{
|
|
||||||
case ZoneingType::None:
|
|
||||||
player.sendToInRangeSet( ActorControlPacket143( player.getId(), ZoneIn, 0x01 ), true );
|
|
||||||
break;
|
|
||||||
case ZoneingType::Teleport:
|
|
||||||
player.sendToInRangeSet( ActorControlPacket143( player.getId(), ZoneIn, 0x01, 0, 0, 110 ), true );
|
|
||||||
break;
|
|
||||||
case ZoneingType::Return:
|
|
||||||
case ZoneingType::ReturnDead:
|
|
||||||
{
|
|
||||||
if( player.getStatus() == Entity::Actor::ActorStatus::Dead )
|
|
||||||
{
|
|
||||||
player.resetHp();
|
|
||||||
player.resetMp();
|
|
||||||
player.setStatus( Entity::Actor::ActorStatus::Idle );
|
|
||||||
|
|
||||||
player.sendToInRangeSet( ActorControlPacket143( player.getId(), ZoneIn, 0x01, 0x01, 0, 111 ), true );
|
player.unsetStateFlag( PlayerStateFlag::BetweenAreas );
|
||||||
player.sendToInRangeSet( ActorControlPacket142( player.getId(), SetStatus, static_cast< uint8_t >( Entity::Actor::ActorStatus::Idle ) ), true );
|
player.unsetStateFlag( PlayerStateFlag::BetweenAreas1 );
|
||||||
}
|
player.sendStateFlags();
|
||||||
else
|
break;
|
||||||
player.sendToInRangeSet( ActorControlPacket143( player.getId(), ZoneIn, 0x01, 0x00, 0, 111 ), true );
|
}
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ZoneingType::FadeIn:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
player.setZoningType( Common::ZoneingType::None );
|
case 0xCA: // Teleport
|
||||||
|
{
|
||||||
|
// TODO: only register this action if enough gil is in possession
|
||||||
|
auto targetAetheryte = g_exdData.getAetheryteInfo( param11 );
|
||||||
|
|
||||||
player.unsetStateFlag( PlayerStateFlag::BetweenAreas );
|
if( targetAetheryte )
|
||||||
player.unsetStateFlag( PlayerStateFlag::BetweenAreas1 );
|
{
|
||||||
player.sendStateFlags();
|
auto fromAetheryte = g_exdData.getAetheryteInfo( g_exdData.m_zoneInfoMap[player.getZoneId()].aetheryte_index );
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 0xCA: // Teleport
|
// calculate cost - does not apply for favorite points or homepoints neither checks for aether tickets
|
||||||
{
|
auto cost =
|
||||||
// TODO: only register this action if enough gil is in possession
|
static_cast< uint16_t >( ( sqrt( pow( fromAetheryte->map_coord_x - targetAetheryte->map_coord_x, 2 ) +
|
||||||
auto targetAetheryte = g_exdData.getAetheryteInfo( param11 );
|
pow( fromAetheryte->map_coord_y - targetAetheryte->map_coord_y, 2 ) ) /
|
||||||
|
2 ) +
|
||||||
|
100 );
|
||||||
|
|
||||||
if( targetAetheryte )
|
// cap at 999 gil
|
||||||
{
|
cost = cost > uint16_t{ 999 } ? uint16_t{ 999 } : cost;
|
||||||
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
|
bool insufficientGil = player.getCurrency( Inventory::CurrencyType::Gil ) < cost;
|
||||||
auto cost = static_cast< uint16_t > ( ( sqrt( pow( fromAetheryte->map_coord_x - targetAetheryte->map_coord_x, 2 ) +
|
// todo: figure out what param1 really does
|
||||||
pow( fromAetheryte->map_coord_y - targetAetheryte->map_coord_y, 2 ) ) / 2 ) + 100 );
|
player.queuePacket( ActorControlPacket143( player.getId(), TeleportStart, insufficientGil ? 2 : 0, param11 ) );
|
||||||
|
|
||||||
// cap at 999 gil
|
if( !insufficientGil )
|
||||||
cost = cost > uint16_t{999} ? uint16_t{999} : cost;
|
{
|
||||||
|
Action::ActionTeleportPtr pActionTeleport(
|
||||||
bool insufficientGil = player.getCurrency( Inventory::CurrencyType::Gil ) < cost;
|
new Action::ActionTeleport( player.getAsPlayer(), param11, cost ) );
|
||||||
// todo: figure out what param1 really does
|
player.setCurrentAction( pActionTeleport );
|
||||||
player.queuePacket( ActorControlPacket143( player.getId(), TeleportStart, insufficientGil ? 2 : 0, param11 ) );
|
}
|
||||||
|
}
|
||||||
if( !insufficientGil )
|
break;
|
||||||
{
|
}
|
||||||
Action::ActionTeleportPtr pActionTeleport( new Action::ActionTeleport( player.getAsPlayer(), param11, cost ) );
|
case 0x1B5: // Dye item
|
||||||
player.setCurrentAction( pActionTeleport );
|
{
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
break;
|
default:
|
||||||
}
|
{
|
||||||
case 0x1B5: // Dye item
|
g_log.debug( "[" + std::to_string( m_pSession->getId() ) + "] Unhandled action: " +
|
||||||
{
|
boost::str( boost::format( "%|04X|" ) % ( uint32_t )( commandId & 0xFFFF ) ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
}
|
||||||
{
|
|
||||||
g_log.debug( "[" + std::to_string( m_pSession->getId() ) + "] Unhandled action: " +
|
|
||||||
boost::str( boost::format( "%|04X|" ) % (uint32_t) ( commandId & 0xFFFF ) ) );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,14 +21,12 @@ 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() );
|
||||||
|
|
||||||
auto penaltyMinutes = player.getCFPenaltyMinutes();
|
auto penaltyMinutes = player.getCFPenaltyMinutes();
|
||||||
if (penaltyMinutes > 255)
|
if( penaltyMinutes > 255 )
|
||||||
{
|
{
|
||||||
// cap it since it's uint8_t in packets
|
// cap it since it's uint8_t in packets
|
||||||
penaltyMinutes = 255;
|
penaltyMinutes = 255;
|
||||||
|
@ -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 );
|
||||||
|
@ -52,12 +48,12 @@ void Core::Network::GameConnection::cfRegisterDuty( const Packets::GamePacket& i
|
||||||
auto contentId4 = inPacket.getValAt< uint16_t >( 52 );
|
auto contentId4 = inPacket.getValAt< uint16_t >( 52 );
|
||||||
auto contentId5 = inPacket.getValAt< uint16_t >( 54 );
|
auto contentId5 = inPacket.getValAt< uint16_t >( 54 );
|
||||||
|
|
||||||
player.sendDebug("Duty register request");
|
player.sendDebug( "Duty register request" );
|
||||||
player.sendDebug("ContentId1" + std::to_string(contentId1));
|
player.sendDebug( "ContentId1" + std::to_string( contentId1 ) );
|
||||||
player.sendDebug("ContentId2" + std::to_string(contentId2));
|
player.sendDebug( "ContentId2" + std::to_string( contentId2 ) );
|
||||||
player.sendDebug("ContentId3" + std::to_string(contentId3));
|
player.sendDebug( "ContentId3" + std::to_string( contentId3 ) );
|
||||||
player.sendDebug("ContentId4" + std::to_string(contentId4));
|
player.sendDebug( "ContentId4" + std::to_string( contentId4 ) );
|
||||||
player.sendDebug("ContentId5" + std::to_string(contentId5));
|
player.sendDebug( "ContentId5" + std::to_string( contentId5 ) );
|
||||||
|
|
||||||
// let's cancel it because otherwise you can't register it again
|
// let's cancel it because otherwise you can't register it again
|
||||||
ZoneChannelPacket< FFXIVIpcCFNotify > cfCancelPacket( player.getId() );
|
ZoneChannelPacket< FFXIVIpcCFNotify > cfCancelPacket( player.getId() );
|
||||||
|
@ -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" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 );
|
||||||
|
@ -144,14 +142,8 @@ void Core::Network::GameConnection::eventHandler( const Packets::GamePacket& inP
|
||||||
linkshellEvent.data().unknown1 = 0x15a;
|
linkshellEvent.data().unknown1 = 0x15a;
|
||||||
player.queuePacket( linkshellEvent );
|
player.queuePacket( linkshellEvent );
|
||||||
|
|
||||||
// abortEventFunc( pPlayer, 0, eventId );
|
// abortEventFunc( pPlayer, 0, eventId );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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();
|
||||||
|
@ -141,7 +139,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
|
||||||
player.sendNotice( "Race for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
|
player.sendNotice( "Race for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
|
||||||
targetPlayer->spawn( targetPlayer );
|
targetPlayer->spawn( targetPlayer );
|
||||||
auto inRange = targetPlayer->getInRangeActors();
|
auto inRange = targetPlayer->getInRangeActors();
|
||||||
for ( auto actor : inRange )
|
for( auto actor : inRange )
|
||||||
{
|
{
|
||||||
targetPlayer->despawn( actor->getAsPlayer() );
|
targetPlayer->despawn( actor->getAsPlayer() );
|
||||||
targetPlayer->spawn( actor->getAsPlayer() );
|
targetPlayer->spawn( actor->getAsPlayer() );
|
||||||
|
@ -154,7 +152,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
|
||||||
player.sendNotice( "Tribe for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
|
player.sendNotice( "Tribe for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
|
||||||
targetPlayer->spawn( targetPlayer );
|
targetPlayer->spawn( targetPlayer );
|
||||||
auto inRange = targetPlayer->getInRangeActors();
|
auto inRange = targetPlayer->getInRangeActors();
|
||||||
for ( auto actor : inRange )
|
for( auto actor : inRange )
|
||||||
{
|
{
|
||||||
targetPlayer->despawn( actor->getAsPlayer() );
|
targetPlayer->despawn( actor->getAsPlayer() );
|
||||||
targetPlayer->spawn( actor->getAsPlayer() );
|
targetPlayer->spawn( actor->getAsPlayer() );
|
||||||
|
@ -167,7 +165,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
|
||||||
player.sendNotice( "Sex for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
|
player.sendNotice( "Sex for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
|
||||||
targetPlayer->spawn( targetPlayer );
|
targetPlayer->spawn( targetPlayer );
|
||||||
auto inRange = targetActor->getInRangeActors();
|
auto inRange = targetActor->getInRangeActors();
|
||||||
for ( auto actor : inRange )
|
for( auto actor : inRange )
|
||||||
{
|
{
|
||||||
targetPlayer->despawn( actor->getAsPlayer() );
|
targetPlayer->despawn( actor->getAsPlayer() );
|
||||||
targetPlayer->spawn( actor->getAsPlayer() );
|
targetPlayer->spawn( actor->getAsPlayer() );
|
||||||
|
@ -184,30 +182,27 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
|
||||||
{
|
{
|
||||||
targetPlayer->getCurrentZone()->setWeatherOverride( param1 );
|
targetPlayer->getCurrentZone()->setWeatherOverride( param1 );
|
||||||
player.sendNotice( "Weather in Zone \"" + targetPlayer->getCurrentZone()->getName() + "\" of " +
|
player.sendNotice( "Weather in Zone \"" + targetPlayer->getCurrentZone()->getName() + "\" of " +
|
||||||
targetPlayer->getName() + " set in range." );
|
targetPlayer->getName() + " set in range." );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GmCommand::Call:
|
case GmCommand::Call:
|
||||||
{
|
{
|
||||||
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() ) +
|
"\nSearchMessage: " + targetPlayer->getSearchMessage() +
|
||||||
"\nExp: " + std::to_string( targetPlayer->getExp() ) +
|
"\nPlayTime: " + std::to_string( targetPlayer->getPlayTime() ) );
|
||||||
"\nSearchMessage: " + targetPlayer->getSearchMessage() +
|
|
||||||
"\nPlayTime: " + std::to_string( targetPlayer->getPlayTime() ) );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GmCommand::Speed:
|
case GmCommand::Speed:
|
||||||
|
@ -236,9 +231,9 @@ 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;
|
||||||
}
|
}
|
||||||
|
@ -268,32 +263,30 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
|
||||||
}
|
}
|
||||||
case GmCommand::Inv:
|
case GmCommand::Inv:
|
||||||
{
|
{
|
||||||
if ( targetActor->getInvincibilityType() == Common::InvincibilityType::InvincibilityRefill )
|
if( targetActor->getInvincibilityType() == Common::InvincibilityType::InvincibilityRefill )
|
||||||
targetActor->setInvincibilityType( Common::InvincibilityType::InvincibilityNone );
|
targetActor->setInvincibilityType( Common::InvincibilityType::InvincibilityNone );
|
||||||
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:
|
||||||
{
|
{
|
||||||
if ( param1 == 1 )
|
if( param1 == 1 )
|
||||||
{
|
{
|
||||||
if ( param2 == 0 )
|
if( param2 == 0 )
|
||||||
{
|
{
|
||||||
for ( uint8_t i = 0; i < 255; i++ )
|
for( uint8_t i = 0; i < 255; i++ )
|
||||||
targetActor->getAsPlayer()->learnSong( i, 0 );
|
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
|
||||||
{
|
{
|
||||||
targetActor->getAsPlayer()->learnSong( param2, 0 );
|
targetActor->getAsPlayer()->learnSong( param2, 0 );
|
||||||
player.sendNotice( "Song " + std::to_string( param2 ) + " for " + targetPlayer->getName() +
|
player.sendNotice( "Song " + std::to_string( param2 ) + " for " + targetPlayer->getName() +
|
||||||
" was turned on." );
|
" was turned on." );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,16 +319,15 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
|
||||||
{
|
{
|
||||||
uint32_t gil = targetPlayer->getCurrency( 1 );
|
uint32_t gil = targetPlayer->getCurrency( 1 );
|
||||||
|
|
||||||
if ( gil < param1 )
|
if( gil < param1 )
|
||||||
{
|
{
|
||||||
player.sendUrgent( "Player does not have enough Gil(" + std::to_string( gil ) + ")" );
|
player.sendUrgent( "Player does not have enough Gil(" + std::to_string( gil ) + ")" );
|
||||||
}
|
}
|
||||||
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,35 +359,34 @@ 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:
|
||||||
{
|
{
|
||||||
if ( param1 == 0 )
|
if( param1 == 0 )
|
||||||
{
|
{
|
||||||
if ( param2 == 0 )
|
if( param2 == 0 )
|
||||||
{
|
{
|
||||||
for ( uint8_t i = 0; i < 255; i++ )
|
for( uint8_t i = 0; i < 255; i++ )
|
||||||
targetActor->getAsPlayer()->registerAetheryte( i );
|
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
|
||||||
{
|
{
|
||||||
targetActor->getAsPlayer()->registerAetheryte( param2 );
|
targetActor->getAsPlayer()->registerAetheryte( param2 );
|
||||||
player.sendNotice( "Aetheryte " + std::to_string( param2 ) + " for " + targetPlayer->getName() +
|
player.sendNotice( "Aetheryte " + std::to_string( param2 ) + " for " + targetPlayer->getName() +
|
||||||
" was turned on." );
|
" was turned on." );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,7 +395,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
|
||||||
case GmCommand::Teri:
|
case GmCommand::Teri:
|
||||||
{
|
{
|
||||||
auto zoneInfo = g_zoneMgr.getZone( param1 );
|
auto zoneInfo = g_zoneMgr.getZone( param1 );
|
||||||
if ( !zoneInfo )
|
if( !zoneInfo )
|
||||||
{
|
{
|
||||||
player.sendUrgent( "Invalid zone " + std::to_string( param1 ) );
|
player.sendUrgent( "Invalid zone " + std::to_string( param1 ) );
|
||||||
}
|
}
|
||||||
|
@ -412,16 +403,17 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
|
||||||
{
|
{
|
||||||
targetPlayer->setPosition( targetPlayer->getPos() );
|
targetPlayer->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;
|
||||||
}
|
}
|
||||||
|
@ -502,7 +495,7 @@ void Core::Network::GameConnection::gm2Handler( const Packets::GamePacket& inPac
|
||||||
player.setZone( targetPlayer->getZoneId() );
|
player.setZone( targetPlayer->getZoneId() );
|
||||||
}
|
}
|
||||||
player.changePosition( targetActor->getPos().x, targetActor->getPos().y, targetActor->getPos().z,
|
player.changePosition( targetActor->getPos().x, targetActor->getPos().y, targetActor->getPos().z,
|
||||||
targetActor->getRotation() );
|
targetActor->getRotation() );
|
||||||
player.sendNotice( "Jumping to " + targetPlayer->getName() );
|
player.sendNotice( "Jumping to " + 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 ) );
|
||||||
|
|
||||||
|
@ -59,39 +57,35 @@ void Core::Network::GameConnection::inventoryModifyHandler( const Packets::GameP
|
||||||
switch( action )
|
switch( action )
|
||||||
{
|
{
|
||||||
|
|
||||||
case 0x07: // discard item action
|
case 0x07: // discard item action
|
||||||
{
|
{
|
||||||
player.getInventory()->discardItem( fromContainer, fromSlot );
|
player.getInventory()->discardItem( fromContainer, fromSlot );
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x08: // move item action
|
||||||
|
{
|
||||||
|
player.getInventory()->moveItem( fromContainer, fromSlot, toContainer, toSlot );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x09: // swap item action
|
||||||
|
{
|
||||||
|
player.getInventory()->swapItem( fromContainer, fromSlot, toContainer, toSlot );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x0C: // merge stack action
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x0A: // split stack action
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x08: // move item action
|
|
||||||
{
|
|
||||||
player.getInventory()->moveItem( fromContainer, fromSlot, toContainer, toSlot );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x09: // swap item action
|
|
||||||
{
|
|
||||||
player.getInventory()->swapItem( fromContainer, fromSlot, toContainer, toSlot );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x0C: // merge stack action
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x0A: // split stack action
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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() )
|
||||||
|
@ -142,13 +137,13 @@ void Core::Network::GameConnection::updatePositionHandler( const Packets::GamePa
|
||||||
uint16_t bit16 : 1;
|
uint16_t bit16 : 1;
|
||||||
} IPC_OP_019AB;
|
} IPC_OP_019AB;
|
||||||
|
|
||||||
uint16_t flags = inPacket.getValAt<uint16_t>( 0x28 );
|
uint16_t flags = inPacket.getValAt< uint16_t >( 0x28 );
|
||||||
memcpy( &IPC_OP_019AB, &flags, 2 );
|
memcpy( &IPC_OP_019AB, &flags, 2 );
|
||||||
|
|
||||||
uint32_t flags1 = inPacket.getValAt<uint32_t>( 0x24 );
|
uint32_t flags1 = inPacket.getValAt< uint32_t >( 0x24 );
|
||||||
memcpy( &IPC_OP_019A, &flags1, 4 );
|
memcpy( &IPC_OP_019A, &flags1, 4 );
|
||||||
|
|
||||||
//g_log.Log(LoggingSeverity::debug, "" + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit1)
|
// g_log.Log(LoggingSeverity::debug, "" + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit1)
|
||||||
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit2)
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit2)
|
||||||
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit3)
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit3)
|
||||||
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit4)
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit4)
|
||||||
|
@ -166,26 +161,25 @@ void Core::Network::GameConnection::updatePositionHandler( const Packets::GamePa
|
||||||
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit16)
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit16)
|
||||||
// + " " + boost::lexical_cast<std::string>((int)flags));
|
// + " " + boost::lexical_cast<std::string>((int)flags));
|
||||||
|
|
||||||
//g_log.Log(LoggingSeverity::debug, "\n" + boost::lexical_cast<std::string>((int)IPC_OP_019A.specialMovement) + "\n"
|
// g_log.Log(LoggingSeverity::debug, "\n" + boost::lexical_cast<std::string>((int)IPC_OP_019A.specialMovement) + "\n"
|
||||||
// + boost::lexical_cast<std::string>((int)IPC_OP_019A.strafe) + "\n"
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019A.strafe) + "\n"
|
||||||
// + boost::lexical_cast<std::string>((int)IPC_OP_019A.moveBackward) + "\n"
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019A.moveBackward) + "\n"
|
||||||
// + boost::lexical_cast<std::string>((int)IPC_OP_019A.strafeRight));
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019A.strafeRight));
|
||||||
|
|
||||||
//g_log.Log(LoggingSeverity::debug, pInPacket->toString());
|
// g_log.Log(LoggingSeverity::debug, pInPacket->toString());
|
||||||
|
|
||||||
//pInPacket->debugPrint();
|
// pInPacket->debugPrint();
|
||||||
|
|
||||||
bool bPosChanged = false;
|
bool bPosChanged = false;
|
||||||
if( ( player.getPos().x != inPacket.getValAt< float >( 0x2c ) ) ||
|
if( ( player.getPos().x != inPacket.getValAt< float >( 0x2c ) ) ||
|
||||||
( player.getPos().y != inPacket.getValAt< float >( 0x30 ) ) ||
|
( player.getPos().y != inPacket.getValAt< float >( 0x30 ) ) ||
|
||||||
( player.getPos().z != inPacket.getValAt< float >( 0x34 ) ) )
|
( player.getPos().z != inPacket.getValAt< float >( 0x34 ) ) )
|
||||||
bPosChanged = true;
|
bPosChanged = true;
|
||||||
if( !bPosChanged && player.getRotation() == inPacket.getValAt< float >( 0x20 ) )
|
if( !bPosChanged && player.getRotation() == inPacket.getValAt< float >( 0x20 ) )
|
||||||
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 );
|
||||||
|
|
||||||
|
@ -313,7 +306,7 @@ void Core::Network::GameConnection::zoneLineHandler( const Packets::GamePacket&
|
||||||
ZoneChannelPacket< FFXIVIpcPrepareZoning > preparePacket( player.getId() );
|
ZoneChannelPacket< FFXIVIpcPrepareZoning > preparePacket( player.getId() );
|
||||||
preparePacket.data().targetZone = targetZone;
|
preparePacket.data().targetZone = targetZone;
|
||||||
|
|
||||||
//ActorControlPacket143 controlPacket( pPlayer, ActorControlType::DespawnZoneScreenMsg,
|
// ActorControlPacket143 controlPacket( pPlayer, ActorControlType::DespawnZoneScreenMsg,
|
||||||
// 0x03, player.getId(), 0x01, targetZone );
|
// 0x03, player.getId(), 0x01, targetZone );
|
||||||
player.queuePacket( preparePacket );
|
player.queuePacket( preparePacket );
|
||||||
}
|
}
|
||||||
|
@ -327,18 +320,17 @@ void Core::Network::GameConnection::zoneLineHandler( const Packets::GamePacket&
|
||||||
targetZone = pZone->getId();
|
targetZone = pZone->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
player.performZoning( targetZone, targetPos, rotation);
|
player.performZoning( targetZone, targetPos, rotation );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Core::Network::GameConnection::discoveryHandler( const Packets::GamePacket& inPacket, Entity::Player& player )
|
||||||
void Core::Network::GameConnection::discoveryHandler( const Packets::GamePacket& inPacket,
|
|
||||||
Entity::Player& player )
|
|
||||||
{
|
{
|
||||||
uint32_t ref_position_id = inPacket.getValAt< uint32_t >( 0x20 );
|
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,24 +363,19 @@ 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 );
|
||||||
|
|
||||||
ZoneChannelPacket< FFXIVIpcBlackList > blackListPacket( player.getId() );
|
ZoneChannelPacket< FFXIVIpcBlackList > blackListPacket( player.getId() );
|
||||||
blackListPacket.data().sequence = count;
|
blackListPacket.data().sequence = count;
|
||||||
// TODO: Fill with actual blacklist data
|
// TODO: Fill with actual blacklist data
|
||||||
//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 );
|
||||||
|
@ -453,18 +432,17 @@ void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket
|
||||||
listPacket.data().entries[0].zoneId = player.getCurrentZone()->getId();
|
listPacket.data().entries[0].zoneId = player.getCurrentZone()->getId();
|
||||||
listPacket.data().entries[0].zoneId1 = 0x0100;
|
listPacket.data().entries[0].zoneId1 = 0x0100;
|
||||||
// TODO: no idea what this does
|
// TODO: no idea what this does
|
||||||
//listPacket.data().entries[0].one = 1;
|
// listPacket.data().entries[0].one = 1;
|
||||||
|
|
||||||
memcpy( listPacket.data().entries[0].name, player.getName().c_str(), strlen( player.getName().c_str() ) );
|
memcpy( listPacket.data().entries[0].name, player.getName().c_str(), strlen( player.getName().c_str() ) );
|
||||||
|
|
||||||
// TODO: actually store and read language from somewhere
|
// TODO: actually store and read language from somewhere
|
||||||
listPacket.data().entries[0].bytes1[0] = 0x01;//flags (lang)
|
listPacket.data().entries[0].bytes1[0] = 0x01; // flags (lang)
|
||||||
// TODO: these flags need to be figured out
|
// TODO: these flags need to be figured out
|
||||||
//listPacket.data().entries[0].bytes1[1] = 0x00;//flags
|
// listPacket.data().entries[0].bytes1[1] = 0x00;//flags
|
||||||
listPacket.data().entries[0].onlineStatusMask = player.getOnlineStatusMask();
|
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 ) );
|
||||||
|
@ -493,13 +468,13 @@ void Core::Network::GameConnection::chatHandler( const Packets::GamePacket& inPa
|
||||||
if( chatString.at( 0 ) == '!' )
|
if( chatString.at( 0 ) == '!' )
|
||||||
{
|
{
|
||||||
// execute game console command
|
// execute game console command
|
||||||
g_gameCommandMgr.execCommand( const_cast< char * >( chatString.c_str() ) + 1, player );
|
g_gameCommandMgr.execCommand( const_cast< char* >( chatString.c_str() ) + 1, player );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatType chatType = static_cast< ChatType >( inPacket.getValAt< uint8_t >( 0x38 ) );
|
ChatType chatType = static_cast< ChatType >( inPacket.getValAt< uint8_t >( 0x38 ) );
|
||||||
|
|
||||||
//ToDo, need to implement sending GM chat types.
|
// ToDo, need to implement sending GM chat types.
|
||||||
ChatPacket chatPacket( player, chatType, chatString );
|
ChatPacket chatPacket( player, chatType, chatString );
|
||||||
|
|
||||||
switch( chatType )
|
switch( chatType )
|
||||||
|
@ -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 );
|
||||||
|
@ -591,15 +562,13 @@ void Core::Network::GameConnection::tellHandler( const Packets::GamePacket& inPa
|
||||||
strcpy( tellPacket.data().msg, msg.c_str() );
|
strcpy( tellPacket.data().msg, msg.c_str() );
|
||||||
strcpy( tellPacket.data().receipientName, player.getName().c_str() );
|
strcpy( tellPacket.data().receipientName, player.getName().c_str() );
|
||||||
// TODO: do these have a meaning?
|
// TODO: do these have a meaning?
|
||||||
//tellPacket.data().u1 = 0x92CD7337;
|
// tellPacket.data().u1 = 0x92CD7337;
|
||||||
//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() );
|
||||||
|
|
||||||
|
|
|
@ -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,92 +38,86 @@ 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 );
|
||||||
|
|
||||||
uint32_t action = inPacket.getValAt< uint32_t >( 0x24 );
|
uint32_t action = inPacket.getValAt< uint32_t >( 0x24 );
|
||||||
uint32_t useCount = inPacket.getValAt< uint32_t >( 0x28 );
|
uint32_t useCount = inPacket.getValAt< uint32_t >( 0x28 );
|
||||||
|
|
||||||
uint64_t targetId = inPacket.getValAt< uint64_t >( 0x30 );
|
uint64_t targetId = inPacket.getValAt< uint64_t >( 0x30 );
|
||||||
|
|
||||||
player.sendDebug( "Skill type:" + std::to_string( type ) );
|
player.sendDebug( "Skill type:" + std::to_string( type ) );
|
||||||
|
|
||||||
switch( type )
|
switch( type )
|
||||||
{
|
{
|
||||||
case Common::SkillType::Normal:
|
case Common::SkillType::Normal:
|
||||||
|
|
||||||
if( action < 1000000 ) // normal action
|
if( action < 1000000 ) // normal action
|
||||||
{
|
{
|
||||||
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 ) );
|
||||||
|
|
||||||
if( action == 5 )
|
if( action == 5 )
|
||||||
{
|
{
|
||||||
auto currentAction = player.getCurrentAction();
|
auto currentAction = player.getCurrentAction();
|
||||||
|
|
||||||
// we should always have an action here, if not there is a bug
|
// we should always have an action here, if not there is a bug
|
||||||
assert( currentAction );
|
assert( currentAction );
|
||||||
currentAction->onStart();
|
currentAction->onStart();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Core::Entity::ActorPtr targetActor = player.getAsPlayer();
|
Core::Entity::ActorPtr targetActor = player.getAsPlayer();
|
||||||
if( targetId != player.getId() )
|
if( targetId != player.getId() )
|
||||||
{
|
{
|
||||||
targetActor = player.lookupTargetById( targetId );
|
targetActor = player.lookupTargetById( targetId );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !player.actionHasCastTime( action ) )
|
if( !player.actionHasCastTime( action ) )
|
||||||
{
|
{
|
||||||
g_scriptMgr.onCastFinish( player, targetActor, action );
|
g_scriptMgr.onCastFinish( player, targetActor, action );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Action::ActionCastPtr pActionCast( new Action::ActionCast( player.getAsPlayer(), targetActor, action ) );
|
Action::ActionCastPtr pActionCast( new Action::ActionCast( player.getAsPlayer(), targetActor, action ) );
|
||||||
player.setCurrentAction( pActionCast );
|
player.setCurrentAction( pActionCast );
|
||||||
player.sendDebug( "setCurrentAction()" );
|
player.sendDebug( "setCurrentAction()" );
|
||||||
player.getCurrentAction()->onStart();
|
player.getCurrentAction()->onStart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( action < 2000000 ) // craft action
|
else if( action < 2000000 ) // craft action
|
||||||
{
|
{
|
||||||
|
}
|
||||||
}
|
else if( action < 3000000 ) // item action
|
||||||
else if( action < 3000000 ) // item action
|
{
|
||||||
{
|
auto info = g_exdData.getEventItemInfo( action );
|
||||||
auto info = g_exdData.getEventItemInfo( action );
|
if( info )
|
||||||
if( info )
|
{
|
||||||
{
|
|
||||||
g_log.debug( info->name );
|
g_log.debug( info->name );
|
||||||
g_scriptMgr.onEventItem( player, action, info->eventId, info->castTime, targetId );
|
g_scriptMgr.onEventItem( player, action, info->eventId, info->castTime, targetId );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( action > 3000000 ) // unknown
|
else if( action > 3000000 ) // unknown
|
||||||
{
|
{
|
||||||
|
}
|
||||||
|
|
||||||
}
|
break;
|
||||||
|
|
||||||
break;
|
case Common::SkillType::MountSkill:
|
||||||
|
|
||||||
case Common::SkillType::MountSkill:
|
player.sendDebug( "Request mount " + std::to_string( action ) );
|
||||||
|
|
||||||
player.sendDebug( "Request mount " + std::to_string( action ) );
|
Action::ActionMountPtr pActionMount( new Action::ActionMount( player.getAsPlayer(), action ) );
|
||||||
|
player.setCurrentAction( pActionMount );
|
||||||
Action::ActionMountPtr pActionMount( new Action::ActionMount( player.getAsPlayer(), action ) );
|
player.sendDebug( "setCurrentAction()" );
|
||||||
player.setCurrentAction( pActionMount );
|
player.getCurrentAction()->onStart();
|
||||||
player.sendDebug( "setCurrentAction()" );
|
|
||||||
player.getCurrentAction()->onStart();
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,49 +1,43 @@
|
||||||
#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 {
|
||||||
namespace Packets {
|
namespace Packets {
|
||||||
namespace Server {
|
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, uint16_t category, uint32_t param1 = 0, uint32_t param2 = 0,
|
||||||
ActorControlPacket142( uint32_t actorId,
|
uint32_t param3 = 0, uint32_t param4 = 0, uint32_t padding1 = 0 ) :
|
||||||
uint16_t category,
|
ZoneChannelPacket< FFXIVIpcActorControl142 >( actorId, actorId )
|
||||||
uint32_t param1 = 0,
|
{
|
||||||
uint32_t param2 = 0,
|
initialize( category, param1, param2, param3, param4 );
|
||||||
uint32_t param3 = 0,
|
};
|
||||||
uint32_t param4 = 0,
|
|
||||||
uint32_t padding1 = 0 ) :
|
|
||||||
ZoneChannelPacket< FFXIVIpcActorControl142 >( actorId, actorId )
|
|
||||||
{
|
|
||||||
initialize( category, param1, param2, param3, param4 );
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initialize( uint16_t category, uint32_t param1, uint32_t param2, uint32_t param3, uint32_t param4 )
|
void initialize( uint16_t category, uint32_t param1, uint32_t param2, uint32_t param3, uint32_t param4 )
|
||||||
{
|
{
|
||||||
m_data.padding = 0;
|
m_data.padding = 0;
|
||||||
m_data.category = category;
|
m_data.category = category;
|
||||||
m_data.param1 = param1;
|
m_data.param1 = param1;
|
||||||
m_data.param2 = param2;
|
m_data.param2 = param2;
|
||||||
m_data.param3 = param3;
|
m_data.param3 = param3;
|
||||||
m_data.param4 = param4;
|
m_data.param4 = param4;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace Server
|
||||||
}
|
} // namespace Packets
|
||||||
}
|
} // namespace Network
|
||||||
}
|
} // namespace Core
|
||||||
|
|
||||||
#endif /*_ACTORCONTROL142_H*/
|
#endif /*_ACTORCONTROL142_H*/
|
|
@ -1,52 +1,46 @@
|
||||||
#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 {
|
||||||
namespace Packets {
|
namespace Packets {
|
||||||
namespace Server {
|
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, uint16_t category, uint32_t param1 = 0, uint32_t param2 = 0,
|
||||||
ActorControlPacket143( uint32_t actorId,
|
uint32_t param3 = 0, uint32_t param4 = 0, uint32_t param5 = 0,
|
||||||
uint16_t category,
|
uint32_t padding1 = 0 ) :
|
||||||
uint32_t param1 = 0,
|
ZoneChannelPacket< FFXIVIpcActorControl143 >( actorId, actorId )
|
||||||
uint32_t param2 = 0,
|
{
|
||||||
uint32_t param3 = 0,
|
initialize( category, param1, param2, param3, param4, param5 );
|
||||||
uint32_t param4 = 0,
|
};
|
||||||
uint32_t param5 = 0,
|
|
||||||
uint32_t padding1 = 0 ) :
|
|
||||||
ZoneChannelPacket< FFXIVIpcActorControl143 >( actorId, actorId )
|
|
||||||
{
|
|
||||||
initialize( category, param1, param2, param3, param4, param5 );
|
|
||||||
};
|
|
||||||
|
|
||||||
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.category = category;
|
m_data.padding = 0;
|
||||||
m_data.param1 = param1;
|
m_data.category = category;
|
||||||
m_data.param2 = param2;
|
m_data.param1 = param1;
|
||||||
m_data.param3 = param3;
|
m_data.param2 = param2;
|
||||||
m_data.param4 = param4;
|
m_data.param3 = param3;
|
||||||
m_data.param5 = param5;
|
m_data.param4 = param4;
|
||||||
};
|
m_data.param5 = param5;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
}
|
} // namespace Server
|
||||||
}
|
} // namespace Packets
|
||||||
}
|
} // namespace Network
|
||||||
}
|
} // namespace Core
|
||||||
|
|
||||||
#endif /*_ACTORCONTROL143_H*/
|
#endif /*_ACTORCONTROL143_H*/
|
|
@ -6,45 +6,40 @@
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Network {
|
namespace Network {
|
||||||
namespace Packets {
|
namespace Packets {
|
||||||
namespace Server {
|
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, uint16_t category, uint32_t param1 = 0, uint32_t param2 = 0,
|
||||||
ActorControlPacket144( uint32_t actorId,
|
uint32_t param3 = 0, uint32_t param4 = 0, uint64_t targetId = 0,
|
||||||
uint16_t category,
|
uint32_t padding1 = 0 ) :
|
||||||
uint32_t param1 = 0,
|
ZoneChannelPacket< FFXIVIpcActorControl144 >( actorId, actorId )
|
||||||
uint32_t param2 = 0,
|
{
|
||||||
uint32_t param3 = 0,
|
initialize( category, param1, param2, param3, param4, targetId );
|
||||||
uint32_t param4 = 0,
|
};
|
||||||
uint64_t targetId = 0,
|
|
||||||
uint32_t padding1 = 0 ) :
|
|
||||||
ZoneChannelPacket< FFXIVIpcActorControl144 >( actorId, actorId )
|
|
||||||
{
|
|
||||||
initialize( category, param1, param2, param3, param4, targetId );
|
|
||||||
};
|
|
||||||
|
|
||||||
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.category = category;
|
m_data.padding = 0;
|
||||||
m_data.param1 = param1;
|
m_data.category = category;
|
||||||
m_data.param2 = param2;
|
m_data.param1 = param1;
|
||||||
m_data.param3 = param3;
|
m_data.param2 = param2;
|
||||||
m_data.param4 = param4;
|
m_data.param3 = param3;
|
||||||
m_data.targetId = targetId;
|
m_data.param4 = param4;
|
||||||
};
|
m_data.targetId = targetId;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
}
|
} // namespace Server
|
||||||
}
|
} // namespace Packets
|
||||||
}
|
} // namespace Network
|
||||||
}
|
} // namespace Core
|
||||||
|
|
||||||
#endif /*_ACTORCONTROL144_H*/
|
#endif /*_ACTORCONTROL144_H*/
|
|
@ -1,91 +1,88 @@
|
||||||
#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 {
|
||||||
namespace Packets {
|
namespace Packets {
|
||||||
namespace Server {
|
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 ) :
|
GamePacketNew< FFXIVIpcActorSpawn, ServerZoneIpcType >( pPlayer->getId(), pTarget->getId() )
|
||||||
GamePacketNew< FFXIVIpcActorSpawn, ServerZoneIpcType >( pPlayer->getId(), pTarget->getId() )
|
{
|
||||||
{
|
initialize( pPlayer, pTarget );
|
||||||
initialize( pPlayer, pTarget );
|
};
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initialize( Entity::PlayerPtr pPlayer, Entity::PlayerPtr pTarget )
|
void initialize( Entity::PlayerPtr pPlayer, Entity::PlayerPtr pTarget )
|
||||||
{
|
{
|
||||||
// TODO: temporary gm rank
|
// TODO: temporary gm rank
|
||||||
m_data.gmRank = 0xff;
|
m_data.gmRank = 0xff;
|
||||||
m_data.classJob = static_cast< uint8_t >( pPlayer->getClass() );
|
m_data.classJob = static_cast< uint8_t >( pPlayer->getClass() );
|
||||||
m_data.status = static_cast< uint8_t >( pPlayer->getStatus() );
|
m_data.status = static_cast< uint8_t >( pPlayer->getStatus() );
|
||||||
m_data.hPCurr = pPlayer->getHp();
|
m_data.hPCurr = pPlayer->getHp();
|
||||||
m_data.mPCurr = pPlayer->getMp();
|
m_data.mPCurr = pPlayer->getMp();
|
||||||
m_data.tPCurr = pPlayer->getTp();
|
m_data.tPCurr = pPlayer->getTp();
|
||||||
m_data.hPMax = pPlayer->getMaxHp();
|
m_data.hPMax = pPlayer->getMaxHp();
|
||||||
m_data.mPMax = pPlayer->getMaxMp();
|
m_data.mPMax = pPlayer->getMaxMp();
|
||||||
m_data.tPMax = 3000;
|
m_data.tPMax = 3000;
|
||||||
m_data.level = pPlayer->getLevel();
|
m_data.level = pPlayer->getLevel();
|
||||||
memcpy( m_data.look, pPlayer->getLookArray(), 26 );
|
memcpy( m_data.look, pPlayer->getLookArray(), 26 );
|
||||||
m_data.mainWeaponModel = pPlayer->getModelMainWeapon();
|
m_data.mainWeaponModel = pPlayer->getModelMainWeapon();
|
||||||
m_data.secWeaponModel = pPlayer->getModelSubWeapon();
|
m_data.secWeaponModel = pPlayer->getModelSubWeapon();
|
||||||
m_data.models[0] = pPlayer->getModelForSlot( Inventory::EquipSlot::Head );
|
m_data.models[0] = pPlayer->getModelForSlot( Inventory::EquipSlot::Head );
|
||||||
m_data.models[1] = pPlayer->getModelForSlot( Inventory::EquipSlot::Body );
|
m_data.models[1] = pPlayer->getModelForSlot( Inventory::EquipSlot::Body );
|
||||||
m_data.models[2] = pPlayer->getModelForSlot( Inventory::EquipSlot::Hands );
|
m_data.models[2] = pPlayer->getModelForSlot( Inventory::EquipSlot::Hands );
|
||||||
m_data.models[3] = pPlayer->getModelForSlot( Inventory::EquipSlot::Legs );
|
m_data.models[3] = pPlayer->getModelForSlot( Inventory::EquipSlot::Legs );
|
||||||
m_data.models[4] = pPlayer->getModelForSlot( Inventory::EquipSlot::Feet );
|
m_data.models[4] = pPlayer->getModelForSlot( Inventory::EquipSlot::Feet );
|
||||||
strcpy( m_data.name, pPlayer->getName().c_str() );
|
strcpy( m_data.name, pPlayer->getName().c_str() );
|
||||||
m_data.pos.x = pPlayer->getPos().x;
|
m_data.pos.x = pPlayer->getPos().x;
|
||||||
m_data.pos.y = pPlayer->getPos().y;
|
m_data.pos.y = pPlayer->getPos().y;
|
||||||
m_data.pos.z = pPlayer->getPos().z;
|
m_data.pos.z = pPlayer->getPos().z;
|
||||||
m_data.voice = pPlayer->getVoiceId();
|
m_data.voice = pPlayer->getVoiceId();
|
||||||
|
|
||||||
m_data.rotation = Math::Util::floatToUInt16Rot( pPlayer->getRotation() );
|
m_data.rotation = Math::Util::floatToUInt16Rot( pPlayer->getRotation() );
|
||||||
|
|
||||||
m_data.statusIcon = pPlayer->getOnlineStatus();
|
m_data.statusIcon = pPlayer->getOnlineStatus();
|
||||||
|
|
||||||
if( pTarget == pPlayer )
|
if( pTarget == pPlayer )
|
||||||
{
|
{
|
||||||
m_data.spawnIndex = 0x00;
|
m_data.spawnIndex = 0x00;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_data.spawnIndex = pTarget->getSpawnIdForActorId( pPlayer->getId() );
|
m_data.spawnIndex = pTarget->getSpawnIdForActorId( pPlayer->getId() );
|
||||||
}
|
}
|
||||||
// 0x20 == spawn hidden to be displayed by the spawneffect control
|
// 0x20 == spawn hidden to be displayed by the spawneffect control
|
||||||
m_data.displayFlags = pPlayer->getStance();
|
m_data.displayFlags = pPlayer->getStance();
|
||||||
|
|
||||||
if( pPlayer->getZoningType() != Common::ZoneingType::None )
|
if( pPlayer->getZoningType() != Common::ZoneingType::None )
|
||||||
{
|
{
|
||||||
m_data.displayFlags |= 0x20;
|
m_data.displayFlags |= 0x20;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_data.targetId = pPlayer->getTargetId();
|
m_data.targetId = pPlayer->getTargetId();
|
||||||
m_data.type = 1;
|
m_data.type = 1;
|
||||||
m_data.unknown_33 = 4;
|
m_data.unknown_33 = 4;
|
||||||
//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*/
|
|
@ -1,41 +1,39 @@
|
||||||
#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 {
|
||||||
namespace Packets {
|
namespace Packets {
|
||||||
namespace Server {
|
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 ) :
|
ZoneChannelPacket< FFXIVIpcChat >( player.getId(), player.getId() )
|
||||||
ZoneChannelPacket< FFXIVIpcChat >( player.getId(), player.getId() )
|
{
|
||||||
{
|
initialize( player, chatType, msg );
|
||||||
initialize( player, chatType, msg );
|
};
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initialize( Entity::Player& player, Common::ChatType chatType, const std::string& msg )
|
void initialize( Entity::Player& player, Common::ChatType chatType, const std::string& msg )
|
||||||
{
|
{
|
||||||
m_data.chatType = chatType;
|
m_data.chatType = chatType;
|
||||||
strcpy( m_data.name, player.getName().c_str() );
|
strcpy( m_data.name, player.getName().c_str() );
|
||||||
strcpy( m_data.msg, msg.c_str() );
|
strcpy( m_data.msg, msg.c_str() );
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace Server
|
||||||
}
|
} // namespace Packets
|
||||||
}
|
} // namespace Network
|
||||||
}
|
} // namespace Core
|
||||||
|
|
||||||
#endif /*_CHATPACKET_H*/
|
#endif /*_CHATPACKET_H*/
|
||||||
|
|
|
@ -5,40 +5,34 @@
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Network {
|
namespace Network {
|
||||||
namespace Packets {
|
namespace Packets {
|
||||||
namespace Server {
|
namespace Server {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The packet sent to finish an event.
|
* @brief The packet sent to finish an event.
|
||||||
*/
|
*/
|
||||||
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,
|
ZoneChannelPacket< FFXIVIpcEventFinish >( playerId, playerId )
|
||||||
uint8_t param1,
|
{
|
||||||
uint32_t param3 ) :
|
initialize( eventId, param1, param3 );
|
||||||
ZoneChannelPacket< FFXIVIpcEventFinish >( playerId, playerId )
|
};
|
||||||
{
|
|
||||||
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.param1 = param1;
|
||||||
m_data.eventId = eventId;
|
m_data.param2 = 1;
|
||||||
m_data.param1 = param1;
|
m_data.param3 = param3;
|
||||||
m_data.param2 = 1;
|
};
|
||||||
m_data.param3 = param3;
|
};
|
||||||
|
|
||||||
};
|
} // namespace Server
|
||||||
};
|
} // namespace Packets
|
||||||
|
} // namespace Network
|
||||||
}
|
} // namespace Core
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /*_EVENTFINISH_H*/
|
#endif /*_EVENTFINISH_H*/
|
|
@ -1,55 +1,44 @@
|
||||||
#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 {
|
||||||
namespace Packets {
|
namespace Packets {
|
||||||
namespace Server {
|
namespace Server {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The packet sent to play an event.
|
* @brief The packet sent to play an event.
|
||||||
*/
|
*/
|
||||||
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,
|
ZoneChannelPacket< FFXIVIpcEventPlay >( playerId, playerId )
|
||||||
uint16_t scene,
|
{
|
||||||
uint32_t flags,
|
initialize( actorId, eventId, scene, flags, param3, param4, param5 );
|
||||||
uint8_t param3,
|
};
|
||||||
uint32_t param4 = 0,
|
|
||||||
uint32_t param5 = 0 ) :
|
|
||||||
ZoneChannelPacket< FFXIVIpcEventPlay >( playerId, playerId )
|
|
||||||
{
|
|
||||||
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,
|
m_data.actorId = actorId;
|
||||||
uint8_t param3,
|
m_data.eventId = eventId;
|
||||||
uint32_t param4,
|
m_data.scene = scene;
|
||||||
uint32_t param5 )
|
m_data.flags = flags;
|
||||||
{
|
m_data.param3 = param3;
|
||||||
m_data.actorId = actorId;
|
m_data.param4 = param4;
|
||||||
m_data.eventId = eventId;
|
m_data.param5 = param5;
|
||||||
m_data.scene = scene;
|
};
|
||||||
m_data.flags = flags;
|
};
|
||||||
m_data.param3 = param3;
|
|
||||||
m_data.param4 = param4;
|
|
||||||
m_data.param5 = param5;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
} // namespace Server
|
||||||
}
|
} // namespace Packets
|
||||||
}
|
} // namespace Network
|
||||||
}
|
} // namespace Core
|
||||||
|
|
||||||
#endif /*_EVENTPLAY_H*/
|
#endif /*_EVENTPLAY_H*/
|
|
@ -1,50 +1,41 @@
|
||||||
#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 {
|
||||||
namespace Packets {
|
namespace Packets {
|
||||||
namespace Server {
|
namespace Server {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The packet sent to start an event.
|
* @brief The packet sent to start an event.
|
||||||
*/
|
*/
|
||||||
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,
|
ZoneChannelPacket< FFXIVIpcEventStart >( playerId, playerId )
|
||||||
uint8_t param1 = 0,
|
{
|
||||||
uint8_t param2 = 0,
|
initialize( actorId, eventId, param1, param2, param3 );
|
||||||
uint32_t param3 = 0 ) :
|
};
|
||||||
ZoneChannelPacket< FFXIVIpcEventStart >( playerId, playerId )
|
|
||||||
{
|
|
||||||
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,
|
m_data.actorId = actorId;
|
||||||
uint8_t param2,
|
m_data.eventId = eventId;
|
||||||
uint32_t param3 )
|
m_data.param1 = param1;
|
||||||
{
|
m_data.param2 = param2;
|
||||||
m_data.actorId = actorId;
|
m_data.param3 = param3;
|
||||||
m_data.eventId = eventId;
|
};
|
||||||
m_data.param1 = param1;
|
};
|
||||||
m_data.param2 = param2;
|
|
||||||
m_data.param3 = param3;
|
|
||||||
|
|
||||||
};
|
} // namespace Server
|
||||||
};
|
} // namespace Packets
|
||||||
|
} // namespace Network
|
||||||
}
|
} // namespace Core
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /*_EVENTSTART_H*/
|
#endif /*_EVENTSTART_H*/
|
|
@ -1,93 +1,92 @@
|
||||||
#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 {
|
||||||
namespace Packets {
|
namespace Packets {
|
||||||
namespace Server {
|
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 InitUIPacket : public ZoneChannelPacket< FFXIVIpcInitUI >
|
class InitUIPacket : public ZoneChannelPacket< FFXIVIpcInitUI >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InitUIPacket( Entity::Player& player ) :
|
InitUIPacket( Entity::Player& player ) :
|
||||||
ZoneChannelPacket< FFXIVIpcInitUI >( player.getId(), player.getId() )
|
ZoneChannelPacket< FFXIVIpcInitUI >( player.getId(), player.getId() )
|
||||||
{
|
{
|
||||||
initialize( player );
|
initialize( player );
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initialize( Entity::Player& player )
|
void initialize( Entity::Player& player )
|
||||||
{
|
{
|
||||||
m_data.contentId = player.getContentId();
|
m_data.contentId = player.getContentId();
|
||||||
|
|
||||||
// TODO: Support rested experience.
|
// TODO: Support rested experience.
|
||||||
m_data.restedExp = 0;
|
m_data.restedExp = 0;
|
||||||
//m_data.padding = 0x100;
|
// m_data.padding = 0x100;
|
||||||
m_data.charId = player.getId();
|
m_data.charId = player.getId();
|
||||||
m_data.race = player.getLookAt( Common::CharaLook::Race );
|
m_data.race = player.getLookAt( Common::CharaLook::Race );
|
||||||
m_data.tribe = player.getLookAt( Common::CharaLook::Tribe );
|
m_data.tribe = player.getLookAt( Common::CharaLook::Tribe );
|
||||||
m_data.gender = player.getLookAt( Common::CharaLook::Gender );
|
m_data.gender = player.getLookAt( Common::CharaLook::Gender );
|
||||||
m_data.currentClass = static_cast< uint8_t >( player.getClass() );
|
m_data.currentClass = static_cast< uint8_t >( player.getClass() );
|
||||||
m_data.currentJob = static_cast< uint8_t >( player.getClass() );
|
m_data.currentJob = static_cast< uint8_t >( player.getClass() );
|
||||||
m_data.deity = static_cast< uint8_t >( player.getGuardianDeity() );
|
m_data.deity = static_cast< uint8_t >( player.getGuardianDeity() );
|
||||||
m_data.namedayMonth = player.getBirthMonth();
|
m_data.namedayMonth = player.getBirthMonth();
|
||||||
m_data.namedayDay = player.getBirthDay();
|
m_data.namedayDay = player.getBirthDay();
|
||||||
// TODO: Support grand company status.
|
// TODO: Support grand company status.
|
||||||
m_data.grandCompany = static_cast< Common::GrandCompany >( player.getGc() );
|
m_data.grandCompany = static_cast< Common::GrandCompany >( player.getGc() );
|
||||||
//m_data.gcRank = GCRank::None;
|
// m_data.gcRank = GCRank::None;
|
||||||
|
|
||||||
// TODO: Support starting city.
|
// TODO: Support starting city.
|
||||||
//m_data.startCity = Town::Gridania;
|
// m_data.startCity = Town::Gridania;
|
||||||
m_data.homepoint = player.getHomepoint();
|
m_data.homepoint = player.getHomepoint();
|
||||||
|
|
||||||
memset( &m_data.name[0], 0, sizeof( m_data.name ) );
|
memset( &m_data.name[0], 0, sizeof( m_data.name ) );
|
||||||
|
|
||||||
strcpy( &m_data.name[0], player.getName().c_str() );
|
strcpy( &m_data.name[0], player.getName().c_str() );
|
||||||
|
|
||||||
memcpy( m_data.aetheryte, player.getAetheryteArray(), sizeof ( m_data.aetheryte ) );
|
memcpy( m_data.aetheryte, player.getAetheryteArray(), sizeof( m_data.aetheryte ) );
|
||||||
|
|
||||||
// Set the class levels and exp.
|
// Set the class levels and exp.
|
||||||
for( uint8_t i = 0; i < 25; i++ )
|
for( uint8_t i = 0; i < 25; i++ )
|
||||||
{
|
{
|
||||||
m_data.levels[i] = player.getClassArray()[i];
|
m_data.levels[i] = player.getClassArray()[i];
|
||||||
m_data.exp[i] = player.getExpArray()[i];
|
m_data.exp[i] = player.getExpArray()[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy( m_data.orchestrionMask, player.getOrchestrionBitmask(), sizeof( m_data.orchestrionMask ) );
|
memcpy( m_data.orchestrionMask, player.getOrchestrionBitmask(), sizeof( m_data.orchestrionMask ) );
|
||||||
|
|
||||||
memcpy( m_data.mountGuideMask, player.getMountGuideBitmask(), sizeof( m_data.mountGuideMask) );
|
memcpy( m_data.mountGuideMask, player.getMountGuideBitmask(), sizeof( m_data.mountGuideMask ) );
|
||||||
|
|
||||||
memcpy( m_data.unlockBitmask, player.getUnlockBitmask(), sizeof( m_data.unlockBitmask ) );
|
memcpy( m_data.unlockBitmask, player.getUnlockBitmask(), sizeof( m_data.unlockBitmask ) );
|
||||||
|
|
||||||
memcpy( m_data.discovery, player.getDiscoveryBitmask(), sizeof( m_data.discovery ) );
|
memcpy( m_data.discovery, player.getDiscoveryBitmask(), sizeof( m_data.discovery ) );
|
||||||
|
|
||||||
memcpy( m_data.howto, player.getHowToArray(), sizeof( m_data.howto ) );
|
memcpy( m_data.howto, player.getHowToArray(), sizeof( m_data.howto ) );
|
||||||
|
|
||||||
m_data.unknown_13 = 0x46;
|
m_data.unknown_13 = 0x46;
|
||||||
m_data.expansion = 2;
|
m_data.expansion = 2;
|
||||||
|
|
||||||
//memset( m_data.unlockBitmask, 0xFF, sizeof( m_data.unlockBitmask ) );
|
// memset( m_data.unlockBitmask, 0xFF, sizeof( m_data.unlockBitmask ) );
|
||||||
//memset( m_data.unknown_0344, 0xFF, sizeof( m_data.unknown_0344 ) );
|
// memset( m_data.unknown_0344, 0xFF, sizeof( m_data.unknown_0344 ) );
|
||||||
//memset( m_data.unknown_F4, 0xFF, sizeof( m_data.unknown_F4 ) );
|
// memset( m_data.unknown_F4, 0xFF, sizeof( m_data.unknown_F4 ) );
|
||||||
//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*/
|
||||||
|
|
|
@ -1,44 +1,43 @@
|
||||||
#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 {
|
||||||
namespace Packets {
|
namespace Packets {
|
||||||
namespace Server {
|
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 ) :
|
ZoneChannelPacket< FFXIVIpcModelEquip >( player.getId(), player.getId() )
|
||||||
ZoneChannelPacket< FFXIVIpcModelEquip >( player.getId(), player.getId() )
|
{
|
||||||
{
|
initialize( player );
|
||||||
initialize( player );
|
};
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initialize( Entity::Player& player )
|
void initialize( Entity::Player& player )
|
||||||
{
|
{
|
||||||
m_data.mainWeapon = player.getModelMainWeapon();
|
m_data.mainWeapon = player.getModelMainWeapon();
|
||||||
m_data.offWeapon = player.getModelSubWeapon();
|
m_data.offWeapon = player.getModelSubWeapon();
|
||||||
m_data.models[0] = player.getModelForSlot( Inventory::EquipSlot::Head );
|
m_data.models[0] = player.getModelForSlot( Inventory::EquipSlot::Head );
|
||||||
m_data.models[1] = player.getModelForSlot( Inventory::EquipSlot::Body );
|
m_data.models[1] = player.getModelForSlot( Inventory::EquipSlot::Body );
|
||||||
m_data.models[2] = player.getModelForSlot( Inventory::EquipSlot::Hands );
|
m_data.models[2] = player.getModelForSlot( Inventory::EquipSlot::Hands );
|
||||||
m_data.models[3] = player.getModelForSlot( Inventory::EquipSlot::Legs );
|
m_data.models[3] = player.getModelForSlot( Inventory::EquipSlot::Legs );
|
||||||
m_data.models[4] = player.getModelForSlot( Inventory::EquipSlot::Feet );
|
m_data.models[4] = player.getModelForSlot( Inventory::EquipSlot::Feet );
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace Server
|
||||||
}
|
} // namespace Packets
|
||||||
}
|
} // namespace Network
|
||||||
}
|
} // namespace Core
|
||||||
|
|
||||||
#endif /*_MODELEQUIPPACKET_H*/
|
#endif /*_MODELEQUIPPACKET_H*/
|
||||||
|
|
|
@ -1,51 +1,48 @@
|
||||||
#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 {
|
||||||
namespace Packets {
|
namespace Packets {
|
||||||
namespace Server {
|
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 ) :
|
ZoneChannelPacket< FFXIVIpcActorMove >( actor.getId(), actor.getId() )
|
||||||
ZoneChannelPacket< FFXIVIpcActorMove >( actor.getId(), actor.getId() )
|
{
|
||||||
{
|
initialize( actor, unk1, unk2, unk3, unk4 );
|
||||||
initialize( actor, unk1, unk2, unk3, unk4 );
|
};
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initialize( Entity::Actor& actor, uint8_t unk1, uint8_t unk2, uint8_t unk3, uint16_t unk4 )
|
void initialize( Entity::Actor& actor, uint8_t unk1, uint8_t unk2, uint8_t unk3, uint16_t unk4 )
|
||||||
{
|
{
|
||||||
|
|
||||||
m_data.rotation = Math::Util::floatToUInt8Rot( actor.getRotation() );
|
m_data.rotation = Math::Util::floatToUInt8Rot( actor.getRotation() );
|
||||||
m_data.unknown_1 = unk1;
|
m_data.unknown_1 = unk1;
|
||||||
m_data.unknown_2 = unk2;
|
m_data.unknown_2 = unk2;
|
||||||
m_data.unknown_3 = unk3;
|
m_data.unknown_3 = unk3;
|
||||||
m_data.unknown_4 = unk4;
|
m_data.unknown_4 = unk4;
|
||||||
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*/
|
||||||
|
|
|
@ -7,32 +7,31 @@
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Network {
|
namespace Network {
|
||||||
namespace Packets {
|
namespace Packets {
|
||||||
namespace Server {
|
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 ) :
|
ZoneChannelPacket< FFXIVIpcPing >( player.getId(), player.getId() )
|
||||||
ZoneChannelPacket< FFXIVIpcPing >( player.getId(), player.getId() )
|
{
|
||||||
{
|
initialize( player, inVal );
|
||||||
initialize( player, inVal );
|
};
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initialize( Entity::Player& player, int32_t inVal )
|
void initialize( Entity::Player& player, int32_t inVal )
|
||||||
{
|
{
|
||||||
m_data.timeInMilliseconds = 0x000014D00000000 + inVal;
|
m_data.timeInMilliseconds = 0x000014D00000000 + inVal;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace Server
|
||||||
}
|
} // namespace Packets
|
||||||
}
|
} // namespace Network
|
||||||
}
|
} // namespace Core
|
||||||
|
|
||||||
#endif /*_CORE_NETWORK_PACKETS_CPINGPACKET_H*/
|
#endif /*_CORE_NETWORK_PACKETS_CPINGPACKET_H*/
|
||||||
|
|
|
@ -1,141 +1,140 @@
|
||||||
#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 {
|
||||||
namespace Packets {
|
namespace Packets {
|
||||||
namespace Server {
|
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:
|
|
||||||
PlayerSpawnPacket( Entity::Player& player, Entity::Player& target ) :
|
|
||||||
GamePacketNew< FFXIVIpcPlayerSpawn, ServerZoneIpcType >( player.getId(), target.getId() )
|
|
||||||
{
|
|
||||||
initialize( player, target );
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
|
||||||
void initialize( Entity::Player& player, Entity::Player& target )
|
|
||||||
{
|
|
||||||
// todo: figure out unkown offsets
|
|
||||||
// TODO: temporary gm rank
|
|
||||||
//m_data.gmRank = 0xff;
|
|
||||||
|
|
||||||
m_data.classJob = static_cast< uint8_t >( player.getClass() );
|
|
||||||
//m_data.status = static_cast< uint8_t >( pPlayer->getStatus() );
|
|
||||||
|
|
||||||
m_data.hPCurr = player.getHp();
|
|
||||||
m_data.mPCurr = player.getMp();
|
|
||||||
m_data.tPCurr = player.getTp();
|
|
||||||
m_data.hPMax = player.getMaxHp();
|
|
||||||
m_data.mPMax = player.getMaxMp();
|
|
||||||
|
|
||||||
//m_data.tPMax = 3000;
|
|
||||||
m_data.level = player.getLevel();
|
|
||||||
m_data.gmRank = player.getGmRank();
|
|
||||||
m_data.pose = 0;
|
|
||||||
|
|
||||||
memcpy( m_data.look, player.getLookArray(), 26 );
|
|
||||||
|
|
||||||
auto item = player.getInventory()->getItemAt( Inventory::GearSet0, Inventory::EquipSlot::MainHand );
|
|
||||||
if( item )
|
|
||||||
m_data.mainWeaponModel = item->getModelId1();
|
|
||||||
m_data.secWeaponModel = player.getModelSubWeapon();
|
|
||||||
|
|
||||||
m_data.models[0] = player.getModelForSlot( Inventory::EquipSlot::Head );
|
|
||||||
m_data.models[1] = player.getModelForSlot( Inventory::EquipSlot::Body );
|
|
||||||
m_data.models[2] = player.getModelForSlot( Inventory::EquipSlot::Hands );
|
|
||||||
m_data.models[3] = player.getModelForSlot( Inventory::EquipSlot::Legs );
|
|
||||||
m_data.models[4] = player.getModelForSlot( Inventory::EquipSlot::Feet );
|
|
||||||
strcpy( m_data.name, player.getName().c_str() );
|
|
||||||
|
|
||||||
m_data.pos.x = player.getPos().x;
|
|
||||||
m_data.pos.y = player.getPos().y;
|
|
||||||
m_data.pos.z = player.getPos().z;
|
|
||||||
m_data.rotation = Math::Util::floatToUInt16Rot( player.getRotation() );
|
|
||||||
|
|
||||||
|
|
||||||
m_data.title = player.getTitle();
|
|
||||||
m_data.voice = player.getVoiceId();
|
|
||||||
m_data.currentMount = player.getCurrentMount();
|
|
||||||
|
|
||||||
m_data.onlineStatus = static_cast< uint8_t >( player.getOnlineStatus() );
|
|
||||||
|
|
||||||
//m_data.u23 = 0x04;
|
|
||||||
//m_data.u24 = 256;
|
|
||||||
m_data.state = static_cast< uint8_t >( player.getStatus() );
|
|
||||||
m_data.type = 1;
|
|
||||||
if( target.getId() == player.getId() )
|
|
||||||
{
|
{
|
||||||
m_data.spawnIndex = 0x00;
|
public:
|
||||||
}
|
PlayerSpawnPacket( Entity::Player& player, Entity::Player& target ) :
|
||||||
else
|
GamePacketNew< FFXIVIpcPlayerSpawn, ServerZoneIpcType >( player.getId(), target.getId() )
|
||||||
{
|
{
|
||||||
m_data.spawnIndex = target.getSpawnIdForActorId( player.getId() );
|
initialize( player, target );
|
||||||
}
|
};
|
||||||
// 0x20 == spawn hidden to be displayed by the spawneffect control
|
|
||||||
m_data.displayFlags = player.getStance();
|
|
||||||
|
|
||||||
if( player.getZoningType() != Common::ZoneingType::None )
|
private:
|
||||||
{
|
void initialize( Entity::Player& player, Entity::Player& target )
|
||||||
m_data.displayFlags |= Entity::Actor::DisplayFlags::Invisible;
|
{
|
||||||
}
|
// todo: figure out unkown offsets
|
||||||
|
// TODO: temporary gm rank
|
||||||
|
// m_data.gmRank = 0xff;
|
||||||
|
|
||||||
if( player.getEquipDisplayFlags() & Core::Common::EquipDisplayFlags::HideHead )
|
m_data.classJob = static_cast< uint8_t >( player.getClass() );
|
||||||
{
|
// m_data.status = static_cast< uint8_t >( pPlayer->getStatus() );
|
||||||
m_data.displayFlags |= Entity::Actor::DisplayFlags::HideHead;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( player.getEquipDisplayFlags() & Core::Common::EquipDisplayFlags::HideWeapon )
|
m_data.hPCurr = player.getHp();
|
||||||
{
|
m_data.mPCurr = player.getMp();
|
||||||
m_data.displayFlags |= Entity::Actor::DisplayFlags::HideWeapon;
|
m_data.tPCurr = player.getTp();
|
||||||
}
|
m_data.hPMax = player.getMaxHp();
|
||||||
|
m_data.mPMax = player.getMaxMp();
|
||||||
|
|
||||||
if( player.getEquipDisplayFlags() & Core::Common::EquipDisplayFlags::Visor )
|
// m_data.tPMax = 3000;
|
||||||
{
|
m_data.level = player.getLevel();
|
||||||
m_data.displayFlags |= Entity::Actor::DisplayFlags::Visor;
|
m_data.gmRank = player.getGmRank();
|
||||||
}
|
m_data.pose = 0;
|
||||||
|
|
||||||
m_data.currentMount = player.getCurrentMount();
|
memcpy( m_data.look, player.getLookArray(), 26 );
|
||||||
|
|
||||||
m_data.targetId = player.getTargetId();
|
auto item = player.getInventory()->getItemAt( Inventory::GearSet0, Inventory::EquipSlot::MainHand );
|
||||||
//m_data.type = 1;
|
if( item )
|
||||||
//m_data.unknown_33 = 4;
|
m_data.mainWeaponModel = item->getModelId1();
|
||||||
//m_data.unknown_38 = 0x70;
|
m_data.secWeaponModel = player.getModelSubWeapon();
|
||||||
//m_data.unknown_60 = 3;
|
|
||||||
//m_data.unknown_61 = 7;
|
|
||||||
|
|
||||||
uint64_t currentTimeMs = Util::getTimeMs();
|
m_data.models[0] = player.getModelForSlot( Inventory::EquipSlot::Head );
|
||||||
|
m_data.models[1] = player.getModelForSlot( Inventory::EquipSlot::Body );
|
||||||
|
m_data.models[2] = player.getModelForSlot( Inventory::EquipSlot::Hands );
|
||||||
|
m_data.models[3] = player.getModelForSlot( Inventory::EquipSlot::Legs );
|
||||||
|
m_data.models[4] = player.getModelForSlot( Inventory::EquipSlot::Feet );
|
||||||
|
strcpy( m_data.name, player.getName().c_str() );
|
||||||
|
|
||||||
for( auto const& effect : player.getStatusEffectMap() )
|
m_data.pos.x = player.getPos().x;
|
||||||
{
|
m_data.pos.y = player.getPos().y;
|
||||||
m_data.effect[effect.first].effect_id = effect.second->getId();
|
m_data.pos.z = player.getPos().z;
|
||||||
m_data.effect[effect.first].duration = static_cast< float >( effect.second->getDuration() -
|
m_data.rotation = Math::Util::floatToUInt16Rot( player.getRotation() );
|
||||||
( currentTimeMs - effect.second->getStartTimeMs() ) ) / 1000;
|
|
||||||
m_data.effect[effect.first].sourceActorId = effect.second->getSrcActorId();
|
|
||||||
m_data.effect[effect.first].unknown1 = effect.second->getParam();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
m_data.title = player.getTitle();
|
||||||
};
|
m_data.voice = player.getVoiceId();
|
||||||
|
m_data.currentMount = player.getCurrentMount();
|
||||||
|
|
||||||
}
|
m_data.onlineStatus = static_cast< uint8_t >( player.getOnlineStatus() );
|
||||||
}
|
|
||||||
}
|
// m_data.u23 = 0x04;
|
||||||
}
|
// m_data.u24 = 256;
|
||||||
|
m_data.state = static_cast< uint8_t >( player.getStatus() );
|
||||||
|
m_data.type = 1;
|
||||||
|
if( target.getId() == player.getId() )
|
||||||
|
{
|
||||||
|
m_data.spawnIndex = 0x00;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_data.spawnIndex = target.getSpawnIdForActorId( player.getId() );
|
||||||
|
}
|
||||||
|
// 0x20 == spawn hidden to be displayed by the spawneffect control
|
||||||
|
m_data.displayFlags = player.getStance();
|
||||||
|
|
||||||
|
if( player.getZoningType() != Common::ZoneingType::None )
|
||||||
|
{
|
||||||
|
m_data.displayFlags |= Entity::Actor::DisplayFlags::Invisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( player.getEquipDisplayFlags() & Core::Common::EquipDisplayFlags::HideHead )
|
||||||
|
{
|
||||||
|
m_data.displayFlags |= Entity::Actor::DisplayFlags::HideHead;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( player.getEquipDisplayFlags() & Core::Common::EquipDisplayFlags::HideWeapon )
|
||||||
|
{
|
||||||
|
m_data.displayFlags |= Entity::Actor::DisplayFlags::HideWeapon;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( player.getEquipDisplayFlags() & Core::Common::EquipDisplayFlags::Visor )
|
||||||
|
{
|
||||||
|
m_data.displayFlags |= Entity::Actor::DisplayFlags::Visor;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_data.currentMount = player.getCurrentMount();
|
||||||
|
|
||||||
|
m_data.targetId = player.getTargetId();
|
||||||
|
// m_data.type = 1;
|
||||||
|
// m_data.unknown_33 = 4;
|
||||||
|
// m_data.unknown_38 = 0x70;
|
||||||
|
// m_data.unknown_60 = 3;
|
||||||
|
// m_data.unknown_61 = 7;
|
||||||
|
|
||||||
|
uint64_t currentTimeMs = Util::getTimeMs();
|
||||||
|
|
||||||
|
for( auto const& effect : player.getStatusEffectMap() )
|
||||||
|
{
|
||||||
|
m_data.effect[effect.first].effect_id = effect.second->getId();
|
||||||
|
m_data.effect[effect.first].duration =
|
||||||
|
static_cast< float >( effect.second->getDuration() -
|
||||||
|
( currentTimeMs - effect.second->getStartTimeMs() ) ) /
|
||||||
|
1000;
|
||||||
|
m_data.effect[effect.first].sourceActorId = effect.second->getSrcActorId();
|
||||||
|
m_data.effect[effect.first].unknown1 = effect.second->getParam();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Server
|
||||||
|
} // namespace Packets
|
||||||
|
} // namespace Network
|
||||||
|
} // namespace Core
|
||||||
|
|
||||||
#endif /*_PlayerSpawn_H*/
|
#endif /*_PlayerSpawn_H*/
|
||||||
|
|
|
@ -1,58 +1,54 @@
|
||||||
#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 {
|
||||||
namespace Packets {
|
namespace Packets {
|
||||||
namespace Server {
|
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 ) :
|
ZoneChannelPacket< FFXIVIpcPlayerStateFlags >( player.getId(), player.getId() )
|
||||||
ZoneChannelPacket< FFXIVIpcPlayerStateFlags >( player.getId(), player.getId() )
|
{
|
||||||
{
|
initialize( player.getStateFlags() );
|
||||||
initialize( player.getStateFlags() );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
PlayerStateFlagsPacket( Entity::Player& player, std::vector< Common::PlayerStateFlag > flags ) :
|
PlayerStateFlagsPacket( Entity::Player& player, std::vector< Common::PlayerStateFlag > flags ) :
|
||||||
ZoneChannelPacket< FFXIVIpcPlayerStateFlags >( player.getId(), player.getId() )
|
ZoneChannelPacket< FFXIVIpcPlayerStateFlags >( player.getId(), player.getId() )
|
||||||
{
|
{
|
||||||
uint8_t newFlags[7];
|
uint8_t newFlags[7];
|
||||||
memset( newFlags, 0, 7 );
|
memset( newFlags, 0, 7 );
|
||||||
|
|
||||||
for( auto& flag : flags )
|
for( auto& flag : flags )
|
||||||
{
|
{
|
||||||
int32_t iFlag = static_cast< uint32_t >( flag );
|
int32_t iFlag = static_cast< uint32_t >( flag );
|
||||||
uint8_t index = iFlag / 8;
|
uint8_t index = iFlag / 8;
|
||||||
uint8_t bitIndex = iFlag % 8;
|
uint8_t bitIndex = iFlag % 8;
|
||||||
|
|
||||||
uint8_t value = 1 << bitIndex;
|
uint8_t value = 1 << bitIndex;
|
||||||
|
|
||||||
newFlags[index] |= value;
|
newFlags[index] |= value;
|
||||||
}
|
}
|
||||||
|
|
||||||
initialize( newFlags );
|
initialize( newFlags );
|
||||||
}
|
}
|
||||||
|
|
||||||
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*/
|
||||||
|
|
|
@ -1,43 +1,42 @@
|
||||||
#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 {
|
||||||
namespace Packets {
|
namespace Packets {
|
||||||
namespace Server {
|
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, uint8_t type = 0,
|
||||||
QuestMessagePacket( Entity::ActorPtr pActor, uint32_t questId, int8_t msgId,
|
uint32_t var1 = 0, uint32_t var2 = 0 ) :
|
||||||
uint8_t type = 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 );
|
};
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initialize( uint32_t questId, int8_t msgId, uint8_t type, uint32_t var1, uint32_t var2 )
|
void initialize( uint32_t questId, int8_t msgId, uint8_t type, uint32_t var1, uint32_t var2 )
|
||||||
{
|
{
|
||||||
m_data.questId = questId;
|
m_data.questId = questId;
|
||||||
m_data.msgId = msgId;
|
m_data.msgId = msgId;
|
||||||
m_data.type = type;
|
m_data.type = type;
|
||||||
m_data.var1 = var1;
|
m_data.var1 = var1;
|
||||||
m_data.var2 = var2;
|
m_data.var2 = var2;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace Server
|
||||||
}
|
} // namespace Packets
|
||||||
}
|
} // namespace Network
|
||||||
}
|
} // namespace Core
|
||||||
|
|
||||||
#endif /* _QUESTMESSAGE_H */
|
#endif /* _QUESTMESSAGE_H */
|
|
@ -1,38 +1,34 @@
|
||||||
#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 {
|
||||||
namespace Packets {
|
namespace Packets {
|
||||||
namespace Server {
|
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 ) :
|
ZoneChannelPacket< FFXIVIpcServerNotice >( playerId, playerId )
|
||||||
ZoneChannelPacket< FFXIVIpcServerNotice >( playerId, playerId )
|
{
|
||||||
{
|
initialize( message );
|
||||||
initialize( message );
|
};
|
||||||
};
|
|
||||||
|
|
||||||
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*/
|
|
@ -1,40 +1,39 @@
|
||||||
#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 {
|
||||||
namespace Packets {
|
namespace Packets {
|
||||||
namespace Server {
|
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 ) :
|
ZoneChannelPacket< FFXIVIpcUpdateHpMpTp >( pActor->getId(), pActor->getId() )
|
||||||
ZoneChannelPacket< FFXIVIpcUpdateHpMpTp >( pActor->getId(), pActor->getId() )
|
{
|
||||||
{
|
initialize( pActor );
|
||||||
initialize( pActor );
|
};
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initialize( Entity::ActorPtr pActor )
|
void initialize( Entity::ActorPtr pActor )
|
||||||
{
|
{
|
||||||
m_data.hp = pActor->getHp();
|
m_data.hp = pActor->getHp();
|
||||||
m_data.mp = pActor->getMp();
|
m_data.mp = pActor->getMp();
|
||||||
m_data.tp = pActor->getTp();
|
m_data.tp = pActor->getTp();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace Server
|
||||||
}
|
} // namespace Packets
|
||||||
}
|
} // namespace Network
|
||||||
}
|
} // namespace Core
|
||||||
|
|
||||||
#endif /*_UPDATEHPMPTP_H*/
|
#endif /*_UPDATEHPMPTP_H*/
|
|
@ -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,10 +31,9 @@ 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 )
|
||||||
{
|
{
|
||||||
|
|
||||||
g_log.info( "ScriptEngine: loading scripts from " + dirname );
|
g_log.info( "ScriptEngine: loading scripts from " + dirname );
|
||||||
|
@ -52,7 +51,6 @@ void Core::Scripting::ScriptManager::loadDir( std::string dirname, std::set<std:
|
||||||
chaiFiles.insert( i.string() );
|
chaiFiles.insert( i.string() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Scripting::ScriptManager::onPlayerFirstEnterWorld( Entity::Player& player )
|
void Core::Scripting::ScriptManager::onPlayerFirstEnterWorld( Entity::Player& player )
|
||||||
|
@ -61,7 +59,7 @@ void Core::Scripting::ScriptManager::onPlayerFirstEnterWorld( Entity::Player& pl
|
||||||
{
|
{
|
||||||
std::string test = m_onFirstEnterWorld( player );
|
std::string test = m_onFirstEnterWorld( player );
|
||||||
}
|
}
|
||||||
catch( const std::exception &e )
|
catch( const std::exception& e )
|
||||||
{
|
{
|
||||||
std::string what = e.what();
|
std::string what = e.what();
|
||||||
g_log.Log( LoggingSeverity::error, what );
|
g_log.Log( LoggingSeverity::error, what );
|
||||||
|
@ -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,15 +104,16 @@ 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 );
|
||||||
}
|
}
|
||||||
catch( std::exception& e )
|
catch( std::exception& e )
|
||||||
{
|
{
|
||||||
player.sendDebug( e.what( ) );
|
player.sendDebug( e.what() );
|
||||||
|
|
||||||
if( eventType == Common::EventType::Quest )
|
if( eventType == Common::EventType::Quest )
|
||||||
{
|
{
|
||||||
|
@ -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 );
|
||||||
|
@ -173,14 +169,15 @@ bool Core::Scripting::ScriptManager::onWithinRange( Entity::Player& player, uint
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Get object from engine
|
// Get object from engine
|
||||||
auto obj = m_pChaiHandler->eval( Event::getEventName( eventId ) );
|
auto obj = m_pChaiHandler->eval( Event::getEventName( eventId ) );
|
||||||
|
|
||||||
player.sendDebug( "Calling: " + objName + "." + eventName );
|
player.sendDebug( "Calling: " + objName + "." + eventName );
|
||||||
|
|
||||||
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++ )
|
||||||
{
|
{
|
||||||
|
@ -369,18 +365,18 @@ bool Core::Scripting::ScriptManager::onMobKill( Entity::Player& player, uint16_t
|
||||||
auto obj = m_pChaiHandler->eval( Event::getEventName( 0x00010000 | questId ) );
|
auto obj = m_pChaiHandler->eval( Event::getEventName( 0x00010000 | questId ) );
|
||||||
std::string objName = Event::getEventName( 0x00010000 | questId );
|
std::string objName = Event::getEventName( 0x00010000 | questId );
|
||||||
|
|
||||||
player.sendDebug("Calling: " + objName + "." + eventName);
|
player.sendDebug( "Calling: " + objName + "." + eventName );
|
||||||
|
|
||||||
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() );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,24 +385,25 @@ bool Core::Scripting::ScriptManager::onMobKill( Entity::Player& player, uint16_t
|
||||||
|
|
||||||
bool Core::Scripting::ScriptManager::onCastFinish( Entity::Player& player, Entity::ActorPtr pTarget, uint32_t actionId )
|
bool Core::Scripting::ScriptManager::onCastFinish( Entity::Player& player, Entity::ActorPtr pTarget, uint32_t actionId )
|
||||||
{
|
{
|
||||||
std::string eventName = "onFinish";
|
std::string eventName = "onFinish";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto obj = m_pChaiHandler->eval( "skillDef_" + std::to_string( actionId ) );
|
auto obj = m_pChaiHandler->eval( "skillDef_" + std::to_string( actionId ) );
|
||||||
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& ) > >(
|
||||||
fn( obj, player, *pTarget );
|
eventName );
|
||||||
}
|
fn( obj, player, *pTarget );
|
||||||
catch( std::exception& e )
|
}
|
||||||
{
|
catch( std::exception& e )
|
||||||
player.sendUrgent( e.what() );
|
{
|
||||||
}
|
player.sendUrgent( e.what() );
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Core::Scripting::ScriptManager::onStatusReceive( Entity::ActorPtr pActor, uint32_t effectId )
|
bool Core::Scripting::ScriptManager::onStatusReceive( Entity::ActorPtr pActor, uint32_t effectId )
|
||||||
|
@ -421,7 +418,7 @@ bool Core::Scripting::ScriptManager::onStatusReceive( Entity::ActorPtr pActor, u
|
||||||
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&) > >( eventName );
|
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value&, Entity::Actor& ) > >( eventName );
|
||||||
fn( obj, *pActor );
|
fn( obj, *pActor );
|
||||||
}
|
}
|
||||||
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 )
|
||||||
|
@ -470,7 +469,7 @@ bool Core::Scripting::ScriptManager::onStatusTimeOut( Entity::ActorPtr pActor, u
|
||||||
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& ) > >( eventName );
|
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value&, Entity::Actor& ) > >( eventName );
|
||||||
fn( obj, *pActor );
|
fn( obj, *pActor );
|
||||||
}
|
}
|
||||||
catch( std::exception& e )
|
catch( std::exception& e )
|
||||||
|
@ -498,6 +497,4 @@ bool Core::Scripting::ScriptManager::onZoneInit( ZonePtr pZone )
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,67 +5,63 @@
|
||||||
#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
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
boost::shared_ptr< chaiscript::ChaiScript > m_pChaiHandler;
|
||||||
|
|
||||||
class ScriptManager
|
std::function< std::string( Entity::Player& ) > m_onFirstEnterWorld;
|
||||||
{
|
// auto fn = m_pChaiHandler->eval< std::function<const std::string( Entity::Player ) > >( "onFirstEnterWorld" );
|
||||||
private:
|
|
||||||
|
|
||||||
boost::shared_ptr< chaiscript::ChaiScript > m_pChaiHandler;
|
public:
|
||||||
|
ScriptManager();
|
||||||
|
~ScriptManager();
|
||||||
|
|
||||||
std::function< std::string( Entity::Player& ) > m_onFirstEnterWorld;
|
int32_t init();
|
||||||
// auto fn = m_pChaiHandler->eval< std::function<const std::string( Entity::Player ) > >( "onFirstEnterWorld" );
|
void reload();
|
||||||
|
|
||||||
public:
|
const boost::shared_ptr< chaiscript::ChaiScript >& getHandler() const;
|
||||||
ScriptManager();
|
|
||||||
~ScriptManager();
|
|
||||||
|
|
||||||
int32_t init();
|
void onPlayerFirstEnterWorld( Entity::Player& player );
|
||||||
void reload();
|
|
||||||
|
|
||||||
const boost::shared_ptr< chaiscript::ChaiScript >& getHandler() const;
|
static bool registerBnpcTemplate( std::string templateName, uint32_t bnpcBaseId, uint32_t bnpcNameId,
|
||||||
|
uint32_t modelId, std::string aiName );
|
||||||
|
|
||||||
void onPlayerFirstEnterWorld( Entity::Player& player );
|
bool onTalk( Entity::Player& player, uint64_t actorId, uint32_t eventId );
|
||||||
|
bool onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 );
|
||||||
|
bool onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z );
|
||||||
|
bool onOutsideRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z );
|
||||||
|
bool onEmote( Entity::Player& player, uint64_t actorId, uint32_t eventId, uint8_t emoteId );
|
||||||
|
bool onEventItem( Entity::Player& player, uint32_t eventItemId, uint32_t eventId, uint32_t castTime,
|
||||||
|
uint64_t targetId );
|
||||||
|
|
||||||
static bool registerBnpcTemplate( std::string templateName, uint32_t bnpcBaseId, uint32_t bnpcNameId, uint32_t modelId, std::string aiName );
|
bool onMobKill( Entity::Player& player, uint16_t nameId );
|
||||||
|
|
||||||
bool onTalk( Entity::Player& player, uint64_t actorId, uint32_t eventId );
|
bool onCastFinish( Entity::Player& pPlayer, Entity::ActorPtr pTarget, uint32_t actionId );
|
||||||
bool onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 );
|
|
||||||
bool onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z );
|
|
||||||
bool onOutsideRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z );
|
|
||||||
bool onEmote( Entity::Player& player, uint64_t actorId, uint32_t eventId, uint8_t emoteId );
|
|
||||||
bool onEventItem( Entity::Player& player, uint32_t eventItemId, uint32_t eventId, uint32_t castTime, uint64_t targetId );
|
|
||||||
|
|
||||||
bool onMobKill( Entity::Player& player, uint16_t nameId );
|
bool onStatusReceive( Entity::ActorPtr pActor, uint32_t effectId );
|
||||||
|
bool onStatusTick( Entity::ActorPtr pActor, Core::StatusEffect::StatusEffect& effect );
|
||||||
|
bool onStatusTimeOut( Entity::ActorPtr pActor, uint32_t effectId );
|
||||||
|
|
||||||
bool onCastFinish( Entity::Player& pPlayer, Entity::ActorPtr pTarget, uint32_t actionId );
|
bool onZoneInit( ZonePtr pZone );
|
||||||
|
|
||||||
bool onStatusReceive( Entity::ActorPtr pActor, uint32_t effectId );
|
bool onEventHandlerReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param1,
|
||||||
bool onStatusTick( Entity::ActorPtr pActor, Core::StatusEffect::StatusEffect& effect );
|
uint16_t param2, uint16_t param3 );
|
||||||
bool onStatusTimeOut( Entity::ActorPtr pActor, uint32_t effectId );
|
bool onEventHandlerTradeReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param,
|
||||||
|
uint32_t catalogId );
|
||||||
|
|
||||||
bool onZoneInit( ZonePtr pZone );
|
void loadDir( std::string dirname, std::set< std::string >& chaiFiles );
|
||||||
|
};
|
||||||
bool onEventHandlerReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param1, uint16_t param2, uint16_t param3 );
|
} // namespace Scripting
|
||||||
bool onEventHandlerTradeReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param, uint32_t catalogId );
|
} // namespace Core
|
||||||
|
|
||||||
|
|
||||||
void loadDir( std::string dirname, std::set<std::string>& chaiFiles );
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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" );
|
||||||
|
@ -137,13 +138,24 @@ int Core::Scripting::ScriptManager::init()
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestBitFlag40 ), "setQuestBitFlag40" );
|
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestBitFlag40 ), "setQuestBitFlag40" );
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestBitFlag48 ), "setQuestBitFlag48" );
|
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestBitFlag48 ), "setQuestBitFlag48" );
|
||||||
|
|
||||||
m_pChaiHandler->add(chaiscript::fun(&Entity::Player::giveQuestRewards), "giveQuestRewards");
|
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::giveQuestRewards ), "giveQuestRewards" );
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::fun< void, Entity::Player, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t >( &Entity::Player::eventPlay ), "eventPlay" );
|
m_pChaiHandler->add( chaiscript::fun< void, Entity::Player, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t >(
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,10 +41,10 @@ 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 )
|
||||||
{
|
{
|
||||||
m_pConfig = XMLConfigPtr( new XMLConfig );
|
m_pConfig = XMLConfigPtr( new XMLConfig );
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -86,7 +86,7 @@ Core::Entity::BattleNpcTemplatePtr Core::ServerZone::getBnpcTemplate( std::strin
|
||||||
{
|
{
|
||||||
auto it = m_bnpcTemplates.find( templateName );
|
auto it = m_bnpcTemplates.find( templateName );
|
||||||
|
|
||||||
if (it != m_bnpcTemplates.end())
|
if( it != m_bnpcTemplates.end() )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return it->second;
|
return it->second;
|
||||||
|
@ -102,7 +102,7 @@ bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> args( argv + 1, argv + argc );
|
std::vector< std::string > args( argv + 1, argv + argc );
|
||||||
for( uint32_t i = 0; i + 1 < args.size(); i += 2 )
|
for( uint32_t i = 0; i + 1 < args.size(); i += 2 )
|
||||||
{
|
{
|
||||||
std::string arg( "" );
|
std::string arg( "" );
|
||||||
|
@ -239,12 +239,11 @@ 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
|
||||||
{
|
{
|
||||||
g_log.info("===========================================================" );
|
g_log.info( "===========================================================" );
|
||||||
g_log.info( "Sapphire Server Project " );
|
g_log.info( "Sapphire Server Project " );
|
||||||
g_log.info( "Version: " + Version::VERSION );
|
g_log.info( "Version: " + Version::VERSION );
|
||||||
g_log.info( "Git Hash: " + Version::GIT_HASH );
|
g_log.info( "Git Hash: " + Version::GIT_HASH );
|
||||||
|
@ -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(); )
|
||||||
{
|
{
|
||||||
|
@ -297,7 +294,7 @@ void Core::ServerZone::mainLoop()
|
||||||
it->second->close();
|
it->second->close();
|
||||||
// if( it->second.unique() )
|
// if( it->second.unique() )
|
||||||
{
|
{
|
||||||
g_log.info("[" + std::to_string(it->second->getId() ) + "] Session removal" );
|
g_log.info( "[" + std::to_string( it->second->getId() ) + "] Session removal" );
|
||||||
it = this->m_sessionMapById.erase( it );
|
it = this->m_sessionMapById.erase( it );
|
||||||
removeSession( pPlayer->getName() );
|
removeSession( pPlayer->getName() );
|
||||||
continue;
|
continue;
|
||||||
|
@ -307,7 +304,7 @@ void Core::ServerZone::mainLoop()
|
||||||
// remove sessions that simply timed out
|
// remove sessions that simply timed out
|
||||||
if( diff > 20 )
|
if( diff > 20 )
|
||||||
{
|
{
|
||||||
g_log.info("[" + std::to_string(it->second->getId() ) + "] Session time out" );
|
g_log.info( "[" + std::to_string( it->second->getId() ) + "] Session time out" );
|
||||||
it->second->close();
|
it->second->close();
|
||||||
// if( it->second.unique() )
|
// if( it->second.unique() )
|
||||||
{
|
{
|
||||||
|
@ -319,9 +316,7 @@ void Core::ServerZone::mainLoop()
|
||||||
{
|
{
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,7 +336,7 @@ bool Core::ServerZone::createSession( uint32_t sessionId )
|
||||||
|
|
||||||
g_log.info( "[" + session_id_str + "] Creating new session" );
|
g_log.info( "[" + session_id_str + "] Creating new session" );
|
||||||
|
|
||||||
boost::shared_ptr<Session> newSession( new Session( sessionId ) );
|
boost::shared_ptr< Session > newSession( new Session( sessionId ) );
|
||||||
m_sessionMapById[sessionId] = newSession;
|
m_sessionMapById[sessionId] = newSession;
|
||||||
|
|
||||||
if( !newSession->loadPlayer() )
|
if( !newSession->loadPlayer() )
|
||||||
|
@ -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 )
|
||||||
|
@ -372,7 +366,7 @@ void Core::ServerZone::updateSession( uint32_t id )
|
||||||
|
|
||||||
Core::SessionPtr Core::ServerZone::getSession( uint32_t id )
|
Core::SessionPtr Core::ServerZone::getSession( uint32_t id )
|
||||||
{
|
{
|
||||||
//std::lock_guard<std::mutex> lock( m_sessionMutex );
|
// std::lock_guard<std::mutex> lock( m_sessionMutex );
|
||||||
|
|
||||||
auto it = m_sessionMapById.find( id );
|
auto it = m_sessionMapById.find( id );
|
||||||
|
|
||||||
|
@ -384,12 +378,12 @@ Core::SessionPtr Core::ServerZone::getSession( uint32_t id )
|
||||||
|
|
||||||
Core::SessionPtr Core::ServerZone::getSession( std::string playerName )
|
Core::SessionPtr Core::ServerZone::getSession( std::string playerName )
|
||||||
{
|
{
|
||||||
//std::lock_guard<std::mutex> lock( m_sessionMutex );
|
// std::lock_guard<std::mutex> lock( m_sessionMutex );
|
||||||
|
|
||||||
auto it = m_sessionMapByName.find( playerName );
|
auto it = m_sessionMapByName.find( playerName );
|
||||||
|
|
||||||
if (it != m_sessionMapByName.end())
|
if( it != m_sessionMapByName.end() )
|
||||||
return (it->second);
|
return ( it->second );
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -412,4 +406,3 @@ bool Core::ServerZone::isRunning() const
|
||||||
{
|
{
|
||||||
return m_bRunning;
|
return m_bRunning;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,73 +4,69 @@
|
||||||
#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 {
|
||||||
|
|
||||||
class ServerZone
|
class ServerZone
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ServerZone( const std::string& configPath );
|
ServerZone( const std::string& configPath );
|
||||||
~ServerZone();
|
~ServerZone();
|
||||||
|
|
||||||
void run( int32_t argc, char* argv[] );
|
void run( int32_t argc, char* argv[] );
|
||||||
|
|
||||||
bool createSession( uint32_t sessionId );
|
bool createSession( uint32_t sessionId );
|
||||||
void removeSession( uint32_t sessionId );
|
void removeSession( uint32_t sessionId );
|
||||||
void removeSession( std::string playerName );
|
void removeSession( std::string playerName );
|
||||||
|
|
||||||
bool loadSettings( int32_t argc, char* argv[] );
|
bool loadSettings( int32_t argc, char* argv[] );
|
||||||
|
|
||||||
SessionPtr getSession( uint32_t id );
|
SessionPtr getSession( uint32_t id );
|
||||||
SessionPtr getSession( std::string playerName );
|
SessionPtr getSession( std::string playerName );
|
||||||
void updateSession( uint32_t id );
|
void updateSession( uint32_t id );
|
||||||
void updateSession( std::string playerName );
|
void updateSession( std::string playerName );
|
||||||
|
|
||||||
XMLConfigPtr getConfig() const;
|
XMLConfigPtr getConfig() const;
|
||||||
|
|
||||||
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 );
|
||||||
|
|
||||||
void mainLoop();
|
void mainLoop();
|
||||||
|
|
||||||
bool isRunning() const;
|
bool isRunning() const;
|
||||||
|
|
||||||
void printBanner() const;
|
void printBanner() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint16_t m_port;
|
||||||
|
std::string m_ip;
|
||||||
|
uint32_t m_lastDBPingTime;
|
||||||
|
|
||||||
private:
|
bool m_bRunning;
|
||||||
|
|
||||||
uint16_t m_port;
|
std::string m_configPath;
|
||||||
std::string m_ip;
|
|
||||||
uint32_t m_lastDBPingTime;
|
|
||||||
|
|
||||||
bool m_bRunning;
|
XMLConfigPtr m_pConfig;
|
||||||
|
|
||||||
std::string m_configPath;
|
std::mutex m_sessionMutex;
|
||||||
|
|
||||||
XMLConfigPtr m_pConfig;
|
std::map< uint32_t, SessionPtr > m_sessionMapById;
|
||||||
|
std::map< std::string, SessionPtr > m_sessionMapByName;
|
||||||
|
|
||||||
std::mutex m_sessionMutex;
|
std::map< uint32_t, uint32_t > m_zones;
|
||||||
|
|
||||||
std::map< uint32_t, SessionPtr > m_sessionMapById;
|
std::map< std::string, Entity::BattleNpcTemplatePtr > m_bnpcTemplates;
|
||||||
std::map< std::string, SessionPtr > m_sessionMapByName;
|
};
|
||||||
|
|
||||||
std::map< uint32_t, uint32_t > m_zones;
|
} // namespace Core
|
||||||
|
|
||||||
std::map< std::string, Entity::BattleNpcTemplatePtr > m_bnpcTemplates;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -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()
|
||||||
|
@ -31,8 +30,8 @@ void Core::Session::setZoneConnection( Network::GameConnectionPtr pZoneCon )
|
||||||
|
|
||||||
void Core::Session::setChatConnection( Network::GameConnectionPtr pChatCon )
|
void Core::Session::setChatConnection( Network::GameConnectionPtr pChatCon )
|
||||||
{
|
{
|
||||||
pChatCon->m_conType = Network::ConnectionType::Chat;
|
pChatCon->m_conType = Network::ConnectionType::Chat;
|
||||||
m_pChatConnection = pChatCon;
|
m_pChatConnection = pChatCon;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::Network::GameConnectionPtr Core::Session::getZoneConnection() const
|
Core::Network::GameConnectionPtr Core::Session::getZoneConnection() const
|
||||||
|
@ -42,10 +41,9 @@ Core::Network::GameConnectionPtr Core::Session::getZoneConnection() const
|
||||||
|
|
||||||
Core::Network::GameConnectionPtr Core::Session::getChatConnection() const
|
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()
|
||||||
|
@ -116,7 +113,7 @@ void Core::Session::update()
|
||||||
// SESSION LOGIC
|
// SESSION LOGIC
|
||||||
m_pPlayer->update( Util::getTimeMs() );
|
m_pPlayer->update( Util::getTimeMs() );
|
||||||
|
|
||||||
if( ( static_cast< uint32_t >( Util::getTimeSeconds() ) - static_cast< uint32_t >( getLastSqlTime() ) ) > 10 )
|
if( ( static_cast< uint32_t >( Util::getTimeSeconds() ) - static_cast< uint32_t >( getLastSqlTime() ) ) > 10 )
|
||||||
{
|
{
|
||||||
updateLastSqlTime();
|
updateLastSqlTime();
|
||||||
m_pPlayer->updateSql();
|
m_pPlayer->updateSql();
|
||||||
|
@ -127,14 +124,12 @@ void Core::Session::update()
|
||||||
|
|
||||||
if( m_pChatConnection )
|
if( m_pChatConnection )
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,53 +7,51 @@
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
class Session : public boost::enable_shared_from_this< Session >
|
class Session : public boost::enable_shared_from_this< Session >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Session( uint32_t sessionId );
|
Session( uint32_t sessionId );
|
||||||
~Session();
|
~Session();
|
||||||
|
|
||||||
void setZoneConnection( Network::GameConnectionPtr zoneCon );
|
void setZoneConnection( Network::GameConnectionPtr zoneCon );
|
||||||
|
|
||||||
void setChatConnection( Network::GameConnectionPtr chatCon );
|
void setChatConnection( Network::GameConnectionPtr chatCon );
|
||||||
|
|
||||||
Network::GameConnectionPtr getZoneConnection() const;
|
Network::GameConnectionPtr getZoneConnection() const;
|
||||||
Network::GameConnectionPtr getChatConnection() const;
|
Network::GameConnectionPtr getChatConnection() const;
|
||||||
|
|
||||||
uint32_t getLastDataTime() const;
|
uint32_t getLastDataTime() const;
|
||||||
uint32_t getLastSqlTime() const;
|
uint32_t getLastSqlTime() const;
|
||||||
|
|
||||||
void updateLastDataTime();
|
void updateLastDataTime();
|
||||||
void updateLastSqlTime();
|
void updateLastSqlTime();
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
uint32_t getId() const;
|
uint32_t getId() const;
|
||||||
|
|
||||||
bool loadPlayer();
|
bool loadPlayer();
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
|
||||||
Entity::PlayerPtr getPlayer() const;
|
Entity::PlayerPtr getPlayer() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t m_sessionId;
|
uint32_t m_sessionId;
|
||||||
|
|
||||||
Entity::PlayerPtr m_pPlayer;
|
Entity::PlayerPtr m_pPlayer;
|
||||||
|
|
||||||
uint32_t m_lastDataTime;
|
uint32_t m_lastDataTime;
|
||||||
|
|
||||||
uint32_t m_lastSqlTime;
|
uint32_t m_lastSqlTime;
|
||||||
bool m_isValid;
|
bool m_isValid;
|
||||||
|
|
||||||
Network::GameConnectionPtr m_pZoneConnection;
|
Network::GameConnectionPtr m_pZoneConnection;
|
||||||
Network::GameConnectionPtr m_pChatConnection;
|
Network::GameConnectionPtr m_pChatConnection;
|
||||||
|
};
|
||||||
|
|
||||||
};
|
} // namespace Core
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -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()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -55,7 +52,7 @@ void Core::StatusEffect::StatusEffect::registerTickEffect( uint8_t type, uint32_
|
||||||
m_currTickEffect = std::make_pair( type, param );
|
m_currTickEffect = std::make_pair( type, param );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair< uint8_t, uint32_t> Core::StatusEffect::StatusEffect::getTickEffect()
|
std::pair< uint8_t, uint32_t > Core::StatusEffect::StatusEffect::getTickEffect()
|
||||||
{
|
{
|
||||||
auto thisTick = m_currTickEffect;
|
auto thisTick = m_currTickEffect;
|
||||||
m_currTickEffect = std::make_pair( 0, 0 );
|
m_currTickEffect = std::make_pair( 0, 0 );
|
||||||
|
@ -90,20 +87,20 @@ void Core::StatusEffect::StatusEffect::applyStatus()
|
||||||
// this is only right when an action is being used by the player
|
// this is only right when an action is being used by the player
|
||||||
// else you probably need to use an actorcontrol
|
// else you probably need to use an actorcontrol
|
||||||
|
|
||||||
//GamePacketNew< FFXIVIpcEffect > effectPacket( m_sourceActor->getId() );
|
// GamePacketNew< FFXIVIpcEffect > effectPacket( m_sourceActor->getId() );
|
||||||
//effectPacket.data().targetId = m_sourceActor->getId();
|
// effectPacket.data().targetId = m_sourceActor->getId();
|
||||||
//effectPacket.data().actionAnimationId = 3;
|
// effectPacket.data().actionAnimationId = 3;
|
||||||
//effectPacket.data().unknown_3 = 1;
|
// effectPacket.data().unknown_3 = 1;
|
||||||
//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;
|
||||||
//effectPacket.data().effects[4].unknown_5 = 0x80;
|
// effectPacket.data().effects[4].unknown_5 = 0x80;
|
||||||
//m_sourceActor->sendToInRangeSet( effectPacket, true );
|
// m_sourceActor->sendToInRangeSet( effectPacket, true );
|
||||||
|
|
||||||
g_log.debug( "StatusEffect applied: " + m_name );
|
g_log.debug( "StatusEffect applied: " + m_name );
|
||||||
g_scriptMgr.onStatusReceive( m_targetActor, m_id );
|
g_scriptMgr.onStatusReceive( m_targetActor, m_id );
|
||||||
|
|
|
@ -5,53 +5,49 @@
|
||||||
|
|
||||||
#include "Forwards.h"
|
#include "Forwards.h"
|
||||||
|
|
||||||
namespace Core
|
namespace Core {
|
||||||
{
|
namespace StatusEffect {
|
||||||
namespace StatusEffect
|
|
||||||
{
|
|
||||||
|
|
||||||
|
class StatusEffect
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
StatusEffect( uint32_t id, Entity::ActorPtr sourceActor, Entity::ActorPtr targetActor, uint32_t duration,
|
||||||
|
uint32_t tickRate );
|
||||||
|
|
||||||
class StatusEffect
|
~StatusEffect();
|
||||||
{
|
|
||||||
public:
|
|
||||||
StatusEffect( uint32_t id, Entity::ActorPtr sourceActor, Entity::ActorPtr targetActor,
|
|
||||||
uint32_t duration, uint32_t tickRate );
|
|
||||||
|
|
||||||
~StatusEffect();
|
void onTick();
|
||||||
|
void applyStatus();
|
||||||
|
void removeStatus();
|
||||||
|
|
||||||
void onTick();
|
uint32_t getId() const;
|
||||||
void applyStatus();
|
uint32_t getDuration() const;
|
||||||
void removeStatus();
|
uint32_t getTickRate() const;
|
||||||
|
uint32_t getSrcActorId() const;
|
||||||
|
uint32_t getTargetActorId() const;
|
||||||
|
uint64_t getLastTickMs() const;
|
||||||
|
uint64_t getStartTimeMs() const;
|
||||||
|
uint16_t getParam() const;
|
||||||
|
void setLastTick( uint64_t lastTick );
|
||||||
|
void setParam( uint16_t param );
|
||||||
|
void registerTickEffect( uint8_t type, uint32_t param );
|
||||||
|
std::pair< uint8_t, uint32_t > getTickEffect();
|
||||||
|
const std::string& getName() const;
|
||||||
|
|
||||||
uint32_t getId() const;
|
private:
|
||||||
uint32_t getDuration() const;
|
uint32_t m_id;
|
||||||
uint32_t getTickRate() const;
|
Entity::ActorPtr m_sourceActor;
|
||||||
uint32_t getSrcActorId() const;
|
Entity::ActorPtr m_targetActor;
|
||||||
uint32_t getTargetActorId() const;
|
uint32_t m_duration;
|
||||||
uint64_t getLastTickMs() const;
|
uint64_t m_startTime;
|
||||||
uint64_t getStartTimeMs() const;
|
uint32_t m_tickRate;
|
||||||
uint16_t getParam() const;
|
uint64_t m_lastTick;
|
||||||
void setLastTick( uint64_t lastTick );
|
uint16_t m_param;
|
||||||
void setParam( uint16_t param );
|
std::string m_name;
|
||||||
void registerTickEffect( uint8_t type, uint32_t param );
|
std::pair< uint8_t, uint32_t > m_currTickEffect;
|
||||||
std::pair< uint8_t, uint32_t> getTickEffect();
|
};
|
||||||
const std::string& getName() const;
|
|
||||||
|
|
||||||
private:
|
} // namespace StatusEffect
|
||||||
uint32_t m_id;
|
} // namespace Core
|
||||||
Entity::ActorPtr m_sourceActor;
|
|
||||||
Entity::ActorPtr m_targetActor;
|
|
||||||
uint32_t m_duration;
|
|
||||||
uint64_t m_startTime;
|
|
||||||
uint32_t m_tickRate;
|
|
||||||
uint64_t m_lastTick;
|
|
||||||
uint16_t m_param;
|
|
||||||
std::string m_name;
|
|
||||||
std::pair< uint8_t, uint32_t> m_currTickEffect;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -5,167 +5,149 @@
|
||||||
#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 )
|
||||||
|
{
|
||||||
|
m_bForcedActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Cell::~Cell()
|
||||||
|
{
|
||||||
|
removeActors();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Cell::init( uint32_t x, uint32_t y, ZonePtr pZone )
|
||||||
|
{
|
||||||
|
// Console->outDebOnly("[Region:%X] Initializing a new cell[%i/%i]", pRegion->getId(), x, y );
|
||||||
|
m_pZone = pZone;
|
||||||
|
m_posX = x;
|
||||||
|
m_posY = y;
|
||||||
|
|
||||||
|
m_actors.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Cell::loadActors( CellCache* pCC )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
m_bLoaded = true;
|
||||||
|
assert( pCC );
|
||||||
|
|
||||||
Cell::Cell()
|
for( auto entry : pCC->battleNpcCache )
|
||||||
: m_bActive(false)
|
|
||||||
, m_bLoaded(false)
|
|
||||||
, m_playerCount(0)
|
|
||||||
, m_bUnloadPending(false)
|
|
||||||
{
|
|
||||||
m_bForcedActive = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Cell::~Cell()
|
|
||||||
{
|
|
||||||
removeActors();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::init(uint32_t x, uint32_t y, ZonePtr pZone)
|
|
||||||
{
|
|
||||||
//Console->outDebOnly("[Region:%X] Initializing a new cell[%i/%i]", pRegion->getId(), x, y );
|
|
||||||
m_pZone = pZone;
|
|
||||||
m_posX = x;
|
|
||||||
m_posY = y;
|
|
||||||
|
|
||||||
m_actors.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::loadActors(CellCache* pCC)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
m_bLoaded = true;
|
entry->setCurrentZone( m_pZone );
|
||||||
assert(pCC);
|
m_pZone->pushActor( entry );
|
||||||
|
|
||||||
for( auto entry : pCC->battleNpcCache )
|
|
||||||
{
|
|
||||||
|
|
||||||
entry->setCurrentZone( m_pZone );
|
|
||||||
m_pZone->pushActor( entry );
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cell::addActor(Entity::ActorPtr pAct)
|
|
||||||
{
|
|
||||||
if(pAct->isPlayer())
|
|
||||||
{
|
|
||||||
//Console->outDebOnly("[Region:%X] Adding player %i to cell[%i/%i]", m_pZone->getId(), pAct->getId(), m_posX, m_posY);
|
|
||||||
++m_playerCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_actors.insert(pAct);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::removeActor(Entity::ActorPtr pAct)
|
|
||||||
{
|
|
||||||
if(pAct->isPlayer())
|
|
||||||
{
|
|
||||||
//->outDebOnly("[Region:%X] Removing player %i from cell[%i/%i]", m_pZone->getId(), pAct->getId(), m_posX, m_posY);
|
|
||||||
--m_playerCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_actors.erase(pAct);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::setActivity(bool state)
|
|
||||||
{
|
|
||||||
if(!m_bActive && state)
|
|
||||||
{
|
|
||||||
// Move all objects to active set.
|
|
||||||
for(auto itr = m_actors.begin(); itr != m_actors.end(); ++itr)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(m_bUnloadPending)
|
|
||||||
{
|
|
||||||
cancelPendingUnload();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else if(m_bActive && !state)
|
|
||||||
{
|
|
||||||
// Move all objects from active set.
|
|
||||||
for(auto itr = m_actors.begin(); itr != m_actors.end(); ++itr)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
m_bActive = state;
|
|
||||||
|
|
||||||
}
|
|
||||||
void Cell::removeActors()
|
|
||||||
{
|
|
||||||
//uint32_t ltime = getMSTime();
|
|
||||||
|
|
||||||
m_actors.clear();
|
|
||||||
|
|
||||||
//This time it's simpler! We just remove everything
|
|
||||||
Entity::ActorPtr pAct; //do this outside the loop!
|
|
||||||
for(auto itr = m_actors.begin(); itr != m_actors.end();)
|
|
||||||
{
|
|
||||||
pAct = (*itr);
|
|
||||||
itr++;
|
|
||||||
|
|
||||||
if(!pAct)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(m_bUnloadPending)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
m_playerCount = 0;
|
|
||||||
m_bLoaded = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Cell::queueUnloadPending()
|
|
||||||
{
|
|
||||||
if(m_bUnloadPending)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_bUnloadPending = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::cancelPendingUnload()
|
|
||||||
{
|
|
||||||
|
|
||||||
if(!m_bUnloadPending)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::unload()
|
|
||||||
{
|
|
||||||
|
|
||||||
assert(m_bUnloadPending);
|
|
||||||
if(m_bActive)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
removeActors();
|
|
||||||
m_bUnloadPending = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Cell::addActor( Entity::ActorPtr pAct )
|
||||||
|
{
|
||||||
|
if( pAct->isPlayer() )
|
||||||
|
{
|
||||||
|
// Console->outDebOnly("[Region:%X] Adding player %i to cell[%i/%i]", m_pZone->getId(), pAct->getId(), m_posX,
|
||||||
|
// m_posY);
|
||||||
|
++m_playerCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_actors.insert( pAct );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Cell::removeActor( Entity::ActorPtr pAct )
|
||||||
|
{
|
||||||
|
if( pAct->isPlayer() )
|
||||||
|
{
|
||||||
|
//->outDebOnly("[Region:%X] Removing player %i from cell[%i/%i]", m_pZone->getId(), pAct->getId(), m_posX,
|
||||||
|
// m_posY);
|
||||||
|
--m_playerCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_actors.erase( pAct );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Cell::setActivity( bool state )
|
||||||
|
{
|
||||||
|
if( !m_bActive && state )
|
||||||
|
{
|
||||||
|
// Move all objects to active set.
|
||||||
|
for( auto itr = m_actors.begin(); itr != m_actors.end(); ++itr )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
if( m_bUnloadPending )
|
||||||
|
{
|
||||||
|
cancelPendingUnload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( m_bActive && !state )
|
||||||
|
{
|
||||||
|
// Move all objects from active set.
|
||||||
|
for( auto itr = m_actors.begin(); itr != m_actors.end(); ++itr )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_bActive = state;
|
||||||
|
}
|
||||||
|
void Cell::removeActors()
|
||||||
|
{
|
||||||
|
// uint32_t ltime = getMSTime();
|
||||||
|
|
||||||
|
m_actors.clear();
|
||||||
|
|
||||||
|
// This time it's simpler! We just remove everything
|
||||||
|
Entity::ActorPtr pAct; // do this outside the loop!
|
||||||
|
for( auto itr = m_actors.begin(); itr != m_actors.end(); )
|
||||||
|
{
|
||||||
|
pAct = ( *itr );
|
||||||
|
itr++;
|
||||||
|
|
||||||
|
if( !pAct )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( m_bUnloadPending )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_playerCount = 0;
|
||||||
|
m_bLoaded = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Cell::queueUnloadPending()
|
||||||
|
{
|
||||||
|
if( m_bUnloadPending )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_bUnloadPending = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Cell::cancelPendingUnload()
|
||||||
|
{
|
||||||
|
|
||||||
|
if( !m_bUnloadPending )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Cell::unload()
|
||||||
|
{
|
||||||
|
|
||||||
|
assert( m_bUnloadPending );
|
||||||
|
if( m_bActive )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
removeActors();
|
||||||
|
m_bUnloadPending = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Core
|
||||||
|
|
|
@ -9,120 +9,77 @@
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
|
struct CellCache
|
||||||
|
{
|
||||||
|
std::vector< Entity::BattleNpcPtr > battleNpcCache;
|
||||||
|
};
|
||||||
|
|
||||||
struct CellCache
|
typedef std::set< Entity::ActorPtr > ActorSet;
|
||||||
{
|
|
||||||
std::vector< Entity::BattleNpcPtr > battleNpcCache;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::set< Entity::ActorPtr > ActorSet;
|
class Cell
|
||||||
|
{
|
||||||
|
friend class Zone;
|
||||||
|
|
||||||
class Cell
|
private:
|
||||||
{
|
bool m_bForcedActive;
|
||||||
friend class Zone;
|
uint16_t m_posX;
|
||||||
|
uint16_t m_posY;
|
||||||
|
ActorSet m_actors;
|
||||||
|
bool m_bActive;
|
||||||
|
bool m_bLoaded;
|
||||||
|
bool m_bUnloadPending;
|
||||||
|
|
||||||
private:
|
uint16_t m_playerCount;
|
||||||
bool m_bForcedActive;
|
ZonePtr m_pZone;
|
||||||
uint16_t m_posX;
|
|
||||||
uint16_t m_posY;
|
|
||||||
ActorSet m_actors;
|
|
||||||
bool m_bActive;
|
|
||||||
bool m_bLoaded;
|
|
||||||
bool m_bUnloadPending;
|
|
||||||
|
|
||||||
uint16_t m_playerCount;
|
public:
|
||||||
ZonePtr m_pZone;
|
Cell();
|
||||||
|
~Cell();
|
||||||
|
|
||||||
public:
|
void init( uint32_t x, uint32_t y, ZonePtr pZone );
|
||||||
Cell();
|
|
||||||
~Cell();
|
|
||||||
|
|
||||||
void init(uint32_t x, uint32_t y, ZonePtr pZone);
|
void addActor( Entity::ActorPtr pAct );
|
||||||
|
|
||||||
void addActor(Entity::ActorPtr pAct);
|
void removeActor( Entity::ActorPtr pAct );
|
||||||
|
|
||||||
void removeActor(Entity::ActorPtr pAct);
|
void loadActors( CellCache* pCC );
|
||||||
|
|
||||||
void loadActors(CellCache* pCC);
|
bool hasActor( Entity::ActorPtr pAct ) { return ( m_actors.find( pAct ) != m_actors.end() ); }
|
||||||
|
|
||||||
bool hasActor(Entity::ActorPtr pAct)
|
bool hasPlayers() const { return ( ( m_playerCount > 0 ) ? true : false ); }
|
||||||
{
|
|
||||||
return (m_actors.find(pAct) != m_actors.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hasPlayers() const
|
size_t getActorCount() const { return m_actors.size(); }
|
||||||
{
|
|
||||||
return ((m_playerCount > 0) ? true : false);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t getActorCount() const
|
void removeActors();
|
||||||
{
|
|
||||||
return m_actors.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
void removeActors();
|
ActorSet::iterator begin() { return m_actors.begin(); }
|
||||||
|
|
||||||
ActorSet::iterator begin()
|
ActorSet::iterator end() { return m_actors.end(); }
|
||||||
{
|
|
||||||
return m_actors.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
ActorSet::iterator end()
|
void setActivity( bool state );
|
||||||
{
|
|
||||||
return m_actors.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setActivity(bool state);
|
bool isActive() const { return m_bActive; }
|
||||||
|
|
||||||
bool isActive() const
|
bool isLoaded() const { return m_bLoaded; }
|
||||||
{
|
|
||||||
return m_bActive;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isLoaded() const
|
uint32_t getPlayerCount() const { return m_playerCount; }
|
||||||
{
|
|
||||||
return m_bLoaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t getPlayerCount() const
|
bool isUnloadPending() const { return m_bUnloadPending; }
|
||||||
{
|
|
||||||
return m_playerCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isUnloadPending() const
|
void setUnloadPending( bool up ) { m_bUnloadPending = up; }
|
||||||
{
|
|
||||||
return m_bUnloadPending;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setUnloadPending(bool up)
|
void queueUnloadPending();
|
||||||
{
|
void cancelPendingUnload();
|
||||||
m_bUnloadPending = up;
|
void unload();
|
||||||
}
|
|
||||||
|
|
||||||
void queueUnloadPending();
|
void setPermanentActivity( bool val ) { m_bForcedActive = val; }
|
||||||
void cancelPendingUnload();
|
|
||||||
void unload();
|
|
||||||
|
|
||||||
void setPermanentActivity(bool val)
|
bool isForcedActive() const { return m_bForcedActive; }
|
||||||
{
|
|
||||||
m_bForcedActive = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isForcedActive() const
|
uint16_t getPosX() const { return m_posX; }
|
||||||
{
|
|
||||||
return m_bForcedActive;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t getPosX() const
|
uint16_t getPosY() const { return m_posY; }
|
||||||
{
|
};
|
||||||
return m_posX;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t getPosY() const
|
} // namespace Core
|
||||||
{
|
|
||||||
return m_posY;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3,23 +3,23 @@
|
||||||
|
|
||||||
#define TilesCount 32
|
#define TilesCount 32
|
||||||
#define TileSize 250.0f
|
#define TileSize 250.0f
|
||||||
#define _minY (-TilesCount*TileSize/2)
|
#define _minY ( -TilesCount * TileSize / 2 )
|
||||||
#define _minX (-TilesCount*TileSize/2)
|
#define _minX ( -TilesCount * TileSize / 2 )
|
||||||
|
|
||||||
#define _maxY (TilesCount*TileSize/2)
|
#define _maxY ( TilesCount * TileSize / 2 )
|
||||||
#define _maxX (TilesCount*TileSize/2)
|
#define _maxX ( TilesCount * TileSize / 2 )
|
||||||
|
|
||||||
#define CellsPerTile 4
|
#define CellsPerTile 4
|
||||||
#define _cellSize (TileSize/CellsPerTile)
|
#define _cellSize ( TileSize / CellsPerTile )
|
||||||
#define _sizeX (TilesCount*CellsPerTile)
|
#define _sizeX ( TilesCount * CellsPerTile )
|
||||||
#define _sizeY (TilesCount*CellsPerTile)
|
#define _sizeY ( TilesCount * CellsPerTile )
|
||||||
|
|
||||||
#define GetRelatCoord(Coord,CellCoord) ((_maxX-Coord)-CellCoord*_cellSize)
|
#define GetRelatCoord( Coord, CellCoord ) ( ( _maxX - Coord ) - CellCoord * _cellSize )
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
class Zone;
|
class Zone;
|
||||||
|
|
||||||
template<class T>
|
template< class T >
|
||||||
class CellHandler
|
class CellHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -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,21 +40,18 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void _init();
|
void _init();
|
||||||
|
|
||||||
|
T*** m_pCells;
|
||||||
T *** m_pCells;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template< class T >
|
||||||
CellHandler<T>::CellHandler()
|
CellHandler< T >::CellHandler()
|
||||||
{
|
{
|
||||||
|
|
||||||
_init();
|
_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template< class T >
|
||||||
template <class T>
|
void CellHandler< T >::_init()
|
||||||
void CellHandler<T>::_init()
|
|
||||||
{
|
{
|
||||||
m_pCells = new T**[_sizeX];
|
m_pCells = new T**[_sizeX];
|
||||||
|
|
||||||
|
@ -66,11 +60,10 @@ void CellHandler<T>::_init()
|
||||||
{
|
{
|
||||||
m_pCells[i] = nullptr;
|
m_pCells[i] = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template< class T >
|
||||||
CellHandler<T>::~CellHandler()
|
CellHandler< T >::~CellHandler()
|
||||||
{
|
{
|
||||||
if( m_pCells )
|
if( m_pCells )
|
||||||
{
|
{
|
||||||
|
@ -94,8 +87,8 @@ CellHandler<T>::~CellHandler()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template< class T >
|
||||||
T* CellHandler<T>::create( uint32_t x, uint32_t y )
|
T* CellHandler< T >::create( uint32_t x, uint32_t y )
|
||||||
{
|
{
|
||||||
if( x >= _sizeX || y >= _sizeY )
|
if( x >= _sizeX || y >= _sizeY )
|
||||||
{
|
{
|
||||||
|
@ -105,25 +98,25 @@ T* CellHandler<T>::create( uint32_t x, uint32_t y )
|
||||||
if( !m_pCells[x] )
|
if( !m_pCells[x] )
|
||||||
{
|
{
|
||||||
m_pCells[x] = new T*[_sizeY];
|
m_pCells[x] = new T*[_sizeY];
|
||||||
memset( m_pCells[x], 0, sizeof( T* )*_sizeY );
|
memset( m_pCells[x], 0, sizeof( T* ) * _sizeY );
|
||||||
}
|
}
|
||||||
|
|
||||||
assert( m_pCells[x][y] == nullptr );
|
assert( m_pCells[x][y] == nullptr );
|
||||||
|
|
||||||
T *cls = new T;
|
T* cls = new T;
|
||||||
m_pCells[x][y] = cls;
|
m_pCells[x][y] = cls;
|
||||||
|
|
||||||
return cls;
|
return cls;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template< class T >
|
||||||
T* CellHandler<T>::createByCoords( float x, float y )
|
T* CellHandler< T >::createByCoords( float x, float y )
|
||||||
{
|
{
|
||||||
return create( getPosX( x ), getPosY( y ) );
|
return create( getPosX( x ), getPosY( y ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template< class T >
|
||||||
void CellHandler<T>::remove( uint32_t x, uint32_t y )
|
void CellHandler< T >::remove( uint32_t x, uint32_t y )
|
||||||
{
|
{
|
||||||
if( x >= _sizeX || y >= _sizeY )
|
if( x >= _sizeX || y >= _sizeY )
|
||||||
{
|
{
|
||||||
|
@ -137,14 +130,14 @@ void CellHandler<T>::remove( uint32_t x, uint32_t y )
|
||||||
|
|
||||||
assert( m_pCells[x][y] != nullptr );
|
assert( m_pCells[x][y] != nullptr );
|
||||||
|
|
||||||
T *cls = m_pCells[x][y];
|
T* cls = m_pCells[x][y];
|
||||||
m_pCells[x][y] = nullptr;
|
m_pCells[x][y] = nullptr;
|
||||||
|
|
||||||
delete cls;
|
delete cls;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template< class T >
|
||||||
T* CellHandler<T>::getCell( uint32_t x, uint32_t y )
|
T* CellHandler< T >::getCell( uint32_t x, uint32_t y )
|
||||||
{
|
{
|
||||||
if( !m_pCells[x] )
|
if( !m_pCells[x] )
|
||||||
{
|
{
|
||||||
|
@ -154,25 +147,25 @@ T* CellHandler<T>::getCell( uint32_t x, uint32_t y )
|
||||||
return m_pCells[x][y];
|
return m_pCells[x][y];
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template< class T >
|
||||||
T* CellHandler<T>::getCellByCoords( float x, float y )
|
T* CellHandler< T >::getCellByCoords( float x, float y )
|
||||||
{
|
{
|
||||||
return getCell( getPosX( x ), getPosY( y ) );
|
return getCell( getPosX( x ), getPosY( y ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template< class T >
|
||||||
uint32_t CellHandler<T>::getPosX( float x )
|
uint32_t CellHandler< T >::getPosX( float x )
|
||||||
{
|
{
|
||||||
assert( ( x >= _minX ) && ( x <= _maxX ) );
|
assert( ( x >= _minX ) && ( x <= _maxX ) );
|
||||||
return ( uint32_t ) ( ( _maxX - x ) / _cellSize );
|
return ( uint32_t )( ( _maxX - x ) / _cellSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template< class T >
|
||||||
uint32_t CellHandler<T>::getPosY( float y )
|
uint32_t CellHandler< T >::getPosY( float y )
|
||||||
{
|
{
|
||||||
assert( ( y >= _minY ) && ( y <= _maxY ) );
|
assert( ( y >= _minY ) && ( y <= _maxY ) );
|
||||||
return ( uint32_t ) ( ( _maxY - y ) / _cellSize );
|
return ( uint32_t )( ( _maxY - y ) / _cellSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace Core
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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"
|
||||||
|
|
||||||
|
@ -38,22 +38,22 @@ extern Core::Scripting::ScriptManager g_scriptMgr;
|
||||||
namespace Core {
|
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;
|
||||||
|
|
||||||
|
@ -117,12 +117,12 @@ CellCache* Zone::getCellCacheAndCreate( uint32_t cellx, uint32_t celly )
|
||||||
if( m_pCellCache[cellx] == nullptr )
|
if( m_pCellCache[cellx] == nullptr )
|
||||||
{
|
{
|
||||||
m_pCellCache[cellx] = new CellCache*[_sizeY];
|
m_pCellCache[cellx] = new CellCache*[_sizeY];
|
||||||
memset(m_pCellCache[cellx], 0, sizeof( CellCache* ) * _sizeY);
|
memset( m_pCellCache[cellx], 0, sizeof( CellCache* ) * _sizeY );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_pCellCache[cellx][celly] == nullptr )
|
if( m_pCellCache[cellx][celly] == nullptr )
|
||||||
{
|
{
|
||||||
//m_pCellCache[cellx][celly] = new CellCache;
|
// m_pCellCache[cellx][celly] = new CellCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_pCellCache[cellx][celly];
|
return m_pCellCache[cellx][celly];
|
||||||
|
@ -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,12 +205,11 @@ 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()
|
||||||
{
|
{
|
||||||
auto zoneInfo = g_exdData.m_zoneInfoMap[ getLayoutId() ];
|
auto zoneInfo = g_exdData.m_zoneInfoMap[getLayoutId()];
|
||||||
|
|
||||||
uint32_t unixTime = static_cast< uint32_t >( time( nullptr ) );
|
uint32_t unixTime = static_cast< uint32_t >( time( nullptr ) );
|
||||||
// Get Eorzea hour for weather start
|
// Get Eorzea hour for weather start
|
||||||
|
@ -227,7 +225,7 @@ uint8_t Zone::getNextWeather()
|
||||||
uint32_t step1 = ( calcBase << 0xB ) ^ calcBase;
|
uint32_t step1 = ( calcBase << 0xB ) ^ calcBase;
|
||||||
uint32_t step2 = ( step1 >> 8 ) ^ step1;
|
uint32_t step2 = ( step1 >> 8 ) ^ step1;
|
||||||
|
|
||||||
uint8_t rate = static_cast< uint8_t >(step2 % 0x64);
|
uint8_t rate = static_cast< uint8_t >( step2 % 0x64 );
|
||||||
|
|
||||||
for( auto entry : zoneInfo.weather_rate_map )
|
for( auto entry : zoneInfo.weather_rate_map )
|
||||||
{
|
{
|
||||||
|
@ -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() )
|
||||||
{
|
{
|
||||||
|
@ -402,9 +393,9 @@ std::size_t Zone::getPopCount() const
|
||||||
|
|
||||||
bool Zone::checkWeather()
|
bool Zone::checkWeather()
|
||||||
{
|
{
|
||||||
if ( m_weatherOverride != 0 )
|
if( m_weatherOverride != 0 )
|
||||||
{
|
{
|
||||||
if ( m_weatherOverride != m_currentWeather )
|
if( m_weatherOverride != m_currentWeather )
|
||||||
{
|
{
|
||||||
m_currentWeather = m_weatherOverride;
|
m_currentWeather = m_weatherOverride;
|
||||||
g_log.debug( "[Zone:" + m_zoneCode + "] overriding weather to : " + std::to_string( m_weatherOverride ) );
|
g_log.debug( "[Zone:" + m_zoneCode + "] overriding weather to : " + std::to_string( m_weatherOverride ) );
|
||||||
|
@ -414,7 +405,7 @@ bool Zone::checkWeather()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto nextWeather = getNextWeather();
|
auto nextWeather = getNextWeather();
|
||||||
if ( nextWeather != m_currentWeather )
|
if( nextWeather != m_currentWeather )
|
||||||
{
|
{
|
||||||
m_currentWeather = nextWeather;
|
m_currentWeather = nextWeather;
|
||||||
g_log.debug( "[Zone:" + m_zoneCode + "] changing weather to : " + std::to_string( nextWeather ) );
|
g_log.debug( "[Zone:" + m_zoneCode + "] changing weather to : " + std::to_string( nextWeather ) );
|
||||||
|
@ -451,7 +442,6 @@ void Zone::updateBnpcs( int64_t tickCount )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for( auto entry : m_BattleNpcMap )
|
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 );
|
||||||
|
@ -576,21 +566,21 @@ void Zone::updateCellActivity( uint32_t x, uint32_t y, int32_t radius )
|
||||||
|
|
||||||
assert( !pCell->isLoaded() );
|
assert( !pCell->isLoaded() );
|
||||||
|
|
||||||
CellCache * pCC = getCellCacheAndCreate( posX, posY );
|
CellCache* pCC = getCellCacheAndCreate( posX, posY );
|
||||||
if( pCC )
|
if( pCC )
|
||||||
pCell->loadActors( pCC );
|
pCell->loadActors( pCC );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Cell is now active
|
// Cell is now active
|
||||||
if( isCellActive( posX, posY ) && !pCell->isActive() )
|
if( isCellActive( posX, posY ) && !pCell->isActive() )
|
||||||
{
|
{
|
||||||
pCell->setActivity( true );
|
pCell->setActivity( true );
|
||||||
|
|
||||||
if( !pCell->isLoaded() )
|
if( !pCell->isLoaded() )
|
||||||
{
|
{
|
||||||
CellCache * pCC = getCellCacheAndCreate( posX, posY );
|
CellCache* pCC = getCellCacheAndCreate( posX, posY );
|
||||||
if( pCC )
|
if( pCC )
|
||||||
pCell->loadActors( pCC );
|
pCell->loadActors( pCC );
|
||||||
}
|
}
|
||||||
|
@ -613,17 +603,13 @@ void Zone::changeActorPosition( Entity::ActorPtr pActor )
|
||||||
Entity::ActorPtr pCurAct;
|
Entity::ActorPtr pCurAct;
|
||||||
|
|
||||||
float fRange = 70.0f;
|
float fRange = 70.0f;
|
||||||
for( auto iter = pActor->m_inRangeActors.begin(); iter != pActor->m_inRangeActors.end();)
|
for( auto iter = pActor->m_inRangeActors.begin(); iter != pActor->m_inRangeActors.end(); )
|
||||||
{
|
{
|
||||||
pCurAct = *iter;
|
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 )
|
||||||
{
|
{
|
||||||
|
@ -676,8 +662,8 @@ void Zone::changeActorPosition( Entity::ActorPtr pActor )
|
||||||
if( pOldCell != nullptr )
|
if( pOldCell != nullptr )
|
||||||
{
|
{
|
||||||
// only do the second check if theres -/+ 2 difference
|
// only do the second check if theres -/+ 2 difference
|
||||||
if( abs( ( int32_t ) cellX - ( int32_t ) pOldCell->m_posX ) > 2 ||
|
if( abs( (int32_t)cellX - (int32_t)pOldCell->m_posX ) > 2 ||
|
||||||
abs( ( int32_t ) cellY - ( int32_t ) pOldCell->m_posY ) > 2 )
|
abs( (int32_t)cellY - (int32_t)pOldCell->m_posY ) > 2 )
|
||||||
updateCellActivity( pOldCell->m_posX, pOldCell->m_posY, 2 );
|
updateCellActivity( pOldCell->m_posX, pOldCell->m_posY, 2 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -701,7 +687,6 @@ void Zone::changeActorPosition( Entity::ActorPtr pActor )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Zone::updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell )
|
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
|
||||||
|
|
|
@ -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,11 +26,13 @@ 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;
|
||||||
uint32_t m_layoutId;
|
uint32_t m_layoutId;
|
||||||
|
|
||||||
std::string m_zoneName;
|
std::string m_zoneName;
|
||||||
std::string m_zoneCode;
|
std::string m_zoneCode;
|
||||||
|
@ -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
|
||||||
|
|
|
@ -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>
|
||||||
|
@ -13,77 +13,76 @@ extern Core::Data::ExdData g_exdData;
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
ZoneMgr::ZoneMgr() = default;
|
ZoneMgr::ZoneMgr() = default;
|
||||||
|
|
||||||
ZoneMgr::~ZoneMgr() = default;
|
ZoneMgr::~ZoneMgr() = default;
|
||||||
|
|
||||||
void ZoneMgr::loadZonePositionMap()
|
void ZoneMgr::loadZonePositionMap()
|
||||||
|
{
|
||||||
|
auto pQR = g_charaDb.query( "SELECT id, target_zone_id, pos_x, pos_y, pos_z, pos_o, radius FROM zonepositions;" );
|
||||||
|
|
||||||
|
while( pQR->next() )
|
||||||
{
|
{
|
||||||
auto pQR = g_charaDb.query( "SELECT id, target_zone_id, pos_x, pos_y, pos_z, pos_o, radius FROM zonepositions;" );
|
uint32_t id = pQR->getUInt( 1 );
|
||||||
|
uint32_t targetZoneId = pQR->getUInt( 2 );
|
||||||
|
Common::FFXIVARR_POSITION3 pos;
|
||||||
|
pos.x = pQR->getFloat( 3 );
|
||||||
|
pos.y = pQR->getFloat( 4 );
|
||||||
|
pos.z = pQR->getFloat( 5 );
|
||||||
|
float posO = pQR->getFloat( 6 );
|
||||||
|
uint32_t radius = pQR->getUInt( 7 );
|
||||||
|
|
||||||
while( pQR->next() )
|
m_zonePositionMap[id] = ZonePositionPtr( new ZonePosition( id, targetZoneId, pos, radius, posO ) );
|
||||||
{
|
|
||||||
uint32_t id = pQR->getUInt( 1 );
|
|
||||||
uint32_t targetZoneId = pQR->getUInt( 2 );
|
|
||||||
Common::FFXIVARR_POSITION3 pos;
|
|
||||||
pos.x = pQR->getFloat( 3 );
|
|
||||||
pos.y = pQR->getFloat( 4 );
|
|
||||||
pos.z = pQR->getFloat( 5 );
|
|
||||||
float posO = pQR->getFloat( 6 );
|
|
||||||
uint32_t radius = pQR->getUInt( 7 );
|
|
||||||
|
|
||||||
m_zonePositionMap[id] = ZonePositionPtr( new ZonePosition( id, targetZoneId, pos, radius, posO ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ZonePositionPtr ZoneMgr::getZonePosition( uint32_t zonePositionId )
|
|
||||||
{
|
|
||||||
auto it = m_zonePositionMap.find( zonePositionId );
|
|
||||||
|
|
||||||
if( it != m_zonePositionMap.end() )
|
|
||||||
return it->second;
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ZoneMgr::createZones()
|
|
||||||
{
|
|
||||||
loadZonePositionMap();
|
|
||||||
|
|
||||||
// find zone info from exd
|
|
||||||
for( auto zone : g_exdData.m_zoneInfoMap )
|
|
||||||
{
|
|
||||||
uint32_t zoneId = zone.first;
|
|
||||||
|
|
||||||
|
|
||||||
auto info = zone.second;
|
|
||||||
g_log.Log( LoggingSeverity::info, std::to_string( info.id ) + "\t" + info.zone_str );
|
|
||||||
|
|
||||||
ZonePtr pZone( new Zone( info.id, info.layout_id, info.zone_name, info.zone_str, false ) );
|
|
||||||
pZone->init();
|
|
||||||
m_zoneMap[info.id] = pZone;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ZoneMgr::updateZones()
|
|
||||||
{
|
|
||||||
for( auto zone : m_zoneMap )
|
|
||||||
{
|
|
||||||
zone.second->runZoneLogic();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ZonePtr ZoneMgr::getZone( uint32_t zoneId )
|
|
||||||
{
|
|
||||||
ZoneMap::iterator it;
|
|
||||||
it = m_zoneMap.find( zoneId );
|
|
||||||
|
|
||||||
if( it != m_zoneMap.end() )
|
|
||||||
return it->second;
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZonePositionPtr ZoneMgr::getZonePosition( uint32_t zonePositionId )
|
||||||
|
{
|
||||||
|
auto it = m_zonePositionMap.find( zonePositionId );
|
||||||
|
|
||||||
|
if( it != m_zonePositionMap.end() )
|
||||||
|
return it->second;
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ZoneMgr::createZones()
|
||||||
|
{
|
||||||
|
loadZonePositionMap();
|
||||||
|
|
||||||
|
// find zone info from exd
|
||||||
|
for( auto zone : g_exdData.m_zoneInfoMap )
|
||||||
|
{
|
||||||
|
uint32_t zoneId = zone.first;
|
||||||
|
|
||||||
|
auto info = zone.second;
|
||||||
|
g_log.Log( LoggingSeverity::info, std::to_string( info.id ) + "\t" + info.zone_str );
|
||||||
|
|
||||||
|
ZonePtr pZone( new Zone( info.id, info.layout_id, info.zone_name, info.zone_str, false ) );
|
||||||
|
pZone->init();
|
||||||
|
m_zoneMap[info.id] = pZone;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneMgr::updateZones()
|
||||||
|
{
|
||||||
|
for( auto zone : m_zoneMap )
|
||||||
|
{
|
||||||
|
zone.second->runZoneLogic();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ZonePtr ZoneMgr::getZone( uint32_t zoneId )
|
||||||
|
{
|
||||||
|
ZoneMap::iterator it;
|
||||||
|
it = m_zoneMap.find( zoneId );
|
||||||
|
|
||||||
|
if( it != m_zoneMap.end() )
|
||||||
|
return it->second;
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Core
|
||||||
|
|
|
@ -1,39 +1,36 @@
|
||||||
#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 {
|
||||||
|
|
||||||
using ZoneMap = std::unordered_map< uint32_t, ZonePtr >;
|
using ZoneMap = std::unordered_map< uint32_t, ZonePtr >;
|
||||||
|
|
||||||
class ZoneMgr
|
class ZoneMgr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ZoneMgr();
|
ZoneMgr();
|
||||||
~ZoneMgr();
|
~ZoneMgr();
|
||||||
|
|
||||||
bool createZones();
|
bool createZones();
|
||||||
|
|
||||||
ZonePtr getZone( uint32_t zoneId );
|
ZonePtr getZone( uint32_t zoneId );
|
||||||
|
|
||||||
void loadZonePositionMap();
|
void loadZonePositionMap();
|
||||||
|
|
||||||
ZonePositionPtr getZonePosition( uint32_t zonePositionId );
|
ZonePositionPtr getZonePosition( uint32_t zonePositionId );
|
||||||
|
|
||||||
void updateZones();
|
void updateZones();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
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
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -30,7 +28,7 @@ uint32_t Core::ZonePosition::getTargetZoneId() const
|
||||||
return m_targetZoneId;
|
return m_targetZoneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Core::Common::FFXIVARR_POSITION3 & Core::ZonePosition::getTargetPosition() const
|
const Core::Common::FFXIVARR_POSITION3& Core::ZonePosition::getTargetPosition() const
|
||||||
{
|
{
|
||||||
return m_targetPos;
|
return m_targetPos;
|
||||||
}
|
}
|
||||||
|
@ -39,5 +37,3 @@ float Core::ZonePosition::getTargetRotation() const
|
||||||
{
|
{
|
||||||
return m_rotation;
|
return m_rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,15 +8,16 @@ namespace Core {
|
||||||
class ZonePosition
|
class ZonePosition
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
uint32_t m_id;
|
uint32_t m_id;
|
||||||
uint32_t m_targetZoneId;
|
uint32_t m_targetZoneId;
|
||||||
Common::FFXIVARR_POSITION3 m_targetPos;
|
Common::FFXIVARR_POSITION3 m_targetPos;
|
||||||
float m_rotation;
|
float m_rotation;
|
||||||
uint32_t m_radius;
|
uint32_t m_radius;
|
||||||
|
|
||||||
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
|
||||||
|
|
Loading…
Add table
Reference in a new issue