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.
 
 
 
 
 
 

118 lines
2.8 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ProtoCSStruct;
using Sog;
namespace Friend
{
public class PlayerTable : IServerDataObj
{
// uid
public Dictionary<long, PlayerInfoFriend> m_playerTable;
public List<PlayerInfoFriend> m_playerListForUpdate;
public PlayerTable()
{
m_playerTable = new Dictionary<long, PlayerInfoFriend>();
m_playerListForUpdate = new List<PlayerInfoFriend>();
}
public override int GetDataType()
{
return FriendDataObjType.PlayerTable;
}
}
public class FixedList<T>
{
private T[] array;
private int count;
private int length;
public FixedList(int num)
{
array = new T[num];
count = 0;
length = num;
}
public int Count => count;
public int Lenght => length;
public ref T this[int index]
{
get
{
if (index < 0 || index >= count)
{
throw new ArgumentOutOfRangeException();
}
return ref array[index];
}
}
public void Add(ref T item)
{
if (count >= length)
{
throw new ArgumentOutOfRangeException();
}
array[count] = item;
count++;
}
public bool IsFull()
{
return count >= length;
}
public void Clear()
{
count = 0;
}
}
public class FriendRecommendInfo
{
public static int MaxLevel = 10;
public static int ArrayNum = MaxLevel / 10 + 1;
public static int NumPerLevel = 500;
// 每10级一个推荐组, uidHash方便查询是否在组中, uidList记录所有在组里的数据, 方便随机推荐
public int logicWorldId;
public HashSet<long>[] uidHash = new HashSet<long>[ArrayNum];
public FixedList<long>[] uidList = new FixedList<long>[ArrayNum];
public FriendRecommendInfo(int logicWorldId)
{
this.logicWorldId = logicWorldId;
for (int i = 0; i < ArrayNum; i++)
{
uidHash[i] = new HashSet<long>();
uidList[i] = new FixedList<long>(NumPerLevel);
}
}
}
public class FriendRecommendTable : IServerDataObj
{
public Dictionary<int, FriendRecommendInfo> m_recommendInfoTable;
public long nextTickSec;
public FriendRecommendTable()
{
m_recommendInfoTable = new Dictionary<int, FriendRecommendInfo>();
}
public override int GetDataType()
{
return FriendDataObjType.FriendRecommendTable;
}
}
}