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.
This commit is contained in:
parent
15c59037d3
commit
eec8b674de
2 changed files with 17 additions and 7 deletions
|
@ -235,13 +235,16 @@ game_info::game_info(const config& game, const std::vector<std::string>& 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();
|
||||
|
||||
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();
|
||||
verified = false;
|
||||
|
||||
|
@ -309,6 +312,7 @@ game_info::game_info(const config& game, const std::vector<std::string>& 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) {
|
||||
|
@ -341,11 +345,14 @@ game_info::game_info(const config& game, const std::vector<std::string>& 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;
|
||||
|
|
|
@ -1553,8 +1553,11 @@ void server::handle_player_in_game(socket_ptr socket, std::shared_ptr<simple_wml
|
|||
// Update the game's description.
|
||||
// If there is no shroud, then tell players in the lobby
|
||||
// what the map looks like
|
||||
const simple_wml::node& s = *wesnothd::game::starting_pos(g.level().root());
|
||||
// fixme: the hanlder of [store_next_scenario] below searches for 'mp_shroud' in [scenario]
|
||||
// at least of the these cosed is likely wrong.
|
||||
if(!data["mp_shroud"].to_bool()) {
|
||||
desc.set_attr_dup("map_data", (*wesnothd::game::starting_pos(data.root()))["map_data"]);
|
||||
desc.set_attr_dup("map_data", s["map_data"]);
|
||||
}
|
||||
|
||||
if(const simple_wml::node* e = data.child("era")) {
|
||||
|
@ -1563,7 +1566,7 @@ void server::handle_player_in_game(socket_ptr socket, std::shared_ptr<simple_wml
|
|||
}
|
||||
}
|
||||
|
||||
if(data.attr("require_scenario").to_bool(false)) {
|
||||
if(s["require_scenario"].to_bool(false)) {
|
||||
desc.set_attr("require_scenario", "yes");
|
||||
}
|
||||
|
||||
|
@ -1658,7 +1661,7 @@ void server::handle_player_in_game(socket_ptr socket, std::shared_ptr<simple_wml
|
|||
}
|
||||
}
|
||||
|
||||
if(data.attr("require_scenario").to_bool(false)) {
|
||||
if(s["require_scenario"].to_bool(false)) {
|
||||
desc.set_attr("require_scenario", "yes");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue