Skip to content
Closed
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
2 changes: 1 addition & 1 deletion Source/CombatExtended/Compatibility/Multiplayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Multiplayer : IPatch
public bool CanInstall()
{
Log.Message("Combat Extended :: Checking Multiplayer Compat");
return ModLister.HasActiveModWithName("Multiplayer");
return ModLister.HasActiveModWithName("Multiplayer") || ModLister.GetActiveModWithIdentifier("rwmt.Multiplayer") != null || ModLister.HasActiveModWithName("Multiplayer [Continuous]");
}

public void Install()
Expand Down
2 changes: 1 addition & 1 deletion Source/MultiplayerCompat/MultiplayerCompat.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@
<ItemGroup>
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.6.4543" GeneratePathProperty="true" />
<PackageReference Include="Lib.Harmony" Version="2.3.6" ExcludeAssets="runtime" />
<PackageReference Include="RimWorld.MultiplayerAPI" Version="0.4.0" />
<PackageReference Include="RimWorld.MultiplayerAPI" Version="0.6.0" />
</ItemGroup>
</Project>
26 changes: 12 additions & 14 deletions Source/MultiplayerCompat/MultiplayerCompat/MultiplayerCompat.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using Multiplayer.API;
Expand Down Expand Up @@ -62,19 +61,20 @@ public void SlowInit(ModContentPack content)
}
}

MP.RegisterAll();

MP.RegisterSyncWorker<CompAmmoUser>(SyncCompAmmoUser);
MP.RegisterSyncWorker<CompFireModes>(SyncCompFireMode);
MP.RegisterSyncWorker<Loadout>(SyncLoadout);
MP.RegisterSyncWorker<LoadoutSlot>(SyncLoadoutSlot);
MP.RegisterSyncWorker<ITab_Inventory>(SyncITab_Inventory, shouldConstruct: true);
global::CombatExtended.Compatibility.Multiplayer.registerCallbacks((() => MP.IsInMultiplayer), (() => MP.IsExecutingSyncCommand), (() => MP.IsExecutingSyncCommandIssuedBySelf));
}
#nullable enable



[SyncWorker]
private static void SyncCompAmmoUser(SyncWorker sync, ref CompAmmoUser comp)
private static void SyncCompAmmoUser(SyncWorker sync, ref CompAmmoUser? comp)
{
if (sync.isWriting)
{
var caster = comp.parent.GetComp<CompEquippable>().PrimaryVerb.Caster;
var caster = comp?.parent.GetComp<CompEquippable>().PrimaryVerb.Caster;

// Sync the turret because in that case syncing fails, due to comp.parent.Map being null,
// which causes it to be inaccessible in MP for general syncing
Expand Down Expand Up @@ -105,12 +105,11 @@ private static void SyncCompAmmoUser(SyncWorker sync, ref CompAmmoUser comp)
}
}

[SyncWorker]
private static void SyncCompFireMode(SyncWorker sync, ref CompFireModes comp)
private static void SyncCompFireMode(SyncWorker sync, ref CompFireModes? comp)
{
if (sync.isWriting)
{
var caster = comp.Caster;
var caster = comp?.Caster;

// Sync the turret because in that case syncing fails, due to comp.parent.Map being null,
// which causes it to be inaccessible in MP for general syncing
Expand Down Expand Up @@ -141,7 +140,6 @@ private static void SyncCompFireMode(SyncWorker sync, ref CompFireModes comp)
}
}

[SyncWorker]
private static void SyncLoadout(SyncWorker sync, ref Loadout loadout)
{
if (sync.isWriting)
Expand All @@ -155,7 +153,6 @@ private static void SyncLoadout(SyncWorker sync, ref Loadout loadout)
}
}

[SyncWorker]
private static void SyncLoadoutSlot(SyncWorker sync, ref LoadoutSlot loadoutSlot)
{
if (sync.isWriting)
Expand Down Expand Up @@ -198,7 +195,8 @@ private static void SyncLoadoutSlot(SyncWorker sync, ref LoadoutSlot loadoutSlot

// Don't sync anything, we just want a blank instance for method calling purposes
// We only care about shouldConstruct being true
[SyncWorker(shouldConstruct = true)]
private static void SyncITab_Inventory(SyncWorker sync, ref ITab_Inventory inventory)
{ }
}

#nullable restore
Loading