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.
225 lines
6.1 KiB
225 lines
6.1 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
using Sog;
|
|
using ProtoCSStruct;
|
|
using Sog.Data;
|
|
|
|
namespace Friend
|
|
{
|
|
public static class FriendStructDef
|
|
{
|
|
public const int MaxCacheTimeout = 7200;
|
|
|
|
// 最大数量
|
|
public const int MaxFriendSelfCount = 1000;
|
|
public const int MaxFriendCount = 30;
|
|
public const int MaxOpListCount = 30;
|
|
public const int MaxChatListCount = 64;
|
|
public const int MaxStrangerListCount = 1;
|
|
public const int MaxBlacklistCount = 50;
|
|
}
|
|
|
|
|
|
public struct DBFriendOneStruct : IStructObject
|
|
{
|
|
public int m_objectID;
|
|
public int GetObjectID()
|
|
{
|
|
return m_objectID;
|
|
}
|
|
public void SetObjectID(int id)
|
|
{
|
|
m_objectID = id;
|
|
}
|
|
public bool IsNull()
|
|
{
|
|
return m_objectID == -1;
|
|
}
|
|
public DBFriendOne oneFriend;
|
|
}
|
|
|
|
public struct DBFriendOneOpStruct : IStructObject
|
|
{
|
|
public int m_objectID; //就是这个结构体所处的位置
|
|
public int GetObjectID()
|
|
{
|
|
return m_objectID;
|
|
}
|
|
public void SetObjectID(int id)
|
|
{
|
|
m_objectID = id;
|
|
}
|
|
public bool IsNull()
|
|
{
|
|
return m_objectID == -1;
|
|
}
|
|
|
|
// 操作类型, 申请/同意/删除/黑名单之类的操作类型
|
|
public int OpType;
|
|
// 操作序列号, 唯一自增, 用来标识操作
|
|
public int OpSeq;
|
|
// 对应 m_cacheStructFriendOne[] 中的index
|
|
public long DBFriendOneID;
|
|
// uid, 方便使用
|
|
public long FriendUid;
|
|
//public DBFriendOneStruct friend;这里不能保存,结构体是拷贝的,保存DBFriendOneID 关联到m_cacheStructFriendOne就好了
|
|
}
|
|
|
|
public struct DBFriendChatOneStruct : IStructObject
|
|
{
|
|
public int m_objectID;
|
|
public int GetObjectID()
|
|
{
|
|
return m_objectID;
|
|
}
|
|
public void SetObjectID(int id)
|
|
{
|
|
m_objectID = id;
|
|
}
|
|
public bool IsNull()
|
|
{
|
|
return m_objectID == -1;
|
|
}
|
|
|
|
public DBFriendChatOne oneFriendChat;
|
|
}
|
|
|
|
public struct DBFriendStrangerOneStruct : IStructObject
|
|
{
|
|
public int m_objectID;
|
|
public int GetObjectID()
|
|
{
|
|
return m_objectID;
|
|
}
|
|
public void SetObjectID(int id)
|
|
{
|
|
m_objectID = id;
|
|
}
|
|
public bool IsNull()
|
|
{
|
|
return m_objectID == -1;
|
|
}
|
|
|
|
public int PlayTogetherCount;//一起玩牌次数
|
|
public long LastUpdateTime; //最后更新时间,比如最后一起玩牌时间
|
|
public long DBFriendOneID;
|
|
//public DBFriendOneStruct data;这里不能保存,结构体是拷贝的,保存DBFriendOneID 关联到m_cacheStructFriendOne就好了
|
|
}
|
|
|
|
//以下为缓存中间结构,用索引关联具体的数据
|
|
unsafe public struct DBFriendOpDataStruct
|
|
{
|
|
public int LastOpSeq;
|
|
public int OpCount;
|
|
public fixed long OpList[FriendStructDef.MaxOpListCount];
|
|
public int LastChatSeq;
|
|
public int ChatCount;
|
|
public fixed long ChatList[FriendStructDef.MaxChatListCount];
|
|
public int StrangerCount;
|
|
public fixed long StrangerList[FriendStructDef.MaxStrangerListCount]; //陌生人列表,比如一起玩过牌的
|
|
}
|
|
|
|
|
|
unsafe public struct DBFriendListStruct
|
|
{
|
|
public int iCount;
|
|
//注意,这里是可以规定实际达到的最大值(DBFriendOpDataStruct中的最大值也一样)
|
|
public fixed long DBFriendOneID[FriendStructDef.MaxFriendCount];
|
|
}
|
|
|
|
public struct FriendCacheInfoStruct : IStructObject
|
|
{
|
|
public int m_objectID;
|
|
public int GetObjectID()
|
|
{
|
|
return m_objectID;
|
|
}
|
|
public void SetObjectID(int id)
|
|
{
|
|
m_objectID = id;
|
|
}
|
|
public bool IsNull()
|
|
{
|
|
return m_objectID == -1;
|
|
}
|
|
|
|
public bool NeedSave;
|
|
public void SetNeedSave(bool needSave)
|
|
{
|
|
NeedSave = needSave;
|
|
if (needSave)
|
|
{
|
|
GetDataSeqSave().MakeDirty();
|
|
}
|
|
}
|
|
public bool GetNeedSave()
|
|
{
|
|
return NeedSave || dataSeqSave.IsDirty();
|
|
}
|
|
|
|
// 自己的信息, gamesvr定期刷新到friendsvr
|
|
public DBFriendSelf Self;
|
|
// 好友列表, 保存的是 m_cacheStructFriendOne[] 中的index
|
|
public DBFriendListStruct FriendList;
|
|
// 好友操作列表, 保存的是 m_cacheStructFriendOneOp[] 中的index
|
|
public DBFriendOpDataStruct FriendOpData;
|
|
// 最后一次访问时间,用来淘汰
|
|
public long LastAccessTime;
|
|
|
|
// 保存DB
|
|
private DataSeqSave dataSeqSave;
|
|
public DataSeqSave GetDataSeqSave()
|
|
{
|
|
if (dataSeqSave == null)
|
|
{
|
|
return dataSeqSave = new DataSeqSave();
|
|
}
|
|
return dataSeqSave;
|
|
}
|
|
|
|
}
|
|
|
|
// RemoteFriendOneStruct在数据结构上和DBFriendOne一致
|
|
// Q:为什么需要RemoteFriendOneStruct?
|
|
// A:避免直接用"="更新数据, 把FriendList中关于好友的特殊数据覆盖了, 比如礼物数据
|
|
public struct RemoteFriendOneStruct : IStructObject
|
|
{
|
|
public int m_objectID;
|
|
public int GetObjectID()
|
|
{
|
|
return m_objectID;
|
|
}
|
|
public void SetObjectID(int id)
|
|
{
|
|
m_objectID = id;
|
|
}
|
|
public bool IsNull()
|
|
{
|
|
return m_objectID == -1;
|
|
}
|
|
|
|
//数据
|
|
public long Uid;
|
|
public FixedStructString32 Icon;
|
|
public FixedStructString32 Nick;
|
|
public int Level;
|
|
public int Gender;
|
|
public long LastLoginTime;
|
|
public int VipLevel;
|
|
public int VipExp;
|
|
public long Chip;
|
|
public bool IsOnline;
|
|
public FixedStructString32 RealmName;
|
|
public int MaxPassMainlandId;
|
|
public long MainlineFightPower;
|
|
public RepeatedDBFriendHeroOne_8 MainlineHeros;
|
|
public int LastLogoutTime;
|
|
public long LastAccessTime;
|
|
public bool IsOpenArena;
|
|
public int IconFrameId;
|
|
public int RealmId;
|
|
}
|
|
}
|
|
|