mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-30 16:17:46 +00:00
Moved ls logic from packetHandler to linkshellHandler, improved invite logic
This commit is contained in:
parent
85bbe38562
commit
47df62f0b4
5 changed files with 86 additions and 64 deletions
|
@ -992,16 +992,6 @@ namespace Sapphire::Common
|
||||||
ReceivedRequest = 0x30
|
ReceivedRequest = 0x30
|
||||||
};
|
};
|
||||||
|
|
||||||
enum LinkshellHierarchy : int32_t
|
|
||||||
{
|
|
||||||
NONE_1 = 0x0,
|
|
||||||
MASTER = 0x1,
|
|
||||||
LEADER = 0x2,
|
|
||||||
MEMBER = 0x3,
|
|
||||||
INVITE = 0x4,
|
|
||||||
MAX_0 = 0x7,
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace Ls
|
namespace Ls
|
||||||
{
|
{
|
||||||
enum LinkshellHierarchyShifted : int32_t
|
enum LinkshellHierarchyShifted : int32_t
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
#include <Network/GamePacket.h>
|
#include <Network/GamePacket.h>
|
||||||
#include <Network/PacketDef/Zone/ServerZoneDef.h>
|
#include <Network/PacketDef/Zone/ServerZoneDef.h>
|
||||||
|
|
||||||
|
#include "Session.h"
|
||||||
|
|
||||||
using namespace Sapphire::Common;
|
using namespace Sapphire::Common;
|
||||||
using namespace Sapphire::Network::Packets;
|
using namespace Sapphire::Network::Packets;
|
||||||
using namespace Sapphire::Network::Packets::WorldPackets::Server;
|
using namespace Sapphire::Network::Packets::WorldPackets::Server;
|
||||||
|
@ -246,4 +248,50 @@ const std::vector< Sapphire::LinkshellPtr > Sapphire::World::Manager::LinkshellM
|
||||||
return lsVec;
|
return lsVec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LinkshellMgr::invitePlayer( const std::string &name, uint64_t linkshellId )
|
||||||
|
{
|
||||||
|
auto& server = Common::Service< World::WorldServer >::ref();
|
||||||
|
|
||||||
|
auto invitedPlayer = server.getSession( name );
|
||||||
|
auto lsPtr = getLinkshellById( linkshellId );
|
||||||
|
|
||||||
|
if( !invitedPlayer || !lsPtr )
|
||||||
|
return Logger::warn( "Failed to invite player to linkshell - session/linkshell not found!" );
|
||||||
|
|
||||||
|
lsPtr->addInvite( invitedPlayer->getPlayer()->getCharacterId() );
|
||||||
|
writeLinkshell( lsPtr->getId() );
|
||||||
|
sendLinkshellList( *invitedPlayer->getPlayer() );
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinkshellMgr::sendLinkshellList( Entity::Player& player )
|
||||||
|
{
|
||||||
|
auto& server = Common::Service< World::WorldServer >::ref();
|
||||||
|
|
||||||
|
auto linkshellListPacket = makeZonePacket< FFXIVIpcGetLinkshellListResult >( player.getId() );
|
||||||
|
|
||||||
|
auto lsVec = getPlayerLinkshells( player );
|
||||||
|
|
||||||
|
for( int i = 0; i < lsVec.size(); ++i )
|
||||||
|
{
|
||||||
|
auto pLs = lsVec[ i ];
|
||||||
|
uint32_t hierarchy = 0;
|
||||||
|
|
||||||
|
if( pLs->getMasterId() == player.getCharacterId() )
|
||||||
|
hierarchy = Ls::LinkshellHierarchyShifted::Master;
|
||||||
|
else if( pLs->getLeaderIdList().count( player.getCharacterId() ) )
|
||||||
|
hierarchy = Ls::LinkshellHierarchyShifted::Leader;
|
||||||
|
else if( pLs->getInviteIdList().count( player.getCharacterId() ) )
|
||||||
|
hierarchy = Ls::LinkshellHierarchyShifted::Invite;
|
||||||
|
else
|
||||||
|
hierarchy = Ls::LinkshellHierarchyShifted::Member;
|
||||||
|
|
||||||
|
linkshellListPacket->data().LinkshellList[ i ].LinkshellID = pLs->getId();
|
||||||
|
linkshellListPacket->data().LinkshellList[ i ].ChannelID = pLs->getChatChannel();
|
||||||
|
linkshellListPacket->data().LinkshellList[ i ].HierarchyID = hierarchy;
|
||||||
|
strcpy( linkshellListPacket->data().LinkshellList[ i ].LinkshellName, pLs->getName().c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
|
server.queueForPlayer( player.getCharacterId(), linkshellListPacket );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,10 @@ namespace Sapphire::World::Manager
|
||||||
|
|
||||||
void finishLinkshellCreation( const std::string& name, uint32_t result, Entity::Player& player );
|
void finishLinkshellCreation( const std::string& name, uint32_t result, Entity::Player& player );
|
||||||
|
|
||||||
|
void invitePlayer( const std::string& name, uint64_t linkshellId );
|
||||||
|
|
||||||
|
void sendLinkshellList( Entity::Player& player );
|
||||||
|
|
||||||
// get all linkshells associated with player
|
// get all linkshells associated with player
|
||||||
const std::vector< LinkshellPtr > getPlayerLinkshells( Entity::Player& player ) const;
|
const std::vector< LinkshellPtr > getPlayerLinkshells( Entity::Player& player ) const;
|
||||||
|
|
||||||
|
|
33
src/world/Network/Handlers/LinkshellHandlers.cpp
Normal file
33
src/world/Network/Handlers/LinkshellHandlers.cpp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#include <Common.h>
|
||||||
|
#include <Network/CommonNetwork.h>
|
||||||
|
#include <Network/GamePacket.h>
|
||||||
|
|
||||||
|
#include <Network/PacketContainer.h>
|
||||||
|
#include <Exd/ExdData.h>
|
||||||
|
#include <Service.h>
|
||||||
|
#include <Network/PacketDef/Zone/ClientZoneDef.h>
|
||||||
|
|
||||||
|
#include "Network/GameConnection.h"
|
||||||
|
|
||||||
|
#include "Session.h"
|
||||||
|
#include "Actor/Player.h"
|
||||||
|
#include "Manager/LinkshellMgr.h"
|
||||||
|
|
||||||
|
using namespace Sapphire::Common;
|
||||||
|
using namespace Sapphire::Network::Packets;
|
||||||
|
using namespace Sapphire::Network::Packets::WorldPackets;
|
||||||
|
using namespace Sapphire::World::Manager;
|
||||||
|
|
||||||
|
void Sapphire::Network::GameConnection::linkshellListHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||||
|
{
|
||||||
|
auto& lsMgr = Common::Service< LinkshellMgr >::ref();
|
||||||
|
lsMgr.sendLinkshellList( player );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sapphire::Network::GameConnection::linkshellJoinHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||||
|
{
|
||||||
|
const auto lsJoinPacket = ZoneChannelPacket< Client::FFXIVIpcLinkshellJoin >( inPacket );
|
||||||
|
auto& lsMgr = Common::Service< LinkshellMgr >::ref();
|
||||||
|
auto charName = std::string( lsJoinPacket.data().MemberCharacterName );
|
||||||
|
lsMgr.invitePlayer( charName, lsJoinPacket.data().LinkshellID );
|
||||||
|
}
|
|
@ -168,60 +168,7 @@ void Sapphire::Network::GameConnection::reqExamineFcInfo( const Packets::FFXIVAR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sapphire::Network::GameConnection::linkshellListHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
void Sapphire::Network::GameConnection::joinChatChannelHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
|
||||||
Entity::Player& player )
|
|
||||||
{
|
|
||||||
auto linkshellListPacket = makeZonePacket< FFXIVIpcGetLinkshellListResult >( player.getId() );
|
|
||||||
|
|
||||||
auto& lsMgr = Common::Service< LinkshellMgr >::ref();
|
|
||||||
auto& ccMgr = Common::Service< ChatChannelMgr >::ref();
|
|
||||||
|
|
||||||
auto lsVec = lsMgr.getPlayerLinkshells( player );
|
|
||||||
|
|
||||||
for( int i = 0; i < lsVec.size(); ++i )
|
|
||||||
{
|
|
||||||
auto pLs = lsVec[ i ];
|
|
||||||
uint32_t hierarchy = 0;
|
|
||||||
|
|
||||||
if( pLs->getMasterId() == player.getCharacterId() )
|
|
||||||
hierarchy = Ls::LinkshellHierarchyShifted::Master;
|
|
||||||
else if( pLs->getLeaderIdList().count( player.getCharacterId() ) )
|
|
||||||
hierarchy = Ls::LinkshellHierarchyShifted::Leader;
|
|
||||||
else if( pLs->getInviteIdList().count( player.getCharacterId() ) )
|
|
||||||
hierarchy = Ls::LinkshellHierarchyShifted::Invite;
|
|
||||||
else
|
|
||||||
hierarchy = Ls::LinkshellHierarchyShifted::Member;
|
|
||||||
|
|
||||||
linkshellListPacket->data().LinkshellList[ i ].LinkshellID = pLs->getId();
|
|
||||||
linkshellListPacket->data().LinkshellList[ i ].ChannelID = pLs->getChatChannel();
|
|
||||||
linkshellListPacket->data().LinkshellList[ i ].HierarchyID = hierarchy;
|
|
||||||
strcpy( linkshellListPacket->data().LinkshellList[ i ].LinkshellName, pLs->getName().c_str() );
|
|
||||||
}
|
|
||||||
|
|
||||||
queueOutPacket( linkshellListPacket );
|
|
||||||
}
|
|
||||||
|
|
||||||
void Sapphire::Network::GameConnection::linkshellJoinHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
|
||||||
Entity::Player& player )
|
|
||||||
{
|
|
||||||
const auto lsJoinPacket = ZoneChannelPacket< Client::FFXIVIpcLinkshellJoin >( inPacket );
|
|
||||||
|
|
||||||
auto& lsMgr = Common::Service< LinkshellMgr >::ref();
|
|
||||||
auto& server = Common::Service< World::WorldServer >::ref();
|
|
||||||
|
|
||||||
auto invitedPlayer = server.getSession( lsJoinPacket.data().MemberCharacterName );
|
|
||||||
auto lsPtr = lsMgr.getLinkshellById( lsJoinPacket.data().LinkshellID );
|
|
||||||
|
|
||||||
if( !invitedPlayer || !lsPtr )
|
|
||||||
return Logger::warn( "Failed to invite player to linkshell - session/linkshell not found!" );
|
|
||||||
|
|
||||||
lsPtr->addInvite( invitedPlayer->getPlayer()->getCharacterId() );
|
|
||||||
lsMgr.writeLinkshell( lsPtr->getId() );
|
|
||||||
// TODO: send inv packets
|
|
||||||
}
|
|
||||||
|
|
||||||
void Sapphire::Network::GameConnection::joinChatChannelHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
|
||||||
Entity::Player& player )
|
|
||||||
{
|
{
|
||||||
const auto joinChannelPacket = ZoneChannelPacket< Client::FFXIVIpcJoinChatChannel >( inPacket );
|
const auto joinChannelPacket = ZoneChannelPacket< Client::FFXIVIpcJoinChatChannel >( inPacket );
|
||||||
const uint64_t channelIdReq = joinChannelPacket.data().ChannelID;
|
const uint64_t channelIdReq = joinChannelPacket.data().ChannelID;
|
||||||
|
|
Loading…
Add table
Reference in a new issue