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

Half work on templating SocialManager, more refactoring

This commit is contained in:
Maru 2017-12-21 03:45:56 -02:00
parent 9e152f253f
commit c8f2ee7305
29 changed files with 63 additions and 37 deletions

View file

@ -6,8 +6,8 @@
#include <Server_Common/Common.h>
#include <Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
#include <Server_Zone/Actor/Social/FriendList.h>
#include <Server_Zone/Actor/Social/Manager/FriendListMgr.h>
#include <Server_Zone/Social/FriendList.h>
#include <Server_Zone/Social/Manager/FriendListMgr.h>
#include <Server_Common/Common.h>
#include "Actor.h"

View file

@ -8,8 +8,6 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
file(GLOB SERVER_PUBLIC_INCLUDE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
/*.h
Actor/*.h
Actor/Social/*.h
Actor/Social/Manager/*.h
Action/*.h
DebugCommand/*.h
Event/*.h
@ -19,6 +17,8 @@ file(GLOB SERVER_PUBLIC_INCLUDE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
Network/*.h
Network/Handlers/*.h
Network/PacketWrappers/*.h
Social/*.h
Social/Manager/*.h
Script/*.h
StatusEffect/*.h
Zone/*.h)
@ -37,6 +37,8 @@ file(GLOB SERVER_SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
Network/*.c*
Network/Handlers/*.c*
Network/PacketWrappers/*.c*
Social/*.c*
Social/Manager/*.c*
Script/*.c*
StatusEffect/*.c*
Zone/*.c*)

View file

@ -1,4 +1,5 @@
#include <boost/lexical_cast.hpp>
#include <random>
#include <Server_Common/Common.h>
#include <Server_Common/Version.h>
@ -348,6 +349,30 @@ void Core::DebugCommandHandler::add( char * data, Entity::Player& player, boost:
pBNpc->setCurrentZone( pZone );
pZone->pushActor( pBNpc );
}
else if( subCommand == "sspawn" )
{
int32_t model, name, count, distCoefficient, i;
sscanf( params.c_str(), "%d %d %d %d", &model, &name, &count, &distCoefficient );
for ( i = 0; i < count; i++ )
{
Common::FFXIVARR_POSITION3 posC = player.getPos();
std::mt19937 gen( rand() * 1000 );
std::uniform_int_distribution<int> dis( distCoefficient * -1, distCoefficient );
posC.x += dis( gen );
posC.z += dis( gen );
Entity::BattleNpcPtr pBNpc( new Entity::BattleNpc( model, name, posC ) );
auto pZone = player.getCurrentZone();
pBNpc->setCurrentZone( pZone );
pZone->pushActor( pBNpc );
}
}
else if( subCommand == "op" )
{

View file

@ -36,7 +36,7 @@
#include "Event/EventHelper.h"
#include "Action/Action.h"
#include "Action/ActionTeleport.h"
#include "Actor/Social/Manager/FriendListMgr.h"
#include "Social/Manager/FriendListMgr.h"
extern Core::Logger g_log;
@ -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::Entity::Social::FriendListMgr g_friendListMgr;
extern Core::Social::SocialMgr g_socialMgr;
using namespace Core::Common;
using namespace Core::Network::Packets;

View file

@ -220,7 +220,7 @@ void Core::ServerZone::run( int32_t argc, char* argv[] )
return;
}
g_friendListMgr.init();
g_friendListMgr = Core::Social::SocialMgr<Common::SocialListType::FriendList>();
Network::HivePtr hive( new Network::Hive() );
Network::addServerToHive< Network::GameConnection >( m_ip, m_port, hive );

View file

@ -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/Social/Group.h>
#include <Server_Zone/Social/Group.h>
#include <Server_Zone/Forwards.h>
#include <boost/enable_shared_from_this.hpp>
#include <set>

View file

@ -6,17 +6,16 @@
#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/Social/Group.h>
#include <Server_Zone/Social/FriendList.h>
#include <Server_Zone/Actor/Social/Manager/GroupMgr.h>
#include <Server_Zone/Social/Manager/SocialMgr.h>
#include <Server_Zone/Forwards.h>
namespace Core {
namespace Entity {
namespace Social {
class FriendListMgr : public GroupMgr
class FriendListMgr
{
public:
FriendListMgr();
@ -32,7 +31,7 @@ public:
private:
// todo: can we handle this m_groups grouptype better..?
GroupType m_type{ GroupType::FriendList };
//GroupType m_type{ GroupType::FriendList };
};

View file

@ -1,19 +1,19 @@
#include "../Group.h"
#include "GroupMgr.h"
#include "SocialMgr.h"
using namespace Core::Entity;
Social::GroupMgr::GroupMgr()
template< class T >
Core::Social::SocialMgr::GroupMgr()
{
}
Social::GroupMgr::~GroupMgr()
Core::Social::SocialMgr::~GroupMgr()
{
}
Social::GroupPtr Social::GroupMgr::findGroupByInviteIdForPlayer( uint64_t playerId ) const
T Core::Social::SocialMgr::findGroupByInviteIdForPlayer( uint64_t playerId ) const
{
auto it = m_invites.find( playerId );
if( it != m_invites.end() )
@ -23,7 +23,7 @@ Social::GroupPtr Social::GroupMgr::findGroupByInviteIdForPlayer( uint64_t player
return nullptr;
}
Social::GroupPtr Social::GroupMgr::findGroupById( uint64_t groupId ) const
T Core::Social::SocialMgr::findGroupById( uint64_t groupId ) const
{
auto it = m_groups.find( groupId );
if( it != m_groups.end() )
@ -33,13 +33,13 @@ Social::GroupPtr Social::GroupMgr::findGroupById( uint64_t groupId ) const
return nullptr;
}
uint64_t Social::GroupMgr::generateGroupId()
uint64_t Core::Social::SocialMgr::GroupMgr::generateGroupId()
{
m_lastGroupId++;
return m_lastGroupId;
}
bool Social::GroupMgr::hasInvite( uint64_t playerId ) const
bool Core::Social::SocialMgr::hasInvite( uint64_t playerId ) const
{
auto it = m_invites.find( playerId );
if ( it != m_invites.end() )

View file

@ -6,23 +6,23 @@
#include <boost/enable_shared_from_this.hpp>
#include <Server_Zone/Forwards.h>
#include <Server_Zone/Actor/Social/Group.h>
#include <Social/Group.h>
namespace Core {
namespace Entity {
namespace Social {
class GroupMgr
template< class T >
class SocialMgr
{
public:
GroupMgr();
virtual ~GroupMgr();
SocialMgr();
virtual ~SocialMgr();
virtual GroupPtr findGroupByInviteIdForPlayer( uint64_t playerId ) const;
virtual GroupPtr findGroupById( uint64_t groupId ) const;
T findGroupByInviteIdForPlayer( uint64_t playerId ) const;
T findGroupById( uint64_t groupId ) const;
/*
template <typename GroupPtr>
GroupPtr findGroup( uint64_t arg )
T findGroup( uint64_t groupId )
{
auto it = m_groups.find( groupId );
if ( it != m_groups.end() )
@ -35,10 +35,11 @@ public:
bool hasInvite( uint64_t playerId ) const;
protected:
GroupType m_type{ GroupType::None };
uint64_t m_groupCount{ 0 };
uint32_t m_maxEntries{ 0xFFFFFFFF };
// those would be implemented in T, so you'd have T.m_type and T.m_maxEntries
// GroupType m_type{ GroupType::None };
// uint32_t m_maxEntries{ 0xFFFFFFFF };
uint64_t m_groupCount{ 0 };
std::map< uint64_t, uint64_t > m_invites;
uint64_t m_lastGroupId{ 0 };
@ -61,11 +62,10 @@ protected:
virtual uint64_t generateGroupId();
private:
std::map< uint64_t, GroupPtr > m_groups;
std::map< uint64_t, T > m_groups;
};
}
}
};
#endif /* ! _GROUPMGR_H */