Skip to content

Commit 8681d22

Browse files
authored
Merge pull request #3 from rwmt/dev
Merge changes
2 parents 041086a + 8bb3e35 commit 8681d22

38 files changed

Lines changed: 805 additions & 422 deletions

.github/workflows/build-beta.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515
build:
1616
name: Build beta
1717
runs-on: ubuntu-latest
18+
env:
19+
GH_TOKEN: ${{ github.token }}
1820
steps:
1921
- name: Checkout Repository
2022
uses: actions/checkout@v4
@@ -32,14 +34,22 @@ jobs:
3234
- name: Build Mod
3335
run: dotnet build ${{ env.SLN_PATH }} --configuration Release --no-restore
3436

35-
- run: mkdir -p output/Multiplayer
36-
37-
- name: Move files
38-
run: mv About/ Assemblies/ AssembliesCustom/ Defs/ Languages/ Textures/ output/Multiplayer
37+
- name: Package files
38+
run: zip -r Multiplayer-beta.zip About/ Assemblies/ AssembliesCustom/ Defs/ Languages/ Textures/
3939

4040
- name: Upload Mod Artifacts
4141
uses: actions/upload-artifact@v4
4242
with:
4343
name: Multiplayer-beta
44-
path: |
45-
output/
44+
path: Multiplayer-beta.zip
45+
46+
- name: Clean up last release
47+
continue-on-error: true
48+
run: |
49+
gh release delete --cleanup-tag --yes "continuous"
50+
51+
- name: Upload new release
52+
run: |
53+
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"
54+
gh release upload "continuous" Multiplayer-beta.zip
55+
gh release edit "continuous" --draft=false

Source/.editorconfig

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
root = true
2-
2+
33
[*]
44
charset = utf-8
55
indent_style = space
66
indent_size = 2
77
insert_final_newline = true
88
trim_trailing_whitespace = true
9-
9+
1010
[*.{cs,js,ts,sql}]
1111
indent_size = 4
12-
end_of_line = crlf
12+
end_of_line = crlf
13+
14+
[*.cs]
15+
# The conflicting classes provided in this assembly are essentially polyfills
16+
# of .NET Core features to allow running on .NET Framework.
17+
dotnet_diagnostic.cs0436.severity = none

Source/Client/AsyncTime/AsyncTimePatches.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
178178
{
179179
foreach (var inst in insts)
180180
{
181-
if (inst.operand == AccessTools.PropertyGetter(typeof(Prefs), nameof(Prefs.AutomaticPauseMode)))
181+
if (inst.operand as MethodInfo == AccessTools.PropertyGetter(typeof(Prefs), nameof(Prefs.AutomaticPauseMode)))
182182
inst.operand = AccessTools.Method(typeof(ReceiveLetterPause), nameof(AutomaticPauseMode));
183-
else if (inst.operand == AccessTools.Method(typeof(TickManager), nameof(TickManager.Pause)))
183+
else if (inst.operand as MethodInfo == AccessTools.Method(typeof(TickManager), nameof(TickManager.Pause)))
184184
inst.operand = AccessTools.Method(typeof(ReceiveLetterPause), nameof(PauseOnLetter));
185185

186186
yield return inst;
@@ -190,7 +190,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
190190
private static AutomaticPauseMode AutomaticPauseMode()
191191
{
192192
return Multiplayer.Client != null
193-
? (AutomaticPauseMode) Multiplayer.GameComp.pauseOnLetter
193+
? (AutomaticPauseMode)Multiplayer.GameComp.pauseOnLetter
194194
: Prefs.AutomaticPauseMode;
195195
}
196196

Source/Client/AsyncTime/TimeControlUI.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using System.Linq;
3+
using System.Reflection;
34
using System.Reflection.Emit;
45
using HarmonyLib;
56
using Multiplayer.Client.Util;
@@ -36,12 +37,12 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
3637
{
3738
foreach (var inst in insts)
3839
{
39-
if (inst.operand == AccessTools.Method(typeof(TimeControls), nameof(TimeControls.DoTimeControlsGUI)))
40+
if (inst.operand as MethodInfo == AccessTools.Method(typeof(TimeControls), nameof(TimeControls.DoTimeControlsGUI)))
4041
inst.operand = AccessTools.Method(typeof(TimeControlPatch), nameof(DoTimeControlsGUI));
4142

4243
yield return inst;
4344

44-
if (inst.operand == AccessTools.Constructor(typeof(Rect),
45+
if (inst.operand as MethodInfo == AccessTools.Constructor(typeof(Rect),
4546
new[] { typeof(float), typeof(float), typeof(float), typeof(float) }))
4647
{
4748
yield return new CodeInstruction(OpCodes.Ldloca_S, 1);
@@ -360,7 +361,7 @@ static void DrawButtons()
360361
}
361362
else
362363
{
363-
// There is a new blocking pause
364+
// There is a new blocking pause
364365
flashDict.Add(flashPos, Time.time);
365366
}
366367
}
@@ -416,7 +417,7 @@ static void DrawPauseFlash(Vector2 pos)
416417
// Only flash at flashInterval from the time the blocking pause began
417418
if (pauseDuration > 0f && pauseDuration % flashInterval < 1f)
418419
{
419-
GenUI.DrawFlash(pos.x, pos.y, UI.screenWidth * 0.6f, Pulser.PulseBrightness(1f, 1f, pauseDuration) * 0.4f, flashColor);
420+
GenUI.DrawFlash(pos.x, pos.y, UI.screenWidth * 0.6f, Pulser.PulseBrightness(1f, 1f, pauseDuration) * 0.4f, flashColor);
420421
}
421422
}
422423
}

Source/Client/Debug/DebugPatches.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
9090
{
9191
foreach (var inst in insts)
9292
{
93-
if (inst.operand == GizmoOnGUI)
93+
if (inst.operand as MethodInfo == GizmoOnGUI)
9494
yield return new CodeInstruction(OpCodes.Call,
9595
AccessTools.Method(typeof(GizmoDrawDebugInfo), nameof(GizmoOnGUIProxy)));
96-
else if (inst.operand == GizmoOnGUIShrunk)
96+
else if (inst.operand as MethodInfo == GizmoOnGUIShrunk)
9797
yield return new CodeInstruction(OpCodes.Call,
9898
AccessTools.Method(typeof(GizmoDrawDebugInfo), nameof(GizmoOnGUIShrunkProxy)));
9999
else

Source/Client/Factions/Blueprints.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> e, M
3030

3131
yield return cur;
3232

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

@@ -103,7 +103,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> e, M
103103
new CodeInstruction(OpCodes.Call, CanPlaceBlueprintAtPatch.ShouldIgnore1Method),
104104
new CodeInstruction(OpCodes.Brtrue, insts[loop + 1].operand)
105105
);
106-
106+
107107
return insts;
108108
}
109109
}
@@ -173,7 +173,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
173173
{
174174
yield return inst;
175175

176-
if (inst.opcode == OpCodes.Call && inst.operand == SpawningWipes)
176+
if (inst.opcode == OpCodes.Call && inst.operand as MethodInfo == SpawningWipes)
177177
{
178178
yield return new CodeInstruction(OpCodes.Ldarg_2);
179179
yield return new CodeInstruction(OpCodes.Ldloc_3);
@@ -196,7 +196,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
196196
{
197197
yield return inst;
198198

199-
if (inst.opcode == OpCodes.Call && inst.operand == SpawningWipes)
199+
if (inst.opcode == OpCodes.Call && inst.operand as MethodInfo == SpawningWipes)
200200
{
201201
yield return new CodeInstruction(OpCodes.Ldarg_2);
202202
yield return new CodeInstruction(OpCodes.Ldloc_S, 4);
@@ -221,7 +221,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
221221
{
222222
yield return inst;
223223

224-
if (inst.opcode == OpCodes.Call && inst.operand == SpawningWipes)
224+
if (inst.opcode == OpCodes.Call && inst.operand as MethodInfo == SpawningWipes)
225225
{
226226
yield return new CodeInstruction(OpCodes.Ldarg_0);
227227
yield return new CodeInstruction(OpCodes.Ldfld, ThingDefField);
@@ -335,7 +335,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
335335
{
336336
yield return inst;
337337

338-
if (inst.opcode == OpCodes.Isinst && inst.operand == typeof(Blueprint))
338+
if (inst.opcode == OpCodes.Isinst && inst.operand as MethodInfo == typeof(Blueprint))
339339
{
340340
yield return new CodeInstruction(OpCodes.Ldnull);
341341
yield return new CodeInstruction(OpCodes.Cgt_Un);

Source/Client/Factions/MultifactionPatches.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static bool Prefix(Quest quest, ref bool __result)
5050
if (quest.TryGetPlayerFaction(out playerFaction) && playerFaction != Faction.OfPlayer)
5151
{
5252
__result = false;
53-
return false;
53+
return false;
5454
}
5555
}
5656
return true;
@@ -82,8 +82,8 @@ static class WorldInspectPanePaneTopYPatch
8282
{
8383
static void Postfix(ref float __result)
8484
{
85-
if (Multiplayer.Client != null && Multiplayer.RealPlayerFaction == Multiplayer.WorldComp.spectatorFaction)
86-
__result += 35f;
85+
if (Multiplayer.Client != null && Multiplayer.RealPlayerFaction == Multiplayer.WorldComp.spectatorFaction)
86+
__result += 35f;
8787
}
8888
}
8989

@@ -198,21 +198,21 @@ static class MainButtonsRootDoButtonsPatch
198198
private static bool ReplaceOriginalDrawing(MainButtonsRoot __instance)
199199
{
200200
if (!IsSpectator)
201-
return true;
201+
return true;
202202

203203
try
204204
{
205205
var allButtons = AllButtonsRef(__instance);
206206
if (allButtons == null)
207-
return true;
207+
return true;
208208

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

214214
DrawCornerButtons(toDraw);
215-
return false;
215+
return false;
216216
}
217217
catch (Exception ex)
218218
{
@@ -421,7 +421,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
421421
{
422422
yield return inst;
423423

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

443443
foreach (var inst in insts)
444444
{
445-
if (inst.operand == isPlayerMethodGetter)
445+
if (inst.operand as MethodInfo == isPlayerMethodGetter)
446446
inst.operand = factionIsPlayer.Method;
447447

448448
yield return inst;
@@ -464,7 +464,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
464464
{
465465
foreach (var inst in insts)
466466
{
467-
if (inst.operand == allColonists)
467+
if (inst.operand as MethodInfo == allColonists)
468468
inst.operand = AccessTools.Method(typeof(RecacheColonistBelieverCountPatch), nameof(ColonistsAllPlayerFactions));
469469
yield return inst;
470470
}
@@ -516,7 +516,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
516516
{
517517
foreach (var inst in insts)
518518
{
519-
if (inst.operand == isColonyMech)
519+
if (inst.operand as MethodInfo == isColonyMech)
520520
inst.operand = AccessTools.Method(typeof(RecacheColonistBelieverCountPatch), nameof(RecacheColonistBelieverCountPatch.IsColonyMechAnyFaction));
521521

522522
yield return inst;
@@ -557,10 +557,10 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
557557
{
558558
foreach (var inst in insts)
559559
{
560-
if (inst.operand == isColonist)
560+
if (inst.operand as MethodInfo == isColonist)
561561
inst.operand = AccessTools.Method(typeof(RecacheColonistBelieverCountPatch), nameof(RecacheColonistBelieverCountPatch.IsColonistAnyFaction));
562562

563-
if (inst.operand == isColonySubhuman)
563+
if (inst.operand as MethodInfo == isColonySubhuman)
564564
inst.operand = AccessTools.Method(typeof(RecacheColonistBelieverCountPatch), nameof(RecacheColonistBelieverCountPatch.IsColonySubhumanAnyFaction));
565565

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

583583
yield return inst;
@@ -632,7 +632,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
632632
{
633633
foreach (var inst in insts)
634634
{
635-
if (inst.operand == PlayOneShotOnCamera)
635+
if (inst.operand as MethodInfo == PlayOneShotOnCamera)
636636
yield return new CodeInstruction(
637637
OpCodes.Call,
638638
SymbolExtensions.GetMethodInfo((SoundDef s, Map m) => PlaySoundReplacement(s, m)));
@@ -661,7 +661,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
661661

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

723723
// Don't draw the ideo plate while choosing starting pawns in multifaction
724-
if (inst.operand == classicModeField)
724+
if (inst.operand as MethodInfo == classicModeField)
725725
{
726726
yield return new CodeInstruction(OpCodes.Ldarg_2);
727727
yield return new CodeInstruction(OpCodes.Call,

Source/Client/Multiplayer.csproj

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>net48</TargetFramework>
@@ -59,16 +59,21 @@
5959
</PropertyGroup>
6060
</Target>
6161

62+
63+
<PropertyGroup>
64+
<ModOutputPath>..\..\</ModOutputPath>
65+
</PropertyGroup>
66+
6267
<Target Name="CopyToRimworld" AfterTargets="Build">
63-
<Copy SourceFiles="bin\Multiplayer.dll" DestinationFiles="..\..\AssembliesCustom\Multiplayer.dll" />
64-
<Copy SourceFiles="bin\MultiplayerCommon.dll" DestinationFiles="..\..\AssembliesCustom\MultiplayerCommon.dll" />
68+
<Copy SourceFiles="bin\Multiplayer.dll" DestinationFiles="$(ModOutputPath)\AssembliesCustom\Multiplayer.dll" />
69+
<Copy SourceFiles="bin\MultiplayerCommon.dll" DestinationFiles="$(ModOutputPath)\AssembliesCustom\MultiplayerCommon.dll" />
6570

66-
<Copy SourceFiles="bin\0MultiplayerAPI.dll" DestinationFiles="..\..\Assemblies\0MultiplayerAPI.dll" />
67-
<Copy SourceFiles="bin\0PrepatcherAPI.dll" DestinationFiles="..\..\Assemblies\0PrepatcherAPI.dll" />
68-
<Copy SourceFiles="bin\LiteNetLib.dll" DestinationFiles="..\..\Assemblies\LiteNetLib.dll" />
69-
<Copy SourceFiles="bin\MultiplayerLoader.dll" DestinationFiles="..\..\Assemblies\MultiplayerLoader.dll" />
70-
<Copy SourceFiles="bin\RestSharp.dll" DestinationFiles="..\..\Assemblies\RestSharp.dll" />
71-
<Copy SourceFiles="bin\System.IO.Compression.dll" DestinationFiles="..\..\Assemblies\System.IO.Compression.dll" />
71+
<Copy SourceFiles="bin\0MultiplayerAPI.dll" DestinationFiles="$(ModOutputPath)\Assemblies\0MultiplayerAPI.dll" />
72+
<Copy SourceFiles="bin\0PrepatcherAPI.dll" DestinationFiles="$(ModOutputPath)\Assemblies\0PrepatcherAPI.dll" />
73+
<Copy SourceFiles="bin\LiteNetLib.dll" DestinationFiles="$(ModOutputPath)\Assemblies\LiteNetLib.dll" />
74+
<Copy SourceFiles="bin\MultiplayerLoader.dll" DestinationFiles="$(ModOutputPath)\Assemblies\MultiplayerLoader.dll" />
75+
<Copy SourceFiles="bin\RestSharp.dll" DestinationFiles="$(ModOutputPath)\Assemblies\RestSharp.dll" />
76+
<Copy SourceFiles="bin\System.IO.Compression.dll" DestinationFiles="$(ModOutputPath)\Assemblies\System.IO.Compression.dll" />
7277
</Target>
7378

7479
</Project>

Source/Client/Networking/NetworkingSteam.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,10 @@ public override string ToString()
5353
}
5454
}
5555

56-
public class SteamClientConn : SteamBaseConn
56+
public class SteamClientConn(CSteamID remoteId) : SteamBaseConn(remoteId, RandomChannelId(), 0)
5757
{
5858
static ushort RandomChannelId() => (ushort)new Random().Next();
5959

60-
public SteamClientConn(CSteamID remoteId) : base(remoteId, RandomChannelId(), 0)
61-
{
62-
}
63-
6460
protected override void HandleReceiveMsg(int msgId, int fragState, ByteReader reader, bool reliable)
6561
{
6662
if (msgId == (int)Packets.Special_Steam_Disconnect)
@@ -91,12 +87,8 @@ private void OnDisconnect()
9187
}
9288
}
9389

94-
public class SteamServerConn : SteamBaseConn
90+
public class SteamServerConn(CSteamID remoteId, ushort clientChannel) : SteamBaseConn(remoteId, 0, clientChannel)
9591
{
96-
public SteamServerConn(CSteamID remoteId, ushort clientChannel) : base(remoteId, 0, clientChannel)
97-
{
98-
}
99-
10092
protected override void HandleReceiveMsg(int msgId, int fragState, ByteReader reader, bool reliable)
10193
{
10294
if (msgId == (int)Packets.Special_Steam_Disconnect)

0 commit comments

Comments
 (0)