Autosave serializes the world straight to UTF-8 bytes (shorter stall of the network loop)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nico Meister
2026-10-05 16:31:57 +02:00
co-authored by Claude Opus 5.5
parent 6e2ef3b570
commit 7d2ce98f1e
+3 -1
View File
@@ -62,7 +62,9 @@ public sealed class WorldState
public void Save(string path) public void Save(string path)
{ {
string tmp = path + ".tmp"; string tmp = path + ".tmp";
File.WriteAllText(tmp, JsonSerializer.Serialize(this, Options)); // Direkt als UTF-8-Bytes: läuft im Netzwerk-Takt (Autosave) - ohne den Umweg über einen großen String und die
// zweite Umwandlung beim Schreiben steht der Server dabei kürzer (gleiche Datei: UTF-8 ohne BOM)
File.WriteAllBytes(tmp, JsonSerializer.SerializeToUtf8Bytes(this, Options));
File.Move(tmp, path, true); File.Move(tmp, path, true);
Dirty = false; Dirty = false;
} }