Skip to content
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

Fix #11055: Make saveload failure error messages consistent with others #12247

Merged
merged 1 commit into from Apr 1, 2024

Conversation

merni-ns
Copy link
Contributor

@merni-ns merni-ns commented Mar 9, 2024

Motivation / Problem

Fixes #11055.

The "save/load failed" error messages were displayed by substituting the reason (_sl.error_str) with a parameter into STR_ERROR_GAME_SAVE_FAILED/STR_ERROR_GAME_LOAD_FAILED. This means the line separation is not the same as those formed by using the two parameters of ShowErrorMessage.

Description

  • Use the first parameter of ShowErrorMessage to show the initial string "Game save failed"/"Game load failed"
  • Use the second parameter to show the reason that was originally the first parameter of STR_ERROR_GAME_(SAVE|LOAD)_FAILED.
  • The _sl.extra_msg, an untranslated string returned by internal APIs, is untouched and used as the first parameter of reasons that require it (and thus the first parameter overall).
  • Make the "Game save failed"/"Game load failed" more consistent by not Capitalising Each Word and adding an ellipsis at the end.

image

Limitations

  • Not tested, except for the case of a save file that the game has no permission to read. In particular the case of "internal error" or "broken savegame", which require one more parameter, are not tested.

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR touches english.txt or translations? Check the guidelines
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, game_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

@merni-ns merni-ns marked this pull request as ready for review March 9, 2024 20:21
@merni-ns merni-ns force-pushed the fix11055 branch 2 times, most recently from e57d345 to 33e4f16 Compare March 16, 2024 12:03
src/saveload/saveload.cpp Outdated Show resolved Hide resolved
src/saveload/saveload.cpp Outdated Show resolved Hide resolved
@@ -2803,8 +2802,7 @@ static SaveOrLoadResult SaveFileToDisk(bool threaded)
/* We don't want to shout when saving is just
* cancelled due to a client disconnecting. */
if (_sl.error_str != STR_NETWORK_ERROR_LOSTCONNECTION) {
/* Skip the "colour" character */
Debug(sl, 0, "{}", GetSaveLoadErrorString() + 3);
Debug(sl, 0, "{}", GetString(GetSaveLoadErrorType()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the colour not stripped any more? Also in the next bit. For example using .substr(3).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully I have fixed it in the current force-push, but I have no idea about how colour codes work.

@merni-ns merni-ns force-pushed the fix11055 branch 3 times, most recently from ae379c5 to ece4b1f Compare March 28, 2024 13:49
…th others

The save/load error messages were combined using string parameters, rather than using the built-in functionality of error dialogs.
@PeterN PeterN merged commit 6f36f3d into OpenTTD:master Apr 1, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: "Game Load Failed" error message is shorter than other two-line messages
4 participants