Skip to content

Commit

Permalink
Send scenario/era/modification source add-ons and addon versions to w…
Browse files Browse the repository at this point in the history
…esnothd.

This adds the additional attributes under the multiplayer information sent to wesnothd:
* mp_scenario_addon_id
* mp_scenario_addon_version (host's version)
* mp_era_addon_id
* mp_era_addon_version (host's version)
* active_mod_addon_ids
* active_mod_versions (host's versions)
  • Loading branch information
Pentarctagon committed Jun 18, 2020
1 parent 39b8eb0 commit 07c68e3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/game_initialization/mp_game_utils.cpp
Expand Up @@ -80,6 +80,8 @@ config initial_level_config(saved_game& state)

config level = state.to_config();
add_multiplayer_classification(level.child_or_add("multiplayer"), state);
level.child("multiplayer")["mp_scenario_addon_id"] = level.child("scenario")["addon_id"].str("N/A");
level.child("multiplayer")["mp_scenario_addon_version"] = state.to_config().child("scenario")["addon_version"].str("N/A");

// [multiplayer] mp_era= should be persistent over saves.
std::string era = params.mp_era;
Expand Down Expand Up @@ -109,6 +111,9 @@ config initial_level_config(saved_game& state)
} else {
level.add_child("era", era_cfg);

level.child("multiplayer")["mp_era_addon_id"] = era_cfg["addon_id"].str("N/A");
level.child("multiplayer")["mp_era_addon_version"] = era_cfg["addon_version"].str("N/A");

// Initialize the list of sides available for the current era.
// We also need this so not to get a segfault in mp_staging for ai configuration.
const config& custom_side = game_config.find_child("multiplayer_side", "id", "Custom");
Expand All @@ -117,13 +122,20 @@ config initial_level_config(saved_game& state)

// Add modifications, needed for ai algorithms which are applied in mp_staging.
const std::vector<std::string>& mods = params.active_mods;
std::vector<std::string> mod_versions;
std::vector<std::string> mod_addon_ids;

for(unsigned i = 0; i < mods.size(); ++i) {
if(const config& mod_cfg = game_config.find_child("modification", "id", mods[i])) {
mod_versions.push_back(mod_cfg["addon_version"].str("N/A"));
mod_addon_ids.push_back(mod_cfg["addon_id"].str("N/A"));
level.add_child("modification", mod_cfg);
}
}

level.child("multiplayer")["active_mod_versions"] = utils::join(mod_versions);
level.child("multiplayer")["active_mod_addon_ids"] = utils::join(mod_addon_ids);

// This will force connecting clients to be using the same version number as us.
level["version"] = game_config::version;
return level;
Expand Down

0 comments on commit 07c68e3

Please sign in to comment.