Author: fendrin
Date: Tue Jan 12 05:03:44 2010
New Revision: 40677
URL: http://svn.gna.org/viewcvs/wesnoth?rev=40677&view=rev
Log:
Fixed the mage teleportation. Hurray!
Modified:
branches/fendrin_pathfind/src/astarsearch.cpp
branches/fendrin_pathfind/src/pathfind.cpp
Modified: branches/fendrin_pathfind/src/astarsearch.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/fendrin_pathfind/src/astarsearch.cpp?rev=40677&r1=40676&r2=40677&view=diff
==============================================================================
--- branches/fendrin_pathfind/src/astarsearch.cpp (original)
+++ branches/fendrin_pathfind/src/astarsearch.cpp Tue Jan 12 05:03:44 2010
@@ -204,7 +204,7 @@
int i;
if (!teleports->empty()) {
- std::set<map_location> allowed_teleports =
teleports->get_adjacents(n.curr);
+ const std::set<map_location>& allowed_teleports =
teleports->get_adjacents(n.curr);
// teleports_iterator = teleports->get_adjacents(n.curr);
// i = teleports_iterator != teleports->end() ?
(*(teleports_iterator->second)).size() + 6 : 6;
@@ -228,6 +228,7 @@
}
if (!locs[i].valid(width, height)) continue;
+ if (locs[i] == n.curr) continue;
node& next = nodes[index(locs[i])];
double thresh = (next.in - search_counter <= 1u) ?
next.g : stop_at;
@@ -255,6 +256,7 @@
route.move_cost = static_cast<int>(nodes[index(dst)].g);
for (node curr = nodes[index(dst)]; curr.prev !=
map_location::null_location; curr = nodes[index(curr.prev)]) {
route.steps.push_back(curr.curr);
+ ERR_PF << "sowas\n";
}
route.steps.push_back(src);
std::reverse(route.steps.begin(), route.steps.end());
@@ -262,7 +264,7 @@
LOG_PF << "aborted a* search " << "\n";
route.move_cost = static_cast<int>(calc->getNoPathValue());
}
-
+ ERR_PF << "fertig\n";
return route;
}
Modified: branches/fendrin_pathfind/src/pathfind.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/fendrin_pathfind/src/pathfind.cpp?rev=40677&r1=40676&r2=40677&view=diff
==============================================================================
--- branches/fendrin_pathfind/src/pathfind.cpp (original)
+++ branches/fendrin_pathfind/src/pathfind.cpp Tue Jan 12 05:03:44 2010
@@ -40,14 +40,19 @@
teleport_map::teleport_map(std::vector<teleport_group> groups) :
teleport_map_(), sources_(), destinations_(), empty_() {
- sources_.push_back(std::set<map_location>() );
-
- for (std::vector<teleport_group>::iterator i = groups.begin(); i !=
groups.end(); i++) {
- sources_.push_back(i->first);
- destinations_.push_back(i->second);
- for(std::set<map_location>::iterator it = i->first.begin(); it
!= i->first.end(); it++) {
- teleport_map_.insert(std::make_pair(*it, &(i->second)));
- }
+ //sources_.push_back(std::set<map_location>() );
+
+ 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++) {
+ teleport_map_.insert(std::make_pair(*it2,
&(*destinations_it)));
+ }
+ destinations_it++;
}
// foreach (const teleport_group& group, groups) {
@@ -63,8 +68,13 @@
// const std::set<map_location> ret = sources_[0];
return empty_;
} else {
-// const std::set<map_location>& ret =
*(teleport_map_.find(loc)->second);
- return *(teleport_map_.find(loc)->second);
+
+ const std::set<map_location>& ret =
*(teleport_map_.find(loc)->second);
+ for (std::set<map_location>::const_iterator it = ret.begin();
it != ret.end(); it++) {
+ ERR_PF << it->x << "/" << it->y << "\n";
+ }
+ // return *(teleport_map_.find(loc)->second);
+ return ret;
}
// return ret;
@@ -317,6 +327,8 @@
for (int i = locs.size(); i-- > 0; ) {
if (!locs[i].valid(map.w(), map.h())) continue;
+ if (locs[i] == n.curr) continue;
+
node& next = nodes[index(locs[i])];
bool next_visited = next.in - search_counter <= 1u;
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits