From b5b1065113049c37af015fc3830eb18247a758fe Mon Sep 17 00:00:00 2001 From: gfgtdf Date: Sat, 28 Jul 2018 12:29:37 +0200 Subject: [PATCH] fix require_scenario & require_era previously both were broken: 1) 'require_scenario' was only checked if the scenario was installed which obviously doesn't make any sense at all. 2) 'require_scenario' was read from the local scenario data instead from the remote scenario. 3) 'require_era' was only checked when the scenario was not installed, so people who do have an outated version of the era installed could not join bacause it assumed require_era=yes in that case. 4) the server tried to read 'require_scenario' from the wrong wml node, 'require_scenario' is an attribute of [scenario] and not of savefile toplevel. (cherry-picked from commit eec8b674de6d04f13f5b875c1b1e6b953e45ef9e) --- src/game_initialization/lobby_data.cpp | 15 +++++++++++---- src/server/server.cpp | 9 ++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/game_initialization/lobby_data.cpp b/src/game_initialization/lobby_data.cpp index 17ae1cad497c..44bb8ae710b3 100644 --- a/src/game_initialization/lobby_data.cpp +++ b/src/game_initialization/lobby_data.cpp @@ -259,6 +259,7 @@ game_info::game_info(const config& game, const std::vector& install if(!game["mp_era"].empty()) { const config& era_cfg = game_config.find_child("era", "id", game["mp_era"]); + const bool require = game["require_era"].to_bool(true); if(era_cfg) { era = era_cfg["name"].str(); era_short = era_cfg["short_name"].str(); @@ -266,10 +267,12 @@ game_info::game_info(const config& game, const std::vector& install era_short = make_short_name(era); } - ADDON_REQ result = check_addon_version_compatibility(era_cfg, game); - addons_outcome = std::max(addons_outcome, result); // Elevate to most severe error level encountered so far + if(require) { + ADDON_REQ result = check_addon_version_compatibility(era_cfg, game); + addons_outcome = std::max(addons_outcome, result); // Elevate to most severe error level encountered so far + } } else { - have_era = !game["require_era"].to_bool(true); + have_era = !require; era = game["mp_era_name"].str(); era_short = make_short_name(era); verified = false; @@ -339,6 +342,7 @@ game_info::game_info(const config& game, const std::vector& install if(!game["mp_scenario"].empty() && game["mp_campaign"].empty()) { // Check if it's a multiplayer scenario const config* level_cfg = &game_config.find_child("multiplayer", "id", game["mp_scenario"]); + const bool require = game["require_scenario"].to_bool(false); // Check if it's a user map if(!*level_cfg) { @@ -371,11 +375,14 @@ game_info::game_info(const config& game, const std::vector& install } } - if((*level_cfg)["require_scenario"].to_bool(false)) { + if(require) { ADDON_REQ result = check_addon_version_compatibility((*level_cfg), game); addons_outcome = std::max(addons_outcome, result); // Elevate to most severe error level encountered so far } } else { + if(require) { + addons_outcome = std::max(addons_outcome, NEED_DOWNLOAD); // Elevate to most severe error level encountered so far + } scenario = formatter() << make_game_type_marker(_("scenario_abbreviation^S"), true) << game["mp_scenario_name"].str(); info_stream << scenario; verified = false; diff --git a/src/server/server.cpp b/src/server/server.cpp index efa42be1f39e..23affacb9c18 100644 --- a/src/server/server.cpp +++ b/src/server/server.cpp @@ -1553,8 +1553,11 @@ void server::handle_player_in_game(socket_ptr socket, std::shared_ptr