diff --git a/src/servers/sapphire_zone/Actor/Player.cpp b/src/servers/sapphire_zone/Actor/Player.cpp index d92056d0..0c0b619a 100644 --- a/src/servers/sapphire_zone/Actor/Player.cpp +++ b/src/servers/sapphire_zone/Actor/Player.cpp @@ -33,7 +33,7 @@ #include #include "Social/FriendList.h" -#include "Script/ScriptManager.h" +#include "Script/ScriptMgr.h" #include "Inventory/Item.h" #include "Inventory/Inventory.h" diff --git a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp index 97fdcd54..a7134ba5 100644 --- a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp +++ b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -376,7 +377,7 @@ void Core::DebugCommandHandler::add( char * data, Entity::Player& player, boost: { Common::FFXIVARR_POSITION3 posC = player.getPos(); std::mt19937 gen( rand() * 1000 ); - std::uniform_int_distribution dis( distCoefficient * -1, distCoefficient ); + std::uniform_int_distribution< int > dis( distCoefficient * -1, distCoefficient ); posC.x += dis( gen ); posC.z += dis( gen ); diff --git a/src/servers/sapphire_zone/Framework.cpp b/src/servers/sapphire_zone/Framework.cpp index b50a7806..04bde01a 100644 --- a/src/servers/sapphire_zone/Framework.cpp +++ b/src/servers/sapphire_zone/Framework.cpp @@ -4,6 +4,12 @@ Core::ServerZone g_serverZone( "config/settings_zone.xml" ); +bool Core::Framework::initSocialGroups() +{ + g_friendListMgr = Core::Social::SocialMgr< Core::Social::FriendList >(); + return true; +} + Core::Logger& Core::Framework::getLogger() { return g_log; @@ -42,4 +48,9 @@ Core::Db::DbWorkerPool< Core::Db::CharaDbConnection >& Core::Framework::getChara Core::ServerZone& Core::Framework::getServerZone() { return g_serverZone; +} + +Core::Social::SocialMgr< Core::Social::FriendList > Core::Framework::getFriendsListMgr() +{ + return g_friendListMgr; } \ No newline at end of file diff --git a/src/servers/sapphire_zone/Framework.h b/src/servers/sapphire_zone/Framework.h index 6c39483a..67e8e068 100644 --- a/src/servers/sapphire_zone/Framework.h +++ b/src/servers/sapphire_zone/Framework.h @@ -6,11 +6,11 @@ #include "Forwards.h" - #include "ServerZone.h" #include - +#include +#include #include #include "Script/ScriptMgr.h" @@ -21,8 +21,8 @@ #include "DebugCommand/DebugCommandHandler.h" -#include -#include +#include "Social/Manager/SocialMgr.h" + namespace Core { @@ -38,9 +38,12 @@ private: TerritoryMgr g_territoryMgr; LinkshellMgr g_linkshellMgr; Db::DbWorkerPool< Db::CharaDbConnection > g_charaDb; + Social::SocialMgr< Social::FriendList > g_friendListMgr; public: + bool initSocialGroups(); + Logger& getLogger(); DebugCommandHandler& getDebugCommandHandler(); Scripting::ScriptMgr& getScriptMgr(); @@ -50,6 +53,8 @@ public: Db::DbWorkerPool< Db::CharaDbConnection >& getCharaDb(); ServerZone& getServerZone(); + Social::SocialMgr< Social::FriendList > getFriendsListMgr(); + }; } diff --git a/src/servers/sapphire_zone/Network/Handlers/PacketHandlers.cpp b/src/servers/sapphire_zone/Network/Handlers/PacketHandlers.cpp index 6813d01c..3d9022d5 100644 --- a/src/servers/sapphire_zone/Network/Handlers/PacketHandlers.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/PacketHandlers.cpp @@ -479,7 +479,7 @@ void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket uint16_t i = 0; - auto playerFriendsList = g_friendListMgr.findGroupById( player.getFriendsListId() ); + auto playerFriendsList = g_framework.getFriendsListMgr().findGroupById( player.getFriendsListId() ); // todo: move this garbage else fucking where for ( auto member : playerFriendsList.getMembers() ) @@ -488,7 +488,7 @@ void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket if ( i == 10 ) break; - g_log.debug( "aaa" + std::to_string( i ) + ": " + member.second.name ); + g_framework.getLogger().debug( "aaa" + std::to_string( i ) + ": " + member.second.name ); listPacket.data().entries[i] = Core::Social::Group::generatePlayerEntry( member.second ); i++; } @@ -539,15 +539,15 @@ void Core::Network::GameConnection::socialReqResponseHandler( const Packets::Gam return; }*/ - g_log.debug( std::to_string( static_cast( action ) ) ); + g_framework.getLogger().debug( std::to_string( static_cast( action ) ) ); - auto pSession = g_serverZone.getSession( targetId ); + auto pSession = g_framework.getServerZone().getSession( targetId ); // todo: notify both inviter/invitee with 0x00CB packet if( pSession ) { - g_log.debug( std::to_string(static_cast(action)) ); + g_framework.getLogger().debug( std::to_string(static_cast(action)) ); } response.data().response = Common::SocialRequestResponse::Accept; memcpy( &( response.data().name ), name.c_str(), 32 ); @@ -561,7 +561,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_serverZone.getSession( name ); + auto pSession = g_framework.getServerZone().getSession( name ); // only the requester needs the response ZoneChannelPacket< FFXIVIpcSocialRequestError > response( player.getId() ); @@ -691,7 +691,7 @@ void Core::Network::GameConnection::socialReqSendHandler( const Packets::GamePac pRecipient->queuePacket( packet ); pRecipient->sendDebug( "ding ding" ); - auto recipientFriendsList = g_friendListMgr.findGroupById( pRecipient->getFriendsListId() ); + auto recipientFriendsList = g_framework.getFriendsListMgr().findGroupById( pRecipient->getFriendsListId() ); auto senderResultPacket = recipientFriendsList.inviteMember( player.getAsPlayer(), pRecipient, player.getId(), pRecipient->getId() ); @@ -699,7 +699,7 @@ void Core::Network::GameConnection::socialReqSendHandler( const Packets::GamePac if ( recipientFriendsList.isFriendList() ) { - g_log.debug( "he HAA HAAA" ); + g_framework.getLogger().debug( "he HAA HAAA" ); } response.data().messageId = typeMessage[category]; @@ -708,7 +708,7 @@ void Core::Network::GameConnection::socialReqSendHandler( const Packets::GamePac player.queuePacket( response ); // todo: handle party, friend request - g_log.debug("sent to " + name); + g_framework.getLogger().debug("sent to " + name); } void Core::Network::GameConnection::chatHandler( const Packets::GamePacket& inPacket, diff --git a/src/servers/sapphire_zone/ServerZone.cpp b/src/servers/sapphire_zone/ServerZone.cpp index 78325bb1..b9691a59 100644 --- a/src/servers/sapphire_zone/ServerZone.cpp +++ b/src/servers/sapphire_zone/ServerZone.cpp @@ -202,6 +202,10 @@ void Core::ServerZone::run( int32_t argc, char* argv[] ) g_log = g_framework.getLogger(); + if ( !g_framework.initSocialGroups() ) + { + g_framework.getLogger().fatal( "Unable to initialize social groups!" ); + } if( !loadSettings( argc, argv ) ) { @@ -216,8 +220,7 @@ void Core::ServerZone::run( int32_t argc, char* argv[] ) return; } - g_friendListMgr = Core::Social::SocialMgr< Core::Social::FriendList >(); - g_friendListMgr.findGroupById( 0 ); + g_framework.getFriendsListMgr().findGroupById( 0 ); Network::HivePtr hive( new Network::Hive() ); Network::addServerToHive< Network::GameConnection >( m_ip, m_port, hive ); diff --git a/src/servers/sapphire_zone/Social/Manager/SocialMgr.cpp b/src/servers/sapphire_zone/Social/Manager/SocialMgr.cpp index 2d228ed5..66766e0d 100644 --- a/src/servers/sapphire_zone/Social/Manager/SocialMgr.cpp +++ b/src/servers/sapphire_zone/Social/Manager/SocialMgr.cpp @@ -1,6 +1,8 @@ #include "../Group.h" #include "SocialMgr.h" +#include "Forwards.h" + template< class T > Core::Social::SocialMgr< T >::SocialMgr() diff --git a/src/servers/sapphire_zone/Social/Manager/SocialMgr.h b/src/servers/sapphire_zone/Social/Manager/SocialMgr.h index 138355cd..fa80f0c3 100644 --- a/src/servers/sapphire_zone/Social/Manager/SocialMgr.h +++ b/src/servers/sapphire_zone/Social/Manager/SocialMgr.h @@ -8,6 +8,8 @@ #include #include +#include "Forwards.h" + namespace Core { namespace Social { @@ -15,6 +17,7 @@ template< class T > class SocialMgr { public: + SocialMgr(); virtual ~SocialMgr();