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

Merge branch 'master' into work

This commit is contained in:
goaaats 2017-12-19 15:47:40 +01:00 committed by GitHub
commit 84c9b3b39c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
96 changed files with 2389 additions and 2369 deletions

View file

@ -22,7 +22,7 @@ When making a PR, please make sure that it follows our style guidelines and good
### Coding style ### Coding style
Indentations are Allman-style based, 4-space, no tabs. Indentations are Allman-style based, 3-space, no tabs.
Space between arguments in function calls, as well as for types. Space between arguments in function calls, as well as for types.
Example (shortened from ActionHandler.cpp): Example (shortened from ActionHandler.cpp):
@ -30,30 +30,30 @@ Example (shortened from ActionHandler.cpp):
```cpp ```cpp
switch( commandId ) switch( commandId )
{ {
case 0x01: // Toggle sheathe case 0x01: // Toggle sheathe
{ {
if ( param11 == 1 ) if ( param11 == 1 )
pPlayer->setStance( Entity::Actor::Stance::Active ); pPlayer->setStance( Entity::Actor::Stance::Active );
else else
{ {
pPlayer->setStance( Entity::Actor::Stance::Passive ); pPlayer->setStance( Entity::Actor::Stance::Passive );
pPlayer->setAutoattack( false ); pPlayer->setAutoattack( false );
} }
pPlayer->sendToInRangeSet( ActorControlPacket142( pPlayer->getId(), 0, param11, 1 ) ); pPlayer->sendToInRangeSet( ActorControlPacket142( pPlayer->getId(), 0, param11, 1 ) );
break; break;
} }
case 0x03: // Change target case 0x03: // Change target
{ {
uint64_t targetId = inPacket.getValAt< uint64_t >( 0x24 ); uint64_t targetId = inPacket.getValAt< uint64_t >( 0x24 );
pPlayer->changeTarget( targetId ); pPlayer->changeTarget( targetId );
break; break;
} }
default: default:
{ {
break; break;
} }
} }
``` ```

View file

@ -3,15 +3,16 @@
<!-- Port the lobby server accepts client connections on --> <!-- Port the lobby server accepts client connections on -->
<ListenPort>54994</ListenPort> <ListenPort>54994</ListenPort>
<AuthPort>54998</AuthPort> <AuthPort>54998</AuthPort>
<!-- Ip the lobby server listens on --> <!-- Ip the lobby server listens on -->
<ListenIp>127.0.0.1</ListenIp> <ListenIp>127.0.0.1</ListenIp>
<!-- Path of FFXIV dat files --> <!-- Path of FFXIV dat files -->
<DataPath>C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\ffxiv</DataPath> <DataPath>C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\ffxiv</DataPath>
<!-- <DataPath>/opt/sapphire_3_15_0/bin/sqpack</DataPath> -->
<!-- IP of the lobby server --> <!-- IP of the lobby server -->
<LobbyHost>127.0.0.1</LobbyHost> <LobbyHost>127.0.0.1</LobbyHost>
<!-- IP of the frontier server --> <!-- IP of the frontier server -->
<FrontierHost>127.0.0.1</FrontierHost> <FrontierHost>127.0.0.1</FrontierHost>
<!-- Secret used for server auth - you *must* change this for public servers --> <!-- Secret used for server auth - you *must* change this for public servers -->
<ServerSecret>default</ServerSecret> <ServerSecret>default</ServerSecret>
<!-- Web server port --> <!-- Web server port -->
<HttpPort>80</HttpPort> <HttpPort>80</HttpPort>

View file

@ -64,7 +64,6 @@ CREATE TABLE `charainfo` (
`HowTo` binary(33) DEFAULT NULL, `HowTo` binary(33) DEFAULT NULL,
`Minions` binary(33) DEFAULT NULL, `Minions` binary(33) DEFAULT NULL,
`Mounts` binary(13) DEFAULT NULL, `Mounts` binary(13) DEFAULT NULL,
`Orchestrion` binary(38) DEFAULT NULL,
`EquippedMannequin` int(5) DEFAULT '0', `EquippedMannequin` int(5) DEFAULT '0',
`ConfigFlags` smallint(5) NOT NULL DEFAULT '0', `ConfigFlags` smallint(5) NOT NULL DEFAULT '0',
`QuestCompleteFlags` binary(200) DEFAULT NULL, `QuestCompleteFlags` binary(200) DEFAULT NULL,
@ -76,7 +75,7 @@ CREATE TABLE `charainfo` (
`GMRank` int(3) DEFAULT '0', `GMRank` int(3) DEFAULT '0',
`Unlocks` binary(64) DEFAULT NULL, `Unlocks` binary(64) DEFAULT NULL,
`CFPenaltyUntil` int(11) DEFAULT NULL, `CFPenaltyUntil` int(11) DEFAULT NULL,
`UPDATE_DATE` datetime DEFAULT NULL, `UPDATE_DATE` DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`CharacterId`) PRIMARY KEY (`CharacterId`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;

View file

@ -32,13 +32,13 @@ FOR %%X IN (*.sql) DO (
REM handle update.sql last REM handle update.sql last
) ELSE ( ) ELSE (
ECHO Importing %%X ECHO Importing %%X
%PATH_MYSQL% %DBNAME% -h %DBADDRESS% -u %USER% < %%X %PATH_MYSQL% %DBNAME% -h %DBADDRESS% -u %USER% %PASSWORD% < %%X
) )
) )
IF EXIST "update.sql" ( IF EXIST "update.sql" (
ECHO Importing update.sql ECHO Importing update.sql
%PATH_MYSQL% %DBNAME% -h %DBADDRESS% -u %USER% < update.sql %PATH_MYSQL% %DBNAME% -h %DBADDRESS% -u %USER% %PASSWORD% < update.sql
) )
ECHO Finished! ECHO Finished!

View file

@ -39,3 +39,6 @@ MODIFY COLUMN UPDATE_DATE DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURR
ALTER TABLE uniqueiddata ALTER TABLE uniqueiddata
MODIFY COLUMN UPDATE_DATE DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; MODIFY COLUMN UPDATE_DATE DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
ALTER TABLE charainfo
ADD `Orchestrion` binary(38) DEFAULT NULL AFTER `Mounts`;

View file

@ -45,31 +45,37 @@ public:
template<class T> template<class T>
T getValAt( uint16_t pos ) const T getValAt( uint16_t pos ) const
{ {
assert(m_segHdr.size > pos); assert( m_segHdr.size > pos );
return *reinterpret_cast< const T* >( &m_dataBuf[0] + pos ); return *reinterpret_cast< const T* >( &m_dataBuf[0] + pos );
} }
void setBytesAt( uint16_t offset, uint8_t * bytes, uint16_t length ) void setBytesAt( uint16_t offset, uint8_t * bytes, uint16_t length )
{ {
assert(m_segHdr.size > offset); assert( m_segHdr.size > offset );
memcpy( reinterpret_cast< uint8_t* >( &m_dataBuf[0] + offset ), bytes, length ); memcpy( reinterpret_cast< uint8_t* >( &m_dataBuf[0] + offset ), bytes, length );
} }
const char * getStringAt( uint16_t pos ) const const char * getStringAt( uint16_t pos ) const
{ {
assert(m_segHdr.size > pos); assert( m_segHdr.size > pos );
return reinterpret_cast< const char* >( &m_dataBuf[0] + pos ); return reinterpret_cast< const char* >( &m_dataBuf[0] + pos );
} }
void setStringAt( uint16_t pos, const std::string& str ) void setStringAt( uint16_t pos, const std::string& str )
{ {
assert(m_segHdr.size > pos); assert( m_segHdr.size > pos );
memcpy( reinterpret_cast< uint8_t* >( &m_dataBuf[0] + pos ), str.c_str(), str.length() ); memcpy( reinterpret_cast< uint8_t* >( &m_dataBuf[0] + pos ), str.c_str(), str.length() );
} }
uint8_t * getData() const uint8_t * getData() const
{ {
return reinterpret_cast< uint8_t* >( &m_dataBuf[0] ); return reinterpret_cast< const uint8_t* >( &m_dataBuf[0] );
}
const uint8_t * getDataAt(uint16_t pos) const
{
assert( m_segHdr.size > pos );
return reinterpret_cast< const uint8_t* >( &m_dataBuf[0] + pos );
} }
void setHeader( uint16_t size, uint16_t type, uint32_t id1, uint32_t id2, uint16_t subType, uint32_t unknown = 0xFED2E000 ); void setHeader( uint16_t size, uint16_t type, uint32_t id1, uint32_t id2, uint16_t subType, uint32_t unknown = 0xFED2E000 );

View file

@ -815,7 +815,7 @@ struct FFXIVIpcPlayerStats : FFXIVIpcBasePacket<PlayerStats>
uint32_t unknown; uint32_t unknown;
uint32_t unknown_1; uint32_t unknown_1;
uint32_t unknown_2; uint32_t unknown_2;
uint32_t parry; uint32_t tenacity;
uint32_t attack; uint32_t attack;
uint32_t defense; uint32_t defense;
uint32_t accuracy; uint32_t accuracy;
@ -837,7 +837,11 @@ struct FFXIVIpcPlayerStats : FFXIVIpcBasePacket<PlayerStats>
uint32_t skillSpeed; uint32_t skillSpeed;
uint32_t spellSpeed1; uint32_t spellSpeed1;
uint32_t spellSpeedMod; uint32_t spellSpeedMod;
uint32_t unknown_6[5]; uint32_t unknown_6;
uint32_t craftsmanship;
uint32_t control;
uint32_t gathering;
uint32_t perception;
uint32_t resistanceSlow; uint32_t resistanceSlow;
uint32_t resistanceSilence; uint32_t resistanceSilence;
uint32_t resistanceBlind; uint32_t resistanceBlind;
@ -846,7 +850,7 @@ struct FFXIVIpcPlayerStats : FFXIVIpcBasePacket<PlayerStats>
uint32_t resistanceSleep; uint32_t resistanceSleep;
uint32_t resistanceBind; uint32_t resistanceBind;
uint32_t resistanceHeavy; uint32_t resistanceHeavy;
uint32_t unknown_7[9]; uint32_t unknown_7[9]; // possibly level sync stats.
}; };
/** /**
@ -881,10 +885,11 @@ struct FFXIVIpcPlayerStateFlags : FFXIVIpcBasePacket<PlayerStateFlags>
struct FFXIVIpcPlayerClassInfo : FFXIVIpcBasePacket<PlayerClassInfo> struct FFXIVIpcPlayerClassInfo : FFXIVIpcBasePacket<PlayerClassInfo>
{ {
uint16_t classId; uint16_t classId;
uint16_t unknown; uint8_t unknown;
uint16_t level; uint8_t isSpecialist;
uint16_t level1; uint16_t level; // Locks actions, equipment, prob more
uint8_t unknownFields[48]; uint16_t level1; // Locks roles, prob more
uint32_t roleActions[10];
}; };
/** /**

View file

@ -200,7 +200,7 @@ void Core::Network::SapphireAPI::deleteCharacter( std::string name, uint32_t acc
g_charaDb.execute( "DELETE FROM charaitemcrystal WHERE CharacterId LIKE '" + std::to_string( id ) + "';" ); g_charaDb.execute( "DELETE FROM charaitemcrystal WHERE CharacterId LIKE '" + std::to_string( id ) + "';" );
g_charaDb.execute( "DELETE FROM charaiteminventory WHERE CharacterId LIKE '" + std::to_string( id ) + "';" ); g_charaDb.execute( "DELETE FROM charaiteminventory WHERE CharacterId LIKE '" + std::to_string( id ) + "';" );
g_charaDb.execute( "DELETE FROM charaitemgearset WHERE CharacterId LIKE '" + std::to_string( id ) + "';" ); g_charaDb.execute( "DELETE FROM charaitemgearset WHERE CharacterId LIKE '" + std::to_string( id ) + "';" );
g_charaDb.execute( "DELETE FROM charaquest WHERE CharacterId LIKE '" + std::to_string( id ) + "';" ); g_charaDb.execute( "DELETE FROM charaquestnew WHERE CharacterId LIKE '" + std::to_string( id ) + "';" );
} }
std::vector< Core::PlayerMinimal > Core::Network::SapphireAPI::getCharList( uint32_t accountId ) std::vector< Core::PlayerMinimal > Core::Network::SapphireAPI::getCharList( uint32_t accountId )

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
#include "Action.h" #include "Action.h"
#include <src/servers/Server_Common/Util/Util.h> #include <Server_Common/Util/Util.h>
Core::Action::Action::Action() Core::Action::Action::Action()

View file

@ -1,8 +1,8 @@
#ifndef _ACTION_H_ #ifndef _ACTION_H_
#define _ACTION_H_ #define _ACTION_H_
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include "src/servers/Server_Zone/Forwards.h" #include "../Forwards.h"
namespace Core { namespace Action { namespace Core { namespace Action {

View file

@ -1,16 +1,16 @@
#include "ActionCast.h" #include "ActionCast.h"
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <src/servers/Server_Common/Util/Util.h> #include <Server_Common/Util/Util.h>
#include <src/servers/Server_Common/Util/UtilMath.h> #include <Server_Common/Util/UtilMath.h>
#include <src/servers/Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket142.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket144.h" #include "Network/PacketWrappers/ActorControlPacket144.h"
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "src/servers/Server_Zone/Script/ScriptManager.h" #include "Script/ScriptManager.h"
using namespace Core::Common; using namespace Core::Common;
using namespace Core::Network; using namespace Core::Network;
@ -52,7 +52,8 @@ void Core::Action::ActionCast::onStart()
castPacket.data().action_id = m_id; castPacket.data().action_id = m_id;
castPacket.data().skillType = Common::SkillType::Normal; castPacket.data().skillType = Common::SkillType::Normal;
castPacket.data().unknown_1 = m_id; castPacket.data().unknown_1 = m_id;
castPacket.data().cast_time = static_cast< float >( m_castTime / 1000 ); // This is used for the cast bar above the target bar of the caster. // This is used for the cast bar above the target bar of the caster.
castPacket.data().cast_time = static_cast< float >( m_castTime / 1000 );
castPacket.data().target_id = m_pTarget->getId(); castPacket.data().target_id = m_pTarget->getId();
m_pSource->sendToInRangeSet( castPacket, true ); m_pSource->sendToInRangeSet( castPacket, true );
@ -73,10 +74,10 @@ void Core::Action::ActionCast::onFinish()
pPlayer->sendStateFlags(); pPlayer->sendStateFlags();
/*auto control = ActorControlPacket143( m_pTarget->getId(), ActorControlType::Unk7, /*auto control = ActorControlPacket143( m_pTarget->getId(), ActorControlType::Unk7,
0x219, m_id, m_id, m_id, m_id ); 0x219, m_id, m_id, m_id, m_id );
m_pSource->sendToInRangeSet( control, true );*/ m_pSource->sendToInRangeSet( control, true );*/
g_scriptMgr.onCastFinish( pPlayer, m_pTarget, m_id ); g_scriptMgr.onCastFinish( *pPlayer, m_pTarget, m_id );
} }
void Core::Action::ActionCast::onInterrupt() void Core::Action::ActionCast::onInterrupt()
@ -89,7 +90,7 @@ void Core::Action::ActionCast::onInterrupt()
m_pSource->getAsPlayer()->sendStateFlags(); m_pSource->getAsPlayer()->sendStateFlags();
auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt, auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt,
0x219, 1, m_id, 0 ); 0x219, 1, m_id, 0 );
// Note: When cast interrupt from taking too much damage, set the last value to 1. This enables the cast interrupt effect. Example: // Note: When cast interrupt from taking too much damage, set the last value to 1. This enables the cast interrupt effect. Example:
// 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 );

View file

@ -1,10 +1,11 @@
#ifndef _ACTIONCAST_H_ #ifndef _ACTIONCAST_H_
#define _ACTIONCAST_H_ #define _ACTIONCAST_H_
#include "src/servers/Server_Zone/Forwards.h" #include "../Forwards.h"
#include "Action.h" #include "Action.h"
namespace Core { namespace Action { namespace Core {
namespace Action {
class ActionCast : public Action class ActionCast : public Action
{ {

View file

@ -1,10 +1,11 @@
#include <src/servers/Server_Common/Util/Util.h> #include <Server_Common/Util/Util.h>
#include <src/servers/Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <src/servers/Server_Common/Util/UtilMath.h> #include <Server_Common/Util/UtilMath.h>
#include "ActionCollision.h" #include "ActionCollision.h"
#include <src/servers/Server_Zone/Actor/Actor.h> #include "Actor/Actor.h"
#include <src/servers/Server_Zone/Actor/Player.h> #include "Actor/Player.h"
#include <cmath> #include <cmath>
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
@ -16,7 +17,7 @@ using namespace Core::Common;
bool ActionCollision::isActorApplicable( ActorPtr actorPtr, TargetFilter targetFilter ) bool ActionCollision::isActorApplicable( ActorPtr actorPtr, TargetFilter targetFilter )
{ {
bool actorApplicable = false; bool actorApplicable = false;
switch ( targetFilter ) switch( targetFilter )
{ {
case TargetFilter::All: case TargetFilter::All:
{ {
@ -57,14 +58,14 @@ std::set< Core::Entity::ActorPtr > ActionCollision::getActorsHitFromAction( FFXI
{ {
std::set< ActorPtr > actorsCollided; std::set< ActorPtr > actorsCollided;
switch ( static_cast< ActionCollisionType >( actionInfo->aoe_type ) ) switch( static_cast< ActionCollisionType >( actionInfo->aoe_type ) )
{ {
case ActionCollisionType::None: case ActionCollisionType::None:
case ActionCollisionType::SingleTarget: case ActionCollisionType::SingleTarget:
{ {
// This is actually needed. There is "splash damage" in actions marked as single target. // This is actually needed. There is "splash damage" in actions marked as single target.
// Notice how we're using aoe_width. How collision works for SingleTarget is unknown as of now. // Notice how we're using aoe_width. How collision works for SingleTarget is unknown as of now.
for ( auto pActor : actorsInRange ) for( auto pActor : actorsInRange )
{ {
// Make sure actor exists. If it doesn't we done goofed. // Make sure actor exists. If it doesn't we done goofed.
assert( pActor ); assert( pActor );
@ -84,7 +85,7 @@ std::set< Core::Entity::ActorPtr > ActionCollision::getActorsHitFromAction( FFXI
} }
case ActionCollisionType::Circle: case ActionCollisionType::Circle:
{ {
for ( auto pActor : actorsInRange ) for( auto pActor : actorsInRange )
{ {
assert( pActor ); assert( pActor );
@ -92,15 +93,13 @@ std::set< Core::Entity::ActorPtr > ActionCollision::getActorsHitFromAction( FFXI
continue; continue;
if ( radiusCollision( pActor->getPos(), aoePosition, actionInfo->aoe_range ) ) if ( radiusCollision( pActor->getPos(), aoePosition, actionInfo->aoe_range ) )
{
actorsCollided.insert( pActor ); actorsCollided.insert( pActor );
}
} }
break; break;
} }
case ActionCollisionType::Box: case ActionCollisionType::Box:
{ {
for ( auto pActor : actorsInRange ) for( auto pActor : actorsInRange )
{ {
assert( pActor ); assert( pActor );

View file

@ -1,43 +1,43 @@
#ifndef _ACTIONCOLLISION_H #ifndef _ACTIONCOLLISION_H
#define _ACTIONCOLLISION_H #define _ACTIONCOLLISION_H
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <src/servers/Server_Zone/Actor/Actor.h> #include "Actor/Actor.h"
#include "Action.h" #include "Action.h"
namespace Core { namespace Core {
namespace Entity { namespace Entity {
enum class TargetFilter enum class TargetFilter
{ {
All, // All actors in the AoE are applicable for collision All, // All actors in the AoE are applicable for collision
Players, // Only players Players, // Only players
Allies, // Only allies (players, ally NPCs) Allies, // Only allies (players, ally NPCs)
Party, // Only party members Party, // Only party members
Enemies // Only enemies Enemies // Only enemies
}; };
class ActionCollision class ActionCollision
{ {
public: public:
static bool isActorApplicable( ActorPtr actorPtr, TargetFilter targetFilter ); static bool isActorApplicable( ActorPtr actorPtr, TargetFilter targetFilter );
static std::set< ActorPtr > getActorsHitFromAction( Common::FFXIVARR_POSITION3 aoePosition, static std::set< ActorPtr > getActorsHitFromAction( Common::FFXIVARR_POSITION3 aoePosition,
std::set< ActorPtr > actorsInRange, std::set< ActorPtr > actorsInRange,
boost::shared_ptr< Data::ActionInfo > actionInfo, boost::shared_ptr< Data::ActionInfo > actionInfo,
TargetFilter targetFilter ); TargetFilter targetFilter );
private: private:
static bool radiusCollision( Common::FFXIVARR_POSITION3 actorPosition, Common::FFXIVARR_POSITION3 aoePosition, static bool radiusCollision( Common::FFXIVARR_POSITION3 actorPosition, Common::FFXIVARR_POSITION3 aoePosition,
uint16_t radius ); uint16_t radius );
static bool boxCollision( Common::FFXIVARR_POSITION3 actorPosition, Common::FFXIVARR_POSITION3 aoePosition, static bool boxCollision( Common::FFXIVARR_POSITION3 actorPosition, Common::FFXIVARR_POSITION3 aoePosition,
uint16_t width, uint16_t height ); uint16_t width, uint16_t height );
}; };
} }
} }
#endif #endif

View file

@ -1,16 +1,16 @@
#include "ActionMount.h" #include "ActionMount.h"
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <src/servers/Server_Common/Util/Util.h> #include <Server_Common/Util/Util.h>
#include <src/servers/Server_Common/Util/UtilMath.h> #include <Server_Common/Util/UtilMath.h>
#include <src/servers/Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket142.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket144.h" #include "Network/PacketWrappers/ActorControlPacket144.h"
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "src/servers/Server_Zone/Script/ScriptManager.h" #include "Script/ScriptManager.h"
using namespace Core::Common; using namespace Core::Common;
using namespace Core::Network; using namespace Core::Network;
@ -23,7 +23,7 @@ extern Core::Scripting::ScriptManager g_scriptMgr;
Core::Action::ActionMount::ActionMount() Core::Action::ActionMount::ActionMount()
{ {
m_handleActionType = Common::HandleActionType::Event; m_handleActionType = HandleActionType::Event;
} }
Core::Action::ActionMount::ActionMount( Entity::ActorPtr pActor, uint16_t mountId ) Core::Action::ActionMount::ActionMount( Entity::ActorPtr pActor, uint16_t mountId )
@ -75,19 +75,20 @@ void Core::Action::ActionMount::onFinish()
pPlayer->unsetStateFlag( PlayerStateFlag::Casting ); pPlayer->unsetStateFlag( PlayerStateFlag::Casting );
pPlayer->sendStateFlags(); pPlayer->sendStateFlags();
ZoneChannelPacket< FFXIVIpcEffect > effectPacket(pPlayer->getId()); ZoneChannelPacket< FFXIVIpcEffect > effectPacket( pPlayer->getId() );
effectPacket.data().targetId = pPlayer->getId(); effectPacket.data().targetId = pPlayer->getId();
effectPacket.data().actionAnimationId = m_id; effectPacket.data().actionAnimationId = m_id;
effectPacket.data().unknown_62 = 13; // Affects displaying action name next to number in floating text // Affects displaying action name next to number in floating text
effectPacket.data().unknown_62 = 13;
effectPacket.data().actionTextId = 4; effectPacket.data().actionTextId = 4;
effectPacket.data().numEffects = 1; effectPacket.data().numEffects = 1;
effectPacket.data().rotation = Math::Util::floatToUInt16Rot(pPlayer->getRotation()); effectPacket.data().rotation = Math::Util::floatToUInt16Rot( pPlayer->getRotation() );
effectPacket.data().effectTarget = INVALID_GAME_OBJECT_ID; effectPacket.data().effectTarget = INVALID_GAME_OBJECT_ID;
effectPacket.data().effects[0].effectType = ActionEffectType::Mount; effectPacket.data().effects[0].effectType = ActionEffectType::Mount;
effectPacket.data().effects[0].hitSeverity = ActionHitSeverityType::CritDamage; effectPacket.data().effects[0].hitSeverity = ActionHitSeverityType::CritDamage;
effectPacket.data().effects[0].value = m_id; effectPacket.data().effects[0].value = m_id;
pPlayer->sendToInRangeSet(effectPacket, true); pPlayer->sendToInRangeSet( effectPacket, true );
pPlayer->mount( m_id ); pPlayer->mount( m_id );
} }

View file

@ -1,10 +1,11 @@
#ifndef _ACTIONMOUNT_H_ #ifndef _ACTIONMOUNT_H_
#define _ACTIONMOUNT_H_ #define _ACTIONMOUNT_H_
#include "src/servers/Server_Zone/Forwards.h" #include "../Forwards.h"
#include "Action.h" #include "Action.h"
namespace Core { namespace Action { namespace Core {
namespace Action {
class ActionMount : public Action class ActionMount : public Action
{ {

View file

@ -1,12 +1,12 @@
#include "ActionTeleport.h" #include "ActionTeleport.h"
#include <src/servers/Server_Common/Util/Util.h> #include <Server_Common/Util/Util.h>
#include <src/servers/Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket142.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
using namespace Core::Common; using namespace Core::Common;
using namespace Core::Network; using namespace Core::Network;
@ -18,7 +18,7 @@ extern Core::Logger g_log;
Core::Action::ActionTeleport::ActionTeleport() Core::Action::ActionTeleport::ActionTeleport()
{ {
m_handleActionType = Common::HandleActionType::Event; m_handleActionType = HandleActionType::Event;
} }
Core::Action::ActionTeleport::ActionTeleport( Entity::ActorPtr pActor, uint16_t targetZone, uint16_t cost ) Core::Action::ActionTeleport::ActionTeleport( Entity::ActorPtr pActor, uint16_t targetZone, uint16_t cost )
@ -81,7 +81,7 @@ void Core::Action::ActionTeleport::onFinish()
//auto control = Network::Packets::Server::ActorControlPacket142( m_pSource->getId(), Common::ActorControlType::TeleportDone ); //auto control = Network::Packets::Server::ActorControlPacket142( m_pSource->getId(), Common::ActorControlType::TeleportDone );
//m_pSource->sendToInRangeSet( control, false ); //m_pSource->sendToInRangeSet( control, false );
pPlayer->setZoningType( Common::ZoneingType::Teleport ); pPlayer->setZoningType( ZoneingType::Teleport );
ZoneChannelPacket< FFXIVIpcEffect > effectPacket( pPlayer->getId() ); ZoneChannelPacket< FFXIVIpcEffect > effectPacket( pPlayer->getId() );
effectPacket.data().targetId = pPlayer->getId(); effectPacket.data().targetId = pPlayer->getId();
@ -90,7 +90,7 @@ void Core::Action::ActionTeleport::onFinish()
effectPacket.data().actionTextId = 5; effectPacket.data().actionTextId = 5;
effectPacket.data().unknown_5 = 1; effectPacket.data().unknown_5 = 1;
effectPacket.data().numEffects = 1; effectPacket.data().numEffects = 1;
effectPacket.data().rotation = static_cast< uint16_t >( 0x8000 * ( (pPlayer->getRotation() + 3.1415926) ) / 3.1415926 ); effectPacket.data().rotation = static_cast< uint16_t >( 0x8000 * ( ( pPlayer->getRotation() + 3.1415926 ) ) / 3.1415926 );
effectPacket.data().effectTarget = pPlayer->getId(); effectPacket.data().effectTarget = pPlayer->getId();
pPlayer->sendToInRangeSet( effectPacket, true ); pPlayer->sendToInRangeSet( effectPacket, true );

View file

@ -1,10 +1,11 @@
#ifndef _ACTIONTELEPORT_H_ #ifndef _ACTIONTELEPORT_H_
#define _ACTIONTELEPORT_H_ #define _ACTIONTELEPORT_H_
#include "src/servers/Server_Zone/Forwards.h" #include "../Forwards.h"
#include "Action.h" #include "Action.h"
namespace Core { namespace Action { namespace Core {
namespace Action {
class ActionTeleport : public Action class ActionTeleport : public Action
{ {

View file

@ -1,12 +1,12 @@
#include <src/servers/Server_Common/Util/Util.h> #include <Server_Common/Util/Util.h>
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include <src/servers/Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include "EventAction.h" #include "EventAction.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket142.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "src/servers/Server_Zone/Actor/Player.h" #include "Server_Zone/Actor/Player.h"
#include "src/servers/Server_Zone/Event/Event.h" #include "Server_Zone/Event/Event.h"
extern Core::Logger g_log; extern Core::Logger g_log;
extern Core::Data::ExdData g_exdData; extern Core::Data::ExdData g_exdData;
@ -18,7 +18,7 @@ using namespace Core::Network::Packets::Server;
Core::Action::EventAction::EventAction() Core::Action::EventAction::EventAction()
{ {
m_handleActionType = Common::HandleActionType::Event; m_handleActionType = HandleActionType::Event;
} }
Core::Action::EventAction::EventAction( Entity::ActorPtr pActor, uint32_t eventId, uint16_t action, Core::Action::EventAction::EventAction( Entity::ActorPtr pActor, uint32_t eventId, uint16_t action,
@ -76,7 +76,6 @@ void Core::Action::EventAction::onFinish()
auto control = ActorControlPacket142( m_pSource->getId(), Common::ActorControlType::CastStart, 0, m_id ); auto control = ActorControlPacket142( m_pSource->getId(), Common::ActorControlType::CastStart, 0, m_id );
if( !pEvent->hasPlayedScene() ) if( !pEvent->hasPlayedScene() )
m_pSource->getAsPlayer()->eventFinish( m_eventId, 1 ); m_pSource->getAsPlayer()->eventFinish( m_eventId, 1 );
else else

View file

@ -1,12 +1,13 @@
#ifndef _EVENTACTION_H_ #ifndef _EVENTACTION_H_
#define _EVENTACTION_H_ #define _EVENTACTION_H_
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include "src/servers/Server_Zone/Forwards.h" #include "../Forwards.h"
#include "src/servers/Server_Zone/Action/Action.h" #include "Action.h"
namespace Core { namespace Action { namespace Core {
namespace Action {
class EventAction : public Action class EventAction : public Action
{ {

View file

@ -1,14 +1,14 @@
#include "EventItemAction.h" #include "EventItemAction.h"
#include <src/servers/Server_Common/Util/Util.h> #include <Server_Common/Util/Util.h>
#include <src/servers/Server_Common/Util/UtilMath.h> #include <Server_Common/Util/UtilMath.h>
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include <string.h> #include <string.h>
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket142.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
extern Core::Logger g_log; extern Core::Logger g_log;
@ -19,7 +19,7 @@ using namespace Core::Network::Packets::Server;
Core::Action::EventItemAction::EventItemAction() Core::Action::EventItemAction::EventItemAction()
{ {
m_handleActionType = Common::HandleActionType::Event; m_handleActionType = HandleActionType::Event;
} }
Core::Action::EventItemAction::EventItemAction( Entity::ActorPtr pActor, uint32_t eventId, uint16_t action, Core::Action::EventItemAction::EventItemAction( Entity::ActorPtr pActor, uint32_t eventId, uint16_t action,

View file

@ -1,10 +1,11 @@
#ifndef _EVENTITEMACTION_H_ #ifndef _EVENTITEMACTION_H_
#define _EVENTITEMACTION_H_ #define _EVENTITEMACTION_H_
#include "src/servers/Server_Zone/Forwards.h" #include "../Forwards.h"
#include "src/servers/Server_Zone/Action/Action.h" #include "Action.h"
namespace Core { namespace Action { namespace Core {
namespace Action {
class EventItemAction : public Action class EventItemAction : public Action
{ {

View file

@ -1,26 +1,25 @@
#include <src/servers/Server_Common/Util/Util.h> #include <Server_Common/Util/Util.h>
#include <src/servers/Server_Common/Util/UtilMath.h> #include <Server_Common/Util/UtilMath.h>
#include <src/servers/Server_Common/Network/PacketContainer.h> #include <Server_Common/Network/PacketContainer.h>
#include <src/servers/Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <src/servers/Server_Common/Network/GamePacket.h> #include <Server_Common/Network/GamePacket.h>
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
#include "src/servers/Server_Zone/Action/Action.h" #include "Action/Action.h"
#include "src/servers/Server_Zone/Zone/Zone.h" #include "Zone/Zone.h"
#include "src/servers/Server_Zone/Network/GameConnection.h" #include "Network/GameConnection.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket142.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket144.h" #include "Network/PacketWrappers/ActorControlPacket144.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/UpdateHpMpTpPacket.h" #include "Network/PacketWrappers/UpdateHpMpTpPacket.h"
#include "src/servers/Server_Zone/StatusEffect/StatusEffectContainer.h" #include "StatusEffect/StatusEffect.h"
#include "src/servers/Server_Zone/StatusEffect/StatusEffect.h" #include "Action/ActionCollision.h"
#include "src/servers/Server_Zone/Action/ActionCollision.h" #include "ServerZone.h"
#include "src/servers/Server_Zone/ServerZone.h" #include "Session.h"
#include "src/servers/Server_Zone/Session.h" #include "Math/CalcBattle.h"
#include "src/servers/Server_Zone/Math/CalcBattle.h"
#include "Actor.h" #include "Actor.h"
#include "Player.h" #include "Player.h"
@ -33,6 +32,11 @@ using namespace Core::Network::Packets::Server;
Core::Entity::Actor::Actor() Core::Entity::Actor::Actor()
{ {
// initialize the free slot queue
for( uint8_t i = 0; i < MAX_STATUS_EFFECTS; i++ )
{
m_statusEffectFreeSlotQueue.push( i );
}
} }
Core::Entity::Actor::~Actor() Core::Entity::Actor::~Actor()
@ -660,7 +664,7 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
uint64_t param2, Entity::Actor& pTarget ) uint64_t param2, Entity::Actor& pTarget )
{ {
if ( isPlayer() ) if( isPlayer() )
{ {
getAsPlayer()->sendDebug( std::to_string( pTarget.getId() ) ); getAsPlayer()->sendDebug( std::to_string( pTarget.getId() ) );
getAsPlayer()->sendDebug( "Handle script skill type: " + std::to_string( type ) ); getAsPlayer()->sendDebug( "Handle script skill type: " + std::to_string( type ) );
@ -682,7 +686,7 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
effectPacket.data().effectTarget = pTarget.getId(); effectPacket.data().effectTarget = pTarget.getId();
// Todo: for each actor, calculate how much damage the calculated value should deal to them - 2-step damage calc. we only have 1-step // Todo: for each actor, calculate how much damage the calculated value should deal to them - 2-step damage calc. we only have 1-step
switch ( type ) switch( type )
{ {
case ActionEffectType::Damage: case ActionEffectType::Damage:
@ -692,7 +696,7 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
effectPacket.data().effects[0].hitSeverity = ActionHitSeverityType::NormalDamage; effectPacket.data().effects[0].hitSeverity = ActionHitSeverityType::NormalDamage;
effectPacket.data().effects[0].unknown_3 = 7; effectPacket.data().effects[0].unknown_3 = 7;
if ( !actionInfoPtr->is_aoe ) if( !actionInfoPtr->is_aoe )
{ {
// If action on this specific target is valid... // If action on this specific target is valid...
if ( isPlayer() && !ActionCollision::isActorApplicable( pTarget.shared_from_this(), TargetFilter::Enemies ) ) if ( isPlayer() && !ActionCollision::isActorApplicable( pTarget.shared_from_this(), TargetFilter::Enemies ) )
@ -700,11 +704,11 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
sendToInRangeSet( effectPacket, true ); sendToInRangeSet( effectPacket, true );
pTarget.takeDamage( static_cast< uint32_t >( param1 ) );
if ( pTarget.isAlive() ) if ( pTarget.isAlive() )
pTarget.onActionHostile( shared_from_this() ); pTarget.onActionHostile( shared_from_this() );
pTarget.takeDamage( static_cast< uint32_t >( param1 ) );
} }
else else
{ {
@ -712,7 +716,7 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
auto actorsCollided = ActionCollision::getActorsHitFromAction( pTarget.getPos(), getInRangeActors( true ), auto actorsCollided = ActionCollision::getActorsHitFromAction( pTarget.getPos(), getInRangeActors( true ),
actionInfoPtr, TargetFilter::Enemies ); actionInfoPtr, TargetFilter::Enemies );
for ( const auto& pHitActor : actorsCollided ) for( const auto& pHitActor : actorsCollided )
{ {
effectPacket.data().targetId = pHitActor->getId(); effectPacket.data().targetId = pHitActor->getId();
effectPacket.data().effectTarget = pHitActor->getId(); effectPacket.data().effectTarget = pHitActor->getId();
@ -720,17 +724,17 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
// todo: send to range of what? ourselves? when mob script hits this is going to be lacking // todo: send to range of what? ourselves? when mob script hits this is going to be lacking
sendToInRangeSet( effectPacket, true ); sendToInRangeSet( effectPacket, true );
pHitActor->takeDamage( static_cast< uint32_t >( param1 ) );
if( pHitActor->isAlive() ) if( pHitActor->isAlive() )
pHitActor->onActionHostile( shared_from_this() ); pHitActor->onActionHostile( shared_from_this() );
pHitActor->takeDamage( static_cast< uint32_t >( param1 ) );
// Debug // Debug
if ( isPlayer() ) if ( isPlayer() )
{ {
if ( pHitActor->isPlayer() ) { if ( pHitActor->isPlayer() )
getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) + " (" + pHitActor->getName() + ")" ); getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) + " (" + pHitActor->getName() + ")" );
}
else else
getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) ); getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) );
} }
@ -748,9 +752,9 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
effectPacket.data().effects[0].effectType = ActionEffectType::Heal; effectPacket.data().effects[0].effectType = ActionEffectType::Heal;
effectPacket.data().effects[0].hitSeverity = ActionHitSeverityType::NormalHeal; effectPacket.data().effects[0].hitSeverity = ActionHitSeverityType::NormalHeal;
if ( !actionInfoPtr->is_aoe ) if( !actionInfoPtr->is_aoe )
{ {
if ( isPlayer() && !ActionCollision::isActorApplicable( pTarget.shared_from_this(), TargetFilter::Allies ) ) if( isPlayer() && !ActionCollision::isActorApplicable( pTarget.shared_from_this(), TargetFilter::Allies ) )
break; break;
sendToInRangeSet( effectPacket, true ); sendToInRangeSet( effectPacket, true );
@ -764,7 +768,7 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
auto actorsCollided = ActionCollision::getActorsHitFromAction( pTarget.getPos(), getInRangeActors( true ), auto actorsCollided = ActionCollision::getActorsHitFromAction( pTarget.getPos(), getInRangeActors( true ),
actionInfoPtr, TargetFilter::Allies ); actionInfoPtr, TargetFilter::Allies );
for ( auto pHitActor : actorsCollided ) for( auto pHitActor : actorsCollided )
{ {
effectPacket.data().targetId = pTarget.getId(); effectPacket.data().targetId = pTarget.getId();
effectPacket.data().effectTarget = pHitActor->getId(); effectPacket.data().effectTarget = pHitActor->getId();
@ -773,11 +777,10 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
pHitActor->heal( calculatedHeal ); pHitActor->heal( calculatedHeal );
// Debug // Debug
if ( isPlayer() ) if( isPlayer() )
{ {
if ( pHitActor->isPlayer() ) { if( pHitActor->isPlayer() )
getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) + " (" + pHitActor->getName() + ")" ); getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) + " (" + pHitActor->getName() + ")" );
}
else else
getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) ); getAsPlayer()->sendDebug( "AoE hit actor " + std::to_string( pHitActor->getId() ) );
} }
@ -794,7 +797,30 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, u
/*! \param StatusEffectPtr to be applied to the actor */ /*! \param StatusEffectPtr to be applied to the actor */
void Core::Entity::Actor::addStatusEffect( StatusEffect::StatusEffectPtr pEffect ) void Core::Entity::Actor::addStatusEffect( StatusEffect::StatusEffectPtr pEffect )
{ {
m_pStatusEffectContainer->addStatusEffect( pEffect ); int8_t nextSlot = getStatusEffectFreeSlot();
// if there is no slot left, do not add the effect
if( nextSlot == -1 )
return;
pEffect->applyStatus();
m_statusEffectMap[nextSlot] = pEffect;
ZoneChannelPacket< Server::FFXIVIpcAddStatusEffect > statusEffectAdd( getId() );
statusEffectAdd.data().actor_id = pEffect->getTargetActorId();
statusEffectAdd.data().actor_id1 = pEffect->getSrcActorId();
statusEffectAdd.data().current_hp = getHp();
statusEffectAdd.data().current_mp = getMp();
statusEffectAdd.data().current_tp = getTp();
statusEffectAdd.data().duration = static_cast< float >( pEffect->getDuration() ) / 1000;
statusEffectAdd.data().effect_id = pEffect->getId();
statusEffectAdd.data().effect_index = nextSlot;
statusEffectAdd.data().max_hp = getMaxHp();
statusEffectAdd.data().max_mp = getMaxMp();
statusEffectAdd.data().max_something = 1;
//statusEffectAdd.data().unknown2 = 28;
statusEffectAdd.data().param = pEffect->getParam();
sendToInRangeSet( statusEffectAdd, isPlayer() );
} }
/*! \param StatusEffectPtr to be applied to the actor */ /*! \param StatusEffectPtr to be applied to the actor */
@ -809,22 +835,173 @@ void Core::Entity::Actor::addStatusEffectById( uint32_t id, int32_t duration, En
/*! \param StatusEffectPtr to be applied to the actor */ /*! \param StatusEffectPtr to be applied to the actor */
void Core::Entity::Actor::addStatusEffectByIdIfNotExist( uint32_t id, int32_t duration, Entity::Actor& pSource, uint16_t param ) void Core::Entity::Actor::addStatusEffectByIdIfNotExist( uint32_t id, int32_t duration, Entity::Actor& pSource, uint16_t param )
{ {
if( !m_pStatusEffectContainer->hasStatusEffect( id ) ) if( hasStatusEffect( id ) )
return;
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
{
return m_rot;
}
void Core::Entity::Actor::setRotation( float rot )
{
m_rot = rot;
}
int8_t Core::Entity::Actor::getStatusEffectFreeSlot()
{
int8_t freeEffectSlot = -1;
if( m_statusEffectFreeSlotQueue.empty() )
return freeEffectSlot;
freeEffectSlot = m_statusEffectFreeSlotQueue.front();
m_statusEffectFreeSlotQueue.pop();
return freeEffectSlot;
}
void Core::Entity::Actor::statusEffectFreeSlot( uint8_t slotId )
{
m_statusEffectFreeSlotQueue.push( slotId );
}
void Core::Entity::Actor::removeSingleStatusEffectById( uint32_t id )
{
for( auto effectIt : m_statusEffectMap )
{ {
StatusEffect::StatusEffectPtr effect( new StatusEffect::StatusEffect( id, pSource.shared_from_this(), if( effectIt.second->getId() == id )
shared_from_this(), duration, 3000 ) ); {
effect->setParam( param ); removeStatusEffect( effectIt.first );
addStatusEffect( effect ); break;
}
} }
} }
/*! \param Status that should be removed, based on its ID. */ void Core::Entity::Actor::removeStatusEffect( uint8_t effectSlotId )
void Core::Entity::Actor::removeSingleStatusEffectFromId( uint32_t id )
{ {
m_pStatusEffectContainer->removeSingleStatusEffectFromId( id ); auto pEffectIt = m_statusEffectMap.find( effectSlotId );
if( pEffectIt == m_statusEffectMap.end() )
return;
statusEffectFreeSlot( effectSlotId );
auto pEffect = pEffectIt->second;
pEffect->removeStatus();
sendToInRangeSet( ActorControlPacket142( getId(), StatusEffectLose, pEffect->getId() ), isPlayer() );
m_statusEffectMap.erase( effectSlotId );
sendStatusEffectUpdate();
} }
Core::StatusEffect::StatusEffectContainerPtr Core::Entity::Actor::getStatusEffectContainer() const std::map< uint8_t, Core::StatusEffect::StatusEffectPtr > Core::Entity::Actor::getStatusEffectMap() const
{ {
return m_pStatusEffectContainer; return m_statusEffectMap;
}
void Core::Entity::Actor::sendStatusEffectUpdate()
{
uint64_t currentTimeMs = Util::getTimeMs();
ZoneChannelPacket< Server::FFXIVIpcStatusEffectList > statusEffectList( getId() );
statusEffectList.data().current_hp = getHp();
statusEffectList.data().current_mp = getMp();
statusEffectList.data().currentTp = getTp();
statusEffectList.data().max_hp = getMaxHp();
statusEffectList.data().max_mp = getMaxMp();
uint8_t slot = 0;
for( auto effectIt : m_statusEffectMap )
{
float timeLeft = static_cast< float >( effectIt.second->getDuration() -
( 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();
slot++;
}
sendToInRangeSet( statusEffectList, isPlayer() );
}
void Core::Entity::Actor::updateStatusEffects()
{
uint64_t currentTimeMs = Util::getTimeMs();
uint32_t thisTickDmg = 0;
uint32_t thisTickHeal = 0;
for( auto effectIt : m_statusEffectMap )
{
uint8_t effectIndex = effectIt.first;
auto effect = effectIt.second;
uint64_t lastTick = effect->getLastTickMs();
uint64_t startTime = effect->getStartTimeMs();
uint32_t duration = effect->getDuration();
uint32_t tickRate = effect->getTickRate();
if( ( currentTimeMs - startTime ) > duration )
{
// remove status effect
removeStatusEffect( effectIndex );
// break because removing invalidates iterators
break;
}
if( ( currentTimeMs - lastTick ) > tickRate )
{
effect->setLastTick( currentTimeMs );
effect->onTick();
auto thisEffect = effect->getTickEffect();
switch( thisEffect.first )
{
case 1:
{
thisTickDmg += thisEffect.second;
break;
}
case 2:
{
thisTickHeal += thisEffect.second;
break;
}
}
}
}
if( thisTickDmg != 0 )
{
takeDamage( 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 ) );
}
}
bool Core::Entity::Actor::hasStatusEffect( uint32_t id )
{
if( m_statusEffectMap.find( id ) != m_statusEffectMap.end() )
return true;
return false;
} }

View file

@ -1,12 +1,13 @@
#ifndef _ACTOR_H_ #ifndef _ACTOR_H_
#define _ACTOR_H_ #define _ACTOR_H_
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <boost/enable_shared_from_this.hpp> #include <boost/enable_shared_from_this.hpp>
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
#include <set> #include <set>
#include <map> #include <map>
#include <queue>
namespace Core { namespace Core {
namespace Entity { namespace Entity {
@ -79,7 +80,7 @@ public:
uint32_t mnd = 0; uint32_t mnd = 0;
uint32_t pie = 0; uint32_t pie = 0;
uint32_t parry = 0; uint32_t tenacity = 0;
uint32_t attack = 0; uint32_t attack = 0;
uint32_t defense = 0; uint32_t defense = 0;
uint32_t accuracy = 0; uint32_t accuracy = 0;
@ -160,11 +161,15 @@ protected:
uint64_t m_targetId; uint64_t m_targetId;
/*! Ptr to a queued action */ /*! Ptr to a queued action */
Action::ActionPtr m_pCurrentAction; Action::ActionPtr m_pCurrentAction;
/*! Container for status effects */
StatusEffect::StatusEffectContainerPtr m_pStatusEffectContainer;
/*! Invincibility type */ /*! Invincibility type */
Common::InvincibilityType m_invincibilityType; Common::InvincibilityType m_invincibilityType;
/*! Status effects */
const uint8_t MAX_STATUS_EFFECTS = 30;
std::queue< uint8_t > m_statusEffectFreeSlotQueue;
std::vector< std::pair< uint8_t, uint32_t> > m_statusEffectList;
std::map< uint8_t, StatusEffect::StatusEffectPtr > m_statusEffectMap;
public: public:
Actor(); Actor();
@ -174,18 +179,36 @@ public:
uint32_t getId() const; uint32_t getId() const;
/// Status effect functions
void addStatusEffect( StatusEffect::StatusEffectPtr pEffect );
void removeStatusEffect( uint8_t effectSlotId );
void removeSingleStatusEffectById( uint32_t id );
void updateStatusEffects();
bool hasStatusEffect( uint32_t id );
int8_t getStatusEffectFreeSlot();
void statusEffectFreeSlot( uint8_t slotId );
std::map< uint8_t, Core::StatusEffect::StatusEffectPtr > getStatusEffectMap() const;
void sendStatusEffectUpdate();
// add a status effect by id
void addStatusEffectById( uint32_t id, int32_t duration, Entity::Actor& pSource, uint16_t param = 0 );
// add a status effect by id if it doesn't exist
void addStatusEffectByIdIfNotExist( uint32_t id, int32_t duration, Entity::Actor& pSource, uint16_t param = 0 );
// remove a status effect by id
void removeSingleStatusEffectFromId( uint32_t id );
/// End Status Effect Functions
void setPosition( const Common::FFXIVARR_POSITION3& pos ); void setPosition( const Common::FFXIVARR_POSITION3& pos );
void setPosition( float x, float y, float z ); void setPosition( float x, float y, float z );
void setRotation( float rot ) void setRotation( float rot );
{
m_rot = rot;
}
float getRotation() const float getRotation() const;
{
return m_rot;
}
Common::FFXIVARR_POSITION3& getPos(); Common::FFXIVARR_POSITION3& getPos();
@ -309,20 +332,6 @@ public:
// set the current cell // set the current cell
void setCell( Cell* pCell ); void setCell( Cell* pCell );
// add a status effect
void addStatusEffect( StatusEffect::StatusEffectPtr pEffect );
// add a status effect by id
void addStatusEffectById( uint32_t id, int32_t duration, Entity::Actor& pSource, uint16_t param = 0 );
// add a status effect by id if it doesn't exist
void addStatusEffectByIdIfNotExist( uint32_t id, int32_t duration, Entity::Actor& pSource, uint16_t param = 0 );
// remove a status effect by id
void removeSingleStatusEffectFromId( uint32_t id );
//get the status effect container
StatusEffect::StatusEffectContainerPtr getStatusEffectContainer() const;
// TODO: Why did i even declare them publicly here?! // TODO: Why did i even declare them publicly here?!
std::set< ActorPtr > m_inRangeActors; std::set< ActorPtr > m_inRangeActors;

View file

@ -4,18 +4,17 @@
#include <stdint.h> #include <stdint.h>
#include <cmath> #include <cmath>
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include <src/servers/Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <src/servers/Server_Common/Util/Util.h> #include <Server_Common/Util/Util.h>
#include <src/servers/Server_Common/Util/UtilMath.h> #include <Server_Common/Util/UtilMath.h>
#include "Player.h" #include "Player.h"
#include "BattleNpc.h" #include "BattleNpc.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/MoveActorPacket.h" #include "Network/PacketWrappers/MoveActorPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket142.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "src/servers/Server_Zone/StatusEffect/StatusEffectContainer.h"
using namespace Core::Common; using namespace Core::Common;
using namespace Core::Network::Packets; using namespace Core::Network::Packets;
@ -40,7 +39,7 @@ Core::Entity::BattleNpc::~BattleNpc()
Core::Entity::BattleNpc::BattleNpc( uint16_t modelId, uint16_t nameid, const Common::FFXIVARR_POSITION3& spawnPos, Core::Entity::BattleNpc::BattleNpc( uint16_t modelId, uint16_t nameid, const Common::FFXIVARR_POSITION3& spawnPos,
uint16_t bnpcBaseId, uint32_t type, uint8_t level, uint8_t behaviour, uint16_t bnpcBaseId, uint32_t type, uint8_t level, uint8_t behaviour,
uint32_t mobType ) uint32_t mobType ) : Actor()
{ {
BattleNpc::m_nextID++; BattleNpc::m_nextID++;
m_id = BattleNpc::m_nextID; m_id = BattleNpc::m_nextID;
@ -87,13 +86,8 @@ Core::Entity::BattleNpc::BattleNpc( uint16_t modelId, uint16_t nameid, const Com
} }
void Core::Entity::BattleNpc::initStatusEffectContainer()
{
m_pStatusEffectContainer = StatusEffect::StatusEffectContainerPtr( new StatusEffect::StatusEffectContainer( shared_from_this() ) );
}
// spawn this player for pTarget // spawn this player for pTarget
void Core::Entity::BattleNpc::spawn( Core::Entity::PlayerPtr pTarget ) void Core::Entity::BattleNpc::spawn( PlayerPtr pTarget )
{ {
//GamePacketNew< FFXIVIpcActorSpawn > spawnPacket( getId(), pTarget->getId() ); //GamePacketNew< FFXIVIpcActorSpawn > spawnPacket( getId(), pTarget->getId() );
@ -155,7 +149,7 @@ void Core::Entity::BattleNpc::spawn( Core::Entity::PlayerPtr pTarget )
} }
// despawn // despawn
void Core::Entity::BattleNpc::despawn( Core::Entity::ActorPtr pTarget ) void Core::Entity::BattleNpc::despawn( ActorPtr pTarget )
{ {
auto pPlayer = pTarget->getAsPlayer(); auto pPlayer = pTarget->getAsPlayer();
@ -177,7 +171,7 @@ Core::Entity::StateMode Core::Entity::BattleNpc::getMode() const
return m_mode; return m_mode;
} }
void Core::Entity::BattleNpc::setMode( Core::Entity::StateMode mode ) void Core::Entity::BattleNpc::setMode( StateMode mode )
{ {
m_mode = mode; m_mode = mode;
} }
@ -187,7 +181,7 @@ uint8_t Core::Entity::BattleNpc::getbehavior() const
return m_behavior; return m_behavior;
} }
void Core::Entity::BattleNpc::hateListAdd( Core::Entity::ActorPtr pActor, int32_t hateAmount ) void Core::Entity::BattleNpc::hateListAdd( ActorPtr pActor, int32_t hateAmount )
{ {
auto hateEntry = new HateListEntry(); auto hateEntry = new HateListEntry();
hateEntry->m_hateAmount = hateAmount; hateEntry->m_hateAmount = hateAmount;
@ -217,7 +211,7 @@ Core::Entity::ActorPtr Core::Entity::BattleNpc::hateListGetHighest()
return nullptr; return nullptr;
} }
void Core::Entity::BattleNpc::setOwner( Core::Entity::PlayerPtr pPlayer ) void Core::Entity::BattleNpc::setOwner( PlayerPtr pPlayer )
{ {
m_pOwner = pPlayer; m_pOwner = pPlayer;
@ -240,7 +234,7 @@ void Core::Entity::BattleNpc::setOwner( Core::Entity::PlayerPtr pPlayer )
void Core::Entity::BattleNpc::sendPositionUpdate() void Core::Entity::BattleNpc::sendPositionUpdate()
{ {
MoveActorPacket movePacket( shared_from_this(), 0x3A, 0x00, 0, 0x5A ); MoveActorPacket movePacket( *this, 0x3A, 0x00, 0, 0x5A );
sendToInRangeSet( movePacket ); sendToInRangeSet( movePacket );
} }
@ -284,7 +278,7 @@ bool Core::Entity::BattleNpc::moveTo( Common::FFXIVARR_POSITION3& pos )
} }
void Core::Entity::BattleNpc::aggro( Core::Entity::ActorPtr pActor ) void Core::Entity::BattleNpc::aggro( ActorPtr pActor )
{ {
m_lastAttack = Util::getTimeMs(); m_lastAttack = Util::getTimeMs();
@ -302,7 +296,7 @@ void Core::Entity::BattleNpc::aggro( Core::Entity::ActorPtr pActor )
} }
} }
void Core::Entity::BattleNpc::deaggro( Core::Entity::ActorPtr pActor ) void Core::Entity::BattleNpc::deaggro( ActorPtr pActor )
{ {
if( !hateListHasActor( pActor ) ) if( !hateListHasActor( pActor ) )
hateListRemove( pActor ); hateListRemove( pActor );
@ -328,7 +322,7 @@ void Core::Entity::BattleNpc::hateListClear()
} }
void Core::Entity::BattleNpc::hateListRemove( Core::Entity::ActorPtr pActor ) void Core::Entity::BattleNpc::hateListRemove( ActorPtr pActor )
{ {
auto it = m_hateList.begin(); auto it = m_hateList.begin();
for( ; it != m_hateList.end(); ++it ) for( ; it != m_hateList.end(); ++it )
@ -348,7 +342,7 @@ void Core::Entity::BattleNpc::hateListRemove( Core::Entity::ActorPtr pActor )
} }
} }
bool Core::Entity::BattleNpc::hateListHasActor( Core::Entity::ActorPtr pActor ) bool Core::Entity::BattleNpc::hateListHasActor( ActorPtr pActor )
{ {
auto it = m_hateList.begin(); auto it = m_hateList.begin();
for( ; it != m_hateList.end(); ++it ) for( ; it != m_hateList.end(); ++it )
@ -369,7 +363,7 @@ uint32_t Core::Entity::BattleNpc::getNameId() const
return m_nameId; return m_nameId;
} }
void Core::Entity::BattleNpc::hateListUpdate( Core::Entity::ActorPtr pActor, int32_t hateAmount ) void Core::Entity::BattleNpc::hateListUpdate( ActorPtr pActor, int32_t hateAmount )
{ {
auto it = m_hateList.begin(); auto it = m_hateList.begin();
@ -458,7 +452,7 @@ void Core::Entity::BattleNpc::onDeath()
hateListClear(); hateListClear();
} }
void Core::Entity::BattleNpc::onActionHostile( Core::Entity::ActorPtr pSource ) void Core::Entity::BattleNpc::onActionHostile( ActorPtr pSource )
{ {
if( hateListGetHighest() == nullptr ) if( hateListGetHighest() == nullptr )
@ -487,9 +481,7 @@ void Core::Entity::BattleNpc::update( int64_t currTime )
return; return;
} }
if ( !m_pStatusEffectContainer ) updateStatusEffects();
initStatusEffectContainer();
m_pStatusEffectContainer->update();
float distance = Math::Util::distance( m_pos.x, m_pos.y, m_pos.z, float distance = Math::Util::distance( m_pos.x, m_pos.y, m_pos.z,
m_posOrigin.x, m_posOrigin.y, m_posOrigin.z ); m_posOrigin.x, m_posOrigin.y, m_posOrigin.z );

View file

@ -4,7 +4,6 @@
#include "Actor.h" #include "Actor.h"
namespace Core { namespace Core {
namespace Entity { namespace Entity {
enum StateMode enum StateMode
@ -76,7 +75,7 @@ public:
void onDeath() override; void onDeath() override;
void onActionHostile( Core::Entity::ActorPtr pSource ) override; void onActionHostile( ActorPtr pSource ) override;
ActorPtr getClaimer() const; ActorPtr getClaimer() const;

View file

@ -1,48 +1,45 @@
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <src/servers/Server_Common/Util/Util.h> #include <Server_Common/Util/Util.h>
#include <src/servers/Server_Common/Util/UtilMath.h> #include <Server_Common/Util/UtilMath.h>
#include <src/servers/Server_Common/Config/XMLConfig.h> #include <Server_Common/Config/XMLConfig.h>
#include <src/servers/Server_Common/Network/GamePacket.h> #include <Server_Common/Network/GamePacket.h>
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include <src/servers/Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <src/servers/Server_Common/Network/PacketContainer.h> #include <Server_Common/Network/PacketContainer.h>
#include "src/servers/Server_Zone/Session.h" #include "Session.h"
#include "Player.h" #include "Player.h"
#include "BattleNpc.h" #include "BattleNpc.h"
#include "src/servers/Server_Zone/Zone/ZoneMgr.h" #include "Zone/ZoneMgr.h"
#include "src/servers/Server_Zone/Zone/Zone.h" #include "Zone/Zone.h"
#include "src/servers/Server_Zone/ServerZone.h" #include "ServerZone.h"
#include "src/servers/Server_Zone/Network/GameConnection.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/PlayerSpawnPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket142.h" #include "Script/ScriptManager.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket143.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/InitUIPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ServerNoticePacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ChatPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ModelEquipPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorSpawnPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/UpdateHpMpTpPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/PlayerStateFlagsPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/PlayerSpawnPacket.h"
#include "src/servers/Server_Zone/Script/ScriptManager.h" #include "Inventory/Item.h"
#include "src/servers/Server_Zone/StatusEffect/StatusEffectContainer.h" #include "Inventory/Inventory.h"
#include "Event/Event.h"
#include "src/servers/Server_Zone/Inventory/Item.h" #include "Action/Action.h"
#include "Action/EventAction.h"
#include "src/servers/Server_Zone/Inventory/Inventory.h" #include "Action/EventItemAction.h"
#include "src/servers/Server_Zone/Event/Event.h" #include "Zone/ZonePosition.h"
#include "src/servers/Server_Zone/Action/Action.h" #include "Math/CalcStats.h"
#include "src/servers/Server_Zone/Action/EventAction.h" #include "Math/CalcBattle.h"
#include "src/servers/Server_Zone/Action/EventItemAction.h"
#include "src/servers/Server_Zone/Zone/ZonePosition.h"
#include "src/servers/Server_Zone/Math/CalcStats.h"
#include "src/servers/Server_Zone/Math/CalcBattle.h"
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
extern Core::Logger g_log; extern Core::Logger g_log;
@ -57,6 +54,7 @@ using namespace Core::Network::Packets::Server;
// player constructor // player constructor
Core::Entity::Player::Player() : Core::Entity::Player::Player() :
Actor(),
m_lastWrite( 0 ), m_lastWrite( 0 ),
m_lastPing( 0 ), m_lastPing( 0 ),
m_bIsLogin( false ), m_bIsLogin( false ),
@ -237,12 +235,13 @@ void Core::Entity::Player::calculateStats()
m_baseStats.mnd = static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_mnd ) / 100 ) + tribeInfo.mod_mnd ); 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.pie = static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_pie ) / 100 ) + tribeInfo.mod_pie );
m_baseStats.skillSpeed = paramGrowthInfo.base_secondary; m_baseStats.skillSpeed = paramGrowthInfo.base_secondary;
m_baseStats.spellSpeed = paramGrowthInfo.base_secondary; m_baseStats.spellSpeed = paramGrowthInfo.base_secondary;
m_baseStats.accuracy = paramGrowthInfo.base_secondary; m_baseStats.accuracy = paramGrowthInfo.base_secondary;
m_baseStats.critHitRate = paramGrowthInfo.base_secondary; m_baseStats.critHitRate = paramGrowthInfo.base_secondary;
m_baseStats.attackPotMagic = paramGrowthInfo.base_secondary; m_baseStats.attackPotMagic = paramGrowthInfo.base_secondary;
m_baseStats.healingPotMagic = paramGrowthInfo.base_secondary; m_baseStats.healingPotMagic = paramGrowthInfo.base_secondary;
m_baseStats.tenacity = paramGrowthInfo.base_secondary;
m_baseStats.max_mp = Math::CalcStats::calculateMaxMp( getAsPlayer() ); m_baseStats.max_mp = Math::CalcStats::calculateMaxMp( getAsPlayer() );
@ -419,7 +418,7 @@ void Core::Entity::Player::setZone( uint32_t zoneId )
} }
queuePacket( contentFinderList ); queuePacket( contentFinderList );
Server::InitUIPacket initUIPacket( pPlayer ); Server::InitUIPacket initUIPacket( *pPlayer );
queuePacket( initUIPacket ); queuePacket( initUIPacket );
ZoneChannelPacket< FFXIVIpcPlayerClassInfo > classInfoPacket( getId() ); ZoneChannelPacket< FFXIVIpcPlayerClassInfo > classInfoPacket( getId() );
@ -435,6 +434,9 @@ void Core::Entity::Player::setZone( uint32_t zoneId )
gcAffPacket.data().gcRank[1] = m_gcRank[1]; gcAffPacket.data().gcRank[1] = m_gcRank[1];
gcAffPacket.data().gcRank[2] = m_gcRank[2]; gcAffPacket.data().gcRank[2] = m_gcRank[2];
queuePacket( gcAffPacket ); queuePacket( gcAffPacket );
m_itemLevel = getInventory()->calculateEquippedGearItemLevel();
sendItemLevel();
} }
ZoneChannelPacket< FFXIVIpcInitZone > initZonePacket( getId() ); ZoneChannelPacket< FFXIVIpcInitZone > initZonePacket( getId() );
@ -715,7 +717,7 @@ void Core::Entity::Player::gainLevel()
void Core::Entity::Player::unlock() void Core::Entity::Player::unlock()
{ {
queuePacket( PlayerStateFlagsPacket( getAsPlayer(), PlayerStateFlagList{} ) ); queuePacket( PlayerStateFlagsPacket( *getAsPlayer(), PlayerStateFlagList{} ) );
} }
void Core::Entity::Player::sendStatusUpdate( bool toSelf ) void Core::Entity::Player::sendStatusUpdate( bool toSelf )
@ -751,7 +753,7 @@ uint8_t Core::Entity::Player::getLevel() const
return static_cast< uint8_t >( m_classArray[classJobIndex] ); return static_cast< uint8_t >( m_classArray[classJobIndex] );
} }
uint8_t Core::Entity::Player::getLevelForClass( Core::Common::ClassJob pClass ) const uint8_t Core::Entity::Player::getLevelForClass( Common::ClassJob pClass ) const
{ {
uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( pClass )].exp_idx; uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( pClass )].exp_idx;
return static_cast< uint8_t >( m_classArray[classJobIndex] ); return static_cast< uint8_t >( m_classArray[classJobIndex] );
@ -780,7 +782,7 @@ void Core::Entity::Player::setInCombat( bool mode )
m_bInCombat = mode; m_bInCombat = mode;
} }
void Core::Entity::Player::setClassJob( Core::Common::ClassJob classJob ) void Core::Entity::Player::setClassJob( Common::ClassJob classJob )
{ {
m_class = classJob; m_class = classJob;
uint8_t level = getLevel(); uint8_t level = getLevel();
@ -809,7 +811,7 @@ void Core::Entity::Player::setLevel( uint8_t level )
m_classArray[classJobIndex] = level; m_classArray[classJobIndex] = level;
} }
void Core::Entity::Player::setLevelForClass( uint8_t level, Core::Common::ClassJob classjob ) void Core::Entity::Player::setLevelForClass( uint8_t level, Common::ClassJob classjob )
{ {
uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( classjob )].exp_idx; uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( classjob )].exp_idx;
m_classArray[classJobIndex] = level; m_classArray[classJobIndex] = level;
@ -817,7 +819,7 @@ void Core::Entity::Player::setLevelForClass( uint8_t level, Core::Common::ClassJ
void Core::Entity::Player::sendModel() void Core::Entity::Player::sendModel()
{ {
ModelEquipPacket modelEquip( getAsPlayer() ); ModelEquipPacket modelEquip( *getAsPlayer() );
sendToInRangeSet( modelEquip, true ); sendToInRangeSet( modelEquip, true );
} }
@ -848,7 +850,7 @@ uint64_t Core::Entity::Player::getModelSystemWeapon() const
int8_t Core::Entity::Player::getAetheryteMaskAt( uint8_t index ) const int8_t Core::Entity::Player::getAetheryteMaskAt( uint8_t index ) const
{ {
if( index > 11 ) if( index > sizeof( m_aetheryte ) )
return 0; return 0;
return m_aetheryte[index]; return m_aetheryte[index];
} }
@ -879,18 +881,18 @@ void Core::Entity::Player::setLookAt( uint8_t index, uint8_t value )
} }
// spawn this player for pTarget // spawn this player for pTarget
void Core::Entity::Player::spawn( Core::Entity::PlayerPtr pTarget ) void Core::Entity::Player::spawn( Entity::PlayerPtr pTarget )
{ {
g_log.debug( "[" + std::to_string( pTarget->getId() ) + "] Spawning " + g_log.debug( "[" + std::to_string( pTarget->getId() ) + "] Spawning " +
getName() + " for " + getName() + " for " +
pTarget->getName() ); pTarget->getName() );
PlayerSpawnPacket spawnActor( getAsPlayer(), pTarget ); PlayerSpawnPacket spawnActor( *getAsPlayer(), *pTarget );
pTarget->queuePacket( spawnActor ); pTarget->queuePacket( spawnActor );
} }
// despawn // despawn
void Core::Entity::Player::despawn( Core::Entity::ActorPtr pTarget ) void Core::Entity::Player::despawn( Entity::ActorPtr pTarget )
{ {
auto pPlayer = pTarget->getAsPlayer(); auto pPlayer = pTarget->getAsPlayer();
@ -901,7 +903,7 @@ void Core::Entity::Player::despawn( Core::Entity::ActorPtr pTarget )
Core::Entity::ActorPtr Core::Entity::Player::lookupTargetById( uint64_t targetId ) Core::Entity::ActorPtr Core::Entity::Player::lookupTargetById( uint64_t targetId )
{ {
Core::Entity::ActorPtr targetActor; ActorPtr targetActor;
auto inRange = getInRangeActors( true ); auto inRange = getInRangeActors( true );
for( auto actor : inRange ) for( auto actor : inRange )
{ {
@ -961,13 +963,11 @@ bool Core::Entity::Player::actionHasCastTime( uint32_t actionId ) //TODO: Add lo
if( actionInfoPtr->is_instant ) if( actionInfoPtr->is_instant )
return false; return false;
if( actionInfoPtr->cast_time == 0 ) return actionInfoPtr->cast_time != 0;
return false;
return true;
} }
bool Core::Entity::Player::hasStateFlag( Core::Common::PlayerStateFlag flag ) const bool Core::Entity::Player::hasStateFlag( Common::PlayerStateFlag flag ) const
{ {
int32_t iFlag = static_cast< uint32_t >( flag ); int32_t iFlag = static_cast< uint32_t >( flag );
@ -978,7 +978,7 @@ bool Core::Entity::Player::hasStateFlag( Core::Common::PlayerStateFlag flag ) co
return ( m_stateFlags[index] & value ) != 0; return ( m_stateFlags[index] & value ) != 0;
} }
void Core::Entity::Player::setStateFlag( Core::Common::PlayerStateFlag flag ) void Core::Entity::Player::setStateFlag( Common::PlayerStateFlag flag )
{ {
int32_t iFlag = static_cast< uint32_t >( flag ); int32_t iFlag = static_cast< uint32_t >( flag );
@ -1006,10 +1006,10 @@ void Core::Entity::Player::setStateFlags( std::vector< Common::PlayerStateFlag >
void Core::Entity::Player::sendStateFlags() void Core::Entity::Player::sendStateFlags()
{ {
queuePacket( PlayerStateFlagsPacket( getAsPlayer() ) ); queuePacket( PlayerStateFlagsPacket( *getAsPlayer() ) );
} }
void Core::Entity::Player::unsetStateFlag( Core::Common::PlayerStateFlag flag ) void Core::Entity::Player::unsetStateFlag( Common::PlayerStateFlag flag )
{ {
if( !hasStateFlag( flag ) ) if( !hasStateFlag( flag ) )
return; return;
@ -1056,7 +1056,7 @@ void Core::Entity::Player::update( int64_t currTime )
if( !isAlive() ) if( !isAlive() )
return; return;
m_pStatusEffectContainer->update(); updateStatusEffects();
m_lastUpdate = currTime; m_lastUpdate = currTime;
@ -1083,7 +1083,7 @@ void Core::Entity::Player::update( int64_t currTime )
if( Math::Util::distance(getPos().x, getPos().y, getPos().z, if( Math::Util::distance(getPos().x, getPos().y, getPos().z,
actor->getPos().x, actor->getPos().y, actor->getPos().z) <= range ) actor->getPos().x, actor->getPos().y, actor->getPos().z) <= range )
{ {
if( ( currTime - m_lastAttack ) > mainWeap->getDelay() ) if( ( currTime - m_lastAttack ) > mainWeap->getDelay() )
@ -1109,7 +1109,7 @@ void Core::Entity::Player::update( int64_t currTime )
void Core::Entity::Player::onMobKill( uint16_t nameId ) void Core::Entity::Player::onMobKill( uint16_t nameId )
{ {
g_scriptMgr.onMobKill( getAsPlayer(), nameId ); g_scriptMgr.onMobKill( *getAsPlayer(), nameId );
} }
void Core::Entity::Player::freePlayerSpawnId( uint32_t actorId ) void Core::Entity::Player::freePlayerSpawnId( uint32_t actorId )
@ -1144,57 +1144,57 @@ uint8_t Core::Entity::Player::getHomepoint() const
return m_homePoint; return m_homePoint;
} }
uint16_t * Core::Entity::Player::getClassArray() uint16_t* Core::Entity::Player::getClassArray()
{ {
return m_classArray; return m_classArray;
} }
const uint16_t * Core::Entity::Player::getClassArray() const const uint16_t* Core::Entity::Player::getClassArray() const
{ {
return m_classArray; return m_classArray;
} }
const uint8_t * Core::Entity::Player::getLookArray() const const uint8_t* Core::Entity::Player::getLookArray() const
{ {
return m_customize; return m_customize;
} }
const uint32_t * Core::Entity::Player::getModelArray() const const uint32_t* Core::Entity::Player::getModelArray() const
{ {
return m_modelEquip; return m_modelEquip;
} }
uint32_t * Core::Entity::Player::getExpArray() uint32_t* Core::Entity::Player::getExpArray()
{ {
return m_expArray; return m_expArray;
} }
const uint32_t * Core::Entity::Player::getExpArray() const const uint32_t* Core::Entity::Player::getExpArray() const
{ {
return m_expArray; return m_expArray;
} }
uint8_t * Core::Entity::Player::getHowToArray() uint8_t* Core::Entity::Player::getHowToArray()
{ {
return m_howTo; return m_howTo;
} }
const uint8_t * Core::Entity::Player::getHowToArray() const const uint8_t* Core::Entity::Player::getHowToArray() const
{ {
return m_howTo; return m_howTo;
} }
const uint8_t * Core::Entity::Player::getUnlockBitmask() const const uint8_t* Core::Entity::Player::getUnlockBitmask() const
{ {
return m_unlocks; return m_unlocks;
} }
const uint8_t * Core::Entity::Player::getOrchestrionBitmask() const const uint8_t* Core::Entity::Player::getOrchestrionBitmask() const
{ {
return m_orchestrion; return m_orchestrion;
} }
const uint8_t * Core::Entity::Player::getMountGuideBitmask() const const uint8_t* Core::Entity::Player::getMountGuideBitmask() const
{ {
return m_mountGuide; return m_mountGuide;
} }
@ -1214,12 +1214,12 @@ uint8_t Core::Entity::Player::getGc() const
return m_gc; return m_gc;
} }
const uint8_t * Core::Entity::Player::getGcRankArray() const const uint8_t* Core::Entity::Player::getGcRankArray() const
{ {
return m_gcRank; return m_gcRank;
} }
void Core::Entity::Player::queuePacket( Core::Network::Packets::GamePacketPtr pPacket ) void Core::Entity::Player::queuePacket( Network::Packets::GamePacketPtr pPacket )
{ {
auto pSession = g_serverZone.getSession( m_id ); auto pSession = g_serverZone.getSession( m_id );
@ -1233,7 +1233,7 @@ void Core::Entity::Player::queuePacket( Core::Network::Packets::GamePacketPtr pP
} }
void Core::Entity::Player::queueChatPacket( Core::Network::Packets::GamePacketPtr pPacket ) void Core::Entity::Player::queueChatPacket( Network::Packets::GamePacketPtr pPacket )
{ {
auto pSession = g_serverZone.getSession( m_id ); auto pSession = g_serverZone.getSession( m_id );
@ -1256,7 +1256,7 @@ void Core::Entity::Player::setLoadingComplete( bool bComplete )
m_bLoadingComplete = bComplete; m_bLoadingComplete = bComplete;
} }
void Core::Entity::Player::performZoning(uint16_t zoneId, const Common::FFXIVARR_POSITION3 &pos, float rotation) void Core::Entity::Player::performZoning( uint16_t zoneId, const Common::FFXIVARR_POSITION3 &pos, float rotation )
{ {
m_pos = pos; m_pos = pos;
m_zoneId = zoneId; m_zoneId = zoneId;
@ -1310,12 +1310,12 @@ void Core::Entity::Player::sendNotice( const std::string& message ) //Purple Tex
void Core::Entity::Player::sendUrgent( const std::string& message ) //Red Text void Core::Entity::Player::sendUrgent( const std::string& message ) //Red Text
{ {
queuePacket( ChatPacket( getAsPlayer(), ChatType::ServerUrgent, message ) ); queuePacket( ChatPacket( *getAsPlayer(), ChatType::ServerUrgent, message ) );
} }
void Core::Entity::Player::sendDebug( const std::string& message ) //Grey Text void Core::Entity::Player::sendDebug( const std::string& message ) //Grey Text
{ {
queuePacket( ChatPacket( getAsPlayer(), ChatType::ServerDebug, message ) ); queuePacket( ChatPacket( *getAsPlayer(), ChatType::ServerDebug, message ) );
} }
void Core::Entity::Player::updateHowtosSeen( uint32_t howToId ) void Core::Entity::Player::updateHowtosSeen( uint32_t howToId )
@ -1329,14 +1329,14 @@ void Core::Entity::Player::updateHowtosSeen( uint32_t howToId )
} }
void Core::Entity::Player::onMobAggro( Core::Entity::BattleNpcPtr pBNpc ) void Core::Entity::Player::onMobAggro( BattleNpcPtr pBNpc )
{ {
hateListAdd( pBNpc ); hateListAdd( pBNpc );
queuePacket( ActorControlPacket142( getId(), ToggleAggro, 1 ) ); queuePacket( ActorControlPacket142( getId(), ToggleAggro, 1 ) );
} }
void Core::Entity::Player::onMobDeaggro( Core::Entity::BattleNpcPtr pBNpc ) void Core::Entity::Player::onMobDeaggro( BattleNpcPtr pBNpc )
{ {
hateListRemove( pBNpc ); hateListRemove( pBNpc );
@ -1344,7 +1344,7 @@ void Core::Entity::Player::onMobDeaggro( Core::Entity::BattleNpcPtr pBNpc )
queuePacket( ActorControlPacket142( getId(), ToggleAggro ) ); queuePacket( ActorControlPacket142( getId(), ToggleAggro ) );
} }
void Core::Entity::Player::hateListAdd( Core::Entity::BattleNpcPtr pBNpc ) void Core::Entity::Player::hateListAdd( BattleNpcPtr pBNpc )
{ {
if( m_freeHateSlotQueue.empty() ) if( m_freeHateSlotQueue.empty() )
@ -1356,7 +1356,7 @@ void Core::Entity::Player::hateListAdd( Core::Entity::BattleNpcPtr pBNpc )
} }
void Core::Entity::Player::hateListRemove( Core::Entity::BattleNpcPtr pBNpc ) void Core::Entity::Player::hateListRemove( BattleNpcPtr pBNpc )
{ {
auto it = m_actorIdTohateSlotMap.begin(); auto it = m_actorIdTohateSlotMap.begin();
@ -1374,7 +1374,7 @@ void Core::Entity::Player::hateListRemove( Core::Entity::BattleNpcPtr pBNpc )
} }
} }
bool Core::Entity::Player::hateListHasMob( Core::Entity::BattleNpcPtr pBNpc ) bool Core::Entity::Player::hateListHasMob( BattleNpcPtr pBNpc )
{ {
auto it = m_actorIdTohateSlotMap.begin(); auto it = m_actorIdTohateSlotMap.begin();
@ -1416,7 +1416,7 @@ void Core::Entity::Player::setIsLogin( bool bIsLogin )
m_bIsLogin = bIsLogin; m_bIsLogin = bIsLogin;
} }
uint8_t * Core::Entity::Player::getTitleList() uint8_t* Core::Entity::Player::getTitleList()
{ {
return m_titleList; return m_titleList;
} }
@ -1589,6 +1589,11 @@ void Core::Entity::Player::setOpeningSequence( uint8_t seq )
m_openingSequence = seq; m_openingSequence = seq;
} }
uint16_t Core::Entity::Player::getItemLevel() const
{
return m_itemLevel;
}
/// Tells client to offset their eorzean time by given timestamp. /// Tells client to offset their eorzean time by given timestamp.
void Core::Entity::Player::setEorzeaTimeOffset( uint64_t timestamp ) void Core::Entity::Player::setEorzeaTimeOffset( uint64_t timestamp )
{ {

View file

@ -1,12 +1,12 @@
#ifndef _PLAYER_H #ifndef _PLAYER_H
#define _PLAYER_H #define _PLAYER_H
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include "Actor.h" #include "Actor.h"
#include "src/servers/Server_Zone/Inventory/Inventory.h" #include "Inventory/Inventory.h"
#include <map> #include <map>
#include <queue> #include <queue>
@ -206,6 +206,10 @@ public:
void unequipItem( Inventory::EquipSlot equipSlotId, ItemPtr pItem ); void unequipItem( Inventory::EquipSlot equipSlotId, ItemPtr pItem );
/*! equip a weapon, possibly forcing a job change */ /*! equip a weapon, possibly forcing a job change */
void equipWeapon( ItemPtr pItem ); void equipWeapon( ItemPtr pItem );
/*! get player ilvl */
uint16_t getItemLevel() const;
/*! send player ilvl */
void sendItemLevel();
/*! get a const pointer to the inventory object */ /*! get a const pointer to the inventory object */
InventoryPtr getInventory() const; InventoryPtr getInventory() const;
/*! get the current main hand model */ /*! get the current main hand model */
@ -238,7 +242,7 @@ public:
/*! returns the level of the currently active class / job */ /*! returns the level of the currently active class / job */
uint8_t getLevel() const override; uint8_t getLevel() const override;
/*! returns the level of the provided class / job */ /*! returns the level of the provided class / job */
uint8_t getLevelForClass( Core::Common::ClassJob pClass ) const; uint8_t getLevelForClass( Common::ClassJob pClass ) const;
/*! returns the exp of the currently active class / job */ /*! returns the exp of the currently active class / job */
uint32_t getExp() const; uint32_t getExp() const;
/*! sets the exp of the currently active class / job */ /*! sets the exp of the currently active class / job */
@ -250,9 +254,9 @@ public:
/*! set level on the currently active class / job to given level */ /*! set level on the currently active class / job to given level */
void setLevel( uint8_t level ); void setLevel( uint8_t level );
/*! set level on the provided class / job to given level */ /*! set level on the provided class / job to given level */
void setLevelForClass( uint8_t level, Core::Common::ClassJob classjob ); void setLevelForClass( uint8_t level, Common::ClassJob classjob );
/*! change class or job to given class / job */ /*! change class or job to given class / job */
void setClassJob( Core::Common::ClassJob classJob ); void setClassJob( Common::ClassJob classJob );
/*! returns a pointer to the class array */ /*! returns a pointer to the class array */
uint16_t* getClassArray(); uint16_t* getClassArray();
/*! returns a const pointer to the class array */ /*! returns a const pointer to the class array */
@ -594,16 +598,20 @@ private:
uint8_t m_openingSequence; uint8_t m_openingSequence;
uint16_t m_itemLevel;
InventoryPtr m_pInventory; InventoryPtr m_pInventory;
std::map< uint32_t, Event::EventPtr > m_eventMap; std::map< uint32_t, Event::EventPtr > m_eventMap;
std::map< uint32_t, uint8_t > m_playerIdToSpawnIdMap; // maps player to spawn id std::map< uint32_t, uint8_t > m_playerIdToSpawnIdMap; // maps player to spawn id
std::queue< uint8_t > m_freeSpawnIdQueue; // queue with spawn ids free to be assigned std::queue< uint8_t > m_freeSpawnIdQueue; // queue with spawn ids free to be assigned
std::queue< uint8_t > m_freeHateSlotQueue; // queue with "hate slots" free to be assigned std::queue< uint8_t > m_freeHateSlotQueue; // queue with "hate slots" free to be assigned
std::map< uint32_t, uint8_t > m_actorIdTohateSlotMap; std::map< uint32_t, uint8_t > m_actorIdTohateSlotMap;
std::map< uint32_t, uint8_t > m_questIdToQuestIdx; // quest mapping, quest id to quest container index std::map< uint32_t, uint8_t > m_questIdToQuestIdx; // quest mapping, quest id to quest container index
std::map< uint8_t, uint32_t > m_questIdxToQuestId; // quest mapping, quest container index to questId std::map< uint8_t, uint32_t > m_questIdxToQuestId; // quest mapping, quest container index to questId
boost::shared_ptr< Common::QuestActive > m_activeQuests[30]; boost::shared_ptr< Common::QuestActive > m_activeQuests[30];
int16_t m_questTracking[5]; int16_t m_questTracking[5];
uint8_t m_stateFlags[7]; uint8_t m_stateFlags[7];
uint8_t m_gmRank; uint8_t m_gmRank;
uint16_t zoneId; uint16_t zoneId;

View file

@ -1,29 +1,29 @@
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <src/servers/Server_Common/Network/GamePacket.h> #include <Server_Common/Network/GamePacket.h>
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include <src/servers/Server_Common/Network/PacketContainer.h> #include <Server_Common/Network/PacketContainer.h>
#include <src/servers/Server_Common/Config/XMLConfig.h> #include <Server_Common/Config/XMLConfig.h>
#include "Player.h" #include "Player.h"
#include "src/servers/Server_Zone/Zone/Zone.h" #include "Zone/Zone.h"
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
#include "src/servers/Server_Zone/Network/GameConnection.h" #include "Network/GameConnection.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket142.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/InitUIPacket.h" #include "Network/PacketWrappers/InitUIPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ServerNoticePacket.h" #include "Network/PacketWrappers/ServerNoticePacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/EventStartPacket.h" #include "Network/PacketWrappers/EventStartPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/EventPlayPacket.h" #include "Network/PacketWrappers/EventPlayPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/EventFinishPacket.h" #include "Network/PacketWrappers/EventFinishPacket.h"
#include "src/servers/Server_Zone/Action/EventAction.h" #include "Action/EventAction.h"
#include "src/servers/Server_Zone/Action/EventItemAction.h" #include "Action/EventItemAction.h"
#include "src/servers/Server_Zone/Event/Event.h" #include "Event/Event.h"
#include "src/servers/Server_Zone/Event/Event.h" #include "Event/Event.h"
#include "Server_Zone/ServerZone.h" #include "ServerZone.h"
extern Core::Logger g_log; extern Core::Logger g_log;
extern Core::ServerZone g_serverZone; extern Core::ServerZone g_serverZone;

View file

@ -1,16 +1,20 @@
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Network/GamePacket.h>
#include <Server_Common/Logging/Logger.h>
#include "Player.h" #include "Player.h"
#include "src/servers/Server_Zone/Zone/ZoneMgr.h" #include "Zone/ZoneMgr.h"
#include "src/servers/Server_Zone/Zone/Zone.h" #include "Zone/Zone.h"
#include <src/servers/Server_Common/Network/GamePacket.h> #include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket143.h" #include "Inventory/Inventory.h"
#include "Inventory/Item.h"
#include "src/servers/Server_Zone/Inventory/Inventory.h" extern Core::Logger g_log;
#include "src/servers/Server_Zone/Inventory/Item.h"
using namespace Core::Common; using namespace Core::Common;
using namespace Core::Network::Packets; using namespace Core::Network::Packets;
@ -21,8 +25,13 @@ Core::InventoryPtr Core::Entity::Player::getInventory() const
return m_pInventory; return m_pInventory;
} }
void Core::Entity::Player::sendItemLevel()
{
queuePacket( ActorControlPacket142( getId(), SetItemLevel, getItemLevel(), 0 ) );
}
// TODO: This has to be redone and simplified // TODO: This has to be redone and simplified
void Core::Entity::Player::equipWeapon( Core::ItemPtr pItem ) void Core::Entity::Player::equipWeapon( ItemPtr pItem )
{ {
ClassJob currentClass = static_cast< ClassJob >( getClass() ); ClassJob currentClass = static_cast< ClassJob >( getClass() );
@ -77,10 +86,10 @@ void Core::Entity::Player::equipWeapon( Core::ItemPtr pItem )
} }
// equip an item // equip an item
void Core::Entity::Player::equipItem( Inventory::EquipSlot equipSlotId, Core::ItemPtr pItem, bool sendModel ) void Core::Entity::Player::equipItem( Inventory::EquipSlot equipSlotId, ItemPtr pItem, bool sendUpdate )
{ {
// Console->outDebOnly("Equipping into slot %i", equipSlotID); //g_log.debug( "Equipping into slot " + std::to_string( equipSlotId ) );
uint64_t model = pItem->getModelId1(); uint64_t model = pItem->getModelId1();
uint64_t model2 = pItem->getModelId2(); uint64_t model2 = pItem->getModelId2();
@ -109,14 +118,21 @@ void Core::Entity::Player::equipItem( Inventory::EquipSlot equipSlotId, Core::It
} }
if( sendModel ) if( sendUpdate )
{
this->sendModel(); this->sendModel();
m_itemLevel = getInventory()->calculateEquippedGearItemLevel();
sendItemLevel();
}
} }
void Core::Entity::Player::unequipItem( Inventory::EquipSlot equipSlotId, ItemPtr pItem ) void Core::Entity::Player::unequipItem( Inventory::EquipSlot equipSlotId, ItemPtr pItem )
{ {
m_modelEquip[static_cast< uint8_t >( equipSlotId )] = 0; m_modelEquip[static_cast< uint8_t >( equipSlotId )] = 0;
sendModel(); sendModel();
m_itemLevel = getInventory()->calculateEquippedGearItemLevel();
sendItemLevel();
} }
uint32_t Core::Entity::Player::getCurrency( uint8_t type ) const uint32_t Core::Entity::Player::getCurrency( uint8_t type ) const

View file

@ -1,16 +1,16 @@
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <src/servers/Server_Common/Network/PacketDef/Zone/ServerZoneDef.h> #include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include <src/servers/Server_Common/Network/GamePacket.h> #include <Server_Common/Network/GamePacket.h>
#include <src/servers/Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <src/servers/Server_Common/Network/PacketContainer.h> #include <Server_Common/Network/PacketContainer.h>
#include "src/servers/Server_Zone/Network/GameConnection.h" #include "Network/GameConnection.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/QuestMessagePacket.h" #include "Network/PacketWrappers/QuestMessagePacket.h"
#include "src/servers/Server_Zone/Session.h" #include "Server_Zone/Session.h"
#include "Player.h" #include "Player.h"
#include "src/servers/Server_Zone/Inventory/Inventory.h" #include "Server_Zone/Inventory/Inventory.h"
extern Core::Data::ExdData g_exdData; extern Core::Data::ExdData g_exdData;

View file

@ -1,35 +1,32 @@
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <src/servers/Server_Common/Network/GamePacket.h> #include <Server_Common/Network/GamePacket.h>
#include <src/servers/Server_Common/Util/Util.h> #include <Server_Common/Util/Util.h>
#include <src/servers/Server_Common/Util/UtilMath.h> #include <Server_Common/Util/UtilMath.h>
#include <src/servers/Server_Common/Config/XMLConfig.h> #include <Server_Common/Config/XMLConfig.h>
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include <src/servers/Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <src/servers/Server_Common/Network/PacketContainer.h> #include <Server_Common/Network/PacketContainer.h>
#include <Server_Common/Common.h>
#include <Server_Common/Database/DatabaseDef.h>
#include <set> #include <set>
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
#include <servers/Server_Common/Common.h>
#include "Player.h" #include "Player.h"
#include "src/servers/Server_Zone/Zone/ZoneMgr.h" #include "Zone/ZoneMgr.h"
#include "src/servers/Server_Zone/Zone/Zone.h" #include "Zone/Zone.h"
#include "src/servers/Server_Zone/ServerZone.h" #include "ServerZone.h"
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
#include "src/servers/Server_Zone/Network/GameConnection.h" #include "Network/GameConnection.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/InitUIPacket.h" #include "Network/PacketWrappers/InitUIPacket.h"
#include "src/servers/Server_Zone/StatusEffect/StatusEffectContainer.h" #include "Inventory/Inventory.h"
#include "src/servers/Server_Zone/Inventory/Inventory.h"
#include <Server_Common/Database/DatabaseDef.h>
extern Core::Logger g_log; extern Core::Logger g_log;
extern Core::ServerZone g_serverZone; extern Core::ServerZone g_serverZone;
@ -42,11 +39,11 @@ using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server; using namespace Core::Network::Packets::Server;
// load player from the db // load player from the db
bool Core::Entity::Player::load( uint32_t charId, Core::SessionPtr pSession ) bool Core::Entity::Player::load( uint32_t charId, SessionPtr pSession )
{ {
const std::string char_id_str = std::to_string( charId ); const std::string char_id_str = std::to_string( charId );
auto stmt = g_charaDb.getPreparedStatement( Core::Db::CharaDbStatements::CHARA_SEL ); auto stmt = g_charaDb.getPreparedStatement( Db::CharaDbStatements::CHARA_SEL );
stmt->setUInt( 1, charId ); stmt->setUInt( 1, charId );
auto res = g_charaDb.query( stmt ); auto res = g_charaDb.query( stmt );
@ -178,7 +175,8 @@ bool Core::Entity::Player::load( uint32_t charId, Core::SessionPtr pSession )
m_lastTickTime = 0; m_lastTickTime = 0;
auto pPlayer = getAsPlayer(); auto pPlayer = getAsPlayer();
m_pInventory = InventoryPtr( new Inventory( pPlayer ) ); // TODO: remove Inventory and actually inline it in Player class
m_pInventory = InventoryPtr( new Inventory( pPlayer.get() ) );
pPlayer->calculateStats(); pPlayer->calculateStats();
@ -211,8 +209,6 @@ bool Core::Entity::Player::load( uint32_t charId, Core::SessionPtr pSession )
initSpawnIdQueue(); initSpawnIdQueue();
m_pStatusEffectContainer = StatusEffect::StatusEffectContainerPtr( new StatusEffect::StatusEffectContainer( shared_from_this() ) );
if( !m_playerIdToSpawnIdMap.empty() ) if( !m_playerIdToSpawnIdMap.empty() )
m_playerIdToSpawnIdMap.clear(); m_playerIdToSpawnIdMap.clear();
@ -222,7 +218,7 @@ bool Core::Entity::Player::load( uint32_t charId, Core::SessionPtr pSession )
bool Core::Entity::Player::loadActiveQuests() bool Core::Entity::Player::loadActiveQuests()
{ {
auto stmt = g_charaDb.getPreparedStatement( Core::Db::CharaDbStatements::CHARA_QUEST_SEL ); auto stmt = g_charaDb.getPreparedStatement( Db::CharaDbStatements::CHARA_QUEST_SEL );
stmt->setUInt( 1, m_id ); stmt->setUInt( 1, m_id );
auto res = g_charaDb.query( stmt ); auto res = g_charaDb.query( stmt );
@ -259,7 +255,7 @@ bool Core::Entity::Player::loadClassData()
{ {
// ClassIdx, Exp, Lvl // ClassIdx, Exp, Lvl
auto stmt = g_charaDb.getPreparedStatement( Core::Db::CharaDbStatements::CHARA_CLASS_SEL ); auto stmt = g_charaDb.getPreparedStatement( Db::CharaDbStatements::CHARA_CLASS_SEL );
stmt->setUInt( 1, m_id ); stmt->setUInt( 1, m_id );
auto res = g_charaDb.query( stmt ); auto res = g_charaDb.query( stmt );
@ -278,7 +274,7 @@ bool Core::Entity::Player::loadClassData()
bool Core::Entity::Player::loadSearchInfo() bool Core::Entity::Player::loadSearchInfo()
{ {
auto stmt = g_charaDb.getPreparedStatement( Core::Db::CharaDbStatements::CHARA_SEARCHINFO_SEL ); auto stmt = g_charaDb.getPreparedStatement( Db::CharaDbStatements::CHARA_SEARCHINFO_SEL );
stmt->setUInt( 1, m_id ); stmt->setUInt( 1, m_id );
auto res = g_charaDb.query( stmt ); auto res = g_charaDb.query( stmt );
@ -306,7 +302,7 @@ void Core::Entity::Player::updateSql()
"EquippedMannequin 44, ConfigFlags 45, QuestCompleteFlags 46, OpeningSequence 47, " "EquippedMannequin 44, ConfigFlags 45, QuestCompleteFlags 46, OpeningSequence 47, "
"QuestTracking 48, GrandCompany 49, GrandCompanyRank 50, Discovery 51, GMRank 52, Unlocks 53, " "QuestTracking 48, GrandCompany 49, GrandCompanyRank 50, Discovery 51, GMRank 52, Unlocks 53, "
"CFPenaltyUntil 54"*/ "CFPenaltyUntil 54"*/
auto stmt = g_charaDb.getPreparedStatement( Core::Db::CharaDbStatements::CHARA_UP ); auto stmt = g_charaDb.getPreparedStatement( Db::CharaDbStatements::CHARA_UP );
stmt->setInt( 1, getHp() ); stmt->setInt( 1, getHp() );
stmt->setInt( 2, getMp() ); stmt->setInt( 2, getMp() );
@ -433,7 +429,7 @@ void Core::Entity::Player::updateDbClass() const
uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( getClass() )].exp_idx; uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( getClass() )].exp_idx;
//Exp = ?, Lvl = ? WHERE CharacterId = ? AND ClassIdx = ? //Exp = ?, Lvl = ? WHERE CharacterId = ? AND ClassIdx = ?
auto stmtS = g_charaDb.getPreparedStatement( Core::Db::CHARA_CLASS_UP ); auto stmtS = g_charaDb.getPreparedStatement( Db::CHARA_CLASS_UP );
stmtS->setInt( 1, getExp() ); stmtS->setInt( 1, getExp() );
stmtS->setInt( 2, getLevel() ); stmtS->setInt( 2, getLevel() );
stmtS->setInt( 3, m_id ); stmtS->setInt( 3, m_id );
@ -443,17 +439,17 @@ void Core::Entity::Player::updateDbClass() const
void Core::Entity::Player::updateDbSearchInfo() const void Core::Entity::Player::updateDbSearchInfo() const
{ {
auto stmtS = g_charaDb.getPreparedStatement( Core::Db::CHARA_SEARCHINFO_UP_SELECTCLASS ); auto stmtS = g_charaDb.getPreparedStatement( Db::CHARA_SEARCHINFO_UP_SELECTCLASS );
stmtS->setInt( 1, m_searchSelectClass ); stmtS->setInt( 1, m_searchSelectClass );
stmtS->setInt( 2, m_id ); stmtS->setInt( 2, m_id );
g_charaDb.execute( stmtS ); g_charaDb.execute( stmtS );
auto stmtS1 = g_charaDb.getPreparedStatement( Core::Db::CHARA_SEARCHINFO_UP_SELECTREGION ); auto stmtS1 = g_charaDb.getPreparedStatement( Db::CHARA_SEARCHINFO_UP_SELECTREGION );
stmtS1->setInt( 1, m_searchSelectRegion ); stmtS1->setInt( 1, m_searchSelectRegion );
stmtS1->setInt( 2, m_id ); stmtS1->setInt( 2, m_id );
g_charaDb.execute( stmtS1 ); g_charaDb.execute( stmtS1 );
auto stmtS2 = g_charaDb.getPreparedStatement( Core::Db::CHARA_SEARCHINFO_UP_SELECTREGION ); auto stmtS2 = g_charaDb.getPreparedStatement( Db::CHARA_SEARCHINFO_UP_SELECTREGION );
stmtS2->setString( 1, string( m_searchMessage != nullptr ? m_searchMessage : "" ) ); stmtS2->setString( 1, string( m_searchMessage != nullptr ? m_searchMessage : "" ) );
stmtS2->setInt( 2, m_id ); stmtS2->setInt( 2, m_id );
g_charaDb.execute( stmtS2 ); g_charaDb.execute( stmtS2 );
@ -467,7 +463,7 @@ void Core::Entity::Player::updateDbAllQuests() const
if( !m_activeQuests[i] ) if( !m_activeQuests[i] )
continue; continue;
auto stmtS3 = g_charaDb.getPreparedStatement( Core::Db::CHARA_QUEST_UP ); auto stmtS3 = g_charaDb.getPreparedStatement( Db::CHARA_QUEST_UP );
stmtS3->setInt( 1, m_activeQuests[i]->c.sequence ); stmtS3->setInt( 1, m_activeQuests[i]->c.sequence );
stmtS3->setInt( 2, m_activeQuests[i]->c.flags ); stmtS3->setInt( 2, m_activeQuests[i]->c.flags );
stmtS3->setInt( 3, m_activeQuests[i]->c.UI8A ); stmtS3->setInt( 3, m_activeQuests[i]->c.UI8A );
@ -486,7 +482,7 @@ void Core::Entity::Player::updateDbAllQuests() const
void Core::Entity::Player::deleteQuest( uint16_t questId ) const void Core::Entity::Player::deleteQuest( uint16_t questId ) const
{ {
auto stmt = g_charaDb.getPreparedStatement( Core::Db::CHARA_QUEST_DEL ); auto stmt = g_charaDb.getPreparedStatement( Db::CHARA_QUEST_DEL );
stmt->setInt( 1, m_id ); stmt->setInt( 1, m_id );
stmt->setInt( 2, questId ); stmt->setInt( 2, questId );
g_charaDb.execute( stmt ); g_charaDb.execute( stmt );
@ -494,7 +490,7 @@ void Core::Entity::Player::deleteQuest( uint16_t questId ) const
void Core::Entity::Player::insertQuest( uint16_t questId, uint8_t index, uint8_t seq ) const void Core::Entity::Player::insertQuest( uint16_t questId, uint8_t index, uint8_t seq ) const
{ {
auto stmt = g_charaDb.getPreparedStatement( Core::Db::CHARA_QUEST_INS ); auto stmt = g_charaDb.getPreparedStatement( Db::CHARA_QUEST_INS );
stmt->setInt( 1, m_id ); stmt->setInt( 1, m_id );
stmt->setInt( 2, index ); stmt->setInt( 2, index );
stmt->setInt( 3, questId ); stmt->setInt( 3, questId );

View file

@ -3,6 +3,7 @@ cmake_policy(SET CMP0015 NEW)
cmake_policy(SET CMP0014 OLD) cmake_policy(SET CMP0014 OLD)
project(Sapphire_Zone) project(Sapphire_Zone)
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
file(GLOB SERVER_PUBLIC_INCLUDE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} file(GLOB SERVER_PUBLIC_INCLUDE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
/*.h /*.h

View file

@ -1,23 +1,20 @@
#ifndef _GAMECOMMAND_H_ #ifndef _GAMECOMMAND_H_
#define _GAMECOMMAND_H_ #define _GAMECOMMAND_H_
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
namespace Core { namespace Core {
class DebugCommandHandler; class DebugCommandHandler;
// CGameCommand is used to define in game text command callbacks
// TODO it should probably be renamed to something more intuitive
// TODO the command identifier, currently '@' should probably be defined in here aswell so it is easily replaced
class DebugCommand class DebugCommand
{ {
public: public:
using pFunc = void ( DebugCommandHandler::* )( char *, Entity::PlayerPtr, boost::shared_ptr< DebugCommand > ); using pFunc = void ( DebugCommandHandler::* )( char *, Entity::Player&, boost::shared_ptr< DebugCommand > );
// String for the command // String for the command
std::string m_commandName; std::string m_commandName;

View file

@ -1,36 +1,36 @@
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <src/servers/Server_Common/Version.h> #include <Server_Common/Version.h>
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <src/servers/Server_Common/Network/CommonNetwork.h> #include <Server_Common/Network/CommonNetwork.h>
#include <src/servers/Server_Common/Util/UtilMath.h> #include <Server_Common/Util/UtilMath.h>
#include <src/servers/Server_Common/Network/PacketContainer.h> #include <Server_Common/Network/PacketContainer.h>
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include <src/servers/Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Database/DatabaseDef.h>
#include "DebugCommand.h" #include "DebugCommand.h"
#include "DebugCommandHandler.h" #include "DebugCommandHandler.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ServerNoticePacket.h" #include "Network/PacketWrappers/ServerNoticePacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket142.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/InitUIPacket.h" #include "Network/PacketWrappers/InitUIPacket.h"
#include "src/servers/Server_Zone/Network/GameConnection.h" #include "Network/GameConnection.h"
#include "src/servers/Server_Zone/Script/ScriptManager.h" #include "Script/ScriptManager.h"
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "src/servers/Server_Zone/Actor/BattleNpc.h" #include "Actor/BattleNpc.h"
#include "src/servers/Server_Zone/Zone/Zone.h" #include "Zone/Zone.h"
#include "src/servers/Server_Zone/ServerZone.h" #include "ServerZone.h"
#include "src/servers/Server_Zone/StatusEffect/StatusEffect.h" #include "StatusEffect/StatusEffect.h"
#include "src/servers/Server_Zone/Session.h" #include "Session.h"
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include <Server_Common/Database/DatabaseDef.h>
#include <cinttypes> #include <cinttypes>
@ -63,18 +63,18 @@ Core::DebugCommandHandler::~DebugCommandHandler()
} }
// add a command set to the register map // add a command set to the register map
void Core::DebugCommandHandler::registerCommand( const std::string& n, Core::DebugCommand::pFunc functionPtr, void Core::DebugCommandHandler::registerCommand( const std::string& n, DebugCommand::pFunc functionPtr,
const std::string& hText, uint8_t uLevel ) const std::string& hText, uint8_t uLevel )
{ {
m_commandMap[std::string( n )] = boost::make_shared<DebugCommand>( n, functionPtr, hText, uLevel ); m_commandMap[std::string( n )] = boost::make_shared< DebugCommand >( n, functionPtr, hText, uLevel );
} }
// try to retrieve the command in question, execute if found // try to retrieve the command in question, execute if found
void Core::DebugCommandHandler::execCommand( char * data, Core::Entity::PlayerPtr pPlayer ) void Core::DebugCommandHandler::execCommand( char * data, Entity::Player& player )
{ {
// define callback pointer // define callback pointer
void ( DebugCommandHandler::*pf )( char *, Entity::PlayerPtr, boost::shared_ptr< DebugCommand > ); void ( DebugCommandHandler::*pf )( char *, Entity::Player&, boost::shared_ptr< DebugCommand > );
std::string commandString; std::string commandString;
@ -94,18 +94,18 @@ void Core::DebugCommandHandler::execCommand( char * data, Core::Entity::PlayerPt
if( it == m_commandMap.end() ) if( it == m_commandMap.end() )
// no command found, do something... or not // no command found, do something... or not
pPlayer->sendUrgent( "Command not found." ); player.sendUrgent( "Command not found." );
else else
{ {
if( pPlayer->getGmRank() < it->second->getRequiredGmLevel() ) if( player.getGmRank() < it->second->getRequiredGmLevel() )
{ {
pPlayer->sendUrgent( "You are not allowed to use this command." ); player.sendUrgent( "You are not allowed to use this command." );
return; return;
} }
// command found, call the callback function and pass parameters if present. // command found, call the callback function and pass parameters if present.
pf = ( *it ).second->m_pFunc; pf = ( *it ).second->m_pFunc;
( this->*pf )( data, pPlayer, ( *it ).second ); ( this->*pf )( data, player, ( *it ).second );
return; return;
} }
@ -117,14 +117,14 @@ void Core::DebugCommandHandler::execCommand( char * data, Core::Entity::PlayerPt
// Definition of the commands // Definition of the commands
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////
void Core::DebugCommandHandler::scriptReload( char * data, Core::Entity::PlayerPtr pPlayer, void Core::DebugCommandHandler::scriptReload( char * data, Entity::Player& player,
boost::shared_ptr<Core::DebugCommand> command ) boost::shared_ptr< DebugCommand > command )
{ {
g_scriptMgr.reload(); g_scriptMgr.reload();
pPlayer->sendDebug( "Scripts reloaded." ); player.sendDebug( "Scripts reloaded." );
} }
void Core::DebugCommandHandler::help( char* data, Entity::PlayerPtr pPlayer, boost::shared_ptr< Core::DebugCommand > command ) void Core::DebugCommandHandler::help( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
{ {
pPlayer->sendDebug( "Registered debug commands:" ); pPlayer->sendDebug( "Registered debug commands:" );
for( auto cmd : m_commandMap ) for( auto cmd : m_commandMap )
@ -132,11 +132,12 @@ void Core::DebugCommandHandler::help( char* data, Entity::PlayerPtr pPlayer, boo
if( pPlayer->getGmRank() >= cmd.second->m_gmLevel ) if( pPlayer->getGmRank() >= cmd.second->m_gmLevel )
{ {
pPlayer->sendDebug( " - " + cmd.first + " - " + cmd.second->getHelpText() ); pPlayer->sendDebug( " - " + cmd.first + " - " + cmd.second->getHelpText() );
} }
} }
} }
void Core::DebugCommandHandler::set( char * data, Core::Entity::PlayerPtr pPlayer, boost::shared_ptr<Core::DebugCommand> command ) void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
{ {
std::string subCommand = ""; std::string subCommand = "";
std::string params = ""; std::string params = "";
@ -156,7 +157,7 @@ void Core::DebugCommandHandler::set( char * data, Core::Entity::PlayerPtr pPlaye
if( command->getName().length() + 1 + pos + 1 < strlen( data ) ) if( command->getName().length() + 1 + pos + 1 < strlen( data ) )
params = std::string( data + command->getName().length() + 1 + pos + 1 ); params = std::string( data + command->getName().length() + 1 + pos + 1 );
g_log.debug( "[" + std::to_string( pPlayer->getId() ) + "] " + g_log.debug( "[" + std::to_string( player.getId() ) + "] " +
"subCommand " + subCommand + " params: " + params ); "subCommand " + subCommand + " params: " + params );
@ -170,25 +171,25 @@ void Core::DebugCommandHandler::set( char * data, Core::Entity::PlayerPtr pPlaye
if( ( posX == 0xcccccccc ) || ( posY == 0xcccccccc ) || ( posZ == 0xcccccccc ) ) if( ( posX == 0xcccccccc ) || ( posY == 0xcccccccc ) || ( posZ == 0xcccccccc ) )
{ {
pPlayer->sendUrgent( "Syntaxerror." ); player.sendUrgent( "Syntaxerror." );
return; return;
} }
if( subCommand == "pos" ) if( subCommand == "pos" )
pPlayer->setPosition( static_cast< float >( posX ), player.setPosition( static_cast< float >( posX ),
static_cast< float >( posY ), static_cast< float >( posY ),
static_cast< float >( posZ ) ); static_cast< float >( posZ ) );
else else
pPlayer->setPosition( pPlayer->getPos().x + static_cast< float >( posX ), player.setPosition( player.getPos().x + static_cast< float >( posX ),
pPlayer->getPos().y + static_cast< float >( posY ), player.getPos().y + static_cast< float >( posY ),
pPlayer->getPos().z + static_cast< float >( posZ ) ); player.getPos().z + static_cast< float >( posZ ) );
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorSetPos > Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorSetPos >
setActorPosPacket( pPlayer->getId() ); setActorPosPacket( player.getId() );
setActorPosPacket.data().x = pPlayer->getPos().x; setActorPosPacket.data().x = player.getPos().x;
setActorPosPacket.data().y = pPlayer->getPos().y; setActorPosPacket.data().y = player.getPos().y;
setActorPosPacket.data().z = pPlayer->getPos().z; setActorPosPacket.data().z = player.getPos().z;
pPlayer->queuePacket( setActorPosPacket ); player.queuePacket( setActorPosPacket );
} }
else if( ( subCommand == "tele" ) && ( params != "" ) ) else if( ( subCommand == "tele" ) && ( params != "" ) )
@ -196,7 +197,7 @@ void Core::DebugCommandHandler::set( char * data, Core::Entity::PlayerPtr pPlaye
int32_t aetheryteId; int32_t aetheryteId;
sscanf( params.c_str(), "%i", &aetheryteId ); sscanf( params.c_str(), "%i", &aetheryteId );
pPlayer->teleport( aetheryteId ); player.teleport( aetheryteId );
} }
else if( ( subCommand == "discovery" ) && ( params != "" ) ) else if( ( subCommand == "discovery" ) && ( params != "" ) )
{ {
@ -204,10 +205,10 @@ void Core::DebugCommandHandler::set( char * data, Core::Entity::PlayerPtr pPlaye
int32_t discover_id; int32_t discover_id;
sscanf( params.c_str(), "%i %i", &map_id, &discover_id ); sscanf( params.c_str(), "%i %i", &map_id, &discover_id );
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcDiscovery > discoveryPacket( pPlayer->getId() ); Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcDiscovery > discoveryPacket( player.getId() );
discoveryPacket.data().map_id = map_id; discoveryPacket.data().map_id = map_id;
discoveryPacket.data().map_part_id = discover_id; discoveryPacket.data().map_part_id = discover_id;
pPlayer->queuePacket( discoveryPacket ); player.queuePacket( discoveryPacket );
} }
else if( ( subCommand == "discovery_pos" ) && ( params != "" ) ) else if( ( subCommand == "discovery_pos" ) && ( params != "" ) )
@ -231,8 +232,8 @@ void Core::DebugCommandHandler::set( char * data, Core::Entity::PlayerPtr pPlaye
else if( subCommand == "discovery_reset" ) else if( subCommand == "discovery_reset" )
{ {
pPlayer->resetDiscovery(); player.resetDiscovery();
pPlayer->queuePacket( Network::Packets::Server::InitUIPacket( pPlayer ) ); player.queuePacket( Network::Packets::Server::InitUIPacket( player ) );
} }
else if( subCommand == "classjob" ) else if( subCommand == "classjob" )
{ {
@ -240,28 +241,28 @@ void Core::DebugCommandHandler::set( char * data, Core::Entity::PlayerPtr pPlaye
sscanf( params.c_str(), "%d", &id ); sscanf( params.c_str(), "%d", &id );
if( pPlayer->getLevelForClass( static_cast<Core::Common::ClassJob> ( id ) ) == 0 ) if( player.getLevelForClass( static_cast< Common::ClassJob > ( id ) ) == 0 )
{ {
pPlayer->setLevelForClass( 1, static_cast<Core::Common::ClassJob> ( id ) ); player.setLevelForClass( 1, static_cast< Common::ClassJob > ( id ) );
pPlayer->setClassJob( static_cast<Core::Common::ClassJob> ( id ) ); player.setClassJob( static_cast< Common::ClassJob > ( id ) );
} }
else else
pPlayer->setClassJob( static_cast<Core::Common::ClassJob> ( id ) ); player.setClassJob( static_cast< Common::ClassJob > ( id ) );
} }
else if( subCommand == "cfpenalty" ) else if( subCommand == "cfpenalty" )
{ {
int32_t minutes; int32_t minutes;
sscanf( params.c_str(), "%d", &minutes ); sscanf( params.c_str(), "%d", &minutes );
pPlayer->setCFPenaltyMinutes( minutes ); player.setCFPenaltyMinutes( minutes );
} }
else if( subCommand == "eorzeatime" ) else if( subCommand == "eorzeatime" )
{ {
uint64_t timestamp; uint64_t timestamp;
sscanf( params.c_str(), "%" SCNu64, &timestamp ); sscanf( params.c_str(), "%" SCNu64, &timestamp );
pPlayer->setEorzeaTimeOffset( timestamp ); player.setEorzeaTimeOffset( timestamp );
pPlayer->sendNotice( "Eorzea time offset: " + std::to_string( timestamp ) ); player.sendNotice( "Eorzea time offset: " + std::to_string( timestamp ) );
} }
else if( subCommand == "model" ) else if( subCommand == "model" )
{ {
@ -269,26 +270,26 @@ void Core::DebugCommandHandler::set( char * data, Core::Entity::PlayerPtr pPlaye
uint32_t val; uint32_t val;
sscanf( params.c_str(), "%d %d", &slot, &val ); sscanf( params.c_str(), "%d %d", &slot, &val );
pPlayer->setModelForSlot( static_cast<Inventory::EquipSlot>( slot ), val ); player.setModelForSlot( static_cast< Inventory::EquipSlot >( slot ), val );
pPlayer->sendModel(); player.sendModel();
pPlayer->sendDebug( "Model updated" ); player.sendDebug( "Model updated" );
} }
else if( subCommand == "mount" ) else if( subCommand == "mount" )
{ {
int32_t id; int32_t id;
sscanf( params.c_str(), "%d", &id ); sscanf( params.c_str(), "%d", &id );
pPlayer->dismount(); player.dismount();
pPlayer->mount( id ); player.mount( id );
} }
else else
{ {
pPlayer->sendUrgent( subCommand + " is not a valid SET command." ); player.sendUrgent( subCommand + " is not a valid SET command." );
} }
} }
void Core::DebugCommandHandler::add( char * data, Core::Entity::PlayerPtr pPlayer, boost::shared_ptr<Core::DebugCommand> command ) void Core::DebugCommandHandler::add( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
{ {
std::string subCommand; std::string subCommand;
std::string params = ""; std::string params = "";
@ -311,7 +312,7 @@ void Core::DebugCommandHandler::add( char * data, Core::Entity::PlayerPtr pPlaye
if( command->getName().length() + 1 + pos + 1 < strlen( data ) ) if( command->getName().length() + 1 + pos + 1 < strlen( data ) )
params = std::string( data + command->getName().length() + 1 + pos + 1 ); params = std::string( data + command->getName().length() + 1 + pos + 1 );
g_log.debug( "[" + std::to_string( pPlayer->getId() ) + "] " + g_log.debug( "[" + std::to_string( player.getId() ) + "] " +
"subCommand " + subCommand + " params: " + params ); "subCommand " + subCommand + " params: " + params );
@ -323,18 +324,18 @@ void Core::DebugCommandHandler::add( char * data, Core::Entity::PlayerPtr pPlaye
sscanf( params.c_str(), "%d %d %hu", &id, &duration, &param ); sscanf( params.c_str(), "%d %d %hu", &id, &duration, &param );
StatusEffect::StatusEffectPtr effect( new StatusEffect::StatusEffect( id, pPlayer, pPlayer, duration, 3000 ) ); StatusEffect::StatusEffectPtr effect( new StatusEffect::StatusEffect( id, player.getAsPlayer(), player.getAsPlayer(), duration, 3000 ) );
effect->setParam( param ); effect->setParam( param );
pPlayer->addStatusEffect( effect ); player.addStatusEffect( effect );
} }
else if( subCommand == "title" ) else if( subCommand == "title" )
{ {
uint32_t titleId; uint32_t titleId;
sscanf( params.c_str(), "%u", &titleId ); sscanf( params.c_str(), "%u", &titleId );
pPlayer->addTitle( titleId ); player.addTitle( titleId );
pPlayer->sendNotice( "Added title (ID: " + std::to_string( titleId ) + ")" ); player.sendNotice( "Added title (ID: " + std::to_string( titleId ) + ")" );
} }
else if( subCommand == "spawn" ) else if( subCommand == "spawn" )
{ {
@ -342,9 +343,9 @@ void Core::DebugCommandHandler::add( char * data, Core::Entity::PlayerPtr pPlaye
sscanf( params.c_str(), "%d %d", &model, &name ); sscanf( params.c_str(), "%d %d", &model, &name );
Entity::BattleNpcPtr pBNpc( new Entity::BattleNpc( model, name, pPlayer->getPos() ) ); Entity::BattleNpcPtr pBNpc( new Entity::BattleNpc( model, name, player.getPos() ) );
auto pZone = pPlayer->getCurrentZone(); auto pZone = player.getCurrentZone();
pBNpc->setCurrentZone( pZone ); pBNpc->setCurrentZone( pZone );
pZone->pushActor( pBNpc ); pZone->pushActor( pBNpc );
@ -354,8 +355,8 @@ void Core::DebugCommandHandler::add( char * data, Core::Entity::PlayerPtr pPlaye
// temporary research packet // temporary research packet
int32_t opcode; int32_t opcode;
sscanf( params.c_str(), "%x", &opcode ); sscanf( params.c_str(), "%x", &opcode );
Network::Packets::GamePacketPtr pPe( new Network::Packets::GamePacket( opcode, 0x30, pPlayer->getId(), pPlayer->getId() ) ); Network::Packets::GamePacketPtr pPe( new Network::Packets::GamePacket( opcode, 0x30, player.getId(), player.getId() ) );
pPlayer->queuePacket( pPe ); player.queuePacket( pPe );
} }
else if( subCommand == "actrl" ) else if( subCommand == "actrl" )
{ {
@ -373,9 +374,9 @@ void Core::DebugCommandHandler::add( char * data, Core::Entity::PlayerPtr pPlaye
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 );
pPlayer->sendNotice( "Injecting ACTOR_CONTROL " + std::to_string( opcode ) ); player.sendNotice( "Injecting ACTOR_CONTROL " + std::to_string( opcode ) );
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorControl143 > actorControl( playerId, pPlayer->getId() ); Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorControl143 > actorControl( playerId, player.getId() );
actorControl.data().category = opcode; actorControl.data().category = opcode;
actorControl.data().param1 = param1; actorControl.data().param1 = param1;
actorControl.data().param2 = param2; actorControl.data().param2 = param2;
@ -383,18 +384,18 @@ void Core::DebugCommandHandler::add( char * data, Core::Entity::PlayerPtr pPlaye
actorControl.data().param4 = param4; actorControl.data().param4 = param4;
actorControl.data().param5 = param5; actorControl.data().param5 = param5;
actorControl.data().param6 = param6; actorControl.data().param6 = param6;
pPlayer->queuePacket( actorControl ); player.queuePacket( actorControl );
/*sscanf(params.c_str(), "%x %x %x %x %x %x %x", &opcode, &param1, &param2, &param3, &param4, &param5, &param6, &playerId); /*sscanf(params.c_str(), "%x %x %x %x %x %x %x", &opcode, &param1, &param2, &param3, &param4, &param5, &param6, &playerId);
Network::Packets::Server::ServerNoticePacket noticePacket(pPlayer, "Injecting ACTOR_CONTROL " + std::to_string(opcode)); Network::Packets::Server::ServerNoticePacket noticePacket( player, "Injecting ACTOR_CONTROL " + std::to_string( opcode ) );
pPlayer->queuePacket(noticePacket); player.queuePacket( noticePacket );
Network::Packets::Server::ActorControlPacket143 controlPacket(pPlayer, opcode, Network::Packets::Server::ActorControlPacket143 controlPacket( player, opcode,
param1, param2, param3, param4, param5, param6, playerId); param1, param2, param3, param4, param5, param6, playerId );
pPlayer->queuePacket(controlPacket);*/ player.queuePacket( controlPacket );*/
} }
else if( subCommand == "unlock" ) else if( subCommand == "unlock" )
@ -410,13 +411,13 @@ void Core::DebugCommandHandler::add( char * data, Core::Entity::PlayerPtr pPlaye
} }
else else
{ {
pPlayer->sendUrgent( subCommand + " is not a valid ADD command." ); player.sendUrgent( subCommand + " is not a valid ADD command." );
} }
} }
void Core::DebugCommandHandler::get( char * data, Core::Entity::PlayerPtr pPlayer, boost::shared_ptr<Core::DebugCommand> command ) void Core::DebugCommandHandler::get( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
{ {
std::string subCommand; std::string subCommand;
std::string params = ""; std::string params = "";
@ -436,45 +437,45 @@ void Core::DebugCommandHandler::get( char * data, Core::Entity::PlayerPtr pPlaye
if( command->getName().length() + 1 + pos + 1 < strlen( data ) ) if( command->getName().length() + 1 + pos + 1 < strlen( data ) )
params = std::string( data + command->getName().length() + 1 + pos + 1 ); params = std::string( data + command->getName().length() + 1 + pos + 1 );
g_log.debug( "[" + std::to_string( pPlayer->getId() ) + "] " + g_log.debug( "[" + std::to_string( player.getId() ) + "] " +
"subCommand " + subCommand + " params: " + params ); "subCommand " + subCommand + " params: " + params );
if( subCommand == "pos" ) if( subCommand == "pos" )
{ {
int16_t map_id = g_exdData.m_zoneInfoMap[pPlayer->getCurrentZone()->getId()].map_id; int16_t map_id = g_exdData.m_zoneInfoMap[player.getCurrentZone()->getId()].map_id;
pPlayer->sendNotice( "Pos:\n" + player.sendNotice( "Pos:\n" +
std::to_string( pPlayer->getPos().x ) + "\n" + std::to_string( player.getPos().x ) + "\n" +
std::to_string( pPlayer->getPos().y ) + "\n" + std::to_string( player.getPos().y ) + "\n" +
std::to_string( pPlayer->getPos().z ) + "\n" + std::to_string( player.getPos().z ) + "\n" +
std::to_string( pPlayer->getRotation() ) + "\nMapId: " + std::to_string( player.getRotation() ) + "\nMapId: " +
std::to_string( map_id ) + "\nZoneID: " + std::to_string( map_id ) + "\nZoneID: " +
std::to_string( pPlayer->getCurrentZone()->getId() ) + "\n" ); std::to_string( player.getCurrentZone()->getId() ) + "\n" );
} }
else else
{ {
pPlayer->sendUrgent( subCommand + " is not a valid GET command." ); player.sendUrgent( subCommand + " is not a valid GET command." );
} }
} }
void Core::DebugCommandHandler::injectPacket( char * data, Core::Entity::PlayerPtr pPlayer, boost::shared_ptr< Core::DebugCommand > command ) void Core::DebugCommandHandler::injectPacket( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
{ {
auto pSession = g_serverZone.getSession( pPlayer->getId() ); auto pSession = g_serverZone.getSession( player.getId() );
if( pSession ) if( pSession )
pSession->getZoneConnection()->injectPacket( data + 7, pPlayer ); pSession->getZoneConnection()->injectPacket( data + 7, player );
} }
void Core::DebugCommandHandler::injectChatPacket( char * data, Core::Entity::PlayerPtr pPlayer, boost::shared_ptr< Core::DebugCommand > command ) void Core::DebugCommandHandler::injectChatPacket( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
{ {
auto pSession = g_serverZone.getSession( pPlayer->getId() ); auto pSession = g_serverZone.getSession( player.getId() );
if( pSession ) if( pSession )
pSession->getChatConnection()->injectPacket( data + 8, pPlayer ); pSession->getChatConnection()->injectPacket( data + 8, player );
} }
void Core::DebugCommandHandler::nudge( char * data, Entity::PlayerPtr pPlayer, boost::shared_ptr<DebugCommand> command ) void Core::DebugCommandHandler::nudge( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
{ {
std::string subCommand; std::string subCommand;
@ -483,7 +484,7 @@ void Core::DebugCommandHandler::nudge( char * data, Entity::PlayerPtr pPlayer, b
std::size_t spos = tmpCommand.find_first_of( " " ); std::size_t spos = tmpCommand.find_first_of( " " );
auto& pos = pPlayer->getPos(); auto& pos = player.getPos();
int32_t offset = 0; int32_t offset = 0;
char direction[20]; char direction[20];
@ -491,45 +492,44 @@ void Core::DebugCommandHandler::nudge( char * data, Entity::PlayerPtr pPlayer, b
sscanf( tmpCommand.c_str(), "%d %s", &offset, direction ); sscanf( tmpCommand.c_str(), "%d %s", &offset, direction );
if( direction[0] == 'u' || direction[0] == '+' ) if( direction[0] == 'u' || direction[0] == '+' )
{ {
pos.y += offset; pos.y += offset;
pPlayer->sendNotice( "nudge: Placing up " + std::to_string( offset ) + " yalms" ); player.sendNotice( "nudge: Placing up " + std::to_string( offset ) + " yalms" );
} }
else if( direction[0] == 'd' || direction[0] == '-' ) else if( direction[0] == 'd' || direction[0] == '-' )
{ {
pos.y -= offset; pos.y -= offset;
pPlayer->sendNotice( "nudge: Placing down " + std::to_string( offset ) + " yalms" ); player.sendNotice( "nudge: Placing down " + std::to_string( offset ) + " yalms" );
} }
else else
{ {
float angle = pPlayer->getRotation() + ( PI / 2 ); float angle = player.getRotation() + ( PI / 2 );
pos.x -= offset * cos( angle ); pos.x -= offset * cos( angle );
pos.z += offset * sin( angle ); pos.z += offset * sin( angle );
pPlayer->sendNotice( "nudge: Placing forward " + std::to_string( offset ) + " yalms" ); player.sendNotice( "nudge: Placing forward " + std::to_string( offset ) + " yalms" );
} }
if( offset != 0 ) if( offset != 0 )
{ {
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorSetPos > Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorSetPos >
setActorPosPacket( pPlayer->getId() ); setActorPosPacket( player.getId() );
setActorPosPacket.data().x = pPlayer->getPos().x; setActorPosPacket.data().x = player.getPos().x;
setActorPosPacket.data().y = pPlayer->getPos().y; setActorPosPacket.data().y = player.getPos().y;
setActorPosPacket.data().z = pPlayer->getPos().z; setActorPosPacket.data().z = player.getPos().z;
setActorPosPacket.data().r16 = Math::Util::floatToUInt16Rot( pPlayer->getRotation() ); setActorPosPacket.data().r16 = Math::Util::floatToUInt16Rot( player.getRotation() );
pPlayer->queuePacket( setActorPosPacket ); player.queuePacket( setActorPosPacket );
} }
} }
void Core::DebugCommandHandler::serverInfo( char * data, Core::Entity::PlayerPtr pPlayer, boost::shared_ptr< Core::DebugCommand > command ) void Core::DebugCommandHandler::serverInfo( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
{ {
pPlayer->sendDebug( "SapphireServer " + Version::VERSION + "\nRev: " + Version::GIT_HASH ); player.sendDebug( "SapphireServer " + Version::VERSION + "\nRev: " + Version::GIT_HASH );
pPlayer->sendDebug( "Compiled: " __DATE__ " " __TIME__ ); player.sendDebug( "Compiled: " __DATE__ " " __TIME__ );
pPlayer->sendDebug( "Sessions: " + std::to_string( g_serverZone.getSessionCount() ) ); player.sendDebug( "Sessions: " + std::to_string( g_serverZone.getSessionCount() ) );
} }
void Core::DebugCommandHandler::unlockCharacter( char* data, Entity::PlayerPtr pPlayer, boost::shared_ptr< Core::DebugCommand > command ) void Core::DebugCommandHandler::unlockCharacter( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
{ {
pPlayer->unlock(); pPlayer->unlock();
} }

View file

@ -4,8 +4,8 @@
#include <map> #include <map>
#include "DebugCommand.h" #include "DebugCommand.h"
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
namespace Core { namespace Core {
@ -15,7 +15,7 @@ class DebugCommandHandler
{ {
private: private:
// container mapping command string to command object // container mapping command string to command object
std::map<std::string, boost::shared_ptr<DebugCommand> > m_commandMap; std::map< std::string, boost::shared_ptr< DebugCommand > > m_commandMap;
public: public:
DebugCommandHandler(); DebugCommandHandler();
@ -25,25 +25,25 @@ public:
void registerCommand( const std::string& n, DebugCommand::pFunc, const std::string& hText, uint8_t uLevel ); void registerCommand( const std::string& n, DebugCommand::pFunc, const std::string& hText, uint8_t uLevel );
// execute command if registered // execute command if registered
void execCommand( char * data, Entity::PlayerPtr pPlayer ); void execCommand( char * data, Entity::Player& player );
// help command // help command
void help( char* data, Entity::PlayerPtr pPlayer, boost::shared_ptr<DebugCommand> command ); void help( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
// command handler callbacks // command handler callbacks
void set( char * data, Entity::PlayerPtr pPlayer, boost::shared_ptr<DebugCommand> command ); void set( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void get( char * data, Entity::PlayerPtr pPlayer, boost::shared_ptr<DebugCommand> command ); void get( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void add( char * data, Entity::PlayerPtr pPlayer, boost::shared_ptr<DebugCommand> command ); void add( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
//void debug( char * data, Entity::PlayerPtr pPlayer, boost::shared_ptr<DebugCommand> command ); //void debug( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void scriptReload( char * data, Entity::PlayerPtr pPlayer, boost::shared_ptr<DebugCommand> command ); void scriptReload( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void injectPacket( char * data, Entity::PlayerPtr pPlayer, boost::shared_ptr<DebugCommand> command ); void injectPacket( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void injectChatPacket( char * data, Entity::PlayerPtr pPlayer, boost::shared_ptr<DebugCommand> command ); void injectChatPacket( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void nudge( char* data, Entity::PlayerPtr pPlayer, boost::shared_ptr<DebugCommand> command ); void nudge( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void serverInfo( char * data, Entity::PlayerPtr pPlayer, boost::shared_ptr<DebugCommand> command ); void serverInfo( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void unlockCharacter( char* data, Entity::PlayerPtr pPlayer, boost::shared_ptr<DebugCommand> command ); void unlockCharacter( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
void targetInfo( char* data, Entity::PlayerPtr pPlayer, boost::shared_ptr<DebugCommand> command ); void targetInfo( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command );
}; };

View file

@ -56,7 +56,7 @@ Core::Scripting::EventReturnCallback Core::Event::Event::getEventReturnCallback(
return m_callback; return m_callback;
} }
void Core::Event::Event::setEventReturnCallback( Core::Scripting::EventReturnCallback callback ) void Core::Event::Event::setEventReturnCallback( Scripting::EventReturnCallback callback )
{ {
m_callback = callback; m_callback = callback;
} }

View file

@ -1,8 +1,7 @@
#include "EventHelper.h" #include "EventHelper.h"
#include "Event.h" #include "Event.h"
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <Server_Common/Exd/ExdData.h>
#include <src/servers/Server_Common/Exd/ExdData.h>
extern Core::Data::ExdData g_exdData; extern Core::Data::ExdData g_exdData;

View file

@ -1,21 +1,22 @@
#include <src/servers/Server_Common/Network/PacketDef/Zone/ServerZoneDef.h> #include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <src/servers/Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include "Inventory.h" #include "Inventory.h"
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "ItemContainer.h" #include "ItemContainer.h"
#include "Item.h" #include "Item.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ServerNoticePacket.h" #include "Network/PacketWrappers/ServerNoticePacket.h"
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <boost/algorithm/clamp.hpp>
#include "src/servers/Server_Zone/Forwards.h" #include "../Forwards.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include <Server_Common/Database/DatabaseDef.h> #include <Server_Common/Database/DatabaseDef.h>
@ -27,7 +28,7 @@ using namespace Core::Network;
using namespace Core::Network::Packets; using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server; using namespace Core::Network::Packets::Server;
Core::Inventory::Inventory( Core::Entity::PlayerPtr pOwner ) Core::Inventory::Inventory( Core::Entity::Player* pOwner )
{ {
m_pOwner = pOwner; m_pOwner = pOwner;
@ -438,6 +439,30 @@ bool Core::Inventory::removeCrystal( CrystalType type, uint32_t amount )
return true; return true;
} }
bool Core::Inventory::isOneHandedWeapon( ItemUICategory weaponCategory )
{
switch ( weaponCategory )
{
case ItemUICategory::AlchemistsPrimaryTool:
case ItemUICategory::ArmorersPrimaryTool:
case ItemUICategory::BotanistsPrimaryTool:
case ItemUICategory::CulinariansPrimaryTool:
case ItemUICategory::OnehandedConjurersArm:
case ItemUICategory::CarpentersPrimaryTool:
case ItemUICategory::FishersPrimaryTool:
case ItemUICategory::GladiatorsArm:
case ItemUICategory::GoldsmithsPrimaryTool:
case ItemUICategory::LeatherworkersPrimaryTool:
case ItemUICategory::MinersPrimaryTool:
case ItemUICategory::OnehandedThaumaturgesArm:
case ItemUICategory::WeaversPrimaryTool:
case ItemUICategory::BlacksmithsPrimaryTool:
return true;
default:
return false;
}
}
bool Core::Inventory::isObtainable( uint32_t catalogId, uint8_t quantity ) bool Core::Inventory::isObtainable( uint32_t catalogId, uint8_t quantity )
{ {
@ -450,7 +475,8 @@ int16_t Core::Inventory::addItem( uint16_t inventoryId, int8_t slotId, uint32_t
auto itemInfo = g_exdData.getItemInfo( catalogId ); auto itemInfo = g_exdData.getItemInfo( catalogId );
if( !itemInfo ) // if item data doesn't exist or it's a blank field
if( !itemInfo || itemInfo->item_level == 0 )
{ {
return -1; return -1;
} }
@ -828,6 +854,40 @@ void Core::Inventory::send()
} }
uint16_t Core::Inventory::calculateEquippedGearItemLevel()
{
uint32_t iLvlResult = 0;
auto gearSetMap = m_inventoryMap[GearSet0]->getItemMap();
auto it = gearSetMap.begin();
while ( it != gearSetMap.end() )
{
auto currItem = it->second;
if ( currItem )
{
iLvlResult += currItem->getItemLevel();
// If item is weapon and isn't one-handed
if ( currItem->isWeapon() && !isOneHandedWeapon( currItem->getCategory() ) )
{
iLvlResult += currItem->getItemLevel();
}
else
{
g_log.debug( "Is one handed" );
}
}
it++;
}
return boost::algorithm::clamp( iLvlResult / 13, 0, 9999 );
}
uint8_t Core::Inventory::getFreeSlotsInBags() uint8_t Core::Inventory::getFreeSlotsInBags()
{ {
uint8_t slots = 0; uint8_t slots = 0;

View file

@ -1,8 +1,8 @@
#ifndef INVENTORY_H_ #ifndef INVENTORY_H_
#define INVENTORY_H_ #define INVENTORY_H_
#include <map> #include <map>
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include "src/servers/Server_Zone/Forwards.h" #include "../Forwards.h"
namespace Core namespace Core
{ {
@ -13,7 +13,7 @@ using InventoryMap = std::map< uint16_t, ItemContainerPtr >;
class Inventory class Inventory
{ {
public: public:
Inventory( Entity::PlayerPtr pOwner ); Inventory( Entity::Player* pOwner );
~Inventory(); ~Inventory();
enum ContainerType : uint16_t enum ContainerType : uint16_t
@ -153,6 +153,10 @@ public:
bool updateContainer( uint16_t containerId, uint8_t slotId, ItemPtr pItem ); bool updateContainer( uint16_t containerId, uint8_t slotId, ItemPtr pItem );
/*! heck if weapon category qualifies the weapon as onehanded */
bool isOneHandedWeapon( Common::ItemUICategory weaponCategory );
/*! calculate and return player ilvl based off equipped gear */
uint16_t calculateEquippedGearItemLevel();
/*! return the current amount of currency of type */ /*! return the current amount of currency of type */
uint32_t getCurrency( CurrencyType type ); uint32_t getCurrency( CurrencyType type );
/*! add amount to the current of type */ /*! add amount to the current of type */
@ -191,7 +195,7 @@ public:
private: private:
Entity::PlayerPtr m_pOwner; Entity::Player* m_pOwner;
InventoryMap m_inventoryMap; InventoryMap m_inventoryMap;
}; };

View file

@ -1,5 +1,5 @@
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <src/servers/Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include "Item.h" #include "Item.h"
extern Core::Data::ExdData g_exdData; extern Core::Data::ExdData g_exdData;
@ -30,6 +30,7 @@ Core::Item::Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t mo
m_magicalDmg = itemInfo->magical_damage; m_magicalDmg = itemInfo->magical_damage;
m_weaponDmg = ( m_physicalDmg != 0 ) ? m_physicalDmg : m_magicalDmg; m_weaponDmg = ( m_physicalDmg != 0 ) ? m_physicalDmg : m_magicalDmg;
m_autoAttackDmg = static_cast< float >( m_weaponDmg * m_delayMs ) / 3000; m_autoAttackDmg = static_cast< float >( m_weaponDmg * m_delayMs ) / 3000;
m_itemLevel = itemInfo->item_level;
} }
Core::Item::~Item() Core::Item::~Item()
@ -57,11 +58,21 @@ uint16_t Core::Item::getMagicalDmg() const
return m_magicalDmg; return m_magicalDmg;
} }
uint16_t Core::Item::getItemLevel() const
{
return m_itemLevel;
}
uint16_t Core::Item::getWeaponDmg() const uint16_t Core::Item::getWeaponDmg() const
{ {
return m_weaponDmg; return m_weaponDmg;
} }
bool Core::Item::isWeapon() const
{
return (m_weaponDmg != 0);
}
uint32_t Core::Item::getId() const uint32_t Core::Item::getId() const
{ {
return m_id; return m_id;

View file

@ -1,7 +1,7 @@
#ifndef _ITEM_H_ #ifndef _ITEM_H_
#define _ITEM_H_ #define _ITEM_H_
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
namespace Core { namespace Core {
@ -48,8 +48,12 @@ public:
uint16_t getWeaponDmg() const; uint16_t getWeaponDmg() const;
bool isWeapon() const;
float getAutoAttackDmg() const; float getAutoAttackDmg() const;
uint16_t getItemLevel() const;
protected: protected:
uint32_t m_id; uint32_t m_id;
@ -71,6 +75,7 @@ protected:
uint16_t m_magicalDmg; uint16_t m_magicalDmg;
uint16_t m_weaponDmg; uint16_t m_weaponDmg;
float m_autoAttackDmg; float m_autoAttackDmg;
uint16_t m_itemLevel;
}; };

View file

@ -1,14 +1,14 @@
#include "src/servers/Server_Zone/Forwards.h" #include "../Forwards.h"
#include "ItemContainer.h" #include "ItemContainer.h"
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include <Server_Common/Database/DatabaseDef.h>
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "Item.h" #include "Item.h"
#include <Server_Common/Database/DatabaseDef.h>
extern Core::Logger g_log; extern Core::Logger g_log;
@ -86,7 +86,7 @@ Core::ItemPtr Core::ItemContainer::getItem( uint8_t slotId )
return m_itemMap[slotId]; return m_itemMap[slotId];
} }
void Core::ItemContainer::setItem( uint8_t slotId, Core::ItemPtr pItem ) void Core::ItemContainer::setItem( uint8_t slotId, ItemPtr pItem )
{ {
if( ( slotId > m_size ) ) if( ( slotId > m_size ) )
return; return;

View file

@ -1,10 +1,9 @@
#pragma once
#ifndef _ITEMCONTAINER_H_ #ifndef _ITEMCONTAINER_H_
#define _ITEMCONTAINER_H_ #define _ITEMCONTAINER_H_
#include <map> #include <map>
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include "../Forwards.h" #include "../Forwards.h"
@ -17,7 +16,7 @@ namespace Core
{ {
public: public:
ItemContainer(uint16_t locationId); ItemContainer( uint16_t locationId );
~ItemContainer(); ~ItemContainer();
uint16_t getId() const; uint16_t getId() const;
@ -30,9 +29,9 @@ namespace Core
const ItemMap& getItemMap() const; const ItemMap& getItemMap() const;
ItemPtr getItem(uint8_t slotId); ItemPtr getItem( uint8_t slotId );
void setItem(uint8_t slotId, ItemPtr item); void setItem( uint8_t slotId, ItemPtr item );
int16_t getFreeSlot(); int16_t getFreeSlot();

View file

@ -2,9 +2,8 @@
#include <Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Common.h> #include <Server_Common/Common.h>
#include <Server_Zone/Actor/Actor.h> #include "Actor/Actor.h"
#include <Server_Zone/Actor/Player.h> #include "Actor/Player.h"
#include "CalcBattle.h" #include "CalcBattle.h"

View file

@ -2,7 +2,7 @@
#define _CALCBATTLE_H #define _CALCBATTLE_H
#include <Server_Common/Common.h> #include <Server_Common/Common.h>
#include <Server_Zone/Actor/Actor.h> #include "Actor/Actor.h"
using namespace Core::Entity; using namespace Core::Entity;

View file

@ -2,8 +2,8 @@
#include <Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <Server_Common/Common.h> #include <Server_Common/Common.h>
#include <Server_Zone/Actor/Actor.h> #include "Actor/Actor.h"
#include <Server_Zone/Actor/Player.h> #include "Actor/Player.h"
#include "CalcStats.h" #include "CalcStats.h"

View file

@ -2,7 +2,7 @@
#define _CALCSTATS_H #define _CALCSTATS_H
#include <Server_Common/Common.h> #include <Server_Common/Common.h>
#include <Server_Zone/Actor/Actor.h> #include "Actor/Actor.h"
using namespace Core::Entity; using namespace Core::Entity;

View file

@ -1,20 +1,20 @@
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <src/servers/Server_Common/Network/CommonNetwork.h> #include <Server_Common/Network/CommonNetwork.h>
#include <src/servers/Server_Common/Util/Util.h> #include <Server_Common/Util/Util.h>
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include <src/servers/Server_Common/Network/PacketContainer.h> #include <Server_Common/Network/PacketContainer.h>
#include <src/servers/Server_Common/Network/GamePacketParser.h> #include <Server_Common/Network/GamePacketParser.h>
#include <boost/format.hpp> #include <boost/format.hpp>
#include "GameConnection.h" #include "GameConnection.h"
#include "src/servers/Server_Zone/ServerZone.h" #include "ServerZone.h"
#include "src/servers/Server_Zone/Session.h" #include "Session.h"
#include "src/servers/Server_Zone/Zone/Zone.h" #include "Zone/Zone.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/InitUIPacket.h" #include "Network/PacketWrappers/InitUIPacket.h"
#include "src/servers/Server_Zone/DebugCommand/DebugCommandHandler.h" #include "DebugCommand/DebugCommandHandler.h"
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
extern Core::DebugCommandHandler g_gameCommandMgr; extern Core::DebugCommandHandler g_gameCommandMgr;
extern Core::Logger g_log; extern Core::Logger g_log;
@ -133,8 +133,7 @@ void Core::Network::GameConnection::OnRecv( std::vector< uint8_t > & buffer )
Disconnect(); Disconnect();
return; return;
} }
else if( headerResult == Malformed )
if( headerResult == Malformed )
{ {
g_log.info( "Dropping connection due to malformed packet header." ); g_log.info( "Dropping connection due to malformed packet header." );
Disconnect(); Disconnect();
@ -153,8 +152,7 @@ void Core::Network::GameConnection::OnRecv( std::vector< uint8_t > & buffer )
Disconnect(); Disconnect();
return; return;
} }
else if( packetResult == Malformed )
if (packetResult == Malformed)
{ {
g_log.info( "Dropping connection due to malformed packets." ); g_log.info( "Dropping connection due to malformed packets." );
Disconnect(); Disconnect();
@ -198,7 +196,7 @@ void Core::Network::GameConnection::handleZonePacket( const Packets::GamePacket&
boost::str( boost::format( "%|04X|" ) % boost::str( boost::format( "%|04X|" ) %
static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) + " )" ); static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) + " )" );
( this->*( it->second ) )( pPacket, m_pSession->getPlayer() ); ( this->*( it->second ) )( pPacket, *m_pSession->getPlayer() );
} }
else else
{ {
@ -226,7 +224,7 @@ void Core::Network::GameConnection::handleChatPacket( const Packets::GamePacket&
boost::str( boost::format( "%|04X|" ) % boost::str( boost::format( "%|04X|" ) %
static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) + " )" ); static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) + " )" );
( this->*( it->second ) )( pPacket, m_pSession->getPlayer() ); ( this->*( it->second ) )( pPacket, *m_pSession->getPlayer() );
} }
else else
{ {
@ -309,7 +307,7 @@ void Core::Network::GameConnection::sendSinglePacket( Packets::GamePacket* pPack
sendPackets( &pRP ); sendPackets( &pRP );
} }
void Core::Network::GameConnection::injectPacket( const std::string& packetpath, Core::Entity::PlayerPtr pPlayer ) void Core::Network::GameConnection::injectPacket( const std::string& packetpath, Core::Entity::Player& pPlayer )
{ {
char packet[0x11570]; char packet[0x11570];
@ -338,7 +336,7 @@ void Core::Network::GameConnection::injectPacket( const std::string& packetpath,
// cycle through the packet entries and queue each one // cycle through the packet entries and queue each one
for( int32_t k = 0x18; k < size; ) for( int32_t k = 0x18; k < size; )
{ {
uint32_t tmpId = pPlayer->getId(); uint32_t tmpId = pPlayer.getId();
// replace ids in the entryheader if needed // replace ids in the entryheader if needed
if( !memcmp( packet + k + 0x04, packet + k + 0x08, 4 ) ) if( !memcmp( packet + k + 0x04, packet + k + 0x08, 4 ) )
{ {

View file

@ -1,18 +1,15 @@
#ifndef GAMECONNECTION_H #ifndef GAMECONNECTION_H
#define GAMECONNECTION_H #define GAMECONNECTION_H
#include <src/servers/Server_Common/Network/Connection.h> #include <Server_Common/Network/Connection.h>
#include <src/servers/Server_Common/Network/Acceptor.h> #include <Server_Common/Network/Acceptor.h>
#include <src/servers/Server_Common/Network/CommonNetwork.h> #include <Server_Common/Network/CommonNetwork.h>
#include <Server_Common/Network/GamePacket.h>
#include <Server_Common/Util/LockedQueue.h>
#include <src/servers/Server_Common/Network/GamePacket.h> #include "Forwards.h"
#include <src/servers/Server_Common/Util/LockedQueue.h> #define DECLARE_HANDLER( x ) void x( const Packets::GamePacket& inPacket, Entity::Player& player )
#include "src/servers/Server_Zone/Forwards.h"
#define DECLARE_HANDLER( x ) void x( const Packets::GamePacket& inPacket, Entity::PlayerPtr pPlayer )
namespace Core { namespace Core {
namespace Network { namespace Network {
@ -29,18 +26,18 @@ class GameConnection : public Connection
{ {
private: private:
typedef void ( GameConnection::* Handler )( const Packets::GamePacket& inPacket, Entity::PlayerPtr pPlayer ); typedef void ( GameConnection::* Handler )( const Packets::GamePacket& inPacket, Entity::Player& player );
using HandlerMap = std::map< uint16_t, Handler >; using HandlerMap = std::map< uint16_t, Handler >;
using HandlerStrMap = std::map< uint16_t, std::string >; using HandlerStrMap = std::map< uint16_t, std::string >;
AcceptorPtr m_pAcceptor; AcceptorPtr m_pAcceptor;
// handler for game packets (main type 0x03, connection type 1) // handler for game packets ( main type 0x03, connection type 1 )
HandlerMap m_zoneHandlerMap; HandlerMap m_zoneHandlerMap;
HandlerStrMap m_zoneHandlerStrMap; HandlerStrMap m_zoneHandlerStrMap;
// handler for game packets (main type 0x03, connection type 2) // handler for game packets ( main type 0x03, connection type 2 )
HandlerMap m_chatHandlerMap; HandlerMap m_chatHandlerMap;
HandlerStrMap m_chatHandlerStrMap; HandlerStrMap m_chatHandlerStrMap;
@ -80,11 +77,11 @@ public:
void handleChatPacket( const Packets::GamePacket& pPacket ); void handleChatPacket( const Packets::GamePacket& pPacket );
void sendPackets( Packets::PacketContainer * pPacket ); void sendPackets( Packets::PacketContainer* pPacket );
void sendSinglePacket( Packets::GamePacket * pPacket ); void sendSinglePacket( Packets::GamePacket* pPacket );
void injectPacket( const std::string& packetpath, Entity::PlayerPtr pPlayer ); void injectPacket( const std::string& packetpath, Entity::Player& player );
DECLARE_HANDLER( initHandler ); DECLARE_HANDLER( initHandler );
DECLARE_HANDLER( finishLoadingHandler ); DECLARE_HANDLER( finishLoadingHandler );

View file

@ -1,39 +1,39 @@
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <src/servers/Server_Common/Network/CommonNetwork.h> #include <Server_Common/Network/CommonNetwork.h>
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include <src/servers/Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <src/servers/Server_Common/Network/PacketContainer.h> #include <Server_Common/Network/PacketContainer.h>
#include <boost/format.hpp> #include <boost/format.hpp>
#include "src/servers/Server_Zone/Network/GameConnection.h" #include "Network/GameConnection.h"
#include "src/servers/Server_Zone/Session.h" #include "Session.h"
#include "src/servers/Server_Zone/Zone/Zone.h" #include "Zone/Zone.h"
#include "src/servers/Server_Zone/Zone/ZonePosition.h" #include "Zone/ZonePosition.h"
#include "src/servers/Server_Zone/ServerZone.h" #include "ServerZone.h"
#include "src/servers/Server_Zone/Zone/ZoneMgr.h" #include "Zone/ZoneMgr.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/InitUIPacket.h" #include "Network/PacketWrappers/InitUIPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/PingPacket.h" #include "Network/PacketWrappers/PingPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/MoveActorPacket.h" #include "Network/PacketWrappers/MoveActorPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ChatPacket.h" #include "Network/PacketWrappers/ChatPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ServerNoticePacket.h" #include "Network/PacketWrappers/ServerNoticePacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket142.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket144.h" #include "Network/PacketWrappers/ActorControlPacket144.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/EventStartPacket.h" #include "Network/PacketWrappers/EventStartPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/EventFinishPacket.h" #include "Network/PacketWrappers/EventFinishPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/PlayerStateFlagsPacket.h" #include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
#include "src/servers/Server_Zone/DebugCommand/DebugCommandHandler.h" #include "DebugCommand/DebugCommandHandler.h"
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "src/servers/Server_Zone/Inventory/Inventory.h" #include "Inventory/Inventory.h"
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
#include "src/servers/Server_Zone/Event/EventHelper.h" #include "Event/EventHelper.h"
#include "src/servers/Server_Zone/Action/Action.h" #include "Action/Action.h"
#include "src/servers/Server_Zone/Action/ActionTeleport.h" #include "Action/ActionTeleport.h"
extern Core::Logger g_log; extern Core::Logger g_log;
extern Core::ServerZone g_serverZone; extern Core::ServerZone g_serverZone;
@ -46,7 +46,7 @@ using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server; using namespace Core::Network::Packets::Server;
void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
uint16_t commandId = inPacket.getValAt< uint16_t >( 0x20 ); uint16_t commandId = inPacket.getValAt< uint16_t >( 0x20 );
uint64_t param1 = inPacket.getValAt< uint64_t >( 0x24 ); uint64_t param1 = inPacket.getValAt< uint64_t >( 0x24 );
@ -70,14 +70,14 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
case 0x01: // Toggle sheathe case 0x01: // Toggle sheathe
{ {
if ( param11 == 1 ) if ( param11 == 1 )
pPlayer->setStance( Entity::Actor::Stance::Active ); player.setStance( Entity::Actor::Stance::Active );
else else
{ {
pPlayer->setStance( Entity::Actor::Stance::Passive ); player.setStance( Entity::Actor::Stance::Passive );
pPlayer->setAutoattack( false ); player.setAutoattack( false );
} }
pPlayer->sendToInRangeSet( ActorControlPacket142( pPlayer->getId(), 0, param11, 1 ) ); player.sendToInRangeSet( ActorControlPacket142( player.getId(), 0, param11, 1 ) );
break; break;
} }
@ -85,13 +85,13 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
{ {
if ( param11 == 1 ) if ( param11 == 1 )
{ {
pPlayer->setAutoattack( true ); player.setAutoattack( true );
pPlayer->setStance( Entity::Actor::Stance::Active ); player.setStance( Entity::Actor::Stance::Active );
} }
else else
pPlayer->setAutoattack( false ); player.setAutoattack( false );
pPlayer->sendToInRangeSet( ActorControlPacket142( pPlayer->getId(), 1, param11, 1 ) ); player.sendToInRangeSet( ActorControlPacket142( player.getId(), 1, param11, 1 ) );
break; break;
} }
@ -99,51 +99,51 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
{ {
uint64_t targetId = inPacket.getValAt< uint64_t >( 0x24 ); uint64_t targetId = inPacket.getValAt< uint64_t >( 0x24 );
pPlayer->changeTarget( targetId ); player.changeTarget( targetId );
break; break;
} }
case 0x65: case 0x65:
{ {
pPlayer->dismount(); player.dismount();
break; break;
} }
case 0x68: // Remove status (clicking it off) case 0x68: // Remove status (clicking it off)
{ {
// todo: check if status can be removed by client from exd // todo: check if status can be removed by client from exd
pPlayer->removeSingleStatusEffectFromId( static_cast< uint32_t >( param1 ) ); player.removeSingleStatusEffectById( static_cast< uint32_t >( param1 ) );
break; break;
} }
case 0x69: // Cancel cast case 0x69: // Cancel cast
{ {
if( pPlayer->getCurrentAction() ) if( player.getCurrentAction() )
pPlayer->getCurrentAction()->setInterrupted(); player.getCurrentAction()->setInterrupted();
break; break;
} }
case 0x12E: // Set player title case 0x12E: // Set player title
{ {
pPlayer->setTitle( static_cast< uint16_t >( param1 ) ); player.setTitle( static_cast< uint16_t >( param1 ) );
break; break;
} }
case 0x12F: // Get title list case 0x12F: // Get title list
{ {
ZoneChannelPacket< FFXIVIpcPlayerTitleList > titleListPacket( pPlayer->getId() ); ZoneChannelPacket< FFXIVIpcPlayerTitleList > titleListPacket( player.getId() );
memcpy( titleListPacket.data().titleList, pPlayer->getTitleList(), sizeof( titleListPacket.data().titleList ) ); memcpy( titleListPacket.data().titleList, player.getTitleList(), sizeof( titleListPacket.data().titleList ) );
pPlayer->queuePacket( titleListPacket ); player.queuePacket( titleListPacket );
break; break;
} }
case 0x133: // Update howtos seen case 0x133: // Update howtos seen
{ {
uint32_t howToId = static_cast< uint32_t >( param1 ); uint32_t howToId = static_cast< uint32_t >( param1 );
pPlayer->updateHowtosSeen( howToId ); player.updateHowtosSeen( howToId );
break; break;
} }
case 0x1F4: // emote case 0x1F4: // emote
{ {
uint64_t targetId = pPlayer->getTargetId(); uint64_t targetId = player.getTargetId();
uint32_t emoteId = inPacket.getValAt< uint32_t >( 0x24 ); uint32_t emoteId = inPacket.getValAt< uint32_t >( 0x24 );
pPlayer->sendToInRangeSet( ActorControlPacket144( pPlayer->getId(), Emote, emoteId, 0, 0, 0, targetId ) ); player.sendToInRangeSet( ActorControlPacket144( player.getId(), Emote, emoteId, 0, 0, 0, targetId ) );
break; break;
} }
case 0xC8: // return dead case 0xC8: // return dead
@ -152,10 +152,10 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
{ {
case ResurrectType::RaiseSpell: case ResurrectType::RaiseSpell:
// todo: handle raise case (set position to raiser, apply weakness status, set hp/mp/tp as well as packet) // todo: handle raise case (set position to raiser, apply weakness status, set hp/mp/tp as well as packet)
pPlayer->returnToHomepoint(); player.returnToHomepoint();
break; break;
case ResurrectType::Return: case ResurrectType::Return:
pPlayer->returnToHomepoint(); player.returnToHomepoint();
break; break;
default: default:
break; break;
@ -164,39 +164,39 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
} }
case 0xC9: // Finish zoning case 0xC9: // Finish zoning
{ {
switch( pPlayer->getZoningType() ) switch( player.getZoningType() )
{ {
case ZoneingType::None: case ZoneingType::None:
pPlayer->sendToInRangeSet( ActorControlPacket143( pPlayer->getId(), ZoneIn, 0x01 ), true ); player.sendToInRangeSet( ActorControlPacket143( player.getId(), ZoneIn, 0x01 ), true );
break; break;
case ZoneingType::Teleport: case ZoneingType::Teleport:
pPlayer->sendToInRangeSet( ActorControlPacket143( pPlayer->getId(), ZoneIn, 0x01, 0, 0, 110 ), true ); player.sendToInRangeSet( ActorControlPacket143( player.getId(), ZoneIn, 0x01, 0, 0, 110 ), true );
break; break;
case ZoneingType::Return: case ZoneingType::Return:
case ZoneingType::ReturnDead: case ZoneingType::ReturnDead:
{ {
if( pPlayer->getStatus() == Entity::Actor::ActorStatus::Dead ) if( player.getStatus() == Entity::Actor::ActorStatus::Dead )
{ {
pPlayer->resetHp(); player.resetHp();
pPlayer->resetMp(); player.resetMp();
pPlayer->setStatus( Entity::Actor::ActorStatus::Idle ); player.setStatus( Entity::Actor::ActorStatus::Idle );
pPlayer->sendToInRangeSet( ActorControlPacket143( pPlayer->getId(), ZoneIn, 0x01, 0x01, 0, 111 ), true ); player.sendToInRangeSet( ActorControlPacket143( player.getId(), ZoneIn, 0x01, 0x01, 0, 111 ), true );
pPlayer->sendToInRangeSet( ActorControlPacket142( pPlayer->getId(), SetStatus, static_cast< uint8_t >( Entity::Actor::ActorStatus::Idle ) ), true ); player.sendToInRangeSet( ActorControlPacket142( player.getId(), SetStatus, static_cast< uint8_t >( Entity::Actor::ActorStatus::Idle ) ), true );
} }
else else
pPlayer->sendToInRangeSet( ActorControlPacket143( pPlayer->getId(), ZoneIn, 0x01, 0x00, 0, 111 ), true ); player.sendToInRangeSet( ActorControlPacket143( player.getId(), ZoneIn, 0x01, 0x00, 0, 111 ), true );
} }
break; break;
case ZoneingType::FadeIn: case ZoneingType::FadeIn:
break; break;
} }
pPlayer->setZoningType( Common::ZoneingType::None ); player.setZoningType( Common::ZoneingType::None );
pPlayer->unsetStateFlag( PlayerStateFlag::BetweenAreas ); player.unsetStateFlag( PlayerStateFlag::BetweenAreas );
pPlayer->unsetStateFlag( PlayerStateFlag::BetweenAreas1 ); player.unsetStateFlag( PlayerStateFlag::BetweenAreas1 );
pPlayer->sendStateFlags(); player.sendStateFlags();
break; break;
} }
@ -207,7 +207,7 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
if( targetAetheryte ) if( targetAetheryte )
{ {
auto fromAetheryte = g_exdData.getAetheryteInfo( g_exdData.m_zoneInfoMap[pPlayer->getZoneId()].aetheryte_index ); auto fromAetheryte = g_exdData.getAetheryteInfo( g_exdData.m_zoneInfoMap[player.getZoneId()].aetheryte_index );
// calculate cost - does not apply for favorite points or homepoints neither checks for aether tickets // calculate cost - does not apply for favorite points or homepoints neither checks for aether tickets
auto cost = static_cast< uint16_t > ( ( sqrt( pow( fromAetheryte->map_coord_x - targetAetheryte->map_coord_x, 2 ) + auto cost = static_cast< uint16_t > ( ( sqrt( pow( fromAetheryte->map_coord_x - targetAetheryte->map_coord_x, 2 ) +
@ -216,22 +216,27 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in
// cap at 999 gil // cap at 999 gil
cost = cost > uint16_t{999} ? uint16_t{999} : cost; cost = cost > uint16_t{999} ? uint16_t{999} : cost;
bool insufficientGil = pPlayer->getCurrency( Inventory::CurrencyType::Gil ) < cost; bool insufficientGil = player.getCurrency( Inventory::CurrencyType::Gil ) < cost;
// todo: figure out what param1 really does // todo: figure out what param1 really does
pPlayer->queuePacket( ActorControlPacket143( pPlayer->getId(), TeleportStart, insufficientGil ? 2 : 0, param11 ) ); player.queuePacket( ActorControlPacket143( player.getId(), TeleportStart, insufficientGil ? 2 : 0, param11 ) );
if( !insufficientGil ) if( !insufficientGil )
{ {
Action::ActionTeleportPtr pActionTeleport( new Action::ActionTeleport( pPlayer, param11, cost ) ); Action::ActionTeleportPtr pActionTeleport( new Action::ActionTeleport( player.getAsPlayer(), param11, cost ) );
pPlayer->setCurrentAction( pActionTeleport ); player.setCurrentAction( pActionTeleport );
} }
} }
break; break;
} }
case 0x1B5: // Dye item
{
break;
}
default: default:
{ {
g_log.debug( "[" + std::to_string( m_pSession->getId() ) + "] Unhandled action: " + g_log.debug( "[" + std::to_string( m_pSession->getId() ) + "] Unhandled action: " +
boost::str( boost::format( "%|04X|" ) % (uint32_t) ( commandId & 0xFFFF ) ) ); boost::str( boost::format( "%|04X|" ) % (uint32_t) ( commandId & 0xFFFF ) ) );
break;
} }
} }
} }

View file

@ -1,21 +1,19 @@
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <src/servers/Server_Common/Network/CommonNetwork.h> #include <Server_Common/Network/CommonNetwork.h>
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include <src/servers/Server_Common/Network/PacketContainer.h> #include <Server_Common/Network/PacketContainer.h>
#include "src/servers/Server_Zone/Network/GameConnection.h"
#include "src/servers/Server_Zone/Session.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ServerNoticePacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket142.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket143.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket144.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/PlayerStateFlagsPacket.h"
#include "src/servers/Server_Zone/Actor/Player.h"
#include "src/servers/Server_Zone/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/PlayerStateFlagsPacket.h"
#include "Actor/Player.h"
#include "Forwards.h"
extern Core::Logger g_log; extern Core::Logger g_log;
@ -25,11 +23,11 @@ using namespace Core::Network::Packets::Server;
void Core::Network::GameConnection::cfDutyInfoRequest( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::cfDutyInfoRequest( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
ZoneChannelPacket< FFXIVIpcCFDutyInfo > dutyInfoPacket( pPlayer->getId() ); ZoneChannelPacket< FFXIVIpcCFDutyInfo > dutyInfoPacket( player.getId() );
auto penaltyMinutes = pPlayer->getCFPenaltyMinutes(); auto penaltyMinutes = player.getCFPenaltyMinutes();
if (penaltyMinutes > 255) if (penaltyMinutes > 255)
{ {
// cap it since it's uint8_t in packets // cap it since it's uint8_t in packets
@ -39,13 +37,13 @@ void Core::Network::GameConnection::cfDutyInfoRequest( const Packets::GamePacket
queueOutPacket( dutyInfoPacket ); queueOutPacket( dutyInfoPacket );
ZoneChannelPacket< FFXIVIpcCFPlayerInNeed > inNeedsPacket( pPlayer->getId() ); ZoneChannelPacket< FFXIVIpcCFPlayerInNeed > inNeedsPacket( player.getId() );
queueOutPacket( inNeedsPacket ); queueOutPacket( inNeedsPacket );
} }
void Core::Network::GameConnection::cfRegisterDuty( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::cfRegisterDuty( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer) Entity::Player& player)
{ {
// TODO use for loop for this // TODO use for loop for this
auto contentId1 = inPacket.getValAt< uint16_t >( 46 ); auto contentId1 = inPacket.getValAt< uint16_t >( 46 );
@ -54,28 +52,28 @@ void Core::Network::GameConnection::cfRegisterDuty( const Packets::GamePacket& i
auto contentId4 = inPacket.getValAt< uint16_t >( 52 ); auto contentId4 = inPacket.getValAt< uint16_t >( 52 );
auto contentId5 = inPacket.getValAt< uint16_t >( 54 ); auto contentId5 = inPacket.getValAt< uint16_t >( 54 );
pPlayer->sendDebug("Duty register request"); player.sendDebug("Duty register request");
pPlayer->sendDebug("ContentId1" + std::to_string(contentId1)); player.sendDebug("ContentId1" + std::to_string(contentId1));
pPlayer->sendDebug("ContentId2" + std::to_string(contentId2)); player.sendDebug("ContentId2" + std::to_string(contentId2));
pPlayer->sendDebug("ContentId3" + std::to_string(contentId3)); player.sendDebug("ContentId3" + std::to_string(contentId3));
pPlayer->sendDebug("ContentId4" + std::to_string(contentId4)); player.sendDebug("ContentId4" + std::to_string(contentId4));
pPlayer->sendDebug("ContentId5" + std::to_string(contentId5)); player.sendDebug("ContentId5" + std::to_string(contentId5));
// let's cancel it because otherwise you can't register it again // let's cancel it because otherwise you can't register it again
ZoneChannelPacket< FFXIVIpcCFNotify > cfCancelPacket( pPlayer->getId() ); ZoneChannelPacket< FFXIVIpcCFNotify > cfCancelPacket( player.getId() );
cfCancelPacket.data().state1 = 3; cfCancelPacket.data().state1 = 3;
cfCancelPacket.data().state2 = 1; // Your registration is withdrawn. cfCancelPacket.data().state2 = 1; // Your registration is withdrawn.
queueOutPacket( cfCancelPacket ); queueOutPacket( cfCancelPacket );
} }
void Core::Network::GameConnection::cfRegisterRoulette( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::cfRegisterRoulette( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer) Entity::Player& player)
{ {
pPlayer->sendDebug("Roulette register"); player.sendDebug("Roulette register");
} }
void Core::Network::GameConnection::cfDutyAccepted( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::cfDutyAccepted( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer) Entity::Player& player)
{ {
pPlayer->sendDebug("TODO: Duty accept"); player.sendDebug("TODO: Duty accept");
} }

View file

@ -1,24 +1,24 @@
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <src/servers/Server_Common/Network/CommonNetwork.h> #include <Server_Common/Network/CommonNetwork.h>
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <src/servers/Server_Common/Network/PacketContainer.h> #include <Server_Common/Network/PacketContainer.h>
#include <src/servers/Server_Common/Network/PacketDef/Zone/ServerZoneDef.h> #include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include <boost/format.hpp> #include <boost/format.hpp>
#include "src/servers/Server_Zone/Network/GameConnection.h" #include "Network/GameConnection.h"
#include "src/servers/Server_Zone/Session.h" #include "Session.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ServerNoticePacket.h" #include "Network/PacketWrappers/ServerNoticePacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket142.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket144.h" #include "Network/PacketWrappers/ActorControlPacket144.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/EventStartPacket.h" #include "Network/PacketWrappers/EventStartPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/EventFinishPacket.h" #include "Network/PacketWrappers/EventFinishPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/PlayerStateFlagsPacket.h" #include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
#include "src/servers/Server_Zone/Script/ScriptManager.h" #include "Script/ScriptManager.h"
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
#include "src/servers/Server_Zone/Event/EventHelper.h" #include "Event/EventHelper.h"
extern Core::Scripting::ScriptManager g_scriptMgr; extern Core::Scripting::ScriptManager g_scriptMgr;
@ -27,22 +27,22 @@ using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server; using namespace Core::Network::Packets::Server;
void Core::Network::GameConnection::eventHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::eventHandler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
uint16_t eventHandlerId = inPacket.getValAt< uint16_t >( 0x12 ); uint16_t eventHandlerId = inPacket.getValAt< uint16_t >( 0x12 );
// we need to abort the event in case it has not been scripted so the player wont be locked up // we need to abort the event in case it has not been scripted so the player wont be locked up
auto abortEventFunc = []( Core::Entity::PlayerPtr pPlayer, uint64_t actorId, uint32_t eventId ) auto abortEventFunc = []( Core::Entity::Player& player, uint64_t actorId, uint32_t eventId )
{ {
pPlayer->queuePacket( EventStartPacket( pPlayer->getId(), actorId, eventId, 1, 0, 0 ) ); player.queuePacket( EventStartPacket( player.getId(), actorId, eventId, 1, 0, 0 ) );
pPlayer->queuePacket( EventFinishPacket( pPlayer->getId(), eventId, 1, 0 ) ); player.queuePacket( EventFinishPacket( player.getId(), eventId, 1, 0 ) );
// this isn't ideal as it will also reset any other status that might be active // this isn't ideal as it will also reset any other status that might be active
pPlayer->queuePacket( PlayerStateFlagsPacket( pPlayer, PlayerStateFlagList{} ) ); player.queuePacket( PlayerStateFlagsPacket( player, PlayerStateFlagList{} ) );
}; };
std::string eventIdStr = boost::str( boost::format( "%|04X|" ) % static_cast< uint32_t >( eventHandlerId & 0xFFFF ) ); std::string eventIdStr = boost::str( boost::format( "%|04X|" ) % static_cast< uint32_t >( eventHandlerId & 0xFFFF ) );
pPlayer->sendDebug( "---------------------------------------" ); player.sendDebug( "---------------------------------------" );
pPlayer->sendDebug( "EventHandler ( " + eventIdStr + " )" ); player.sendDebug( "EventHandler ( " + eventIdStr + " )" );
switch( eventHandlerId ) switch( eventHandlerId )
{ {
@ -52,8 +52,8 @@ void Core::Network::GameConnection::eventHandler( const Packets::GamePacket& inP
uint64_t actorId = inPacket.getValAt< uint64_t >( 0x20 ); uint64_t actorId = inPacket.getValAt< uint64_t >( 0x20 );
uint32_t eventId = inPacket.getValAt< uint32_t >( 0x28 ); uint32_t eventId = inPacket.getValAt< uint32_t >( 0x28 );
if( !g_scriptMgr.onTalk( pPlayer, actorId, eventId ) ) if( !g_scriptMgr.onTalk( player, actorId, eventId ) )
abortEventFunc( pPlayer, actorId, eventId ); abortEventFunc( player, actorId, eventId );
break; break;
} }
@ -65,8 +65,8 @@ void Core::Network::GameConnection::eventHandler( const Packets::GamePacket& inP
std::string eventName = Event::getEventName( eventId ); std::string eventName = Event::getEventName( eventId );
if( !g_scriptMgr.onEmote( pPlayer, actorId, eventId, static_cast< uint8_t >( emoteId ) ) ) if( !g_scriptMgr.onEmote( player, actorId, eventId, static_cast< uint8_t >( emoteId ) ) )
abortEventFunc( pPlayer, actorId, eventId ); abortEventFunc( player, actorId, eventId );
break; break;
} }
@ -81,8 +81,8 @@ void Core::Network::GameConnection::eventHandler( const Packets::GamePacket& inP
std::string eventName = Event::getEventName( eventId ); std::string eventName = Event::getEventName( eventId );
if( !g_scriptMgr.onWithinRange( pPlayer, eventId, eventParam1, x, y, z ) ) if( !g_scriptMgr.onWithinRange( player, eventId, eventParam1, x, y, z ) )
abortEventFunc( pPlayer, 0, eventId ); abortEventFunc( player, 0, eventId );
break; break;
} }
@ -96,8 +96,8 @@ void Core::Network::GameConnection::eventHandler( const Packets::GamePacket& inP
std::string eventName = Event::getEventName( eventId ); std::string eventName = Event::getEventName( eventId );
if( !g_scriptMgr.onOutsideRange( pPlayer, eventId, eventParam1, x, y, z ) ) if( !g_scriptMgr.onOutsideRange( player, eventId, eventParam1, x, y, z ) )
abortEventFunc( pPlayer, 0, eventId ); abortEventFunc( player, 0, eventId );
break; break;
} }
@ -109,8 +109,8 @@ void Core::Network::GameConnection::eventHandler( const Packets::GamePacket& inP
std::string eventName = Event::getEventName( eventId ); std::string eventName = Event::getEventName( eventId );
if( !g_scriptMgr.onEnterTerritory( pPlayer, eventId, eventParam1, eventParam2 ) ) if( !g_scriptMgr.onEnterTerritory( player, eventId, eventParam1, eventParam2 ) )
abortEventFunc( pPlayer, 0, eventId ); abortEventFunc( player, 0, eventId );
break; break;
} }
@ -125,8 +125,8 @@ void Core::Network::GameConnection::eventHandler( const Packets::GamePacket& inP
std::string eventName = Event::getEventName( eventId ); std::string eventName = Event::getEventName( eventId );
if( !g_scriptMgr.onEventHandlerReturn( pPlayer, eventId, subEvent, param1, param2, param3 ) ) if( !g_scriptMgr.onEventHandlerReturn( player, eventId, subEvent, param1, param2, param3 ) )
abortEventFunc( pPlayer, 0, eventId ); abortEventFunc( player, 0, eventId );
break; break;
} }
@ -137,14 +137,12 @@ void Core::Network::GameConnection::eventHandler( const Packets::GamePacket& inP
uint16_t subEvent = inPacket.getValAt< uint16_t >( 0x24 ); uint16_t subEvent = inPacket.getValAt< uint16_t >( 0x24 );
std::string lsName = inPacket.getStringAt( 0x27 ); std::string lsName = inPacket.getStringAt( 0x27 );
ZoneChannelPacket< FFXIVIpcEventLinkshell > linkshellEvent( player.getId() );
ZoneChannelPacket< FFXIVIpcEventLinkshell > linkshellEvent( pPlayer->getId() );
linkshellEvent.data().eventId = eventId; linkshellEvent.data().eventId = eventId;
linkshellEvent.data().scene = static_cast< uint8_t >(subEvent); linkshellEvent.data().scene = static_cast< uint8_t >( subEvent );
linkshellEvent.data().param3 = 1; linkshellEvent.data().param3 = 1;
linkshellEvent.data().unknown1 = 0x15a; linkshellEvent.data().unknown1 = 0x15a;
pPlayer->queuePacket( linkshellEvent ); player.queuePacket( linkshellEvent );
// abortEventFunc( pPlayer, 0, eventId ); // abortEventFunc( pPlayer, 0, eventId );
break; break;

View file

@ -1,39 +1,39 @@
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <src/servers/Server_Common/Network/CommonNetwork.h> #include <Server_Common/Network/CommonNetwork.h>
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include <src/servers/Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <src/servers/Server_Common/Network/PacketContainer.h> #include <Server_Common/Network/PacketContainer.h>
#include <boost/format.hpp> #include <boost/format.hpp>
#include "src/servers/Server_Zone/Network/GameConnection.h" #include "Network/GameConnection.h"
#include "src/servers/Server_Zone/Session.h" #include "Session.h"
#include "src/servers/Server_Zone/Zone/Zone.h" #include "Zone/Zone.h"
#include "src/servers/Server_Zone/Zone/ZonePosition.h" #include "Zone/ZonePosition.h"
#include "src/servers/Server_Zone/ServerZone.h" #include "ServerZone.h"
#include "src/servers/Server_Zone/Zone/ZoneMgr.h" #include "Zone/ZoneMgr.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/InitUIPacket.h" #include "Network/PacketWrappers/InitUIPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/PingPacket.h" #include "Network/PacketWrappers/PingPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/MoveActorPacket.h" #include "Network/PacketWrappers/MoveActorPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ChatPacket.h" #include "Network/PacketWrappers/ChatPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ServerNoticePacket.h" #include "Network/PacketWrappers/ServerNoticePacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket142.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket144.h" #include "Network/PacketWrappers/ActorControlPacket144.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/EventStartPacket.h" #include "Network/PacketWrappers/EventStartPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/EventFinishPacket.h" #include "Network/PacketWrappers/EventFinishPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/PlayerStateFlagsPacket.h" #include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
#include "src/servers/Server_Zone/DebugCommand/DebugCommandHandler.h" #include "DebugCommand/DebugCommandHandler.h"
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "src/servers/Server_Zone/Inventory/Inventory.h" #include "Inventory/Inventory.h"
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
#include "src/servers/Server_Zone/Event/EventHelper.h" #include "Event/EventHelper.h"
#include "src/servers/Server_Zone/Action/Action.h" #include "Action/Action.h"
#include "src/servers/Server_Zone/Action/ActionTeleport.h" #include "Action/ActionTeleport.h"
extern Core::Logger g_log; extern Core::Logger g_log;
extern Core::ServerZone g_serverZone; extern Core::ServerZone g_serverZone;
@ -93,9 +93,9 @@ enum GmCommand
JumpNpc = 0x025F, JumpNpc = 0x025F,
}; };
void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPacket, Entity::PlayerPtr pPlayer ) void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPacket, Entity::Player& player )
{ {
if( pPlayer->getGmRank() <= 0 ) if( player.getGmRank() <= 0 )
return; return;
uint32_t commandId = inPacket.getValAt< uint32_t >( 0x20 ); uint32_t commandId = inPacket.getValAt< uint32_t >( 0x20 );
@ -103,19 +103,20 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
uint32_t param2 = inPacket.getValAt< uint32_t >( 0x28 ); uint32_t param2 = inPacket.getValAt< uint32_t >( 0x28 );
uint32_t param3 = inPacket.getValAt< uint32_t >( 0x38 ); uint32_t param3 = inPacket.getValAt< uint32_t >( 0x38 );
g_log.debug( pPlayer->getName() + " used GM1 commandId: " + std::to_string( commandId ) + g_log.debug( player.getName() + " used GM1 commandId: " + std::to_string( commandId ) +
", params: " + std::to_string( param1 ) + ", " + ", params: " + std::to_string( param1 ) + ", " +
std::to_string( param2 ) + ", " + std::to_string( param3 ) ); std::to_string( param2 ) + ", " + std::to_string( param3 ) );
Core::Entity::ActorPtr targetActor; Core::Entity::ActorPtr targetActor;
if( pPlayer->getId() == param3 ) if( player.getId() == param3 )
{ {
targetActor = pPlayer; targetActor = player.getAsPlayer();
} }
else { else
auto inRange = pPlayer->getInRangeActors(); {
auto inRange = player.getInRangeActors();
for( auto actor : inRange ) for( auto actor : inRange )
{ {
if( actor->getId() == param3 ) if( actor->getId() == param3 )
@ -132,13 +133,13 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
case GmCommand::Lv: case GmCommand::Lv:
{ {
targetPlayer->setLevel( param1 ); targetPlayer->setLevel( param1 );
pPlayer->sendNotice( "Level for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) ); player.sendNotice( "Level for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
break; break;
} }
case GmCommand::Race: case GmCommand::Race:
{ {
targetPlayer->setLookAt( CharaLook::Race, param1 ); targetPlayer->setLookAt( CharaLook::Race, param1 );
pPlayer->sendNotice( "Race for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) ); player.sendNotice( "Race for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
targetPlayer->spawn( targetPlayer ); targetPlayer->spawn( targetPlayer );
auto inRange = targetPlayer->getInRangeActors(); auto inRange = targetPlayer->getInRangeActors();
for( auto actor : inRange ) for( auto actor : inRange )
@ -151,7 +152,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
case GmCommand::Tribe: case GmCommand::Tribe:
{ {
targetPlayer->setLookAt( CharaLook::Tribe, param1 ); targetPlayer->setLookAt( CharaLook::Tribe, param1 );
pPlayer->sendNotice( "Tribe for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) ); player.sendNotice( "Tribe for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
targetPlayer->spawn( targetPlayer ); targetPlayer->spawn( targetPlayer );
auto inRange = targetPlayer->getInRangeActors(); auto inRange = targetPlayer->getInRangeActors();
for( auto actor : inRange ) for( auto actor : inRange )
@ -164,7 +165,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
case GmCommand::Sex: case GmCommand::Sex:
{ {
targetPlayer->setLookAt( CharaLook::Gender, param1 ); targetPlayer->setLookAt( CharaLook::Gender, param1 );
pPlayer->sendNotice( "Sex for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) ); player.sendNotice( "Sex for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
targetPlayer->spawn( targetPlayer ); targetPlayer->spawn( targetPlayer );
auto inRange = targetActor->getInRangeActors(); auto inRange = targetActor->getInRangeActors();
for( auto actor : inRange ) for( auto actor : inRange )
@ -176,14 +177,14 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
} }
case GmCommand::Time: case GmCommand::Time:
{ {
pPlayer->setEorzeaTimeOffset( param2 ); player.setEorzeaTimeOffset( param2 );
pPlayer->sendNotice( "Eorzea time offset: " + std::to_string( param2 ) ); player.sendNotice( "Eorzea time offset: " + std::to_string( param2 ) );
break; break;
} }
case GmCommand::Weather: case GmCommand::Weather:
{ {
targetPlayer->getCurrentZone()->setWeatherOverride( param1 ); targetPlayer->getCurrentZone()->setWeatherOverride( param1 );
pPlayer->sendNotice( "Weather in Zone \"" + targetPlayer->getCurrentZone()->getName() + "\" of " + player.sendNotice( "Weather in Zone \"" + targetPlayer->getCurrentZone()->getName() + "\" of " +
targetPlayer->getName() + " set in range." ); targetPlayer->getName() + " set in range." );
break; break;
} }
@ -192,14 +193,14 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
if( targetPlayer->getZoneId() != pPlayer->getZoneId() ) if( targetPlayer->getZoneId() != pPlayer->getZoneId() )
targetPlayer->setZone( pPlayer->getZoneId() ); targetPlayer->setZone( pPlayer->getZoneId() );
targetPlayer->changePosition( pPlayer->getPos().x, pPlayer->getPos().y, pPlayer->getPos().z, targetPlayer->changePosition( player.getPos().x, player.getPos().y, player.getPos().z,
pPlayer->getRotation() ); player.getRotation() );
pPlayer->sendNotice( "Calling " + targetPlayer->getName() ); player.sendNotice( "Calling " + targetPlayer->getName() );
break; break;
} }
case GmCommand::Inspect: case GmCommand::Inspect:
{ {
pPlayer->sendNotice( "Name: " + targetPlayer->getName() + player.sendNotice( "Name: " + targetPlayer->getName() +
"\nGil: " + std::to_string( targetPlayer->getCurrency( 1 ) ) + "\nGil: " + std::to_string( targetPlayer->getCurrency( 1 ) ) +
"\nZone: " + targetPlayer->getCurrentZone()->getName() + "\nZone: " + targetPlayer->getCurrentZone()->getName() +
"(" + std::to_string( targetPlayer->getZoneId() ) + ")" + "(" + std::to_string( targetPlayer->getZoneId() ) + ")" +
@ -212,14 +213,14 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
} }
case GmCommand::Speed: case GmCommand::Speed:
{ {
targetPlayer->queuePacket( ActorControlPacket143( pPlayer->getId(), Flee, param1 ) ); targetPlayer->queuePacket( ActorControlPacket143( player.getId(), Flee, param1 ) );
pPlayer->sendNotice( "Speed for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) ); player.sendNotice( "Speed for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
break; break;
} }
case GmCommand::Kill: case GmCommand::Kill:
{ {
targetActor->takeDamage( 9999999 ); targetActor->takeDamage( 9999999 );
pPlayer->sendNotice( "Killed " + std::to_string( targetActor->getId() ) ); player.sendNotice( "Killed " + std::to_string( targetActor->getId() ) );
break; break;
} }
case GmCommand::Icon: case GmCommand::Icon:
@ -236,34 +237,34 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
strcpy( searchInfoPacket.data().searchMessage, targetPlayer->getSearchMessage() ); strcpy( searchInfoPacket.data().searchMessage, targetPlayer->getSearchMessage() );
targetPlayer->queuePacket( searchInfoPacket ); targetPlayer->queuePacket( searchInfoPacket );
targetPlayer->sendToInRangeSet( ActorControlPacket142( pPlayer->getId(), SetStatusIcon, targetPlayer->sendToInRangeSet( ActorControlPacket142( player.getId(), SetStatusIcon,
static_cast< uint8_t >( pPlayer->getOnlineStatus() ) ), static_cast< uint8_t >( player.getOnlineStatus() ) ),
true ); true );
pPlayer->sendNotice( "Icon for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) ); player.sendNotice( "Icon for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
break; break;
} }
case GmCommand::Hp: case GmCommand::Hp:
{ {
targetPlayer->setHp( param1 ); targetPlayer->setHp( param1 );
pPlayer->sendNotice( "Hp for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) ); player.sendNotice( "Hp for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
break; break;
} }
case GmCommand::Mp: case GmCommand::Mp:
{ {
targetPlayer->setMp( param1 ); targetPlayer->setMp( param1 );
pPlayer->sendNotice( "Mp for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) ); player.sendNotice( "Mp for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
break; break;
} }
case GmCommand::Gp: case GmCommand::Gp:
{ {
targetPlayer->setHp( param1 ); targetPlayer->setHp( param1 );
pPlayer->sendNotice( "Gp for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) ); player.sendNotice( "Gp for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
break; break;
} }
case GmCommand::Exp: case GmCommand::Exp:
{ {
targetPlayer->gainExp( param1 ); targetPlayer->gainExp( param1 );
pPlayer->sendNotice( std::to_string( param1 ) + " Exp was added to " + targetPlayer->getName() ); player.sendNotice( std::to_string( param1 ) + " Exp was added to " + targetPlayer->getName() );
break; break;
} }
case GmCommand::Inv: case GmCommand::Inv:
@ -273,7 +274,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
else else
targetActor->setInvincibilityType( Common::InvincibilityType::InvincibilityRefill ); targetActor->setInvincibilityType( Common::InvincibilityType::InvincibilityRefill );
pPlayer->sendNotice( "Invincibility for " + targetPlayer->getName() + player.sendNotice( "Invincibility for " + targetPlayer->getName() +
" was switched." ); " was switched." );
break; break;
} }
@ -286,13 +287,13 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
for( uint8_t i = 0; i < 255; i++ ) for( uint8_t i = 0; i < 255; i++ )
targetActor->getAsPlayer()->learnSong( i, 0 ); targetActor->getAsPlayer()->learnSong( i, 0 );
pPlayer->sendNotice( "All Songs for " + targetPlayer->getName() + player.sendNotice( "All Songs for " + targetPlayer->getName() +
" were turned on." ); " were turned on." );
} }
else else
{ {
targetActor->getAsPlayer()->learnSong( param2, 0 ); targetActor->getAsPlayer()->learnSong( param2, 0 );
pPlayer->sendNotice( "Song " + std::to_string( param2 ) + " for " + targetPlayer->getName() + player.sendNotice( "Song " + std::to_string( param2 ) + " for " + targetPlayer->getName() +
" was turned on." ); " was turned on." );
} }
} }
@ -327,18 +328,18 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
if( param1 == 0xcccccccc ) if( param1 == 0xcccccccc )
{ {
pPlayer->sendUrgent( "Syntaxerror." ); player.sendUrgent( "Syntaxerror." );
return; return;
} }
if( !targetPlayer->addItem( -1, param1, param2 ) ) if( !targetPlayer->addItem( -1, param1, param2 ) )
pPlayer->sendUrgent( "Item " + std::to_string( param1 ) + " not found..." ); player.sendUrgent( "Item " + std::to_string( param1 ) + " not found..." );
break; break;
} }
case GmCommand::Gil: case GmCommand::Gil:
{ {
targetPlayer->addCurrency( 1, param1 ); targetPlayer->addCurrency( 1, param1 );
pPlayer->sendNotice( "Added " + std::to_string( param1 ) + " Gil for " + targetPlayer->getName() ); player.sendNotice( "Added " + std::to_string( param1 ) + " Gil for " + targetPlayer->getName() );
break; break;
} }
case GmCommand::Collect: case GmCommand::Collect:
@ -347,12 +348,12 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
if( gil < param1 ) if( gil < param1 )
{ {
pPlayer->sendUrgent( "Player does not have enough Gil(" + std::to_string( gil ) + ")" ); player.sendUrgent( "Player does not have enough Gil(" + std::to_string( gil ) + ")" );
} }
else else
{ {
targetPlayer->removeCurrency( 1, param1 ); targetPlayer->removeCurrency( 1, param1 );
pPlayer->sendNotice( "Removed " + std::to_string( param1 ) + player.sendNotice( "Removed " + std::to_string( param1 ) +
" Gil from " + targetPlayer->getName() + " Gil from " + targetPlayer->getName() +
"(" + std::to_string( gil ) + " before)" ); "(" + std::to_string( gil ) + " before)" );
} }
@ -386,14 +387,14 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
case GmCommand::GC: case GmCommand::GC:
{ {
targetPlayer->setGc( param1 ); targetPlayer->setGc( param1 );
pPlayer->sendNotice( "GC for " + targetPlayer->getName() + player.sendNotice( "GC for " + targetPlayer->getName() +
" was set to " + std::to_string( targetPlayer->getGc() ) ); " was set to " + std::to_string( targetPlayer->getGc() ) );
break; break;
} }
case GmCommand::GCRank: case GmCommand::GCRank:
{ {
targetPlayer->setGcRankAt( targetPlayer->getGc() - 1, param1 ); targetPlayer->setGcRankAt( targetPlayer->getGc() - 1, param1 );
pPlayer->sendNotice( "GC Rank for " + targetPlayer->getName() + player.sendNotice( "GC Rank for " + targetPlayer->getName() +
" for GC " + std::to_string( targetPlayer->getGc() ) + " for GC " + std::to_string( targetPlayer->getGc() ) +
" was set to " + std::to_string( targetPlayer->getGcRankArray()[targetPlayer->getGc() - 1] ) ); " was set to " + std::to_string( targetPlayer->getGcRankArray()[targetPlayer->getGc() - 1] ) );
break; break;
@ -407,13 +408,13 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
for( uint8_t i = 0; i < 255; i++ ) for( uint8_t i = 0; i < 255; i++ )
targetActor->getAsPlayer()->registerAetheryte( i ); targetActor->getAsPlayer()->registerAetheryte( i );
pPlayer->sendNotice( "All Aetherytes for " + targetPlayer->getName() + player.sendNotice( "All Aetherytes for " + targetPlayer->getName() +
" were turned on." ); " were turned on." );
} }
else else
{ {
targetActor->getAsPlayer()->registerAetheryte( param2 ); targetActor->getAsPlayer()->registerAetheryte( param2 );
pPlayer->sendNotice( "Aetheryte " + std::to_string( param2 ) + " for " + targetPlayer->getName() + player.sendNotice( "Aetheryte " + std::to_string( param2 ) + " for " + targetPlayer->getName() +
" was turned on." ); " was turned on." );
} }
} }
@ -425,55 +426,56 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
auto zoneInfo = g_zoneMgr.getZone( param1 ); auto zoneInfo = g_zoneMgr.getZone( param1 );
if( !zoneInfo ) if( !zoneInfo )
{ {
pPlayer->sendUrgent( "Invalid zone " + std::to_string( param1 ) ); player.sendUrgent( "Invalid zone " + std::to_string( param1 ) );
} }
else else
{ {
targetPlayer->setPosition( targetPlayer->getPos() ); targetPlayer->setPosition( targetPlayer->getPos() );
targetPlayer->performZoning( param1, targetPlayer->getPos(), 0 ); targetPlayer->performZoning( param1, targetPlayer->getPos(), 0 );
pPlayer->sendNotice( targetPlayer->getName() + " was warped to zone " + std::to_string( param1 ) + " (" + zoneInfo->getName() + ")" ); pPlayer->sendNotice( targetPlayer->getName() + " was warped to zone " + std::to_string( param1 ) + " (" + zoneInfo->getName() + ")" );
} }
break; break;
} }
case GmCommand::TeriInfo: case GmCommand::TeriInfo:
{ {
pPlayer->sendNotice( "ZoneId: " + std::to_string( pPlayer->getZoneId() ) + "\nName: " + player.sendNotice( "ZoneId: " + std::to_string( player.getZoneId() ) + "\nName: " +
pPlayer->getCurrentZone()->getName() + "\nInternalName: " + player.getCurrentZone()->getName() + "\nInternalName: " +
pPlayer->getCurrentZone()->getInternalName() + "\nPopCount: " + player.getCurrentZone()->getInternalName() + "\nPopCount: " +
std::to_string( pPlayer->getCurrentZone()->getPopCount() ) + std::to_string( player.getCurrentZone()->getPopCount() ) +
"\nCurrentWeather:" + std::to_string( pPlayer->getCurrentZone()->getCurrentWeather() ) + "\nCurrentWeather:" + std::to_string( player.getCurrentZone()->getCurrentWeather() ) +
"\nNextWeather:" + std::to_string( pPlayer->getCurrentZone()->getNextWeather() ) ); "\nNextWeather:" + std::to_string( player.getCurrentZone()->getNextWeather() ) );
break; break;
} }
case GmCommand::Jump: case GmCommand::Jump:
{ {
auto inRange = pPlayer->getInRangeActors(); auto inRange = player.getInRangeActors();
for( auto actor : inRange ) for( auto actor : inRange )
{ {
pPlayer->changePosition( targetActor->getPos().x, targetActor->getPos().y, targetActor->getPos().z, player.changePosition( targetActor->getPos().x, targetActor->getPos().y, targetActor->getPos().z,
targetActor->getRotation() ); targetActor->getRotation() );
} }
pPlayer->sendNotice( "Jumping to " + targetPlayer->getName() + " in range." ); player.sendNotice( "Jumping to " + targetPlayer->getName() + " in range." );
break; break;
} }
default: default:
pPlayer->sendUrgent( "GM1 Command not implemented: " + std::to_string( commandId ) ); player.sendUrgent( "GM1 Command not implemented: " + std::to_string( commandId ) );
break; break;
} }
} }
void Core::Network::GameConnection::gm2Handler( const Packets::GamePacket& inPacket, Entity::PlayerPtr pPlayer ) void Core::Network::GameConnection::gm2Handler( const Packets::GamePacket& inPacket, Entity::Player& player )
{ {
if( pPlayer->getGmRank() <= 0 ) if( player.getGmRank() <= 0 )
return; return;
uint32_t commandId = inPacket.getValAt< uint32_t >( 0x20 ); uint32_t commandId = inPacket.getValAt< uint32_t >( 0x20 );
std::string param1 = inPacket.getStringAt( 0x34 ); std::string param1 = inPacket.getStringAt( 0x34 );
g_log.debug( pPlayer->getName() + " used GM2 commandId: " + std::to_string( commandId ) + ", params: " + param1 ); g_log.debug( player.getName() + " used GM2 commandId: " + std::to_string( commandId ) + ", params: " + param1 );
auto targetSession = g_serverZone.getSession( param1 ); auto targetSession = g_serverZone.getSession( param1 );
Core::Entity::ActorPtr targetActor; Core::Entity::ActorPtr targetActor;
@ -486,11 +488,11 @@ void Core::Network::GameConnection::gm2Handler( const Packets::GamePacket& inPac
{ {
if( param1 == "self" ) if( param1 == "self" )
{ {
targetActor = pPlayer; targetActor = player.getAsPlayer();
} }
else else
{ {
pPlayer->sendUrgent( "Player " + param1 + " not found on this server." ); player.sendUrgent( "Player " + param1 + " not found on this server." );
return; return;
} }
} }
@ -508,25 +510,25 @@ void Core::Network::GameConnection::gm2Handler( const Packets::GamePacket& inPac
targetPlayer->resetMp(); targetPlayer->resetMp();
targetPlayer->setStatus( Entity::Actor::ActorStatus::Idle ); targetPlayer->setStatus( Entity::Actor::ActorStatus::Idle );
targetPlayer->sendToInRangeSet( ActorControlPacket143( pPlayer->getId(), ZoneIn, 0x01, 0x01, 0, 113 ), true ); targetPlayer->sendToInRangeSet( ActorControlPacket143( player.getId(), ZoneIn, 0x01, 0x01, 0, 113 ), true );
targetPlayer->sendToInRangeSet( ActorControlPacket142( pPlayer->getId(), SetStatus, targetPlayer->sendToInRangeSet( ActorControlPacket142( player.getId(), SetStatus,
static_cast< uint8_t >( Entity::Actor::ActorStatus::Idle ) ), true ); static_cast< uint8_t >( Entity::Actor::ActorStatus::Idle ) ), true );
pPlayer->sendNotice( "Raised " + targetPlayer->getName() ); player.sendNotice( "Raised " + targetPlayer->getName() );
break; break;
} }
case GmCommand::Jump: case GmCommand::Jump:
{ {
if( targetPlayer->getZoneId() != pPlayer->getZoneId() ) if( targetPlayer->getZoneId() != player.getZoneId() )
{ {
pPlayer->setZone( targetPlayer->getZoneId() ); player.setZone( targetPlayer->getZoneId() );
} }
pPlayer->changePosition( targetActor->getPos().x, targetActor->getPos().y, targetActor->getPos().z, player.changePosition( targetActor->getPos().x, targetActor->getPos().y, targetActor->getPos().z,
targetActor->getRotation() ); targetActor->getRotation() );
pPlayer->sendNotice( "Jumping to " + targetPlayer->getName() ); player.sendNotice( "Jumping to " + targetPlayer->getName() );
break; break;
} }
default: default:
pPlayer->sendUrgent( "GM2 Command not implemented: " + std::to_string( commandId ) ); player.sendUrgent( "GM2 Command not implemented: " + std::to_string( commandId ) );
break; break;
} }

View file

@ -1,29 +1,29 @@
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <src/servers/Server_Common/Network/CommonNetwork.h> #include <Server_Common/Network/CommonNetwork.h>
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include <src/servers/Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <src/servers/Server_Common/Network/PacketContainer.h> #include <Server_Common/Network/PacketContainer.h>
#include <boost/format.hpp> #include <boost/format.hpp>
#include "src/servers/Server_Zone/Network/GameConnection.h" #include "Network/GameConnection.h"
#include "src/servers/Server_Zone/Session.h" #include "Session.h"
#include "src/servers/Server_Zone/Zone/Zone.h" #include "Zone/Zone.h"
#include "src/servers/Server_Zone/Zone/ZonePosition.h" #include "Zone/ZonePosition.h"
#include "src/servers/Server_Zone/ServerZone.h" #include "ServerZone.h"
#include "src/servers/Server_Zone/Zone/ZoneMgr.h" #include "Zone/ZoneMgr.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ServerNoticePacket.h" #include "Network/PacketWrappers/ServerNoticePacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket142.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket144.h" #include "Network/PacketWrappers/ActorControlPacket144.h"
#include "src/servers/Server_Zone/DebugCommand/DebugCommandHandler.h" #include "DebugCommand/DebugCommandHandler.h"
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "src/servers/Server_Zone/Inventory/Inventory.h" #include "Inventory/Inventory.h"
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
extern Core::Logger g_log; extern Core::Logger g_log;
extern Core::ServerZone g_serverZone; extern Core::ServerZone g_serverZone;
@ -37,7 +37,7 @@ using namespace Core::Network::Packets::Server;
void Core::Network::GameConnection::inventoryModifyHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::inventoryModifyHandler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
uint32_t seq = inPacket.getValAt< uint32_t >( 0x20 ); uint32_t seq = inPacket.getValAt< uint32_t >( 0x20 );
uint8_t action = inPacket.getValAt< uint8_t >( 0x24 ); uint8_t action = inPacket.getValAt< uint8_t >( 0x24 );
@ -46,10 +46,10 @@ void Core::Network::GameConnection::inventoryModifyHandler( const Packets::GameP
uint16_t fromContainer = inPacket.getValAt< uint16_t >( 0x2C ); uint16_t fromContainer = inPacket.getValAt< uint16_t >( 0x2C );
uint16_t toContainer = inPacket.getValAt< uint16_t >( 0x40 ); uint16_t toContainer = inPacket.getValAt< uint16_t >( 0x40 );
ZoneChannelPacket< FFXIVIpcInventoryActionAck > ackPacket( pPlayer->getId() ); ZoneChannelPacket< FFXIVIpcInventoryActionAck > ackPacket( player.getId() );
ackPacket.data().sequence = seq; ackPacket.data().sequence = seq;
ackPacket.data().type = 7; ackPacket.data().type = 7;
pPlayer->queuePacket( ackPacket ); player.queuePacket( ackPacket );
g_log.debug( inPacket.toString() ); g_log.debug( inPacket.toString() );
@ -61,19 +61,19 @@ void Core::Network::GameConnection::inventoryModifyHandler( const Packets::GameP
case 0x07: // discard item action case 0x07: // discard item action
{ {
pPlayer->getInventory()->discardItem( fromContainer, fromSlot ); player.getInventory()->discardItem( fromContainer, fromSlot );
} }
break; break;
case 0x08: // move item action case 0x08: // move item action
{ {
pPlayer->getInventory()->moveItem( fromContainer, fromSlot, toContainer, toSlot ); player.getInventory()->moveItem( fromContainer, fromSlot, toContainer, toSlot );
} }
break; break;
case 0x09: // swap item action case 0x09: // swap item action
{ {
pPlayer->getInventory()->swapItem( fromContainer, fromSlot, toContainer, toSlot ); player.getInventory()->swapItem( fromContainer, fromSlot, toContainer, toSlot );
} }
break; break;

View file

@ -1,43 +1,42 @@
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <src/servers/Server_Common/Network/CommonNetwork.h> #include <Server_Common/Network/CommonNetwork.h>
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include <src/servers/Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <src/servers/Server_Common/Network/PacketContainer.h> #include <Server_Common/Network/PacketContainer.h>
#include <src/servers/Server_Common/Network/PacketDef/Chat/ServerChatDef.h> #include <Server_Common/Network/PacketDef/Chat/ServerChatDef.h>
#include <Server_Common/Database/DatabaseDef.h>
#include <boost/format.hpp> #include <boost/format.hpp>
#include "Network/GameConnection.h"
#include "src/servers/Server_Zone/Network/GameConnection.h" #include "Session.h"
#include "Zone/Zone.h"
#include "Zone/ZonePosition.h"
#include "ServerZone.h"
#include "Zone/ZoneMgr.h"
#include "src/servers/Server_Zone/Session.h" #include "Network/PacketWrappers/InitUIPacket.h"
#include "src/servers/Server_Zone/Zone/Zone.h" #include "Network/PacketWrappers/PingPacket.h"
#include "src/servers/Server_Zone/Zone/ZonePosition.h" #include "Network/PacketWrappers/MoveActorPacket.h"
#include "src/servers/Server_Zone/ServerZone.h" #include "Network/PacketWrappers/ChatPacket.h"
#include "src/servers/Server_Zone/Zone/ZoneMgr.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/PlayerStateFlagsPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/InitUIPacket.h" #include "DebugCommand/DebugCommandHandler.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/PingPacket.h" #include "Actor/Player.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/MoveActorPacket.h" #include "Inventory/Inventory.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ChatPacket.h" #include "Forwards.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ServerNoticePacket.h" #include "Event/EventHelper.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket142.h" #include "Action/Action.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket143.h" #include "Action/ActionTeleport.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket144.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/EventStartPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/EventFinishPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/PlayerStateFlagsPacket.h"
#include "src/servers/Server_Zone/DebugCommand/DebugCommandHandler.h"
#include "src/servers/Server_Zone/Actor/Player.h"
#include "src/servers/Server_Zone/Inventory/Inventory.h"
#include "src/servers/Server_Zone/Forwards.h"
#include "src/servers/Server_Zone/Event/EventHelper.h"
#include "src/servers/Server_Zone/Action/Action.h"
#include "src/servers/Server_Zone/Action/ActionTeleport.h"
#include <Server_Common/Database/DatabaseDef.h>
extern Core::Logger g_log; extern Core::Logger g_log;
extern Core::ServerZone g_serverZone; extern Core::ServerZone g_serverZone;
@ -50,15 +49,15 @@ using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server; using namespace Core::Network::Packets::Server;
void Core::Network::GameConnection::fcInfoReqHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::fcInfoReqHandler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
GamePacketPtr pPe( new GamePacket( 0xDD, 0x78, pPlayer->getId(), pPlayer->getId() ) ); GamePacketPtr pPe( new GamePacket( 0xDD, 0x78, player.getId(), player.getId() ) );
pPe->setValAt< uint8_t >( 0x48, 0x01 ); pPe->setValAt< uint8_t >( 0x48, 0x01 );
queueOutPacket( pPe ); queueOutPacket( pPe );
} }
void Core::Network::GameConnection::setSearchInfoHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::setSearchInfoHandler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
uint32_t inval = inPacket.getValAt< uint32_t >( 0x20 ); uint32_t inval = inPacket.getValAt< uint32_t >( 0x20 );
uint32_t inval1 = inPacket.getValAt< uint32_t >( 0x24 ); uint32_t inval1 = inPacket.getValAt< uint32_t >( 0x24 );
@ -66,54 +65,53 @@ void Core::Network::GameConnection::setSearchInfoHandler( const Packets::GamePac
uint8_t selectRegion = inPacket.getValAt< uint8_t >( 0x31 ); uint8_t selectRegion = inPacket.getValAt< uint8_t >( 0x31 );
pPlayer->setSearchInfo( selectRegion, 0, inPacket.getStringAt( 0x32 ) ); player.setSearchInfo( selectRegion, 0, inPacket.getStringAt( 0x32 ) );
pPlayer->setOnlineStatusMask( status ); player.setOnlineStatusMask( status );
if( pPlayer->isNewAdventurer() && !( inval & 0x01000000 ) ) if( player.isNewAdventurer() && !( inval & 0x01000000 ) )
// mark player as not new adventurer anymore // mark player as not new adventurer anymore
pPlayer->setNewAdventurer( false ); player.setNewAdventurer( false );
else if( inval & 0x01000000 ) else if( inval & 0x01000000 )
// mark player as new adventurer // mark player as new adventurer
pPlayer->setNewAdventurer( true ); player.setNewAdventurer( true );
ZoneChannelPacket< FFXIVIpcSetOnlineStatus > statusPacket( pPlayer->getId() ); ZoneChannelPacket< FFXIVIpcSetOnlineStatus > statusPacket( player.getId() );
statusPacket.data().onlineStatusFlags = status; statusPacket.data().onlineStatusFlags = status;
queueOutPacket( statusPacket ); queueOutPacket( statusPacket );
ZoneChannelPacket< FFXIVIpcSetSearchInfo > searchInfoPacket( pPlayer->getId() ); ZoneChannelPacket< FFXIVIpcSetSearchInfo > searchInfoPacket( player.getId() );
searchInfoPacket.data().onlineStatusFlags = status; searchInfoPacket.data().onlineStatusFlags = status;
searchInfoPacket.data().selectRegion = pPlayer->getSearchSelectRegion(); searchInfoPacket.data().selectRegion = player.getSearchSelectRegion();
strcpy( searchInfoPacket.data().searchMessage, pPlayer->getSearchMessage() ); strcpy( searchInfoPacket.data().searchMessage, player.getSearchMessage() );
queueOutPacket( searchInfoPacket ); queueOutPacket( searchInfoPacket );
pPlayer->sendToInRangeSet( ActorControlPacket142( pPlayer->getId(), SetStatusIcon, player.sendToInRangeSet( ActorControlPacket142( player.getId(), SetStatusIcon,
static_cast< uint8_t >( pPlayer->getOnlineStatus() ) ), static_cast< uint8_t >( player.getOnlineStatus() ) ), true );
true );
} }
void Core::Network::GameConnection::reqSearchInfoHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::reqSearchInfoHandler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
ZoneChannelPacket< FFXIVIpcInitSearchInfo > searchInfoPacket( pPlayer->getId() ); ZoneChannelPacket< FFXIVIpcInitSearchInfo > searchInfoPacket( player.getId() );
searchInfoPacket.data().onlineStatusFlags = pPlayer->getOnlineStatusMask(); searchInfoPacket.data().onlineStatusFlags = player.getOnlineStatusMask();
searchInfoPacket.data().selectRegion = pPlayer->getSearchSelectRegion(); searchInfoPacket.data().selectRegion = player.getSearchSelectRegion();
strcpy( searchInfoPacket.data().searchMessage, pPlayer->getSearchMessage() ); strcpy( searchInfoPacket.data().searchMessage, player.getSearchMessage() );
queueOutPacket( searchInfoPacket ); queueOutPacket( searchInfoPacket );
} }
void Core::Network::GameConnection::linkshellListHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::linkshellListHandler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
ZoneChannelPacket< FFXIVIpcLinkshellList > linkshellListPacket( pPlayer->getId() ); ZoneChannelPacket< FFXIVIpcLinkshellList > linkshellListPacket( player.getId() );
queueOutPacket( linkshellListPacket ); queueOutPacket( linkshellListPacket );
} }
void Core::Network::GameConnection::updatePositionHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::updatePositionHandler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
// if the player is marked for zoning we no longer want to update his pos // if the player is marked for zoning we no longer want to update his pos
if( pPlayer->isMarkedForZoning() ) if( player.isMarkedForZoning() )
return; return;
struct testMov struct testMov
@ -178,23 +176,23 @@ void Core::Network::GameConnection::updatePositionHandler( const Packets::GamePa
//pInPacket->debugPrint(); //pInPacket->debugPrint();
bool bPosChanged = false; bool bPosChanged = false;
if( ( pPlayer->getPos().x != inPacket.getValAt< float >( 0x2c ) ) || if( ( player.getPos().x != inPacket.getValAt< float >( 0x2c ) ) ||
( pPlayer->getPos().y != inPacket.getValAt< float >( 0x30 ) ) || ( player.getPos().y != inPacket.getValAt< float >( 0x30 ) ) ||
( pPlayer->getPos().z != inPacket.getValAt< float >( 0x34 ) ) ) ( player.getPos().z != inPacket.getValAt< float >( 0x34 ) ) )
bPosChanged = true; bPosChanged = true;
if( !bPosChanged && pPlayer->getRotation() == inPacket.getValAt< float >( 0x20 ) ) if( !bPosChanged && player.getRotation() == inPacket.getValAt< float >( 0x20 ) )
return; return;
pPlayer->setRotation( inPacket.getValAt< float >( 0x20 ) ); player.setRotation( inPacket.getValAt< float >( 0x20 ) );
pPlayer->setPosition( inPacket.getValAt< float >( 0x2c ), player.setPosition( inPacket.getValAt< float >( 0x2c ),
inPacket.getValAt< float >( 0x30 ), inPacket.getValAt< float >( 0x30 ),
inPacket.getValAt< float >( 0x34 ) ); inPacket.getValAt< float >( 0x34 ) );
if( ( pPlayer->getCurrentAction() != nullptr ) && bPosChanged ) if( ( player.getCurrentAction() != nullptr ) && bPosChanged )
pPlayer->getCurrentAction()->setInterrupted(); player.getCurrentAction()->setInterrupted();
// if no one is in range, don't bother trying to send a position update // if no one is in range, don't bother trying to send a position update
if( !pPlayer->hasInRangeActor() ) if( !player.hasInRangeActor() )
return; return;
uint8_t unk = inPacket.getValAt< uint8_t >( 0x29 ); uint8_t unk = inPacket.getValAt< uint8_t >( 0x29 );
@ -278,26 +276,26 @@ void Core::Network::GameConnection::updatePositionHandler( const Packets::GamePa
} }
} }
MoveActorPacket movePacket( pPlayer, unk1, unk2, unk3, unk4 ); MoveActorPacket movePacket( player, unk1, unk2, unk3, unk4 );
pPlayer->sendToInRangeSet( movePacket ); player.sendToInRangeSet( movePacket );
} }
void Core::Network::GameConnection::reqEquipDisplayFlagsHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::reqEquipDisplayFlagsHandler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
g_log.info( "[" + std::to_string( pPlayer->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 ) ) );
pPlayer->setEquipDisplayFlags( inPacket.getValAt< uint8_t >( 0x20 ) ); player.setEquipDisplayFlags( inPacket.getValAt< uint8_t >( 0x20 ) );
} }
void Core::Network::GameConnection::zoneLineHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::zoneLineHandler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
uint32_t zoneLineId = inPacket.getValAt< uint32_t >( 0x20 ); uint32_t zoneLineId = inPacket.getValAt< uint32_t >( 0x20 );
pPlayer->sendDebug( "Walking ZoneLine " + std::to_string( zoneLineId ) ); player.sendDebug( "Walking ZoneLine " + std::to_string( zoneLineId ) );
auto pZone = pPlayer->getCurrentZone(); auto pZone = player.getCurrentZone();
auto pLine = g_zoneMgr.getZonePosition( zoneLineId ); auto pLine = g_zoneMgr.getZonePosition( zoneLineId );
@ -307,34 +305,34 @@ void Core::Network::GameConnection::zoneLineHandler( const Packets::GamePacket&
if( pLine != nullptr ) if( pLine != nullptr )
{ {
pPlayer->sendDebug( "ZoneLine " + std::to_string( zoneLineId ) + " found." ); player.sendDebug( "ZoneLine " + std::to_string( zoneLineId ) + " found." );
targetPos = pLine->getTargetPosition(); targetPos = pLine->getTargetPosition();
targetZone = pLine->getTargetZoneId(); targetZone = pLine->getTargetZoneId();
rotation = pLine->getTargetRotation(); rotation = pLine->getTargetRotation();
ZoneChannelPacket< FFXIVIpcPrepareZoning > preparePacket( pPlayer->getId() ); ZoneChannelPacket< FFXIVIpcPrepareZoning > preparePacket( player.getId() );
preparePacket.data().targetZone = targetZone; preparePacket.data().targetZone = targetZone;
//ActorControlPacket143 controlPacket( pPlayer, ActorControlType::DespawnZoneScreenMsg, //ActorControlPacket143 controlPacket( pPlayer, ActorControlType::DespawnZoneScreenMsg,
// 0x03, pPlayer->getId(), 0x01, targetZone ); // 0x03, player.getId(), 0x01, targetZone );
pPlayer->queuePacket( preparePacket ); player.queuePacket( preparePacket );
} }
else else
{ {
// No zoneline found, revert to last zone // No zoneline found, revert to last zone
pPlayer->sendUrgent( "ZoneLine " + std::to_string( zoneLineId ) + " not found." ); player.sendUrgent( "ZoneLine " + std::to_string( zoneLineId ) + " not found." );
targetPos.x = 0; targetPos.x = 0;
targetPos.y = 0; targetPos.y = 0;
targetPos.z = 0; targetPos.z = 0;
targetZone = pZone->getId(); targetZone = pZone->getId();
} }
pPlayer->performZoning( targetZone, targetPos, rotation); player.performZoning( targetZone, targetPos, rotation);
} }
void Core::Network::GameConnection::discoveryHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::discoveryHandler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
uint32_t ref_position_id = inPacket.getValAt< uint32_t >( 0x20 ); uint32_t ref_position_id = inPacket.getValAt< uint32_t >( 0x20 );
@ -344,47 +342,47 @@ void Core::Network::GameConnection::discoveryHandler( const Packets::GamePacket&
if( !pQR->next() ) if( !pQR->next() )
{ {
pPlayer->sendNotice( "Discovery ref pos ID: " + std::to_string( ref_position_id ) + " not found. " ); player.sendNotice( "Discovery ref pos ID: " + std::to_string( ref_position_id ) + " not found. " );
return; return;
} }
ZoneChannelPacket< FFXIVIpcDiscovery > discoveryPacket( pPlayer->getId() ); ZoneChannelPacket< FFXIVIpcDiscovery > discoveryPacket( player.getId() );
discoveryPacket.data().map_id = pQR->getUInt( 2 ); discoveryPacket.data().map_id = pQR->getUInt( 2 );
discoveryPacket.data().map_part_id = pQR->getUInt( 3 ); discoveryPacket.data().map_part_id = pQR->getUInt( 3 );
pPlayer->queuePacket( discoveryPacket ); player.queuePacket( discoveryPacket );
pPlayer->sendNotice( "Discovery ref pos ID: " + std::to_string( ref_position_id ) ); player.sendNotice( "Discovery ref pos ID: " + std::to_string( ref_position_id ) );
pPlayer->discover( pQR->getUInt16( 2 ), pQR->getUInt16( 3 ) ); player.discover( pQR->getUInt16( 2 ), pQR->getUInt16( 3 ) );
} }
void Core::Network::GameConnection::playTimeHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::playTimeHandler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
ZoneChannelPacket< FFXIVIpcPlayTime > playTimePacket( pPlayer->getId() ); ZoneChannelPacket< FFXIVIpcPlayTime > playTimePacket( player.getId() );
playTimePacket.data().playTimeInMinutes = pPlayer->getPlayTime() / 60; playTimePacket.data().playTimeInMinutes = player.getPlayTime() / 60;
pPlayer->queuePacket( playTimePacket ); player.queuePacket( playTimePacket );
} }
void Core::Network::GameConnection::initHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::initHandler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
// init handler means this is a login procedure // init handler means this is a login procedure
pPlayer->setIsLogin( true ); player.setIsLogin( true );
pPlayer->setZone( pPlayer->getZoneId() ); player.setZone( player.getZoneId() );
} }
void Core::Network::GameConnection::blackListHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::blackListHandler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
uint8_t count = inPacket.getValAt< uint8_t >( 0x21 ); uint8_t count = inPacket.getValAt< uint8_t >( 0x21 );
ZoneChannelPacket< FFXIVIpcBlackList > blackListPacket( pPlayer->getId() ); ZoneChannelPacket< FFXIVIpcBlackList > blackListPacket( player.getId() );
blackListPacket.data().sequence = count; blackListPacket.data().sequence = count;
// TODO: Fill with actual blacklist data // TODO: Fill with actual blacklist data
//blackListPacket.data().entry[0].contentId = 1; //blackListPacket.data().entry[0].contentId = 1;
@ -395,39 +393,39 @@ void Core::Network::GameConnection::blackListHandler( const Packets::GamePacket&
void Core::Network::GameConnection::pingHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::pingHandler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
int32_t inVal = inPacket.getValAt< int32_t >( 0x20 ); int32_t inVal = inPacket.getValAt< int32_t >( 0x20 );
PingPacket pingPacket( pPlayer, inVal ); PingPacket pingPacket( player, inVal );
queueOutPacket( pingPacket ); queueOutPacket( pingPacket );
pPlayer->setLastPing( static_cast< uint32_t >( time( nullptr ) ) ); player.setLastPing( static_cast< uint32_t >( time( nullptr ) ) );
} }
void Core::Network::GameConnection::finishLoadingHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::finishLoadingHandler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
// player is done zoning // player is done zoning
pPlayer->setLoadingComplete( true ); player.setLoadingComplete( true );
// if this is a login event // if this is a login event
if( pPlayer->isLogin() ) if( player.isLogin() )
{ {
// fire the onLogin Event // fire the onLogin Event
pPlayer->onLogin(); player.onLogin();
pPlayer->setIsLogin( false ); player.setIsLogin( false );
} }
// spawn the player for himself // spawn the player for himself
pPlayer->spawn( pPlayer ); player.spawn( player.getAsPlayer() );
// notify the zone of a change in position to force an "inRangeActor" update // notify the zone of a change in position to force an "inRangeActor" update
pPlayer->getCurrentZone()->changeActorPosition( pPlayer ); player.getCurrentZone()->changeActorPosition( player.getAsPlayer() );
} }
void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
uint8_t type = inPacket.getValAt< uint8_t >( 0x2A ); uint8_t type = inPacket.getValAt< uint8_t >( 0x2A );
@ -436,7 +434,7 @@ void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket
if( type == 0x02 ) if( type == 0x02 )
{ // party list { // party list
ZoneChannelPacket< FFXIVIpcSocialList > listPacket( pPlayer->getId() );; ZoneChannelPacket< FFXIVIpcSocialList > listPacket( player.getId() );
listPacket.data().type = 2; listPacket.data().type = 2;
listPacket.data().sequence = count; listPacket.data().sequence = count;
@ -444,26 +442,26 @@ void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket
int32_t entrysizes = sizeof( listPacket.data().entries ); int32_t entrysizes = sizeof( listPacket.data().entries );
memset( listPacket.data().entries, 0, sizeof( listPacket.data().entries ) ); memset( listPacket.data().entries, 0, sizeof( listPacket.data().entries ) );
listPacket.data().entries[0].bytes[2] = pPlayer->getCurrentZone()->getId(); listPacket.data().entries[0].bytes[2] = player.getCurrentZone()->getId();
listPacket.data().entries[0].bytes[3] = 0x80; listPacket.data().entries[0].bytes[3] = 0x80;
listPacket.data().entries[0].bytes[4] = 0x02; listPacket.data().entries[0].bytes[4] = 0x02;
listPacket.data().entries[0].bytes[6] = 0x3B; listPacket.data().entries[0].bytes[6] = 0x3B;
listPacket.data().entries[0].bytes[11] = 0x10; listPacket.data().entries[0].bytes[11] = 0x10;
listPacket.data().entries[0].classJob = static_cast< uint8_t >( pPlayer->getClass() ); listPacket.data().entries[0].classJob = static_cast< uint8_t >( player.getClass() );
listPacket.data().entries[0].contentId = pPlayer->getContentId(); listPacket.data().entries[0].contentId = player.getContentId();
listPacket.data().entries[0].level = pPlayer->getLevel(); listPacket.data().entries[0].level = player.getLevel();
listPacket.data().entries[0].zoneId = pPlayer->getCurrentZone()->getId(); listPacket.data().entries[0].zoneId = player.getCurrentZone()->getId();
listPacket.data().entries[0].zoneId1 = 0x0100; listPacket.data().entries[0].zoneId1 = 0x0100;
// TODO: no idea what this does // TODO: no idea what this does
//listPacket.data().entries[0].one = 1; //listPacket.data().entries[0].one = 1;
memcpy( listPacket.data().entries[0].name, pPlayer->getName().c_str(), strlen( pPlayer->getName().c_str() ) ); memcpy( listPacket.data().entries[0].name, player.getName().c_str(), strlen( player.getName().c_str() ) );
// TODO: actually store and read language from somewhere // TODO: actually store and read language from somewhere
listPacket.data().entries[0].bytes1[0] = 0x01;//flags (lang) listPacket.data().entries[0].bytes1[0] = 0x01;//flags (lang)
// TODO: these flags need to be figured out // TODO: these flags need to be figured out
//listPacket.data().entries[0].bytes1[1] = 0x00;//flags //listPacket.data().entries[0].bytes1[1] = 0x00;//flags
listPacket.data().entries[0].onlineStatusMask = pPlayer->getOnlineStatusMask(); listPacket.data().entries[0].onlineStatusMask = player.getOnlineStatusMask();
queueOutPacket( listPacket ); queueOutPacket( listPacket );
@ -471,7 +469,7 @@ void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket
else if( type == 0x0b ) else if( type == 0x0b )
{ // friend list { // friend list
ZoneChannelPacket< FFXIVIpcSocialList > listPacket( pPlayer->getId() ); ZoneChannelPacket< FFXIVIpcSocialList > listPacket( player.getId() );
listPacket.data().type = 0x0B; listPacket.data().type = 0x0B;
listPacket.data().sequence = count; listPacket.data().sequence = count;
memset( listPacket.data().entries, 0, sizeof( listPacket.data().entries ) ); memset( listPacket.data().entries, 0, sizeof( listPacket.data().entries ) );
@ -485,7 +483,7 @@ void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket
} }
void Core::Network::GameConnection::chatHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::chatHandler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
std::string chatString( inPacket.getStringAt( 0x3a ) ); std::string chatString( inPacket.getStringAt( 0x3a ) );
@ -495,35 +493,35 @@ void Core::Network::GameConnection::chatHandler( const Packets::GamePacket& inPa
if( chatString.at( 0 ) == '!' ) if( chatString.at( 0 ) == '!' )
{ {
// execute game console command // execute game console command
g_gameCommandMgr.execCommand( const_cast< char * >( chatString.c_str() ) + 1, pPlayer ); g_gameCommandMgr.execCommand( const_cast< char * >( chatString.c_str() ) + 1, player );
return; return;
} }
ChatType chatType = static_cast<ChatType>( inPacket.getValAt< uint8_t >( 0x38 ) ); ChatType chatType = static_cast< ChatType >( inPacket.getValAt< uint8_t >( 0x38 ) );
//ToDo, need to implement sending GM chat types. //ToDo, need to implement sending GM chat types.
ChatPacket chatPacket( pPlayer, chatType, chatString ); ChatPacket chatPacket( player, chatType, chatString );
switch( chatType ) switch( chatType )
{ {
case ChatType::Say: case ChatType::Say:
{ {
pPlayer->getCurrentZone()->queueOutPacketForRange( pPlayer, 50, chatPacket ); player.getCurrentZone()->queueOutPacketForRange( player, 50, chatPacket );
break; break;
} }
case ChatType::Yell: case ChatType::Yell:
{ {
pPlayer->getCurrentZone()->queueOutPacketForRange(pPlayer, 6000, chatPacket); player.getCurrentZone()->queueOutPacketForRange( player, 6000, chatPacket );
break; break;
} }
case ChatType::Shout: case ChatType::Shout:
{ {
pPlayer->getCurrentZone()->queueOutPacketForRange( pPlayer, 6000, chatPacket ); player.getCurrentZone()->queueOutPacketForRange( player, 6000, chatPacket );
break; break;
} }
default: default:
{ {
pPlayer->getCurrentZone()->queueOutPacketForRange( pPlayer, 50, chatPacket ); player.getCurrentZone()->queueOutPacketForRange( player, 50, chatPacket );
break; break;
} }
} }
@ -535,19 +533,19 @@ void Core::Network::GameConnection::chatHandler( const Packets::GamePacket& inPa
// log right back in. // log right back in.
// Also the packet needs to be converted to an ipc structure // Also the packet needs to be converted to an ipc structure
void Core::Network::GameConnection::logoutHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::logoutHandler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
ZoneChannelPacket< FFXIVIpcLogout > logoutPacket( pPlayer->getId() ); ZoneChannelPacket< FFXIVIpcLogout > logoutPacket( player.getId() );
logoutPacket.data().flags1 = 0x02; logoutPacket.data().flags1 = 0x02;
logoutPacket.data().flags2 = 0x2000; logoutPacket.data().flags2 = 0x2000;
queueOutPacket( logoutPacket ); queueOutPacket( logoutPacket );
pPlayer->setMarkedForRemoval(); player.setMarkedForRemoval();
} }
void Core::Network::GameConnection::tellHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::tellHandler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
std::string targetPcName = inPacket.getStringAt( 0x21 ); std::string targetPcName = inPacket.getStringAt( 0x21 );
std::string msg = inPacket.getStringAt( 0x41 ); std::string msg = inPacket.getStringAt( 0x41 );
@ -556,7 +554,7 @@ void Core::Network::GameConnection::tellHandler( const Packets::GamePacket& inPa
if( !pSession ) if( !pSession )
{ {
ChatChannelPacket< FFXIVIpcTellErrNotFound > tellErrPacket( pPlayer->getId() ); ChatChannelPacket< FFXIVIpcTellErrNotFound > tellErrPacket( player.getId() );
strcpy( tellErrPacket.data().receipientName, targetPcName.c_str() ); strcpy( tellErrPacket.data().receipientName, targetPcName.c_str() );
sendSinglePacket( tellErrPacket ); sendSinglePacket( tellErrPacket );
@ -589,9 +587,9 @@ void Core::Network::GameConnection::tellHandler( const Packets::GamePacket& inPa
return; return;
} }
ChatChannelPacket< FFXIVIpcTell > tellPacket( pPlayer->getId() ); ChatChannelPacket< FFXIVIpcTell > tellPacket( player.getId() );
strcpy( tellPacket.data().msg, msg.c_str() ); strcpy( tellPacket.data().msg, msg.c_str() );
strcpy( tellPacket.data().receipientName, pPlayer->getName().c_str() ); strcpy( tellPacket.data().receipientName, player.getName().c_str() );
// TODO: do these have a meaning? // TODO: do these have a meaning?
//tellPacket.data().u1 = 0x92CD7337; //tellPacket.data().u1 = 0x92CD7337;
//tellPacket.data().u2a = 0x2E; //tellPacket.data().u2a = 0x2E;
@ -601,12 +599,12 @@ void Core::Network::GameConnection::tellHandler( const Packets::GamePacket& inPa
} }
void Core::Network::GameConnection::performNoteHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::performNoteHandler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
GamePacketNew< FFXIVIpcPerformNote, ServerZoneIpcType > performPacket( pPlayer->getId() ); ZoneChannelPacket< FFXIVIpcPerformNote > performPacket( player.getId() );
uint8_t inVal = inPacket.getValAt< uint8_t >( 0x20 ); auto inVal = inPacket.getDataAt( 0x20 );
memcpy( &performPacket.data().data[0], &inVal, 32 ); memcpy( &performPacket.data().data[0], inVal, 32 );
pPlayer->sendToInRangeSet( performPacket ); player.sendToInRangeSet( performPacket );
} }

View file

@ -1,34 +1,34 @@
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <src/servers/Server_Common/Network/CommonNetwork.h> #include <Server_Common/Network/CommonNetwork.h>
#include <src/servers/Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <src/servers/Server_Common/Network/PacketContainer.h> #include <Server_Common/Network/PacketContainer.h>
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include <boost/format.hpp> #include <boost/format.hpp>
#include "src/servers/Server_Zone/Network/GameConnection.h" #include "Network/GameConnection.h"
#include "src/servers/Server_Zone/Session.h" #include "Session.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ServerNoticePacket.h" #include "Network/PacketWrappers/ServerNoticePacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket142.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket143.h" #include "Network/PacketWrappers/ActorControlPacket143.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket144.h" #include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Network/PacketWrappers/MoveActorPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/PlayerStateFlagsPacket.h" #include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
#include "src/servers/Server_Zone/DebugCommand/DebugCommandHandler.h" #include "DebugCommand/DebugCommandHandler.h"
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
#include "src/servers/Server_Zone/Action/Action.h" #include "Action/Action.h"
#include "src/servers/Server_Zone/Action/ActionCast.h" #include "Action/ActionCast.h"
#include "src/servers/Server_Zone/Action/ActionMount.h" #include "Action/ActionMount.h"
#include "src/servers/Server_Zone/Script/ScriptManager.h" #include "Script/ScriptManager.h"
#include "Server_Zone/Network/PacketWrappers/MoveActorPacket.h"
extern Core::Scripting::ScriptManager g_scriptMgr; extern Core::Scripting::ScriptManager g_scriptMgr;
@ -40,7 +40,7 @@ using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server; using namespace Core::Network::Packets::Server;
void Core::Network::GameConnection::skillHandler( const Packets::GamePacket& inPacket, void Core::Network::GameConnection::skillHandler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer ) Entity::Player& player )
{ {
uint8_t type = inPacket.getValAt< uint32_t >( 0x21 ); uint8_t type = inPacket.getValAt< uint32_t >( 0x21 );
@ -49,7 +49,7 @@ void Core::Network::GameConnection::skillHandler( const Packets::GamePacket& inP
uint64_t targetId = inPacket.getValAt< uint64_t >( 0x30 ); uint64_t targetId = inPacket.getValAt< uint64_t >( 0x30 );
pPlayer->sendDebug( "Skill type:" + std::to_string( type ) ); player.sendDebug( "Skill type:" + std::to_string( type ) );
switch( type ) switch( type )
{ {
@ -58,16 +58,16 @@ void Core::Network::GameConnection::skillHandler( const Packets::GamePacket& inP
if( action < 1000000 ) // normal action if( action < 1000000 ) // normal action
{ {
std::string actionIdStr = boost::str( boost::format( "%|04X|" ) % action ); std::string actionIdStr = boost::str( boost::format( "%|04X|" ) % action );
pPlayer->sendDebug( "---------------------------------------" ); player.sendDebug( "---------------------------------------" );
pPlayer->sendDebug( "ActionHandler ( " + actionIdStr + " | " + player.sendDebug( "ActionHandler ( " + actionIdStr + " | " +
g_exdData.getActionInfo( action )->name + g_exdData.getActionInfo( action )->name +
" | " + std::to_string( targetId ) + " )" ); " | " + std::to_string( targetId ) + " )" );
pPlayer->queuePacket( ActorControlPacket142( pPlayer->getId(), ActorControlType::ActionStart, 0x01, action ) ); player.queuePacket( ActorControlPacket142( player.getId(), ActorControlType::ActionStart, 0x01, action ) );
if( action == 5 ) if( action == 5 )
{ {
auto currentAction = pPlayer->getCurrentAction(); auto currentAction = player.getCurrentAction();
// we should always have an action here, if not there is a bug // we should always have an action here, if not there is a bug
assert( currentAction ); assert( currentAction );
@ -75,22 +75,22 @@ void Core::Network::GameConnection::skillHandler( const Packets::GamePacket& inP
} }
else else
{ {
Core::Entity::ActorPtr targetActor = pPlayer; Core::Entity::ActorPtr targetActor = player.getAsPlayer();
if( targetId != pPlayer->getId() ) if( targetId != player.getId() )
{ {
targetActor = pPlayer->lookupTargetById( targetId ); targetActor = player.lookupTargetById( targetId );
} }
if( !pPlayer->actionHasCastTime( action ) ) if( !player.actionHasCastTime( action ) )
{ {
g_scriptMgr.onCastFinish( pPlayer, targetActor, action ); g_scriptMgr.onCastFinish( player, targetActor, action );
} }
else else
{ {
Action::ActionCastPtr pActionCast( new Action::ActionCast( pPlayer, targetActor, action ) ); Action::ActionCastPtr pActionCast( new Action::ActionCast( player.getAsPlayer(), targetActor, action ) );
pPlayer->setCurrentAction( pActionCast ); player.setCurrentAction( pActionCast );
pPlayer->sendDebug( "setCurrentAction()" ); player.sendDebug( "setCurrentAction()" );
pPlayer->getCurrentAction()->onStart(); player.getCurrentAction()->onStart();
} }
} }
} }
@ -104,7 +104,7 @@ void Core::Network::GameConnection::skillHandler( const Packets::GamePacket& inP
if( info ) if( info )
{ {
g_log.debug( info->name ); g_log.debug( info->name );
g_scriptMgr.onEventItem( pPlayer, action, info->eventId, info->castTime, targetId ); g_scriptMgr.onEventItem( player, action, info->eventId, info->castTime, targetId );
} }
} }
else if( action > 3000000 ) // unknown else if( action > 3000000 ) // unknown
@ -116,12 +116,12 @@ void Core::Network::GameConnection::skillHandler( const Packets::GamePacket& inP
case Common::SkillType::MountSkill: case Common::SkillType::MountSkill:
pPlayer->sendDebug( "Request mount " + std::to_string( action ) ); player.sendDebug( "Request mount " + std::to_string( action ) );
Action::ActionMountPtr pActionMount( new Action::ActionMount(pPlayer, action) ); Action::ActionMountPtr pActionMount( new Action::ActionMount( player.getAsPlayer(), action ) );
pPlayer->setCurrentAction( pActionMount ); player.setCurrentAction( pActionMount );
pPlayer->sendDebug("setCurrentAction()"); player.sendDebug( "setCurrentAction()" );
pPlayer->getCurrentAction()->onStart(); player.getCurrentAction()->onStart();
break; break;

View file

@ -1,9 +1,9 @@
#ifndef _ACTORCONTROL142_H #ifndef _ACTORCONTROL142_H
#define _ACTORCONTROL142_H #define _ACTORCONTROL142_H
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <src/servers/Server_Common/Network/PacketDef/Zone/ServerZoneDef.h> #include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
namespace Core { namespace Core {
namespace Network { namespace Network {

View file

@ -1,9 +1,9 @@
#ifndef _ACTORCONTROL143_H #ifndef _ACTORCONTROL143_H
#define _ACTORCONTROL143_H #define _ACTORCONTROL143_H
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <src/servers/Server_Common/Network/PacketDef/Zone/ServerZoneDef.h> #include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
namespace Core { namespace Core {

View file

@ -1,8 +1,8 @@
#ifndef _ACTORCONTROL144_H #ifndef _ACTORCONTROL144_H
#define _ACTORCONTROL144_H #define _ACTORCONTROL144_H
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <src/servers/Server_Common/Network/PacketDef/Zone/ServerZoneDef.h> #include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
namespace Core { namespace Core {
namespace Network { namespace Network {

View file

@ -1,10 +1,10 @@
#ifndef _ACTORSPAWN_H #ifndef _ACTORSPAWN_H
#define _ACTORSPAWN_H #define _ACTORSPAWN_H
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <src/servers/Server_Common/Util/UtilMath.h> #include <Server_Common/Util/UtilMath.h>
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
namespace Core { namespace Core {
namespace Network { namespace Network {

View file

@ -1,9 +1,9 @@
#ifndef _CHATPACKET_H #ifndef _CHATPACKET_H
#define _CHATPACKET_H #define _CHATPACKET_H
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <src/servers/Server_Common/Network/PacketDef/Zone/ServerZoneDef.h> #include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
namespace Core { namespace Core {
@ -18,17 +18,17 @@ class ChatPacket :
public ZoneChannelPacket< FFXIVIpcChat > public ZoneChannelPacket< FFXIVIpcChat >
{ {
public: public:
ChatPacket( Entity::PlayerPtr player, Common::ChatType chatType, const std::string& msg ) : ChatPacket( Entity::Player& player, Common::ChatType chatType, const std::string& msg ) :
ZoneChannelPacket< FFXIVIpcChat >( player->getId(), player->getId() ) ZoneChannelPacket< FFXIVIpcChat >( player.getId(), player.getId() )
{ {
initialize( player, chatType, msg ); initialize( player, chatType, msg );
}; };
private: private:
void initialize( Entity::PlayerPtr player, Common::ChatType chatType, const std::string& msg ) void initialize( Entity::Player& player, Common::ChatType chatType, const std::string& msg )
{ {
m_data.chatType = chatType; m_data.chatType = chatType;
strcpy( m_data.name, player->getName().c_str() ); strcpy( m_data.name, player.getName().c_str() );
strcpy( m_data.msg, msg.c_str() ); strcpy( m_data.msg, msg.c_str() );
}; };
}; };

View file

@ -1,7 +1,7 @@
#ifndef _EVENTFINISH_H #ifndef _EVENTFINISH_H
#define _EVENTFINISH_H #define _EVENTFINISH_H
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
namespace Core { namespace Core {
namespace Network { namespace Network {

View file

@ -1,8 +1,8 @@
#ifndef _EVENTPLAY_H #ifndef _EVENTPLAY_H
#define _EVENTPLAY_H #define _EVENTPLAY_H
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
namespace Core { namespace Core {
namespace Network { namespace Network {

View file

@ -1,8 +1,8 @@
#ifndef _EVENTSTART_H #ifndef _EVENTSTART_H
#define _EVENTSTART_H #define _EVENTSTART_H
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
namespace Core { namespace Core {
namespace Network { namespace Network {

View file

@ -1,10 +1,10 @@
#ifndef _CORE_NETWORK_PACKETS_INITUIPACKET_H #ifndef _CORE_NETWORK_PACKETS_INITUIPACKET_H
#define _CORE_NETWORK_PACKETS_INITUIPACKET_H #define _CORE_NETWORK_PACKETS_INITUIPACKET_H
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <src/servers/Server_Common/Network/PacketDef/Zone/ServerZoneDef.h> #include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include "Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "Server_Zone/Forwards.h" #include "Forwards.h"
namespace Core { namespace Core {
namespace Network { namespace Network {
@ -18,59 +18,59 @@ namespace Server {
class InitUIPacket : public ZoneChannelPacket< FFXIVIpcInitUI > class InitUIPacket : public ZoneChannelPacket< FFXIVIpcInitUI >
{ {
public: public:
InitUIPacket( Entity::PlayerPtr player ) : InitUIPacket( Entity::Player& player ) :
ZoneChannelPacket< FFXIVIpcInitUI >( player->getId(), player->getId() ) ZoneChannelPacket< FFXIVIpcInitUI >( player.getId(), player.getId() )
{ {
initialize( player ); initialize( player );
}; };
private: private:
void initialize( Entity::PlayerPtr player ) void initialize( Entity::Player& player )
{ {
m_data.contentId = player->getContentId(); m_data.contentId = player.getContentId();
// TODO: Support rested experience. // TODO: Support rested experience.
m_data.restedExp = 0; m_data.restedExp = 0;
//m_data.padding = 0x100; //m_data.padding = 0x100;
m_data.charId = player->getId(); m_data.charId = player.getId();
m_data.race = player->getLookAt( Common::CharaLook::Race ); m_data.race = player.getLookAt( Common::CharaLook::Race );
m_data.tribe = player->getLookAt( Common::CharaLook::Tribe ); m_data.tribe = player.getLookAt( Common::CharaLook::Tribe );
m_data.gender = player->getLookAt( Common::CharaLook::Gender ); m_data.gender = player.getLookAt( Common::CharaLook::Gender );
m_data.currentClass = static_cast< uint8_t >( player->getClass() ); m_data.currentClass = static_cast< uint8_t >( player.getClass() );
m_data.currentJob = static_cast< uint8_t >( player->getClass() ); m_data.currentJob = static_cast< uint8_t >( player.getClass() );
m_data.deity = static_cast< uint8_t >( player->getGuardianDeity() ); m_data.deity = static_cast< uint8_t >( player.getGuardianDeity() );
m_data.namedayMonth = player->getBirthMonth(); m_data.namedayMonth = player.getBirthMonth();
m_data.namedayDay = player->getBirthDay(); m_data.namedayDay = player.getBirthDay();
// TODO: Support grand company status. // TODO: Support grand company status.
m_data.grandCompany = static_cast< Common::GrandCompany >( player->getGc() ); m_data.grandCompany = static_cast< Common::GrandCompany >( player.getGc() );
//m_data.gcRank = GCRank::None; //m_data.gcRank = GCRank::None;
// TODO: Support starting city. // TODO: Support starting city.
//m_data.startCity = Town::Gridania; //m_data.startCity = Town::Gridania;
m_data.homepoint = player->getHomepoint(); m_data.homepoint = player.getHomepoint();
memset( &m_data.name[0], 0, sizeof( m_data.name ) ); memset( &m_data.name[0], 0, sizeof( m_data.name ) );
strcpy( &m_data.name[0], player->getName().c_str() ); strcpy( &m_data.name[0], player.getName().c_str() );
memcpy( m_data.aetheryte, player->getAetheryteArray(), sizeof ( m_data.aetheryte ) ); memcpy( m_data.aetheryte, player.getAetheryteArray(), sizeof ( m_data.aetheryte ) );
// Set the class levels and exp. // Set the class levels and exp.
for( uint8_t i = 0; i < 25; i++ ) for( uint8_t i = 0; i < 25; i++ )
{ {
m_data.levels[i] = player->getClassArray()[i]; m_data.levels[i] = player.getClassArray()[i];
m_data.exp[i] = player->getExpArray()[i]; m_data.exp[i] = player.getExpArray()[i];
} }
memcpy( m_data.orchestrionMask, player->getOrchestrionBitmask(), sizeof( m_data.orchestrionMask ) ); memcpy( m_data.orchestrionMask, player.getOrchestrionBitmask(), sizeof( m_data.orchestrionMask ) );
memcpy( m_data.mountGuideMask, player->getMountGuideBitmask(), sizeof( m_data.mountGuideMask) ); memcpy( m_data.mountGuideMask, player.getMountGuideBitmask(), sizeof( m_data.mountGuideMask) );
memcpy( m_data.unlockBitmask, player->getUnlockBitmask(), sizeof( m_data.unlockBitmask ) ); memcpy( m_data.unlockBitmask, player.getUnlockBitmask(), sizeof( m_data.unlockBitmask ) );
memcpy( m_data.discovery, player->getDiscoveryBitmask(), sizeof( m_data.discovery ) ); memcpy( m_data.discovery, player.getDiscoveryBitmask(), sizeof( m_data.discovery ) );
memcpy( m_data.howto, player->getHowToArray(), sizeof( m_data.howto ) ); memcpy( m_data.howto, player.getHowToArray(), sizeof( m_data.howto ) );
m_data.unknown_13 = 0x46; m_data.unknown_13 = 0x46;
m_data.expansion = 2; m_data.expansion = 2;

View file

@ -1,9 +1,9 @@
#ifndef _MODELEQUIPPACKET_H #ifndef _MODELEQUIPPACKET_H
#define _MODELEQUIPPACKET_H #define _MODELEQUIPPACKET_H
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
namespace Core { namespace Core {
namespace Network { namespace Network {
@ -17,22 +17,22 @@ class ModelEquipPacket :
public ZoneChannelPacket< FFXIVIpcModelEquip > public ZoneChannelPacket< FFXIVIpcModelEquip >
{ {
public: public:
ModelEquipPacket( Entity::PlayerPtr player ) : ModelEquipPacket( Entity::Player& player ) :
ZoneChannelPacket< FFXIVIpcModelEquip >( player->getId(), player->getId() ) ZoneChannelPacket< FFXIVIpcModelEquip >( player.getId(), player.getId() )
{ {
initialize( player ); initialize( player );
}; };
private: private:
void initialize( Entity::PlayerPtr player ) void initialize( Entity::Player& player )
{ {
m_data.mainWeapon = player->getModelMainWeapon(); m_data.mainWeapon = player.getModelMainWeapon();
m_data.offWeapon = player->getModelSubWeapon(); m_data.offWeapon = player.getModelSubWeapon();
m_data.models[0] = player->getModelForSlot( Inventory::EquipSlot::Head ); m_data.models[0] = player.getModelForSlot( Inventory::EquipSlot::Head );
m_data.models[1] = player->getModelForSlot( Inventory::EquipSlot::Body ); m_data.models[1] = player.getModelForSlot( Inventory::EquipSlot::Body );
m_data.models[2] = player->getModelForSlot( Inventory::EquipSlot::Hands ); m_data.models[2] = player.getModelForSlot( Inventory::EquipSlot::Hands );
m_data.models[3] = player->getModelForSlot( Inventory::EquipSlot::Legs ); m_data.models[3] = player.getModelForSlot( Inventory::EquipSlot::Legs );
m_data.models[4] = player->getModelForSlot( Inventory::EquipSlot::Feet ); m_data.models[4] = player.getModelForSlot( Inventory::EquipSlot::Feet );
}; };
}; };

View file

@ -1,11 +1,11 @@
#ifndef _MOVEACTORPACKET_H #ifndef _MOVEACTORPACKET_H
#define _MOVEACTORPACKET_H #define _MOVEACTORPACKET_H
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <src/servers/Server_Common/Network/PacketDef/Zone/ServerZoneDef.h> #include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include <src/servers/Server_Common/Util/UtilMath.h> #include <Server_Common/Util/UtilMath.h>
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
namespace Core { namespace Core {
@ -21,24 +21,24 @@ class MoveActorPacket :
public ZoneChannelPacket< FFXIVIpcActorMove > public ZoneChannelPacket< FFXIVIpcActorMove >
{ {
public: public:
MoveActorPacket( Entity::ActorPtr actor, uint8_t unk1, uint8_t unk2, uint8_t unk3, uint16_t unk4 ) : MoveActorPacket( Entity::Actor& actor, uint8_t unk1, uint8_t unk2, uint8_t unk3, uint16_t unk4 ) :
ZoneChannelPacket< FFXIVIpcActorMove >( actor->getId(), actor->getId() ) ZoneChannelPacket< FFXIVIpcActorMove >( actor.getId(), actor.getId() )
{ {
initialize( actor, unk1, unk2, unk3, unk4 ); initialize( actor, unk1, unk2, unk3, unk4 );
}; };
private: private:
void initialize( Entity::ActorPtr actor, uint8_t unk1, uint8_t unk2, uint8_t unk3, uint16_t unk4 ) void initialize( Entity::Actor& actor, uint8_t unk1, uint8_t unk2, uint8_t unk3, uint16_t unk4 )
{ {
m_data.rotation = Math::Util::floatToUInt8Rot( actor->getRotation() ); m_data.rotation = Math::Util::floatToUInt8Rot( actor.getRotation() );
m_data.unknown_1 = unk1; m_data.unknown_1 = unk1;
m_data.unknown_2 = unk2; m_data.unknown_2 = unk2;
m_data.unknown_3 = unk3; m_data.unknown_3 = unk3;
m_data.unknown_4 = unk4; m_data.unknown_4 = unk4;
m_data.posX = Math::Util::floatToUInt16( actor->getPos().x ); m_data.posX = Math::Util::floatToUInt16( actor.getPos().x );
m_data.posY = Math::Util::floatToUInt16( actor->getPos().y ); m_data.posY = Math::Util::floatToUInt16( actor.getPos().y );
m_data.posZ = Math::Util::floatToUInt16( actor->getPos().z ); m_data.posZ = Math::Util::floatToUInt16( actor.getPos().z );
}; };
}; };

View file

@ -1,9 +1,9 @@
#ifndef _CORE_NETWORK_PACKETS_PINGPACKET_H #ifndef _CORE_NETWORK_PACKETS_PINGPACKET_H
#define _CORE_NETWORK_PACKETS_PINGPACKET_H #define _CORE_NETWORK_PACKETS_PINGPACKET_H
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
namespace Core { namespace Core {
namespace Network { namespace Network {
@ -17,14 +17,14 @@ class PingPacket :
public ZoneChannelPacket< FFXIVIpcPing > public ZoneChannelPacket< FFXIVIpcPing >
{ {
public: public:
PingPacket( Entity::PlayerPtr player, int32_t inVal ) : PingPacket( Entity::Player& player, int32_t inVal ) :
ZoneChannelPacket< FFXIVIpcPing >( player->getId(), player->getId() ) ZoneChannelPacket< FFXIVIpcPing >( player.getId(), player.getId() )
{ {
initialize( player, inVal ); initialize( player, inVal );
}; };
private: private:
void initialize( Entity::PlayerPtr player, int32_t inVal ) void initialize( Entity::Player& player, int32_t inVal )
{ {
m_data.timeInMilliseconds = 0x000014D00000000 + inVal; m_data.timeInMilliseconds = 0x000014D00000000 + inVal;
}; };

View file

@ -1,15 +1,14 @@
#ifndef _PLAYERSPAWN_H #ifndef _PLAYERSPAWN_H
#define _PLAYERSPAWN_H #define _PLAYERSPAWN_H
#include <src/servers/Server_Common/Network/PacketDef/Zone/ServerZoneDef.h> #include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <src/servers/Server_Common/Util/UtilMath.h> #include <Server_Common/Util/UtilMath.h>
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
#include "src/servers/Server_Zone/Inventory/Inventory.h" #include "Inventory/Inventory.h"
#include "src/servers/Server_Zone/Inventory/Item.h" #include "Inventory/Item.h"
#include "src/servers/Server_Zone/StatusEffect/StatusEffectContainer.h" #include "StatusEffect/StatusEffect.h"
#include "src/servers/Server_Zone/StatusEffect/StatusEffect.h"
namespace Core { namespace Core {
namespace Network { namespace Network {
@ -23,97 +22,97 @@ namespace Server {
public GamePacketNew< FFXIVIpcPlayerSpawn, ServerZoneIpcType > public GamePacketNew< FFXIVIpcPlayerSpawn, ServerZoneIpcType >
{ {
public: public:
PlayerSpawnPacket( Entity::PlayerPtr pPlayer, Entity::PlayerPtr pTarget ) : PlayerSpawnPacket( Entity::Player& player, Entity::Player& target ) :
GamePacketNew< FFXIVIpcPlayerSpawn, ServerZoneIpcType >( pPlayer->getId(), pTarget->getId() ) GamePacketNew< FFXIVIpcPlayerSpawn, ServerZoneIpcType >( player.getId(), target.getId() )
{ {
initialize( pPlayer, pTarget ); initialize( player, target );
}; };
private: private:
void initialize( Entity::PlayerPtr pPlayer, Entity::PlayerPtr pTarget ) void initialize( Entity::Player& player, Entity::Player& target )
{ {
// todo: figure out unkown offsets // todo: figure out unkown offsets
// TODO: temporary gm rank // TODO: temporary gm rank
//m_data.gmRank = 0xff; //m_data.gmRank = 0xff;
m_data.classJob = static_cast< uint8_t >( pPlayer->getClass() ); m_data.classJob = static_cast< uint8_t >( player.getClass() );
//m_data.status = static_cast< uint8_t >( pPlayer->getStatus() ); //m_data.status = static_cast< uint8_t >( pPlayer->getStatus() );
m_data.hPCurr = pPlayer->getHp(); m_data.hPCurr = player.getHp();
m_data.mPCurr = pPlayer->getMp(); m_data.mPCurr = player.getMp();
m_data.tPCurr = pPlayer->getTp(); m_data.tPCurr = player.getTp();
m_data.hPMax = pPlayer->getMaxHp(); m_data.hPMax = player.getMaxHp();
m_data.mPMax = pPlayer->getMaxMp(); m_data.mPMax = player.getMaxMp();
//m_data.tPMax = 3000; //m_data.tPMax = 3000;
m_data.level = pPlayer->getLevel(); m_data.level = player.getLevel();
m_data.gmRank = pPlayer->getGmRank(); m_data.gmRank = player.getGmRank();
m_data.pose = 0; m_data.pose = 0;
memcpy( m_data.look, pPlayer->getLookArray(), 26 ); memcpy( m_data.look, player.getLookArray(), 26 );
auto item = pPlayer->getInventory()->getItemAt( Inventory::GearSet0, Inventory::EquipSlot::MainHand ); auto item = player.getInventory()->getItemAt( Inventory::GearSet0, Inventory::EquipSlot::MainHand );
if( item ) if( item )
m_data.mainWeaponModel = item->getModelId1(); m_data.mainWeaponModel = item->getModelId1();
m_data.secWeaponModel = pPlayer->getModelSubWeapon(); m_data.secWeaponModel = player.getModelSubWeapon();
m_data.models[0] = pPlayer->getModelForSlot( Inventory::EquipSlot::Head ); m_data.models[0] = player.getModelForSlot( Inventory::EquipSlot::Head );
m_data.models[1] = pPlayer->getModelForSlot( Inventory::EquipSlot::Body ); m_data.models[1] = player.getModelForSlot( Inventory::EquipSlot::Body );
m_data.models[2] = pPlayer->getModelForSlot( Inventory::EquipSlot::Hands ); m_data.models[2] = player.getModelForSlot( Inventory::EquipSlot::Hands );
m_data.models[3] = pPlayer->getModelForSlot( Inventory::EquipSlot::Legs ); m_data.models[3] = player.getModelForSlot( Inventory::EquipSlot::Legs );
m_data.models[4] = pPlayer->getModelForSlot( Inventory::EquipSlot::Feet ); m_data.models[4] = player.getModelForSlot( Inventory::EquipSlot::Feet );
strcpy( m_data.name, pPlayer->getName().c_str() ); strcpy( m_data.name, player.getName().c_str() );
m_data.pos.x = pPlayer->getPos().x; m_data.pos.x = player.getPos().x;
m_data.pos.y = pPlayer->getPos().y; m_data.pos.y = player.getPos().y;
m_data.pos.z = pPlayer->getPos().z; m_data.pos.z = player.getPos().z;
m_data.rotation = Math::Util::floatToUInt16Rot( pPlayer->getRotation() ); m_data.rotation = Math::Util::floatToUInt16Rot( player.getRotation() );
m_data.title = pPlayer->getTitle(); m_data.title = player.getTitle();
m_data.voice = pPlayer->getVoiceId(); m_data.voice = player.getVoiceId();
m_data.currentMount = pPlayer->getCurrentMount(); m_data.currentMount = player.getCurrentMount();
m_data.onlineStatus = static_cast< uint8_t >( pPlayer->getOnlineStatus() ); m_data.onlineStatus = static_cast< uint8_t >( player.getOnlineStatus() );
//m_data.u23 = 0x04; //m_data.u23 = 0x04;
//m_data.u24 = 256; //m_data.u24 = 256;
m_data.state = static_cast< uint8_t >( pPlayer->getStatus() ); m_data.state = static_cast< uint8_t >( player.getStatus() );
m_data.type = 1; m_data.type = 1;
if( pTarget == pPlayer ) if( target.getId() == player.getId() )
{ {
m_data.spawnIndex = 0x00; m_data.spawnIndex = 0x00;
} }
else else
{ {
m_data.spawnIndex = pTarget->getSpawnIdForActorId( pPlayer->getId() ); m_data.spawnIndex = target.getSpawnIdForActorId( player.getId() );
} }
// 0x20 == spawn hidden to be displayed by the spawneffect control // 0x20 == spawn hidden to be displayed by the spawneffect control
m_data.displayFlags = pPlayer->getStance(); m_data.displayFlags = player.getStance();
if( pPlayer->getZoningType() != Common::ZoneingType::None ) if( player.getZoningType() != Common::ZoneingType::None )
{ {
m_data.displayFlags |= Entity::Actor::DisplayFlags::Invisible; m_data.displayFlags |= Entity::Actor::DisplayFlags::Invisible;
} }
if( pPlayer->getEquipDisplayFlags() & Core::Common::EquipDisplayFlags::HideHead ) if( player.getEquipDisplayFlags() & Core::Common::EquipDisplayFlags::HideHead )
{ {
m_data.displayFlags |= Entity::Actor::DisplayFlags::HideHead; m_data.displayFlags |= Entity::Actor::DisplayFlags::HideHead;
} }
if( pPlayer->getEquipDisplayFlags() & Core::Common::EquipDisplayFlags::HideWeapon ) if( player.getEquipDisplayFlags() & Core::Common::EquipDisplayFlags::HideWeapon )
{ {
m_data.displayFlags |= Entity::Actor::DisplayFlags::HideWeapon; m_data.displayFlags |= Entity::Actor::DisplayFlags::HideWeapon;
} }
if( pPlayer->getEquipDisplayFlags() & Core::Common::EquipDisplayFlags::Visor ) if( player.getEquipDisplayFlags() & Core::Common::EquipDisplayFlags::Visor )
{ {
m_data.displayFlags |= Entity::Actor::DisplayFlags::Visor; m_data.displayFlags |= Entity::Actor::DisplayFlags::Visor;
} }
m_data.currentMount = pPlayer->getCurrentMount(); m_data.currentMount = player.getCurrentMount();
m_data.targetId = pPlayer->getTargetId(); m_data.targetId = player.getTargetId();
//m_data.type = 1; //m_data.type = 1;
//m_data.unknown_33 = 4; //m_data.unknown_33 = 4;
//m_data.unknown_38 = 0x70; //m_data.unknown_38 = 0x70;
@ -122,10 +121,11 @@ namespace Server {
uint64_t currentTimeMs = Util::getTimeMs(); uint64_t currentTimeMs = Util::getTimeMs();
for( auto const& effect : pPlayer->getStatusEffectContainer()->getEffectMap() ) for( auto const& effect : player.getStatusEffectMap() )
{ {
m_data.effect[effect.first].effect_id = effect.second->getId(); m_data.effect[effect.first].effect_id = effect.second->getId();
m_data.effect[effect.first].duration = static_cast< float >( effect.second->getDuration() - ( 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].sourceActorId = effect.second->getSrcActorId();
m_data.effect[effect.first].unknown1 = effect.second->getParam(); m_data.effect[effect.first].unknown1 = effect.second->getParam();
} }

View file

@ -1,9 +1,9 @@
#ifndef _PLAYERSTATE_H #ifndef _PLAYERSTATE_H
#define _PLAYERSTATE_H #define _PLAYERSTATE_H
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
namespace Core { namespace Core {
namespace Network { namespace Network {
@ -17,14 +17,14 @@ class PlayerStateFlagsPacket :
public ZoneChannelPacket< FFXIVIpcPlayerStateFlags > public ZoneChannelPacket< FFXIVIpcPlayerStateFlags >
{ {
public: public:
PlayerStateFlagsPacket( Entity::PlayerPtr pActor ) : PlayerStateFlagsPacket( Entity::Player& player ) :
ZoneChannelPacket< FFXIVIpcPlayerStateFlags >( pActor->getId(), pActor->getId() ) ZoneChannelPacket< FFXIVIpcPlayerStateFlags >( player.getId(), player.getId() )
{ {
initialize( pActor->getStateFlags() ); initialize( player.getStateFlags() );
} }
PlayerStateFlagsPacket( Entity::PlayerPtr pActor, std::vector< Common::PlayerStateFlag > flags ) : PlayerStateFlagsPacket( Entity::Player& player, std::vector< Common::PlayerStateFlag > flags ) :
ZoneChannelPacket< FFXIVIpcPlayerStateFlags >( pActor->getId(), pActor->getId() ) ZoneChannelPacket< FFXIVIpcPlayerStateFlags >( player.getId(), player.getId() )
{ {
uint8_t newFlags[7]; uint8_t newFlags[7];
memset( newFlags, 0, 7 ); memset( newFlags, 0, 7 );

View file

@ -1,9 +1,9 @@
#ifndef _QUESTMESSAGE_H #ifndef _QUESTMESSAGE_H
#define _QUESTMESSAGE_H #define _QUESTMESSAGE_H
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
namespace Core { namespace Core {
namespace Network { namespace Network {

View file

@ -1,9 +1,9 @@
#ifndef _SERVERNOTICEPACKET_H #ifndef _SERVERNOTICEPACKET_H
#define _SERVERNOTICEPACKET_H #define _SERVERNOTICEPACKET_H
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <src/servers/Server_Common/Network/PacketDef/Zone/ServerZoneDef.h> #include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
namespace Core { namespace Core {
namespace Network { namespace Network {

View file

@ -1,9 +1,9 @@
#ifndef _UPDATEHPMPTP_H #ifndef _UPDATEHPMPTP_H
#define _UPDATEHPMPTP_H #define _UPDATEHPMPTP_H
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <src/servers/Server_Zone/Actor/Actor.h> #include <Actor/Actor.h>
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
namespace Core { namespace Core {
namespace Network { namespace Network {

View file

@ -1,18 +1,18 @@
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include <src/servers/Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <chaiscript/chaiscript.hpp> #include <chaiscript/chaiscript.hpp>
#include <src/servers/Server_Common/Script/ChaiscriptStdLib.h> #include <Server_Common/Script/ChaiscriptStdLib.h>
#include "src/servers/Server_Zone/Zone/Zone.h" #include "Zone/Zone.h"
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "src/servers/Server_Zone/Actor/BattleNpc.h" #include "Actor/BattleNpc.h"
#include "src/servers/Server_Zone/ServerZone.h" #include "ServerZone.h"
#include "src/servers/Server_Zone/Event/Event.h" #include "Event/Event.h"
#include "src/servers/Server_Zone/Event/EventHelper.h" #include "Event/EventHelper.h"
#include "src/servers/Server_Zone/StatusEffect/StatusEffect.h" #include "StatusEffect/StatusEffect.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ServerNoticePacket.h" #include "Network/PacketWrappers/ServerNoticePacket.h"
#include "src/servers/Server_Zone/Script/ScriptManager.h" #include "Script/ScriptManager.h"
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
@ -55,11 +55,11 @@ void Core::Scripting::ScriptManager::loadDir( std::string dirname, std::set<std:
} }
void Core::Scripting::ScriptManager::onPlayerFirstEnterWorld( Core::Entity::PlayerPtr pPlayer ) void Core::Scripting::ScriptManager::onPlayerFirstEnterWorld( Entity::Player& player )
{ {
try try
{ {
std::string test = m_onFirstEnterWorld( *pPlayer ); std::string test = m_onFirstEnterWorld( player );
} }
catch( const std::exception &e ) catch( const std::exception &e )
{ {
@ -87,18 +87,18 @@ const boost::shared_ptr< chaiscript::ChaiScript >& Core::Scripting::ScriptManage
} }
bool Core::Scripting::ScriptManager::onTalk( Core::Entity::PlayerPtr pPlayer, uint64_t actorId, uint32_t eventId ) bool Core::Scripting::ScriptManager::onTalk( Entity::Player& player, uint64_t actorId, uint32_t eventId )
{ {
std::string eventName = "onTalk"; std::string eventName = "onTalk";
std::string objName = Event::getEventName( eventId ); std::string objName = Event::getEventName( eventId );
pPlayer->sendDebug( "Actor: " + player.sendDebug( "Actor: " +
std::to_string( actorId ) + " -> " + std::to_string( actorId ) + " -> " +
std::to_string( Core::Event::mapEventActorToRealActor( static_cast< uint32_t >( actorId ) ) ) + std::to_string( Event::mapEventActorToRealActor( static_cast< uint32_t >( actorId ) ) ) +
" \neventId: " + " \neventId: " +
std::to_string( eventId ) + std::to_string( eventId ) +
" (0x" + boost::str( boost::format( "%|08X|" ) " (0x" + boost::str( boost::format( "%|08X|" )
% static_cast< uint64_t >( eventId & 0xFFFFFFF ) ) + ")" ); % static_cast< uint64_t >( eventId & 0xFFFFFFF ) ) + ")" );
uint16_t eventType = eventId >> 16; uint16_t eventType = eventId >> 16;
@ -106,26 +106,26 @@ bool Core::Scripting::ScriptManager::onTalk( Core::Entity::PlayerPtr pPlayer, ui
{ {
// Get object from engine // Get object from engine
auto obj = m_pChaiHandler->eval( objName ); auto obj = m_pChaiHandler->eval( objName );
pPlayer->sendDebug( "Calling: " + objName + "." + eventName ); player.sendDebug( "Calling: " + objName + "." + eventName );
pPlayer->eventStart( actorId, eventId, Event::Event::Talk, 0, 0 ); player.eventStart( actorId, eventId, Event::Event::Talk, 0, 0 );
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &,
uint32_t, Entity::Player&, uint64_t ) > >( eventName ); uint32_t, Entity::Player&, uint64_t ) > >( eventName );
fn( obj, eventId, *pPlayer, actorId ); fn( obj, eventId, player, actorId );
pPlayer->checkEvent( eventId ); player.checkEvent( eventId );
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
pPlayer->sendDebug( e.what( ) ); player.sendDebug( e.what( ) );
if( eventType == Common::EventType::Quest ) if( eventType == Common::EventType::Quest )
{ {
auto questInfo = g_exdData.getQuestInfo( eventId ); auto questInfo = g_exdData.getQuestInfo( eventId );
if( questInfo ) if( questInfo )
{ {
pPlayer->sendUrgent( "Quest not implemented: " + questInfo->name ); player.sendUrgent( "Quest not implemented: " + questInfo->name );
return false; return false;
} }
} }
@ -135,7 +135,7 @@ bool Core::Scripting::ScriptManager::onTalk( Core::Entity::PlayerPtr pPlayer, ui
return true; return true;
} }
bool Core::Scripting::ScriptManager::onEnterTerritory( Core::Entity::PlayerPtr pPlayer, uint32_t eventId, bool Core::Scripting::ScriptManager::onEnterTerritory( Entity::Player& player, uint32_t eventId,
uint16_t param1, uint16_t param2 ) uint16_t param1, uint16_t param2 )
{ {
std::string eventName = "onEnterTerritory"; std::string eventName = "onEnterTerritory";
@ -146,25 +146,25 @@ bool Core::Scripting::ScriptManager::onEnterTerritory( Core::Entity::PlayerPtr p
// Get object from engine // Get object from engine
auto obj = m_pChaiHandler->eval( objName ); auto obj = m_pChaiHandler->eval( objName );
pPlayer->sendDebug( "Calling: " + objName + "." + eventName ); player.sendDebug( "Calling: " + objName + "." + eventName );
pPlayer->eventStart( pPlayer->getId(), eventId, Event::Event::EnterTerritory, 0, pPlayer->getZoneId() ); player.eventStart( player.getId(), eventId, Event::Event::EnterTerritory, 0, player.getZoneId() );
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t, auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t,
Entity::Player&, uint16_t, uint16_t ) > >( eventName ); Entity::Player&, uint16_t, uint16_t ) > >( eventName );
fn( obj, eventId, *pPlayer, param1, param2 ); fn( obj, eventId, player, param1, param2 );
pPlayer->checkEvent( eventId ); player.checkEvent( eventId );
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
pPlayer->sendDebug( e.what() ); player.sendDebug( e.what() );
return false; return false;
} }
return true; return true;
} }
bool Core::Scripting::ScriptManager::onWithinRange( Entity::PlayerPtr pPlayer, uint32_t eventId, uint32_t param1, bool Core::Scripting::ScriptManager::onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1,
float x, float y, float z ) float x, float y, float z )
{ {
std::string eventName = "onWithinRange"; std::string eventName = "onWithinRange";
@ -175,25 +175,25 @@ bool Core::Scripting::ScriptManager::onWithinRange( Entity::PlayerPtr pPlayer, u
// Get object from engine // Get object from engine
auto obj = m_pChaiHandler->eval( Event::getEventName( eventId ) ); auto obj = m_pChaiHandler->eval( Event::getEventName( eventId ) );
pPlayer->sendDebug( "Calling: " + objName + "." + eventName ); player.sendDebug( "Calling: " + objName + "." + eventName );
pPlayer->eventStart( pPlayer->getId(), eventId, Event::Event::WithinRange, 1, param1 ); player.eventStart( player.getId(), eventId, Event::Event::WithinRange, 1, param1 );
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t, Entity::Player&, uint32_t, auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t, Entity::Player&, uint32_t,
float, float, float ) > >( eventName ); float, float, float ) > >( eventName );
fn( obj, eventId, *pPlayer, param1, x, y, z ); fn( obj, eventId, player, param1, x, y, z );
pPlayer->checkEvent( eventId ); player.checkEvent( eventId );
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
pPlayer->sendDebug( e.what() ); player.sendDebug( e.what() );
return false; return false;
} }
return true; return true;
} }
bool Core::Scripting::ScriptManager::onOutsideRange( Entity::PlayerPtr pPlayer, uint32_t eventId, uint32_t param1, bool Core::Scripting::ScriptManager::onOutsideRange( Entity::Player& player, uint32_t eventId, uint32_t param1,
float x, float y, float z ) float x, float y, float z )
{ {
std::string eventName = "onOutsideRange"; std::string eventName = "onOutsideRange";
@ -204,25 +204,25 @@ bool Core::Scripting::ScriptManager::onOutsideRange( Entity::PlayerPtr pPlayer,
// Get object from engine // Get object from engine
auto obj = m_pChaiHandler->eval( Event::getEventName( eventId ) ); auto obj = m_pChaiHandler->eval( Event::getEventName( eventId ) );
pPlayer->sendDebug( "Calling: " + objName + "." + eventName ); player.sendDebug( "Calling: " + objName + "." + eventName );
pPlayer->eventStart( pPlayer->getId(), eventId, Event::Event::OutsideRange, 1, param1 ); player.eventStart( player.getId(), eventId, Event::Event::OutsideRange, 1, param1 );
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t, Entity::Player&, uint32_t, auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t, Entity::Player&, uint32_t,
float, float, float ) > >( eventName ); float, float, float ) > >( eventName );
fn( obj, eventId, *pPlayer, param1, x, y, z ); fn( obj, eventId, player, param1, x, y, z );
pPlayer->checkEvent( eventId ); player.checkEvent( eventId );
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
pPlayer->sendDebug( e.what() ); player.sendDebug( e.what() );
return false; return false;
} }
return true; return true;
} }
bool Core::Scripting::ScriptManager::onEmote( Core::Entity::PlayerPtr pPlayer, uint64_t actorId, bool Core::Scripting::ScriptManager::onEmote( Entity::Player& player, uint64_t actorId,
uint32_t eventId, uint8_t emoteId ) uint32_t eventId, uint8_t emoteId )
{ {
std::string eventName = "onEmote"; std::string eventName = "onEmote";
@ -232,15 +232,15 @@ bool Core::Scripting::ScriptManager::onEmote( Core::Entity::PlayerPtr pPlayer, u
{ {
auto obj = m_pChaiHandler->eval( Event::getEventName( eventId ) ); auto obj = m_pChaiHandler->eval( Event::getEventName( eventId ) );
pPlayer->sendDebug( "Calling: " + objName + "." + eventName ); player.sendDebug( "Calling: " + objName + "." + eventName );
pPlayer->eventStart( actorId, eventId, Event::Event::Emote, 0, emoteId ); player.eventStart( actorId, eventId, Event::Event::Emote, 0, emoteId );
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t, Entity::Player&, auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t, Entity::Player&,
uint64_t, uint8_t ) > >( eventName ); uint64_t, uint8_t ) > >( eventName );
fn( obj, eventId, *pPlayer, actorId, emoteId ); fn( obj, eventId, player, actorId, emoteId );
pPlayer->checkEvent( eventId ); player.checkEvent( eventId );
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
@ -251,7 +251,7 @@ bool Core::Scripting::ScriptManager::onEmote( Core::Entity::PlayerPtr pPlayer, u
auto questInfo = g_exdData.getQuestInfo( eventId ); auto questInfo = g_exdData.getQuestInfo( eventId );
if( questInfo ) if( questInfo )
{ {
pPlayer->sendDebug( "Quest not implemented: " + questInfo->name + "\n" + e.what() ); player.sendDebug( "Quest not implemented: " + questInfo->name + "\n" + e.what() );
return false; return false;
} }
} }
@ -260,22 +260,22 @@ bool Core::Scripting::ScriptManager::onEmote( Core::Entity::PlayerPtr pPlayer, u
return true; return true;
} }
bool Core::Scripting::ScriptManager::onEventHandlerReturn( Core::Entity::PlayerPtr pPlayer, uint32_t eventId, bool Core::Scripting::ScriptManager::onEventHandlerReturn( Entity::Player& player, uint32_t eventId,
uint16_t subEvent, uint16_t param1, uint16_t param2, uint16_t subEvent, uint16_t param1, uint16_t param2,
uint16_t param3 ) uint16_t param3 )
{ {
pPlayer->sendDebug( "eventId: " + player.sendDebug( "eventId: " +
std::to_string( eventId ) + std::to_string( eventId ) +
" ( 0x" + boost::str( boost::format( "%|08X|" ) % ( uint64_t ) ( eventId & 0xFFFFFFF ) ) + " ) " + " ( 0x" + boost::str( boost::format( "%|08X|" ) % ( uint64_t ) ( eventId & 0xFFFFFFF ) ) + " ) " +
" scene: " + std::to_string( subEvent ) + " scene: " + std::to_string( subEvent ) +
" p1: " + std::to_string( param1 ) + " p1: " + std::to_string( param1 ) +
" p2: " + std::to_string( param2 ) + " p2: " + std::to_string( param2 ) +
" p3: " + std::to_string( param3 ) ); " p3: " + std::to_string( param3 ) );
try try
{ {
auto pEvent = pPlayer->getEvent( eventId ); auto pEvent = player.getEvent( eventId );
if( pEvent ) if( pEvent )
{ {
pEvent->setPlayedScene( false ); pEvent->setPlayedScene( false );
@ -284,27 +284,27 @@ bool Core::Scripting::ScriptManager::onEventHandlerReturn( Core::Entity::PlayerP
// if there is one, proceed to call it // if there is one, proceed to call it
if( eventCallback ) if( eventCallback )
{ {
eventCallback( *pPlayer, eventId, param1, param2, param3 ); eventCallback( player, eventId, param1, param2, param3 );
if( !pEvent->hasPlayedScene() ) if( !pEvent->hasPlayedScene() )
pPlayer->eventFinish( eventId, 1 ); player.eventFinish( eventId, 1 );
else else
pEvent->setPlayedScene( false ); pEvent->setPlayedScene( false );
} }
// else, finish the event. // else, finish the event.
else else
pPlayer->eventFinish( eventId, 1 ); player.eventFinish( eventId, 1 );
} }
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
pPlayer->sendNotice( e.what() ); player.sendNotice( e.what() );
return false; return false;
} }
return true; return true;
} }
bool Core::Scripting::ScriptManager::onEventHandlerTradeReturn( Core::Entity::PlayerPtr pPlayer, uint32_t eventId, bool Core::Scripting::ScriptManager::onEventHandlerTradeReturn( Entity::Player& player, uint32_t eventId,
uint16_t subEvent, uint16_t param, uint32_t catalogId ) uint16_t subEvent, uint16_t param, uint32_t catalogId )
{ {
std::string eventName = Event::getEventName( eventId ) + "_TRADE"; std::string eventName = Event::getEventName( eventId ) + "_TRADE";
@ -313,7 +313,7 @@ bool Core::Scripting::ScriptManager::onEventHandlerTradeReturn( Core::Entity::Pl
{ {
auto fn = m_pChaiHandler->eval< std::function< void( Entity::Player&, uint32_t, auto fn = m_pChaiHandler->eval< std::function< void( Entity::Player&, uint32_t,
uint16_t, uint16_t, uint32_t ) > >( eventName ); uint16_t, uint16_t, uint32_t ) > >( eventName );
fn( *pPlayer, eventId, subEvent, param, catalogId ); fn( player, eventId, subEvent, param, catalogId );
} }
catch( ... ) catch( ... )
{ {
@ -323,7 +323,7 @@ bool Core::Scripting::ScriptManager::onEventHandlerTradeReturn( Core::Entity::Pl
return true; return true;
} }
bool Core::Scripting::ScriptManager::onEventItem( Entity::PlayerPtr pPlayer, uint32_t eventItemId, bool Core::Scripting::ScriptManager::onEventItem( Entity::Player& player, uint32_t eventItemId,
uint32_t eventId, uint32_t castTime, uint64_t targetId ) uint32_t eventId, uint32_t castTime, uint64_t targetId )
{ {
std::string eventName = "onEventItem"; std::string eventName = "onEventItem";
@ -333,17 +333,17 @@ bool Core::Scripting::ScriptManager::onEventItem( Entity::PlayerPtr pPlayer, uin
{ {
auto obj = m_pChaiHandler->eval( Event::getEventName( eventId ) ); auto obj = m_pChaiHandler->eval( Event::getEventName( eventId ) );
pPlayer->sendDebug( "Calling: " + objName + "." + eventName ); player.sendDebug( "Calling: " + objName + "." + eventName );
pPlayer->eventStart( targetId, eventId, Event::Event::Item, 0, 0 ); player.eventStart( targetId, eventId, Event::Event::Item, 0, 0 );
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t, Entity::Player&, auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t, Entity::Player&,
uint32_t, uint32_t, uint64_t ) > >( eventName ); uint32_t, uint32_t, uint64_t ) > >( eventName );
fn( obj, eventId, *pPlayer, eventItemId, castTime, targetId ); fn( obj, eventId, player, eventItemId, castTime, targetId );
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
pPlayer->sendNotice( e.what() ); player.sendNotice( e.what() );
return false; return false;
} }
@ -351,7 +351,7 @@ bool Core::Scripting::ScriptManager::onEventItem( Entity::PlayerPtr pPlayer, uin
} }
bool Core::Scripting::ScriptManager::onMobKill( Entity::PlayerPtr pPlayer, uint16_t nameId ) bool Core::Scripting::ScriptManager::onMobKill( Entity::Player& player, uint16_t nameId )
{ {
std::string eventName = "onBnpcKill_" + std::to_string( nameId ); std::string eventName = "onBnpcKill_" + std::to_string( nameId );
@ -359,7 +359,7 @@ bool Core::Scripting::ScriptManager::onMobKill( Entity::PlayerPtr pPlayer, uint1
// loop through all active quests and try to call available onMobKill callbacks // loop through all active quests and try to call available onMobKill callbacks
for( size_t i = 0; i < 30; i++ ) for( size_t i = 0; i < 30; i++ )
{ {
auto activeQuests = pPlayer->getQuestActive( static_cast< uint16_t >( i ) ); auto activeQuests = player.getQuestActive( static_cast< uint16_t >( i ) );
if( !activeQuests ) if( !activeQuests )
continue; continue;
@ -369,12 +369,12 @@ bool Core::Scripting::ScriptManager::onMobKill( Entity::PlayerPtr pPlayer, uint1
auto obj = m_pChaiHandler->eval( Event::getEventName( 0x00010000 | questId ) ); auto obj = m_pChaiHandler->eval( Event::getEventName( 0x00010000 | questId ) );
std::string objName = Event::getEventName( 0x00010000 | questId ); std::string objName = Event::getEventName( 0x00010000 | questId );
pPlayer->sendDebug("Calling: " + objName + "." + eventName); player.sendDebug("Calling: " + objName + "." + eventName);
try try
{ {
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Player& ) > >(eventName); auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Player& ) > >(eventName);
fn( obj, *pPlayer ); fn( obj, player );
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
@ -387,7 +387,7 @@ bool Core::Scripting::ScriptManager::onMobKill( Entity::PlayerPtr pPlayer, uint1
return true; return true;
} }
bool Core::Scripting::ScriptManager::onCastFinish( Entity::PlayerPtr pPlayer, Entity::ActorPtr pTarget, uint32_t actionId ) bool Core::Scripting::ScriptManager::onCastFinish( Entity::Player& player, Entity::ActorPtr pTarget, uint32_t actionId )
{ {
std::string eventName = "onFinish"; std::string eventName = "onFinish";
@ -396,14 +396,14 @@ bool Core::Scripting::ScriptManager::onCastFinish( Entity::PlayerPtr pPlayer, En
auto obj = m_pChaiHandler->eval( "skillDef_" + std::to_string( actionId ) ); auto obj = m_pChaiHandler->eval( "skillDef_" + std::to_string( actionId ) );
std::string objName = "skillDef_" + std::to_string( actionId ); std::string objName = "skillDef_" + std::to_string( actionId );
pPlayer->sendDebug( "Calling: " + objName + "." + eventName ); player.sendDebug( "Calling: " + objName + "." + eventName );
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Player&, auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Player&,
Entity::Actor& ) > >( eventName ); Entity::Actor& ) > >( eventName );
fn( obj, *pPlayer, *pTarget ); fn( obj, player, *pTarget );
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
pPlayer->sendUrgent( e.what() ); player.sendUrgent( e.what() );
} }
return true; return true;
@ -446,7 +446,7 @@ bool Core::Scripting::ScriptManager::onStatusTick( Entity::ActorPtr pActor, Core
pActor->getAsPlayer()->sendDebug( "Calling: " + objName + "." + eventName ); pActor->getAsPlayer()->sendDebug( "Calling: " + objName + "." + eventName );
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Actor&, auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Actor&,
Core::StatusEffect::StatusEffect& ) > >( eventName ); StatusEffect::StatusEffect& ) > >( eventName );
fn( obj, *pActor, effect ); fn( obj, *pActor, effect );
} }
catch( std::exception& e ) catch( std::exception& e )

View file

@ -5,8 +5,8 @@
#include <mutex> #include <mutex>
#include <set> #include <set>
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include "../Forwards.h" #include "Forwards.h"
namespace chaiscript namespace chaiscript
@ -37,20 +37,20 @@ namespace Core
const boost::shared_ptr< chaiscript::ChaiScript >& getHandler() const; const boost::shared_ptr< chaiscript::ChaiScript >& getHandler() const;
void onPlayerFirstEnterWorld( Entity::PlayerPtr pPlayer ); 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::PlayerPtr pPlayer, uint64_t actorId, uint32_t eventId ); bool onTalk( Entity::Player& player, uint64_t actorId, uint32_t eventId );
bool onEnterTerritory( Entity::PlayerPtr pPlayer, uint32_t eventId, uint16_t param1, uint16_t param2 ); bool onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 );
bool onWithinRange( Entity::PlayerPtr pPlayer, uint32_t eventId, uint32_t param1, float x, float y, float z ); bool onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z );
bool onOutsideRange( Entity::PlayerPtr pPlayer, 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::PlayerPtr pPlayer, uint64_t actorId, uint32_t eventId, uint8_t emoteId ); bool onEmote( Entity::Player& player, uint64_t actorId, uint32_t eventId, uint8_t emoteId );
bool onEventItem( Entity::PlayerPtr pPlayer, 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::PlayerPtr pPlayer, uint16_t nameId ); bool onMobKill( Entity::Player& player, uint16_t nameId );
bool onCastFinish( Entity::PlayerPtr pPlayer, Entity::ActorPtr pTarget, uint32_t actionId ); bool onCastFinish( Entity::Player& pPlayer, Entity::ActorPtr pTarget, uint32_t actionId );
bool onStatusReceive( Entity::ActorPtr pActor, uint32_t effectId ); bool onStatusReceive( Entity::ActorPtr pActor, uint32_t effectId );
bool onStatusTick( Entity::ActorPtr pActor, Core::StatusEffect::StatusEffect& effect ); bool onStatusTick( Entity::ActorPtr pActor, Core::StatusEffect::StatusEffect& effect );
@ -58,8 +58,8 @@ namespace Core
bool onZoneInit( ZonePtr pZone ); bool onZoneInit( ZonePtr pZone );
bool onEventHandlerReturn( Entity::PlayerPtr pPlayer, uint32_t eventId, uint16_t subEvent, uint16_t param1, uint16_t param2, uint16_t param3 ); bool onEventHandlerReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param1, uint16_t param2, uint16_t param3 );
bool onEventHandlerTradeReturn( Entity::PlayerPtr pPlayer, uint32_t eventId, uint16_t subEvent, uint16_t param, uint32_t catalogId ); bool onEventHandlerTradeReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param, uint32_t catalogId );
void loadDir( std::string dirname, std::set<std::string>& chaiFiles ); void loadDir( std::string dirname, std::set<std::string>& chaiFiles );

View file

@ -4,18 +4,17 @@
#include <Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include <Server_Common/Script/ChaiscriptStdLib.h> #include <Server_Common/Script/ChaiscriptStdLib.h>
#include "src/servers/Server_Zone/ServerZone.h" #include "ServerZone.h"
#include "src/servers/Server_Zone/Script/ScriptManager.h" #include "Script/ScriptManager.h"
#include "src/servers/Server_Zone/Zone/Zone.h" #include "Zone/Zone.h"
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "src/servers/Server_Zone/Actor/BattleNpc.h" #include "Actor/BattleNpc.h"
#include "src/servers/Server_Zone/Event/Event.h" #include "Event/Event.h"
#include "src/servers/Server_Zone/Event/EventHelper.h" #include "Event/EventHelper.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ServerNoticePacket.h" #include "StatusEffect/StatusEffect.h"
#include "src/servers/Server_Zone/StatusEffect/StatusEffect.h"
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>

View file

@ -1,9 +1,9 @@
#include "ServerZone.h" #include "ServerZone.h"
#include <src/servers/Server_Common/Version.h> #include <Server_Common/Version.h>
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include <src/servers/Server_Common/Config/XMLConfig.h> #include <Server_Common/Config/XMLConfig.h>
#include <src/servers/Server_Common/Version.h> #include <Server_Common/Version.h>
#include <MySqlBase.h> #include <MySqlBase.h>
#include <Connection.h> #include <Connection.h>
@ -61,7 +61,7 @@ Core::XMLConfigPtr Core::ServerZone::getConfig() const
size_t Core::ServerZone::getSessionCount() const size_t Core::ServerZone::getSessionCount() const
{ {
return m_sessionMap.size(); return m_sessionMapById.size();
} }
bool Core::ServerZone::registerBnpcTemplate( std::string templateName, uint32_t bnpcBaseId, bool Core::ServerZone::registerBnpcTemplate( std::string templateName, uint32_t bnpcBaseId,
@ -263,7 +263,7 @@ void Core::ServerZone::mainLoop()
auto currTime = static_cast< uint32_t >( time( nullptr ) ); auto currTime = static_cast< uint32_t >( time( nullptr ) );
lock_guard< std::mutex > lock( this->m_sessionMutex ); lock_guard< std::mutex > lock( this->m_sessionMutex );
for( auto sessionIt : this->m_sessionMap ) for( auto sessionIt : this->m_sessionMapById )
{ {
auto session = sessionIt.second; auto session = sessionIt.second;
if( session && session->getPlayer() ) if( session && session->getPlayer() )
@ -284,8 +284,8 @@ void Core::ServerZone::mainLoop()
} }
auto it = this->m_sessionMap.begin(); auto it = this->m_sessionMapById.begin();
for( ; it != this->m_sessionMap.end(); ) for( ; it != this->m_sessionMapById.end(); )
{ {
uint32_t diff = currTime - it->second->getLastDataTime(); uint32_t diff = currTime - it->second->getLastDataTime();
@ -298,7 +298,8 @@ void Core::ServerZone::mainLoop()
// if( it->second.unique() ) // if( it->second.unique() )
{ {
g_log.info("[" + std::to_string(it->second->getId() ) + "] Session removal" ); g_log.info("[" + std::to_string(it->second->getId() ) + "] Session removal" );
it = this->m_sessionMap.erase( it ); it = this->m_sessionMapById.erase( it );
removeSession( pPlayer->getName() );
continue; continue;
} }
} }
@ -310,7 +311,8 @@ void Core::ServerZone::mainLoop()
it->second->close(); it->second->close();
// if( it->second.unique() ) // if( it->second.unique() )
{ {
it = this->m_sessionMap.erase(it ); it = this->m_sessionMapById.erase( it );
removeSession( pPlayer->getName() );
} }
} }
else else
@ -329,9 +331,9 @@ bool Core::ServerZone::createSession( uint32_t sessionId )
const std::string session_id_str = std::to_string( sessionId ); const std::string session_id_str = std::to_string( sessionId );
auto it = m_sessionMap.find( sessionId ); auto it = m_sessionMapById.find( sessionId );
if( it != m_sessionMap.end() ) if( it != m_sessionMapById.end() )
{ {
g_log.error( "[" + session_id_str + "] Error creating session" ); g_log.error( "[" + session_id_str + "] Error creating session" );
return false; return false;
@ -340,7 +342,7 @@ bool Core::ServerZone::createSession( uint32_t sessionId )
g_log.info( "[" + session_id_str + "] Creating new session" ); g_log.info( "[" + session_id_str + "] Creating new session" );
boost::shared_ptr<Session> newSession( new Session( sessionId ) ); boost::shared_ptr<Session> newSession( new Session( sessionId ) );
m_sessionMap[sessionId] = newSession; m_sessionMapById[sessionId] = newSession;
if( !newSession->loadPlayer() ) if( !newSession->loadPlayer() )
{ {
@ -348,7 +350,7 @@ bool Core::ServerZone::createSession( uint32_t sessionId )
return false; return false;
} }
m_playerSessionMap[newSession->getPlayer()->getName()] = newSession; m_sessionMapByName[newSession->getPlayer()->getName()] = newSession;
return true; return true;
@ -356,15 +358,15 @@ bool Core::ServerZone::createSession( uint32_t sessionId )
void Core::ServerZone::removeSession( uint32_t sessionId ) void Core::ServerZone::removeSession( uint32_t sessionId )
{ {
m_sessionMap.erase( sessionId ); m_sessionMapById.erase( sessionId );
} }
void Core::ServerZone::updateSession( uint32_t id ) void Core::ServerZone::updateSession( uint32_t id )
{ {
std::lock_guard< std::mutex > lock( m_sessionMutex ); std::lock_guard< std::mutex > lock( m_sessionMutex );
auto it = m_sessionMap.find( id ); auto it = m_sessionMapById.find( id );
if( it != m_sessionMap.end() ) if( it != m_sessionMapById.end() )
it->second->loadPlayer(); it->second->loadPlayer();
} }
@ -372,9 +374,9 @@ Core::SessionPtr Core::ServerZone::getSession( uint32_t id )
{ {
//std::lock_guard<std::mutex> lock( m_sessionMutex ); //std::lock_guard<std::mutex> lock( m_sessionMutex );
auto it = m_sessionMap.find( id ); auto it = m_sessionMapById.find( id );
if( it != m_sessionMap.end() ) if( it != m_sessionMapById.end() )
return ( it->second ); return ( it->second );
return nullptr; return nullptr;
@ -384,9 +386,9 @@ Core::SessionPtr Core::ServerZone::getSession( std::string playerName )
{ {
//std::lock_guard<std::mutex> lock( m_sessionMutex ); //std::lock_guard<std::mutex> lock( m_sessionMutex );
auto it = m_playerSessionMap.find( playerName ); auto it = m_sessionMapByName.find( playerName );
if (it != m_playerSessionMap.end()) if (it != m_sessionMapByName.end())
return (it->second); return (it->second);
return nullptr; return nullptr;
@ -394,15 +396,15 @@ Core::SessionPtr Core::ServerZone::getSession( std::string playerName )
void Core::ServerZone::removeSession( std::string playerName ) void Core::ServerZone::removeSession( std::string playerName )
{ {
m_playerSessionMap.erase( playerName ); m_sessionMapByName.erase( playerName );
} }
void Core::ServerZone::updateSession( std::string playerName ) void Core::ServerZone::updateSession( std::string playerName )
{ {
std::lock_guard< std::mutex > lock( m_sessionMutex ); std::lock_guard< std::mutex > lock( m_sessionMutex );
auto it = m_playerSessionMap.find( playerName ); auto it = m_sessionMapByName.find( playerName );
if( it != m_playerSessionMap.end() ) if( it != m_sessionMapByName.end() )
it->second->loadPlayer(); it->second->loadPlayer();
} }

View file

@ -1,14 +1,14 @@
#ifndef __GAMESERVER_H #ifndef __GAMESERVER_H
#define __GAMESERVER_H #define __GAMESERVER_H
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <mutex> #include <mutex>
#include <map> #include <map>
#include "Forwards.h" #include "Forwards.h"
#include "src/servers/Server_Zone/Actor/BattleNpcTemplate.h" #include "Actor/BattleNpcTemplate.h"
namespace Core { namespace Core {
@ -61,8 +61,8 @@ namespace Core {
std::mutex m_sessionMutex; std::mutex m_sessionMutex;
std::map< uint32_t, SessionPtr > m_sessionMap; std::map< uint32_t, SessionPtr > m_sessionMapById;
std::map< std::string, SessionPtr > m_playerSessionMap; std::map< std::string, SessionPtr > m_sessionMapByName;
std::map< uint32_t, uint32_t > m_zones; std::map< uint32_t, uint32_t > m_zones;

View file

@ -1,11 +1,11 @@
#include <time.h> #include <time.h>
#include <src/servers/Server_Common/Util/Util.h> #include <Server_Common/Util/Util.h>
#include <src/servers/Server_Common/Network/PacketContainer.h> #include <Server_Common/Network/PacketContainer.h>
#include "src/servers/Server_Zone/Network/GameConnection.h" #include "Network/GameConnection.h"
#include "Session.h" #include "Session.h"
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
Core::Session::Session( uint32_t sessionId ) Core::Session::Session( uint32_t sessionId )
: m_sessionId( sessionId ) : m_sessionId( sessionId )
@ -23,13 +23,13 @@ Core::Session::~Session()
{ {
} }
void Core::Session::setZoneConnection( Core::Network::GameConnectionPtr pZoneCon ) void Core::Session::setZoneConnection( Network::GameConnectionPtr pZoneCon )
{ {
pZoneCon->m_conType = Network::ConnectionType::Zone; pZoneCon->m_conType = Network::ConnectionType::Zone;
m_pZoneConnection = pZoneCon; m_pZoneConnection = pZoneCon;
} }
void Core::Session::setChatConnection( Core::Network::GameConnectionPtr pChatCon ) void Core::Session::setChatConnection( Network::GameConnectionPtr pChatCon )
{ {
pChatCon->m_conType = Network::ConnectionType::Chat; pChatCon->m_conType = Network::ConnectionType::Chat;
m_pChatConnection = pChatCon; m_pChatConnection = pChatCon;

View file

@ -5,11 +5,8 @@
#include "Forwards.h" #include "Forwards.h"
namespace Core { namespace Core {
class Session : public boost::enable_shared_from_this< Session > class Session : public boost::enable_shared_from_this< Session >
{ {
public: public:

View file

@ -1,16 +1,16 @@
#include <src/servers/Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <src/servers/Server_Common/Util/Util.h> #include <Server_Common/Util/Util.h>
#include <src/servers/Server_Common/Network/PacketDef/Zone/ServerZoneDef.h> #include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include <src/servers/Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <algorithm> #include <algorithm>
#include "src/servers/Server_Zone/Actor/Actor.h" #include "Actor/Actor.h"
#include "StatusEffect.h" #include "StatusEffect.h"
#include "src/servers/Server_Zone/Script/ScriptManager.h" #include "Script/ScriptManager.h"
extern Core::Logger g_log; extern Core::Logger g_log;
extern Core::Data::ExdData g_exdData; extern Core::Data::ExdData g_exdData;

View file

@ -3,7 +3,7 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
namespace Core namespace Core
{ {

View file

@ -1,218 +0,0 @@
#include <src/servers/Server_Common/Util/Util.h>
#include <src/servers/Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include "src/servers/Server_Zone/Actor/Actor.h"
#include "StatusEffect.h"
#include "StatusEffectContainer.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket142.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket143.h"
using namespace Core::Common;
using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server;
Core::StatusEffect::StatusEffectContainer::StatusEffectContainer( Entity::ActorPtr pOwner )
: m_pOwner( pOwner )
{
// initialize the free slot queue
for( uint8_t i = 0; i < MAX_EFFECTS; i++ )
{
m_freeEffectSlotQueue.push( i );
}
}
int8_t Core::StatusEffect::StatusEffectContainer::getFreeSlot()
{
int8_t freeEffectSlot = -1;
if( m_freeEffectSlotQueue.empty() )
return freeEffectSlot;
freeEffectSlot = m_freeEffectSlotQueue.front();
m_freeEffectSlotQueue.pop();
return freeEffectSlot;
}
void Core::StatusEffect::StatusEffectContainer::freeSlot( uint8_t slotId )
{
m_freeEffectSlotQueue.push( slotId );
}
Core::StatusEffect::StatusEffectContainer::~StatusEffectContainer()
{
}
void Core::StatusEffect::StatusEffectContainer::addStatusEffect( StatusEffectPtr pEffect )
{
int8_t nextSlot = getFreeSlot();
// if there is no slot left, do not add the effect
if( nextSlot == -1 )
return;
pEffect->applyStatus();
m_effectMap[nextSlot] = pEffect;
ZoneChannelPacket< Server::FFXIVIpcAddStatusEffect > statusEffectAdd( m_pOwner->getId() );
statusEffectAdd.data().actor_id = pEffect->getTargetActorId();
statusEffectAdd.data().actor_id1 = pEffect->getSrcActorId();
statusEffectAdd.data().current_hp = m_pOwner->getHp();
statusEffectAdd.data().current_mp = m_pOwner->getMp();
statusEffectAdd.data().current_tp = m_pOwner->getTp();
statusEffectAdd.data().duration = static_cast< float >( pEffect->getDuration() ) / 1000;
statusEffectAdd.data().effect_id = pEffect->getId();
statusEffectAdd.data().effect_index = nextSlot;
statusEffectAdd.data().max_hp = m_pOwner->getMaxHp();
statusEffectAdd.data().max_mp = m_pOwner->getMaxMp();
statusEffectAdd.data().max_something = 1;
//statusEffectAdd.data().unknown2 = 28;
statusEffectAdd.data().param = pEffect->getParam();
bool sendToSelf = m_pOwner->isPlayer() ? true : false;
m_pOwner->sendToInRangeSet( statusEffectAdd, sendToSelf );
}
void Core::StatusEffect::StatusEffectContainer::removeSingleStatusEffectFromId( uint32_t id )
{
for (auto effectIt : m_effectMap)
{
if (effectIt.second->getId() == id)
{
removeStatusEffect( effectIt.first );
break;
}
}
}
void Core::StatusEffect::StatusEffectContainer::removeStatusEffect( uint8_t effectSlotId )
{
auto pEffectIt = m_effectMap.find( effectSlotId );
if( pEffectIt == m_effectMap.end() )
return;
freeSlot( effectSlotId );
auto pEffect = pEffectIt->second;
pEffect->removeStatus();
bool sendToSelf = m_pOwner->isPlayer() ? true : false;
m_pOwner->sendToInRangeSet( ActorControlPacket142( m_pOwner->getId(), StatusEffectLose, pEffect->getId() ), sendToSelf );
m_effectMap.erase( effectSlotId );
sendUpdate();
}
std::map< uint8_t, Core::StatusEffect::StatusEffectPtr > Core::StatusEffect::StatusEffectContainer::getEffectMap() const
{
return m_effectMap;
}
void Core::StatusEffect::StatusEffectContainer::sendUpdate()
{
uint64_t currentTimeMs = Util::getTimeMs();
ZoneChannelPacket< Server::FFXIVIpcStatusEffectList > statusEffectList( m_pOwner->getId() );
statusEffectList.data().current_hp = m_pOwner->getHp();
statusEffectList.data().current_mp = m_pOwner->getMp();
statusEffectList.data().currentTp = m_pOwner->getTp();
statusEffectList.data().max_hp = m_pOwner->getMaxHp();
statusEffectList.data().max_mp = m_pOwner->getMaxMp();
uint8_t slot = 0;
for( auto effectIt : m_effectMap )
{
float timeLeft = static_cast< float >( effectIt.second->getDuration() - ( 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();
slot++;
}
bool sendToSelf = m_pOwner->isPlayer();
m_pOwner->sendToInRangeSet( statusEffectList, sendToSelf );
}
void Core::StatusEffect::StatusEffectContainer::update()
{
uint64_t currentTimeMs = Util::getTimeMs();
uint32_t thisTickDmg = 0;
uint32_t thisTickHeal = 0;
for( auto effectIt : m_effectMap )
{
uint8_t effectIndex = effectIt.first;
auto effect = effectIt.second;
uint64_t lastTick = effect->getLastTickMs();
uint64_t startTime = effect->getStartTimeMs();
uint32_t duration = effect->getDuration();
uint32_t tickRate = effect->getTickRate();
if( ( currentTimeMs - startTime ) > duration )
{
// remove status effect
removeStatusEffect( effectIndex );
// break because removing invalidates iterators
break;
}
if( ( currentTimeMs - lastTick ) > tickRate )
{
effect->setLastTick( currentTimeMs );
effect->onTick();
auto thisEffect = effect->getTickEffect();
switch( thisEffect.first )
{
case 1:
{
thisTickDmg += thisEffect.second;
break;
}
case 2:
{
thisTickHeal += thisEffect.second;
break;
}
}
}
}
if( thisTickDmg != 0 )
{
m_pOwner->takeDamage( thisTickDmg );
m_pOwner->sendToInRangeSet( ActorControlPacket142( m_pOwner->getId(), HPFloatingText, 0, static_cast< uint8_t >( ActionEffectType::Damage ), thisTickDmg ) );
}
if( thisTickHeal != 0 )
{
m_pOwner->heal( thisTickDmg );
m_pOwner->sendToInRangeSet( ActorControlPacket142( m_pOwner->getId(), HPFloatingText, 0, static_cast< uint8_t >( ActionEffectType::Heal ), thisTickHeal ) );
}
}
bool Core::StatusEffect::StatusEffectContainer::hasStatusEffect( uint32_t id )
{
for( auto effectIt : m_effectMap )
{
if( effectIt.second->getId() == id )
{
return true;
}
}
return false;
}

View file

@ -1,49 +0,0 @@
#ifndef _STATUSEFFECTCONTAINER_H_
#define _STATUSEFFECTCONTAINER_H_
#include <boost/shared_ptr.hpp>
#include <queue>
#include <map>
#include "src/servers/Server_Zone/Forwards.h"
namespace Core
{
namespace StatusEffect
{
class StatusEffectContainer
{
public:
StatusEffectContainer( Entity::ActorPtr pOwner );
~StatusEffectContainer();
void addStatusEffect( StatusEffectPtr pEffect );
void removeStatusEffect( uint8_t effectSlotId );
void removeSingleStatusEffectFromId( uint32_t id );
void update();
bool hasStatusEffect( uint32_t id );
int8_t getFreeSlot();
void freeSlot( uint8_t slotId );
std::map< uint8_t, Core::StatusEffect::StatusEffectPtr > getEffectMap() const;
void sendUpdate();
private:
const uint8_t MAX_EFFECTS = 30;
Entity::ActorPtr m_pOwner;
std::queue< uint8_t > m_freeEffectSlotQueue;
std::vector< std::pair< uint8_t, uint32_t> > m_tickEffectList;
std::map< uint8_t, StatusEffectPtr > m_effectMap;
};
}
}
#endif

View file

@ -1,9 +1,8 @@
#include "Cell.h" #include "Cell.h"
#include "src/servers/Server_Zone/Actor/Actor.h" #include "Actor/Actor.h"
#include "src/servers/Server_Zone/Actor/BattleNpc.h" #include "Actor/BattleNpc.h"
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
#include "Zone.h" #include "Zone.h"
@ -47,7 +46,6 @@ namespace Core
{ {
entry->setCurrentZone( m_pZone ); entry->setCurrentZone( m_pZone );
entry->getAsBattleNpc()->initStatusEffectContainer();
m_pZone->pushActor( entry ); m_pZone->pushActor( entry );
} }

View file

@ -4,7 +4,7 @@
#include <stdint.h> #include <stdint.h>
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
#include <set> #include <set>
namespace Core { namespace Core {

View file

@ -1,36 +1,35 @@
#include <stdio.h> #include <stdio.h>
#include <vector> #include <vector>
#include <src/servers/Server_Common/Logging/Logger.h> #include <Server_Common/Logging/Logger.h>
#include <src/servers/Server_Common/Util/Util.h> #include <Server_Common/Util/Util.h>
#include <src/servers/Server_Common/Util/UtilMath.h> #include <Server_Common/Util/UtilMath.h>
#include <src/servers/Server_Common/Network/GamePacket.h> #include <Server_Common/Network/GamePacket.h>
#include <src/servers/Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <src/servers/Server_Common/Exd/ExdData.h> #include <Server_Common/Exd/ExdData.h>
#include <src/servers/Server_Common/Network/CommonNetwork.h> #include <Server_Common/Network/CommonNetwork.h>
#include <src/servers/Server_Common/Network/PacketDef/Zone/ServerZoneDef.h> #include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include <src/servers/Server_Common/Network/PacketContainer.h> #include <Server_Common/Network/PacketContainer.h>
#include <Server_Common/Database/DatabaseDef.h>
#include "Zone.h" #include "Zone.h"
#include "ZoneMgr.h" #include "ZoneMgr.h"
#include "src/servers/Server_Zone/Session.h" #include "Session.h"
#include "src/servers/Server_Zone/Actor/Actor.h" #include "Actor/Actor.h"
#include "src/servers/Server_Zone/Actor/Player.h" #include "Actor/Player.h"
#include "src/servers/Server_Zone/Actor/BattleNpc.h" #include "Actor/BattleNpc.h"
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
#include "src/servers/Server_Zone/Network/GameConnection.h" #include "Network/GameConnection.h"
#include "src/servers/Server_Zone/ServerZone.h" #include "ServerZone.h"
#include "src/servers/Server_Zone/Script/ScriptManager.h" #include "Script/ScriptManager.h"
#include "CellHandler.h" #include "CellHandler.h"
#include <time.h> #include <time.h>
#include <Server_Common/Database/DatabaseDef.h>
extern Core::Logger g_log; extern Core::Logger g_log;
extern Core::ServerZone g_serverZone; extern Core::ServerZone g_serverZone;
extern Core::Data::ExdData g_exdData; extern Core::Data::ExdData g_exdData;
@ -180,16 +179,10 @@ void Zone::loadCellCache()
pos.x = posX; pos.x = posX;
pos.y = posY; pos.y = posY;
pos.z = posZ; pos.z = posZ;
Entity::BattleNpcPtr pBNpc( new Entity::BattleNpc( modelId, nameId, Entity::BattleNpcPtr pBNpc( new Entity::BattleNpc( modelId, nameId, pos,
pos,
sizeId, type, level, behaviour, mobType ) ); sizeId, type, level, behaviour, mobType ) );
pBNpc->setRotation( static_cast< float >( rotation ) ); pBNpc->setRotation( static_cast< float >( rotation ) );
cache.push_back( pBNpc ); cache.push_back( pBNpc );
//pushActor( pBNpc );
//m_zonePositionMap[id] = ZonePositionPtr( new ZonePosition( id, targetZoneId, Position( posX, posY, posZ, posO ), radius ) );
} }
@ -290,9 +283,6 @@ void Zone::pushActor( Entity::ActorPtr pActor )
g_log.debug( "[Zone:" + m_zoneCode + "] Adding player [" + std::to_string( pActor->getId() ) + "]" ); g_log.debug( "[Zone:" + m_zoneCode + "] Adding player [" + std::to_string( pActor->getId() ) + "]" );
auto pPlayer = pActor->getAsPlayer(); auto pPlayer = pActor->getAsPlayer();
// fire the onEnter Lua event
//LuaManager->onRegionEnter(this, pPlayer);
auto pSession = g_serverZone.getSession( pPlayer->getId() ); auto pSession = g_serverZone.getSession( pPlayer->getId() );
if( pSession ) if( pSession )
m_sessionSet.insert( pSession ); m_sessionSet.insert( pSession );
@ -343,7 +333,7 @@ void Zone::removeActor( Entity::ActorPtr pActor )
{ {
Entity::ActorPtr pCurAct; Entity::ActorPtr pCurAct;
for( auto iter = pActor->m_inRangeActors.begin(); iter != pActor->m_inRangeActors.end();) for( auto iter = pActor->m_inRangeActors.begin(); iter != pActor->m_inRangeActors.end(); )
{ {
pCurAct = *iter; pCurAct = *iter;
auto iter2 = iter++; auto iter2 = iter++;
@ -354,21 +344,21 @@ void Zone::removeActor( Entity::ActorPtr pActor )
} }
void Zone::queueOutPacketForRange( Entity::PlayerPtr pSourcePlayer, uint32_t range, Network::Packets::GamePacketPtr pPacketEntry ) void Zone::queueOutPacketForRange( Entity::Player& sourcePlayer, uint32_t range, Network::Packets::GamePacketPtr pPacketEntry )
{ {
for( auto it = m_playerMap.begin(); it != m_playerMap.end(); ++it ) for( auto it = m_playerMap.begin(); it != m_playerMap.end(); ++it )
{ {
float distance = Math::Util::distance( pSourcePlayer->getPos().x, float distance = Math::Util::distance( sourcePlayer.getPos().x,
pSourcePlayer->getPos().y, sourcePlayer.getPos().y,
pSourcePlayer->getPos().z, sourcePlayer.getPos().z,
( *it ).second->getPos().x, ( *it ).second->getPos().x,
( *it ).second->getPos().y, ( *it ).second->getPos().y,
( *it ).second->getPos().z ); ( *it ).second->getPos().z );
if( ( distance < range ) && pSourcePlayer->getId() != ( *it ).second->getId() ) if( ( distance < range ) && sourcePlayer.getId() != ( *it ).second->getId() )
{ {
auto pSession = g_serverZone.getSession( ( *it ).second->getId() ); auto pSession = g_serverZone.getSession( ( *it ).second->getId() );
pPacketEntry->setValAt<uint32_t>( 0x08, ( *it ).second->getId() ); pPacketEntry->setValAt< uint32_t >( 0x08, ( *it ).second->getId() );
if( pSession ) if( pSession )
pSession->getZoneConnection()->queueOutPacket( pPacketEntry ); pSession->getZoneConnection()->queueOutPacket( pPacketEntry );
} }

View file

@ -2,12 +2,12 @@
#define _ZONE_H #define _ZONE_H
#include <unordered_map> #include <unordered_map>
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
#include "Cell.h" #include "Cell.h"
#include "CellHandler.h" #include "CellHandler.h"
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
#include <set> #include <set>
#include <boost/enable_shared_from_this.hpp> #include <boost/enable_shared_from_this.hpp>
@ -15,11 +15,10 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
namespace Core { namespace Core {
namespace Entity namespace Entity
{ {
class Actor; class Actor;
class Player; class Player;
} }
class Session; class Session;
@ -39,8 +38,8 @@ protected:
bool m_bPrivate; bool m_bPrivate;
std::unordered_map<int32_t, Entity::PlayerPtr > m_playerMap; std::unordered_map< int32_t, Entity::PlayerPtr > m_playerMap;
std::unordered_map<int32_t, Entity::BattleNpcPtr > m_BattleNpcMap; std::unordered_map< int32_t, Entity::BattleNpcPtr > m_BattleNpcMap;
std::set< Entity::BattleNpcPtr > m_BattleNpcDeadMap; std::set< Entity::BattleNpcPtr > m_BattleNpcDeadMap;
@ -90,7 +89,7 @@ public:
void updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell ); void updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell );
void queueOutPacketForRange( Entity::PlayerPtr pSourcePlayer, uint32_t range, Network::Packets::GamePacketPtr pPacketEntry ); void queueOutPacketForRange( Entity::Player& sourcePlayer, uint32_t range, Network::Packets::GamePacketPtr pPacketEntry );
virtual uint32_t getId(); virtual uint32_t getId();

View file

@ -4,7 +4,6 @@
#include "ZoneMgr.h" #include "ZoneMgr.h"
#include "Zone.h" #include "Zone.h"
#include "ZonePosition.h" #include "ZonePosition.h"
#include <Server_Common/Database/DatabaseDef.h> #include <Server_Common/Database/DatabaseDef.h>
@ -65,51 +64,6 @@ namespace Core {
m_zoneMap[info.id] = pZone; m_zoneMap[info.id] = pZone;
} }
//do
//{
// Db::Field *field = pQR->fetch();
// uint16_t id = field[0].getUInt16();
// std::string inName = field[1].getString();
// std::string name = field[2].getString();
// uint32_t layoutId = field[3].getUInt32();
// bool isPrivate = field[4].getBool();
// if(!isPrivate)
// {
// g_log.Log(LoggingSeverity::info, std::to_string(id) + "\t" + inName + " - " + name);
// ZonePtr pZone( new Zone( id, layoutId, name, inName, isPrivate ) );
// m_zoneMap[id] = pZone;
// // start the region worker
// // ThreadPool->executeTask(pRegion);
// }
// else
// {
// //Console->outTime(" --> %s", inName.c_str());
// //Console->outTime("\tCached private instance...", name.c_str());
// //// write the instance data into the instance cache for later use
// //InstanceCacheEntry * pICE = new InstanceCacheEntry();
// //pICE->id = id;
// //pICE->inName = inName;
// //pICE->minX = minX;
// //pICE->maxX = maxX;
// //pICE->minY = minY;
// //pICE->maxY = maxY;
// //pICE->name = name;
// //pICE->layoutId = layoutId;
// //pICE->isPrivate = isPrivate;
// //m_instanceCache[pICE->id] = pICE;
// //m_instanceCacheName[inName] = pICE;
// //createInstance(pICE);
// }
//} while(pQR->nextRow());
return true; return true;
} }

View file

@ -4,7 +4,7 @@
#include <unordered_map> #include <unordered_map>
#include <map> #include <map>
#include "src/servers/Server_Zone/Forwards.h" #include "Forwards.h"
namespace Core { namespace Core {

View file

@ -7,7 +7,7 @@ Core::ZonePosition::ZonePosition()
{ {
} }
Core::ZonePosition::ZonePosition( uint32_t id, uint32_t targetZoneId, const Core::Common::FFXIVARR_POSITION3& targetPosition, uint32_t radius, float rotation ) Core::ZonePosition::ZonePosition( uint32_t id, uint32_t targetZoneId, const Common::FFXIVARR_POSITION3& targetPosition, uint32_t radius, float rotation )
{ {
m_id = id; m_id = id;
m_targetZoneId = targetZoneId; m_targetZoneId = targetZoneId;

View file

@ -1,7 +1,7 @@
#ifndef _ZONELINE_H #ifndef _ZONELINE_H
#define _ZONELINE_H #define _ZONELINE_H
#include <src/servers/Server_Common/Common.h> #include <Server_Common/Common.h>
namespace Core { namespace Core {

View file

@ -5,10 +5,12 @@ compile with STANDALONE defined to compile without boost and sapphire dependenci
usage: usage:
- regular - regular
- compile with root sapphire dir cmakelists - compile with root sapphire dir cmakelists
- sapphire/src/tools/bin/pcb_reader2 "<path/to/game/sqpack/ffxiv>" <territory> - sapphire/src/tools/bin/pcb_reader2 <territory> "<path/to/game/sqpack/ffxiv>"
- standalone - standalone
- compile main.cpp with STANDALONE defined in build arg - compile main.cpp with STANDALONE defined in build arg
- download ffxivexplorer <http://ffxivexplorer.fragmenterworks.com/> - download ffxivexplorer <http://ffxivexplorer.fragmenterworks.com/>
- ffxivexplorer > path/to/ffxiv's/game/sqpack/ffxiv/0a0000.dat
- exd/territorytype.exh > `File > Export` and copy `territorytype.exh.csv` from exproted directory to `pcb_reader.exe` directory
- ffxivexplorer > path/to/ffxiv's/game/sqpack/ffxiv/020000.dat - ffxivexplorer > path/to/ffxiv's/game/sqpack/ffxiv/020000.dat
- ctrl click the following: - ctrl click the following:
- `bg/ffxiv/[REGION]/common/collision` - `bg/ffxiv/[REGION]/common/collision`

View file

@ -4,6 +4,7 @@
#include <iostream> #include <iostream>
#include <chrono> #include <chrono>
#include <fstream> #include <fstream>
#include <regex>
#include "pcb.h" #include "pcb.h"
#include "lgb.h" #include "lgb.h"
@ -84,39 +85,38 @@ int parseBlockEntry( char* data, std::vector<PCB_BLOCK_ENTRY>& entries, int gOff
std::string zoneNameToPath( const std::string& name ) std::string zoneNameToPath( const std::string& name )
{ {
char teri = name[0]; std::string path;
char region = name[1]; auto inFile = std::ifstream( "territorytype.exh.csv" );
char type = name[2]; if( inFile.good() )
char zone = name[3];
static std::map< char, std::string > teriMap
{ {
{ 'r', "roc" }, std::string line;
{ 'w', "wil" }, std::regex re("(\\d+),\"(.*)\",\"(.*)\",.*");
{ 'l', "lak" }, while( std::getline( inFile, line ) )
{ 'o', "ocn" }, {
{ 'f', "fst" }, std::smatch match;
{ 'a', "air" }, if( std::regex_match( line, match, re ) )
{ 's', "sea" }, {
{ 'z', "zon" } if( name == match[2].str() )
}; {
path = match[3].str();
static std::map< char, std::string > typeMap break;
}
}
}
}
if( !path.empty() )
{ {
{ 'f', "fld" }, //path = path.substr( path.find_first_of( "/" ) + 1, path.size() - path.find_first_of( "/" ));
{ 't', "twn" }, //path = std::string( "ffxiv/" ) + path;
{ 'd', "dun" }, path = std::string( "bg" ) + path.substr( 0, path.find( "/level/" ) );
{ 'b', "bah" }, std::cout << "[Info] " << "Found path for " << name << ": " << path << std::endl;
{ 'i', "ind" }, }
{ 'e', "evt" }, else
}; {
std::string ret; throw std::runtime_error( "Unable to find path for " + name +
const auto& teriRet = teriMap[teri]; ".\n\tPlease open 0a0000.win32.index with FFXIV Explorer and extract territorytype.exh as CSV\n\tand copy territorytype.exh.csv into pcb_reader.exe directory" );
const auto& typeRet = typeMap[type]; }
ret += teriRet + "_"; return path;
ret += teri;
ret += region;
ret += "/" + typeRet + "/" + name;
return ret;
} }
void readFileToBuffer( const std::string& path, std::vector< char >& buf ) void readFileToBuffer( const std::string& path, std::vector< char >& buf )
@ -141,24 +141,25 @@ int main( int argc, char* argv[] )
{ {
auto startTime = std::chrono::system_clock::now(); auto startTime = std::chrono::system_clock::now();
std::string gamePath = "C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\ffxiv"; // todo: support expansions
std::string gamePath = "C:\\Program Files (x86)\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\ffxiv";
std::string zoneName = "r1f1"; std::string zoneName = "r1f1";
if( argc > 1 ) if( argc > 1 )
{ {
gamePath = argv[1]; zoneName = argv[1];
if( argc > 2 ) if( argc > 2 )
{ {
zoneName = argv[2]; gamePath = argv[2];
} }
} }
const auto& zonePath = zoneNameToPath( zoneName );
try try
{ {
std::string listPcbPath( "bg/ffxiv/" + zonePath + "/collision/list.pcb" ); const auto& zonePath = zoneNameToPath( zoneName );
std::string bgLgbPath( "bg/ffxiv/" + zonePath + "/level/bg.lgb" ); std::string listPcbPath( zonePath + "/collision/list.pcb" );
std::string collisionFilePath( "bg/ffxiv/" + zonePath + "/collision/" ); std::string bgLgbPath( zonePath + "/level/bg.lgb" );
std::string collisionFilePath( zonePath + "/collision/" );
std::vector< char > section; std::vector< char > section;
std::vector< char > section1; std::vector< char > section1;
@ -274,7 +275,7 @@ int main( int argc, char* argv[] )
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
std::cout << "Unable to load collision mesh " << fileName << "\n\tError:\n\t" << e.what() << "\n"; std::cout << "[Error] " << "Unable to load collision mesh " << fileName << "\n\tError:\n\t" << e.what() << "\n";
return false; return false;
} }
}; };
@ -301,7 +302,7 @@ int main( int argc, char* argv[] )
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
std::cout << "Unable to load SGB " << fileName << "\n\tError:\n\t" << e.what() << "\n"; std::cout << "[Error] " << "Unable to load SGB " << fileName << "\n\tError:\n\t" << e.what() << "\n";
sgbFiles.insert( std::make_pair( fileName, sgbFile ) ); sgbFiles.insert( std::make_pair( fileName, sgbFile ) );
} }
return false; return false;
@ -394,8 +395,8 @@ int main( int argc, char* argv[] )
loadPcbFile( fileName ); loadPcbFile( fileName );
pushVerts( pcbFiles[fileName], fileName ); pushVerts( pcbFiles[fileName], fileName );
} }
std::cout << "Writing obj file " << "\n"; std::cout << "[Info] " << "Writing obj file " << "\n";
std::cout << bgLgb.groups.size() << " groups " << "\n"; std::cout << "[Info] " << bgLgb.groups.size() << " groups " << "\n";
uint32_t totalGroups = 0; uint32_t totalGroups = 0;
uint32_t totalGroupEntries = 0; uint32_t totalGroupEntries = 0;
for( const auto& group : bgLgb.groups ) for( const auto& group : bgLgb.groups )
@ -467,15 +468,18 @@ int main( int argc, char* argv[] )
} }
} }
} }
std::cout << "\n\nLoaded " << pcbFiles.size() << " PCB Files \n"; std::cout << "\n[Info] " << "Loaded " << pcbFiles.size() << " PCB Files \n";
std::cout << "Total Groups " << totalGroups << " Total entries " << totalGroupEntries << "\n"; std::cout << "[Info] " << "Total Groups " << totalGroups << " Total entries " << totalGroupEntries << "\n";
} }
std::cout << "Finished exporting " << zoneName << " in " << std::cout << "[Success] " << "Finished exporting " << zoneName << " in " <<
std::chrono::duration_cast< std::chrono::seconds >( std::chrono::system_clock::now() - startTime ).count() << " seconds\n"; std::chrono::duration_cast< std::chrono::seconds >( std::chrono::system_clock::now() - startTime ).count() << " seconds\n";
} }
catch( std::exception& e ) catch( std::exception& e )
{ {
std::cout << e.what() << std::endl; std::cout << "[Error] " << e.what() << std::endl;
std::cout << "[Error] " << "Unable to extract collision data.\n\tIf using standalone ensure your working directory folder layout is \n\tbg/[ffxiv|ex1|ex2]/teri/type/zone/[level|collision]" << std::endl;
std::cout << std::endl;
std::cout << "[Info] " << "Usage: pcb_reader2 territory \"path/to/game/sqpack/ffxiv\" " << std::endl;
} }
return 0; return 0;
} }