mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-24 18:47:45 +00:00
Refactor some more, work on Manager global obj;
This commit is contained in:
parent
5b58e5a6e2
commit
b85bc25f58
29 changed files with 100 additions and 64 deletions
|
@ -1,2 +0,0 @@
|
|||
#include "../FriendList.h"
|
||||
#include "FriendListMgr.h"
|
|
@ -1,41 +0,0 @@
|
|||
#ifndef _FRIENDLISTMGR_H
|
||||
#define _FRIENDLISTMGR_H
|
||||
|
||||
#include <map>
|
||||
#include <cstdint>
|
||||
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <Server_Zone/Forwards.h>
|
||||
#include <Server_Zone/Actor/Group/Group.h>
|
||||
|
||||
#include <Server_Zone/Actor/Group/Manager/GroupMgr.h>
|
||||
|
||||
namespace Core {
|
||||
namespace Entity {
|
||||
namespace Group {
|
||||
|
||||
class FriendListMgr : public GroupMgr
|
||||
{
|
||||
public:
|
||||
FriendListMgr( GroupType type, uint32_t maxEntries ) :
|
||||
GroupMgr( type, maxEntries ),
|
||||
m_type( type ), m_maxEntries( maxEntries ) {};
|
||||
~FriendListMgr() {};
|
||||
|
||||
GroupPtr findGroupByInviteIdForPlayer( uint64_t playerId ) const;
|
||||
GroupPtr findGroupById( uint64_t groupId ) const;
|
||||
|
||||
private:
|
||||
GroupType m_type{ GroupType::None };
|
||||
uint64_t m_groupCount{ 0 };
|
||||
uint32_t m_maxEntries{ 0xFFFFFFFF };
|
||||
std::map< uint64_t, GroupPtr > m_groups; // < groupid, groupPtr >
|
||||
std::map< uint64_t, uint64_t > m_invites; // < recipient, groupid >
|
||||
virtual GroupPtr createGroup( PlayerPtr pOwner ) = 0;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif /* ! _FRIENDLISTMGR_H */
|
|
@ -29,6 +29,9 @@
|
|||
#include "src/servers/Server_Zone/Network/PacketWrappers/PlayerStateFlagsPacket.h"
|
||||
#include "src/servers/Server_Zone/Network/PacketWrappers/PlayerSpawnPacket.h"
|
||||
|
||||
#include "src/servers/Server_Zone/Actor/Social/FriendList.h"
|
||||
#include "src/servers/Server_Zone/Actor/Social/Manager/FriendListMgr.h"
|
||||
|
||||
#include "src/servers/Server_Zone/Script/ScriptManager.h"
|
||||
|
||||
#include "src/servers/Server_Zone/Inventory/Item.h"
|
||||
|
@ -49,6 +52,8 @@ extern Core::ZoneMgr g_zoneMgr;
|
|||
extern Core::Data::ExdData g_exdData;
|
||||
extern Core::Scripting::ScriptManager g_scriptMgr;
|
||||
|
||||
extern Core::Entity::Social::FriendListMgr g_friendListMgr;
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network::Packets;
|
||||
using namespace Core::Network::Packets::Server;
|
||||
|
@ -300,7 +305,7 @@ void Core::Entity::Player::sendStats()
|
|||
queuePacket( statPacket );
|
||||
}
|
||||
|
||||
Group::FriendListPtr Core::Entity::Player::getFriendsList() const
|
||||
Social::FriendListPtr Core::Entity::Player::getFriendsList() const
|
||||
{
|
||||
return m_friendsList;
|
||||
}
|
||||
|
@ -441,6 +446,8 @@ void Core::Entity::Player::setZone( uint32_t zoneId )
|
|||
gcAffPacket.data().gcRank[2] = m_gcRank[2];
|
||||
queuePacket( gcAffPacket );
|
||||
|
||||
m_friendsList = g_friendListMgr.getPlayerFriendsList( getId() );
|
||||
|
||||
m_itemLevel = getInventory()->calculateEquippedGearItemLevel();
|
||||
sendItemLevel();
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
|
||||
#include <src/servers/Server_Common/Common.h>
|
||||
#include <src/servers/Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
#include <src/servers/Server_Zone/Actor/Group/FriendList.h>
|
||||
#include <src/servers/Server_Zone/Actor/Social/FriendList.h>
|
||||
#include <src/servers/Server_Zone/Actor/Social/Manager/FriendListMgr.h>
|
||||
|
||||
#include "Actor.h"
|
||||
#include "src/servers/Server_Zone/Inventory/Inventory.h"
|
||||
|
@ -359,7 +360,7 @@ public:
|
|||
// Social-based
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Group::FriendListPtr getFriendsList() const;
|
||||
Social::FriendListPtr getFriendsList() const;
|
||||
|
||||
|
||||
// Aetheryte / Action / Attribute bitmasks
|
||||
|
@ -623,7 +624,7 @@ private:
|
|||
|
||||
// Social-based
|
||||
|
||||
Group::FriendListPtr m_friendsList;
|
||||
Social::FriendListPtr m_friendsList;
|
||||
|
||||
uint8_t m_equipDisplayFlags;
|
||||
|
||||
|
|
|
@ -14,10 +14,11 @@
|
|||
extern Core::ServerZone g_serverZone;
|
||||
extern Core::Logger g_log;
|
||||
|
||||
using namespace Core::Entity;
|
||||
using namespace Core::Network::Packets;
|
||||
using namespace Core::Network::Packets::Server;
|
||||
|
||||
std::vector< PlayerEntry > Core::Entity::Group::FriendList::getFriendListEntries( uint16_t entryAmount )
|
||||
std::vector< PlayerEntry > Core::Entity::Social::FriendList::getFriendListEntries( uint16_t entryAmount )
|
||||
{
|
||||
std::vector< PlayerEntry > entryList = {};
|
||||
uint16_t limit = 0;
|
|
@ -5,7 +5,7 @@
|
|||
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
#include <Server_Common/Network/GamePacketNew.h>
|
||||
#include <Server_Common/Forwards.h>
|
||||
#include <Server_Zone/Actor/Group/Group.h>
|
||||
#include <Server_Zone/Actor/Social/Group.h>
|
||||
#include <Server_Zone/Forwards.h>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <set>
|
||||
|
@ -17,7 +17,7 @@ using namespace Core::Network::Packets::Server;
|
|||
|
||||
namespace Core {
|
||||
namespace Entity {
|
||||
namespace Group {
|
||||
namespace Social {
|
||||
|
||||
class FriendList;
|
||||
using FriendListPtr = boost::shared_ptr< FriendList >;
|
||||
|
@ -28,7 +28,7 @@ class FriendList : public Group
|
|||
public:
|
||||
FriendList( uint64_t id, uint64_t ownerId, uint32_t maxCapacity, time_point createTime ) :
|
||||
Group( id, ownerId, maxCapacity, createTime ),
|
||||
m_id( id ), m_ownerId( m_ownerId ), m_maxCapacity( maxCapacity ), m_createTime( createTime ) {};
|
||||
m_id( id ), m_ownerId( ownerId ), m_maxCapacity( maxCapacity ), m_createTime( createTime ) {};
|
||||
|
||||
~FriendList() {};
|
||||
|
||||
|
@ -50,8 +50,6 @@ public:
|
|||
bool isBlacklist() const;
|
||||
bool isContentGroup() const;
|
||||
|
||||
Core::Network::Packets::ZoneChannelPacket< FFXIVIpcSocialList > generateFriendsListPacket( PlayerPtr pPlayer );
|
||||
|
||||
std::vector< Core::Network::Packets::Server::PlayerEntry > getFriendListEntries( uint16_t entryAmount );
|
||||
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
extern Core::ServerZone g_serverZone;
|
||||
|
||||
using namespace Core::Entity::Group;
|
||||
using namespace Core::Entity::Social;
|
||||
|
||||
// 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
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
namespace Core {
|
||||
namespace Entity {
|
||||
namespace Group {
|
||||
namespace Social {
|
||||
|
||||
class Group;
|
||||
using GroupPtr = boost::shared_ptr< Group >;
|
|
@ -0,0 +1,30 @@
|
|||
#include <random>
|
||||
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <src/servers/Server_Common/Logging/Logger.h>
|
||||
|
||||
#include "../Group.h"
|
||||
#include "../FriendList.h"
|
||||
#include "FriendListMgr.h"
|
||||
|
||||
extern Core::Logger g_log;
|
||||
|
||||
using namespace Core::Entity;
|
||||
|
||||
Social::FriendListMgr::FriendListMgr()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Social::FriendListPtr Social::FriendListMgr::getPlayerFriendsList( uint32_t playerId )
|
||||
{
|
||||
std::mt19937_64 engine( std::random_device{}( ) );
|
||||
std::uniform_int_distribution<uint64_t> distribution;
|
||||
auto ui64 = distribution( engine );
|
||||
|
||||
FriendList nFriendList( ui64, playerId, 200, std::chrono::steady_clock::now() );
|
||||
|
||||
FriendListPtr pFriendList = boost::make_shared< FriendList >( nFriendList );
|
||||
pFriendList->getCapacity();
|
||||
return pFriendList;
|
||||
}
|
37
src/servers/Server_Zone/Actor/Social/Manager/FriendListMgr.h
Normal file
37
src/servers/Server_Zone/Actor/Social/Manager/FriendListMgr.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
#ifndef _FRIENDLISTMGR_H
|
||||
#define _FRIENDLISTMGR_H
|
||||
|
||||
#include <map>
|
||||
#include <cstdint>
|
||||
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <Server_Zone/Forwards.h>
|
||||
#include <Server_Zone/Actor/Social/Group.h>
|
||||
#include <Server_Zone/Actor/Social/FriendList.h>
|
||||
|
||||
#include <Server_Zone/Actor/Social/Manager/GroupMgr.h>
|
||||
|
||||
namespace Core {
|
||||
namespace Entity {
|
||||
namespace Social {
|
||||
|
||||
class FriendListMgr
|
||||
{
|
||||
public:
|
||||
FriendListMgr();
|
||||
|
||||
FriendListPtr getPlayerFriendsList( uint32_t playerId );
|
||||
|
||||
private:
|
||||
GroupType m_type{ GroupType::FriendList };
|
||||
uint64_t m_groupCount{ 0 };
|
||||
uint32_t m_maxEntries{ 0xFFFFFFFF };
|
||||
std::map< uint64_t, GroupPtr > m_groups; // < groupid, groupPtr >
|
||||
std::map< uint64_t, uint64_t > m_invites; // < recipient, groupid >
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif /* ! _FRIENDLISTMGR_H */
|
|
@ -1,7 +1,14 @@
|
|||
#include "../Group.h"
|
||||
#include "GroupMgr.h"
|
||||
|
||||
Core::Entity::Group::GroupPtr Core::Entity::Group::GroupMgr::findGroupByInviteIdForPlayer( uint64_t playerId ) const
|
||||
using namespace Core::Entity;
|
||||
|
||||
Social::GroupMgr::GroupMgr()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Social::GroupPtr Social::GroupMgr::findGroupByInviteIdForPlayer( uint64_t playerId ) const
|
||||
{
|
||||
auto it = m_invites.find( playerId );
|
||||
if( it != m_invites.end() )
|
||||
|
@ -11,7 +18,7 @@ Core::Entity::Group::GroupPtr Core::Entity::Group::GroupMgr::findGroupByInviteId
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Core::Entity::Group::GroupPtr Core::Entity::Group::GroupMgr::findGroupById( uint64_t groupId ) const
|
||||
Social::GroupPtr Core::Entity::Social::GroupMgr::findGroupById( uint64_t groupId ) const
|
||||
{
|
||||
auto it = m_groups.find( groupId );
|
||||
if( it != m_groups.end() )
|
|
@ -6,18 +6,16 @@
|
|||
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <Server_Zone/Forwards.h>
|
||||
#include <Server_Zone/Actor/Group/Group.h>
|
||||
#include <Server_Zone/Actor/Social/Group.h>
|
||||
|
||||
namespace Core {
|
||||
namespace Entity {
|
||||
namespace Group {
|
||||
namespace Social {
|
||||
|
||||
class GroupMgr : public boost::enable_shared_from_this< GroupMgr >
|
||||
{
|
||||
public:
|
||||
GroupMgr( GroupType type, uint32_t maxEntries ) :
|
||||
m_type( type ), m_maxEntries( maxEntries ) {};
|
||||
~GroupMgr() {};
|
||||
GroupMgr();
|
||||
|
||||
GroupPtr findGroupByInviteIdForPlayer( uint64_t playerId ) const;
|
||||
GroupPtr findGroupById( uint64_t groupId ) const;
|
||||
|
@ -28,7 +26,7 @@ private:
|
|||
uint32_t m_maxEntries{ 0xFFFFFFFF };
|
||||
std::map< uint64_t, GroupPtr > m_groups;
|
||||
std::map< uint64_t, uint64_t > m_invites; // < recipient, groupid >
|
||||
virtual GroupPtr createGroup( PlayerPtr pOwner ) = 0;
|
||||
//virtual GroupPtr createGroup( PlayerPtr pOwner ) = 0;
|
||||
|
||||
/*
|
||||
friend virtual Core::Network::Packets::GamePacketPtr Core::Entity::Group::Group::addMember( PlayerPtr pSender, PlayerPtr pRecipient, uint64_t senderId = 0, uint64_t recipientId = 0 );
|
|
@ -467,7 +467,7 @@ void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket
|
|||
break;
|
||||
|
||||
g_log.debug( "aaa" + std::to_string( i ) + ": " + member.second.name );
|
||||
listPacket.data().entries[i] = Core::Entity::Group::Group::generatePlayerEntry( member.second );
|
||||
listPacket.data().entries[i] = Core::Entity::Social::Group::generatePlayerEntry( member.second );
|
||||
i++;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue