本文整理汇总了C++中vconfig::count_children方法的典型用法代码示例。如果您正苦于以下问题:C++ vconfig::count_children方法的具体用法?C++ vconfig::count_children怎么用?C++ vconfig::count_children使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vconfig
的用法示例。
在下文中一共展示了vconfig::count_children方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: internal_matches_filter
bool basic_unit_filter_impl::internal_matches_filter(const unit & u, const map_location& loc, const unit* u2) const
{
if (!vcfg["name"].blank() && vcfg["name"].t_str() != u.name()) {
return false;
}
if (!vcfg["id"].empty()) {
std::vector<std::string> id_list = utils::split(vcfg["id"]);
if (std::find(id_list.begin(), id_list.end(), u.id()) == id_list.end()) {
return false;
}
}
// Allow 'speaker' as an alternative to id, since people use it so often
if (!vcfg["speaker"].blank() && vcfg["speaker"].str() != u.id()) {
return false;
}
if (vcfg.has_child("filter_location")) {
if (vcfg.count_children("filter_location") > 1) {
FAIL("Encountered multiple [filter_location] children of a standard unit filter. "
"This is not currently supported and in all versions of wesnoth would have "
"resulted in the later children being ignored. You must use [and] or similar "
"to achieve the desired result.");
}
terrain_filter filt(vcfg.child("filter_location"), &fc_, use_flat_tod_);
if (!filt.match(loc)) {
return false;
}
}
if(vcfg.has_child("filter_side")) {
if (vcfg.count_children("filter_side") > 1) {
FAIL("Encountered multiple [filter_side] children of a standard unit filter. "
"This is not currently supported and in all versions of wesnoth would have "
"resulted in the later children being ignored. You must use [and] or similar "
"to achieve the desired result.");
}
side_filter filt(vcfg.child("filter_side"), &fc_);
if(!filt.match(u.side()))
return false;
}
// Also allow filtering on location ranges outside of the location filter
if (!vcfg["x"].blank() || !vcfg["y"].blank()){
if(vcfg["x"] == "recall" && vcfg["y"] == "recall") {
//locations on the map are considered to not be on a recall list
if (fc_.get_disp_context().map().on_board(loc))
{
return false;
}
} else if(vcfg["x"].empty() && vcfg["y"].empty()) {
return false;
} else if(!loc.matches_range(vcfg["x"], vcfg["y"])) {
return false;
}
}
// The type could be a comma separated list of types
if (!vcfg["type"].empty()) {
std::vector<std::string> types = utils::split(vcfg["type"]);
if (std::find(types.begin(), types.end(), u.type_id()) == types.end()) {
return false;
}
}
// Shorthand for all advancements of a given type
if (!vcfg["type_tree"].empty()) {
std::set<std::string> types;
for(const std::string type : utils::split(vcfg["type_tree"])) {
if(types.count(type)) {
continue;
}
if(const unit_type* ut = unit_types.find(type)) {
const auto& tree = ut->advancement_tree();
types.insert(tree.begin(), tree.end());
types.insert(type);
}
}
if(types.find(u.type_id()) == types.end()) {
return false;
}
}
// The variation_type could be a comma separated list of types
if (!vcfg["variation"].empty())
{
std::vector<std::string> types = utils::split(vcfg["variation"]);
if (std::find(types.begin(), types.end(), u.variation()) == types.end()) {
return false;
}
}
// The has_variation_type could be a comma separated list of types
if (!vcfg["has_variation"].empty())
{
bool match = false;
// If this unit is a variation itself then search in the base unit's variations.
const unit_type* const type = u.variation().empty() ? &u.type() : unit_types.find(u.type().base_id());
assert(type);
//.........这里部分代码省略.........