Fix the recall (Alt-R was broken since 2008-03-13T07:44:33Z!esr@thyrsus.com) problem...

...by using id= everywhere, rather than description=, as the attribute
for both team and side IDs.  Note: This will almost certainly break MP
compatibility.
This commit is contained in:
Eric S. Raymond 2008-03-18 22:16:22 +00:00
parent 71150843d5
commit 0481391922
9 changed files with 18 additions and 18 deletions

View File

@ -223,7 +223,7 @@ void get_player_info(const config& cfg, game_state& gamestate,
int get_first_human_team(const config::child_list::const_iterator& cfg, const config::child_list& unit_cfg){
int result = -1;
const std::string& controller = (**cfg)["controller"];
if (controller == preferences::client_type() && (**cfg)["description"] == preferences::login()) {
if (controller == preferences::client_type() && (**cfg)["id"] == preferences::login()) {
result = cfg - unit_cfg.begin();
} else if((**cfg)["controller"] == "human") {
result = cfg - unit_cfg.begin();

View File

@ -2012,7 +2012,7 @@ private:
void menu_handler::send_chat_message(const std::string& message, bool allies_only)
{
config cfg;
cfg["description"] = preferences::login();
cfg["id"] = preferences::login();
cfg["message"] = message;
const int side = is_observer() ? 0 : gui_->viewing_team()+1;
@ -2031,7 +2031,7 @@ private:
}
recorder.speak(cfg);
add_chat_message(time(NULL), cfg["description"], side, message,
add_chat_message(time(NULL), cfg["id"], side, message,
private_message ? game_display::MESSAGE_PRIVATE : game_display::MESSAGE_PUBLIC);
}

View File

@ -67,7 +67,7 @@ connect::side::side(connect& parent, const config& cfg, int index) :
player_number_(parent.video(), lexical_cast_default<std::string>(index+1, ""),
font::SIZE_LARGE, font::LOBBY_COLOUR),
combo_controller_(parent.disp(), parent.player_types_),
orig_controller_(parent.video(), cfg.get_attribute("description"), font::SIZE_SMALL),
orig_controller_(parent.video(), cfg.get_attribute("id"), font::SIZE_SMALL),
combo_ai_algorithm_(parent.disp(), std::vector<std::string>()),
combo_faction_(parent.disp(), parent.player_factions_),
combo_leader_(parent.disp(), std::vector<std::string>()),
@ -557,7 +557,7 @@ config connect::side::get_config() const
res["side"] = lexical_cast<std::string>(index_ + 1);
}
res["controller"] = controller_names[controller_];
res["description"] = id_;
res["id"] = id_;
res["current_player"] = id_;
if (id_.empty()) {
@ -674,7 +674,7 @@ config connect::side::get_config() const
config trimmed = cfg_;
trimmed["side"] = "";
trimmed["controller"] = "";
trimmed["description"] = "";
trimmed["id"] = "";
trimmed["team_name"] = "";
trimmed["user_team_name"] = "";
trimmed["colour"] = "";

View File

@ -143,7 +143,7 @@ void level_to_gamestate(config& level, game_state& state, bool saved_game)
if ( ((**side)["side"] == (**lside)["side"])
&& ((**side)["current_player"] != (**lside)["current_player"]) ){
(**side)["current_player"] = (**lside)["current_player"];
(**side)["description"] = (**lside)["description"];
(**side)["id"] = (**lside)["id"];
(**side)["save_id"] = (**lside)["save_id"];
(**side)["controller"] = (**lside)["controller"];
break;

View File

@ -247,7 +247,7 @@ void wait::join_game(bool observe)
//available side.
int side_choice = 0;
for(config::child_list::const_iterator s = sides_list.begin(); s != sides_list.end(); ++s) {
if((**s)["controller"] == "network" && (**s)["description"].empty()) {
if((**s)["controller"] == "network" && (**s)["id"].empty()) {
if((**s)["save_id"] == preferences::login() || (**s)["current_player"] == preferences::login()) {
side_choice = s - sides_list.begin();
}
@ -461,8 +461,8 @@ void wait::generate_menu()
}
}
if(!sd["description"].empty())
playerlist.push_back(sd["description"]);
if(!sd["id"].empty())
playerlist.push_back(sd["id"]);
std::string leader_name;
std::string leader_image;

View File

@ -294,7 +294,7 @@ LEVEL_RESULT play_game(display& disp, game_state& gamestate, const config& game_
if(id.empty())
continue;
controllers[id] = player_controller((**side)["controller"],
(**side)["description"]);
(**side)["id"]);
}
}

View File

@ -453,9 +453,9 @@ void replay::add_chat_log_entry(const config* speak, std::stringstream& str, con
const std::string& team_name = cfg["team_name"];
if(team_name == "" || team_name == team) {
if(team_name == "") {
str << "<" << cfg["description"] << "> ";
str << "<" << cfg["id"] << "> ";
} else {
str << "*" << cfg["description"] << "* ";
str << "*" << cfg["id"] << "* ";
}
str << cfg["message"] << "\n";
}
@ -857,7 +857,7 @@ bool do_replay_handle(game_display& disp, const gamemap& map, const game_data& g
&& teams[disp.viewing_team()].team_name() == team_name)
|| (is_observer() && team_name == "observer"))
{
const std::string& speaker_name = (*child)["description"];
const std::string& speaker_name = (*child)["id"];
const std::string& message = (*child)["message"];
//if (!preferences::show_lobby_join(speaker_name, message)) return;
bool is_whisper = (speaker_name.find("whisper: ") == 0);

View File

@ -757,7 +757,7 @@ bool game::process_turn(simple_wml::document& data, const player_map::const_iter
// Force the description to be correct,
// to prevent spoofing of messages.
speak.set_attr_dup("description", user->second.name().c_str());
speak.set_attr_dup("id", user->second.name().c_str());
// Also check the side for players.
if (is_player(user->first)) {
const size_t side_num = speak["side"].to_int();
@ -1226,7 +1226,7 @@ void game::send_server_message(const char* message, network::connection sock, si
simple_wml::node& cmd = doc.root().add_child("turn");
simple_wml::node& cfg = cmd.add_child("command");
simple_wml::node& msg = cfg.add_child("speak");
msg.set_attr("description", "server");
msg.set_attr("id", "server");
msg.set_attr_dup("message", message);
} else {
simple_wml::node& msg = doc.root().add_child("message");

View File

@ -89,7 +89,7 @@ team::team_info::team_info(const config& cfg) :
action_bonus_count(lexical_cast_default<int>(cfg["action_bonus_count"])),
flag(cfg["flag"]),
flag_icon(cfg["flag_icon"]),
description(cfg["description"]),
description(cfg["id"]),
objectives(cfg["objectives"]),
objectives_changed(utils::string_bool(cfg["objectives_changed"])),
controller(),
@ -283,7 +283,7 @@ void team::team_info::write(config& cfg) const
cfg["current_player"] = current_player;
cfg["flag"] = flag;
cfg["flag_icon"] = flag_icon;
cfg["description"] = description;
cfg["id"] = description;
cfg["objectives"] = objectives;
cfg["objectives_changed"] = objectives_changed ? "yes" : "no";
cfg["countdown_time"]= countdown_time;