Server 2.10.2: warn when an uploaded save has no items.txt
Bought parts (oil filter, spark plugs, fan belt, battery ...) and whether they are installed are stored in items.txt. Without it they are missing on the car - e.g. the finished Satsuma of a downloaded save loses oil on the server (in singleplayer an old local items.txt hides the problem). The upload result now says so. 2 new tests (148 pass). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -1392,7 +1392,7 @@ public sealed class GameServer
|
|||||||
SaveWorld();
|
SaveWorld();
|
||||||
Log($"New save game uploaded by {by} ({found.Count} files) - it is also the new reset point");
|
Log($"New save game uploaded by {by} ({found.Count} files) - it is also the new reset point");
|
||||||
ReconnectAll($"{by} uploaded a new save game - reconnecting...");
|
ReconnectAll($"{by} uploaded a new save game - reconnecting...");
|
||||||
return $"Save game uploaded ({found.Count} files) - everyone reconnects";
|
return $"Save game uploaded ({found.Count} files) - everyone reconnects" + SaveStore.MissingItemsWarning(found);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Aktuellen Spielstand als ZIP.</summary>
|
/// <summary>Aktuellen Spielstand als ZIP.</summary>
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<RootNamespace>MSCO.Server</RootNamespace>
|
<RootNamespace>MSCO.Server</RootNamespace>
|
||||||
<AssemblyName>MSCO.Server</AssemblyName>
|
<AssemblyName>MSCO.Server</AssemblyName>
|
||||||
<Version>2.10.1</Version>
|
<Version>2.10.2</Version>
|
||||||
<Company>MBM</Company>
|
<Company>MBM</Company>
|
||||||
<Product>MSCO Dedicated Server</Product>
|
<Product>MSCO Dedicated Server</Product>
|
||||||
<InvariantGlobalization>true</InvariantGlobalization>
|
<InvariantGlobalization>true</InvariantGlobalization>
|
||||||
|
|||||||
+11
-1
@@ -216,6 +216,16 @@ public static class SaveStore
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Hinweis, wenn im Spielstand items.txt fehlt: dort stehen alle gekauften Teile und Gegenstände (Ölfilter,
|
||||||
|
/// Zündkerzen, Keilriemen, Batterie ...) samt "eingebaut". Ohne die Datei fehlen sie am Auto - z.B. läuft Öl aus,
|
||||||
|
/// weil kein Ölfilter da ist. Im Einzelspieler fällt das nicht auf, wenn dort noch eine alte items.txt liegt.
|
||||||
|
/// </summary>
|
||||||
|
public static string MissingItemsWarning(IReadOnlyDictionary<string, byte[]> files) =>
|
||||||
|
files.ContainsKey("items.txt") ? ""
|
||||||
|
: " - WARNING: items.txt is missing in this save. Bought parts (oil filter, spark plugs, fan belt, battery ...) are " +
|
||||||
|
"stored there, so they are missing on the car (e.g. oil runs out without the oil filter). Upload the save with items.txt.";
|
||||||
|
|
||||||
/// <summary>Aktuellen Spielstand als ZIP.</summary>
|
/// <summary>Aktuellen Spielstand als ZIP.</summary>
|
||||||
public static byte[] ExportZip(string dataDir)
|
public static byte[] ExportZip(string dataDir)
|
||||||
{
|
{
|
||||||
@@ -247,7 +257,7 @@ public static class SaveStore
|
|||||||
}
|
}
|
||||||
catch (Exception e) { return "Could not write the save game: " + e.Message; }
|
catch (Exception e) { return "Could not write the save game: " + e.Message; }
|
||||||
GameServer.Log($"New save game uploaded by {by} ({files.Count} files, server stopped) - it is also the new reset point");
|
GameServer.Log($"New save game uploaded by {by} ({files.Count} files, server stopped) - it is also the new reset point");
|
||||||
return $"Save game uploaded ({files.Count} files) - start the server to use it";
|
return $"Save game uploaded ({files.Count} files) - start the server to use it" + MissingItemsWarning(files);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Server aus: Backup wiederherstellen.</summary>
|
/// <summary>Server aus: Backup wiederherstellen.</summary>
|
||||||
|
|||||||
+4
-1
@@ -537,8 +537,10 @@ async Task PanelTests()
|
|||||||
up.Headers.Add("X-MSCO-Panel", "1");
|
up.Headers.Add("X-MSCO-Panel", "1");
|
||||||
up.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/zip");
|
up.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/zip");
|
||||||
var upRes = await owner.SendAsync(up);
|
var upRes = await owner.SendAsync(up);
|
||||||
|
string upText = await upRes.Content.ReadAsStringAsync();
|
||||||
Check(upRes.IsSuccessStatusCode && File.ReadAllText(Path.Combine(dir, "save", "defaultES2File.txt")) == "ZIPPED SAVE",
|
Check(upRes.IsSuccessStatusCode && File.ReadAllText(Path.Combine(dir, "save", "defaultES2File.txt")) == "ZIPPED SAVE",
|
||||||
"A save game ZIP can be uploaded: " + await upRes.Content.ReadAsStringAsync());
|
"A save game ZIP can be uploaded: " + upText);
|
||||||
|
Check(upText.Contains("items.txt is missing"), "Uploading a save without items.txt warns (bought parts like the oil filter would be missing)");
|
||||||
Check(!File.Exists(Path.Combine(dir, "..", "evil.txt")) && !File.Exists(Path.Combine(dir, "evil.txt")), "Paths inside the ZIP are never used");
|
Check(!File.Exists(Path.Combine(dir, "..", "evil.txt")) && !File.Exists(Path.Combine(dir, "evil.txt")), "Paths inside the ZIP are never used");
|
||||||
Check(File.ReadAllText(Path.Combine(dir, "save_original", "defaultES2File.txt")) == "ZIPPED SAVE", "The uploaded save is the new reset point");
|
Check(File.ReadAllText(Path.Combine(dir, "save_original", "defaultES2File.txt")) == "ZIPPED SAVE", "The uploaded save is the new reset point");
|
||||||
// RAR (mit WinRAR gepackt, "solid", Unterordner, zusätzliche fremde Datei)
|
// RAR (mit WinRAR gepackt, "solid", Unterordner, zusätzliche fremde Datei)
|
||||||
@@ -550,6 +552,7 @@ async Task PanelTests()
|
|||||||
Check(rarRes.IsSuccessStatusCode && File.ReadAllText(Path.Combine(dir, "save", "defaultES2File.txt")) == "RAR SAVE"
|
Check(rarRes.IsSuccessStatusCode && File.ReadAllText(Path.Combine(dir, "save", "defaultES2File.txt")) == "RAR SAVE"
|
||||||
&& File.ReadAllText(Path.Combine(dir, "save", "items.txt")) == "rar items" && !File.Exists(Path.Combine(dir, "save", "readme.txt")),
|
&& File.ReadAllText(Path.Combine(dir, "save", "items.txt")) == "rar items" && !File.Exists(Path.Combine(dir, "save", "readme.txt")),
|
||||||
"A RAR archive can be uploaded (only the save files are taken): " + await rarRes.Content.ReadAsStringAsync());
|
"A RAR archive can be uploaded (only the save files are taken): " + await rarRes.Content.ReadAsStringAsync());
|
||||||
|
Check(!(await rarRes.Content.ReadAsStringAsync()).Contains("items.txt is missing"), "No items.txt warning when the save has items.txt");
|
||||||
var junk = new HttpRequestMessage(HttpMethod.Post, "api/save/upload") { Content = new ByteArrayContent(System.Text.Encoding.UTF8.GetBytes("this is no archive")) };
|
var junk = new HttpRequestMessage(HttpMethod.Post, "api/save/upload") { Content = new ByteArrayContent(System.Text.Encoding.UTF8.GetBytes("this is no archive")) };
|
||||||
junk.Headers.Add("X-MSCO-Panel", "1");
|
junk.Headers.Add("X-MSCO-Panel", "1");
|
||||||
var junkRes = await owner.SendAsync(junk);
|
var junkRes = await owner.SendAsync(junk);
|
||||||
|
|||||||
Reference in New Issue
Block a user