Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Source/Client/AsyncTime/AsyncTimePatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
foreach (var inst in insts)
{
if (inst.operand == AccessTools.PropertyGetter(typeof(Prefs), nameof(Prefs.AutomaticPauseMode)))
if (inst.operand as MethodInfo == AccessTools.PropertyGetter(typeof(Prefs), nameof(Prefs.AutomaticPauseMode)))
inst.operand = AccessTools.Method(typeof(ReceiveLetterPause), nameof(AutomaticPauseMode));
else if (inst.operand == AccessTools.Method(typeof(TickManager), nameof(TickManager.Pause)))
else if (inst.operand as MethodInfo == AccessTools.Method(typeof(TickManager), nameof(TickManager.Pause)))
inst.operand = AccessTools.Method(typeof(ReceiveLetterPause), nameof(PauseOnLetter));

yield return inst;
Expand All @@ -190,7 +190,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
private static AutomaticPauseMode AutomaticPauseMode()
{
return Multiplayer.Client != null
? (AutomaticPauseMode) Multiplayer.GameComp.pauseOnLetter
? (AutomaticPauseMode)Multiplayer.GameComp.pauseOnLetter
: Prefs.AutomaticPauseMode;
}

Expand Down
9 changes: 5 additions & 4 deletions Source/Client/AsyncTime/TimeControlUI.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using HarmonyLib;
using Multiplayer.Client.Util;
Expand Down Expand Up @@ -36,12 +37,12 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
foreach (var inst in insts)
{
if (inst.operand == AccessTools.Method(typeof(TimeControls), nameof(TimeControls.DoTimeControlsGUI)))
if (inst.operand as MethodInfo == AccessTools.Method(typeof(TimeControls), nameof(TimeControls.DoTimeControlsGUI)))
inst.operand = AccessTools.Method(typeof(TimeControlPatch), nameof(DoTimeControlsGUI));

yield return inst;

if (inst.operand == AccessTools.Constructor(typeof(Rect),
if (inst.operand as MethodInfo == AccessTools.Constructor(typeof(Rect),
new[] { typeof(float), typeof(float), typeof(float), typeof(float) }))
{
yield return new CodeInstruction(OpCodes.Ldloca_S, 1);
Expand Down Expand Up @@ -360,7 +361,7 @@ static void DrawButtons()
}
else
{
// There is a new blocking pause
// There is a new blocking pause
flashDict.Add(flashPos, Time.time);
}
}
Expand Down Expand Up @@ -416,7 +417,7 @@ static void DrawPauseFlash(Vector2 pos)
// Only flash at flashInterval from the time the blocking pause began
if (pauseDuration > 0f && pauseDuration % flashInterval < 1f)
{
GenUI.DrawFlash(pos.x, pos.y, UI.screenWidth * 0.6f, Pulser.PulseBrightness(1f, 1f, pauseDuration) * 0.4f, flashColor);
GenUI.DrawFlash(pos.x, pos.y, UI.screenWidth * 0.6f, Pulser.PulseBrightness(1f, 1f, pauseDuration) * 0.4f, flashColor);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Client/Debug/DebugPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
foreach (var inst in insts)
{
if (inst.operand == GizmoOnGUI)
if (inst.operand as MethodInfo == GizmoOnGUI)
yield return new CodeInstruction(OpCodes.Call,
AccessTools.Method(typeof(GizmoDrawDebugInfo), nameof(GizmoOnGUIProxy)));
else if (inst.operand == GizmoOnGUIShrunk)
else if (inst.operand as MethodInfo == GizmoOnGUIShrunk)
yield return new CodeInstruction(OpCodes.Call,
AccessTools.Method(typeof(GizmoDrawDebugInfo), nameof(GizmoOnGUIShrunkProxy)));
else
Expand Down
12 changes: 6 additions & 6 deletions Source/Client/Factions/Blueprints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> e, M

yield return cur;

if (cur.opcode == OpCodes.Call && cur.operand == CanPlaceBlueprintOver)
if (cur.opcode == OpCodes.Call && cur.operand as MethodInfo == CanPlaceBlueprintOver)
{
var thingToIgnoreIndex = insts[i - 2].operand;

Expand Down Expand Up @@ -103,7 +103,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> e, M
new CodeInstruction(OpCodes.Call, CanPlaceBlueprintAtPatch.ShouldIgnore1Method),
new CodeInstruction(OpCodes.Brtrue, insts[loop + 1].operand)
);

return insts;
}
}
Expand Down Expand Up @@ -173,7 +173,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
yield return inst;

if (inst.opcode == OpCodes.Call && inst.operand == SpawningWipes)
if (inst.opcode == OpCodes.Call && inst.operand as MethodInfo == SpawningWipes)
{
yield return new CodeInstruction(OpCodes.Ldarg_2);
yield return new CodeInstruction(OpCodes.Ldloc_3);
Expand All @@ -196,7 +196,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
yield return inst;

if (inst.opcode == OpCodes.Call && inst.operand == SpawningWipes)
if (inst.opcode == OpCodes.Call && inst.operand as MethodInfo == SpawningWipes)
{
yield return new CodeInstruction(OpCodes.Ldarg_2);
yield return new CodeInstruction(OpCodes.Ldloc_S, 4);
Expand All @@ -221,7 +221,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
yield return inst;

if (inst.opcode == OpCodes.Call && inst.operand == SpawningWipes)
if (inst.opcode == OpCodes.Call && inst.operand as MethodInfo == SpawningWipes)
{
yield return new CodeInstruction(OpCodes.Ldarg_0);
yield return new CodeInstruction(OpCodes.Ldfld, ThingDefField);
Expand Down Expand Up @@ -335,7 +335,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
yield return inst;

if (inst.opcode == OpCodes.Isinst && inst.operand == typeof(Blueprint))
if (inst.opcode == OpCodes.Isinst && inst.operand as MethodInfo == typeof(Blueprint))
{
yield return new CodeInstruction(OpCodes.Ldnull);
yield return new CodeInstruction(OpCodes.Cgt_Un);
Expand Down
32 changes: 16 additions & 16 deletions Source/Client/Factions/MultifactionPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static bool Prefix(Quest quest, ref bool __result)
if (quest.TryGetPlayerFaction(out playerFaction) && playerFaction != Faction.OfPlayer)
{
__result = false;
return false;
return false;
}
}
return true;
Expand Down Expand Up @@ -82,8 +82,8 @@ static class WorldInspectPanePaneTopYPatch
{
static void Postfix(ref float __result)
{
if (Multiplayer.Client != null && Multiplayer.RealPlayerFaction == Multiplayer.WorldComp.spectatorFaction)
__result += 35f;
if (Multiplayer.Client != null && Multiplayer.RealPlayerFaction == Multiplayer.WorldComp.spectatorFaction)
__result += 35f;
}
}

Expand Down Expand Up @@ -198,21 +198,21 @@ static class MainButtonsRootDoButtonsPatch
private static bool ReplaceOriginalDrawing(MainButtonsRoot __instance)
{
if (!IsSpectator)
return true;
return true;

try
{
var allButtons = AllButtonsRef(__instance);
if (allButtons == null)
return true;
return true;

var toDraw = SpectatorButtons
.Select(name => allButtons.Find(b => b.defName == name))
.Where(b => b?.Worker.Visible ?? false)
.ToList();

DrawCornerButtons(toDraw);
return false;
return false;
}
catch (Exception ex)
{
Expand Down Expand Up @@ -421,7 +421,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
yield return inst;

if (inst.operand == playerFactionField)
if (inst.operand as MethodInfo == playerFactionField)
yield return new CodeInstruction(OpCodes.Call, factionOfPlayer.Method);
}
}
Expand All @@ -442,7 +442,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst

foreach (var inst in insts)
{
if (inst.operand == isPlayerMethodGetter)
if (inst.operand as MethodInfo == isPlayerMethodGetter)
inst.operand = factionIsPlayer.Method;

yield return inst;
Expand All @@ -464,7 +464,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
foreach (var inst in insts)
{
if (inst.operand == allColonists)
if (inst.operand as MethodInfo == allColonists)
inst.operand = AccessTools.Method(typeof(RecacheColonistBelieverCountPatch), nameof(ColonistsAllPlayerFactions));
yield return inst;
}
Expand Down Expand Up @@ -516,7 +516,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
foreach (var inst in insts)
{
if (inst.operand == isColonyMech)
if (inst.operand as MethodInfo == isColonyMech)
inst.operand = AccessTools.Method(typeof(RecacheColonistBelieverCountPatch), nameof(RecacheColonistBelieverCountPatch.IsColonyMechAnyFaction));

yield return inst;
Expand Down Expand Up @@ -557,10 +557,10 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
foreach (var inst in insts)
{
if (inst.operand == isColonist)
if (inst.operand as MethodInfo == isColonist)
inst.operand = AccessTools.Method(typeof(RecacheColonistBelieverCountPatch), nameof(RecacheColonistBelieverCountPatch.IsColonistAnyFaction));

if (inst.operand == isColonySubhuman)
if (inst.operand as MethodInfo == isColonySubhuman)
inst.operand = AccessTools.Method(typeof(RecacheColonistBelieverCountPatch), nameof(RecacheColonistBelieverCountPatch.IsColonySubhumanAnyFaction));

yield return inst;
Expand All @@ -577,7 +577,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
foreach (var inst in insts)
{
if (inst.operand == isFreeNonSlaveColonist)
if (inst.operand as MethodInfo == isFreeNonSlaveColonist)
inst.operand = AccessTools.Method(typeof(ValidatePawnPatch), nameof(IsFreeNonSlaveColonistAnyFaction));

yield return inst;
Expand Down Expand Up @@ -632,7 +632,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
foreach (var inst in insts)
{
if (inst.operand == PlayOneShotOnCamera)
if (inst.operand as MethodInfo == PlayOneShotOnCamera)
yield return new CodeInstruction(
OpCodes.Call,
SymbolExtensions.GetMethodInfo((SoundDef s, Map m) => PlaySoundReplacement(s, m)));
Expand Down Expand Up @@ -661,7 +661,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst

// This instruction is part of wornGraphicPaths[thingIDNumber % wornGraphicPaths.Count]
// The function makes sure the id is positive
if (inst.operand == thingIDNumberField)
if (inst.operand as MethodInfo == thingIDNumberField)
yield return new CodeInstruction(OpCodes.Call,
AccessTools.Method(typeof(ApparelWornGraphicPathGetterPatch), nameof(MakeIdPositive)));
}
Expand Down Expand Up @@ -721,7 +721,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
yield return inst;

// Don't draw the ideo plate while choosing starting pawns in multifaction
if (inst.operand == classicModeField)
if (inst.operand as MethodInfo == classicModeField)
{
yield return new CodeInstruction(OpCodes.Ldarg_2);
yield return new CodeInstruction(OpCodes.Call,
Expand Down
2 changes: 1 addition & 1 deletion Source/Client/Patches/AllGroupsPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst

foreach (CodeInstruction inst in insts)
{
if (inst.operand == AllGroups)
if (inst.operand as MethodInfo == AllGroups)
{
yield return new CodeInstruction(OpCodes.Ldarg_1).MoveLabelsFrom(inst);
yield return new CodeInstruction(OpCodes.Call, method);
Expand Down
2 changes: 1 addition & 1 deletion Source/Client/Patches/ArbiterPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
yield return inst;

if (inst.operand == IsCreated)
if (inst.operand as MethodInfo == IsCreated)
{
yield return new CodeInstruction(OpCodes.Ldsfld, ArbiterField);
yield return new CodeInstruction(OpCodes.Or);
Expand Down
14 changes: 7 additions & 7 deletions Source/Client/Patches/Determinism.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> e)

for (int i = insts.Count - 1; i >= 0; i--)
{
if (insts[i].operand == FirstOrDefault)
if (insts[i].operand as MethodInfo == FirstOrDefault)
insts.Insert(
i + 1,
new CodeInstruction(OpCodes.Ldloc_1),
Expand Down Expand Up @@ -138,7 +138,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
yield return inst;

if (inst.operand == CellRectContains)
if (inst.operand as MethodInfo == CellRectContains)
{
yield return new CodeInstruction(OpCodes.Ldc_I4_1);
yield return new CodeInstruction(OpCodes.Or);
Expand All @@ -155,7 +155,7 @@ public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructio
foreach (CodeInstruction inst in insts)
{
yield return inst;
if (!found && inst.operand == cellsShuffledField)
if (!found && inst.operand as MethodInfo == cellsShuffledField)
{
yield return new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(CellsShufflePatchShared), nameof(ShouldShuffle)));
yield return new CodeInstruction(OpCodes.Not);
Expand Down Expand Up @@ -266,7 +266,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
foreach (var inst in insts)
{
if (inst.operand == AccessTools.PropertyGetter(typeof(ModLister), nameof(ModLister.BiotechInstalled)))
if (inst.operand as MethodInfo == AccessTools.PropertyGetter(typeof(ModLister), nameof(ModLister.BiotechInstalled)))
inst.operand = AccessTools.PropertyGetter(typeof(ModsConfig), nameof(ModsConfig.BiotechActive));
yield return inst;
}
Expand Down Expand Up @@ -302,7 +302,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
foreach (var inst in insts)
{
// Remove mutation of battleActive during saving which was a source of non-determinism
if (inst.opcode == OpCodes.Stfld && inst.operand == battleActiveField)
if (inst.opcode == OpCodes.Stfld && inst.operand as MethodInfo == battleActiveField)
{
yield return new CodeInstruction(OpCodes.Pop);
yield return new CodeInstruction(OpCodes.Pop);
Expand Down Expand Up @@ -341,7 +341,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
foreach (var inst in insts)
{
if (inst.opcode == OpCodes.Stfld && inst.operand == queryTickField)
if (inst.opcode == OpCodes.Stfld && inst.operand as MethodInfo == queryTickField)
{
yield return new CodeInstruction(OpCodes.Ldarg_0);
yield return new CodeInstruction(OpCodes.Ldarg_1);
Expand Down Expand Up @@ -385,7 +385,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
foreach (var inst in insts)
{
if (inst.operand == clearMethod)
if (inst.operand as MethodInfo == clearMethod)
yield return new CodeInstruction(OpCodes.Pop);
else
yield return inst;
Expand Down
2 changes: 1 addition & 1 deletion Source/Client/Patches/Feedback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
foreach (var inst in insts)
{
if (inst.operand == IsSelected)
if (inst.operand as MethodInfo == IsSelected)
{
yield return new CodeInstruction(OpCodes.Ldarg_0);
yield return new CodeInstruction(OpCodes.Call, DeselectOnDespawnMethod);
Expand Down
2 changes: 1 addition & 1 deletion Source/Client/Patches/HashCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
foreach (var inst in insts)
{
if (inst.operand == Combine)
if (inst.operand as MethodInfo == Combine)
inst.operand = AccessTools.Method(typeof(PatchTargetInfoHashCodes), nameof(CombineHashes));

yield return inst;
Expand Down
2 changes: 1 addition & 1 deletion Source/Client/Patches/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
yield return inst;

if (inst.operand == FrameCountField)
if (inst.operand as MethodInfo == FrameCountField)
{
yield return new CodeInstruction(OpCodes.Ldarg_0);
yield return new CodeInstruction(OpCodes.Call, FrameCountReplacementMethod);
Expand Down
4 changes: 2 additions & 2 deletions Source/Client/Patches/Seeds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
foreach (CodeInstruction inst in insts)
{
if (inst.operand == Rot4GetRandom)
if (inst.operand as MethodInfo == Rot4GetRandom)
{
// Load newThing.thingIdNumber to the stack
yield return new CodeInstruction(OpCodes.Ldarg_0);
Expand All @@ -137,7 +137,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst

yield return inst;

if (inst.operand == Rot4GetRandom)
if (inst.operand as MethodInfo == Rot4GetRandom)
yield return new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Rand), nameof(Rand.PopState)));
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Client/Persistent/ISwitchToMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
{
foreach (var inst in insts)
{
if (inst.opcode == OpCodes.Ldfld && inst.operand == doCloseXField)
if (inst.opcode == OpCodes.Ldfld && inst.operand as MethodInfo == doCloseXField)
{
yield return new CodeInstruction(OpCodes.Ldarg_0); // This window
yield return new CodeInstruction(OpCodes.Ldloc_0); // Window rect
Expand Down
Loading
Loading