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.
71 lines
2.7 KiB
71 lines
2.7 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
using Sog;
|
|
using ProtoCSStruct;
|
|
using Google.Protobuf.Collections;
|
|
|
|
namespace Friend
|
|
{
|
|
/// <summary>
|
|
/// 好友op列表里的数据是不是和实际这个玩家的数据一致呢,不一致则需要更新
|
|
/// 这个更新比较消耗cpu,所以不要tick的太快,不在线的玩家不处理,反正处理了玩家也看不到
|
|
/// </summary>
|
|
public static class FriendOpListDataSyncSvc
|
|
{
|
|
public static void TickSync(long uid, bool notifyClient)
|
|
{
|
|
PlayerInfoFriend player = FriendServerUtils.GetPlayerTableOp().GetPlayerInfo(uid);
|
|
if (player == null || ! player.IsOnline)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//这个是有可能的,db没有加载成功
|
|
ref FriendCacheInfoStruct info = ref FriendOp.GetFriendInfoByUid(player.UserID);
|
|
if (info.IsNull())
|
|
{
|
|
return;
|
|
}
|
|
|
|
// todo 后期优化性能时可以考虑不在tick时更新FriendOp, 让玩家可以自由点头像查看对方信息, 这样查看时更新即可
|
|
for (int i = 0; i < info.FriendOpData.OpCount; i++)
|
|
{
|
|
bool bChg = false;
|
|
ref DBFriendOneOpStruct oneop = ref FriendOp.GetFriendOpByIndex(ref info, i);
|
|
|
|
ref DBFriendOneStruct submit = ref FriendInfoCache.m_cacheStructFriendOne.GetByIndex(oneop.DBFriendOneID);
|
|
if (FriendUtils.IsPlayerBelongThisServer(submit.oneFriend.Uid))
|
|
{
|
|
ref FriendCacheInfoStruct submitInfo = ref FriendOp.GetFriendInfoByUid(submit.oneFriend.Uid);
|
|
if (! submitInfo.IsNull())
|
|
{
|
|
bChg = FriendUtils.CheckAndChangeFriendOne(ref submit, ref submitInfo);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ref RemoteFriendOneStruct submitInfo = ref FriendOp.GetRemoteFriendOneByUid(submit.oneFriend.Uid);
|
|
if (! submitInfo.IsNull())
|
|
{
|
|
bChg = FriendUtils.CheckAndChangeFriendOneByRemoteFriend(ref submit, ref submitInfo);
|
|
}
|
|
}
|
|
|
|
if (bChg)
|
|
{
|
|
TraceLog.Trace("FriendOpListDataSyncSvc.TickSync uid {0} submit {1} data chg", uid, submit.oneFriend.Uid);
|
|
|
|
info.SetNeedSave(true);
|
|
|
|
if (notifyClient)
|
|
{
|
|
FriendNotify.NotifyPlayerFriendOpListChg(uid, ref oneop, ref submit);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|