Jump to content

friend list


Guest Method

Recommended Posts

hi I have a little (stupid?) ask.

how can I set the friendlist to : NOT even gm or admin can add another faction into own friend list ?

I found this source code, dunno if it is right ... what to set ?

void WorldSession::HandleFriendListOpcode( WorldPacket & recv_data )
{
   CHECK_PACKET_SIZE(recv_data, 4);
   sLog.outDebug( "WORLD: Received CMSG_CONTACT_LIST" );
   uint32 unk;
   recv_data >> unk;
   sLog.outDebug("unk value is %u", unk);
   _player->GetSocial()->SendSocialList();
}

void WorldSession::HandleAddFriendOpcode( WorldPacket & recv_data )
{
   CHECK_PACKET_SIZE(recv_data, 1+1);

   sLog.outDebug( "WORLD: Received CMSG_ADD_FRIEND" );

   std::string friendName  = GetMangosString(LANG_FRIEND_IGNORE_UNKNOWN);
   std::string friendNote;
   FriendsResult friendResult = FRIEND_NOT_FOUND;
   Player *pFriend     = NULL;
   uint64 friendGuid   = 0;

   recv_data >> friendName;

   // recheck
   CHECK_PACKET_SIZE(recv_data, (friendName.size()+1)+1);

   recv_data >> friendNote;

   if(!normalizePlayerName(friendName))
       return;

   CharacterDatabase.escape_string(friendName);            // prevent SQL injection - normal name don't must changed by this call

   sLog.outDebug( "WORLD: %s asked to add friend : '%s'",
       GetPlayer()->GetName(), friendName.c_str() );

   friendGuid = objmgr.GetPlayerGUIDByName(friendName);

   if(friendGuid)
   {
       pFriend = ObjectAccessor::FindPlayer(friendGuid);
       if(pFriend==GetPlayer())
           friendResult = FRIEND_SELF;
       else if(GetPlayer()->GetTeam()!=objmgr.GetPlayerTeamByGUID(friendGuid) && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND) && GetSecurity() < SEC_MODERATOR)
           friendResult = FRIEND_ENEMY;
       else if(GetPlayer()->GetSocial()->HasFriend(GUID_LOPART(friendGuid)))
           friendResult = FRIEND_ALREADY;
   }

   if (friendGuid && friendResult==FRIEND_NOT_FOUND)
   {
       if( pFriend && pFriend->IsInWorld() && pFriend->IsVisibleGloballyFor(GetPlayer()))
           friendResult = FRIEND_ADDED_ONLINE;
       else
           friendResult = FRIEND_ADDED_OFFLINE;

       if(!_player->GetSocial()->AddToSocialList(GUID_LOPART(friendGuid), false))
       {
           friendResult = FRIEND_LIST_FULL;
           sLog.outDebug( "WORLD: %s's friend list is full.", GetPlayer()->GetName());
       }

       _player->GetSocial()->SetFriendNote(GUID_LOPART(friendGuid), friendNote);

       sLog.outDebug( "WORLD: %s Guid found '%u'.", friendName.c_str(), GUID_LOPART(friendGuid));
   }
   else if(friendResult==FRIEND_ALREADY)
   {
       sLog.outDebug( "WORLD: %s Guid Already a Friend.", friendName.c_str() );
   }
   else if(friendResult==FRIEND_SELF)
   {
       sLog.outDebug( "WORLD: %s Guid can't add himself.", friendName.c_str() );
   }
   else
   {
       sLog.outDebug( "WORLD: %s Guid not found.", friendName.c_str() );
   }

   sSocialMgr.SendFriendStatus(GetPlayer(), friendResult, GUID_LOPART(friendGuid), friendName, false);

   sLog.outDebug( "WORLD: Sent (SMSG_FRIEND_STATUS)" );
}

void WorldSession::HandleDelFriendOpcode( WorldPacket & recv_data )
{
   CHECK_PACKET_SIZE(recv_data, 8);

   uint64 FriendGUID;

   sLog.outDebug( "WORLD: Received CMSG_DEL_FRIEND" );

   recv_data >> FriendGUID;

   _player->GetSocial()->RemoveFromSocialList(GUID_LOPART(FriendGUID), false);

   sSocialMgr.SendFriendStatus(GetPlayer(), FRIEND_REMOVED, GUID_LOPART(FriendGUID), "", false);

   sLog.outDebug( "WORLD: Sent motd (SMSG_FRIEND_STATUS)" );
}

void WorldSession::HandleAddIgnoreOpcode( WorldPacket & recv_data )
{
   CHECK_PACKET_SIZE(recv_data,1);

   sLog.outDebug( "WORLD: Received CMSG_ADD_IGNORE" );

   std::string IgnoreName = GetMangosString(LANG_FRIEND_IGNORE_UNKNOWN);
   FriendsResult ignoreResult = FRIEND_IGNORE_NOT_FOUND;
   uint64 IgnoreGuid = 0;

   recv_data >> IgnoreName;

   if(!normalizePlayerName(IgnoreName))
       return;

   CharacterDatabase.escape_string(IgnoreName);            // prevent SQL injection - normal name don't must changed by this call

   sLog.outDebug( "WORLD: %s asked to Ignore: '%s'",
       GetPlayer()->GetName(), IgnoreName.c_str() );

   IgnoreGuid = objmgr.GetPlayerGUIDByName(IgnoreName);

   if(IgnoreGuid)
   {
       if(IgnoreGuid==GetPlayer()->GetGUID())
           ignoreResult = FRIEND_IGNORE_SELF;
       else
       {
           if( GetPlayer()->GetSocial()->HasIgnore(GUID_LOPART(IgnoreGuid)) )
               ignoreResult = FRIEND_IGNORE_ALREADY;
       }
   }

   if (IgnoreGuid && ignoreResult == FRIEND_IGNORE_NOT_FOUND)
   {
       ignoreResult = FRIEND_IGNORE_ADDED;

       if(!_player->GetSocial()->AddToSocialList(GUID_LOPART(IgnoreGuid), true))
           ignoreResult = FRIEND_IGNORE_FULL;
   }
   else if(ignoreResult==FRIEND_IGNORE_ALREADY)
   {
       sLog.outDebug( "WORLD: %s Guid Already Ignored.", IgnoreName.c_str() );
   }
   else if(ignoreResult==FRIEND_IGNORE_SELF)
   {
       sLog.outDebug( "WORLD: %s Guid can't add himself.", IgnoreName.c_str() );
   }
   else
   {
       sLog.outDebug( "WORLD: %s Guid not found.", IgnoreName.c_str() );
   }

   sSocialMgr.SendFriendStatus(GetPlayer(), ignoreResult, GUID_LOPART(IgnoreGuid), "", false);

   sLog.outDebug( "WORLD: Sent (SMSG_FRIEND_STATUS)" );
}

void WorldSession::HandleDelIgnoreOpcode( WorldPacket & recv_data )
{
   CHECK_PACKET_SIZE(recv_data, 8);

   uint64 IgnoreGUID;

   sLog.outDebug( "WORLD: Received CMSG_DEL_IGNORE" );

   recv_data >> IgnoreGUID;

   _player->GetSocial()->RemoveFromSocialList(GUID_LOPART(IgnoreGUID), true);

   sSocialMgr.SendFriendStatus(GetPlayer(), FRIEND_IGNORE_REMOVED, GUID_LOPART(IgnoreGUID), "", false);

   sLog.outDebug( "WORLD: Sent motd (SMSG_FRIEND_STATUS)" );
}

void WorldSession::HandleSetFriendNoteOpcode( WorldPacket & recv_data )
{
   CHECK_PACKET_SIZE(recv_data, 8+1);
   uint64 guid;
   std::string note;
   recv_data >> guid >> note;
   _player->GetSocial()->SetFriendNote(guid, note);
}

10x a lot for your ideas

Link to comment
Share on other sites

but you know, for my pvp server, we would like to have it separated :/ because gms can join the battle with gm account ( surely without using commands )

excuse my request, I know that this is not for whole comunity ...

edit: blah, bad explanation ... we wouldn't like to saw location of another faction player ... :)

Link to comment
Share on other sites

how can I set the friendlist to : NOT even gm or admin can add another faction into own friend list ?

Delete "&& GetSecurity() < SEC_MODERATOR" from this line:

else if(GetPlayer()->GetTeam()!=objmgr.GetPlayerTeamByGUID(friendGuid) && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND) && GetSecurity() < SEC_MODERATOR)

Patch (git)

--- a/src/game/MiscHandler.cpp
+++ b/src/game/MiscHandler.cpp
@@ -668,7 +668,7 @@ void WorldSession::HandleAddFriendOpcode( WorldPacket & recv_data )
        pFriend = ObjectAccessor::FindPlayer(friendGuid);
        if(pFriend==GetPlayer())
            friendResult = FRIEND_SELF;
-        else if(GetPlayer()->GetTeam()!=objmgr.GetPlayerTeamByGUID(friendGuid) && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND) && GetSecurity() < SEC_MODERATOR)
+        else if(GetPlayer()->GetTeam()!=objmgr.GetPlayerTeamByGUID(friendGuid) && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND))
            friendResult = FRIEND_ENEMY;
        else if(GetPlayer()->GetSocial()->HasFriend(GUID_LOPART(friendGuid)))
            friendResult = FRIEND_ALREADY;

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use