From 9bcdc956514b45b164f403dfb0fe21f8c86fc105 Mon Sep 17 00:00:00 2001 From: Dylan Craine Date: Fri, 7 Mar 2025 19:27:59 -0700 Subject: [PATCH] Fix deceptive "successfully saved" messages for mappers (#5714) * Actually check if map save succeeded before displaying success message It would be great to offer more clarity to the mapper about *why* the save didn't succeed, but at least they won't be deceived into thinking their work has been saved when it hasn't. Portuguese localization text is via DuckDuckGo Translate, so I hope it's reasonable. * Actually check save success for saving grids These messages need localization, too, but that seems out of scope for my PR. * Improve map save error message Now it tells the mapper to go look at the server log. Still translated via DuckDuckGo Translate. * Normalize indentation and style --- Resources/Locale/en-US/commands.ftl | 1 + Resources/Locale/pt-BR/commands.ftl | 1 + Robust.Server/Console/Commands/MapCommands.cs | 22 +++++++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Resources/Locale/en-US/commands.ftl b/Resources/Locale/en-US/commands.ftl index 4d0c0cf84..c1f70bca1 100644 --- a/Resources/Locale/en-US/commands.ftl +++ b/Resources/Locale/en-US/commands.ftl @@ -156,6 +156,7 @@ cmd-savemap-not-exist = Target map does not exist. cmd-savemap-init-warning = Attempted to save a post-init map without forcing the save. cmd-savemap-attempt = Attempting to save map {$mapId} to {$path}. cmd-savemap-success = Map successfully saved. +cmd-savemap-error = Could not save map! See server log for details. cmd-hint-savemap-id = cmd-hint-savemap-path = cmd-hint-savemap-force = [bool] diff --git a/Resources/Locale/pt-BR/commands.ftl b/Resources/Locale/pt-BR/commands.ftl index 86220b207..5941db07b 100644 --- a/Resources/Locale/pt-BR/commands.ftl +++ b/Resources/Locale/pt-BR/commands.ftl @@ -136,6 +136,7 @@ cmd-savemap-not-exist = O mapa de destino não existe. cmd-savemap-init-warning = Tentativa de salvar um mapa pós-inicialização sem forçar o salvamento. cmd-savemap-attempt = Tentando salvar o mapa {$mapId} em {$path}. cmd-savemap-success = Mapa salvo com sucesso. +cmd-savemap-error = Não foi possível salvar o mapa! Consulte o log do servidor para obter detalhes. cmd-hint-savemap-id = cmd-hint-savemap-path = cmd-hint-savemap-force = [bool] diff --git a/Robust.Server/Console/Commands/MapCommands.cs b/Robust.Server/Console/Commands/MapCommands.cs index 511fdc954..35217383e 100644 --- a/Robust.Server/Console/Commands/MapCommands.cs +++ b/Robust.Server/Console/Commands/MapCommands.cs @@ -43,8 +43,15 @@ namespace Robust.Server.Console.Commands return; } - _ent.System().TrySaveGrid(uid, new ResPath(args[1])); - shell.WriteLine("Save successful. Look in the user data directory."); + bool saveSuccess = _ent.System().TrySaveGrid(uid, new ResPath(args[1])); + if(saveSuccess) + { + shell.WriteLine("Save successful. Look in the user data directory."); + } + else + { + shell.WriteError("Save unsuccessful!"); + } } public override CompletionResult GetCompletion(IConsoleShell shell, string[] args) @@ -207,8 +214,15 @@ namespace Robust.Server.Console.Commands } shell.WriteLine(Loc.GetString("cmd-savemap-attempt", ("mapId", mapId), ("path", args[1]))); - _system.GetEntitySystem().TrySaveMap(mapId, new ResPath(args[1])); - shell.WriteLine(Loc.GetString("cmd-savemap-success")); + bool saveSuccess = _system.GetEntitySystem().TrySaveMap(mapId, new ResPath(args[1])); + if(saveSuccess) + { + shell.WriteLine(Loc.GetString("cmd-savemap-success")); + } + else + { + shell.WriteError(Loc.GetString("cmd-savemap-error")); + } } }