mp: Improve display of wesnothd client errors in general
Besides replacing the "End of file" error when getting disconnected from the server under unexpected circumstances (e.g. because the server died) with a translatable and more intuitive message, this also makes it so other network error messages ("Connection refused", "Host not found", etcetera) are displayed in the UI in a slightly clearer fashion, and in an error dialog that must be dismissed with a click on a button, instead of a transient message that can be easily missed due to an accidental misclick. Closes #3005.
This commit is contained in:
parent
d2be366858
commit
359a37b4c5
5 changed files with 39 additions and 3 deletions
|
@ -11,6 +11,7 @@
|
|||
* Removed individual Join/Observe buttons for each game in the MP Lobby.
|
||||
* Highlight the titles of MP games with vacant slots.
|
||||
* Improved MP Lobby layout on low resolutions.
|
||||
* Improved reporting of network errors in the MP lobby (issue #3005).
|
||||
### Units
|
||||
* Changed the plural name for the merfolk race from Mermen to Merfolk (issue #2940)
|
||||
and replaced a few instances in core unit or terrain descriptions accordingly.
|
||||
|
|
|
@ -5,6 +5,8 @@ changelog: https://github.com/wesnoth/wesnoth/blob/1.14/changelog.md
|
|||
## Version 1.14.0+dev
|
||||
### Language and i18n
|
||||
* Updated translations: French, Galician, German, Italian, Slovak, Spanish.
|
||||
### User interface
|
||||
* Improved reporting of network errors in the MP lobby (issue #3005).
|
||||
### Miscellaneous and bug fixes
|
||||
* Attempting to save a screenshot with an unsupported format now shows an error
|
||||
message, instead of saving the screenshot as BMP with the requested extension.
|
||||
|
|
|
@ -867,7 +867,26 @@ bool game_launcher::play_multiplayer(mp_selection res)
|
|||
} catch(wesnothd_error& e) {
|
||||
if(!e.message.empty()) {
|
||||
ERR_NET << "caught network error: " << e.message << std::endl;
|
||||
gui2::show_transient_message("", translation::gettext(e.message.c_str()));
|
||||
|
||||
std::string user_msg;
|
||||
auto conn_err = dynamic_cast<wesnothd_connection_error*>(&e);
|
||||
|
||||
if(conn_err) {
|
||||
// The wesnothd_connection_error subclass is only thrown with messages
|
||||
// from boost::system::error_code which we can't translate ourselves.
|
||||
// It's also the originator of the infamous EOF error that happens when
|
||||
// the server dies. <https://github.com/wesnoth/wesnoth/issues/3005>. It
|
||||
// will provide a translated string instead of that when it happens.
|
||||
user_msg = !conn_err->user_message.empty()
|
||||
? conn_err->user_message
|
||||
: _("Connection failed: ") + e.message;
|
||||
} else {
|
||||
// This will be a message from the server itself, which we can
|
||||
// probably translate.
|
||||
user_msg = translation::gettext(e.message.c_str());
|
||||
}
|
||||
|
||||
gui2::show_error_message(user_msg);
|
||||
} else {
|
||||
ERR_NET << "caught network error" << std::endl;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "wesnothd_connection.hpp"
|
||||
|
||||
#include "gui/dialogs/loading_screen.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "log.hpp"
|
||||
#include "serialization/parser.hpp"
|
||||
#include "utils/functional.hpp"
|
||||
|
@ -395,7 +396,13 @@ bool wesnothd_connection::receive_data(config& result)
|
|||
{
|
||||
std::lock_guard<std::mutex> lock(last_error_mutex_);
|
||||
if(last_error_) {
|
||||
throw error(last_error_);
|
||||
std::string user_msg;
|
||||
|
||||
if(last_error_ == boost::asio::error::eof) {
|
||||
user_msg = _("Disconnected from server.");
|
||||
}
|
||||
|
||||
throw error(last_error_, user_msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,13 @@ struct ingame_wesnothd_error : public wesnothd_error ,public lua_jailbreak_excep
|
|||
///TODO: find a short name
|
||||
struct wesnothd_connection_error : public wesnothd_error ,public lua_jailbreak_exception
|
||||
{
|
||||
wesnothd_connection_error(const boost::system::error_code& error) : wesnothd_error(error.message()) {}
|
||||
wesnothd_connection_error(const boost::system::error_code& error, const std::string& msg = "")
|
||||
: wesnothd_error(error.message())
|
||||
, user_message(msg)
|
||||
{}
|
||||
|
||||
/** User-friendly and potentially translated message for use in the UI. */
|
||||
std::string user_message;
|
||||
|
||||
IMPLEMENT_LUA_JAILBREAK_EXCEPTION(wesnothd_connection_error)
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue