Adjusted mp::lobby game's description for MP campaign.

This commit is contained in:
Andrius Silinskas 2013-09-11 17:23:33 +01:00
parent ea28bfe209
commit 5238f1e2d8
6 changed files with 74 additions and 33 deletions

View file

@ -28,6 +28,8 @@ mp_game_settings::mp_game_settings() :
hash(),
mp_era(),
mp_scenario(),
mp_scenario_name(),
mp_campaign(),
active_mods(),
side_users(),
num_turns(0),
@ -60,6 +62,8 @@ mp_game_settings::mp_game_settings(const config& cfg) :
hash(),
mp_era(),
mp_scenario(),
mp_scenario_name(),
mp_campaign(),
active_mods(),
side_users(),
num_turns(0),
@ -93,6 +97,8 @@ mp_game_settings::mp_game_settings(const mp_game_settings& settings)
, hash(settings.hash)
, mp_era(settings.mp_era)
, mp_scenario(settings.mp_scenario)
, mp_scenario_name(settings.mp_scenario_name)
, mp_campaign(settings.mp_campaign)
, active_mods(settings.active_mods)
, side_users(settings.side_users)
, num_turns(settings.num_turns)
@ -128,6 +134,8 @@ void mp_game_settings::set_from_config(const config& game_cfg)
hash = cfg["hash"].str();
mp_era = cfg["mp_era"].str();
mp_scenario = cfg["mp_scenario"].str();
mp_scenario_name = cfg["scenario_name"].str();
mp_campaign = cfg["mp_campaign"].str();
active_mods = utils::split(cfg["active_mods"], ',');
side_users = utils::map_split(cfg["side_users"]);
xp_modifier = cfg["experience_modifier"];
@ -156,6 +164,8 @@ void mp_game_settings::reset()
hash = "";
mp_era = "";
mp_scenario = "";
mp_scenario_name = "";
mp_campaign = "";
active_mods.clear();
side_users.clear();
num_turns = 0;
@ -181,6 +191,8 @@ config mp_game_settings::to_config() const
cfg["hash"] = hash;
cfg["mp_era"] = mp_era;
cfg["mp_scenario"] = mp_scenario;
cfg["mp_scenario_name"] = mp_scenario_name;
cfg["mp_campaign"] = mp_campaign;
cfg["active_mods"] = utils::join(active_mods, ",");
cfg["side_users"] = utils::join_map(side_users);
cfg["experience_modifier"] = xp_modifier;

View file

@ -38,6 +38,8 @@ struct mp_game_settings : public savegame::savegame_config
std::string hash;
std::string mp_era;
std::string mp_scenario;
std::string mp_scenario_name;
std::string mp_campaign;
std::vector<std::string> active_mods;
std::map<std::string, std::string> side_users;

View file

@ -332,7 +332,8 @@ void configure::process_event()
parameters_.hash = scenario.hash();
parameters_.scenario_data = scenario;
parameters_.mp_scenario = parameters_.scenario_data["id"].str();
parameters_.mp_scenario = scenario["id"].str();
parameters_.mp_scenario_name = scenario["name"].str();
force_use_map_settings_check_ = true;
}

View file

@ -360,6 +360,7 @@ void create_engine::prepare_for_new_level()
parameters_.scenario_data = current_level().data();
parameters_.hash = parameters_.scenario_data.hash();
parameters_.mp_scenario = parameters_.scenario_data["id"].str();
parameters_.mp_scenario_name = parameters_.scenario_data["name"].str();
}
void create_engine::prepare_for_campaign(const std::string& difficulty)
@ -381,6 +382,8 @@ void create_engine::prepare_for_campaign(const std::string& difficulty)
current_level().set_data(
resources::config_manager->game_config().find_child("multiplayer",
"id", current_level().data()["first_scenario"]));
parameters_.mp_campaign = current_level().id();
}
void create_engine::prepare_for_saved_game()

View file

@ -501,43 +501,65 @@ void gamebrowser::set_game_items(const config& cfg, const config& game_config)
games_.back().map_info += " — ??×??";
}
games_.back().map_info += " ";
if (!game["mp_scenario"].empty())
{
// check if it's a multiplayer scenario
const config *level_cfg = &game_config.find_child("multiplayer", "id", game["mp_scenario"]);
if (!*level_cfg) {
// check if it's a user map
level_cfg = &game_config.find_child("generic_multiplayer", "id", game["mp_scenario"]);
}
if (*level_cfg) {
games_.back().map_info += (*level_cfg)["name"].str();
// reloaded games do not match the original scenario hash,
// so it makes no sense to test them, they always would appear
// as remote scenarios
if (map_hashes_ && !games_.back().reloaded) {
std::string hash = game["hash"];
bool hash_found = false;
BOOST_FOREACH(const config::attribute &i, map_hashes_.attribute_range()) {
if (i.first == game["mp_scenario"] && i.second == hash) {
hash_found = true;
break;
if (game["mp_campaign"].empty()) {
if (!game["mp_scenario"].empty()) {
// Check if it's a multiplayer scenario.
const config* level_cfg = &game_config.find_child("multiplayer",
"id", game["mp_scenario"]);
if (!*level_cfg) {
// Check if it's a user map.
level_cfg = &game_config.find_child("generic_multiplayer",
"id", game["mp_scenario"]);
}
if (*level_cfg) {
games_.back().map_info += (*level_cfg)["name"].str();
// Reloaded games do not match the original scenario hash,
// so it makes no sense to test them,
// they always would appear as remote scenarios.
if (map_hashes_ && !games_.back().reloaded) {
std::string hash = game["hash"];
bool hash_found = false;
BOOST_FOREACH(const config::attribute& i,
map_hashes_.attribute_range()) {
if (i.first == game["mp_scenario"] &&
i.second == hash) {
hash_found = true;
break;
}
}
if (!hash_found) {
games_.back().map_info += "";
games_.back().map_info += _("Remote scenario");
verified = false;
}
}
if(!hash_found) {
games_.back().map_info += "";
games_.back().map_info += _("Remote scenario");
verified = false;
}
} else {
utils::string_map symbols;
symbols["scenario_id"] = game["mp_scenario"];
games_.back().map_info +=
vgettext("Unknown scenario: $scenario_id", symbols);
verified = false;
}
} else {
utils::string_map symbols;
symbols["scenario_id"] = game["mp_scenario"];
games_.back().map_info += vgettext("Unknown scenario: $scenario_id", symbols);
games_.back().map_info += _("Unknown scenario");
verified = false;
}
} else {
games_.back().map_info += _("Unknown scenario");
verified = false;
games_.back().map_info += game["mp_scenario_name"].str();
const config* level_cfg = &game_config.find_child("campaign", "id",
game["mp_campaign"]);
if (*level_cfg) {
games_.back().map_info += " (" + (*level_cfg)["name"].str() + ")";
} else {
utils::string_map symbols;
symbols["campaign_id"] = game["mp_campaign"];
games_.back().map_info +=
vgettext("Unknown scenario: $campaign_id", symbols);
verified = false;
}
}
games_.back().mod_info += "Modifications: ";

View file

@ -571,8 +571,9 @@ LEVEL_RESULT play_game(game_display& disp, game_state& gamestate,
team_init(starting_pos, gamestate);
params.scenario_data = *scenario;
params.mp_scenario = params.scenario_data["id"].str();
params.num_turns = params.scenario_data["turns"].to_int(-1);
params.mp_scenario = (*scenario)["id"].str();
params.mp_scenario_name = (*scenario)["name"].str();
params.num_turns = (*scenario)["turns"].to_int(-1);
params.saved_game = false;
params.use_map_settings =
(*scenario)["force_use_map_settings"].to_bool(true);