Skip to content

Commit 4cedd9c

Browse files
committed
fix roleId, hook password input
1 parent df2f5c0 commit 4cedd9c

5 files changed

+42
-4
lines changed

GameClientNetwork_Patch.cs

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using HarmonyLib;
2+
3+
namespace PEPatch
4+
{
5+
[HarmonyPatch(typeof(GameClientNetwork))]
6+
public class GameClientNetwork_Patch
7+
{
8+
[HarmonyPrefix]
9+
[HarmonyPatch("uLink_OnFailedToConnect")]
10+
public static bool uLink_OnFailedToConnect(uLink.NetworkConnectionError error)
11+
{
12+
if (error == uLink.NetworkConnectionError.InvalidPassword && UILobbyMainWndCtrl.Instance != null)
13+
{
14+
MessageBox_N.CancelMask(MsgInfoType.ServerLoginMask);
15+
16+
var serverData = Traverse.Create(UILobbyMainWndCtrl.Instance).Field("mSelectServerData").GetValue();
17+
18+
if (serverData is ServerRegistered)
19+
{
20+
Traverse.Create(serverData).Field("PasswordStatus").SetValue(1);
21+
UILobbyMainWndCtrl.Instance.mCheckPasswordInput.text = string.Empty;
22+
UILobbyMainWndCtrl.Instance.mPassWordWnd.SetActive(true);
23+
return false;
24+
}
25+
}
26+
27+
return true;
28+
}
29+
30+
}
31+
}

PEPatch.csproj

+4
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,15 @@
4646
<Reference Include="System.Data.DataSetExtensions" />
4747
<Reference Include="System.Data" />
4848
<Reference Include="System.Xml" />
49+
<Reference Include="uLink">
50+
<HintPath>PELib\uLink.dll</HintPath>
51+
</Reference>
4952
<Reference Include="UnityEngine">
5053
<HintPath>PELib\UnityEngine.dll</HintPath>
5154
</Reference>
5255
</ItemGroup>
5356
<ItemGroup>
57+
<Compile Include="GameClientNetwork_Patch.cs" />
5458
<Compile Include="PatchInitializer.cs" />
5559
<Compile Include="PatchUtils.cs" />
5660
<Compile Include="Properties\AssemblyInfo.cs" />

PatchUtils.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static void LoadMultiplayerData()
7171

7272
var steamId = SteamFriendPrcMgr.Instance.GetMyInfo()._SteamID.m_SteamID;
7373

74-
var roleId = (steamId.GetHashCode() ^ customData.charactorName.GetHashCode()) % 16000000;
74+
var roleId = (steamId.GetHashCode() ^ customData.charactorName.GetHashCode()) % 13000000;
7575

7676
var role = new CustomData.RoleInfo()
7777
{

UILobbyMainWndCtrl_Patch.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,12 @@ public static bool BtnJoinOnClick(UILobbyMainWndCtrl __instance)
7777
Traverse.Create(server).Field("GameMode").SetValue(0);
7878
Traverse.Create(server).Field("ServerUID").SetValue(1L);
7979

80-
__instance.GetType().GetMethod("ConnectServer", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).Invoke(__instance, new object[] { false, server });
80+
Traverse.Create(__instance).Field("mSelectServerData").SetValue(server);
81+
Traverse.Create(__instance).Field("roomUID").SetValue(1L);
8182

82-
return false;
83+
__instance.mCheckPasswordInput.text = string.Empty;
84+
85+
return true;
8386
}
8487
}
8588
}

UIPlayerBuildCtrl_Patch.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static bool CreatePlayer(UIPlayerBuildCtrl __instance)
3333

3434
var steamId = SteamFriendPrcMgr.Instance.GetMyInfo()._SteamID.m_SteamID;
3535

36-
var roleId = (steamId.GetHashCode() ^ name.GetHashCode()) % 16000000;
36+
var roleId = (steamId.GetHashCode() ^ name.GetHashCode()) % 13000000;
3737

3838
var role = new CustomData.RoleInfo()
3939
{

0 commit comments

Comments
 (0)