当前位置: 首页>>代码示例>>C++>>正文


C++ config::child_or_empty方法代码示例

本文整理汇总了C++中config::child_or_empty方法的典型用法代码示例。如果您正苦于以下问题:C++ config::child_or_empty方法的具体用法?C++ config::child_or_empty怎么用?C++ config::child_or_empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在config的用法示例。


在下文中一共展示了config::child_or_empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

/**
 * Constructor from a config.
 */
clearer_info::clearer_info(const config & cfg) :
	underlying_id(cfg["underlying_id"].to_size_t()),
	sight_range(cfg["vision"].to_int()),
	slowed(cfg.child_or_empty("status")["slowed"].to_bool()),
	costs(cfg.child_or_empty("vision_costs"))
{
}
开发者ID:GregoryLundberg,项目名称:wesnoth,代码行数:10,代码来源:vision.cpp

示例2:

/**
 * Constructor from a config
 */
movetype::movetype(const config & cfg) :
	movement_(cfg.child_or_empty("movement_costs"), nullptr, &vision_),    // This is not access before initialization; the address is merely stored at this point.
	vision_(cfg.child_or_empty("vision_costs"), &movement_, &jamming_), // This is not access before initialization; the address is merely stored at this point.
	jamming_(cfg.child_or_empty("jamming_costs"), &vision_, nullptr),
	defense_(cfg.child_or_empty("defense")),
	resist_(cfg.child_or_empty("resistance")),
	flying_(cfg["flies"].to_bool(false))
{
}
开发者ID:ArtBears,项目名称:wesnoth,代码行数:12,代码来源:movetype.cpp

示例3:

/**
 * Constructor for when read from a saved config.
 * This is the reverse of to_config() and corresponds to reading [menu_item].
 * Handlers are not initialized.
 */
wml_menu_item::wml_menu_item(const std::string& id, const config & cfg) :
		item_id_(id),
		event_name_(make_item_name(id)),
		hotkey_id_(make_item_hotkey(id)),
		image_(cfg["image"].str()),
		description_(cfg["description"].t_str()),
		needs_select_(cfg["needs_select"].to_bool(false)),
		show_if_(cfg.child_or_empty("show_if"), true),
		filter_location_(cfg.child_or_empty("filter_location"), true),
		command_(cfg.child_or_empty("command")),
		default_hotkey_(cfg.child_or_empty("default_hotkey")),
		use_hotkey_(cfg["use_hotkey"].to_bool(true)),
		use_wml_menu_(cfg["use_hotkey"].str() != "only")
{
}
开发者ID:AI0867,项目名称:wesnoth,代码行数:20,代码来源:menu_item.cpp

示例4: config

carryover_info::carryover_info(const config& cfg, bool from_snpashot)
	: carryover_sides_()
	, variables_(cfg.child_or_empty("variables"))
	, rng_(cfg)
	, wml_menu_items_()
	, next_scenario_(cfg["next_scenario"])
	, next_underlying_unit_id_(cfg["next_underlying_unit_id"].to_int(0))
{
	for(const config& side : cfg.child_range("side"))
	{
		if(side["lost"].to_bool(false) || !side["persistent"].to_bool(true) || side["save_id"].empty())
		{
			//this shouldn't happen outside a snpshot.
			if(!from_snpashot) {
				ERR_NG << "found invalid carryover data in saved game, lost='" << side["lost"] << "' persistent='" << side["persistent"] << "' save_id='" << side["save_id"] << "'\n";
			}
			continue;
		}
		this->carryover_sides_.emplace_back(side);
	}
	for(const config& item : cfg.child_range("menu_item"))
	{
		wml_menu_items_.push_back(new config(item));
	}
}
开发者ID:GregoryLundberg,项目名称:wesnoth,代码行数:25,代码来源:carryover.cpp

示例5:

gamemap::gamemap(const tdata_cache& tdata, const config& level):
		tiles_(1),
		tdata_(tdata),
		villages_(),
		borderCache_(),
		terrainFrequencyCache_(),
		w_(-1),
		h_(-1),
		total_width_(0),
		total_height_(0),
		border_size_(gamemap::default_border)
{
	DBG_G << "loading map: '" << level.debug() << "'\n";

	const config& map_child = level.child_or_empty("map");

	if (map_child.empty()) {
		const std::string& map_data = level["map_data"];
		if (!map_data.empty()) {
			read(map_data);
		} else {
			w_ = 0;
			h_ = 0;
			total_width_ = 0;
			total_height_ = 0;
		}
	} else {
		read(map_child["data"], true);
	}
}
开发者ID:Stewie23,项目名称:wesnoth,代码行数:30,代码来源:map.cpp

示例6:

attack_type::attack_type(const config& cfg) :
	self_loc_(),
	other_loc_(),
	is_attacker_(false),
	other_attack_(nullptr),
	description_(cfg["description"].t_str()),
	id_(cfg["name"]),
	type_(cfg["type"]),
	icon_(cfg["icon"]),
	range_(cfg["range"]),
	min_range_(cfg["min_range"].to_int(1)),
	max_range_(cfg["max_range"].to_int(1)),
	damage_(cfg["damage"]),
	num_attacks_(cfg["number"]),
	attack_weight_(cfg["attack_weight"].to_double(1.0)),
	defense_weight_(cfg["defense_weight"].to_double(1.0)),
	accuracy_(cfg["accuracy"]),
	movement_used_(cfg["movement_used"].to_int(100000)),
	parry_(cfg["parry"]),
	specials_(cfg.child_or_empty("specials"))
{
	if (description_.empty())
		description_ = translation::egettext(id_.c_str());

	if(icon_.empty()){
		if (id_ != "")
			icon_ = "attacks/" + id_ + ".png";
		else
			icon_ = "attacks/blank-attack.png";
	}
}
开发者ID:aquileia,项目名称:wesnoth,代码行数:31,代码来源:attack_type.cpp

示例7:

gamemap::gamemap(const config& cfg, const config& level):
		tiles_(1),
		terrainList_(),
		tcodeToTerrain_(),
		villages_(),
		borderCache_(),
		terrainFrequencyCache_(),
		w_(-1),
		h_(-1),
		total_width_(0),
		total_height_(0),
		border_size_(gamemap::SINGLE_TILE_BORDER),
		usage_(IS_MAP)
{
	DBG_G << "loading map: '" << level.debug() << "'\n";
	const config::const_child_itors &terrains = cfg.child_range("terrain_type");
	create_terrain_maps(terrains, terrainList_, tcodeToTerrain_);

	const config& map_child = level.child_or_empty("map");

	if (map_child.empty()) {
		const std::string& map_data = level["map_data"];
		if (!map_data.empty()) {
			read(map_data);
		} else {
			w_ = 0;
			h_ = 0;
			total_width_ = 0;
			total_height_ = 0;
		}
	} else {
		read(map_child["data"], true, map_child["border_size"], map_child["usage"]);
	}
}
开发者ID:gaconkzk,项目名称:wesnoth,代码行数:34,代码来源:map.cpp

示例8: route

	shroud_clearing_action(const config& cfg)
		: route()
		, view_info(cfg.child_or_empty("unit"))
		, original_village_owner(cfg["village_owner"].to_int())
		, take_village_timebonus(cfg["village_timebonus"].to_bool())
	{
		read_locations(cfg, route);
	}
开发者ID:ArtBears,项目名称:wesnoth,代码行数:8,代码来源:shroud_clearing_action.hpp

示例9:

game_data::game_data(const config& level)
		: variable_set()
		, scoped_variables()
		, last_selected(map_location::null_location())
		, rng_(level)
		, variables_(level.child_or_empty("variables"))
		, phase_(INITIAL)
		, can_end_turn_(level["can_end_turn"].to_bool(true))
		, next_scenario_(level["next_scenario"])
{
}
开发者ID:Martin9295,项目名称:wesnoth,代码行数:11,代码来源:game_data.cpp

示例10: data

/**
 * Note that initially we get access only to readonly context (engine is created rather early, when there's no way to move/attack.
 * We inject full ai_context later.
 */
engine_lua::engine_lua( readonly_context &context, const config &cfg )
	: engine(context,cfg)
	, code_(cfg["code"])
	, lua_ai_context_(resources::lua_kernel->create_lua_ai_context(
		cfg["code"].str().c_str(), this))
{
	name_ = "lua";

	config data(cfg.child_or_empty("data"));
	lua_ai_context_->set_persistent_data(data);
}
开发者ID:AG-Dev,项目名称:wesnoth_ios,代码行数:15,代码来源:engine_lua.cpp

示例11:

carryover::carryover(const config& side)
		: add_(!side["carryover_add"].empty() ? side["carryover_add"].to_bool() : side["add"].to_bool())
		, current_player_(side["current_player"])
		, gold_(!side["carryover_gold"].empty() ? side["carryover_gold"].to_int() : side["gold"].to_int())
		// if we load it from a snapshot we need to read the recruits from "recruits" and not from "previous_recruits".
		, previous_recruits_(side.has_attribute("recruit") ? utils::set_split(side["recruit"]) :utils::set_split(side["previous_recruits"]))
		, recall_list_()
		, save_id_(side["save_id"])
		, variables_(side.child_or_empty("variables"))
{
	for(const config& u : side.child_range("unit")) {
		recall_list_.push_back(u);
		config& u_back = recall_list_.back();
		u_back.remove_attributes("side", "goto_x", "goto_y", "x", "y", "hidden");
	}
}
开发者ID:GregoryLundberg,项目名称:wesnoth,代码行数:16,代码来源:carryover.cpp

示例12: data

/**
 * Note that initially we get access only to readonly context (engine is created rather early, when there's no way to move/attack.
 * We inject full ai_context later.
 */
engine_lua::engine_lua( readonly_context &context, const config &cfg )
	: engine(context,cfg)
	, code_(get_engine_code(cfg))
	, lua_ai_context_(resources::lua_kernel->create_lua_ai_context(
		get_engine_code(cfg).c_str(), this))
{
	name_ = "lua";
	config data(cfg.child_or_empty("data"));
	config args(cfg.child_or_empty("args"));

	if (lua_ai_context_) { // The context might be nullptr if the config contains errors
		lua_ai_context_->set_persistent_data(data);
		lua_ai_context_->set_arguments(args);
		lua_ai_context_->update_state();
	}
}
开发者ID:aquileia,项目名称:wesnoth,代码行数:20,代码来源:engine_lua.cpp

示例13: name

mp_game_settings::mp_game_settings(const config& cfg)
	: name(cfg["scenario"].str())
	, password()
	, hash(cfg["hash"].str())
	, mp_era(cfg["mp_era"].str())
	, mp_era_addon_id(cfg["mp_era_addon_id"].str())
	, mp_scenario(cfg["mp_scenario"].str())
	, mp_scenario_name(cfg["mp_scenario_name"].str())
	, mp_campaign(cfg["mp_campaign"].str())
	, active_mods(utils::split(cfg["active_mods"], ','))
	, side_users(utils::map_split(cfg["side_users"]))
	, show_connect(cfg["show_connect"].to_bool(true))
	, num_turns(cfg["mp_num_turns"])
	, village_gold(cfg["mp_village_gold"])
	, village_support(cfg["mp_village_support"])
	, xp_modifier(cfg["experience_modifier"].to_int(100))
	, mp_countdown_init_time(cfg["mp_countdown_init_time"])
	, mp_countdown_reservoir_time(cfg["mp_countdown_reservoir_time"])
	, mp_countdown_turn_bonus(cfg["mp_countdown_turn_bonus"])
	, mp_countdown_action_bonus(cfg["mp_countdown_action_bonus"])
	, mp_countdown(cfg["mp_countdown"].to_bool())
	, use_map_settings(cfg["mp_use_map_settings"].to_bool())
	, random_start_time(cfg["mp_random_start_time"].to_bool())
	, fog_game(cfg["mp_fog"].to_bool())
	, shroud_game(cfg["mp_shroud"].to_bool())
	, allow_observers(cfg["observer"].to_bool())
	, registered_users_only(cfg["registered_users_only"].to_bool())
	, shuffle_sides(cfg["shuffle_sides"].to_bool())
	, saved_game(cfg["savegame"].to_bool())
	, random_faction_mode(cfg["random_faction_mode"].to_enum<RANDOM_FACTION_MODE>(RANDOM_FACTION_MODE::DEFAULT))
	, options(cfg.child_or_empty("options"))
	, addons()
{
	for (const config & a : cfg.child_range("addon")) {
		if (!a["id"].empty()) {
			addons.insert(std::make_pair(a["id"].str(), addon_version_info(a)));
		}
	}
}
开发者ID:Wedge009,项目名称:wesnoth,代码行数:39,代码来源:mp_game_settings.cpp

示例14: config

carryover_info::carryover_info(const config& cfg, bool from_snpashot)
	: carryover_sides_()
	, variables_(cfg.child_or_empty("variables"))
	, rng_(cfg)
	, wml_menu_items_()
	, next_scenario_(cfg["next_scenario"])
	, next_underlying_unit_id_(cfg["next_underlying_unit_id"].to_int(0))
{
	for(const config& side : cfg.child_range("side"))
	{
		if(side["lost"].to_bool(false) || !side["persistent"].to_bool(true))
		{
			//this shouldnt happen outside a snpshot.
			assert(from_snpashot);
			continue;
		}
		this->carryover_sides_.push_back(carryover(side));
	}
	for(const config& item : cfg.child_range("menu_item"))
	{
		wml_menu_items_.push_back(new config(item));
	}
}
开发者ID:PoignardAzur,项目名称:wesnoth,代码行数:23,代码来源:carryover.cpp

示例15: id

game_info::game_info(const config& game, const config& game_config)
	: mini_map()
	, id(game["id"])
	, map_data(game["map_data"])
	, name(game["name"])
	, scenario()
	, remote_scenario(false)
	, map_info()
	, map_size_info()
	, era()
	, era_short()
	, gold(game["mp_village_gold"])
	, support(game["mp_village_support"])
	, xp(game["experience_modifier"].str() + "%")
	, vision()
	, status()
	, time_limit()
	, vacant_slots(lexical_cast_default<int>(game["slots"],
											 0)) // Can't use to_int() here.
	, current_turn(0)
	, reloaded(game["savegame"].to_bool())
	, started(false)
	, fog(game["mp_fog"].to_bool())
	, shroud(game["mp_shroud"].to_bool())
	, observers(game["observer"].to_bool(true))
	, shuffle_sides(game["shuffle_sides"].to_bool(true))
	, use_map_settings(game["mp_use_map_settings"].to_bool())
	, verified(true)
	, password_required(game["password"].to_bool())
	, have_era(true)
	, have_all_mods(true)
	, has_friends(false)
	, has_ignored(false)
	, display_status(NEW)
{
	std::string turn = game["turn"];
	if(!game["mp_era"].empty()) {
		const config& era_cfg
				= game_config.find_child("era", "id", game["mp_era"]);
		utils::string_map symbols;
		symbols["era_id"] = game["mp_era"];
		if(era_cfg) {
			era = era_cfg["name"].str();
			era_short = era_cfg["short_name"].str();
			if(era_short.empty()) {
				era_short = make_short_name(era);
			}
		} else {
			have_era = !game["require_era"].to_bool(true);
			era = vgettext("Unknown era: $era_id", symbols);
			era_short = "?" + make_short_name(era);
			verified = false;
		}
	} else {
		era = _("Unknown era");
		era_short = "??";
		verified = false;
	}
	map_info = era;

	if(!game.child_or_empty("modification").empty()) {
		BOOST_FOREACH(const config &cfg, game.child_range("modification")) {
			if (cfg["require_modification"].to_bool(false)) {
				const config &mod = game_config.find_child("modification", "id",
														   cfg["id"]);
				if (!mod) {
					have_all_mods = false;
					break;
				}
			}
		}
	}
开发者ID:Martin9295,项目名称:wesnoth,代码行数:72,代码来源:lobby_data.cpp


注:本文中的config::child_or_empty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。