Skip to content

Commit

Permalink
1.5 Update part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
notfood committed Apr 12, 2024
1 parent 533f281 commit 51c9e11
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 54 deletions.
4 changes: 2 additions & 2 deletions About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<ModMetaData>
<packageId>rwmt.MultiplayerCompatibility</packageId>
<name>Multiplayer Compatibility</name>
<author>notfood</author>
<author>RimWorld Multiplayer Team</author>
<supportedVersions>
<li>1.4</li>
<li>1.5</li>
</supportedVersions>
<description>Miscellaneous patches to make Multiplayer work
Mod Support:
Expand Down
3 changes: 2 additions & 1 deletion Source/DebugActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using HarmonyLib;
using RimWorld;
using RimWorld.Planet;
using LudeonTK;
using UnityEngine;
using Verse;
using Random = System.Random;
Expand Down Expand Up @@ -456,4 +457,4 @@ private static bool IsOverrideOfAny(MethodInfo method, HashSet<MethodInfo> possi

#endregion
}
}
}
2 changes: 1 addition & 1 deletion Source/Mods/BiotechExpansionMythic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private static void LatePatch()
{
foreach (var typeName in new[] { "BTE_MY.GeneGizmo_ResourceAurum", "BTE_MY.GeneGizmo_ResourceReverence" })
{
MpCompat.harmony.Patch(AccessTools.DeclaredMethod($"{typeName}:{nameof(GeneGizmo_Resource.DrawLabel)}"),
MpCompat.harmony.Patch(AccessTools.DeclaredMethod($"{typeName}:{nameof(GeneGizmo_Resource.DrawHeader)}"),
prefix: new HarmonyMethod(typeof(BiotechExpansionMythic), nameof(PreDrawLabel)));
}
}
Expand Down
6 changes: 3 additions & 3 deletions Source/Mods/RimFridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public RimFridgeCompat(ModContentPack mod)
dialogType = AccessTools.TypeByName("RimFridge.Dialog_RenameFridge");
fridgeField = AccessTools.FieldRefAccess<ThingComp>(dialogType, "fridge");

MP.RegisterSyncWorker<Dialog_Rename>(SyncFridgeName, dialogType);
MP.RegisterSyncWorker<object>(SyncFridgeName, dialogType);
MP.RegisterSyncMethod(dialogType, "SetName");
}

Expand All @@ -36,13 +36,13 @@ public RimFridgeCompat(ModContentPack mod)
}
}

private static void SyncFridgeName(SyncWorker sync, ref Dialog_Rename dialog)
private static void SyncFridgeName(SyncWorker sync, ref object dialog)
{
if (sync.isWriting)
sync.Write(fridgeField(dialog));
else
{
dialog = (Dialog_Rename)FormatterServices.GetUninitializedObject(dialogType);
dialog = FormatterServices.GetUninitializedObject(dialogType);
fridgeField(dialog) = sync.Read<ThingComp>();
}
}
Expand Down
12 changes: 6 additions & 6 deletions Source/Mods/SignsAndComments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ namespace Multiplayer.Compat
public class SignsAndComments
{
private static ConstructorInfo renameSignDialogCtor;
private static AccessTools.FieldRef<Dialog_Rename, Color> dialogColorField;
private static AccessTools.FieldRef<Dialog_Rename, ThingComp> dialogSignCompField;
private static AccessTools.FieldRef<object, Color> dialogColorField;
private static AccessTools.FieldRef<object, ThingComp> dialogSignCompField;

public SignsAndComments(ModContentPack mod)
{
Expand All @@ -33,11 +33,11 @@ public SignsAndComments(ModContentPack mod)
dialogColorField = AccessTools.FieldRefAccess<Color>(renameDialogType, "curColor");
dialogSignCompField = AccessTools.FieldRefAccess<ThingComp>(renameDialogType, "signComp");

MP.RegisterSyncMethod(renameDialogType, nameof(Dialog_Rename.SetName));
MP.RegisterSyncWorker<Dialog_Rename>(SyncRenameSignDialog, renameDialogType);
MP.RegisterSyncMethod(renameDialogType, nameof(IRenameable.RenamableLabel));
MP.RegisterSyncWorker<object>(SyncRenameSignDialog, renameDialogType);
}

private static void SyncRenameSignDialog(SyncWorker sync, ref Dialog_Rename dialog)
private static void SyncRenameSignDialog(SyncWorker sync, ref object dialog)
{
if (sync.isWriting)
{
Expand All @@ -49,7 +49,7 @@ private static void SyncRenameSignDialog(SyncWorker sync, ref Dialog_Rename dial
var comp = sync.Read<ThingComp>();
var color = sync.Read<Color>();

dialog = (Dialog_Rename)renameSignDialogCtor.Invoke(new object[] { comp });
dialog = renameSignDialogCtor.Invoke(new object[] { comp });
dialogColorField(dialog) = color;
}
}
Expand Down
31 changes: 0 additions & 31 deletions Source/Mods/VanillaExpandedFramework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1214,37 +1214,6 @@ private static void PatchDoorTeleporter()
renameDoorTeleporterDialogThingField = AccessTools.FieldRefAccess<ThingWithComps>(renameDoorTeleporterDialogType, "DoorTeleporter");

PatchingUtilities.PatchPushPopRand(renameDoorTeleporterDialogConstructor);
MP.RegisterSyncWorker<Dialog_Rename>(SyncDialogRenameDoorTeleporter, renameDoorTeleporterDialogType);
MP.RegisterSyncMethod(renameDoorTeleporterDialogType, nameof(Dialog_Rename.SetName))
// Since we sync the "SetName" method and nothing else, it'll leave the dialog open for
// players who didn't click the button to rename it - we need to manually close it.
.SetPostInvoke((dialog, _) =>
{
if (dialog is Window w)
Find.WindowStack.TryRemove(w);
});
}

private static void SyncDialogRenameDoorTeleporter(SyncWorker sync, ref Dialog_Rename dialog)
{
if (sync.isWriting)
{
sync.Write(renameDoorTeleporterDialogThingField(dialog));
sync.Write(dialog.curName);
}
else
{
var doorTeleporter = sync.Read<ThingWithComps>();
var name = sync.Read<string>();

// The dialog may be already open
dialog = Find.WindowStack.Windows.FirstOrDefault(x => x.GetType() == renameDoorTeleporterDialogType) as Dialog_Rename;
// If the dialog is not open, or the open dialog is for a different door - create a new dialog instead
if (dialog == null || renameDoorTeleporterDialogThingField(dialog) != doorTeleporter)
dialog = (Dialog_Rename)renameDoorTeleporterDialogConstructor.Invoke(new object[] { doorTeleporter });

dialog.curName = name;
}
}

#endregion
Expand Down
6 changes: 3 additions & 3 deletions Source/Multiplayer_Compat.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@

<ItemGroup>
<PackageReference Include="Lib.Harmony">
<Version>2.2.*</Version>
<Version>2.3.*</Version>
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="RimWorld.MultiplayerAPI">
<Version>0.5.0</Version>
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Krafs.Rimworld.Ref">
<Version>1.4.*</Version>
<Version>1.5.*</Version>
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Krafs.Publicizer">
<Version>1.0.*</Version>
<Version>2.2.*</Version>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions Source_Referenced/Multiplayer_Compat_Referenced.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
<Private>false</Private>
</ProjectReference>
<PackageReference Include="Lib.Harmony">
<Version>2.2.*</Version>
<Version>2.3.*</Version>
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="RimWorld.MultiplayerAPI">
<Version>0.5.0</Version>
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Krafs.Rimworld.Ref">
<Version>1.4.*</Version>
<Version>1.5.*</Version>
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Krafs.Publicizer">
<Version>1.0.*</Version>
<Version>2.2.*</Version>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<Reference Include="..\References\*.dll">
Expand Down
4 changes: 0 additions & 4 deletions release_bundler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

set -e

cd Source
dotnet build -c Release
cd ../Source_Referenced
dotnet build -c Release
cd ..

rm -rf Multiplayer-Compatibility/
mkdir -p Multiplayer-Compatibility
Expand Down

0 comments on commit 51c9e11

Please sign in to comment.