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

More templating stuff

This commit is contained in:
Maru 2017-12-25 02:13:54 -02:00
parent c8f2ee7305
commit 5c793993d3
11 changed files with 31 additions and 34 deletions

View file

@ -30,8 +30,8 @@
#include "Script/ScriptManager.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/Social/FriendList.h"
#include "src/servers/Server_Zone/Actor/Manager/FriendListMgr.h"
#include "src/servers/Server_Zone/Script/ScriptManager.h"
#include "Inventory/Item.h"

View file

@ -44,7 +44,7 @@ extern Core::ServerZone g_serverZone;
extern Core::ZoneMgr g_zoneMgr;
extern Core::Data::ExdData g_exdData;
extern Core::DebugCommandHandler g_gameCommandMgr;
extern Core::Social::SocialMgr g_socialMgr;
extern Core::Social::SocialMgr<Core::Common::SocialListType> g_socialMgr;
using namespace Core::Common;
using namespace Core::Network::Packets;

View file

@ -41,7 +41,7 @@ Core::Data::ExdData g_exdData;
Core::ZoneMgr g_zoneMgr;
Core::LinkshellMgr g_linkshellMgr;
Core::Db::DbWorkerPool< Core::Db::CharaDbConnection > g_charaDb;
Core::Entity::Social::FriendListMgr g_friendListMgr;
Core::Social::SocialMgr< Core::Social:: > g_friendListMgr;
Core::ServerZone::ServerZone( const std::string& configPath )
: m_configPath( configPath ),
@ -220,7 +220,7 @@ void Core::ServerZone::run( int32_t argc, char* argv[] )
return;
}
g_friendListMgr = Core::Social::SocialMgr<Common::SocialListType::FriendList>();
g_friendListMgr = Core::Social::SocialMgr<Core::Social::FriendList>();
Network::HivePtr hive( new Network::Hive() );
Network::addServerToHive< Network::GameConnection >( m_ip, m_port, hive );

View file

@ -15,11 +15,10 @@
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::Social::FriendList::getFriendListEntries( uint16_t entryAmount )
std::vector< PlayerEntry > Core::Social::FriendList::getFriendListEntries( uint16_t entryAmount )
{
std::vector< PlayerEntry > entryList = {};
uint16_t limit = 0;

View file

@ -16,7 +16,6 @@ using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server;
namespace Core {
namespace Entity {
namespace Social {
class FriendList;
@ -56,7 +55,6 @@ protected:
};
}
}
};
#endif // ! _FRIENDLIST_H

View file

@ -15,7 +15,7 @@
extern Core::ServerZone g_serverZone;
extern Core::Logger g_log;
using namespace Core::Entity::Social;
using namespace Core::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

View file

@ -11,7 +11,6 @@
#include <map>
namespace Core {
namespace Entity {
namespace Social {
class Group;
@ -51,10 +50,10 @@ public:
bool isBlacklist() const;
bool isContentGroup() const;
virtual Core::Network::Packets::GamePacketPtr addMember( PlayerPtr pSender, PlayerPtr pRecipient, uint64_t senderId = 0, uint64_t recipientId = 0 );
virtual Core::Network::Packets::GamePacketPtr addMember( Entity::PlayerPtr pSender, Entity::PlayerPtr pRecipient, uint64_t senderId = 0, uint64_t recipientId = 0 );
virtual Core::Network::Packets::GamePacketPtr inviteMember( PlayerPtr pSender, PlayerPtr pRecipient, uint64_t senderId = 0, uint64_t recipientId = 0 );
virtual Core::Network::Packets::GamePacketPtr removeMember( PlayerPtr pSender, PlayerPtr pRecipient, uint64_t senderId = 0, uint64_t recipientId = 0 );
virtual Core::Network::Packets::GamePacketPtr inviteMember( Entity::PlayerPtr pSender, Entity::PlayerPtr pRecipient, uint64_t senderId = 0, uint64_t recipientId = 0 );
virtual Core::Network::Packets::GamePacketPtr removeMember( Entity::PlayerPtr pSender, Entity::PlayerPtr pRecipient, uint64_t senderId = 0, uint64_t recipientId = 0 );
//virtual Core::Network::Packets::GamePacketPtr kickMember( PlayerPtr pSender, PlayerPtr pRecipient, uint64_t senderId = 0, uint64_t recipientId = 0 );
virtual void sendPacketToMembers( Core::Network::Packets::GamePacketPtr pPacket, bool invitesToo = false );
@ -87,7 +86,6 @@ private:
};
}
}
};
#endif // ! _GROUP_H

View file

@ -9,19 +9,18 @@
extern Core::Logger g_log;
using namespace Core::Entity;
Core::Entity::Social::FriendListMgr::FriendListMgr()
Core::Social::FriendListMgr::FriendListMgr()
{
}
bool Social::FriendListMgr::init()
bool Core::Social::FriendListMgr::init()
{
return true;
}
uint64_t Social::FriendListMgr::fetchPlayerFriendsList( uint32_t playerId )
uint64_t Core::Social::FriendListMgr::fetchPlayerFriendsList( uint32_t playerId )
{
uint64_t newGroupId = generateGroupId();

View file

@ -27,7 +27,7 @@ public:
FriendListPtr findGroupByInviteIdForPlayer( uint64_t playerId ) const;
FriendListPtr findGroupById( uint64_t groupId ) const;
*/
std::map< uint64_t, FriendListPtr > m_groups;
//std::map< uint64_t, FriendListPtr > m_groups;
private:
// todo: can we handle this m_groups grouptype better..?
@ -35,7 +35,7 @@ private:
};
}
}
};
}
#endif /* ! _FRIENDLISTMGR_H */

View file

@ -3,17 +3,18 @@
template< class T >
Core::Social::SocialMgr::GroupMgr()
Core::Social::SocialMgr::SocialMgr()
{
}
template< class T >
Core::Social::SocialMgr::~SocialMgr()
{
}
Core::Social::SocialMgr::~GroupMgr()
{
}
T Core::Social::SocialMgr::findGroupByInviteIdForPlayer( uint64_t playerId ) const
template< class T >
T Core::Social::SocialMgr< T >::findGroupByInviteIdForPlayer( uint64_t playerId ) const
{
auto it = m_invites.find( playerId );
if( it != m_invites.end() )
@ -22,8 +23,8 @@ T Core::Social::SocialMgr::findGroupByInviteIdForPlayer( uint64_t playerId ) con
}
return nullptr;
}
T Core::Social::SocialMgr::findGroupById( uint64_t groupId ) const
template< class T >
T Core::Social::SocialMgr< T >::findGroupById( uint64_t groupId ) const
{
auto it = m_groups.find( groupId );
if( it != m_groups.end() )
@ -33,13 +34,15 @@ T Core::Social::SocialMgr::findGroupById( uint64_t groupId ) const
return nullptr;
}
uint64_t Core::Social::SocialMgr::GroupMgr::generateGroupId()
template< class T >
uint64_t Core::Social::SocialMgr< T >::generateGroupId() const
{
m_lastGroupId++;
return m_lastGroupId;
}
bool Core::Social::SocialMgr::hasInvite( uint64_t playerId ) const
template< class T >
bool Core::Social::SocialMgr< T >::hasInvite( uint64_t playerId ) const
{
auto it = m_invites.find( playerId );
if ( it != m_invites.end() )

View file

@ -59,7 +59,7 @@ protected:
friend virtual void disband();
*/
virtual uint64_t generateGroupId();
virtual uint64_t generateGroupId() const;
private:
std::map< uint64_t, T > m_groups;