Compare commits
4 Commits
a5c775019d
...
c818adb693
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c818adb693 | ||
|
|
ed34a4eece | ||
|
|
92e78f970f | ||
|
|
97f2ad38bb |
@@ -5,9 +5,10 @@ namespace stick.plugins.kcpable.Protocol;
|
||||
|
||||
public class ConvGenerator(CSteamID local, CSteamID remote, int channel)
|
||||
{
|
||||
readonly ulong smaller = Math.Min(local.m_SteamID, remote.m_SteamID);
|
||||
readonly ulong bigger = Math.Max(local.m_SteamID, remote.m_SteamID);
|
||||
readonly int channel = channel;
|
||||
private ulong Combined => smaller ^ (bigger << 1) ^ ((ulong)channel << 2); // 位交错
|
||||
public uint Generate() => (uint)(Combined & 0xFFFFFFFF) ^ (uint)(Combined >> 32); // 全部64位异或压缩到32位的conv
|
||||
private readonly uint localId = local.GetAccountID().m_AccountID;
|
||||
private readonly uint remoteId = remote.GetAccountID().m_AccountID;
|
||||
private uint Smaller => Math.Min(localId, remoteId);
|
||||
private uint Bigger => Math.Max(localId, remoteId);
|
||||
private readonly uint channel = (uint)channel;
|
||||
public uint Generate() => Smaller ^ (Bigger << 1) ^ (channel << 2); // 位交错
|
||||
}
|
||||
5
plan.md
5
plan.md
@@ -56,14 +56,13 @@
|
||||
|
||||
conv的划分应该精确到单人单channel
|
||||
|
||||
1. 取两边steamid
|
||||
1. 取两边steamid的accountid
|
||||
2. 按大小分成bigger和smaller
|
||||
3. 取需要发送到的目标channel(懒得发只定义了两个)
|
||||
4. 计算
|
||||
|
||||
``` csharp
|
||||
private ulong Combined => smaller ^ (bigger << 1) ^ ((ulong)channel << 2); // 位交错
|
||||
public uint Generate() => (uint)(Combined & 0xFFFFFFFF) ^ (uint)(Combined >> 32); // 全部64位异或压缩到32位的conv
|
||||
public uint Generate() => smaller ^ (bigger << 1) ^ (channel << 2); // 位交错
|
||||
```
|
||||
|
||||
## 其它
|
||||
|
||||
Reference in New Issue
Block a user