Author: mordante
Date: Sun Mar 6 20:08:17 2011
New Revision: 48804
URL: http://svn.gna.org/viewcvs/wesnoth?rev=48804&view=rev
Log:
Improve pathfind::teleport_map constructor.
Remove an unused parameter.
Send a not modified vector as const ref instead as copy.
Make some other parameters const as well.
Modified:
trunk/src/pathfind/teleport.cpp
trunk/src/pathfind/teleport.hpp
Modified: trunk/src/pathfind/teleport.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/pathfind/teleport.cpp?rev=48804&r1=48803&r2=48804&view=diff
==============================================================================
--- trunk/src/pathfind/teleport.cpp (original)
+++ trunk/src/pathfind/teleport.cpp Sun Mar 6 20:08:17 2011
@@ -92,14 +92,22 @@
return retval;
}
-pathfind::teleport_map::teleport_map(std::vector<teleport_group> groups, const
unit& u, const unit_map &/*units*/, const team &viewing_team, bool see_all,
bool ignore_units)
- : teleport_map_(), sources_(), targets_() {
-
- for (std::vector<teleport_group>::iterator it = groups.begin(); it !=
groups.end(); ++it) {
+pathfind::teleport_map::teleport_map(
+ const std::vector<teleport_group>& groups
+ , const unit& u
+ , const team &viewing_team
+ , const bool see_all
+ , const bool ignore_units)
+ : teleport_map_()
+ , sources_()
+ , targets_()
+{
+
+ foreach(const teleport_group& group, groups) {
teleport_pair locations;
- it->get_teleport_pair(locations, u, ignore_units);
- if (!see_all && !it->always_visible() &&
viewing_team.is_enemy(u.side())) {
+ group.get_teleport_pair(locations, u, ignore_units);
+ if (!see_all && !group.always_visible() &&
viewing_team.is_enemy(u.side())) {
teleport_pair filter_locs;
foreach(const map_location &loc, locations.first)
if(!viewing_team.fogged(loc))
@@ -110,7 +118,7 @@
locations.first.swap(filter_locs.first);
locations.second.swap(filter_locs.second);
}
- std::string teleport_id = it->get_teleport_id();
+ std::string teleport_id = group.get_teleport_id();
std::set<map_location>::iterator source_it =
locations.first.begin();
for (; source_it != locations.first.end(); ++source_it ) {
@@ -184,7 +192,7 @@
const std::vector<teleport_group>& global_groups =
resources::tunnels->get();
groups.insert(groups.end(), global_groups.begin(), global_groups.end());
- return teleport_map(groups, u, *resources::units, viewing_team,
see_all, ignore_units);
+ return teleport_map(groups, u, viewing_team, see_all, ignore_units);
}
pathfind::manager::manager(const config &cfg) : tunnels_(),
id_(lexical_cast_default<int>(cfg["next_teleport_group_id"], 0)) {
Modified: trunk/src/pathfind/teleport.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/pathfind/teleport.hpp?rev=48804&r1=48803&r2=48804&view=diff
==============================================================================
--- trunk/src/pathfind/teleport.hpp (original)
+++ trunk/src/pathfind/teleport.hpp Sun Mar 6 20:08:17 2011
@@ -74,9 +74,13 @@
class teleport_map {
public:
- teleport_map(std::vector<teleport_group> teleport_groups, const unit& u,
- const unit_map &units, const team &viewing_team, bool
see_all,
- bool ignore_units);
+ teleport_map(
+ const std::vector<teleport_group>& teleport_groups
+ , const unit& u
+ , const team &viewing_team
+ , const bool see_all
+ , const bool ignore_units);
+
teleport_map() :
teleport_map_(), sources_(), targets_() {
}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits