Skip to content

Commit def0fb6

Browse files
committed
[修改]1. 修改修改ActorType和ID的获取
1 parent 417a9c3 commit def0fb6

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

GameFrameX.Core/Utility/IdGenerator.cs

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace GameFrameX.Core.Utility
99
/// 服务器id 类型 时间戳 自增
1010
/// 玩家
1111
/// 公会
12-
/// 服务器id * 1000 + 全局功能id
12+
/// 服务器id * 100000 + 全局功能id
1313
/// 全局玩法
1414
/// </summary>
1515
public static class IdGenerator
@@ -29,7 +29,7 @@ public static class IdGenerator
2929
/// <returns></returns>
3030
public static int GetServerId(long id)
3131
{
32-
return (int)(id < GlobalConst.MaxGlobalId ? id / 1000 : id >> GlobalConst.ServerIdOrModuleIdMask);
32+
return (int)(id < GlobalConst.MaxGlobalId ? id / 100000 : id >> GlobalConst.ServerIdOrModuleIdMask);
3333
}
3434

3535
/// <summary>
@@ -78,7 +78,7 @@ public static ActorType GetActorType(long id)
7878
if (id < GlobalConst.MaxGlobalId)
7979
{
8080
// 全局actor
81-
return (ActorType)(id % 1000);
81+
return (ActorType)id;
8282
}
8383

8484
return (ActorType)((id >> GlobalConst.ActorTypeMask) & 0xF);
@@ -112,33 +112,19 @@ public static long GetActorId(ActorType type, int serverId = 0)
112112
{
113113
return GetMultiActorId(type, serverId);
114114
}
115-
else
116-
{
117-
return GetGlobalActorId(type, serverId);
118-
}
115+
116+
return GetGlobalActorId(type, serverId);
119117
}
120118

121119
/// <summary>
122-
/// 根据ActorType获取ActorId开始值
120+
///
123121
/// </summary>
124122
/// <param name="type"></param>
123+
/// <param name="serverId"></param>
125124
/// <returns></returns>
126-
/// <exception cref="ArgumentException"></exception>
127-
public static long GetMultiActorIdBegin(ActorType type)
128-
{
129-
if (type >= ActorType.Separator)
130-
{
131-
throw new ArgumentException($"input actor type error: {type}");
132-
}
133-
134-
var id = (long)GlobalSettings.ServerId << GlobalConst.ServerIdOrModuleIdMask;
135-
id |= (long)type << GlobalConst.ActorTypeMask;
136-
return id;
137-
}
138-
139125
private static long GetGlobalActorId(ActorType type, int serverId)
140126
{
141-
return (long)(serverId * 1000 + type);
127+
return (long)(serverId * 100000 + type);
142128
}
143129

144130

0 commit comments

Comments
 (0)