Skip to content

Commit

Permalink
Clean up accesstools
Browse files Browse the repository at this point in the history
  • Loading branch information
RedstoneWizard08 committed Apr 12, 2024
1 parent 1bfdd7d commit dde6e8e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Source/Patches/LobbyPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ internal static bool OnNetworkingSessionRequest(SteamLobbyHandler __instance, St
internal static bool OpenLobby(SteamLobbyHandler __instance) {
if (__instance.MasterClient) {
if (__instance.IsPlayingWithRandoms()) {
SteamMatchmaking.SetLobbyType((CSteamID)AccessTools.Field(typeof(CSteamID), "m_CurrentLobby").GetValue(__instance), ELobbyType.k_ELobbyTypePublic);
SteamMatchmaking.SetLobbyType(__instance.m_CurrentLobby, ELobbyType.k_ELobbyTypePublic);
} else {
SteamMatchmaking.SetLobbyType((CSteamID)AccessTools.Field(typeof(CSteamID), "m_CurrentLobby").GetValue(__instance), ELobbyType.k_ELobbyTypeFriendsOnly);
SteamMatchmaking.SetLobbyType(__instance.m_CurrentLobby, ELobbyType.k_ELobbyTypeFriendsOnly);
}

SteamMatchmaking.SetLobbyJoinable((CSteamID)AccessTools.Field(typeof(CSteamID), "m_CurrentLobby").GetValue(__instance), true);
SteamMatchmaking.SetLobbyJoinable(__instance.m_CurrentLobby, true);
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion Source/Patches/QuotaPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ internal class QuotaPatch {
[HarmonyPostfix]
[HarmonyPatch(typeof(RoomStatsHolder), MethodType.Constructor, [typeof(SurfaceNetworkHandler), typeof(int), typeof(int), typeof(int)])]
internal static void Constructor(RoomStatsHolder __instance, SurfaceNetworkHandler handler, int startMoney, int startQuotaToReachToReach, int daysPerQuota) {
AccessTools.Property(typeof(RoomStatsHolder), "DaysPerQutoa").SetValue(__instance, Plugin.Instance.PluginConfig.daysPerQuota.Value);
__instance.DaysPerQutoa = Plugin.Instance.PluginConfig.daysPerQuota.Value;
}
}
}
4 changes: 1 addition & 3 deletions Source/Patches/SyncPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
namespace ConfigurableWarning.Patches {
[HarmonyPatch]
internal class SyncPatch {
internal static Player GetPlayer(PlayerSyncer __instance) => (Player)AccessTools.Field(typeof(PlayerSyncer), "player").GetValue(__instance);

[HarmonyPrefix]
[HarmonyPatch(typeof(PlayerSyncer), nameof(PlayerSyncer.OnPhotonSerializeView))]
internal static bool OnPhotonSerializeView(PlayerSyncer __instance, PhotonStream stream, PhotonMessageInfo info) {
Expand Down Expand Up @@ -36,7 +34,7 @@ internal static bool OnPhotonSerializeView(PlayerSyncer __instance, PhotonStream
stream.SendNext(array);
binarySerializer.Dispose();
} else {
if (GetPlayer(__instance) == null || GetPlayer(__instance).data == null) {
if (__instance.player == null || __instance.player.data == null) {
return true;
}

Expand Down

0 comments on commit dde6e8e

Please sign in to comment.