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


C++ unit_map::end方法代码示例

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


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

示例1: install_

		uint32_t install_(const std::string& fpath)
		{
			unit_map_cit cit = unit_map_.find(fpath);
			if(cit != unit_map_.end()) {  // find it !, To be not install.
				return 0;
			}

			auto tpath = strip_last_of_delimita_path(fpath);
			auto bpath = get_file_path(tpath);
			bpath += '/';

			unit_map_it it = unit_map_.find(bpath);
			if(it != unit_map_.end()) {
				unit_t& t = it->second;
				std::string name = get_file_name(tpath);
				if(fpath.back() == '/') name += '/';
				t.install_child(name);
			}

			uint32_t hnd = handle_set_.create();
			unit_t u;
			u.set_id(hnd);
			unit_map_.emplace(fpath, u);
			return hnd;
		}
开发者ID:hirakuni45,项目名称:glfw3_app,代码行数:25,代码来源:tree_unit.hpp

示例2: backstab_check

bool backstab_check(const map_location& attacker_loc,
                    const map_location& defender_loc,
                    const unit_map& units, const std::vector<team>& teams)
{
	const unit_map::const_iterator defender = units.find(defender_loc);
	if(defender == units.end()) return false; // No defender

	map_location adj[6];
	get_adjacent_tiles(defender_loc, adj);
	int i;
	for(i = 0; i != 6; ++i) {
		if(adj[i] == attacker_loc)
			break;
	}
	if(i >= 6) return false;  // Attack not from adjacent location

	const unit_map::const_iterator opp =
		units.find(adj[(i+3)%6]);
	if(opp == units.end()) return false; // No opposite unit
	if (opp->incapacitated()) return false;
	if (size_t(defender->side() - 1) >= teams.size() || size_t(opp->side() - 1) >= teams.size())
		return true; // If sides aren't valid teams, then they are enemies
	if (teams[defender->side() - 1].is_enemy(opp->side()))
		return true; // Defender and opposite are enemies
	return false; // Defender and opposite are friends
}
开发者ID:Coffee--,项目名称:wesnoth-old,代码行数:26,代码来源:attack.cpp

示例3: reset

void move_unit_spectator::reset(const unit_map &units)
{
	ambusher_ = units.end();
	failed_teleport_ = units.end();
	seen_enemies_.clear();
	seen_friends_.clear();
	unit_ = units.end();
}
开发者ID:kreuz,项目名称:wesnoth,代码行数:8,代码来源:move.cpp

示例4: get_sub_directory

		//-----------------------------------------------------------------//
		utils::strings get_sub_directory(const std::string& root, bool full)
		{
			utils::strings list;

			auto fpath = create_full_path(root);
			if(fpath.empty()) {
				return list;
			}

			if(fpath.back() != '/') fpath += '/';

			unit_map_it it = unit_map_.find(fpath);
			if(it != unit_map_.end()) {
				const typename unit_t::childs& chs = it->second.get_childs();
				list.resize(chs.size());
				list.clear();
				for(const auto& s : chs) {
					if(full) {
						list.push_back(fpath + strip_last_of_delimita_path(s));
					} else {
						list.push_back(s);
					}
				}
			}
			return list;
		}
开发者ID:hirakuni45,项目名称:glfw3_app,代码行数:27,代码来源:tree_unit.hpp

示例5: apply_temp_modifier

void move::apply_temp_modifier(unit_map& unit_map)
{
	if (get_source_hex() == get_dest_hex())
		return; //zero-hex move, used by attack subclass

	// Safety: Make sure the old temporary_unit_mover (if any) is destroyed
	// before creating a new one.
	mover_.reset();

	//@todo: deal with multi-turn moves, which may for instance end their first turn
	// by capturing a village

	//@todo: we may need to change unit status here and change it back in remove_temp_modifier
	unit* unit;
	{
		unit_map::iterator unit_it = unit_map.find(get_source_hex());
		assert(unit_it != unit_map.end());
		unit = &*unit_it;
	}

	//Modify movement points
	DBG_WB <<"Move: Changing movement points for unit " << unit->name() << " [" << unit->id()
			<< "] from " << unit->movement_left() << " to "
			<< unit->movement_left() - movement_cost_ << ".\n";
	// Move the unit
	DBG_WB << "Move: Temporarily moving unit " << unit->name() << " [" << unit->id()
			<< "] from (" << get_source_hex() << ") to (" << get_dest_hex() <<")\n";
	mover_.reset(new temporary_unit_mover(unit_map, get_source_hex(), get_dest_hex(),
	                                      unit->movement_left() - movement_cost_));

	//Update status of fake unit (not undone by remove_temp_modifiers)
	//@todo this contradicts the name "temp_modifiers"
	fake_unit_->set_movement(unit->movement_left(), true);
}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例6: time_of_day_at

time_of_day tod_manager::time_of_day_at(const unit_map& units,const map_location& loc, const gamemap& map) const
{
	int lighten = std::max<int>(map.get_terrain_info(map.get_terrain(loc)).light_modification() , 0);
	int darken = std::min<int>(map.get_terrain_info(map.get_terrain(loc)).light_modification() , 0);

	time_of_day tod = get_time_of_day(lighten + darken,loc);

	if(loc.valid()) {
		map_location locs[7];
		locs[0] = loc;
		get_adjacent_tiles(loc,locs+1);

		for(int i = 0; i != 7; ++i) {
			const unit_map::const_iterator itor = units.find(locs[i]);
			if(itor != units.end() &&
			    itor->second.get_ability_bool("illuminates") &&
			    !itor->second.incapacitated())
			{
				unit_ability_list illum = itor->second.get_abilities("illuminates");
				unit_abilities::effect illum_effect(illum,lighten,false);
				int mod = illum_effect.get_composite_value();
				if(mod + tod.lawful_bonus > illum.highest("max_value").first) {
					mod = illum.highest("max_value").first - tod.lawful_bonus;
				}
				lighten = std::max<int>(mod, lighten);
				darken = std::min<int>(mod, darken);
			}
		}
	}
	tod = get_time_of_day(lighten + darken,loc);

	return tod;
}
开发者ID:oys0317,项目名称:opensanguo,代码行数:33,代码来源:tod_manager.cpp

示例7: verify

static void verify(const unit_map& units, const config& cfg) {
	std::stringstream errbuf;
	LOG_REPLAY << "verifying unit structure...\n";

	const size_t nunits = cfg["num_units"].to_size_t();
	if(nunits != units.size()) {
		errbuf << "SYNC VERIFICATION FAILED: number of units from data source differ: "
			   << nunits << " according to data source. " << units.size() << " locally\n";

		std::set<map_location> locs;
		BOOST_FOREACH(const config &u, cfg.child_range("unit"))
		{
			const map_location loc(u);
			locs.insert(loc);

			if(units.count(loc) == 0) {
				errbuf << "data source says there is a unit at "
					   << loc << " but none found locally\n";
			}
		}

		for(unit_map::const_iterator j = units.begin(); j != units.end(); ++j) {
			if (locs.count(j->get_location()) == 0) {
				errbuf << "local unit at " << j->get_location()
					   << " but none in data source\n";
			}
		}
		replay::process_error(errbuf.str());
		errbuf.clear();
	}
开发者ID:nguyenducnhaty,项目名称:wesnoth,代码行数:30,代码来源:replay.cpp

示例8: install_

		bool install_(const std::string& key, const T& value)
		{
			std::string fpath;
			if(!create_full_path(key, fpath)) {
				return false;
			}

			bool f = false;
			utils::strings ss = split_text(fpath, "/");
			std::string p;
			for(uint32_t i = 0; i < ss.size(); ++i) {
				p += '/';
				p += ss[i];
				unit_t u;
				u.value = value;
				u.set_id(serial_id_);
				std::pair<unit_map_it, bool> ret = unit_map_.insert(unit_pair(p, u));
				if(ret.second) {
					++serial_id_;
					auto prev = utils::get_file_path(p);
					if(p != prev) {
						unit_map_it it = unit_map_.find(prev);
						if(it != unit_map_.end()) {
							unit_t& t = it->second;
							t.install_child(utils::get_file_name(p));
						}
					}
					f = true;
				} else {
					f = false;
				}
			}
			return f;
		}
开发者ID:hirakuni45,项目名称:glfw3_app,代码行数:34,代码来源:tree_unit.hpp

示例9: is_directory

		//-----------------------------------------------------------------//
		bool is_directory(unit_map_cit cit) const
		{
			if(cit != unit_map_.end()) {
				return cit->first.back() == '/';
			} else {
				return false;
			}
		}
开发者ID:hirakuni45,项目名称:glfw3_app,代码行数:9,代码来源:tree_unit.hpp

示例10:

unit_map::unit_map(const unit_map& that)
	: umap_()
	, lmap_()
{
	for (const_unit_iterator i = that.begin(); i != that.end(); ++i) {
		add(i->get_location(), *i);
	}
}
开发者ID:niegenug,项目名称:wesnoth,代码行数:8,代码来源:unit_map.cpp

示例11: create_list

		//-----------------------------------------------------------------//
		unit_map_its create_list(const std::string& root)
		{
			unit_map_its list;
			if(unit_map_.empty()) {
				list.clear();
				return list;
			}

			if(root.empty()) {
				list.resize(unit_map_.size());
				list.clear();
				for(unit_map_it it = unit_map_.begin(); it != unit_map_.end(); ++it) {
					list.push_back(it);
				}
			} else {
				auto fpath = create_full_path(root);
				if(fpath.empty()) {
					list.clear();
					return list;
				}

				unit_map_it it = unit_map_.find(fpath);
				if(it != unit_map_.end()) {
					const typename unit_t::childs& ch = it->second.get_childs();
					list.resize(ch.size());
					list.clear();
					for(const auto& s : ch) {
						auto path = create_full_path(s);
						if(!path.empty()) {
							it = unit_map_.find(path);
							if(it != unit_map_.end()) {
								list.push_back(it);
							}
						}
					}
				} else {
					list.clear();
				}
			}

			std::sort(list.begin(), list.end(), [] (unit_map_it l, unit_map_it r) {
				return l->first < r->first; }
			);

			return list;
		}
开发者ID:hirakuni45,项目名称:glfw3_app,代码行数:47,代码来源:tree_unit.hpp

示例12:

std::pair<int, map_location> under_leadership(const unit_map& units, const map_location& loc)
{
	const unit_map::const_iterator un = units.find(loc);
	if(un == units.end()) {
		return {0, map_location::null_location()};
	}

	unit_ability_list abil = un->get_abilities("leadership");
	return abil.highest("value");
}
开发者ID:fluffbeast,项目名称:wesnoth-old,代码行数:10,代码来源:attack.cpp

示例13:

unit_map::unit_map(const unit_map& that) :
	/* Initialize to silence compiler warnings. */
	map_(),
	lmap_(),
	num_iters_(0),
	num_invalid_(0)
{
	for (const_unit_iterator i = that.begin(); i != that.end(); i++) {
		add(i->first, i->second);
	}
}
开发者ID:oys0317,项目名称:opensanguo,代码行数:11,代码来源:unit_map.cpp

示例14: under_leadership

map_location under_leadership(const unit_map& units, const map_location& loc,
                              int* bonus)
{
	const unit_map::const_iterator un = units.find(loc);
	if(un == units.end()) {
		return map_location::null_location;
	}
	unit_ability_list abil = un->get_abilities("leadership");
	if(bonus) {
		*bonus = abil.highest("value").first;
	}
	return abil.highest("value").second;
}
开发者ID:Coffee--,项目名称:wesnoth-old,代码行数:13,代码来源:attack.cpp

示例15: find

		//-----------------------------------------------------------------//
		uint32_t find(const std::string& path) const {
			auto fpath = create_full_path(path);
			if(fpath.empty()) {
				return 0;
			}

			unit_map_cit cit = unit_map_.find(fpath);
			if(cit != unit_map_.end()) {
				return cit->second.get_id();
			} else {
				return 0;
			}
		}
开发者ID:hirakuni45,项目名称:glfw3_app,代码行数:14,代码来源:tree_unit.hpp


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