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

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

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


From: Guillaume Melquiond
Subject: [Wesnoth-cvs-commits] wesnoth/src cavegen.cpp
Date: Thu, 27 Jan 2005 17:38:07 -0500

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Guillaume Melquiond <address@hidden>    05/01/27 22:38:05

Modified files:
        src            : cavegen.cpp 

Log message:
        Yay, another bug... "width" is not the size of the map! And put an 
assert along the way.

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

Patches:
Index: wesnoth/src/cavegen.cpp
diff -u wesnoth/src/cavegen.cpp:1.12 wesnoth/src/cavegen.cpp:1.13
--- wesnoth/src/cavegen.cpp:1.12        Fri Jan 21 20:07:30 2005
+++ wesnoth/src/cavegen.cpp     Thu Jan 27 22:38:05 2005
@@ -277,11 +277,10 @@
        size_t windiness_;
 };
 
-double passage_path_calculator::cost(const gamemap::location& loc, double, 
bool) const
+double passage_path_calculator::cost(const gamemap::location& loc, const 
double, const bool) const
 {
-       if(loc.x < 0 || loc.y < 0 || size_t(loc.x) >= map_.size() || 
map_.empty() || size_t(loc.y) >= map_.front().size()) {
-               return 100000.0;
-       }
+       wassert(loc.x >= 0 && loc.y >= 0 && size_t(loc.x) < map_.size() &&
+               !map_.empty() && size_t(loc.y) < map_.front().size());
 
        double res = 1.0;
        if(map_[loc.x][loc.y] == wall_) {
@@ -308,11 +307,10 @@
        
        passage_path_calculator calc(map_,wall_,laziness,windiness);
        
-       const size_t width = maximum<size_t>(1,atoi(p.cfg["width"].c_str()));
-       const size_t height = maximum<size_t>(1,atoi(p.cfg["height"].c_str()));
-       
-       const paths::route rt = a_star_search(p.src, p.dst, 10000.0, &calc, 
width, height);
+       const paths::route rt = a_star_search(p.src, p.dst, 10000.0, &calc, 
width_, height_);
 
+       const size_t width = maximum<size_t>(1,atoi(p.cfg["width"].c_str()));
+
        const size_t jagged = atoi(p.cfg["jagged"].c_str());
        
        for(std::vector<gamemap::location>::const_iterator i = 
rt.steps.begin(); i != rt.steps.end(); ++i) {




reply via email to

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