mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-02 00:47:45 +00:00
Implemented a switch to chose from zone or chat handlers
This commit is contained in:
parent
f4df52f3d9
commit
08ff069ee1
7 changed files with 247 additions and 148 deletions
|
@ -0,0 +1,34 @@
|
|||
#ifndef _CORE_NETWORK_PACKETS_CHAT_SERVER_IPC_H
|
||||
#define _CORE_NETWORK_PACKETS_CHAT_SERVER_IPC_H
|
||||
|
||||
#include "src/servers/Server_Common/Common.h"
|
||||
#include "src/servers/Server_Common/Network/CommonNetwork.h"
|
||||
|
||||
namespace Core {
|
||||
namespace Network {
|
||||
namespace Packets {
|
||||
namespace Server {
|
||||
|
||||
/**
|
||||
* Structural representation of the packet sent by the server as response
|
||||
* to a ping packet
|
||||
*/
|
||||
struct FFXIVIpcTell : FFXIVIpcBasePacket<Tell>
|
||||
{
|
||||
uint32_t u1;
|
||||
uint16_t u2a;
|
||||
uint16_t u2b;
|
||||
uint8_t preName;
|
||||
char receipientName[32];
|
||||
char msg[1031];
|
||||
};
|
||||
|
||||
|
||||
} /* Server */
|
||||
} /* Packets */
|
||||
} /* Network */
|
||||
} /* Core */
|
||||
|
||||
|
||||
|
||||
#endif /*_CORE_NETWORK_PACKETS_CHAT_SERVER_IPC_H*/
|
|
@ -114,7 +114,7 @@ namespace Packets {
|
|||
|
||||
// Unknown IPC types that still need to be sent
|
||||
// TODO: figure all these out properly
|
||||
IPCTYPE_UNK_320 = 0x1FB,
|
||||
IPCTYPE_UNK_320 = 0x1FB,
|
||||
IPCTYPE_UNK_322 = 0x1FD,
|
||||
|
||||
};
|
||||
|
@ -185,7 +185,7 @@ namespace Packets {
|
|||
*/
|
||||
enum ServerChatIpcType : uint16_t
|
||||
{
|
||||
Tell = 0x0064, // updated for sb
|
||||
Tell = 0x0064, // updated for sb
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -193,7 +193,7 @@ namespace Packets {
|
|||
*/
|
||||
enum ClientChatIpcType : uint16_t
|
||||
{
|
||||
TellReq = 0x0064,
|
||||
TellReq = 0x0064,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -9,132 +9,132 @@ namespace Network {
|
|||
namespace Packets {
|
||||
namespace Server {
|
||||
|
||||
struct FFXIVIpcRetainerList : FFXIVIpcBasePacket<LobbyRetainerList>
|
||||
{
|
||||
uint8_t padding[0x210];
|
||||
};
|
||||
struct FFXIVIpcRetainerList : FFXIVIpcBasePacket<LobbyRetainerList>
|
||||
{
|
||||
uint8_t padding[0x210];
|
||||
};
|
||||
|
||||
/**
|
||||
*/
|
||||
struct FFXIVIpcServiceIdInfo : FFXIVIpcBasePacket<LobbyServiceAccountList>
|
||||
struct FFXIVIpcServiceIdInfo : FFXIVIpcBasePacket<LobbyServiceAccountList>
|
||||
{
|
||||
uint64_t seq;
|
||||
uint8_t padding;
|
||||
uint8_t numServiceAccounts;
|
||||
uint8_t u1;
|
||||
uint8_t u2;
|
||||
uint32_t padding1;
|
||||
|
||||
struct
|
||||
{
|
||||
uint64_t seq;
|
||||
uint8_t padding;
|
||||
uint8_t numServiceAccounts;
|
||||
uint8_t u1;
|
||||
uint8_t u2;
|
||||
uint32_t id;
|
||||
uint32_t unknown;
|
||||
uint32_t index;
|
||||
char name[0x44];
|
||||
} serviceAccount[8];
|
||||
};
|
||||
|
||||
|
||||
struct FFXIVIpcServerList : FFXIVIpcBasePacket<LobbyServerList>
|
||||
{
|
||||
uint64_t seq;
|
||||
uint16_t final;
|
||||
uint16_t offset;
|
||||
uint32_t numServers;
|
||||
uint32_t padding;
|
||||
uint32_t padding1;
|
||||
|
||||
struct
|
||||
{
|
||||
uint16_t id;
|
||||
uint16_t index;
|
||||
uint32_t flags; // 0x02 = World not accepting new characters
|
||||
uint32_t padding1;
|
||||
|
||||
struct
|
||||
{
|
||||
uint32_t id;
|
||||
uint32_t unknown;
|
||||
uint32_t index;
|
||||
char name[0x44];
|
||||
} serviceAccount[8];
|
||||
};
|
||||
|
||||
|
||||
struct FFXIVIpcServerList : FFXIVIpcBasePacket<LobbyServerList>
|
||||
{
|
||||
uint64_t seq;
|
||||
uint16_t final;
|
||||
uint16_t offset;
|
||||
uint32_t numServers;
|
||||
uint32_t padding;
|
||||
uint32_t padding1;
|
||||
|
||||
struct
|
||||
{
|
||||
uint16_t id;
|
||||
uint16_t index;
|
||||
uint32_t flags; // 0x02 = World not accepting new characters
|
||||
uint32_t padding1;
|
||||
uint32_t icon; // 2 = bonus XP star
|
||||
uint32_t padding2;
|
||||
char name[0x40];
|
||||
} server[6];
|
||||
};
|
||||
|
||||
struct FFXIVIpcCharList : FFXIVIpcBasePacket<LobbyCharList>
|
||||
{
|
||||
uint64_t seq;
|
||||
uint8_t counter; // current packet count * 4, count * 4 +1 on last packet.
|
||||
uint8_t numInPacket; // always 2??
|
||||
uint16_t padding;
|
||||
uint8_t unknown1;
|
||||
uint8_t unknown2;
|
||||
uint8_t unknown3;
|
||||
uint8_t unknown4; // 0x80 in case of last packet
|
||||
uint32_t unknown5[7];
|
||||
uint8_t unknown6; // 0x80 in case of last packet
|
||||
uint8_t veteranRank;
|
||||
uint8_t unknown7;
|
||||
uint8_t padding1;
|
||||
uint32_t daysSubscribed;
|
||||
uint32_t remainingDays;
|
||||
uint32_t daysToNextRank;
|
||||
uint16_t maxCharOnWorld;
|
||||
uint16_t unknown8;
|
||||
uint32_t entitledExpansion;
|
||||
uint32_t icon; // 2 = bonus XP star
|
||||
uint32_t padding2;
|
||||
char name[0x40];
|
||||
} server[6];
|
||||
};
|
||||
|
||||
struct CharaDetails
|
||||
{
|
||||
uint32_t uniqueId;
|
||||
uint32_t padding;
|
||||
uint64_t contentId;
|
||||
uint32_t index;
|
||||
uint32_t padding2;
|
||||
uint16_t serverId;
|
||||
char nameChara[32];
|
||||
char nameServer[32];
|
||||
char charDetailJson[1030];
|
||||
} charaDetails[2];
|
||||
struct FFXIVIpcCharList : FFXIVIpcBasePacket<LobbyCharList>
|
||||
{
|
||||
uint64_t seq;
|
||||
uint8_t counter; // current packet count * 4, count * 4 +1 on last packet.
|
||||
uint8_t numInPacket; // always 2??
|
||||
uint16_t padding;
|
||||
uint8_t unknown1;
|
||||
uint8_t unknown2;
|
||||
uint8_t unknown3;
|
||||
uint8_t unknown4; // 0x80 in case of last packet
|
||||
uint32_t unknown5[7];
|
||||
uint8_t unknown6; // 0x80 in case of last packet
|
||||
uint8_t veteranRank;
|
||||
uint8_t unknown7;
|
||||
uint8_t padding1;
|
||||
uint32_t daysSubscribed;
|
||||
uint32_t remainingDays;
|
||||
uint32_t daysToNextRank;
|
||||
uint16_t maxCharOnWorld;
|
||||
uint16_t unknown8;
|
||||
uint32_t entitledExpansion;
|
||||
uint32_t padding2;
|
||||
|
||||
};
|
||||
|
||||
struct FFXIVIpcEnterWorld : FFXIVIpcBasePacket<LobbyEnterWorld>
|
||||
struct CharaDetails
|
||||
{
|
||||
uint64_t seq;
|
||||
uint32_t charId;
|
||||
uint32_t uniqueId;
|
||||
uint32_t padding;
|
||||
uint64_t contentId;
|
||||
uint32_t index;
|
||||
uint32_t padding2;
|
||||
char sid[66];
|
||||
uint16_t port;
|
||||
char host[48];
|
||||
uint64_t padding3;
|
||||
uint64_t padding4;
|
||||
};
|
||||
uint16_t serverId;
|
||||
char nameChara[32];
|
||||
char nameServer[32];
|
||||
char charDetailJson[1030];
|
||||
} charaDetails[2];
|
||||
|
||||
struct FFXIVIpcCharCreate : FFXIVIpcBasePacket<LobbyCharCreate>
|
||||
{
|
||||
uint64_t seq;
|
||||
uint8_t unknown;
|
||||
uint8_t unknown_2;
|
||||
uint8_t type;
|
||||
uint8_t padding;
|
||||
uint32_t unknown_3;
|
||||
uint32_t unknown_4;
|
||||
uint32_t unknown_5;
|
||||
uint64_t content_id;
|
||||
uint16_t unknown_7;
|
||||
uint16_t unknown_8;
|
||||
uint32_t unknown_9;
|
||||
uint16_t unknown_10;
|
||||
char name[32];
|
||||
char world[32];
|
||||
};
|
||||
};
|
||||
|
||||
struct FFXIVIpcLobbyError : FFXIVIpcBasePacket<LobbyError>
|
||||
{
|
||||
uint64_t seq;
|
||||
uint32_t error_id;
|
||||
uint32_t param;
|
||||
uint16_t message_id;
|
||||
char message[516];
|
||||
};
|
||||
struct FFXIVIpcEnterWorld : FFXIVIpcBasePacket<LobbyEnterWorld>
|
||||
{
|
||||
uint64_t seq;
|
||||
uint32_t charId;
|
||||
uint32_t padding;
|
||||
uint64_t contentId;
|
||||
uint32_t padding2;
|
||||
char sid[66];
|
||||
uint16_t port;
|
||||
char host[48];
|
||||
uint64_t padding3;
|
||||
uint64_t padding4;
|
||||
};
|
||||
|
||||
struct FFXIVIpcCharCreate : FFXIVIpcBasePacket<LobbyCharCreate>
|
||||
{
|
||||
uint64_t seq;
|
||||
uint8_t unknown;
|
||||
uint8_t unknown_2;
|
||||
uint8_t type;
|
||||
uint8_t padding;
|
||||
uint32_t unknown_3;
|
||||
uint32_t unknown_4;
|
||||
uint32_t unknown_5;
|
||||
uint64_t content_id;
|
||||
uint16_t unknown_7;
|
||||
uint16_t unknown_8;
|
||||
uint32_t unknown_9;
|
||||
uint16_t unknown_10;
|
||||
char name[32];
|
||||
char world[32];
|
||||
};
|
||||
|
||||
struct FFXIVIpcLobbyError : FFXIVIpcBasePacket<LobbyError>
|
||||
{
|
||||
uint64_t seq;
|
||||
uint32_t error_id;
|
||||
uint32_t param;
|
||||
uint16_t message_id;
|
||||
char message[516];
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
|
||||
void handleGamePacket( Packets::FFXIVARR_PACKET_RAW &pPacket );
|
||||
|
||||
void handleGamePacket( Packets::GamePacketPtr pPacket );
|
||||
void handlePacket( Packets::GamePacketPtr pPacket );
|
||||
|
||||
void sendPackets( Packets::PacketContainer * pPacket );
|
||||
|
||||
|
|
|
@ -34,7 +34,13 @@ Core::Network::GameConnection::GameConnection( Core::Network::HivePtr pHive,
|
|||
auto setZoneHandler = [=]( uint16_t opcode, std::string handlerName, GameConnection::Handler pHandler )
|
||||
{
|
||||
m_zoneHandlerMap[opcode] = pHandler;
|
||||
m_packetHandlerStrMap[opcode] = handlerName;
|
||||
m_zoneHandlerStrMap[opcode] = handlerName;
|
||||
};
|
||||
|
||||
auto setChatHandler = [=]( uint16_t opcode, std::string handlerName, GameConnection::Handler pHandler )
|
||||
{
|
||||
m_chatHandlerMap[opcode] = pHandler;
|
||||
m_chatHandlerStrMap[opcode] = handlerName;
|
||||
};
|
||||
|
||||
setZoneHandler( ClientZoneIpcType::PingHandler, "PingHandler", &GameConnection::pingHandler );
|
||||
|
@ -84,6 +90,9 @@ Core::Network::GameConnection::GameConnection( Core::Network::HivePtr pHive,
|
|||
setZoneHandler( ClientZoneIpcType::CFRegisterRoulette, "CFRegisterRoulette", &GameConnection::cfRegisterRoulette );
|
||||
setZoneHandler( ClientZoneIpcType::CFCommenceHandler, "CFDutyAccepted", &GameConnection::cfDutyAccepted);
|
||||
|
||||
|
||||
setChatHandler( ClientChatIpcType::TellReq, "TellReq", &GameConnection::tellHandler);
|
||||
|
||||
}
|
||||
|
||||
Core::Network::GameConnection::~GameConnection()
|
||||
|
@ -134,40 +143,78 @@ void Core::Network::GameConnection::queueOutPacket( Core::Network::Packets::Game
|
|||
m_outQueue.push( outPacket );
|
||||
}
|
||||
|
||||
void Core::Network::GameConnection::handleGamePacket( Core::Network::Packets::GamePacketPtr pPacket )
|
||||
void Core::Network::GameConnection::handleZonePacket( const Packets::GamePacket& pPacket )
|
||||
{
|
||||
auto it = m_zoneHandlerMap.find( pPacket.getSubType() );
|
||||
|
||||
std::string sessionStr = "[" + std::to_string( m_pSession->getId() ) + "]";
|
||||
|
||||
if( it != m_zoneHandlerMap.end() )
|
||||
{
|
||||
auto itStr = m_zoneHandlerStrMap.find( pPacket.getSubType() );
|
||||
std::string name = itStr != m_zoneHandlerStrMap.end() ? itStr->second : "unknown";
|
||||
// dont display packet notification if it is a ping or pos update, don't want the spam
|
||||
if( pPacket.getSubType() != PingHandler &&
|
||||
pPacket.getSubType() != UpdatePositionHandler )
|
||||
|
||||
g_log.debug( sessionStr + " Handling Zone IPC : " + name + "( " +
|
||||
boost::str( boost::format( "%|04X|" ) %
|
||||
static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) + " )" );
|
||||
|
||||
( this->*( it->second ) )( pPacket, m_pSession->getPlayer() );
|
||||
}
|
||||
else
|
||||
{
|
||||
g_log.debug( sessionStr + " Undefined Zone IPC : Unknown ( " +
|
||||
boost::str( boost::format( "%|04X|" ) %
|
||||
static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) + " )" );
|
||||
g_log.debug( pPacket.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Core::Network::GameConnection::handleChatPacket( const Packets::GamePacket& pPacket )
|
||||
{
|
||||
auto it = m_chatHandlerMap.find( pPacket.getSubType() );
|
||||
|
||||
std::string sessionStr = "[" + std::to_string( m_pSession->getId() ) + "]";
|
||||
|
||||
if( it != m_chatHandlerMap.end() )
|
||||
{
|
||||
auto itStr = m_chatHandlerStrMap.find( pPacket.getSubType() );
|
||||
std::string name = itStr != m_chatHandlerStrMap.end() ? itStr->second : "unknown";
|
||||
// dont display packet notification if it is a ping or pos update, don't want the spam
|
||||
|
||||
g_log.debug( sessionStr + " Handling Chat IPC : " + name + "( " +
|
||||
boost::str( boost::format( "%|04X|" ) %
|
||||
static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) + " )" );
|
||||
|
||||
( this->*( it->second ) )( pPacket, m_pSession->getPlayer() );
|
||||
}
|
||||
else
|
||||
{
|
||||
g_log.debug( sessionStr + " Undefined Chat IPC : Unknown ( " +
|
||||
boost::str( boost::format( "%|04X|" ) %
|
||||
static_cast< uint32_t >( pPacket.getSubType() & 0xFFFF ) ) + " )" );
|
||||
g_log.debug( pPacket.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
void Core::Network::GameConnection::handlePacket( Core::Network::Packets::GamePacketPtr pPacket )
|
||||
{
|
||||
if( !m_pSession )
|
||||
return;
|
||||
|
||||
/*if( m_conType == Network::ConnectionType::Zone )
|
||||
switch( m_conType )
|
||||
{
|
||||
g_log.debug( "Zone Packet" );
|
||||
case Network::ConnectionType::Zone:
|
||||
handleZonePacket( *pPacket );
|
||||
break;
|
||||
|
||||
case Network::ConnectionType::Chat:
|
||||
handleChatPacket( *pPacket );
|
||||
break;
|
||||
}
|
||||
else if( m_conType == Network::ConnectionType::Chat )
|
||||
{
|
||||
g_log.debug( "Chat Packet" );
|
||||
}*/
|
||||
|
||||
auto it = m_zoneHandlerMap.find( pPacket->getSubType() );
|
||||
|
||||
if( it != m_zoneHandlerMap.end() )
|
||||
{
|
||||
auto name = m_packetHandlerStrMap[pPacket->getSubType()];
|
||||
// dont display packet notification if it is a ping or pos update, don't want the spam
|
||||
if( pPacket->getSubType() != ClientZoneIpcType::PingHandler &&
|
||||
pPacket->getSubType() != ClientZoneIpcType::UpdatePositionHandler )
|
||||
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() );
|
||||
}
|
||||
else
|
||||
{
|
||||
g_log.debug( "[" + std::to_string( m_pSession->getId() ) + "] Undefined packet : Unknown ( " +
|
||||
boost::str( boost::format( "%|04X|" ) % static_cast< uint32_t >( pPacket->getSubType() & 0xFFFF ) ) + " )" );
|
||||
g_log.debug( pPacket->toString() );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -185,7 +232,7 @@ void Core::Network::GameConnection::processInQueue()
|
|||
// handle the incoming game packets
|
||||
while( auto pPacket = m_inQueue.pop() )
|
||||
{
|
||||
handleGamePacket( pPacket );
|
||||
handlePacket(pPacket);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,9 +36,13 @@ private:
|
|||
|
||||
AcceptorPtr m_pAcceptor;
|
||||
|
||||
// handler for game packets (main type 0x03)
|
||||
// handler for game packets (main type 0x03, connection type 1)
|
||||
HandlerMap m_zoneHandlerMap;
|
||||
HandlerStrMap m_packetHandlerStrMap;
|
||||
HandlerStrMap m_zoneHandlerStrMap;
|
||||
|
||||
// handler for game packets (main type 0x03, connection type 2)
|
||||
HandlerMap m_chatHandlerMap;
|
||||
HandlerStrMap m_chatHandlerStrMap;
|
||||
|
||||
SessionPtr m_pSession;
|
||||
|
||||
|
@ -70,7 +74,11 @@ public:
|
|||
void processInQueue();
|
||||
void processOutQueue();
|
||||
|
||||
void handleGamePacket( Packets::GamePacketPtr pPacket );
|
||||
void handlePacket( Packets::GamePacketPtr pPacket );
|
||||
|
||||
void handleZonePacket( const Packets::GamePacket& pPacket );
|
||||
|
||||
void handleChatPacket( const Packets::GamePacket& pPacket );
|
||||
|
||||
void sendPackets( Packets::PacketContainer * pPacket );
|
||||
|
||||
|
@ -108,6 +116,8 @@ public:
|
|||
DECLARE_HANDLER( gm1Handler );
|
||||
DECLARE_HANDLER( gm2Handler );
|
||||
|
||||
DECLARE_HANDLER( tellHandler );
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -542,3 +542,11 @@ void Core::Network::GameConnection::logoutHandler( const Packets::GamePacket& in
|
|||
logoutPacket.data().flags2 = 0x2000;
|
||||
queueOutPacket( logoutPacket );
|
||||
}
|
||||
|
||||
|
||||
void Core::Network::GameConnection::tellHandler( const Packets::GamePacket& inPacket,
|
||||
Entity::PlayerPtr pPlayer )
|
||||
{
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue