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

Apply clang-format to zone server

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,11 +1,11 @@
#include <Server_Common/Util/Util.h>
#include <Server_Common/Util/UtilMath.h>
#include <Server_Common/Network/PacketContainer.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Network/GamePacket.h>
#include <Server_Common/Network/PacketContainer.h>
#include <Server_Common/Util/Util.h>
#include <Server_Common/Util/UtilMath.h>
#include "Forwards.h"
#include "Action/Action.h"
#include "Forwards.h"
#include "Zone/Zone.h"
@ -15,13 +15,13 @@
#include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Network/PacketWrappers/UpdateHpMpTpPacket.h"
#include "StatusEffect/StatusEffect.h"
#include "Action/ActionCollision.h"
#include "Actor.h"
#include "Math/CalcBattle.h"
#include "Player.h"
#include "ServerZone.h"
#include "Session.h"
#include "Math/CalcBattle.h"
#include "Actor.h"
#include "Player.h"
#include "StatusEffect/StatusEffect.h"
extern Core::ServerZone g_serverZone;
extern Core::Data::ExdData g_exdData;
@ -243,12 +243,12 @@ void Core::Entity::Actor::die()
// if the actor is a player, the update needs to be send to himself too
bool selfNeedsUpdate = isPlayer();
sendToInRangeSet( ActorControlPacket142( m_id, SetStatus, static_cast< uint8_t >( ActorStatus::Dead ) ), selfNeedsUpdate );
sendToInRangeSet( ActorControlPacket142( m_id, SetStatus, static_cast< uint8_t >( ActorStatus::Dead ) ),
selfNeedsUpdate );
// TODO: not all actor show the death animation when they die, some quest npcs might just despawn
// although that might be handled by setting the HP to 1 and doing some script magic
sendToInRangeSet( ActorControlPacket142( m_id, DeathAnimation, 0, 0, 0, 0x20 ), selfNeedsUpdate );
}
/*!
@ -318,7 +318,6 @@ bool Core::Entity::Actor::checkAction()
m_pCurrentAction.reset();
return true;
}
/*!
@ -330,8 +329,7 @@ void Core::Entity::Actor::changeTarget( uint64_t targetId )
{
setTargetId( targetId );
sendToInRangeSet( ActorControlPacket144( m_id, SetTarget,
0, 0, 0, 0, targetId ) );
sendToInRangeSet( ActorControlPacket144( m_id, SetTarget, 0, 0, 0, 0, targetId ) );
}
/*!
@ -355,7 +353,8 @@ void Core::Entity::Actor::takeDamage( uint32_t damage )
{
if( damage >= m_hp )
{
switch( m_invincibilityType ) {
switch( m_invincibilityType )
{
case InvincibilityNone:
setHp( 0 );
die();
@ -455,12 +454,8 @@ Core::Entity::ActorPtr Core::Entity::Actor::getClosestActor()
for( const auto& pCurAct : m_inRangeActors )
{
float distance = Math::Util::distance( getPos().x,
getPos().y,
getPos().z,
pCurAct->getPos().x,
pCurAct->getPos().y,
pCurAct->getPos().z );
float distance = Math::Util::distance( getPos().x, getPos().y, getPos().z, pCurAct->getPos().x,
pCurAct->getPos().y, pCurAct->getPos().z );
if( distance < minDistance )
{
@ -660,8 +655,8 @@ ChaiScript Skill Handler.
\param GamePacketPtr to send
\param bool should be send to self?
*/
void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, uint64_t param1,
uint64_t param2, Entity::Actor& pTarget )
void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, uint64_t param1, uint64_t param2,
Entity::Actor& pTarget )
{
if( isPlayer() )
@ -685,7 +680,8 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
effectPacket.data().rotation = Math::Util::floatToUInt16Rot( getRotation() );
effectPacket.data().effectTarget = pTarget.getId();
// Todo: for each actor, calculate how much damage the calculated value should deal to them - 2-step damage calc. we only have 1-step
// Todo: for each actor, calculate how much damage the calculated value should deal to them - 2-step damage calc. we
// only have 1-step
switch( type )
{
@ -708,7 +704,6 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
pTarget.onActionHostile( shared_from_this() );
pTarget.takeDamage( static_cast< uint32_t >( param1 ) );
}
else
{
@ -724,7 +719,6 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
// todo: send to range of what? ourselves? when mob script hits this is going to be lacking
sendToInRangeSet( effectPacket, true );
if( pHitActor->isAlive() )
pHitActor->onActionHostile( shared_from_this() );
@ -734,7 +728,8 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
if( isPlayer() )
{
if( pHitActor->isPlayer() )
getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) + " (" + pHitActor->getName() + ")" );
getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) + " (" +
pHitActor->getName() + ")" );
else
getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) );
}
@ -746,7 +741,8 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
case ActionEffectType::Heal:
{
uint32_t calculatedHeal = Math::CalcBattle::calculateHealValue( getAsPlayer(), static_cast< uint32_t >( param1 ) );
uint32_t calculatedHeal =
Math::CalcBattle::calculateHealValue( getAsPlayer(), static_cast< uint32_t >( param1 ) );
effectPacket.data().effects[0].value = calculatedHeal;
effectPacket.data().effects[0].effectType = ActionEffectType::Heal;
@ -780,7 +776,8 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
if( isPlayer() )
{
if( pHitActor->isPlayer() )
getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) + " (" + pHitActor->getName() + ")" );
getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) + " (" +
pHitActor->getName() + ")" );
else
getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) );
}
@ -826,23 +823,23 @@ void Core::Entity::Actor::addStatusEffect( StatusEffect::StatusEffectPtr pEffect
/*! \param StatusEffectPtr to be applied to the actor */
void Core::Entity::Actor::addStatusEffectById( uint32_t id, int32_t duration, Entity::Actor& pSource, uint16_t param )
{
StatusEffect::StatusEffectPtr effect( new StatusEffect::StatusEffect( id, pSource.shared_from_this(),
shared_from_this(), duration, 3000 ) );
StatusEffect::StatusEffectPtr effect(
new StatusEffect::StatusEffect( id, pSource.shared_from_this(), shared_from_this(), duration, 3000 ) );
effect->setParam( param );
addStatusEffect( effect );
}
/*! \param StatusEffectPtr to be applied to the actor */
void Core::Entity::Actor::addStatusEffectByIdIfNotExist( uint32_t id, int32_t duration, Entity::Actor& pSource, uint16_t param )
void Core::Entity::Actor::addStatusEffectByIdIfNotExist( uint32_t id, int32_t duration, Entity::Actor& pSource,
uint16_t param )
{
if( hasStatusEffect( id ) )
return;
StatusEffect::StatusEffectPtr effect( new StatusEffect::StatusEffect( id, pSource.shared_from_this(),
shared_from_this(), duration, 3000 ) );
StatusEffect::StatusEffectPtr effect(
new StatusEffect::StatusEffect( id, pSource.shared_from_this(), shared_from_this(), duration, 3000 ) );
effect->setParam( param );
addStatusEffect( effect );
}
float Core::Entity::Actor::getRotation() const
@ -923,7 +920,8 @@ void Core::Entity::Actor::sendStatusEffectUpdate()
for( auto effectIt : m_statusEffectMap )
{
float timeLeft = static_cast< float >( effectIt.second->getDuration() -
( currentTimeMs - effectIt.second->getStartTimeMs() ) ) / 1000;
( currentTimeMs - effectIt.second->getStartTimeMs() ) ) /
1000;
statusEffectList.data().effect[slot].duration = timeLeft;
statusEffectList.data().effect[slot].effect_id = effectIt.second->getId();
statusEffectList.data().effect[slot].sourceActorId = effectIt.second->getSrcActorId();
@ -931,7 +929,6 @@ void Core::Entity::Actor::sendStatusEffectUpdate()
}
sendToInRangeSet( statusEffectList, isPlayer() );
}
void Core::Entity::Actor::updateStatusEffects()
@ -980,22 +977,22 @@ void Core::Entity::Actor::updateStatusEffects()
thisTickHeal += thisEffect.second;
break;
}
}
}
}
if( thisTickDmg != 0 )
{
takeDamage( thisTickDmg );
sendToInRangeSet( ActorControlPacket142( getId(), HPFloatingText, 0, static_cast< uint8_t >( ActionEffectType::Damage ), thisTickDmg ) );
sendToInRangeSet( ActorControlPacket142( getId(), HPFloatingText, 0,
static_cast< uint8_t >( ActionEffectType::Damage ), thisTickDmg ) );
}
if( thisTickHeal != 0 )
{
heal( thisTickDmg );
sendToInRangeSet( ActorControlPacket142( getId(), HPFloatingText, 0, static_cast< uint8_t >( ActionEffectType::Heal ), thisTickHeal ) );
sendToInRangeSet( ActorControlPacket142( getId(), HPFloatingText, 0,
static_cast< uint8_t >( ActionEffectType::Heal ), thisTickHeal ) );
}
}

View file

@ -5,9 +5,9 @@
#include <boost/enable_shared_from_this.hpp>
#include "Forwards.h"
#include <set>
#include <map>
#include <queue>
#include <set>
namespace Core {
namespace Entity {
@ -272,7 +272,8 @@ public:
void setStatus( ActorStatus status );
void handleScriptSkill( uint32_t type, uint16_t actionId, uint64_t param1, uint64_t param2, Entity::Actor& target );
void handleScriptSkill( uint32_t type, uint16_t actionId, uint64_t param1, uint64_t param2,
Entity::Actor& target );
virtual void autoAttack( ActorPtr pTarget );
@ -332,16 +333,14 @@ public:
// set the current cell
void setCell( Cell* pCell );
// TODO: Why did i even declare them publicly here?!
std::set< ActorPtr > m_inRangeActors;
std::set< PlayerPtr > m_inRangePlayers;
std::map< uint32_t, ActorPtr > m_inRangeActorMap;
Core::Cell* m_pCell;
};
}
}
} // namespace Entity
} // namespace Core
#endif

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,12 +4,11 @@
#include <map>
#include "DebugCommand.h"
#include <Server_Common/Common.h>
#include "Forwards.h"
#include <Server_Common/Common.h>
namespace Core {
// handler for in game commands
class DebugCommandHandler
{
@ -44,8 +43,7 @@ public:
void unlockCharacter( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void targetInfo( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
};
}
} // namespace Core
#endif

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -5,18 +5,11 @@
#include "Forwards.h"
#include "Zone.h"
// TODO: the entire zone / areahandling is a bit outdated ( in parts i used this for the 1.0 iteration )
// likely this could be greatly improved or redone
namespace Core
{
namespace Core {
Cell::Cell()
: m_bActive(false)
, m_bLoaded(false)
, m_playerCount(0)
, m_bUnloadPending(false)
Cell::Cell() : m_bActive( false ), m_bLoaded( false ), m_playerCount( 0 ), m_bUnloadPending( false )
{
m_bForcedActive = false;
}
@ -47,7 +40,6 @@ namespace Core
entry->setCurrentZone( m_pZone );
m_pZone->pushActor( entry );
}
}
@ -55,7 +47,8 @@ namespace Core
{
if( pAct->isPlayer() )
{
//Console->outDebOnly("[Region:%X] Adding player %i to cell[%i/%i]", m_pZone->getId(), pAct->getId(), m_posX, m_posY);
// Console->outDebOnly("[Region:%X] Adding player %i to cell[%i/%i]", m_pZone->getId(), pAct->getId(), m_posX,
// m_posY);
++m_playerCount;
}
@ -66,7 +59,8 @@ namespace Core
{
if( pAct->isPlayer() )
{
//->outDebOnly("[Region:%X] Removing player %i from cell[%i/%i]", m_pZone->getId(), pAct->getId(), m_posX, m_posY);
//->outDebOnly("[Region:%X] Removing player %i from cell[%i/%i]", m_pZone->getId(), pAct->getId(), m_posX,
// m_posY);
--m_playerCount;
}
@ -80,28 +74,22 @@ namespace Core
// 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()
{
@ -123,17 +111,13 @@ namespace Core
if( m_bUnloadPending )
{
}
}
m_playerCount = 0;
m_bLoaded = false;
}
void Cell::queueUnloadPending()
{
if( m_bUnloadPending )
@ -142,7 +126,6 @@ namespace Core
}
m_bUnloadPending = true;
}
void Cell::cancelPendingUnload()
@ -152,7 +135,6 @@ namespace Core
{
return;
}
}
void Cell::unload()
@ -168,4 +150,4 @@ namespace Core
m_bUnloadPending = false;
}
}
} // namespace Core

View file

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

View file

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

View file

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

View file

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

View file

@ -1,9 +1,9 @@
#include <src/servers/Server_Common/Logging/Logger.h>
#include <src/servers/Server_Common/Exd/ExdData.h>
#include <boost/lexical_cast.hpp>
#include <src/servers/Server_Common/Exd/ExdData.h>
#include <src/servers/Server_Common/Logging/Logger.h>
#include "ZoneMgr.h"
#include "Zone.h"
#include "ZoneMgr.h"
#include "ZonePosition.h"
#include <Server_Common/Database/DatabaseDef.h>
@ -55,7 +55,6 @@ namespace Core {
{
uint32_t zoneId = zone.first;
auto info = zone.second;
g_log.Log( LoggingSeverity::info, std::to_string( info.id ) + "\t" + info.zone_str );
@ -86,4 +85,4 @@ namespace Core {
return nullptr;
}
}
} // namespace Core

View file

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

View file

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

View file

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