Skip to content
Open
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/Client/AsyncTime/AsyncWorldTimeComp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public void ExecuteCmd(ScheduledCommand cmd)

private static void CreateJoinPointAndSendIfHost()
{
Multiplayer.session.dataSnapshot = SaveLoad.CreateGameDataSnapshot(SaveLoad.SaveAndReload(true), Multiplayer.GameComp.multifaction);
Multiplayer.session.dataSnapshot = SaveLoad.CreateGameDataSnapshot(SaveLoad.SaveAndReload(), Multiplayer.GameComp.multifaction);

if (!TickPatch.Simulating && !Multiplayer.IsReplay)
{
Expand Down
29 changes: 10 additions & 19 deletions Source/Client/Saving/SaveLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ public record TempGameData(XmlDocument SaveData, byte[] SessionData);

public static class SaveLoad
{
public static TempGameData SaveAndReload(bool cache = false)
public static TempGameData SaveAndReload()
{
Multiplayer.reloading = true;

var worldGridSaved = Find.WorldGrid;
var tweenedPos = new Dictionary<int, Vector3>();
var drawers = new Dictionary<int, MapDrawer>();
var localFactionId = Multiplayer.RealPlayerFaction.loadID;
var mapCmds = new Dictionary<int, Queue<ScheduledCommand>>();
var planetRenderMode = Find.World.renderer.wantedMode;
Expand All @@ -37,8 +35,6 @@ public static TempGameData SaveAndReload(bool cache = false)

foreach (Map map in Find.Maps)
{
drawers[map.uniqueID] = map.mapDrawer;

foreach (Pawn p in map.mapPawns.AllPawnsSpawned)
tweenedPos[p.thingIDNumber] = p.drawer.tweener.tweenedPos;

Expand All @@ -58,20 +54,15 @@ public static TempGameData SaveAndReload(bool cache = false)
gameData = SaveGameData();
}

if (cache)
{
MapDrawerRegenPatch.copyFrom = drawers;
WorldGridCachePatch.copyFrom = worldGridSaved;
WorldGridExposeDataPatch.copyFrom = worldGridSaved;
WorldRendererCachePatch.copyFrom = worldGridSaved;
}
else
{
MapDrawerRegenPatch.copyFrom.Clear();
WorldGridCachePatch.copyFrom = null;
WorldGridExposeDataPatch.copyFrom = null;
WorldRendererCachePatch.copyFrom = null;
}
// Join-point live caches stay disabled here.
// Reusing render/world objects across reload proved unstable, while the measured gain
// was only about half a second, which is not enough to justify the risk.
// We still clear/null the static holders instead of commenting them out so stale state
// cannot survive if another path ever arms these cache fields again.
MapDrawerRegenPatch.copyFrom.Clear();
WorldGridCachePatch.copyFrom = null;
WorldGridExposeDataPatch.copyFrom = null;
WorldRendererCachePatch.copyFrom = null;

MusicManagerPlay musicManager = null;
if (Find.MusicManagerPlay.gameObjectCreated)
Expand Down
Loading