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.
75 lines
3.3 KiB
75 lines
3.3 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
using Sog;
|
|
|
|
namespace Friend
|
|
{
|
|
public class FriendInfoCache : IServerDataObj
|
|
{
|
|
// uid -> m_cacheStructFriendInfo[] 中的索引
|
|
public static Dictionary<long, long> m_selfIDMap;
|
|
// 玩家自己好友相关的数据
|
|
public static StructMemoryCache<FriendCacheInfoStruct> m_cacheStructFriendInfo;
|
|
// 玩家好友列表中每个好友的数据
|
|
public static StructMemoryCache<DBFriendOneStruct> m_cacheStructFriendOne;
|
|
// 玩家操作列表的数据, 比如申请好友, 删除好友
|
|
public static StructMemoryCache<DBFriendOneOpStruct> m_cacheStructFriendOneOp;
|
|
// 玩家私聊
|
|
public static StructMemoryCache<DBFriendChatOneStruct> m_cacheStructFriendChat;
|
|
// 陌生人推荐
|
|
public static StructMemoryCache<DBFriendStrangerOneStruct> m_cacheStructFriendStranger;
|
|
|
|
// 不在当前服务器上的好友索引, uid -> m_remoteFriendOneCache [] 中的索引
|
|
public static Dictionary<long, long> m_remoteFriendIDMap;
|
|
// 不在当前服务器上的好友的数据
|
|
public static StructMemoryCache<RemoteFriendOneStruct> m_remoteFriendOneCache;
|
|
|
|
// 好友数据中的icon压缩以后长度不会大于35,这里加个数字检查下是否有bug,停服的时候打个log
|
|
public long ErrIconCount;
|
|
|
|
public FriendInfoCache(int self, int friendList, int friendOp, int chatList, int stranger)
|
|
{
|
|
m_selfIDMap = new Dictionary<long, long>();
|
|
|
|
//(备注下:目前一旦超过FriendStructDef.MaxFriendSelfCount限制,peek就会崩溃,代码注意判断)
|
|
m_cacheStructFriendInfo = new StructMemoryCache<FriendCacheInfoStruct>(self);
|
|
|
|
|
|
//DBFriendOneStruct 312 byte
|
|
// friendOpData和strangerList里面也占用了DBFriendOneStruct
|
|
int friendOneNum = self * (friendList + friendOp + chatList + stranger) / 4;
|
|
m_cacheStructFriendOne = new StructMemoryCache<DBFriendOneStruct>(friendOneNum);
|
|
|
|
m_cacheStructFriendOneOp = new StructMemoryCache<DBFriendOneOpStruct>(self * friendOp / 4);
|
|
|
|
// DBFriendChatOneStruct 712
|
|
m_cacheStructFriendChat = new StructMemoryCache<DBFriendChatOneStruct>(self * chatList / 4);
|
|
|
|
if (stranger > 1)
|
|
{
|
|
m_cacheStructFriendStranger = new StructMemoryCache<DBFriendStrangerOneStruct>(self * stranger / 4);
|
|
}
|
|
else
|
|
{
|
|
// 陌生人功能现在不要了, 以防策划临时起意又改回来, 分配1个单位内存
|
|
m_cacheStructFriendStranger = new StructMemoryCache<DBFriendStrangerOneStruct>(1);
|
|
}
|
|
|
|
m_remoteFriendIDMap = new Dictionary<long, long>();
|
|
|
|
// 目前只有好友列表中的不属于当前服务器的好友信息会放在remote中
|
|
// 最大值 = self_num * max_friend_person, 假设所有人的好友都不在同一个服务器
|
|
// RemoteFriendOneStruct 312
|
|
m_remoteFriendOneCache = new StructMemoryCache<RemoteFriendOneStruct>(self * friendList / 4);
|
|
}
|
|
|
|
public override int GetDataType()
|
|
{
|
|
return FriendDataObjType.FriendInfoCache;
|
|
}
|
|
|
|
}
|
|
}
|
|
|