mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-28 20:27:46 +00:00
Further changes to list type;
This commit is contained in:
parent
44d158e4e0
commit
9f8d4d9674
6 changed files with 28 additions and 21 deletions
|
@ -497,7 +497,7 @@ void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket
|
|||
|
||||
g_fw.get< Logger >()->debug( "aaa" + std::to_string( i ) );
|
||||
// todo: replace this with call for generating the entire vector
|
||||
listPacket.data().entries[i] = Core::Social::FriendList::generatePlayerEntry( member );
|
||||
listPacket.data().entries[i] = playerFriendsList->generatePlayerEntry( member );
|
||||
i++;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ uint32_t FriendList::addMember( uint64_t contentId, FriendEntryType friendEntryT
|
|||
|
||||
uint32_t logMessage = 0;
|
||||
|
||||
m_members.insert( contentId );
|
||||
m_members.push_back( contentId );
|
||||
|
||||
FriendEntry friendEntry;
|
||||
friendEntry.timestamp = std::time( nullptr );
|
||||
|
@ -41,12 +41,12 @@ uint32_t FriendList::addMember( uint64_t contentId, FriendEntryType friendEntryT
|
|||
friendEntry.entryStatus = friendEntryType;
|
||||
friendEntry.unknown = 0;
|
||||
|
||||
m_entries.insert( friendEntry );
|
||||
m_entries.push_back( friendEntry );
|
||||
|
||||
return logMessage;
|
||||
}
|
||||
|
||||
std::set< FriendEntry >& FriendList::getEntries()
|
||||
std::vector< FriendEntry >& FriendList::getEntries()
|
||||
{
|
||||
return m_entries;
|
||||
}
|
||||
|
@ -101,13 +101,16 @@ std::vector< PlayerEntry > FriendList::getFriendListEntries( uint16_t entryAmoun
|
|||
//todo: generalize this for linkshell etc
|
||||
Core::Network::Packets::Server::PlayerEntry FriendList::generatePlayerEntry( uint64_t contentId )
|
||||
{
|
||||
// We check if player is online. If so, we can pull data from existing session in memory
|
||||
// Otherwise, we pull from SQL. We can optimize this later, there are quite a few choices here
|
||||
// Correlate our contentID with the PlayerEntry map, based on index
|
||||
// can probably optimize using std::set and doing something funky with pointers
|
||||
|
||||
auto pSession = g_fw.get< ServerZone >()->getSession( contentId );
|
||||
|
||||
auto dataIndex = m_members.find( contentId );
|
||||
auto friendEntry = m_entries;
|
||||
std::vector< uint64_t >::iterator it;
|
||||
|
||||
it = std::find( m_members.begin(), m_members.end(), contentId );
|
||||
|
||||
auto dataIndex = std::distance( m_members.begin(), it );
|
||||
|
||||
auto friendEntry = m_entries.at( dataIndex );
|
||||
|
||||
// todo: set as offline in one of the unknown values, if session does not exist
|
||||
Core::Network::Packets::Server::PlayerEntry entry = {};
|
||||
|
@ -123,7 +126,12 @@ Core::Network::Packets::Server::PlayerEntry FriendList::generatePlayerEntry( uin
|
|||
entry.unavailable = 0; // unavailable (other world)
|
||||
entry.one = 1;
|
||||
|
||||
if ( pSession )
|
||||
// We check if player is online. If so, we can pull data from existing session in memory
|
||||
// Otherwise, we pull from SQL. We can optimize this later, there are quite a few choices here
|
||||
|
||||
auto pSession = g_fw.get< ServerZone >()->getSession( contentId );
|
||||
|
||||
if( pSession )
|
||||
{
|
||||
auto pPlayer = pSession->getPlayer();
|
||||
//entry.contentId = pPlayer->getContentId();
|
||||
|
@ -165,7 +173,6 @@ Core::Network::Packets::Server::PlayerEntry FriendList::generatePlayerEntry( uin
|
|||
{
|
||||
// Todo: Can we make PlayerSQL a static function and use it for this?
|
||||
|
||||
|
||||
auto name = res->getString( "Name" );
|
||||
strcpy( entry.name, name.c_str() );
|
||||
//memcpy( entry.name, res->getString( "Name" ), strlen( pPlayer->getName().c_str() ) );
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
uint32_t addMember( uint64_t contentId, FriendEntryType friendEntryType );
|
||||
|
||||
/*! access entry vector */
|
||||
std::set< FriendEntry >& getEntries();
|
||||
std::vector< FriendEntry >& getEntries();
|
||||
|
||||
protected:
|
||||
uint64_t m_id{ 0 };
|
||||
|
|
|
@ -28,14 +28,14 @@ uint32_t Group::addMember( uint64_t contentId )
|
|||
|
||||
uint32_t logMessage = 0;
|
||||
|
||||
m_members.insert( contentId );
|
||||
m_members.push_back( contentId );
|
||||
|
||||
return logMessage;
|
||||
}
|
||||
|
||||
bool Group::hasMember( uint64_t contentId ) const
|
||||
{
|
||||
return m_members.find( contentId ) != m_members.end();
|
||||
return std::find( m_members.begin(), m_members.end(), contentId ) != m_members.end();
|
||||
}
|
||||
|
||||
Core::Network::Packets::GamePacketPtr Group::processInvite( uint64_t recipientId, uint64_t senderId )
|
||||
|
@ -62,7 +62,7 @@ Core::Network::Packets::GamePacketPtr Group::processInvite( uint64_t recipientId
|
|||
|
||||
//m_groupInvites.erase( recipientId );
|
||||
|
||||
m_members.emplace( recipientId );
|
||||
m_members.push_back( recipientId );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -167,7 +167,7 @@ void Group::sendPacketToMembers( Core::Network::Packets::GamePacketPtr pPacket,
|
|||
|
||||
|
||||
|
||||
std::set< uint64_t >& Group::getMembers()
|
||||
std::vector< uint64_t >& Group::getMembers()
|
||||
{
|
||||
return m_members;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
//virtual void populateGroupMembers();
|
||||
|
||||
/*! access member vector */
|
||||
std::set< uint64_t >& getMembers();
|
||||
std::vector< uint64_t >& getMembers();
|
||||
|
||||
/*! get container limit */
|
||||
uint32_t getCapacity() const;
|
||||
|
|
|
@ -137,7 +137,7 @@ uint64_t Core::Social::SocialMgr< Core::Social::FriendList >::loadFriendsList( u
|
|||
// todo: fix this garbage check
|
||||
if( list.at( 0 ) != 0 )
|
||||
{
|
||||
friendsList.getMembers().insert( list.begin(), list.end() );
|
||||
friendsList.getMembers() = list;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,9 +148,9 @@ uint64_t Core::Social::SocialMgr< Core::Social::FriendList >::loadFriendsList( u
|
|||
|
||||
if( inviteData.size() )
|
||||
{
|
||||
std::vector< Social::FriendEntry > list( friends.size() / 8 );
|
||||
std::vector< Social::FriendEntry > invList( friends.size() / 8 );
|
||||
|
||||
friendsList.getEntries().insert( list.begin(), list.end() );
|
||||
friendsList.getEntries() = invList;
|
||||
}
|
||||
|
||||
auto friendListPtr = boost::make_shared< Social::FriendList >( friendsList );
|
||||
|
|
Loading…
Add table
Reference in a new issue