fixed some compile errors. Fixed problem in Ford of Abez with monsters attacking Li'sar

This commit is contained in:
uid68803 2004-01-12 16:23:59 +00:00
parent 78ab068286
commit 2979c91358
3 changed files with 37 additions and 7 deletions

View file

@ -92,6 +92,12 @@ Defeat:
gold=200
enemy=1
leader_value=100
#target Konrad especially heavily
[target]
value=100
description=Konrad
[/target]
[/side]
{STORM_TRIDENT 16 17}

View file

@ -679,6 +679,32 @@ config& config::add_child(const std::string& key, const config& val)
return *v.back();
}
struct remove_ordered {
remove_ordered(const std::string& key) : key_(key) {}
bool operator()(const config::child_pos& pos) const { return pos.pos->first == key_; }
private:
std::string key_;
};
void config::clear_children(const std::string& key)
{
ordered_children.erase(std::remove_if(ordered_children.begin(),ordered_children.end(),remove_ordered(key)),ordered_children.end());
children.erase(key);
}
void config::remove_child(const std::string& key, size_t index)
{
//remove from the ordering
const child_pos pos(children.find(key),index);
ordered_children.erase(std::remove(ordered_children.begin(),ordered_children.end(),pos),ordered_children.end());
//remove from the child map
child_list& v = children[key];
assert(index < v.size());
v.erase(v.begin()+index);
}
std::string& config::operator[](const std::string& key)
{
return values[key];

View file

@ -119,13 +119,8 @@ struct config
const config* find_child(const std::string& key, const std::string& name,
const std::string& value) const;
void clear_children(const std::string& key) { children.erase(key); }
void remove_child(const std::string& key, size_t index) {
child_list& v = children[key];
assert(index < v.size());
v.erase(v.begin()+index);
ordered_children.erase(ordered_children.end());
}
void clear_children(const std::string& key);
void remove_child(const std::string& key, size_t index);
static std::vector<std::string> split(const std::string& val, char c=',');
static std::string& strip(std::string& str);
@ -142,6 +137,9 @@ struct config
child_pos(child_map::const_iterator p, size_t i) : pos(p), index(i) {}
child_map::const_iterator pos;
size_t index;
bool operator==(const child_pos& o) const { return pos == o.pos && index == o.index; }
bool operator!=(const child_pos& o) const { return !operator==(o); }
};
struct all_children_iterator {