mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-09 20:06:16 +00:00
Fixed the cavegen to work properly with the new terrain system.
This commit is contained in:
parent
ae3c05b8ed
commit
683341e426
@ -24,7 +24,8 @@
|
||||
|
||||
cave_map_generator::cave_map_generator(const config* cfg) : wall_(t_translation::CAVE_WALL),
|
||||
clear_(t_translation::CAVE), village_(t_translation::UNDERGROUND_VILLAGE),
|
||||
castle_(t_translation::DWARVEN_CASTLE), cfg_(cfg), width_(50), height_(50),
|
||||
castle_(t_translation::DWARVEN_CASTLE), keep_(t_translation::DWARVEN_KEEP),
|
||||
cfg_(cfg), width_(50), height_(50),
|
||||
village_density_(0), flipx_(false), flipy_(false)
|
||||
{
|
||||
if(cfg_ == NULL) {
|
||||
@ -44,7 +45,6 @@ cave_map_generator::cave_map_generator(const config* cfg) : wall_(t_translation:
|
||||
LOG_NG << "flipx: " << r << " < " << chance << " = " << (flipx_ ? "true" : "false") << "\n";
|
||||
flipy_ = (rand()%100) < atoi((*cfg_)["flipy_chance"].c_str());
|
||||
|
||||
|
||||
}
|
||||
|
||||
size_t cave_map_generator::translate_x(size_t x) const
|
||||
@ -104,17 +104,9 @@ config cave_map_generator::create_scenario(const std::vector<std::string>& /*arg
|
||||
}
|
||||
|
||||
LOG_NG << "outputting map....\n";
|
||||
std::stringstream out;
|
||||
for(size_t y = 0; y != height_; ++y) {
|
||||
for(size_t x = 0; x != width_; ++x) {
|
||||
out << t_translation::write_letter(map_[x][y]); //FIXME MdW, should this be done by the map converter??
|
||||
}
|
||||
|
||||
out << "\n";
|
||||
}
|
||||
|
||||
res_["map_data"] = out.str();
|
||||
|
||||
res_["map_data"] = t_translation::write_game_map(map_, starting_positions_);
|
||||
|
||||
LOG_NG << "returning result...\n";
|
||||
|
||||
return res_;
|
||||
@ -359,8 +351,12 @@ void cave_map_generator::set_terrain(gamemap::location loc, t_translation::t_let
|
||||
|
||||
void cave_map_generator::place_castle(const std::string& side, gamemap::location loc)
|
||||
{
|
||||
if(side != "") {
|
||||
set_terrain(loc, t_translation::read_letter(side, t_translation::T_FORMAT_AUTO));
|
||||
const int starting_position = lexical_cast_default<int>(side, -1);
|
||||
if(starting_position != -1) {
|
||||
set_terrain(loc, keep_);
|
||||
|
||||
const struct t_translation::coordinate coord = {loc.x, loc.y};
|
||||
starting_positions_[starting_position] = coord;
|
||||
}
|
||||
|
||||
gamemap::location adj[6];
|
||||
|
@ -60,8 +60,9 @@ private:
|
||||
void set_terrain(gamemap::location loc, t_translation::t_letter t);
|
||||
void place_castle(const std::string& side, gamemap::location loc);
|
||||
|
||||
t_translation::t_letter wall_, clear_, village_, castle_;
|
||||
t_translation::t_letter wall_, clear_, village_, castle_, keep_;
|
||||
t_translation::t_map map_;
|
||||
std::map<int, t_translation::coordinate> starting_positions_;
|
||||
|
||||
std::map<std::string,size_t> chamber_ids_;
|
||||
std::vector<chamber> chambers_;
|
||||
|
@ -144,6 +144,7 @@ const t_letter CAVE_WALL = string_to_number_("Xu");
|
||||
const t_letter CAVE = string_to_number_("Uu");
|
||||
const t_letter UNDERGROUND_VILLAGE = string_to_number_("Vu");
|
||||
const t_letter DWARVEN_CASTLE = string_to_number_("Cud");
|
||||
const t_letter DWARVEN_KEEP = string_to_number_("Kud");
|
||||
|
||||
const t_letter PLUS = string_to_number_("+");
|
||||
const t_letter MINUS = string_to_number_("-");
|
||||
|
@ -94,6 +94,7 @@ namespace t_translation {
|
||||
extern const t_letter CAVE;
|
||||
extern const t_letter UNDERGROUND_VILLAGE;
|
||||
extern const t_letter DWARVEN_CASTLE;
|
||||
extern const t_letter DWARVEN_KEEP;
|
||||
|
||||
extern const t_letter PLUS; // +
|
||||
extern const t_letter MINUS; // -
|
||||
|
Loading…
x
Reference in New Issue
Block a user