diff options
author | Raphael Langella <raphael.langella@gmail.com> | 2012-08-26 22:50:06 +0200 |
---|---|---|
committer | Raphael Langella <raphael.langella@gmail.com> | 2012-08-26 23:06:30 +0200 |
commit | 770bcbd1844b97b671d0e47ea8313cdf2c74c5ea (patch) | |
tree | e030cf61afce9ca69b74bb38eb73734bf10f633e /crawl-ref/source/mon-pathfind.cc | |
parent | a6c16c7f2066c854a01f25e9e6c3d8e44282a638 (diff) | |
download | crawl-ref-770bcbd1844b97b671d0e47ea8313cdf2c74c5ea.tar.gz crawl-ref-770bcbd1844b97b671d0e47ea8313cdf2c74c5ea.zip |
Use std namespace.
I had to rename distance() (in coord.h) to distance2() because it conflicts
with the STL function to compare 2 iterators. Not a bad change given how it
returns the square of the distance anyway.
I also had to rename the message global variable (in message.cc) to buffer.
I tried to fix and improve the coding style has much as I could, but I
probably missed a few given how huge and tedious it is.
I also didn't touch crawl-gdb.py, and the stuff in prebuilt, rltiles/tool
and util/levcomp.*, because I have no clue about those.
Diffstat (limited to 'crawl-ref/source/mon-pathfind.cc')
-rw-r--r-- | crawl-ref/source/mon-pathfind.cc | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/crawl-ref/source/mon-pathfind.cc b/crawl-ref/source/mon-pathfind.cc index cee7639fbd..eca2d185d4 100644 --- a/crawl-ref/source/mon-pathfind.cc +++ b/crawl-ref/source/mon-pathfind.cc @@ -233,7 +233,7 @@ bool monster_pathfind::calc_path_to_neighbours() continue; #ifdef DEBUG_PATHFIND - mprf("old dist: %d, new dist: %d, infinite: %d", old_dist, distance, + mprf("old dist: %d, new dist: %d, infinite: %d", old_dist, distance2, INFINITE_DISTANCE); #endif // If the new distance is better than the old one (initialised with @@ -298,7 +298,7 @@ bool monster_pathfind::get_best_position() if (i > min_length) min_length = i; - std::vector<coord_def> &vec = hash[i]; + vector<coord_def> &vec = hash[i]; // Pick the last position pushed into the vector as it's most // likely to be close to the target. pos = vec[vec.size()-1]; @@ -322,12 +322,12 @@ bool monster_pathfind::get_best_position() // Using the prev vector backtrack from start to target to find all steps to // take along the shortest path. -std::vector<coord_def> monster_pathfind::backtrack() +vector<coord_def> monster_pathfind::backtrack() { #ifdef DEBUG_PATHFIND mpr("Backtracking..."); #endif - std::vector<coord_def> path; + vector<coord_def> path; pos = target; path.push_back(pos); @@ -362,15 +362,15 @@ std::vector<coord_def> monster_pathfind::backtrack() // This is done because Crawl's pathfinding - once a target is in sight and easy // reach - is both very robust and natural, especially if we want to flexibly // avoid plants and other monsters in the way. -std::vector<coord_def> monster_pathfind::calc_waypoints() +vector<coord_def> monster_pathfind::calc_waypoints() { - std::vector<coord_def> path = backtrack(); + vector<coord_def> path = backtrack(); // If no path found, nothing to be done. if (path.empty()) return path; - std::vector<coord_def> waypoints; + vector<coord_def> waypoints; pos = path[0]; #ifdef DEBUG_PATHFIND @@ -515,7 +515,7 @@ void monster_pathfind::update_pos(coord_def npos, int total) // then call_add_new_pos. int old_total = dist[npos.x][npos.y] + estimated_cost(npos); - std::vector<coord_def> &vec = hash[old_total]; + vector<coord_def> &vec = hash[old_total]; for (unsigned int i = 0; i < vec.size(); i++) { if (vec[i] == npos) |