1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-25 02:57:45 +00:00

Refactor some more, work on Manager global obj;

This commit is contained in:
Maru 2017-12-07 17:28:55 -02:00
parent 5b58e5a6e2
commit b85bc25f58
29 changed files with 100 additions and 64 deletions

View file

@ -1,2 +0,0 @@
#include "../FriendList.h"
#include "FriendListMgr.h"

View file

@ -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 */

View file

@ -29,6 +29,9 @@
#include "src/servers/Server_Zone/Network/PacketWrappers/PlayerStateFlagsPacket.h" #include "src/servers/Server_Zone/Network/PacketWrappers/PlayerStateFlagsPacket.h"
#include "src/servers/Server_Zone/Network/PacketWrappers/PlayerSpawnPacket.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/Script/ScriptManager.h"
#include "src/servers/Server_Zone/Inventory/Item.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::Data::ExdData g_exdData;
extern Core::Scripting::ScriptManager g_scriptMgr; extern Core::Scripting::ScriptManager g_scriptMgr;
extern Core::Entity::Social::FriendListMgr g_friendListMgr;
using namespace Core::Common; using namespace Core::Common;
using namespace Core::Network::Packets; using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server; using namespace Core::Network::Packets::Server;
@ -300,7 +305,7 @@ void Core::Entity::Player::sendStats()
queuePacket( statPacket ); queuePacket( statPacket );
} }
Group::FriendListPtr Core::Entity::Player::getFriendsList() const Social::FriendListPtr Core::Entity::Player::getFriendsList() const
{ {
return m_friendsList; return m_friendsList;
} }
@ -441,6 +446,8 @@ void Core::Entity::Player::setZone( uint32_t zoneId )
gcAffPacket.data().gcRank[2] = m_gcRank[2]; gcAffPacket.data().gcRank[2] = m_gcRank[2];
queuePacket( gcAffPacket ); queuePacket( gcAffPacket );
m_friendsList = g_friendListMgr.getPlayerFriendsList( getId() );
m_itemLevel = getInventory()->calculateEquippedGearItemLevel(); m_itemLevel = getInventory()->calculateEquippedGearItemLevel();
sendItemLevel(); sendItemLevel();
} }

View file

@ -5,7 +5,8 @@
#include <src/servers/Server_Common/Common.h> #include <src/servers/Server_Common/Common.h>
#include <src/servers/Server_Common/Network/PacketDef/Zone/ServerZoneDef.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 "Actor.h"
#include "src/servers/Server_Zone/Inventory/Inventory.h" #include "src/servers/Server_Zone/Inventory/Inventory.h"
@ -359,7 +360,7 @@ public:
// Social-based // Social-based
////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////
Group::FriendListPtr getFriendsList() const; Social::FriendListPtr getFriendsList() const;
// Aetheryte / Action / Attribute bitmasks // Aetheryte / Action / Attribute bitmasks
@ -623,7 +624,7 @@ private:
// Social-based // Social-based
Group::FriendListPtr m_friendsList; Social::FriendListPtr m_friendsList;
uint8_t m_equipDisplayFlags; uint8_t m_equipDisplayFlags;

View file

@ -14,10 +14,11 @@
extern Core::ServerZone g_serverZone; extern Core::ServerZone g_serverZone;
extern Core::Logger g_log; extern Core::Logger g_log;
using namespace Core::Entity;
using namespace Core::Network::Packets; using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server; 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 = {}; std::vector< PlayerEntry > entryList = {};
uint16_t limit = 0; uint16_t limit = 0;

View file

@ -5,7 +5,7 @@
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h> #include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include <Server_Common/Network/GamePacketNew.h> #include <Server_Common/Network/GamePacketNew.h>
#include <Server_Common/Forwards.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 <Server_Zone/Forwards.h>
#include <boost/enable_shared_from_this.hpp> #include <boost/enable_shared_from_this.hpp>
#include <set> #include <set>
@ -17,7 +17,7 @@ using namespace Core::Network::Packets::Server;
namespace Core { namespace Core {
namespace Entity { namespace Entity {
namespace Group { namespace Social {
class FriendList; class FriendList;
using FriendListPtr = boost::shared_ptr< FriendList >; using FriendListPtr = boost::shared_ptr< FriendList >;
@ -28,7 +28,7 @@ class FriendList : public Group
public: public:
FriendList( uint64_t id, uint64_t ownerId, uint32_t maxCapacity, time_point createTime ) : FriendList( uint64_t id, uint64_t ownerId, uint32_t maxCapacity, time_point createTime ) :
Group( id, ownerId, maxCapacity, 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() {}; ~FriendList() {};
@ -50,8 +50,6 @@ public:
bool isBlacklist() const; bool isBlacklist() const;
bool isContentGroup() const; bool isContentGroup() const;
Core::Network::Packets::ZoneChannelPacket< FFXIVIpcSocialList > generateFriendsListPacket( PlayerPtr pPlayer );
std::vector< Core::Network::Packets::Server::PlayerEntry > getFriendListEntries( uint16_t entryAmount ); std::vector< Core::Network::Packets::Server::PlayerEntry > getFriendListEntries( uint16_t entryAmount );

View file

@ -13,7 +13,7 @@
extern Core::ServerZone g_serverZone; 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: 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 // todo: invite map in g_serverZone.getGroupMgr(GroupType) and look up

View file

@ -12,7 +12,7 @@
namespace Core { namespace Core {
namespace Entity { namespace Entity {
namespace Group { namespace Social {
class Group; class Group;
using GroupPtr = boost::shared_ptr< Group >; using GroupPtr = boost::shared_ptr< Group >;

View file

@ -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;
}

View 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 */

View file

@ -1,7 +1,14 @@
#include "../Group.h" #include "../Group.h"
#include "GroupMgr.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 ); auto it = m_invites.find( playerId );
if( it != m_invites.end() ) if( it != m_invites.end() )
@ -11,7 +18,7 @@ Core::Entity::Group::GroupPtr Core::Entity::Group::GroupMgr::findGroupByInviteId
return nullptr; 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 ); auto it = m_groups.find( groupId );
if( it != m_groups.end() ) if( it != m_groups.end() )

View file

@ -6,18 +6,16 @@
#include <boost/enable_shared_from_this.hpp> #include <boost/enable_shared_from_this.hpp>
#include <Server_Zone/Forwards.h> #include <Server_Zone/Forwards.h>
#include <Server_Zone/Actor/Group/Group.h> #include <Server_Zone/Actor/Social/Group.h>
namespace Core { namespace Core {
namespace Entity { namespace Entity {
namespace Group { namespace Social {
class GroupMgr : public boost::enable_shared_from_this< GroupMgr > class GroupMgr : public boost::enable_shared_from_this< GroupMgr >
{ {
public: public:
GroupMgr( GroupType type, uint32_t maxEntries ) : GroupMgr();
m_type( type ), m_maxEntries( maxEntries ) {};
~GroupMgr() {};
GroupPtr findGroupByInviteIdForPlayer( uint64_t playerId ) const; GroupPtr findGroupByInviteIdForPlayer( uint64_t playerId ) const;
GroupPtr findGroupById( uint64_t groupId ) const; GroupPtr findGroupById( uint64_t groupId ) const;
@ -28,7 +26,7 @@ private:
uint32_t m_maxEntries{ 0xFFFFFFFF }; uint32_t m_maxEntries{ 0xFFFFFFFF };
std::map< uint64_t, GroupPtr > m_groups; std::map< uint64_t, GroupPtr > m_groups;
std::map< uint64_t, uint64_t > m_invites; // < recipient, groupid > 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 ); friend virtual Core::Network::Packets::GamePacketPtr Core::Entity::Group::Group::addMember( PlayerPtr pSender, PlayerPtr pRecipient, uint64_t senderId = 0, uint64_t recipientId = 0 );

View file

@ -467,7 +467,7 @@ void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket
break; break;
g_log.debug( "aaa" + std::to_string( i ) + ": " + member.second.name ); 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++; i++;
} }