From 99b1b1dcf03319e1b656b75a134799ea8c5f8da9 Mon Sep 17 00:00:00 2001 From: Mordred Date: Thu, 17 Aug 2017 17:30:00 +0200 Subject: [PATCH] Changed handlers to take a const& instead of a shared_ptr of inPacket --- src/servers/Server_Common/GamePacket.cpp | 2 +- src/servers/Server_Common/GamePacket.h | 16 ++-- src/servers/Server_Zone/ActionHandler.cpp | 18 ++-- src/servers/Server_Zone/CFHandlers.cpp | 26 +++--- src/servers/Server_Zone/EventHandlers.cpp | 50 +++++------ src/servers/Server_Zone/GMCommandHandlers.cpp | 20 +++-- src/servers/Server_Zone/GameConnection.cpp | 2 +- src/servers/Server_Zone/GameConnection.h | 4 +- src/servers/Server_Zone/InventoryHandler.cpp | 16 ++-- src/servers/Server_Zone/PacketHandlers.cpp | 84 +++++++++---------- src/servers/Server_Zone/SkillHandler.cpp | 8 +- 11 files changed, 124 insertions(+), 122 deletions(-) diff --git a/src/servers/Server_Common/GamePacket.cpp b/src/servers/Server_Common/GamePacket.cpp index 180ccfec..9618eaa8 100644 --- a/src/servers/Server_Common/GamePacket.cpp +++ b/src/servers/Server_Common/GamePacket.cpp @@ -94,7 +94,7 @@ void Core::Network::Packets::GamePacket::savePacket() } -std::string Core::Network::Packets::GamePacket::toString() +std::string Core::Network::Packets::GamePacket::toString() const { std::string str = "\n"; diff --git a/src/servers/Server_Common/GamePacket.h b/src/servers/Server_Common/GamePacket.h index d4bf27c3..f74ef798 100644 --- a/src/servers/Server_Common/GamePacket.h +++ b/src/servers/Server_Common/GamePacket.h @@ -20,17 +20,17 @@ public: GamePacket( void ); ~GamePacket( void ); - uint16_t getSize() + uint16_t getSize() const { return m_segHdr.size; } - uint16_t getType() + uint16_t getType() const { return m_segHdr.type; } - uint16_t getSubType() + uint16_t getSubType() const { return m_subType; } @@ -42,9 +42,9 @@ public: } template - T getValAt( uint16_t pos ) + T getValAt( uint16_t pos ) const { - return *reinterpret_cast< 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 ) @@ -52,9 +52,9 @@ public: memcpy( reinterpret_cast< uint8_t* >( &m_dataBuf[0] + offset ), bytes, length ); } - char * getStringAt( uint16_t pos ) + const char * getStringAt( uint16_t pos ) const { - return reinterpret_cast< char* >( &m_dataBuf[0] + pos ); + return reinterpret_cast< const char* >( &m_dataBuf[0] + pos ); } void setStringAt( uint16_t pos, const std::string& str ) @@ -69,7 +69,7 @@ public: void setHeader( uint16_t size, uint16_t type, uint32_t id1, uint32_t id2, uint16_t subType, uint32_t unknown = 0xFED2E000 ); - std::string toString(); + std::string toString() const; void savePacket(); diff --git a/src/servers/Server_Zone/ActionHandler.cpp b/src/servers/Server_Zone/ActionHandler.cpp index 03d46e66..a6f0fa60 100644 --- a/src/servers/Server_Zone/ActionHandler.cpp +++ b/src/servers/Server_Zone/ActionHandler.cpp @@ -54,15 +54,15 @@ using namespace Core::Network::Packets; using namespace Core::Network::Packets::Server; -void Core::Network::GameConnection::actionHandler( Core::Network::Packets::GamePacketPtr pInPacket, +void Core::Network::GameConnection::actionHandler( const Core::Network::Packets::GamePacket& inPacket, Core::Entity::PlayerPtr pPlayer ) { - uint16_t commandId = pInPacket->getValAt< uint16_t >( 0x20 ); - uint64_t param1 = pInPacket->getValAt< uint64_t >( 0x24 ); - uint32_t param11 = pInPacket->getValAt< uint32_t >( 0x24 ); - uint32_t param12 = pInPacket->getValAt< uint32_t >( 0x28 ); - uint32_t param2 = pInPacket->getValAt< uint32_t >( 0x2c ); - uint64_t param3 = pInPacket->getValAt< uint64_t >( 0x38 ); + uint16_t commandId = inPacket.getValAt< uint16_t >( 0x20 ); + uint64_t param1 = inPacket.getValAt< uint64_t >( 0x24 ); + uint32_t param11 = inPacket.getValAt< uint32_t >( 0x24 ); + uint32_t param12 = inPacket.getValAt< uint32_t >( 0x28 ); + uint32_t param2 = inPacket.getValAt< uint32_t >( 0x2c ); + uint64_t param3 = inPacket.getValAt< uint64_t >( 0x38 ); g_log.debug( "[" + std::to_string( m_pSession->getId() ) + "] Incoming action: " + boost::str( boost::format( "%|04X|" ) % ( uint32_t ) ( commandId & 0xFFFF ) ) + @@ -107,7 +107,7 @@ void Core::Network::GameConnection::actionHandler( Core::Network::Packets::GameP case 0x03: // Change target { - uint64_t targetId = pInPacket->getValAt< uint64_t >( 0x24 ); + uint64_t targetId = inPacket.getValAt< uint64_t >( 0x24 ); pPlayer->changeTarget( targetId ); break; } @@ -121,7 +121,7 @@ void Core::Network::GameConnection::actionHandler( Core::Network::Packets::GameP case 0x1F4: // emote { uint64_t targetId = pPlayer->getTargetId(); - uint32_t emoteId = pInPacket->getValAt< uint32_t >( 0x24 ); + uint32_t emoteId = inPacket.getValAt< uint32_t >( 0x24 ); pPlayer->sendToInRangeSet( ActorControlPacket144( pPlayer->getId(), Emote, emoteId, 0, 0, 0, targetId ) ); break; diff --git a/src/servers/Server_Zone/CFHandlers.cpp b/src/servers/Server_Zone/CFHandlers.cpp index 31cb0172..357bd0ca 100644 --- a/src/servers/Server_Zone/CFHandlers.cpp +++ b/src/servers/Server_Zone/CFHandlers.cpp @@ -54,8 +54,8 @@ using namespace Core::Network::Packets; using namespace Core::Network::Packets::Server; -void Core::Network::GameConnection::cfDutyInfoRequest(Core::Network::Packets::GamePacketPtr pInPacket, - Core::Entity::PlayerPtr pPlayer) +void Core::Network::GameConnection::cfDutyInfoRequest( const Core::Network::Packets::GamePacket& inPacket, + Core::Entity::PlayerPtr pPlayer ) { GamePacketNew< FFXIVIpcCFDutyInfo > dutyInfoPacket( pPlayer->getId() ); queueOutPacket( dutyInfoPacket ); @@ -65,15 +65,15 @@ void Core::Network::GameConnection::cfDutyInfoRequest(Core::Network::Packets::Ga } -void Core::Network::GameConnection::cfRegisterDuty(Core::Network::Packets::GamePacketPtr pInPacket, - Core::Entity::PlayerPtr pPlayer) +void Core::Network::GameConnection::cfRegisterDuty( const Core::Network::Packets::GamePacket& inPacket, + Core::Entity::PlayerPtr pPlayer) { // TODO use for loop for this - auto contentId1 = pInPacket->getValAt< uint16_t >( 46 ); - auto contentId2 = pInPacket->getValAt< uint16_t >( 48 ); - auto contentId3 = pInPacket->getValAt< uint16_t >( 50 ); - auto contentId4 = pInPacket->getValAt< uint16_t >( 52 ); - auto contentId5 = pInPacket->getValAt< uint16_t >( 54 ); + auto contentId1 = inPacket.getValAt< uint16_t >( 46 ); + auto contentId2 = inPacket.getValAt< uint16_t >( 48 ); + auto contentId3 = inPacket.getValAt< uint16_t >( 50 ); + auto contentId4 = inPacket.getValAt< uint16_t >( 52 ); + auto contentId5 = inPacket.getValAt< uint16_t >( 54 ); pPlayer->sendDebug("Duty register request"); pPlayer->sendDebug("ContentId1" + std::to_string(contentId1)); @@ -89,14 +89,14 @@ void Core::Network::GameConnection::cfRegisterDuty(Core::Network::Packets::GameP queueOutPacket( cfCancelPacket ); } -void Core::Network::GameConnection::cfRegisterRoulette(Core::Network::Packets::GamePacketPtr pInPacket, - Core::Entity::PlayerPtr pPlayer) +void Core::Network::GameConnection::cfRegisterRoulette( const Core::Network::Packets::GamePacket& inPacket, + Core::Entity::PlayerPtr pPlayer) { pPlayer->sendDebug("Roulette register"); } -void Core::Network::GameConnection::cfDutyAccepted(Core::Network::Packets::GamePacketPtr pInPacket, - Core::Entity::PlayerPtr pPlayer) +void Core::Network::GameConnection::cfDutyAccepted( const Core::Network::Packets::GamePacket& inPacket, + Core::Entity::PlayerPtr pPlayer) { pPlayer->sendDebug("TODO: Duty accept"); } diff --git a/src/servers/Server_Zone/EventHandlers.cpp b/src/servers/Server_Zone/EventHandlers.cpp index cb7de0b6..7d914f33 100644 --- a/src/servers/Server_Zone/EventHandlers.cpp +++ b/src/servers/Server_Zone/EventHandlers.cpp @@ -48,10 +48,10 @@ using namespace Core::Common; using namespace Core::Network::Packets; using namespace Core::Network::Packets::Server; -void Core::Network::GameConnection::eventHandler( Core::Network::Packets::GamePacketPtr pInPacket, +void Core::Network::GameConnection::eventHandler( const Core::Network::Packets::GamePacket& inPacket, Core::Entity::PlayerPtr pPlayer ) { - uint16_t eventHandlerId = pInPacket->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 auto abortEventFunc = []( Core::Entity::PlayerPtr pPlayer, uint64_t actorId, uint32_t eventId ) @@ -71,8 +71,8 @@ void Core::Network::GameConnection::eventHandler( Core::Network::Packets::GamePa case ClientIpcType::TalkEventHandler: // Talk event { - uint64_t actorId = pInPacket->getValAt< uint64_t >( 0x20 ); - uint32_t eventId = pInPacket->getValAt< uint32_t >( 0x28 ); + uint64_t actorId = inPacket.getValAt< uint64_t >( 0x20 ); + uint32_t eventId = inPacket.getValAt< uint32_t >( 0x28 ); if( !g_scriptMgr.onTalk( pPlayer, actorId, eventId ) ) abortEventFunc( pPlayer, actorId, eventId ); @@ -81,9 +81,9 @@ void Core::Network::GameConnection::eventHandler( Core::Network::Packets::GamePa case ClientIpcType::EmoteEventHandler: // Emote event { - uint64_t actorId = pInPacket->getValAt< uint64_t >( 0x20 ); - uint32_t eventId = pInPacket->getValAt< uint32_t >( 0x28 ); - uint16_t emoteId = pInPacket->getValAt< uint16_t >( 0x2C ); + uint64_t actorId = inPacket.getValAt< uint64_t >( 0x20 ); + uint32_t eventId = inPacket.getValAt< uint32_t >( 0x28 ); + uint16_t emoteId = inPacket.getValAt< uint16_t >( 0x2C ); std::string eventName = Event::getEventName( eventId ); @@ -95,11 +95,11 @@ void Core::Network::GameConnection::eventHandler( Core::Network::Packets::GamePa case ClientIpcType::WithinRangeEventHandler: { - uint32_t eventId = pInPacket->getValAt< uint32_t >( 0x24 ); - uint32_t eventParam1 = pInPacket->getValAt< uint32_t >( 0x20 ); - float x = pInPacket->getValAt< float >( 0x28 ); - float y = pInPacket->getValAt< float >( 0x2C ); - float z = pInPacket->getValAt< float >( 0x30 ); + uint32_t eventId = inPacket.getValAt< uint32_t >( 0x24 ); + uint32_t eventParam1 = inPacket.getValAt< uint32_t >( 0x20 ); + float x = inPacket.getValAt< float >( 0x28 ); + float y = inPacket.getValAt< float >( 0x2C ); + float z = inPacket.getValAt< float >( 0x30 ); std::string eventName = Event::getEventName( eventId ); @@ -110,11 +110,11 @@ void Core::Network::GameConnection::eventHandler( Core::Network::Packets::GamePa case ClientIpcType::OutOfRangeEventHandler: { - uint32_t eventId = pInPacket->getValAt< uint32_t >( 0x24 ); - uint32_t eventParam1 = pInPacket->getValAt< uint32_t >( 0x20 ); - float x = pInPacket->getValAt< float >( 0x28 ); - float y = pInPacket->getValAt< float >( 0x2C ); - float z = pInPacket->getValAt< float >( 0x30 ); + uint32_t eventId = inPacket.getValAt< uint32_t >( 0x24 ); + uint32_t eventParam1 = inPacket.getValAt< uint32_t >( 0x20 ); + float x = inPacket.getValAt< float >( 0x28 ); + float y = inPacket.getValAt< float >( 0x2C ); + float z = inPacket.getValAt< float >( 0x30 ); std::string eventName = Event::getEventName( eventId ); @@ -125,9 +125,9 @@ void Core::Network::GameConnection::eventHandler( Core::Network::Packets::GamePa case ClientIpcType::EnterTeriEventHandler: { - uint32_t eventId = pInPacket->getValAt< uint32_t >( 0x20 ); - uint16_t eventParam1 = pInPacket->getValAt< uint16_t >( 0x24 ); - uint16_t eventParam2 = pInPacket->getValAt< uint16_t >( 0x26 ); + uint32_t eventId = inPacket.getValAt< uint32_t >( 0x20 ); + uint16_t eventParam1 = inPacket.getValAt< uint16_t >( 0x24 ); + uint16_t eventParam2 = inPacket.getValAt< uint16_t >( 0x26 ); std::string eventName = Event::getEventName( eventId ); @@ -139,11 +139,11 @@ void Core::Network::GameConnection::eventHandler( Core::Network::Packets::GamePa case ClientIpcType::ReturnEventHandler: case ClientIpcType::TradeReturnEventHandler: { - uint32_t eventId = pInPacket->getValAt< uint32_t >( 0x20 ); - uint16_t subEvent = pInPacket->getValAt< uint16_t >( 0x24 ); - uint16_t param1 = pInPacket->getValAt< uint16_t >( 0x26 ); - uint16_t param2 = pInPacket->getValAt< uint16_t >( 0x28 ); - uint16_t param3 = pInPacket->getValAt< uint16_t >( 0x2C ); + uint32_t eventId = inPacket.getValAt< uint32_t >( 0x20 ); + uint16_t subEvent = inPacket.getValAt< uint16_t >( 0x24 ); + uint16_t param1 = inPacket.getValAt< uint16_t >( 0x26 ); + uint16_t param2 = inPacket.getValAt< uint16_t >( 0x28 ); + uint16_t param3 = inPacket.getValAt< uint16_t >( 0x2C ); std::string eventName = Event::getEventName( eventId ); diff --git a/src/servers/Server_Zone/GMCommandHandlers.cpp b/src/servers/Server_Zone/GMCommandHandlers.cpp index 70b644d1..c0041075 100644 --- a/src/servers/Server_Zone/GMCommandHandlers.cpp +++ b/src/servers/Server_Zone/GMCommandHandlers.cpp @@ -92,15 +92,17 @@ enum GmCommand Jump = 0x025E, JumpNpc = 0x025F, }; -void Core::Network::GameConnection::gm1Handler( Core::Network::Packets::GamePacketPtr pInPacket, +void Core::Network::GameConnection::gm1Handler( const Core::Network::Packets::GamePacket& inPacket, Core::Entity::PlayerPtr pPlayer ) { - uint32_t commandId = pInPacket->getValAt< uint32_t >( 0x20 ); - uint32_t param1 = pInPacket->getValAt< uint32_t >( 0x24 ); - uint32_t param2 = pInPacket->getValAt< uint32_t >( 0x28 ); - uint32_t param3 = pInPacket->getValAt< uint32_t >( 0x38 ); + uint32_t commandId = inPacket.getValAt< uint32_t >( 0x20 ); + uint32_t param1 = inPacket.getValAt< uint32_t >( 0x24 ); + uint32_t param2 = inPacket.getValAt< uint32_t >( 0x28 ); + uint32_t param3 = inPacket.getValAt< uint32_t >( 0x38 ); - g_log.debug( pPlayer->getName() + " used GM1 commandId: " + std::to_string( commandId ) + ", params: " + std::to_string( param1 ) + ", " + std::to_string( param2 ) + ", " + std::to_string( param3 ) ); + g_log.debug( pPlayer->getName() + " used GM1 commandId: " + std::to_string( commandId ) + + ", params: " + std::to_string( param1 ) + ", " + + std::to_string( param2 ) + ", " + std::to_string( param3 ) ); Core::Entity::ActorPtr targetActor; @@ -336,11 +338,11 @@ void Core::Network::GameConnection::gm1Handler( Core::Network::Packets::GamePack } -void Core::Network::GameConnection::gm2Handler( Core::Network::Packets::GamePacketPtr pInPacket, +void Core::Network::GameConnection::gm2Handler( const Core::Network::Packets::GamePacket& inPacket, Core::Entity::PlayerPtr pPlayer ) { - uint32_t commandId = pInPacket->getValAt< uint32_t >( 0x20 ); - std::string param1 = pInPacket->getStringAt( 0x34 ); + uint32_t commandId = inPacket.getValAt< uint32_t >( 0x20 ); + std::string param1 = inPacket.getStringAt( 0x34 ); g_log.debug( pPlayer->getName() + " used GM2 commandId: " + std::to_string( commandId ) + ", params: " + param1 ); diff --git a/src/servers/Server_Zone/GameConnection.cpp b/src/servers/Server_Zone/GameConnection.cpp index 6dd4712a..66c6b11f 100644 --- a/src/servers/Server_Zone/GameConnection.cpp +++ b/src/servers/Server_Zone/GameConnection.cpp @@ -155,7 +155,7 @@ void Core::Network::GameConnection::handleGamePacket( Core::Network::Packets::Ga g_log.debug( "[" + std::to_string( m_pSession->getId() ) + "] Handling packet : " + name + "( " + boost::str( boost::format( "%|04X|" ) % static_cast< uint32_t >( pPacket->getSubType() & 0xFFFF ) ) + " )" ); - ( this->*( it->second ) )( pPacket, m_pSession->getPlayer() ); + ( this->*( it->second ) )( *pPacket, m_pSession->getPlayer() ); } else { diff --git a/src/servers/Server_Zone/GameConnection.h b/src/servers/Server_Zone/GameConnection.h index 49c43de2..a437ef71 100644 --- a/src/servers/Server_Zone/GameConnection.h +++ b/src/servers/Server_Zone/GameConnection.h @@ -12,7 +12,7 @@ #include "Forwards.h" -#define DECLARE_HANDLER( x ) void x( Packets::GamePacketPtr pInPacket, Entity::PlayerPtr pPlayer ) +#define DECLARE_HANDLER( x ) void x( const Packets::GamePacket& inPacket, Entity::PlayerPtr pPlayer ) namespace Core { namespace Network { @@ -28,7 +28,7 @@ class GameConnection : public Connection { private: - typedef void ( GameConnection::* Handler )( Packets::GamePacketPtr pInPacket, Entity::PlayerPtr pPlayer ); + typedef void ( GameConnection::* Handler )( const Packets::GamePacket& inPacket, Entity::PlayerPtr pPlayer ); typedef std::map< uint16_t, Handler > HandlerMap; typedef std::map< uint16_t, std::string > HandlerStrMap; diff --git a/src/servers/Server_Zone/InventoryHandler.cpp b/src/servers/Server_Zone/InventoryHandler.cpp index 95c3e13e..766f98c7 100644 --- a/src/servers/Server_Zone/InventoryHandler.cpp +++ b/src/servers/Server_Zone/InventoryHandler.cpp @@ -54,15 +54,15 @@ using namespace Core::Network::Packets; using namespace Core::Network::Packets::Server; -void Core::Network::GameConnection::inventoryModifyHandler( Core::Network::Packets::GamePacketPtr pInPacket, +void Core::Network::GameConnection::inventoryModifyHandler( const Core::Network::Packets::GamePacket& inPacket, Core::Entity::PlayerPtr pPlayer ) { - uint32_t seq = pInPacket->getValAt< uint32_t >( 0x20 ); - uint8_t action = pInPacket->getValAt< uint8_t >( 0x24 ); - uint8_t fromSlot = pInPacket->getValAt< uint8_t >( 0x30 ); - uint8_t toSlot = pInPacket->getValAt< uint8_t >( 0x44 ); - uint16_t fromContainer = pInPacket->getValAt< uint16_t >( 0x2C ); - uint16_t toContainer = pInPacket->getValAt< uint16_t >( 0x40 ); + uint32_t seq = inPacket.getValAt< uint32_t >( 0x20 ); + uint8_t action = inPacket.getValAt< uint8_t >( 0x24 ); + uint8_t fromSlot = inPacket.getValAt< uint8_t >( 0x30 ); + uint8_t toSlot = inPacket.getValAt< uint8_t >( 0x44 ); + uint16_t fromContainer = inPacket.getValAt< uint16_t >( 0x2C ); + uint16_t toContainer = inPacket.getValAt< uint16_t >( 0x40 ); GamePacketNew< FFXIVIpcInventoryActionAck > ackPacket( pPlayer->getId() ); ackPacket.data().sequence = seq; @@ -70,7 +70,7 @@ void Core::Network::GameConnection::inventoryModifyHandler( Core::Network::Packe pPlayer->queuePacket( ackPacket ); - g_log.debug( pInPacket->toString() ); + g_log.debug( inPacket.toString() ); g_log.debug( "InventoryAction: " + std::to_string( action ) ); // TODO: other inventory operations need to be implemented diff --git a/src/servers/Server_Zone/PacketHandlers.cpp b/src/servers/Server_Zone/PacketHandlers.cpp index 1ebd516f..8770d992 100644 --- a/src/servers/Server_Zone/PacketHandlers.cpp +++ b/src/servers/Server_Zone/PacketHandlers.cpp @@ -53,24 +53,24 @@ using namespace Core::Common; using namespace Core::Network::Packets; using namespace Core::Network::Packets::Server; -void Core::Network::GameConnection::fcInfoReqHandler( Core::Network::Packets::GamePacketPtr pInPacket, - Core::Entity::PlayerPtr pPlayer ) +void Core::Network::GameConnection::fcInfoReqHandler( const Core::Network::Packets::GamePacket& inPacket, + Core::Entity::PlayerPtr pPlayer ) { GamePacketPtr pPe( new GamePacket( 0xDD, 0x78, pPlayer->getId(), pPlayer->getId() ) ); pPe->setValAt< uint8_t >( 0x48, 0x01 ); queueOutPacket( pPe ); } -void Core::Network::GameConnection::setSearchInfoHandler( Core::Network::Packets::GamePacketPtr pInPacket, +void Core::Network::GameConnection::setSearchInfoHandler( const Core::Network::Packets::GamePacket& inPacket, Core::Entity::PlayerPtr pPlayer ) { - uint32_t inval = pInPacket->getValAt< uint32_t >( 0x20 ); - uint32_t inval1 = pInPacket->getValAt< uint32_t >( 0x24 ); - uint64_t status = pInPacket->getValAt< uint64_t >( 0x20 ); + uint32_t inval = inPacket.getValAt< uint32_t >( 0x20 ); + uint32_t inval1 = inPacket.getValAt< uint32_t >( 0x24 ); + uint64_t status = inPacket.getValAt< uint64_t >( 0x20 ); - uint8_t selectRegion = pInPacket->getValAt< uint8_t >( 0x31 ); + uint8_t selectRegion = inPacket.getValAt< uint8_t >( 0x31 ); - pPlayer->setSearchInfo( selectRegion, 0, pInPacket->getStringAt( 0x32 ) ); + pPlayer->setSearchInfo( selectRegion, 0, inPacket.getStringAt( 0x32 ) ); pPlayer->setOnlineStatusMask( status ); @@ -96,7 +96,7 @@ void Core::Network::GameConnection::setSearchInfoHandler( Core::Network::Packets true ); } -void Core::Network::GameConnection::reqSearchInfoHandler( Core::Network::Packets::GamePacketPtr pInPacket, +void Core::Network::GameConnection::reqSearchInfoHandler( const Core::Network::Packets::GamePacket& inPacket, Core::Entity::PlayerPtr pPlayer ) { GamePacketNew< FFXIVIpcInitSearchInfo > searchInfoPacket( pPlayer->getId() ); @@ -106,14 +106,14 @@ void Core::Network::GameConnection::reqSearchInfoHandler( Core::Network::Packets queueOutPacket( searchInfoPacket ); } -void Core::Network::GameConnection::linkshellListHandler( Core::Network::Packets::GamePacketPtr pInPacket, +void Core::Network::GameConnection::linkshellListHandler( const Core::Network::Packets::GamePacket& inPacket, Core::Entity::PlayerPtr pPlayer ) { GamePacketNew< FFXIVIpcLinkshellList > linkshellListPacket( pPlayer->getId() ); queueOutPacket( linkshellListPacket ); } -void Core::Network::GameConnection::updatePositionHandler( Core::Network::Packets::GamePacketPtr pInPacket, +void Core::Network::GameConnection::updatePositionHandler( const Core::Network::Packets::GamePacket& inPacket, Core::Entity::PlayerPtr pPlayer ) { // if the player is marked for zoning we no longer want to update his pos @@ -148,10 +148,10 @@ void Core::Network::GameConnection::updatePositionHandler( Core::Network::Packet uint16_t bit16 : 1; } IPC_OP_019AB; - uint16_t flags = pInPacket->getValAt( 0x28 ); + uint16_t flags = inPacket.getValAt( 0x28 ); memcpy( &IPC_OP_019AB, &flags, 2 ); - uint32_t flags1 = pInPacket->getValAt( 0x24 ); + uint32_t flags1 = inPacket.getValAt( 0x24 ); memcpy( &IPC_OP_019A, &flags1, 4 ); //g_log.Log(LoggingSeverity::debug, "" + boost::lexical_cast((int)IPC_OP_019AB.bit1) @@ -182,17 +182,17 @@ void Core::Network::GameConnection::updatePositionHandler( Core::Network::Packet //pInPacket->debugPrint(); bool bPosChanged = false; - if( ( pPlayer->getPos().x != pInPacket->getValAt< float >( 0x2c ) ) || - ( pPlayer->getPos().y != pInPacket->getValAt< float >( 0x30 ) ) || - ( pPlayer->getPos().z != pInPacket->getValAt< float >( 0x34 ) ) ) + if( ( pPlayer->getPos().x != inPacket.getValAt< float >( 0x2c ) ) || + ( pPlayer->getPos().y != inPacket.getValAt< float >( 0x30 ) ) || + ( pPlayer->getPos().z != inPacket.getValAt< float >( 0x34 ) ) ) bPosChanged = true; - if( !bPosChanged && pPlayer->getRotation() == pInPacket->getValAt< float >( 0x20 ) ) + if( !bPosChanged && pPlayer->getRotation() == inPacket.getValAt< float >( 0x20 ) ) return; - pPlayer->setRotation( pInPacket->getValAt< float >( 0x20 ) ); - pPlayer->setPosition( pInPacket->getValAt< float >( 0x2c ), - pInPacket->getValAt< float >( 0x30 ), - pInPacket->getValAt< float >( 0x34 ) ); + pPlayer->setRotation( inPacket.getValAt< float >( 0x20 ) ); + pPlayer->setPosition( inPacket.getValAt< float >( 0x2c ), + inPacket.getValAt< float >( 0x30 ), + inPacket.getValAt< float >( 0x34 ) ); pPlayer->setSyncFlag( PlayerSyncFlags::Position ); @@ -203,9 +203,9 @@ void Core::Network::GameConnection::updatePositionHandler( Core::Network::Packet if( !pPlayer->hasInRangeActor() ) return; - uint8_t unk = pInPacket->getValAt< uint8_t >( 0x29 ); + uint8_t unk = inPacket.getValAt< uint8_t >( 0x29 ); - uint16_t moveType = pInPacket->getValAt< uint16_t >( 0x28 ); + uint16_t moveType = inPacket.getValAt< uint16_t >( 0x28 ); uint8_t unk1 = 0; uint8_t unk2 = 0; @@ -291,10 +291,10 @@ void Core::Network::GameConnection::updatePositionHandler( Core::Network::Packet -void Core::Network::GameConnection::zoneLineHandler( Core::Network::Packets::GamePacketPtr pInPacket, +void Core::Network::GameConnection::zoneLineHandler( const Core::Network::Packets::GamePacket& inPacket, Core::Entity::PlayerPtr pPlayer ) { - uint32_t zoneLineId = pInPacket->getValAt< uint32_t >( 0x20 ); + uint32_t zoneLineId = inPacket.getValAt< uint32_t >( 0x20 ); pPlayer->sendDebug( "Walking ZoneLine " + std::to_string( zoneLineId ) ); @@ -336,10 +336,10 @@ void Core::Network::GameConnection::zoneLineHandler( Core::Network::Packets::Gam } -void Core::Network::GameConnection::discoveryHandler( Core::Network::Packets::GamePacketPtr pInPacket, +void Core::Network::GameConnection::discoveryHandler( const Core::Network::Packets::GamePacket& inPacket, Core::Entity::PlayerPtr pPlayer ) { - uint32_t ref_position_id = pInPacket->getValAt< uint32_t >( 0x20 ); + uint32_t ref_position_id = inPacket.getValAt< uint32_t >( 0x20 ); auto pQR = g_database.query( "SELECT id, map_id, discover_id " "FROM discoveryinfo " @@ -365,7 +365,7 @@ void Core::Network::GameConnection::discoveryHandler( Core::Network::Packets::Ga } -void Core::Network::GameConnection::playTimeHandler( Core::Network::Packets::GamePacketPtr pInPacket, +void Core::Network::GameConnection::playTimeHandler( const Core::Network::Packets::GamePacket& inPacket, Core::Entity::PlayerPtr pPlayer ) { GamePacketNew< FFXIVIpcPlayTime > playTimePacket( pPlayer->getId() ); @@ -374,7 +374,7 @@ void Core::Network::GameConnection::playTimeHandler( Core::Network::Packets::Gam } -void Core::Network::GameConnection::initHandler( Core::Network::Packets::GamePacketPtr pInPacket, +void Core::Network::GameConnection::initHandler( const Core::Network::Packets::GamePacket& inPacket, Core::Entity::PlayerPtr pPlayer ) { // init handler means this is a login procedure @@ -384,10 +384,10 @@ void Core::Network::GameConnection::initHandler( Core::Network::Packets::GamePac } -void Core::Network::GameConnection::blackListHandler( Core::Network::Packets::GamePacketPtr pInPacket, +void Core::Network::GameConnection::blackListHandler( const Core::Network::Packets::GamePacket& inPacket, Core::Entity::PlayerPtr pPlayer ) { - uint8_t count = pInPacket->getValAt< uint8_t >( 0x21 ); + uint8_t count = inPacket.getValAt< uint8_t >( 0x21 ); GamePacketNew< FFXIVIpcBlackList > blackListPacket( pPlayer->getId() ); blackListPacket.data().sequence = count; @@ -399,10 +399,10 @@ void Core::Network::GameConnection::blackListHandler( Core::Network::Packets::Ga } -void Core::Network::GameConnection::pingHandler( Core::Network::Packets::GamePacketPtr pInPacket, +void Core::Network::GameConnection::pingHandler( const Core::Network::Packets::GamePacket& inPacket, Core::Entity::PlayerPtr pPlayer ) { - int32_t inVal = pInPacket->getValAt< int32_t >( 0x20 ); + int32_t inVal = inPacket.getValAt< int32_t >( 0x20 ); PingPacket pingPacket( pPlayer, inVal ); queueOutPacket( pingPacket ); @@ -410,7 +410,7 @@ void Core::Network::GameConnection::pingHandler( Core::Network::Packets::GamePac } -void Core::Network::GameConnection::finishLoadingHandler( Core::Network::Packets::GamePacketPtr pInPacket, +void Core::Network::GameConnection::finishLoadingHandler( const Core::Network::Packets::GamePacket& inPacket, Core::Entity::PlayerPtr pPlayer ) { // player is done zoning @@ -431,12 +431,12 @@ void Core::Network::GameConnection::finishLoadingHandler( Core::Network::Packets pPlayer->getCurrentZone()->changeActorPosition( pPlayer ); } -void Core::Network::GameConnection::socialListHandler( Core::Network::Packets::GamePacketPtr pInPacket, +void Core::Network::GameConnection::socialListHandler( const Core::Network::Packets::GamePacket& inPacket, Core::Entity::PlayerPtr pPlayer ) { - uint8_t type = pInPacket->getValAt< uint8_t >( 0x2A ); - uint8_t count = pInPacket->getValAt< uint8_t >( 0x2B ); + uint8_t type = inPacket.getValAt< uint8_t >( 0x2A ); + uint8_t count = inPacket.getValAt< uint8_t >( 0x2B ); if( type == 0x02 ) { // party list @@ -489,13 +489,13 @@ void Core::Network::GameConnection::socialListHandler( Core::Network::Packets::G } -void Core::Network::GameConnection::chatHandler( Core::Network::Packets::GamePacketPtr pInPacket, +void Core::Network::GameConnection::chatHandler( const Core::Network::Packets::GamePacket& inPacket, Core::Entity::PlayerPtr pPlayer ) { - std::string chatString( pInPacket->getStringAt( 0x3a ) ); + std::string chatString( inPacket.getStringAt( 0x3a ) ); - uint32_t sourceId = pInPacket->getValAt< uint32_t >( 0x24 ); + uint32_t sourceId = inPacket.getValAt< uint32_t >( 0x24 ); if( chatString.at( 0 ) == '@' ) { @@ -504,7 +504,7 @@ void Core::Network::GameConnection::chatHandler( Core::Network::Packets::GamePac return; } - ChatType chatType = static_cast( pInPacket->getValAt< uint8_t >( 0x38 ) ); + ChatType chatType = static_cast( inPacket.getValAt< uint8_t >( 0x38 ) ); //ToDo, need to implement sending GM chat types. ChatPacket chatPacket( pPlayer, chatType, chatString ); @@ -539,7 +539,7 @@ void Core::Network::GameConnection::chatHandler( Core::Network::Packets::GamePac // currently we wait for the session to just time out after logout, this can be a problem is the user tries to // log right back in. // Also the packet needs to be converted to an ipc structure -void Core::Network::GameConnection::logoutHandler( Core::Network::Packets::GamePacketPtr pInPacket, +void Core::Network::GameConnection::logoutHandler( const Core::Network::Packets::GamePacket& inPacket, Core::Entity::PlayerPtr pPlayer ) { GamePacketNew< FFXIVIpcLogout > logoutPacket( pPlayer->getId() ); diff --git a/src/servers/Server_Zone/SkillHandler.cpp b/src/servers/Server_Zone/SkillHandler.cpp index b6e262cf..5ebda338 100644 --- a/src/servers/Server_Zone/SkillHandler.cpp +++ b/src/servers/Server_Zone/SkillHandler.cpp @@ -48,14 +48,14 @@ using namespace Core::Common; using namespace Core::Network::Packets; using namespace Core::Network::Packets::Server; -void Core::Network::GameConnection::skillHandler( Core::Network::Packets::GamePacketPtr pInPacket, +void Core::Network::GameConnection::skillHandler( const Core::Network::Packets::GamePacket& inPacket, Core::Entity::PlayerPtr pPlayer ) { - uint32_t action = pInPacket->getValAt< uint32_t >( 0x24 ); - uint32_t useCount = pInPacket->getValAt< uint32_t >( 0x28 ); + uint32_t action = inPacket.getValAt< uint32_t >( 0x24 ); + uint32_t useCount = inPacket.getValAt< uint32_t >( 0x28 ); - uint64_t targetId = pInPacket->getValAt< uint64_t >( 0x30 ); + uint64_t targetId = inPacket.getValAt< uint64_t >( 0x30 ); if( action < 1000000 ) // normal action {