wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src pathfind.cpp


From: David White
Subject: [Wesnoth-cvs-commits] wesnoth/src pathfind.cpp
Date: Thu, 14 Oct 2004 20:23:53 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     David White <address@hidden>    04/10/15 00:16:31

Modified files:
        src            : pathfind.cpp 

Log message:
        fixed bug where STARTING_VILLAGES macro didn't work properly

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/pathfind.cpp.diff?tr1=1.43&tr2=1.44&r1=text&r2=text

Patches:
Index: wesnoth/src/pathfind.cpp
diff -u wesnoth/src/pathfind.cpp:1.43 wesnoth/src/pathfind.cpp:1.44
--- wesnoth/src/pathfind.cpp:1.43       Thu Oct  7 01:47:33 2004
+++ wesnoth/src/pathfind.cpp    Fri Oct 15 00:16:31 2004
@@ -1,4 +1,4 @@
-/* $Id: pathfind.cpp,v 1.43 2004/10/07 01:47:33 Sirp Exp $ */
+/* $Id: pathfind.cpp,v 1.44 2004/10/15 00:16:31 Sirp Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -102,28 +102,30 @@
        std::set<gamemap::location>& res)
 {
        typedef std::set<gamemap::location> location_set;
-       location_set not_visited(locs.begin(), locs.end()), must_visit, visited;
+       location_set not_visited(locs.begin(), locs.end()), must_visit;
        ++radius;
 
        for(;;) {
                location_set::const_iterator it = not_visited.begin(), it_end = 
not_visited.end();
-               std::copy(it,it_end,std::inserter(visited,visited.end()));
+               std::copy(it,it_end,std::inserter(res,res.end()));
                for(; it != it_end; ++it) {
                        gamemap::location adj[6];
                        get_adjacent_tiles(*it, adj);
                        for(size_t i = 0; i != 6; ++i) {
                                gamemap::location const &loc = adj[i];
-                               if (!map.on_board(loc)) continue;
-                               if (visited.find(loc) != visited.end()) 
continue;
-                               must_visit.insert(loc);
+                               if(map.on_board(loc) && res.count(loc) == 0) {
+                                       must_visit.insert(loc);
+                               }
                        }
                }
 
-               if (--radius == 0 || must_visit.empty()) break;
+               if(--radius == 0 || must_visit.empty()) {
+                       break;
+               }
+
                not_visited.swap(must_visit);
                must_visit.clear();
        }
-       
std::copy(visited.begin(),visited.end(),std::inserter(visited,visited.end()));
 }
 
 bool enemy_zoc(const gamemap& map, const gamestatus& status, 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]