-
-
Notifications
You must be signed in to change notification settings - Fork 140
Standalone prepublish maintenance #877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,6 +81,7 @@ ipch/ | |
| *.opensdf | ||
| *.sdf | ||
| *.cachefile | ||
| *.lscache | ||
| *.VC.db | ||
| *.VC.VC.opendb | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,16 @@ public static class DesignatorPatches | |
| { | ||
| public static bool DesignateSingleCell(Designator __instance, IntVec3 __0) | ||
| { | ||
| if (!Multiplayer.InInterface) return true; | ||
| if (!Multiplayer.InInterface) | ||
| { | ||
| Log.WarningOnce( | ||
| "Multiplayer: blocked DesignateSingleCell because InInterface=false " + | ||
| $"designator={__instance.GetType().Name}, reloading={Multiplayer.reloading}, ticking={Multiplayer.Ticking}, " + | ||
| $"executingCmds={Multiplayer.ExecutingCmds}, simulating={TickPatch.Simulating}, frozen={TickPatch.Frozen}, " + | ||
| $"hasCurrentEvent={LongEventHandler.currentEvent != null}, programState={Current.ProgramState}", | ||
| 18000101); | ||
| return true; | ||
| } | ||
|
|
||
| Designator designator = __instance; | ||
|
|
||
|
|
@@ -44,7 +53,16 @@ public static bool DesignateSingleCell(Designator __instance, IntVec3 __0) | |
|
|
||
| public static bool DesignateMultiCell(Designator __instance, IEnumerable<IntVec3> __0) | ||
| { | ||
| if (!Multiplayer.InInterface) return true; | ||
| if (!Multiplayer.InInterface) | ||
| { | ||
| Log.WarningOnce( | ||
| "Multiplayer: blocked DesignateMultiCell because InInterface=false " + | ||
| $"designator={__instance.GetType().Name}, reloading={Multiplayer.reloading}, ticking={Multiplayer.Ticking}, " + | ||
| $"executingCmds={Multiplayer.ExecutingCmds}, simulating={TickPatch.Simulating}, frozen={TickPatch.Frozen}, " + | ||
| $"hasCurrentEvent={LongEventHandler.currentEvent != null}, programState={Current.ProgramState}", | ||
| 18000102); | ||
| return true; | ||
| } | ||
|
Comment on lines
+56
to
+65
|
||
|
|
||
| // No cells implies Finalize(false), which currently doesn't cause side effects | ||
| if (!__0.Any()) return true; | ||
|
|
@@ -70,7 +88,16 @@ public static bool DesignateMultiCell(Designator __instance, IEnumerable<IntVec3 | |
|
|
||
| public static bool DesignateThing(Designator __instance, Thing __0) | ||
| { | ||
| if (!Multiplayer.InInterface) return true; | ||
| if (!Multiplayer.InInterface) | ||
| { | ||
| Log.WarningOnce( | ||
| "Multiplayer: blocked DesignateThing because InInterface=false " + | ||
| $"designator={__instance.GetType().Name}, thing={__0}, reloading={Multiplayer.reloading}, ticking={Multiplayer.Ticking}, " + | ||
| $"executingCmds={Multiplayer.ExecutingCmds}, simulating={TickPatch.Simulating}, frozen={TickPatch.Frozen}, " + | ||
| $"hasCurrentEvent={LongEventHandler.currentEvent != null}, programState={Current.ProgramState}", | ||
| 18000103); | ||
| return true; | ||
| } | ||
|
Comment on lines
+91
to
+100
|
||
|
|
||
| Designator designator = __instance; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -248,7 +248,7 @@ static bool Prefix(ref AcceptanceReport __result) | |||||||
| } | ||||||||
|
|
||||||||
| // Not in a landing session, use vanilla logic for player control | ||||||||
| __result = Current.Game.PlayerHasControl; | ||||||||
| __result = true; | ||||||||
| return false; | ||||||||
|
Comment on lines
+251
to
252
|
||||||||
| __result = true; | |
| return false; | |
| return true; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| using System.IO; | ||
| using System.Linq; | ||
| using Multiplayer.Common; | ||
| using Multiplayer.Common.Networking.Packet; | ||
| using RimWorld; | ||
| using UnityEngine; | ||
| using Verse; | ||
|
|
@@ -14,8 +15,18 @@ public static void DoAutosave() | |
| { | ||
| LongEventHandler.QueueLongEvent(() => | ||
| { | ||
| SaveGameToFile_Overwrite(GetNextAutosaveFileName(), false); | ||
| Multiplayer.Client.Send(Packets.Client_Autosaving); | ||
| if (!SaveGameToFile_Overwrite(GetNextAutosaveFileName(), false)) | ||
| return; | ||
|
|
||
| Multiplayer.Client.Send(new ClientAutosavingPacket(JoinPointRequestReason.Save)); | ||
|
|
||
| // When connected to a standalone server, also upload fresh snapshots | ||
| if (Multiplayer.session?.ConnectedToStandaloneServer == true) | ||
| { | ||
| var snapshot = SaveLoad.CreateGameDataSnapshot(SaveLoad.SaveGameData(), false); | ||
| SaveLoad.SendStandaloneMapSnapshots(snapshot); | ||
| SaveLoad.SendStandaloneWorldSnapshot(snapshot); | ||
| } | ||
| }, "MpSaving", false, null); | ||
| } | ||
|
|
||
|
|
@@ -33,30 +44,37 @@ private static string GetNextAutosaveFileName() | |
| .First(); | ||
| } | ||
|
|
||
| public static void SaveGameToFile_Overwrite(string fileNameNoExtension, bool currentReplay) | ||
| public static bool SaveGameToFile_Overwrite(string fileNameNoExtension, bool currentReplay) | ||
| { | ||
| Log.Message($"Multiplayer: saving to file {fileNameNoExtension}"); | ||
|
|
||
| try | ||
| { | ||
| var tmp = new FileInfo(Path.Combine(Multiplayer.ReplaysDir, $"{fileNameNoExtension}.tmp.zip")); | ||
| Replay.ForSaving(tmp).WriteData( | ||
| var tmpPath = Path.Combine(Multiplayer.ReplaysDir, $"{fileNameNoExtension}.tmp.zip"); | ||
| if (File.Exists(tmpPath)) | ||
| File.Delete(tmpPath); | ||
|
|
||
| Replay.ForSaving(new FileInfo(tmpPath)).WriteData( | ||
| currentReplay ? | ||
| Multiplayer.session.dataSnapshot : | ||
| SaveLoad.CreateGameDataSnapshot(SaveLoad.SaveGameData(), false) | ||
| ); | ||
|
|
||
| var dst = new FileInfo(Path.Combine(Multiplayer.ReplaysDir, $"{fileNameNoExtension}.zip")); | ||
| if (!dst.Exists) dst.Open(FileMode.Create).Close(); | ||
| tmp.Replace(dst.FullName, null); | ||
| var dstPath = Path.Combine(Multiplayer.ReplaysDir, $"{fileNameNoExtension}.zip"); | ||
| if (File.Exists(dstPath)) | ||
| File.Delete(dstPath); | ||
|
|
||
| File.Move(tmpPath, dstPath); | ||
|
|
||
| Messages.Message("MpGameSaved".Translate(fileNameNoExtension), MessageTypeDefOf.SilentInput, false); | ||
| Multiplayer.session.lastSaveAt = Time.realtimeSinceStartup; | ||
| return true; | ||
| } | ||
| catch (Exception e) | ||
| { | ||
| Log.Error($"Exception saving multiplayer game as {fileNameNoExtension}: {e}"); | ||
| Messages.Message("MpGameSaveFailed".Translate(), MessageTypeDefOf.SilentInput, false); | ||
| return false; | ||
| } | ||
|
Comment on lines
+47
to
78
|
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warning message says the action was "blocked", but this prefix returns
true, which allows the originalDesignateSingleCellto run (i.e., it isn’t blocked). This is misleading when diagnosing desyncs.Either change the log text to reflect that sync interception was skipped (not blocked), or return
falseif the designator really should be blocked whenInInterfaceis false.