Author: ai0867
Date: Tue Jan 12 19:49:58 2010
New Revision: 40682
URL: http://svn.gna.org/viewcvs/wesnoth?rev=40682&view=rev
Log:
Add commented-out logging. Somewhat improve teleport_map's constructor
Modified:
branches/fendrin_pathfind/src/pathfind.cpp
Modified: branches/fendrin_pathfind/src/pathfind.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/fendrin_pathfind/src/pathfind.cpp?rev=40682&r1=40681&r2=40682&view=diff
==============================================================================
--- branches/fendrin_pathfind/src/pathfind.cpp (original)
+++ branches/fendrin_pathfind/src/pathfind.cpp Tue Jan 12 19:49:58 2010
@@ -40,17 +40,30 @@
teleport_map::teleport_map(std::vector<teleport_group> groups) :
teleport_map_(), sources_(), destinations_(), empty_() {
- for (std::vector<teleport_group>::iterator it = groups.begin(); it !=
groups.end(); it++) {
+ for (std::vector<teleport_group>::iterator it = groups.begin(); it !=
groups.end(); ++it) {
sources_.push_back(it->first);
destinations_.push_back(it->second);
}
std::vector<std::set<map_location> >::iterator destinations_it =
destinations_.begin();
- for (std::vector<std::set<map_location> >::iterator it =
sources_.begin(); it != sources_.end(); it++) {
- for (std::set<map_location>::iterator it2 = it->begin(); it2 !=
it->end(); it2++) {
+ std::vector<std::set<map_location> >::iterator sources_it =
sources_.begin();
+ for (; sources_it != sources_.end() && destinations_it !=
destinations_.end();) {
+ for (std::set<map_location>::iterator it2 =
sources_it->begin(); it2 != sources_it->end(); ++it2) {
+ //std::stringstream ss;
+ //ss << "Adding teleporter: (" << it2->x << ',' <<
it2->y << ") -> ";
+ //foreach(const map_location &dest, (*destinations_it))
+ // ss << '(' << dest.x << ',' << dest.y << "),";
+ //ss << "\n";
+ //ERR_PF << ss.str();
teleport_map_.insert(std::make_pair(*it2,
&(*destinations_it)));
}
- destinations_it++;
+ ++sources_it;
+ ++destinations_it;
+ }
+ if (sources_it != sources_.end()) {
+ ERR_PF << "More sources than destinations\n";
+ } else if (destinations_it != destinations_.end()) {
+ ERR_PF << "More destinations than sources\n";
}
}
@@ -63,9 +76,11 @@
} else {
const std::set<map_location>& ret =
*(teleport_map_.find(loc)->second);
//TODO remove debug output
-// for (std::set<map_location>::const_iterator it = ret.begin();
it != ret.end(); it++) {
-// ERR_PF << it->x << "/" << it->y << "\n";
-// }
+ //ERR_PF << "Getting adjacents:\n";
+ //for (std::set<map_location>::const_iterator it = ret.begin();
it != ret.end(); ++it) {
+ // ERR_PF << "location: (" << it->x << ',' << it->y <<
")\n";
+ // assert(it->valid(200,200)); // Reasonable map-size
assumption
+ //}
return ret;
}
}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits