[[MP fixes for eras]]

* Made era data be transmitted with games, so that clients may join games even
  if they do not have this era on their computer.

* COMMENTED OUT the statistics verification in replay.cpp. Seems that it
  completely breaks MP games!

				//Disabling because it breaks multiplayer.
				//Apparently, statistics::replay_verify_stats
				//is only written to in game::load_game() (!)
				//Re-enable when fixed / if I am wrong.
				//
				//By the way, making a "config" object global
				//is highly objectable IMO.
				//
				// --Ayin 30 mar. 2005
				//
				//if (!game_config::ignore_replay_errors)
				//	throw replay::error();
This commit is contained in:
Philippe Plantier 2005-03-30 19:48:17 +00:00
parent e70232843d
commit 7c5d4ec0cf
6 changed files with 49 additions and 45 deletions

View file

@ -825,6 +825,7 @@ void connect::lists_init()
}
era_sides_ = era_cfg->get_children("multiplayer_side");
level_.add_child("era", *era_cfg);
for(std::vector<config*>::const_iterator faction = era_sides_.begin(); faction != era_sides_.end(); ++faction) {
player_factions_.push_back((**faction)["name"]);

View file

@ -123,8 +123,12 @@ create::create(display& disp, const config &cfg, chat& c, config& gamelist) :
}
era_combo_.set_items(eras);
if (size_t(preferences::era()) < eras.size())
if (size_t(preferences::era()) < eras.size()) {
era_combo_.set_selected(preferences::era());
} else {
era_combo_.set_selected(0);
}
utils::string_map i18n_symbols;
i18n_symbols["login"] = preferences::login();

View file

@ -196,27 +196,6 @@ void wait::join_game(bool observe)
}
const bool allow_changes = (*sides_list[side_choice])["allow_changes"] != "no";
const std::string& era = level_["era"];
const config* const era_cfg = game_config().find_child("era","id",era);
if(era_cfg == NULL) {
set_result(QUIT);
throw network::error(_("Era not available"));
return;
}
era_sides_ = *era_cfg;
const config::child_list& possible_sides = era_cfg->get_children("multiplayer_side");
if(possible_sides.empty()) {
set_result(QUIT);
throw network::error(_("No multiplayer sides found"));
return;
}
std::vector<std::string> choices;
for(config::child_list::const_iterator side =
possible_sides.begin(); side != possible_sides.end(); ++side) {
choices.push_back((**side)["name"]);
}
//if the client is allowed to choose their team, instead of having
//it set by the server, do that here.
@ -224,17 +203,36 @@ void wait::join_game(bool observe)
size_t faction_choice = 0;
if(allow_changes) {
const config* era = level_.child("era");
if(era == NULL)
throw network::error(_("Era not available"));
const config::child_list& possible_sides =
era->get_children("multiplayer_side");
if(possible_sides.empty()) {
set_result(QUIT);
throw network::error(_("No multiplayer sides found"));
return;
}
std::vector<std::string> choices;
for(config::child_list::const_iterator side =
possible_sides.begin(); side !=
possible_sides.end(); ++side) {
choices.push_back((**side)["name"]);
}
std::vector<gui::preview_pane* > preview_panes;
leader_preview_pane leader_selector(disp(), &game_data_, possible_sides);
leader_preview_pane leader_selector(disp(), &game_data_,
possible_sides);
preview_panes.push_back(&leader_selector);
faction_choice = size_t(gui::show_dialog(disp(), NULL, "", _("Choose your side:"),
faction_choice = size_t(gui::show_dialog(disp(), NULL, "",
_("Choose your side:"),
gui::OK_ONLY, &choices, &preview_panes));
leader_choice = leader_selector.get_selected_leader();
}
wassert(faction_choice < possible_sides.size());
//team_ = faction_choice;
wassert(faction_choice < possible_sides.size());
}
config response;
response["side"] = lexical_cast<std::string>(side_choice + 1);
@ -270,8 +268,6 @@ void wait::start_game()
}
}
// FIXME: To be reviewed
//any replay data is only temporary and should be removed from
//the level data in case we want to save the game later
config* const replay_data = level_.child("replay");
@ -368,15 +364,8 @@ void wait::generate_menu()
std::string description = sd["description"];
const std::string faction_id = sd["id"];
const config* const faction_cfg =
era_sides_.find_child("multiplayer_side", "id", faction_id);
std::string side_name;
if (faction_cfg != NULL) {
side_name = (*faction_cfg)["name"];
} else {
side_name = sd["name"];
}
t_string side_name = sd["name"];
std::string leader_type = sd["type"];
// Hack: if there is a unit which can recruit, use it as a
@ -405,10 +394,11 @@ void wait::generate_menu()
if (!leader_image.empty()) {
// Dumps the "image" part of the faction name, if any,
// to replace it by a picture of the actual leader
if(side_name[0] == font::IMAGE) {
std::string::size_type p = side_name.find_first_of(COLUMN_SEPARATOR);
if(side_name.str()[0] == font::IMAGE) {
std::string::size_type p =
side_name.str().find_first_of(COLUMN_SEPARATOR);
if(p != std::string::npos && p < side_name.size()) {
side_name = IMAGE_PREFIX + leader_image + COLUMN_SEPARATOR + side_name.substr(p+1);
side_name = IMAGE_PREFIX + leader_image + COLUMN_SEPARATOR + side_name.str().substr(p+1);
}
}
}

View file

@ -75,8 +75,6 @@ private:
// int team_;
const game_data& game_data_;
config era_sides_;
config level_;
game_state state_;

View file

@ -610,7 +610,18 @@ bool do_replay(display& disp, const gamemap& map, const game_data& gameinfo,
const config current_stats = statistics::write_stats();
if(current_stats != statistics::replay_verify_stats) {
ERR_NW << "replay statistics verification failed\n";
if (!game_config::ignore_replay_errors) throw replay::error();
//Disabling because it breaks multiplayer.
//Apparently, statistics::replay_verify_stats
//is only written to in game::load_game() (!)
//Re-enable when fixed / if I am wrong.
//
//By the way, making a "config" object global
//is highly objectable IMO.
//
// --Ayin 30 mar. 2005
//
//if (!game_config::ignore_replay_errors)
// throw replay::error();
}
return false;
}

View file

@ -15,7 +15,6 @@
#include <map>
#include "tstring.hpp"
#include "wassert.hpp"
#include "gettext.hpp"
#include "filesystem.hpp"
#include "log.hpp"
@ -27,6 +26,7 @@ namespace {
const char UNTRANSLATABLE_PART = 0x02;
const char TEXTDOMAIN_SEPARATOR = 0x03;
const char ID_TRANSLATABLE_PART = 0x04;
const char UNTRANSLATABLE_STRING = 0x05;
std::vector<std::string> id_to_textdomain;
std::map<std::string, unsigned int> textdomain_to_id;