Added the silent= option in the [objectives] tag, ...

...which allows objectives to be silently changed.

When there are no objectives in a category (win / lose), this category
is now not displayed at all.
This commit is contained in:
Philippe Plantier 2005-03-19 21:26:30 +00:00
parent 4cc69d5cb7
commit a8c22c0d6f
3 changed files with 11 additions and 14 deletions

View File

@ -531,10 +531,10 @@ bool event_handler::handle_event_command(const queued_event& event_info, const s
else if(cmd == "objectives") {
const std::string win_str = "@";
const std::string lose_str = "#";
const std::string none_str = _("None specified");
const std::string& summary = cfg["summary"];
const size_t side = lexical_cast_default<size_t>(cfg["side"], 0);
bool silent = cfg["silent"] == "yes";
if(side != 0 && (side - 1) >= teams->size()) {
ERR_NG << "Invalid side: " << cfg["side"] << " in objectives event\n";
@ -574,16 +574,12 @@ bool event_handler::handle_event_command(const queued_event& event_info, const s
std::stringstream objs;
if(!summary.empty())
objs << "*" << summary << "\n";
objs << win_string << "\n";
if(win_objectives.empty()) {
objs << none_str << "\n";
} else {
if(!win_objectives.empty()) {
objs << win_string << "\n";
objs << win_objectives << "\n";
}
objs << lose_string << "\n";
if(lose_objectives.empty()) {
objs << none_str << "\n";
} else {
if(!lose_objectives.empty()) {
objs << lose_string << "\n";
objs << lose_objectives << "\n";
}
@ -591,10 +587,10 @@ bool event_handler::handle_event_command(const queued_event& event_info, const s
for(std::vector<team>::iterator itor = teams->begin();
itor != teams->end(); ++itor) {
itor->set_objectives(objs.str());
itor->set_objectives(objs.str(), silent);
}
} else {
(*teams)[side - 1].set_objectives(objs.str());
(*teams)[side - 1].set_objectives(objs.str(), silent);
}
}

View File

@ -526,10 +526,11 @@ const std::string& team::save_id() const
return info_.save_id;
}
void team::set_objectives(const std::string& new_objectives)
void team::set_objectives(const std::string& new_objectives, bool silently)
{
info_.objectives = new_objectives;
info_.objectives_changed = true;
if(!silently)
info_.objectives_changed = true;
}
void team::reset_objectives_changed()

View File

@ -125,7 +125,7 @@ public:
const std::string& name() const;
const std::string& save_id() const;
void set_objectives(const std::string& new_objectives);
void set_objectives(const std::string& new_objectives, bool silently=false);
void reset_objectives_changed();
const std::string& objectives() const;