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
22 changes: 16 additions & 6 deletions .github/workflows/build-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
build:
name: Build beta
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -32,14 +34,22 @@ jobs:
- name: Build Mod
run: dotnet build ${{ env.SLN_PATH }} --configuration Release --no-restore

- run: mkdir -p output/Multiplayer

- name: Move files
run: mv About/ Assemblies/ AssembliesCustom/ Defs/ Languages/ Textures/ output/Multiplayer
- name: Package files
run: zip -r Multiplayer-beta.zip About/ Assemblies/ AssembliesCustom/ Defs/ Languages/ Textures/

- name: Upload Mod Artifacts
uses: actions/upload-artifact@v4
with:
name: Multiplayer-beta
path: |
output/
path: Multiplayer-beta.zip

- name: Clean up last release
continue-on-error: true
run: |
gh release delete --cleanup-tag --yes "continuous"

- name: Upload new release
run: |
gh release create --target "${{ github.sha }}" --title "Continuous" --notes "This 'alpha' release is an automatically generated snapshot of the current state of development. It is continuously updated with work-in-progress changes that may be broken, incomplete, or incompatible." --draft "continuous"
gh release upload "continuous" Multiplayer-beta.zip
gh release edit "continuous" --draft=false
11 changes: 8 additions & 3 deletions Source/.editorconfig
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.{cs,js,ts,sql}]
indent_size = 4
end_of_line = crlf
end_of_line = crlf

[*.cs]
# The conflicting classes provided in this assembly are essentially polyfills
# of .NET Core features to allow running on .NET Framework.
dotnet_diagnostic.cs0436.severity = none
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
23 changes: 14 additions & 9 deletions Source/Client/Multiplayer.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net48</TargetFramework>
Expand Down Expand Up @@ -59,16 +59,21 @@
</PropertyGroup>
</Target>


<PropertyGroup>
<ModOutputPath>..\..\</ModOutputPath>
</PropertyGroup>

<Target Name="CopyToRimworld" AfterTargets="Build">
<Copy SourceFiles="bin\Multiplayer.dll" DestinationFiles="..\..\AssembliesCustom\Multiplayer.dll" />
<Copy SourceFiles="bin\MultiplayerCommon.dll" DestinationFiles="..\..\AssembliesCustom\MultiplayerCommon.dll" />
<Copy SourceFiles="bin\Multiplayer.dll" DestinationFiles="$(ModOutputPath)\AssembliesCustom\Multiplayer.dll" />
<Copy SourceFiles="bin\MultiplayerCommon.dll" DestinationFiles="$(ModOutputPath)\AssembliesCustom\MultiplayerCommon.dll" />

<Copy SourceFiles="bin\0MultiplayerAPI.dll" DestinationFiles="..\..\Assemblies\0MultiplayerAPI.dll" />
<Copy SourceFiles="bin\0PrepatcherAPI.dll" DestinationFiles="..\..\Assemblies\0PrepatcherAPI.dll" />
<Copy SourceFiles="bin\LiteNetLib.dll" DestinationFiles="..\..\Assemblies\LiteNetLib.dll" />
<Copy SourceFiles="bin\MultiplayerLoader.dll" DestinationFiles="..\..\Assemblies\MultiplayerLoader.dll" />
<Copy SourceFiles="bin\RestSharp.dll" DestinationFiles="..\..\Assemblies\RestSharp.dll" />
<Copy SourceFiles="bin\System.IO.Compression.dll" DestinationFiles="..\..\Assemblies\System.IO.Compression.dll" />
<Copy SourceFiles="bin\0MultiplayerAPI.dll" DestinationFiles="$(ModOutputPath)\Assemblies\0MultiplayerAPI.dll" />
<Copy SourceFiles="bin\0PrepatcherAPI.dll" DestinationFiles="$(ModOutputPath)\Assemblies\0PrepatcherAPI.dll" />
<Copy SourceFiles="bin\LiteNetLib.dll" DestinationFiles="$(ModOutputPath)\Assemblies\LiteNetLib.dll" />
<Copy SourceFiles="bin\MultiplayerLoader.dll" DestinationFiles="$(ModOutputPath)\Assemblies\MultiplayerLoader.dll" />
<Copy SourceFiles="bin\RestSharp.dll" DestinationFiles="$(ModOutputPath)\Assemblies\RestSharp.dll" />
<Copy SourceFiles="bin\System.IO.Compression.dll" DestinationFiles="$(ModOutputPath)\Assemblies\System.IO.Compression.dll" />
</Target>

</Project>
12 changes: 2 additions & 10 deletions Source/Client/Networking/NetworkingSteam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,10 @@ public override string ToString()
}
}

public class SteamClientConn : SteamBaseConn
public class SteamClientConn(CSteamID remoteId) : SteamBaseConn(remoteId, RandomChannelId(), 0)
{
static ushort RandomChannelId() => (ushort)new Random().Next();

public SteamClientConn(CSteamID remoteId) : base(remoteId, RandomChannelId(), 0)
{
}

protected override void HandleReceiveMsg(int msgId, int fragState, ByteReader reader, bool reliable)
{
if (msgId == (int)Packets.Special_Steam_Disconnect)
Expand Down Expand Up @@ -91,12 +87,8 @@ private void OnDisconnect()
}
}

public class SteamServerConn : SteamBaseConn
public class SteamServerConn(CSteamID remoteId, ushort clientChannel) : SteamBaseConn(remoteId, 0, clientChannel)
{
public SteamServerConn(CSteamID remoteId, ushort clientChannel) : base(remoteId, 0, clientChannel)
{
}

protected override void HandleReceiveMsg(int msgId, int fragState, ByteReader reader, bool reliable)
{
if (msgId == (int)Packets.Special_Steam_Disconnect)
Expand Down
Loading
Loading