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

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

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


From: David White
Subject: [Wesnoth-cvs-commits] wesnoth/src mapgen.cpp
Date: Sun, 23 Jan 2005 09:25:29 -0500

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     David White <address@hidden>    05/01/23 14:25:28

Modified files:
        src            : mapgen.cpp 

Log message:
        re-committed silene's changes that I accidentally deleted

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

Patches:
Index: wesnoth/src/mapgen.cpp
diff -u wesnoth/src/mapgen.cpp:1.53 wesnoth/src/mapgen.cpp:1.54
--- wesnoth/src/mapgen.cpp:1.53 Sat Jan 22 12:08:46 2005
+++ wesnoth/src/mapgen.cpp      Sun Jan 23 14:25:25 2005
@@ -19,7 +19,10 @@
 #include "pathfind.hpp"
 #include "race.hpp"
 #include "scoped_resource.hpp"
-#include "util.hpp"
+#include "util.hpp"
+
+#define ERR_CF lg::err(lg::config)
+#define LOG_NG lg::info(lg::engine)
 
 //function to generate a random map, from a string which describes
 //the generator to use and its arguments
@@ -30,8 +33,8 @@
        std::vector<std::string> parameters = config::split(parms,' ');
        util::scoped_ptr<map_generator> 
generator(create_map_generator(parameters.front(),cfg));
        if(generator == NULL) {
-               std::cerr << "could not find map generator '" << 
parameters.front() << "'\n";
-               return "";
+               ERR_CF << "could not find map generator '" << 
parameters.front() << "'\n";
+               return std::string();
        }
 
        parameters.erase(parameters.begin());
@@ -45,7 +48,7 @@
        std::vector<std::string> parameters = config::split(parms,' ');
        util::scoped_ptr<map_generator> 
generator(create_map_generator(parameters.front(),cfg));
        if(generator == NULL) {
-               std::cerr << "could not find map generator '" << 
parameters.front() << "'\n";
+               ERR_CF << "could not find map generator '" << 
parameters.front() << "'\n";
                return config();
        }
 
@@ -85,7 +88,7 @@
        size_t center_x = width/2;
        size_t center_y = height/2;
 
-       std::cerr << "off-centering...\n";
+       LOG_NG << "off-centering...\n";
 
        if(island_off_center != 0) {
                switch(rand()%4) {
@@ -133,7 +136,7 @@
                if(island_size != 0) {
                        const size_t diffx = abs(x1 - int(center_x));
                        const size_t diffy = abs(y1 - int(center_y));
-                       const size_t dist = size_t(sqrt(double(diffx*diffx + 
diffy*diffy)));
+                       const size_t dist = size_t(std::sqrt(double(diffx*diffx 
+ diffy*diffy)));
                        is_valley = dist > island_size;
                }
 
@@ -149,7 +152,7 @@
                                const int xdiff = (x2-x1);
                                const int ydiff = (y2-y1);
 
-                               const int height = radius - 
int(sqrt(double(xdiff*xdiff + ydiff*ydiff)));
+                               const int height = radius - 
int(std::sqrt(double(xdiff*xdiff + ydiff*ydiff)));
 
                                if(height > 0) {
                                        if(is_valley) {
@@ -246,7 +249,7 @@
        
        //if we're at the end of the river
        if(!on_map || terrain[x][y] == 'c' || terrain[x][y] == 's') {
-               std::cerr << "generating river...\n";
+               LOG_NG << "generating river...\n";
 
                //generate the river
                for(std::vector<location>::const_iterator i = river.begin();
@@ -254,7 +257,7 @@
                        terrain[i->x][i->y] = 'c';
                }
 
-                       std::cerr << "done generating river\n";
+               LOG_NG << "done generating river\n";
 
                return true;
        }
@@ -526,23 +529,23 @@
        const std::vector<std::string>& options = 
config::split(string_table[id]);
        if(options.empty() == false) {
                const size_t choice = rand()%options.size();
-               std::cerr << "calling name generator...\n";
+               LOG_NG << "calling name generator...\n";
                const std::string& name = 
name_generator.generate_name(unit_race::MALE);
-               std::cerr << "name generator returned '" << name << "'\n";
+               LOG_NG << "name generator returned '" << name << "'\n";
                if(base_name != NULL) {
                        *base_name = name;
                }
 
-               std::cerr << "assigned base name..\n";
+               LOG_NG << "assigned base name..\n";
                std::map<std::string,std::string> table;
                if(additional_symbols == NULL) {
                        additional_symbols = &table;
                }
 
-               std::cerr << "got additional symbols\n";
+               LOG_NG << "got additional symbols\n";
 
                (*additional_symbols)["name"] = name;
-               std::cerr << "interpolation variables into '" << 
options[choice] << "'\n";
+               LOG_NG << "interpolation variables into '" << options[choice] 
<< "'\n";
                return 
config::interpolate_variables_into_string(options[choice],additional_symbols);
        }
 
@@ -658,11 +661,11 @@
        width *= 3;
        height *= 3;
        
-       std::cerr << "generating height map...\n";
+       LOG_NG << "generating height map...\n";
        //generate the height of everything.
        const height_map heights = 
generate_height_map(width,height,iterations,hill_size,island_size,island_off_center);
-       std::cerr << "done generating height map...\n";
-       std::cerr << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks();
+       LOG_NG << "done generating height map...\n";
+       LOG_NG << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks();
 
        const config* const names_info = cfg.child("naming");
        config naming;
@@ -670,8 +673,8 @@
                naming = *names_info;
        }
 
-       std::cerr << "random map config: '" << cfg.write() << "'\n";
-       std::cerr << "making dummy race for naming: '" << naming.write() << 
"'\n";
+       LOG_NG << "random map config: '" << cfg.write() << "'\n";
+       LOG_NG << "making dummy race for naming: '" << naming.write() << "'\n";
        //make a dummy race for generating names
        unit_race name_generator(naming);
 
@@ -696,8 +699,8 @@
                }
        }
 
-       std::cerr << "placed land forms\n";
-       std::cerr << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks();
+       LOG_NG << "placed land forms\n";
+       LOG_NG << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks();
 
        //now that we have our basic set of flatland/hills/mountains/water, we 
can place lakes
        //and rivers on the map. All rivers are sourced at a lake. Lakes must 
be in high land -
@@ -722,9 +725,9 @@
                                
                                if(river.empty() == false && labels != NULL) {
                                        std::string base_name;
-                                       std::cerr << "generating name for 
river...\n";
+                                       LOG_NG << "generating name for 
river...\n";
                                        const std::string& name = 
generate_name(name_generator,"river_name",&base_name);
-                                       std::cerr << "named river '" << name << 
"'\n";
+                                       LOG_NG << "named river '" << name << 
"'\n";
                                        size_t name_frequency = 20;
                                        
for(std::vector<location>::const_iterator r = river.begin(); r != river.end(); 
++r) {
 
@@ -737,10 +740,10 @@
                                                
river_names.insert(std::pair<location,std::string>(loc,base_name));
                                        }
 
-                                       std::cerr << "put down river name...\n";
+                                       LOG_NG << "put down river name...\n";
                                }
 
-                               std::cerr << "generating lake...\n";
+                               LOG_NG << "generating lake...\n";
                                std::set<location> locs;
                                const bool res = 
generate_lake(terrain,x,y,atoi(cfg["lake_size"].c_str()),locs);
                                if(res && labels != NULL) {
@@ -785,8 +788,8 @@
                }
        }
 
-       std::cerr << "done generating rivers...\n";
-       std::cerr << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks();
+       LOG_NG << "done generating rivers...\n";
+       LOG_NG << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks();
 
        const size_t default_dimensions = 40*40*9;
 
@@ -798,8 +801,8 @@
                                                               
(atoi(cfg["temperature_iterations"].c_str())*width*height)/default_dimensions,
                                                                                
                                   atoi(cfg["temperature_size"].c_str()),0,0);
 
-       std::cerr << "generated temperature map...\n";
-       std::cerr << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks();
+       LOG_NG << "generated temperature map...\n";
+       LOG_NG << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks();
 
        std::vector<terrain_converter> converters;
        const config::child_list& converter_items = cfg.get_children("convert");
@@ -807,8 +810,8 @@
                converters.push_back(terrain_converter(**cv));
        }
 
-       std::cerr << "created terrain converters\n";
-       std::cerr << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks();
+       LOG_NG << "created terrain converters\n";
+       LOG_NG << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks();
 
 
        //iterate over every flatland tile, and determine what type of flatland 
it is,
@@ -824,8 +827,8 @@
                }
        }
 
-       std::cerr << "placing villages...\n";
-       std::cerr << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks();
+       LOG_NG << "placing villages...\n";
+       LOG_NG << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks();
 
        //place villages in a 'grid', to make placing fair, but with villages
        //displaced from their position according to terrain and randomness, to
@@ -833,12 +836,12 @@
 
        std::set<location> villages;
 
-       std::cerr << "placing castles...\n";
+       LOG_NG << "placing castles...\n";
 
        //try to find configuration for castles.
        const config* const castle_config = cfg.child("castle");
        if(castle_config == NULL) {
-               std::cerr << "Could not find castle configuration\n";
+               LOG_NG << "Could not find castle configuration\n";
                return "";
        }
 
@@ -855,7 +858,7 @@
        std::set<location> failed_locs;
 
        for(size_t player = 0; player != nplayers; ++player) {
-               std::cerr << "placing castle for " << player << "\n";
+               LOG_NG << "placing castle for " << player << "\n";
                log_scope("placing castle");
                const int min_x = width/3 + 2;
                const int min_y = height/3 + 2;
@@ -887,8 +890,8 @@
                castles.push_back(best_loc);
        }
 
-       std::cerr << "placing roads...\n";
-       std::cerr << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks();
+       LOG_NG << "placing roads...\n";
+       LOG_NG << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks();
 
        //place roads. We select two tiles at random locations on the borders 
of the map,
        //and try to build roads between them.
@@ -1028,7 +1031,7 @@
                        }
                }
 
-               std::cerr << "looked at " << calc.calls << " locations\n";
+               LOG_NG << "looked at " << calc.calls << " locations\n";
        }
 
 
@@ -1065,8 +1068,8 @@
                }
        }
 
-       std::cerr << "placed castles\n";
-       std::cerr << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks();
+       LOG_NG << "placed castles\n";
+       LOG_NG << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks();
 
        if(nvillages > 0) {
                const config* const naming = cfg.child("village_naming");
@@ -1095,7 +1098,7 @@
                std::set<std::string> used_names;
        
                for(size_t vx = 0; vx < width; vx += village_x) {
-                       std::cerr << "village at " << vx << "\n";
+                       LOG_NG << "village at " << vx << "\n";
                        for(size_t vy = rand()%village_y; vy < height; vy += 
village_y) {
                                
                                const size_t add_x = rand()%3;
@@ -1189,8 +1192,8 @@
                }
        }
 
-       std::cerr << "placed villages\n";
-       std::cerr << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks();
+       LOG_NG << "placed villages\n";
+       LOG_NG << (SDL_GetTicks() - ticks) << "\n"; ticks = SDL_GetTicks();
 
 
        return output_map(terrain);




reply via email to

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