Skip to content

Commit

Permalink
Version 0.10.1, always reload as spectator faction
Browse files Browse the repository at this point in the history
  • Loading branch information
Zetrith committed Apr 13, 2024
1 parent aea566f commit 81fd504
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
5 changes: 3 additions & 2 deletions Source/Client/MultiplayerGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void ChangeRealPlayerFaction(int newFaction)
ChangeRealPlayerFaction(Find.FactionManager.GetById(newFaction));
}

public void ChangeRealPlayerFaction(Faction newFaction)
public void ChangeRealPlayerFaction(Faction newFaction, bool regenMapDrawers = true)
{
Log.Message($"Changing real player faction to {newFaction} from {myFaction}");

Expand All @@ -136,7 +136,8 @@ public void ChangeRealPlayerFaction(Faction newFaction)

foreach (Map m in Find.Maps)
{
m.mapDrawer.RegenerateEverythingNow();
if (regenMapDrawers)
m.mapDrawer.RegenerateEverythingNow();

foreach (var t in m.listerThings.AllThings)
if (t is ThingWithComps tc)
Expand Down
12 changes: 9 additions & 3 deletions Source/Client/Saving/SaveLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Threading;
using System.Xml;
using Multiplayer.Client.Saving;
using Multiplayer.Client.Util;
using UnityEngine;
using Verse;
using Verse.Profile;
Expand Down Expand Up @@ -45,9 +46,14 @@ public static TempGameData SaveAndReload()

mapCmds[ScheduledCommand.Global] = Multiplayer.AsyncWorldTime.cmds;

DeepProfiler.Start("Multiplayer SaveAndReload: Save");
var gameData = SaveGameData();
DeepProfiler.End();
TempGameData gameData;
using (DeepProfilerWrapper.Section("Multiplayer SaveAndReload: Save"))
{
// When reloading in multifaction always save as the spectator faction to ensure determinism
if (Multiplayer.GameComp.multifaction)
Multiplayer.game.ChangeRealPlayerFaction(Multiplayer.WorldComp.spectatorFaction, false);
gameData = SaveGameData();
}

MapDrawerRegenPatch.copyFrom = drawers;
WorldGridCachePatch.copyFrom = worldGridSaved;
Expand Down
4 changes: 3 additions & 1 deletion Source/Client/Syncing/ImplSerialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public static void Init()
Multiplayer.serialization.AddExplicitImplType(typeof(IThingHolder));
Multiplayer.serialization.AddExplicitImplType(typeof(IReloadableComp));
Multiplayer.serialization.AddExplicitImplType(typeof(Policy));
Multiplayer.serialization.AddExplicitImplType(typeof(PawnRoleSelectionWidgetBase<ILordJobRole>));

// todo for 1.5
// Multiplayer.serialization.AddExplicitImplType(typeof(PawnRoleSelectionWidgetBase<ILordJobRole>));
}
}
4 changes: 2 additions & 2 deletions Source/Common/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ namespace Multiplayer.Common
{
public static class MpVersion
{
public const string Version = "0.10";
public const int Protocol = 42;
public const string Version = "0.10.1";
public const int Protocol = 43;

public const string ApiAssemblyName = "0MultiplayerAPI";

Expand Down

0 comments on commit 81fd504

Please sign in to comment.