Skip to content

Commit d6b30df

Browse files
committed
add steamId and roleId
1 parent e89dc6f commit d6b30df

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

PEPatch.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
<Reference Include="Assembly-CSharp">
3838
<HintPath>PELib\Assembly-CSharp.dll</HintPath>
3939
</Reference>
40+
<Reference Include="Assembly-CSharp-firstpass">
41+
<HintPath>PELib\Assembly-CSharp-firstpass.dll</HintPath>
42+
</Reference>
4043
<Reference Include="System" />
4144
<Reference Include="System.Core" />
4245
<Reference Include="System.Xml.Linq" />

PatchUtils.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,23 @@ public static void LoadMultiplayerData()
6868
var customData = new CustomCharactor.CustomData();
6969
customData.Deserialize(buff);
7070

71+
var steamId = SteamFriendPrcMgr.Instance.GetMyInfo()._SteamID.m_SteamID;
72+
73+
var roleId = steamId.GetHashCode();
74+
75+
if (roleId > int.MaxValue - 4)
76+
{
77+
roleId = 1;
78+
}
79+
7180
rez.Add(new CustomData.RoleInfo()
7281
{
7382
appearData = customData.appearData.Serialize(),
7483
nudeData = customData.nudeAvatarData.Serialize(),
7584
name = customData.charactorName,
7685
sex = (byte)(int)customData.sex,
77-
roleID = rez.Count + 1
86+
steamId = steamId,
87+
roleID = roleId + rez.Count + 1
7888
});
7989
}
8090
}

UIPlayerBuildCtrl_Patch.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using HarmonyLib;
2+
using System.Linq;
23

34
namespace PEPatch
45
{
@@ -20,12 +21,24 @@ public static bool CreatePlayer(UIPlayerBuildCtrl __instance)
2021
var playerModel = Traverse.Create(__instance).Field("mCurrent").GetValue<PlayerModel>();
2122
byte[] appearData = playerModel.mAppearData.Serialize();
2223
byte[] nudeData = playerModel.mNude.Serialize();
24+
25+
var steamId = SteamFriendPrcMgr.Instance.GetMyInfo()._SteamID.m_SteamID;
26+
27+
var roleId = steamId.GetHashCode();
28+
29+
if (roleId > int.MaxValue - 4)
30+
{
31+
roleId = 1;
32+
}
33+
2334
var role = new CustomData.RoleInfo()
2435
{
2536
appearData = appearData,
2637
nudeData = nudeData,
2738
name = name,
28-
sex = (byte)(int)Traverse.Create(__instance).Property("Sex").GetValue()
39+
sex = (byte)(int)Traverse.Create(__instance).Property("Sex").GetValue(),
40+
steamId = SteamFriendPrcMgr.Instance.GetMyInfo()._SteamID.m_SteamID,
41+
roleID = roleId + GameClientLobby.Self.myRoles.Where(r => r.deletedFlag != 1).Select(r => r.roleID).DefaultIfEmpty(0).Max() + 1
2942
};
3043

3144
GameClientLobby.Self.myRoles.Add(role);

0 commit comments

Comments
 (0)