You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
3.4 KiB
95 lines
3.4 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
using Sog;
|
|
using ProtoCSStruct;
|
|
|
|
|
|
namespace Friend
|
|
{
|
|
public static class FriendStrangerSvc
|
|
{
|
|
|
|
public static void TickDeleteStrangerIfInFriendList(long uid, bool notifyClient)
|
|
{
|
|
// 添加好友时处理陌生人, 不要在tick中处理
|
|
#if false
|
|
|
|
PlayerInfoFriend player = FriendServerUtils.GetPlayerTableOp().GetPlayerInfo(uid);
|
|
if (player == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (player.IsOnline == false)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//这个是有可能的,db没有加载成功
|
|
ref FriendCacheInfoStruct info = ref FriendOp.GetFriendInfoByUid(player.UserID);
|
|
if (info.IsNull())
|
|
{
|
|
return;
|
|
}
|
|
|
|
for (int i = info.FriendOpData.StrangerCount - 1; i >= 0; i--)
|
|
{
|
|
|
|
ref DBFriendStrangerOneStruct stranger = ref FriendOp.GetFriendStrangerByIndex(ref info, i);
|
|
ref DBFriendOneStruct strangerFriend = ref FriendInfoCache.m_cacheStructFriendOne.GetByIndex(stranger.DBFriendOneID);
|
|
|
|
//这个陌生人已经在好友列表了,删除之
|
|
TraceLog.Trace("FriendStrangerSvc.TickDeleteStrangerIfInFriendList uid {0} stranger {1} already in my friend list,delete from strangerlist"
|
|
, uid, strangerFriend.oneFriend.Uid);
|
|
|
|
|
|
//这里有错误,先编译通过吧
|
|
FriendOp.DoDeleteFriendOP(ref info, stranger.DBFriendOneID);
|
|
|
|
//通知客户端吗
|
|
if(notifyClient)
|
|
{
|
|
FriendNotify.NotifyPlayerFriendStrangerListDelete(uid, strangerFriend.oneFriend.Uid);
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|
|
public static void OnCliFriendQueryStrangerReq(uint remoteAppID, StructPacket packet)
|
|
{
|
|
PlayerInfoFriend player = FriendServerUtils.GetPlayerTableOp().GetPlayerInfo(packet.ObjectID);
|
|
if (player == null)
|
|
{
|
|
TraceLog.Error("FriendRecommenderSvc.OnCliFriendQueryStrangerReq can not find player uid {0}", packet.ObjectID);
|
|
return;
|
|
}
|
|
|
|
ref FriendCacheInfoStruct friendinfo = ref FriendOp.GetFriendInfoByUid(player.UserID);
|
|
if (friendinfo.IsNull())
|
|
{
|
|
TraceLog.Error("FriendRecommenderSvc.OnCliFriendQueryStrangerReq can not find player uid {0} friendInfo from cache"
|
|
, player.UserID);
|
|
return;
|
|
}
|
|
|
|
CSFriendQueryStrangerRes res = new CSFriendQueryStrangerRes();
|
|
for (int i = 0; i < friendinfo.FriendOpData.StrangerCount; i++)
|
|
{
|
|
ref DBFriendStrangerOneStruct oneStruct = ref FriendOp.GetFriendStrangerByIndex(ref friendinfo, i);
|
|
ref var friendone = ref FriendInfoCache.m_cacheStructFriendOne.GetByIndex(oneStruct.DBFriendOneID);
|
|
if(friendone.IsNull())continue;
|
|
|
|
DBFriendStrangerOne one = new DBFriendStrangerOne();
|
|
one.PlayTogetherCount = oneStruct.PlayTogetherCount;
|
|
one.LastUpdateTime = oneStruct.LastUpdateTime;
|
|
one.Data.CopyFrom(ref friendone.oneFriend);
|
|
res.List.Add(ref one);
|
|
}
|
|
|
|
FriendServerUtils.GetPacketSender().SendToServerByID(player.WorldServerID, (int)CSGameMsgID.FriendQueryStrangerRes,ref res, player.UserID);
|
|
}
|
|
}
|
|
}
|
|
|