mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-27 20:07:45 +00:00
Apply new framework to social model
This commit is contained in:
parent
30cc6644cd
commit
fefaedf03f
8 changed files with 51 additions and 37 deletions
|
@ -41,6 +41,7 @@
|
|||
#include "Action/Action.h"
|
||||
#include "Action/ActionTeleport.h"
|
||||
#include "Social/Manager/SocialMgr.h"
|
||||
#include "Social/FriendList.h"
|
||||
|
||||
#include "Session.h"
|
||||
#include "ServerZone.h"
|
||||
|
@ -485,7 +486,7 @@ void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket
|
|||
|
||||
uint16_t i = 0;
|
||||
|
||||
auto playerFriendsList = g_framework.getFriendsListMgr().findGroupById( player.getFriendsListId() );
|
||||
auto playerFriendsList = g_fw.get< Social::SocialMgr< Social::FriendList > >()->findGroupById( player.getFriendsListId() );
|
||||
|
||||
// todo: move this garbage else fucking where
|
||||
for ( auto member : playerFriendsList.getMembers() )
|
||||
|
@ -494,7 +495,7 @@ void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket
|
|||
if ( i == 10 )
|
||||
break;
|
||||
|
||||
g_framework.getLogger().debug( "aaa" + std::to_string( i ) + ": " + member.second.name );
|
||||
g_fw.get< Logger >()->debug( "aaa" + std::to_string( i ) + ": " + member.second.name );
|
||||
listPacket.data().entries[i] = Core::Social::Group::generatePlayerEntry( member.second );
|
||||
i++;
|
||||
}
|
||||
|
@ -545,15 +546,15 @@ void Core::Network::GameConnection::socialReqResponseHandler( const Packets::Gam
|
|||
return;
|
||||
}*/
|
||||
|
||||
g_framework.getLogger().debug( std::to_string( static_cast<uint8_t>( action ) ) );
|
||||
g_fw.get< Logger >()->debug( std::to_string( static_cast<uint8_t>( action ) ) );
|
||||
|
||||
auto pSession = g_framework.getServerZone().getSession( targetId );
|
||||
auto pSession = g_fw.get< ServerZone >()->getSession( targetId );
|
||||
|
||||
// todo: notify both inviter/invitee with 0x00CB packet
|
||||
|
||||
if( pSession )
|
||||
{
|
||||
g_framework.getLogger().debug( std::to_string(static_cast<uint8_t>(action)) );
|
||||
g_fw.get< Logger >()->debug( std::to_string(static_cast<uint8_t>(action)) );
|
||||
}
|
||||
response.data().response = Common::SocialRequestResponse::Accept;
|
||||
memcpy( &( response.data().name ), name.c_str(), 32 );
|
||||
|
@ -567,7 +568,7 @@ void Core::Network::GameConnection::socialReqSendHandler( const Packets::GamePac
|
|||
auto category = inPacket.getValAt< Common::SocialCategory >( 0x20 );
|
||||
auto name = std::string( inPacket.getStringAt( 0x21 ) );
|
||||
|
||||
auto pSession = g_framework.getServerZone().getSession( name );
|
||||
auto pSession = g_fw.get< ServerZone >()->getSession( name );
|
||||
|
||||
// only the requester needs the response
|
||||
ZoneChannelPacket< FFXIVIpcSocialRequestError > response( player.getId() );
|
||||
|
@ -697,7 +698,7 @@ void Core::Network::GameConnection::socialReqSendHandler( const Packets::GamePac
|
|||
pRecipient->queuePacket( packet );
|
||||
pRecipient->sendDebug( "ding ding" );
|
||||
|
||||
auto recipientFriendsList = g_framework.getFriendsListMgr().findGroupById( pRecipient->getFriendsListId() );
|
||||
auto recipientFriendsList = g_fw.get< Social::SocialMgr< Social::FriendList > >()->findGroupById( pRecipient->getFriendsListId() );
|
||||
|
||||
auto senderResultPacket = recipientFriendsList.inviteMember( player.getAsPlayer(), pRecipient, player.getId(), pRecipient->getId() );
|
||||
|
||||
|
@ -705,7 +706,7 @@ void Core::Network::GameConnection::socialReqSendHandler( const Packets::GamePac
|
|||
|
||||
if ( recipientFriendsList.isFriendList() )
|
||||
{
|
||||
g_framework.getLogger().debug( "he HAA HAAA" );
|
||||
g_fw.get< Logger >()->debug( "he HAA HAAA" );
|
||||
}
|
||||
|
||||
response.data().messageId = typeMessage[category];
|
||||
|
@ -714,7 +715,7 @@ void Core::Network::GameConnection::socialReqSendHandler( const Packets::GamePac
|
|||
|
||||
player.queuePacket( response );
|
||||
// todo: handle party, friend request
|
||||
g_framework.getLogger().debug("sent to " + name);
|
||||
g_fw.get< Logger >()->debug( "sent to " + name );
|
||||
}
|
||||
|
||||
void Core::Network::GameConnection::chatHandler( const Packets::GamePacket& inPacket,
|
||||
|
|
|
@ -183,7 +183,7 @@ void Core::ServerZone::run( int32_t argc, char* argv[] )
|
|||
return;
|
||||
}
|
||||
|
||||
g_framework.getFriendsListMgr().findGroupById( 0 );
|
||||
//g_framework.getFriendsListMgr().findGroupById( 0 );
|
||||
|
||||
Network::HivePtr hive( new Network::Hive() );
|
||||
Network::addServerToHive< Network::GameConnection >( m_ip, m_port, hive );
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
#include <cassert>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <common/Logging/Logger.h>
|
||||
#include <Logging/Logger.h>
|
||||
|
||||
#include <sapphire_zone/Session.h>
|
||||
#include <common/Network/PacketDef/Ipcs.h>
|
||||
#include <common/Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
#include <Network/PacketDef/Ipcs.h>
|
||||
#include <Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
#include <sapphire_zone/Actor/Actor.h>
|
||||
#include <sapphire_zone/Actor/Player.h>
|
||||
#include <sapphire_zone/ServerZone.h>
|
||||
#include <sapphire_zone/Zone/Zone.h>
|
||||
#include <common/Network/GamePacketNew.h>
|
||||
|
||||
#include <Network/GamePacketNew.h>
|
||||
#include "Group.h"
|
||||
#include "FriendList.h"
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef _FRIENDLIST_H
|
||||
#define _FRIENDLIST_H
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
#include <common/Forwards.h>
|
||||
#include <Common.h>
|
||||
#include <Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
#include <Forwards.h>
|
||||
#include <sapphire_zone/Forwards.h>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <set>
|
||||
|
|
|
@ -1,23 +1,25 @@
|
|||
#include <cassert>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <common/Logging/Logger.h>
|
||||
#include <Logging/Logger.h>
|
||||
|
||||
#include <sapphire_zone/Session.h>
|
||||
#include <common/Network/PacketDef/Ipcs.h>
|
||||
#include <common/Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
#include <Network/PacketDef/Ipcs.h>
|
||||
#include <Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
#include <sapphire_zone/Actor/Actor.h>
|
||||
#include <sapphire_zone/Actor/Player.h>
|
||||
#include <sapphire_zone/ServerZone.h>
|
||||
#include <sapphire_zone/Zone/Zone.h>
|
||||
#include <common/Network/GamePacketNew.h>
|
||||
#include "Group.h"
|
||||
#include <Network/GamePacketNew.h>
|
||||
|
||||
extern Core::ServerZone g_serverZone;
|
||||
extern Core::Logger g_log;
|
||||
#include "Group.h"
|
||||
#include "Framework.h"
|
||||
#include "Forwards.h"
|
||||
|
||||
extern Core::Framework g_fw;
|
||||
|
||||
using namespace Core::Social;
|
||||
using namespace Core::Network;
|
||||
|
||||
// todo: i fuckin have no fuckin clue how to use group manager classes, why not just have a map of <id, group>?
|
||||
// todo: invite map in g_serverZone.getGroupMgr(GroupType) and look up
|
||||
|
||||
Core::Network::Packets::GamePacketPtr Group::addMember( Core::Entity::PlayerPtr pSender, Core::Entity::PlayerPtr pRecipient, uint64_t senderId, uint64_t recipientId )
|
||||
|
@ -66,11 +68,12 @@ Core::Network::Packets::GamePacketPtr Group::addMember( Core::Entity::PlayerPtr
|
|||
return packet;
|
||||
}
|
||||
|
||||
Core::Network::Packets::GamePacketPtr Group::inviteMember( Core::Entity::PlayerPtr pSender, Core::Entity::PlayerPtr pRecipient, uint64_t senderId, uint64_t recipientId )
|
||||
Packets::GamePacketPtr Group::inviteMember( Core::Entity::PlayerPtr pSender, Core::Entity::PlayerPtr pRecipient, uint64_t senderId, uint64_t recipientId )
|
||||
{
|
||||
assert( pSender != nullptr || senderId != 0 );
|
||||
|
||||
auto packet = GamePacketNew< Server::FFXIVIpcSocialRequestResponse, ServerZoneIpcType >( recipientId, senderId );
|
||||
|
||||
auto packet = Packets::GamePacketNew< Packets::Server::FFXIVIpcSocialRequestResponse, Packets::ServerZoneIpcType >( recipientId, senderId );
|
||||
packet.data().contentId = recipientId;
|
||||
packet.data().category = Common::SocialCategory::Friends;
|
||||
|
||||
|
@ -93,7 +96,7 @@ Core::Network::Packets::GamePacketPtr Group::removeMember( Core::Entity::PlayerP
|
|||
{
|
||||
assert( pSender != nullptr || senderId != 0 );
|
||||
|
||||
auto packet = GamePacketNew< Server::FFXIVIpcSocialRequestResponse, ServerZoneIpcType >( recipientId, senderId );
|
||||
auto packet = Packets::GamePacketNew< Packets::Server::FFXIVIpcSocialRequestResponse, Packets::ServerZoneIpcType >( recipientId, senderId );
|
||||
packet.data().contentId = recipientId;
|
||||
packet.data().category = Common::SocialCategory::Friends;
|
||||
|
||||
|
@ -105,7 +108,7 @@ void Group::sendPacketToMembers( Core::Network::Packets::GamePacketPtr pPacket,
|
|||
assert( pPacket );
|
||||
for( const auto& member : m_members )
|
||||
{
|
||||
auto pSession = g_serverZone.getSession( member.second.name );
|
||||
auto pSession = g_fw.get< ServerZone >()->getSession( member.second.name );
|
||||
if( pSession )
|
||||
{
|
||||
pSession->getPlayer()->queuePacket( pPacket );
|
||||
|
@ -123,7 +126,7 @@ Core::Network::Packets::Server::PlayerEntry Group::generatePlayerEntry( GroupMem
|
|||
// We check if player is online. If so, we can pull more data - otherwise just name
|
||||
// todo: set as offline in one of the unknown values, if session does not exist
|
||||
|
||||
auto pSession = g_serverZone.getSession( groupMember.name ); // todo: aa i don't like this. maybe just store their ID instead of contentID???
|
||||
auto pSession = g_fw.get< ServerZone >()->getSession( groupMember.name ); // todo: aa i don't like this. maybe just store their ID instead of contentID???
|
||||
|
||||
entry.timestamp = 1512799339;
|
||||
entry.status = 2;
|
||||
|
@ -148,15 +151,15 @@ Core::Network::Packets::Server::PlayerEntry Group::generatePlayerEntry( GroupMem
|
|||
entry.knownLanguages = 0x0F;
|
||||
entry.onlineStatusMask = pPlayer->getOnlineStatusMask();
|
||||
|
||||
g_log.debug( std::to_string( pPlayer->getContentId() ) );
|
||||
g_fw.get< Logger >()->debug( std::to_string( pPlayer->getContentId() ) );
|
||||
}
|
||||
|
||||
// TODO: no idea what this does - me neither
|
||||
//listPacket.data().entries[0].one = 1;
|
||||
|
||||
g_log.debug( std::to_string(groupMember.contentId) );
|
||||
g_fw.get< Logger >()->debug( std::to_string(groupMember.contentId) );
|
||||
|
||||
g_log.debug( std::to_string( entry.contentId ) );
|
||||
g_fw.get< Logger >()->debug( std::to_string( entry.contentId ) );
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
#ifndef _GROUP_H
|
||||
#define _GROUP_H
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
#include <common/Forwards.h>
|
||||
#include <Common.h>
|
||||
#include <Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
#include <Forwards.h>
|
||||
#include <sapphire_zone/Forwards.h>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <set>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <chrono>
|
||||
|
||||
namespace Core {
|
||||
namespace Social {
|
||||
|
@ -73,7 +74,7 @@ protected:
|
|||
uint64_t m_ownerId{ 0 };
|
||||
uint32_t m_maxCapacity{ 250 };
|
||||
uint32_t m_maxRoles{ 50 };
|
||||
time_point m_createTime{ std::chrono::steady_clock::now() };
|
||||
std::chrono::steady_clock::time_point m_createTime{ std::chrono::steady_clock::now() };
|
||||
std::map< uint64_t, GroupMember > m_members;
|
||||
std::map< uint64_t, GroupMember > m_invites; // <recipient, groupmember (which contains senderId)>
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef _SOCIALMGR_H
|
||||
#define _SOCIALMGR_H
|
||||
|
||||
#include <Common.h>
|
||||
|
||||
#include <map>
|
||||
#include <cstdint>
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include "Linkshell/LinkshellMgr.h"
|
||||
#include "Zone/TerritoryMgr.h"
|
||||
#include "DebugCommand/DebugCommandHandler.h"
|
||||
#include "Social/Manager/SocialMgr.h"
|
||||
#include "Social/FriendList.h"
|
||||
|
||||
Core::Framework g_fw;
|
||||
|
||||
|
@ -29,6 +31,8 @@ bool setupFramework()
|
|||
auto pTeriMgr = boost::make_shared< TerritoryMgr >();
|
||||
auto pDebugCom = boost::make_shared< DebugCommandHandler >();
|
||||
|
||||
auto pFriendsListMgr = boost::make_shared< Social::SocialMgr< Social::FriendList > >();
|
||||
|
||||
pLogger->setLogPath( "log/SapphireZone_" );
|
||||
pLogger->init();
|
||||
|
||||
|
@ -42,6 +46,8 @@ bool setupFramework()
|
|||
g_fw.set< TerritoryMgr >( pTeriMgr );
|
||||
g_fw.set< DebugCommandHandler >( pDebugCom );
|
||||
|
||||
g_fw.set< Social::SocialMgr< Social::FriendList > >( pFriendsListMgr );
|
||||
|
||||
// actuall catch errors here...
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue