Rename terrain classes to avoid t_ prefix
This commit is contained in:
parent
e0614251c4
commit
b74afeff73
57 changed files with 545 additions and 545 deletions
|
@ -47,7 +47,7 @@
|
|||
#include "serialization/string_utils.hpp" // for split, etc
|
||||
#include "team.hpp" // for team
|
||||
#include "terrain/filter.hpp" // for terrain_filter
|
||||
#include "terrain/translation.hpp" // for t_terrain
|
||||
#include "terrain/translation.hpp" // for terrain_code
|
||||
#include "time_of_day.hpp" // for time_of_day
|
||||
#include "tod_manager.hpp" // for tod_manager
|
||||
#include "units/unit.hpp" // for unit, intrusive_ptr_release, etc
|
||||
|
@ -1084,7 +1084,7 @@ double readonly_context_impl::power_projection(const map_location& loc, const mo
|
|||
continue;
|
||||
}
|
||||
|
||||
const t_translation::t_terrain terrain = map_[locs[i]];
|
||||
const t_translation::terrain_code terrain = map_[locs[i]];
|
||||
|
||||
typedef move_map::const_iterator Itor;
|
||||
typedef std::pair<Itor,Itor> Range;
|
||||
|
|
|
@ -351,7 +351,7 @@ void aspect_attacks_base::do_attack_analysis(
|
|||
int aspect_attacks_base::rate_terrain(const unit& u, const map_location& loc)
|
||||
{
|
||||
const gamemap &map_ = resources::gameboard->map();
|
||||
const t_translation::t_terrain terrain = map_.get_terrain(loc);
|
||||
const t_translation::terrain_code terrain = map_.get_terrain(loc);
|
||||
const int defense = u.defense_modifier(terrain);
|
||||
int rating = 100 - defense;
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ struct move_cost_calculator : pathfind::cost_calculator
|
|||
|
||||
double cost(const map_location& loc, const double) const
|
||||
{
|
||||
const t_translation::t_terrain terrain = map_[loc];
|
||||
const t_translation::terrain_code terrain = map_[loc];
|
||||
|
||||
const double move_cost = unit_.movement_cost(terrain);
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ default_ai_context& default_ai_context_impl::get_default_ai_context(){
|
|||
int default_ai_context_impl::rate_terrain(const unit& u, const map_location& loc) const
|
||||
{
|
||||
const gamemap &map_ = resources::gameboard->map();
|
||||
const t_translation::t_terrain terrain = map_.get_terrain(loc);
|
||||
const t_translation::terrain_code terrain = map_.get_terrain(loc);
|
||||
const int defense = u.defense_modifier(terrain);
|
||||
int rating = 100 - defense;
|
||||
|
||||
|
|
|
@ -657,7 +657,7 @@ double recruitment::get_average_defense(const std::string& u_type) const {
|
|||
long summed_defense = 0;
|
||||
int total_terrains = 0;
|
||||
for (const terrain_count_map::value_type& entry : important_terrain_) {
|
||||
const t_translation::t_terrain& terrain = entry.first;
|
||||
const t_translation::terrain_code& terrain = entry.first;
|
||||
int count = entry.second;
|
||||
int defense = 100 - u_info->movement_type().defense_modifier(terrain);
|
||||
summed_defense += defense * count;
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace default_recruitment {
|
|||
// The leader will then recruit according to the map.
|
||||
typedef std::map<std::string, double> score_map;
|
||||
|
||||
typedef std::map<t_translation::t_terrain, int> terrain_count_map;
|
||||
typedef std::map<t_translation::terrain_code, int> terrain_count_map;
|
||||
typedef std::map<std::string, int> count_map;
|
||||
|
||||
struct data {
|
||||
|
|
|
@ -78,7 +78,7 @@ class unit_adapter {
|
|||
}
|
||||
}
|
||||
|
||||
int movement_cost(const t_translation::t_terrain & terrain) const {
|
||||
int movement_cost(const t_translation::terrain_code & terrain) const {
|
||||
if(unit_type_ != nullptr) {
|
||||
return unit_type_->movement_type().movement_cost(terrain);
|
||||
} else {
|
||||
|
|
|
@ -304,7 +304,7 @@ void editor_action_shuffle_area::perform_without_undo(map_context& mc) const
|
|||
std::vector<map_location>::const_iterator shuffle_it = shuffle.begin();
|
||||
std::set<map_location>::const_iterator orig_it = area_.begin();
|
||||
while (orig_it != area_.end()) {
|
||||
t_translation::t_terrain tmp = mc.get_map().get_terrain(*orig_it);
|
||||
t_translation::terrain_code tmp = mc.get_map().get_terrain(*orig_it);
|
||||
mc.draw_terrain(mc.get_map().get_terrain(*shuffle_it), *orig_it);
|
||||
mc.draw_terrain(tmp, *shuffle_it);
|
||||
++orig_it;
|
||||
|
|
|
@ -193,13 +193,13 @@ class editor_action_location_terrain : public editor_action_location
|
|||
{
|
||||
public:
|
||||
editor_action_location_terrain(map_location loc,
|
||||
const t_translation::t_terrain & t)
|
||||
const t_translation::terrain_code & t)
|
||||
: editor_action_location(loc), t_(t)
|
||||
{
|
||||
}
|
||||
const char* get_name() const { return "location_terrain"; }
|
||||
protected:
|
||||
t_translation::t_terrain t_;
|
||||
t_translation::terrain_code t_;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -245,7 +245,7 @@ class editor_action_paint_area : public editor_action_area
|
|||
{
|
||||
public:
|
||||
editor_action_paint_area(const std::set<map_location>& area,
|
||||
const t_translation::t_terrain & t, bool one_layer=false)
|
||||
const t_translation::terrain_code & t, bool one_layer=false)
|
||||
: editor_action_area(area), t_(t), one_layer_(one_layer)
|
||||
{
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ class editor_action_paint_area : public editor_action_area
|
|||
void perform_without_undo(map_context& mc) const;
|
||||
const char* get_name() const { return "paint_area"; }
|
||||
protected:
|
||||
t_translation::t_terrain t_;
|
||||
t_translation::terrain_code t_;
|
||||
bool one_layer_;
|
||||
};
|
||||
|
||||
|
@ -265,7 +265,7 @@ class editor_action_fill : public editor_action_location_terrain
|
|||
{
|
||||
public:
|
||||
editor_action_fill(map_location loc,
|
||||
const t_translation::t_terrain & t, bool one_layer=false)
|
||||
const t_translation::terrain_code & t, bool one_layer=false)
|
||||
: editor_action_location_terrain(loc, t), one_layer_(one_layer)
|
||||
{
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ class editor_action_resize_map : public editor_action
|
|||
{
|
||||
public:
|
||||
editor_action_resize_map(int x_size, int y_size, int x_offset, int y_offset,
|
||||
const t_translation::t_terrain & fill = t_translation::NONE_TERRAIN)
|
||||
const t_translation::terrain_code & fill = t_translation::NONE_TERRAIN)
|
||||
: x_size_(x_size), y_size_(y_size), x_offset_(x_offset), y_offset_(y_offset), fill_(fill)
|
||||
{
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ class editor_action_resize_map : public editor_action
|
|||
int y_size_;
|
||||
int x_offset_;
|
||||
int y_offset_;
|
||||
t_translation::t_terrain fill_;
|
||||
t_translation::terrain_code fill_;
|
||||
};
|
||||
|
||||
class editor_action_apply_mask : public editor_action
|
||||
|
|
|
@ -141,8 +141,8 @@ bool mouse_action::has_ctrl_modifier() const
|
|||
#endif
|
||||
}
|
||||
|
||||
void mouse_action::set_terrain_mouse_overlay(editor_display& disp, const t_translation::t_terrain & fg,
|
||||
const t_translation::t_terrain & bg)
|
||||
void mouse_action::set_terrain_mouse_overlay(editor_display& disp, const t_translation::terrain_code & fg,
|
||||
const t_translation::terrain_code & bg)
|
||||
{
|
||||
surface image_fg(image::get_image(disp.get_map().get_terrain_info(fg).editor_image()));
|
||||
surface image_bg(image::get_image(disp.get_map().get_terrain_info(bg).editor_image()));
|
||||
|
|
|
@ -137,8 +137,8 @@ protected:
|
|||
/**
|
||||
* Helper function for derived classes that need a active-terrain mouse overlay
|
||||
*/
|
||||
void set_terrain_mouse_overlay(editor_display& disp, const t_translation::t_terrain & fg,
|
||||
const t_translation::t_terrain & bg);
|
||||
void set_terrain_mouse_overlay(editor_display& disp, const t_translation::terrain_code & fg,
|
||||
const t_translation::terrain_code & bg);
|
||||
|
||||
/**
|
||||
* The hex previously used in move operations
|
||||
|
|
|
@ -263,7 +263,7 @@ void context_manager::new_map_dialog()
|
|||
int w = get_map().w();
|
||||
int h = get_map().h();
|
||||
if(gui2::teditor_new_map::execute(w, h, gui_.video())) {
|
||||
const t_translation::t_terrain& fill = get_selected_bg_terrain();
|
||||
const t_translation::terrain_code& fill = get_selected_bg_terrain();
|
||||
new_map(w, h, fill, true);
|
||||
}
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ void context_manager::new_scenario_dialog()
|
|||
int w = get_map().w();
|
||||
int h = get_map().h();
|
||||
if(gui2::teditor_new_map::execute(w, h, gui_.video())) {
|
||||
const t_translation::t_terrain& fill = get_selected_bg_terrain();
|
||||
const t_translation::terrain_code& fill = get_selected_bg_terrain();
|
||||
new_scenario(w, h, fill, true);
|
||||
}
|
||||
}
|
||||
|
@ -560,7 +560,7 @@ void context_manager::resize_map_dialog()
|
|||
if(gui2::teditor_resize_map::execute(w, h, dir, copy, gui_.video())) {
|
||||
|
||||
if (w != get_map().w() || h != get_map().h()) {
|
||||
t_translation::t_terrain fill = get_selected_bg_terrain();
|
||||
t_translation::terrain_code fill = get_selected_bg_terrain();
|
||||
if (copy) {
|
||||
fill = t_translation::NONE_TERRAIN;
|
||||
}
|
||||
|
@ -724,7 +724,7 @@ void context_manager::create_default_context()
|
|||
{
|
||||
if(saved_windows_.empty()) {
|
||||
|
||||
t_translation::t_terrain default_terrain =
|
||||
t_translation::terrain_code default_terrain =
|
||||
t_translation::read_terrain_code(game_config::default_terrain);
|
||||
const config& default_schedule = game_config_.find_child("editor_times", "id", "default");
|
||||
map_context* mc = new map_context(editor_map(game_config_, 44, 33, default_terrain), gui_, true, default_schedule);
|
||||
|
@ -944,7 +944,7 @@ void context_manager::revert_map()
|
|||
load_map(filename, false);
|
||||
}
|
||||
|
||||
void context_manager::new_map(int width, int height, const t_translation::t_terrain & fill, bool new_context)
|
||||
void context_manager::new_map(int width, int height, const t_translation::terrain_code & fill, bool new_context)
|
||||
{
|
||||
const config& default_schedule = game_config_.find_child("editor_times", "id", "default");
|
||||
editor_map m(game_config_, width, height, fill);
|
||||
|
@ -956,7 +956,7 @@ void context_manager::new_map(int width, int height, const t_translation::t_terr
|
|||
}
|
||||
}
|
||||
|
||||
void context_manager::new_scenario(int width, int height, const t_translation::t_terrain & fill, bool new_context)
|
||||
void context_manager::new_scenario(int width, int height, const t_translation::terrain_code & fill, bool new_context)
|
||||
{
|
||||
const config& default_schedule = game_config_.find_child("editor_times", "id", "default");
|
||||
editor_map m(game_config_, width, height, fill);
|
||||
|
|
|
@ -240,13 +240,13 @@ private:
|
|||
/**
|
||||
* Create a new map.
|
||||
*/
|
||||
void new_map(int width, int height, const t_translation::t_terrain & fill,
|
||||
void new_map(int width, int height, const t_translation::terrain_code & fill,
|
||||
bool new_context);
|
||||
|
||||
/**
|
||||
* Create a new scenario.
|
||||
*/
|
||||
void new_scenario(int width, int height, const t_translation::t_terrain & fill,
|
||||
void new_scenario(int width, int height, const t_translation::terrain_code & fill,
|
||||
bool new_context);
|
||||
|
||||
/**
|
||||
|
|
|
@ -66,8 +66,8 @@ editor_map editor_map::from_string(const config& terrain_cfg, const std::string&
|
|||
}
|
||||
}
|
||||
|
||||
editor_map::editor_map(const config& terrain_cfg, size_t width, size_t height, const t_translation::t_terrain & filler)
|
||||
: gamemap(std::make_shared<terrain_type_data>(terrain_cfg), t_translation::write_game_map(t_translation::t_map(width + 2, height + 2, filler)))
|
||||
editor_map::editor_map(const config& terrain_cfg, size_t width, size_t height, const t_translation::terrain_code & filler)
|
||||
: gamemap(std::make_shared<terrain_type_data>(terrain_cfg), t_translation::write_game_map(t_translation::ter_map(width + 2, height + 2, filler)))
|
||||
, selection_()
|
||||
{
|
||||
sanity_check();
|
||||
|
@ -115,7 +115,7 @@ void editor_map::sanity_check()
|
|||
|
||||
std::set<map_location> editor_map::get_contiguous_terrain_tiles(const map_location& start) const
|
||||
{
|
||||
t_translation::t_terrain terrain = get_terrain(start);
|
||||
t_translation::terrain_code terrain = get_terrain(start);
|
||||
std::set<map_location> result;
|
||||
std::deque<map_location> queue;
|
||||
result.insert(start);
|
||||
|
@ -214,7 +214,7 @@ bool editor_map::everything_selected() const
|
|||
}
|
||||
|
||||
void editor_map::resize(int width, int height, int x_offset, int y_offset,
|
||||
const t_translation::t_terrain & filler)
|
||||
const t_translation::terrain_code & filler)
|
||||
{
|
||||
int old_w = w();
|
||||
int old_h = h();
|
||||
|
@ -281,9 +281,9 @@ bool editor_map::same_size_as(const gamemap& other) const
|
|||
&& w() == other.w();
|
||||
}
|
||||
|
||||
void editor_map::expand_right(int count, const t_translation::t_terrain & filler)
|
||||
void editor_map::expand_right(int count, const t_translation::terrain_code & filler)
|
||||
{
|
||||
t_translation::t_map tiles_new(tiles_.w + count, tiles_.h);
|
||||
t_translation::ter_map tiles_new(tiles_.w + count, tiles_.h);
|
||||
w_ += count;
|
||||
for (int x = 0, x_end = tiles_.w; x != x_end; ++x) {
|
||||
for (int y = 0, y_end = tiles_.h; y != y_end; ++y) {
|
||||
|
@ -298,9 +298,9 @@ void editor_map::expand_right(int count, const t_translation::t_terrain & filler
|
|||
tiles_ = std::move(tiles_new);
|
||||
}
|
||||
|
||||
void editor_map::expand_left(int count, const t_translation::t_terrain & filler)
|
||||
void editor_map::expand_left(int count, const t_translation::terrain_code & filler)
|
||||
{
|
||||
t_translation::t_map tiles_new(tiles_.w + count, tiles_.h);
|
||||
t_translation::ter_map tiles_new(tiles_.w + count, tiles_.h);
|
||||
w_ += count;
|
||||
for (int x = 0, x_end = tiles_.w; x != x_end; ++x) {
|
||||
for (int y = 0, y_end = tiles_.h; y != y_end; ++y) {
|
||||
|
@ -315,9 +315,9 @@ void editor_map::expand_left(int count, const t_translation::t_terrain & filler)
|
|||
tiles_ = std::move(tiles_new);
|
||||
}
|
||||
|
||||
void editor_map::expand_top(int count, const t_translation::t_terrain & filler)
|
||||
void editor_map::expand_top(int count, const t_translation::terrain_code & filler)
|
||||
{
|
||||
t_translation::t_map tiles_new(tiles_.w, tiles_.h + count);
|
||||
t_translation::ter_map tiles_new(tiles_.w, tiles_.h + count);
|
||||
h_ += count;
|
||||
for (int x = 0, x_end = tiles_.w; x != x_end; ++x) {
|
||||
for (int y = 0, y_end = tiles_.h; y != y_end; ++y) {
|
||||
|
@ -332,9 +332,9 @@ void editor_map::expand_top(int count, const t_translation::t_terrain & filler)
|
|||
tiles_ = std::move(tiles_new);
|
||||
}
|
||||
|
||||
void editor_map::expand_bottom(int count, const t_translation::t_terrain & filler)
|
||||
void editor_map::expand_bottom(int count, const t_translation::terrain_code & filler)
|
||||
{
|
||||
t_translation::t_map tiles_new(tiles_.w, tiles_.h + count);
|
||||
t_translation::ter_map tiles_new(tiles_.w, tiles_.h + count);
|
||||
h_ += count;
|
||||
for (int x = 0, x_end = tiles_.w; x != x_end; ++x) {
|
||||
for (int y = 0, y_end = tiles_.h; y != y_end; ++y) {
|
||||
|
@ -354,7 +354,7 @@ void editor_map::shrink_right(int count)
|
|||
if(count < 0 || count > tiles_.w) {
|
||||
throw editor_map_operation_exception();
|
||||
}
|
||||
t_translation::t_map tiles_new(tiles_.w - count, tiles_.h);
|
||||
t_translation::ter_map tiles_new(tiles_.w - count, tiles_.h);
|
||||
for (int x = 0, x_end = tiles_new.w; x != x_end; ++x) {
|
||||
for (int y = 0, y_end = tiles_new.h; y != y_end; ++y) {
|
||||
tiles_new.get(x, y) = tiles_.get(x, y);
|
||||
|
@ -369,7 +369,7 @@ void editor_map::shrink_left(int count)
|
|||
if (count < 0 || count > tiles_.w) {
|
||||
throw editor_map_operation_exception();
|
||||
}
|
||||
t_translation::t_map tiles_new(tiles_.w - count, tiles_.h);
|
||||
t_translation::ter_map tiles_new(tiles_.w - count, tiles_.h);
|
||||
for (int x = 0, x_end = tiles_new.w; x != x_end; ++x) {
|
||||
for (int y = 0, y_end = tiles_new.h; y != y_end; ++y) {
|
||||
tiles_new.get(x, y) = tiles_.get(x + count, y);
|
||||
|
@ -384,7 +384,7 @@ void editor_map::shrink_top(int count)
|
|||
if (count < 0 || count > tiles_.h) {
|
||||
throw editor_map_operation_exception();
|
||||
}
|
||||
t_translation::t_map tiles_new(tiles_.w, tiles_.h - count);
|
||||
t_translation::ter_map tiles_new(tiles_.w, tiles_.h - count);
|
||||
for (int x = 0, x_end = tiles_new.w; x != x_end; ++x) {
|
||||
for (int y = 0, y_end = tiles_new.h; y != y_end; ++y) {
|
||||
tiles_new.get(x, y) = tiles_.get(x, y + count);
|
||||
|
@ -399,7 +399,7 @@ void editor_map::shrink_bottom(int count)
|
|||
if (count < 0 || count > tiles_.h) {
|
||||
throw editor_map_operation_exception();
|
||||
}
|
||||
t_translation::t_map tiles_new(tiles_.w, tiles_.h - count);
|
||||
t_translation::ter_map tiles_new(tiles_.w, tiles_.h - count);
|
||||
for (int x = 0, x_end = tiles_new.w; x != x_end; ++x) {
|
||||
for (int y = 0, y_end = tiles_new.h; y != y_end; ++y) {
|
||||
tiles_new.get(x, y) = tiles_.get(x, y);
|
||||
|
|
|
@ -90,7 +90,7 @@ public:
|
|||
/**
|
||||
* Create an editor map with the given dimensions and filler terrain
|
||||
*/
|
||||
editor_map(const config& terrain_cfg, size_t width, size_t height, const t_translation::t_terrain & filler);
|
||||
editor_map(const config& terrain_cfg, size_t width, size_t height, const t_translation::terrain_code & filler);
|
||||
|
||||
/**
|
||||
* Create an editor_map by upgrading an existing gamemap. The map data is
|
||||
|
@ -174,7 +174,7 @@ public:
|
|||
* when expanding, otherwise the filler terrain will be inserted there
|
||||
*/
|
||||
void resize(int width, int height, int x_offset, int y_offset,
|
||||
const t_translation::t_terrain & filler = t_translation::NONE_TERRAIN);
|
||||
const t_translation::terrain_code & filler = t_translation::NONE_TERRAIN);
|
||||
|
||||
/**
|
||||
* A sort-of diff operation returning a mask that, when applied to the current editor_map,
|
||||
|
@ -190,10 +190,10 @@ public:
|
|||
|
||||
protected:
|
||||
//helper functions for resizing
|
||||
void expand_right(int count, const t_translation::t_terrain & filler);
|
||||
void expand_left(int count, const t_translation::t_terrain & filler);
|
||||
void expand_top(int count, const t_translation::t_terrain & filler);
|
||||
void expand_bottom(int count, const t_translation::t_terrain & filler);
|
||||
void expand_right(int count, const t_translation::terrain_code & filler);
|
||||
void expand_left(int count, const t_translation::terrain_code & filler);
|
||||
void expand_top(int count, const t_translation::terrain_code & filler);
|
||||
void expand_bottom(int count, const t_translation::terrain_code & filler);
|
||||
void shrink_right(int count);
|
||||
void shrink_left(int count);
|
||||
void shrink_top(int count);
|
||||
|
|
|
@ -345,16 +345,16 @@ bool map_context::select_area(int index)
|
|||
return map_.set_selection(tod_manager_->get_area_by_index(index));
|
||||
}
|
||||
|
||||
void map_context::draw_terrain(const t_translation::t_terrain & terrain,
|
||||
void map_context::draw_terrain(const t_translation::terrain_code & terrain,
|
||||
const map_location& loc, bool one_layer_only)
|
||||
{
|
||||
t_translation::t_terrain full_terrain = one_layer_only ? terrain :
|
||||
t_translation::terrain_code full_terrain = one_layer_only ? terrain :
|
||||
map_.get_terrain_info(terrain).terrain_with_default_base();
|
||||
|
||||
draw_terrain_actual(full_terrain, loc, one_layer_only);
|
||||
}
|
||||
|
||||
void map_context::draw_terrain_actual(const t_translation::t_terrain & terrain,
|
||||
void map_context::draw_terrain_actual(const t_translation::terrain_code & terrain,
|
||||
const map_location& loc, bool one_layer_only)
|
||||
{
|
||||
if (!map_.on_board_with_border(loc)) {
|
||||
|
@ -363,7 +363,7 @@ void map_context::draw_terrain_actual(const t_translation::t_terrain & terrain,
|
|||
LOG_ED << "Attempted to draw terrain off the map (" << loc << ")\n";
|
||||
return;
|
||||
}
|
||||
t_translation::t_terrain old_terrain = map_.get_terrain(loc);
|
||||
t_translation::terrain_code old_terrain = map_.get_terrain(loc);
|
||||
if (terrain != old_terrain) {
|
||||
if (terrain.base == t_translation::NO_LAYER) {
|
||||
map_.set_terrain(loc, terrain, terrain_type_data::OVERLAY);
|
||||
|
@ -376,10 +376,10 @@ void map_context::draw_terrain_actual(const t_translation::t_terrain & terrain,
|
|||
}
|
||||
}
|
||||
|
||||
void map_context::draw_terrain(const t_translation::t_terrain & terrain,
|
||||
void map_context::draw_terrain(const t_translation::terrain_code & terrain,
|
||||
const std::set<map_location>& locs, bool one_layer_only)
|
||||
{
|
||||
t_translation::t_terrain full_terrain = one_layer_only ? terrain :
|
||||
t_translation::terrain_code full_terrain = one_layer_only ? terrain :
|
||||
map_.get_terrain_info(terrain).terrain_with_default_base();
|
||||
|
||||
for(const map_location& loc : locs) {
|
||||
|
|
|
@ -214,20 +214,20 @@ public:
|
|||
* Draw a terrain on a single location on the map.
|
||||
* Sets the refresh flags accordingly.
|
||||
*/
|
||||
void draw_terrain(const t_translation::t_terrain & terrain, const map_location& loc,
|
||||
void draw_terrain(const t_translation::terrain_code & terrain, const map_location& loc,
|
||||
bool one_layer_only = false);
|
||||
|
||||
/**
|
||||
* Actual drawing function used by both overloaded variants of draw_terrain.
|
||||
*/
|
||||
void draw_terrain_actual(const t_translation::t_terrain & terrain, const map_location& loc,
|
||||
void draw_terrain_actual(const t_translation::terrain_code & terrain, const map_location& loc,
|
||||
bool one_layer_only = false);
|
||||
|
||||
/**
|
||||
* Draw a terrain on a set of locations on the map.
|
||||
* Sets the refresh flags accordingly.
|
||||
*/
|
||||
void draw_terrain(const t_translation::t_terrain & terrain, const std::set<map_location>& locs,
|
||||
void draw_terrain(const t_translation::terrain_code & terrain, const std::set<map_location>& locs,
|
||||
bool one_layer_only = false);
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,7 +35,7 @@ struct tile_info
|
|||
}
|
||||
|
||||
map_location offset;
|
||||
t_translation::t_terrain terrain;
|
||||
t_translation::terrain_code terrain;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,7 +39,7 @@ sdl_handler_vector editor_palette<Item>::handler_members()
|
|||
}
|
||||
return h;
|
||||
}
|
||||
template sdl_handler_vector editor_palette<t_translation::t_terrain>::handler_members();
|
||||
template sdl_handler_vector editor_palette<t_translation::terrain_code>::handler_members();
|
||||
template sdl_handler_vector editor_palette<unit_type>::handler_members();
|
||||
template sdl_handler_vector editor_palette<overlay>::handler_members();
|
||||
|
||||
|
@ -81,7 +81,7 @@ void editor_palette<Item>::expand_palette_groups_menu(std::vector<std::string>&
|
|||
}
|
||||
}
|
||||
}
|
||||
template void editor_palette<t_translation::t_terrain>::expand_palette_groups_menu(std::vector<std::string>& items);
|
||||
template void editor_palette<t_translation::terrain_code>::expand_palette_groups_menu(std::vector<std::string>& items);
|
||||
template void editor_palette<unit_type>::expand_palette_groups_menu(std::vector<std::string>& items);
|
||||
template void editor_palette<overlay>::expand_palette_groups_menu(std::vector<std::string>& items);
|
||||
|
||||
|
@ -99,7 +99,7 @@ bool editor_palette<Item>::scroll_up()
|
|||
}
|
||||
return false;
|
||||
}
|
||||
template bool editor_palette<t_translation::t_terrain>::scroll_up();
|
||||
template bool editor_palette<t_translation::terrain_code>::scroll_up();
|
||||
template bool editor_palette<unit_type>::scroll_up();
|
||||
template bool editor_palette<overlay>::scroll_up();
|
||||
|
||||
|
@ -117,7 +117,7 @@ void editor_palette<Item>::expand_palette_groups_menu(std::vector< std::pair< st
|
|||
items.push_back(std::pair<std::string, std::string>( img, groupname));
|
||||
}
|
||||
}
|
||||
template void editor_palette<t_translation::t_terrain>::expand_palette_groups_menu(std::vector< std::pair< std::string, std::string> >& items);
|
||||
template void editor_palette<t_translation::terrain_code>::expand_palette_groups_menu(std::vector< std::pair< std::string, std::string> >& items);
|
||||
template void editor_palette<unit_type>::expand_palette_groups_menu(std::vector< std::pair< std::string, std::string> >& items);
|
||||
template void editor_palette<overlay>::expand_palette_groups_menu(std::vector< std::pair< std::string, std::string> >& items);
|
||||
|
||||
|
@ -126,7 +126,7 @@ bool editor_palette<Item>::can_scroll_up()
|
|||
{
|
||||
return (items_start_ != 0);
|
||||
}
|
||||
template bool editor_palette<t_translation::t_terrain>::can_scroll_up();
|
||||
template bool editor_palette<t_translation::terrain_code>::can_scroll_up();
|
||||
template bool editor_palette<unit_type>::can_scroll_up();
|
||||
template bool editor_palette<overlay>::can_scroll_up();
|
||||
|
||||
|
@ -135,7 +135,7 @@ bool editor_palette<Item>::can_scroll_down()
|
|||
{
|
||||
return (items_start_ + nitems_ + item_width_ <= num_items());
|
||||
}
|
||||
template bool editor_palette<t_translation::t_terrain>::can_scroll_down();
|
||||
template bool editor_palette<t_translation::terrain_code>::can_scroll_down();
|
||||
template bool editor_palette<unit_type>::can_scroll_down();
|
||||
template bool editor_palette<overlay>::can_scroll_down();
|
||||
|
||||
|
@ -158,7 +158,7 @@ bool editor_palette<Item>::scroll_down()
|
|||
draw();
|
||||
return scrolled;
|
||||
}
|
||||
template bool editor_palette<t_translation::t_terrain>::scroll_down();
|
||||
template bool editor_palette<t_translation::terrain_code>::scroll_down();
|
||||
template bool editor_palette<unit_type>::scroll_down();
|
||||
template bool editor_palette<overlay>::scroll_down();
|
||||
|
||||
|
@ -187,7 +187,7 @@ void editor_palette<Item>::set_group(const std::string& id)
|
|||
ERR_ED << "No items found in group with the id: '" << id << "'." << std::endl;
|
||||
}
|
||||
}
|
||||
template void editor_palette<t_translation::t_terrain>::set_group(const std::string& id);
|
||||
template void editor_palette<t_translation::terrain_code>::set_group(const std::string& id);
|
||||
template void editor_palette<unit_type>::set_group(const std::string& id);
|
||||
template void editor_palette<overlay>::set_group(const std::string& id);
|
||||
|
||||
|
@ -197,7 +197,7 @@ void editor_palette<Item>::set_group(size_t index)
|
|||
assert(groups_.size() > index);
|
||||
set_group(groups_[index].id);
|
||||
}
|
||||
template void editor_palette<t_translation::t_terrain>::set_group(size_t index);
|
||||
template void editor_palette<t_translation::terrain_code>::set_group(size_t index);
|
||||
template void editor_palette<unit_type>::set_group(size_t index);
|
||||
template void editor_palette<overlay>::set_group(size_t index);
|
||||
|
||||
|
@ -213,7 +213,7 @@ size_t editor_palette<Item>::active_group_index()
|
|||
|
||||
return static_cast<size_t>(-1);
|
||||
}
|
||||
template size_t editor_palette<t_translation::t_terrain>::active_group_index();
|
||||
template size_t editor_palette<t_translation::terrain_code>::active_group_index();
|
||||
template size_t editor_palette<unit_type>::active_group_index();
|
||||
template size_t editor_palette<overlay>::active_group_index();
|
||||
|
||||
|
@ -233,7 +233,7 @@ void editor_palette<Item>::adjust_size(const SDL_Rect& target)
|
|||
gui_.video().clear_help_string(help_handle_);
|
||||
help_handle_ = gui_.video().set_help_string(get_help_string());
|
||||
}
|
||||
template void editor_palette<t_translation::t_terrain>::adjust_size(const SDL_Rect& target);
|
||||
template void editor_palette<t_translation::terrain_code>::adjust_size(const SDL_Rect& target);
|
||||
template void editor_palette<unit_type>::adjust_size(const SDL_Rect& target);
|
||||
template void editor_palette<overlay>::adjust_size(const SDL_Rect& target);
|
||||
|
||||
|
@ -247,7 +247,7 @@ void editor_palette<Item>::select_fg_item(const std::string& item_id)
|
|||
gui_.video().clear_help_string(help_handle_);
|
||||
help_handle_ = gui_.video().set_help_string(get_help_string());
|
||||
}
|
||||
template void editor_palette<t_translation::t_terrain>::select_fg_item(const std::string& terrain_id);
|
||||
template void editor_palette<t_translation::terrain_code>::select_fg_item(const std::string& terrain_id);
|
||||
template void editor_palette<unit_type>::select_fg_item(const std::string& unit_id);
|
||||
template void editor_palette<overlay>::select_fg_item(const std::string& unit_id);
|
||||
|
||||
|
@ -261,7 +261,7 @@ void editor_palette<Item>::select_bg_item(const std::string& item_id)
|
|||
gui_.video().clear_help_string(help_handle_);
|
||||
help_handle_ = gui_.video().set_help_string(get_help_string());
|
||||
}
|
||||
template void editor_palette<t_translation::t_terrain>::select_bg_item(const std::string& terrain_id);
|
||||
template void editor_palette<t_translation::terrain_code>::select_bg_item(const std::string& terrain_id);
|
||||
template void editor_palette<unit_type>::select_bg_item(const std::string& unit_id);
|
||||
template void editor_palette<overlay>::select_bg_item(const std::string& unit_id);
|
||||
|
||||
|
@ -273,7 +273,7 @@ void editor_palette<Item>::swap()
|
|||
select_bg_item(selected_bg_item_);
|
||||
set_dirty();
|
||||
}
|
||||
template void editor_palette<t_translation::t_terrain>::swap();
|
||||
template void editor_palette<t_translation::terrain_code>::swap();
|
||||
template void editor_palette<unit_type>::swap();
|
||||
template void editor_palette<overlay>::swap();
|
||||
|
||||
|
@ -282,7 +282,7 @@ int editor_palette<Item>::num_items()
|
|||
{
|
||||
return group_map_[active_group_].size();
|
||||
}
|
||||
template int editor_palette<t_translation::t_terrain>::num_items();
|
||||
template int editor_palette<t_translation::terrain_code>::num_items();
|
||||
template int editor_palette<unit_type>::num_items();
|
||||
template int editor_palette<overlay>::num_items();
|
||||
|
||||
|
@ -291,7 +291,7 @@ bool editor_palette<Item>::is_selected_fg_item(const std::string& id)
|
|||
{
|
||||
return selected_fg_item_ == id;
|
||||
}
|
||||
template bool editor_palette<t_translation::t_terrain>::is_selected_fg_item(const std::string& id);
|
||||
template bool editor_palette<t_translation::terrain_code>::is_selected_fg_item(const std::string& id);
|
||||
template bool editor_palette<unit_type>::is_selected_fg_item(const std::string& id);
|
||||
template bool editor_palette<overlay>::is_selected_fg_item(const std::string& id);
|
||||
|
||||
|
@ -300,7 +300,7 @@ bool editor_palette<Item>::is_selected_bg_item(const std::string& id)
|
|||
{
|
||||
return selected_bg_item_ == id;
|
||||
}
|
||||
template bool editor_palette<t_translation::t_terrain>::is_selected_bg_item(const std::string& id);
|
||||
template bool editor_palette<t_translation::terrain_code>::is_selected_bg_item(const std::string& id);
|
||||
template bool editor_palette<unit_type>::is_selected_bg_item(const std::string& id);
|
||||
template bool editor_palette<overlay>::is_selected_bg_item(const std::string& id);
|
||||
|
||||
|
@ -405,7 +405,7 @@ void editor_palette<Item>::draw_contents()
|
|||
}
|
||||
update_rect(location());
|
||||
}
|
||||
template void editor_palette<t_translation::t_terrain>::draw_contents();
|
||||
template void editor_palette<t_translation::terrain_code>::draw_contents();
|
||||
template void editor_palette<unit_type>::draw_contents();
|
||||
template void editor_palette<overlay>::draw_contents();
|
||||
|
||||
|
|
|
@ -24,53 +24,53 @@
|
|||
#include "formula/string_utils.hpp"
|
||||
|
||||
namespace {
|
||||
static t_translation::t_terrain fg_terrain;
|
||||
static t_translation::t_terrain bg_terrain;
|
||||
static t_translation::terrain_code fg_terrain;
|
||||
static t_translation::terrain_code bg_terrain;
|
||||
}
|
||||
|
||||
namespace editor {
|
||||
|
||||
const t_translation::t_terrain& get_selected_bg_terrain() {
|
||||
const t_translation::terrain_code& get_selected_bg_terrain() {
|
||||
return bg_terrain;
|
||||
}
|
||||
|
||||
const t_translation::t_terrain& get_selected_fg_terrain() {
|
||||
const t_translation::terrain_code& get_selected_fg_terrain() {
|
||||
return fg_terrain;
|
||||
}
|
||||
|
||||
const t_translation::t_terrain& terrain_palette::selected_fg_item() const { return fg_terrain; }
|
||||
const t_translation::t_terrain& terrain_palette::selected_bg_item() const { return bg_terrain; }
|
||||
const t_translation::terrain_code& terrain_palette::selected_fg_item() const { return fg_terrain; }
|
||||
const t_translation::terrain_code& terrain_palette::selected_bg_item() const { return bg_terrain; }
|
||||
|
||||
|
||||
static bool is_valid_terrain(const t_translation::t_terrain & c) {
|
||||
static bool is_valid_terrain(const t_translation::terrain_code & c) {
|
||||
return !(c == t_translation::VOID_TERRAIN || c == t_translation::FOGGED);
|
||||
}
|
||||
|
||||
void terrain_palette::select_bg_item(const std::string& item_id) {
|
||||
bg_terrain = item_map_[item_id];
|
||||
editor_palette<t_translation::t_terrain>::select_bg_item(item_id);
|
||||
editor_palette<t_translation::terrain_code>::select_bg_item(item_id);
|
||||
}
|
||||
|
||||
void terrain_palette::select_fg_item(const std::string& item_id) {
|
||||
fg_terrain = item_map_[item_id];
|
||||
editor_palette<t_translation::t_terrain>::select_fg_item(item_id);
|
||||
editor_palette<t_translation::terrain_code>::select_fg_item(item_id);
|
||||
}
|
||||
|
||||
void terrain_palette::select_bg_item(const t_translation::t_terrain& terrain) {
|
||||
void terrain_palette::select_bg_item(const t_translation::terrain_code& terrain) {
|
||||
bg_terrain = terrain;
|
||||
editor_palette<t_translation::t_terrain>::select_bg_item(get_id(terrain));
|
||||
editor_palette<t_translation::terrain_code>::select_bg_item(get_id(terrain));
|
||||
}
|
||||
|
||||
void terrain_palette::select_fg_item(const t_translation::t_terrain& terrain) {
|
||||
void terrain_palette::select_fg_item(const t_translation::terrain_code& terrain) {
|
||||
fg_terrain = terrain;
|
||||
editor_palette<t_translation::t_terrain>::select_fg_item(get_id(terrain));
|
||||
editor_palette<t_translation::terrain_code>::select_fg_item(get_id(terrain));
|
||||
}
|
||||
|
||||
|
||||
void terrain_palette::setup(const config& cfg)
|
||||
{
|
||||
// Get the available terrains temporary in items
|
||||
t_translation::t_list items = map().get_terrain_list();
|
||||
t_translation::ter_list items = map().get_terrain_list();
|
||||
|
||||
//move "invalid" items to the end
|
||||
std::stable_partition(items.begin(), items.end(), is_valid_terrain);
|
||||
|
@ -99,7 +99,7 @@ void terrain_palette::setup(const config& cfg)
|
|||
}
|
||||
|
||||
// add the groups for all terrains to the map
|
||||
for (const t_translation::t_terrain& t : items) {
|
||||
for (const t_translation::terrain_code& t : items) {
|
||||
|
||||
const terrain_type& t_info = map().get_terrain_info(t);
|
||||
DBG_ED << "Palette: processing terrain " << t_info.name()
|
||||
|
@ -153,10 +153,10 @@ void terrain_palette::setup(const config& cfg)
|
|||
}
|
||||
}
|
||||
|
||||
void terrain_palette::draw_item(const t_translation::t_terrain& terrain,
|
||||
void terrain_palette::draw_item(const t_translation::terrain_code& terrain,
|
||||
surface& image, std::stringstream& tooltip_text) {
|
||||
|
||||
const t_translation::t_terrain base_terrain =
|
||||
const t_translation::terrain_code base_terrain =
|
||||
map().get_terrain_info(terrain).default_base();
|
||||
|
||||
//Draw default base for overlay terrains
|
||||
|
@ -206,11 +206,11 @@ void terrain_palette::draw_item(const t_translation::t_terrain& terrain,
|
|||
terrain_palette::terrain_palette(editor_display &gui, const config& cfg,
|
||||
editor_toolkit &toolkit)
|
||||
//TODO avoid magic numbers
|
||||
: editor_palette<t_translation::t_terrain>(gui, cfg, 36, 4, toolkit)
|
||||
: editor_palette<t_translation::terrain_code>(gui, cfg, 36, 4, toolkit)
|
||||
{
|
||||
}
|
||||
|
||||
const std::string& terrain_palette::get_id(const t_translation::t_terrain& terrain)
|
||||
const std::string& terrain_palette::get_id(const t_translation::terrain_code& terrain)
|
||||
{
|
||||
const terrain_type& t_info = map().get_terrain_info(terrain);
|
||||
return t_info.id();
|
||||
|
|
|
@ -26,11 +26,11 @@ namespace editor {
|
|||
|
||||
class editor_toolkit;
|
||||
|
||||
const t_translation::t_terrain& get_selected_fg_terrain();
|
||||
const t_translation::t_terrain& get_selected_bg_terrain();
|
||||
const t_translation::terrain_code& get_selected_fg_terrain();
|
||||
const t_translation::terrain_code& get_selected_bg_terrain();
|
||||
|
||||
/** Palette where the terrain to be drawn can be selected. */
|
||||
class terrain_palette : public editor_palette<t_translation::t_terrain> {
|
||||
class terrain_palette : public editor_palette<t_translation::terrain_code> {
|
||||
|
||||
public:
|
||||
|
||||
|
@ -41,11 +41,11 @@ public:
|
|||
|
||||
virtual void setup(const config& cfg);
|
||||
|
||||
void select_bg_item(const t_translation::t_terrain& terrain);
|
||||
void select_fg_item(const t_translation::t_terrain& terrain);
|
||||
void select_bg_item(const t_translation::terrain_code& terrain);
|
||||
void select_fg_item(const t_translation::terrain_code& terrain);
|
||||
|
||||
const t_translation::t_terrain& selected_fg_item() const;
|
||||
const t_translation::t_terrain& selected_bg_item() const;
|
||||
const t_translation::terrain_code& selected_fg_item() const;
|
||||
const t_translation::terrain_code& selected_bg_item() const;
|
||||
|
||||
virtual std::string get_help_string();
|
||||
|
||||
|
@ -54,9 +54,9 @@ private:
|
|||
virtual void select_bg_item(const std::string& item_id);
|
||||
virtual void select_fg_item(const std::string& item_id);
|
||||
|
||||
virtual const std::string& get_id(const t_translation::t_terrain& terrain);
|
||||
virtual const std::string& get_id(const t_translation::terrain_code& terrain);
|
||||
|
||||
virtual void draw_item(const t_translation::t_terrain& terrain, surface& item_image, std::stringstream& tooltip_text);
|
||||
virtual void draw_item(const t_translation::terrain_code& terrain, surface& item_image, std::stringstream& tooltip_text);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -299,7 +299,7 @@ bool game_board::change_terrain(const map_location &loc, const std::string &t_st
|
|||
const std::string & mode_str, bool replace_if_failed)
|
||||
{
|
||||
//Code internalized from the implementation in lua.cpp
|
||||
t_translation::t_terrain terrain = t_translation::read_terrain_code(t_str);
|
||||
t_translation::terrain_code terrain = t_translation::read_terrain_code(t_str);
|
||||
if (terrain == t_translation::NONE_TERRAIN) return false;
|
||||
|
||||
terrain_type_data::tmerge_mode mode = terrain_type_data::BOTH;
|
||||
|
@ -317,7 +317,7 @@ bool game_board::change_terrain(const map_location &loc, const std::string &t_st
|
|||
* easier to do this as wanted by the author in WML.
|
||||
*/
|
||||
|
||||
t_translation::t_terrain
|
||||
t_translation::terrain_code
|
||||
old_t = map_->get_terrain(loc),
|
||||
new_t = map_->tdata()->merge_terrains(old_t, terrain, mode, replace_if_failed);
|
||||
if (new_t == t_translation::NONE_TERRAIN) return false;
|
||||
|
@ -331,7 +331,7 @@ bool game_board::change_terrain(const map_location &loc, const std::string &t_st
|
|||
|
||||
map_->set_terrain(loc, new_t);
|
||||
|
||||
for(const t_translation::t_terrain &ut : map_->underlying_union_terrain(loc)) {
|
||||
for(const t_translation::terrain_code &ut : map_->underlying_union_terrain(loc)) {
|
||||
preferences::encountered_terrains().insert(ut);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -169,7 +169,7 @@ public:
|
|||
// Functions used in the editor:
|
||||
|
||||
//void draw_terrain_palette(int x, int y, terrain_type::TERRAIN selected);
|
||||
t_translation::t_terrain get_terrain_on(int palx, int paly, int x, int y);
|
||||
t_translation::terrain_code get_terrain_on(int palx, int paly, int x, int y);
|
||||
|
||||
/**
|
||||
* Sets the team controlled by the player using the computer.
|
||||
|
|
|
@ -34,7 +34,7 @@ struct map_location;
|
|||
class vconfig;
|
||||
|
||||
namespace t_translation {
|
||||
struct t_terrain;
|
||||
struct terrain_code;
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,7 +70,7 @@ namespace game_events
|
|||
* Changes a terrain location.
|
||||
* Ensures that villages are properly lost and that new terrains are discovered.
|
||||
*/
|
||||
void change_terrain(const map_location &loc, const t_translation::t_terrain &t,
|
||||
void change_terrain(const map_location &loc, const t_translation::terrain_code &t,
|
||||
terrain_type_data::tmerge_mode mode, bool replace_if_failed);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ bool haloes = true;
|
|||
|
||||
std::map<std::string, std::set<std::string> > completed_campaigns;
|
||||
std::set<std::string> encountered_units_set;
|
||||
std::set<t_translation::t_terrain> encountered_terrains_set;
|
||||
std::set<t_translation::terrain_code> encountered_terrains_set;
|
||||
|
||||
std::map<std::string, std::vector<std::string> > history_map;
|
||||
|
||||
|
@ -149,7 +149,7 @@ manager::manager() :
|
|||
const std::vector<std::string> v (utils::split(preferences::get("encountered_units")));
|
||||
encountered_units_set.insert(v.begin(), v.end());
|
||||
|
||||
const t_translation::t_list terrain (t_translation::read_list(preferences::get("encountered_terrain_list")));
|
||||
const t_translation::ter_list terrain (t_translation::read_list(preferences::get("encountered_terrain_list")));
|
||||
encountered_terrains_set.insert(terrain.begin(), terrain.end());
|
||||
|
||||
if (const config &history = preferences::get_child("history"))
|
||||
|
@ -185,7 +185,7 @@ manager::~manager()
|
|||
preferences::set_child("completed_campaigns", campaigns);
|
||||
std::vector<std::string> v (encountered_units_set.begin(), encountered_units_set.end());
|
||||
preferences::set("encountered_units", utils::join(v));
|
||||
t_translation::t_list terrain (encountered_terrains_set.begin(), encountered_terrains_set.end());
|
||||
t_translation::ter_list terrain (encountered_terrains_set.begin(), encountered_terrains_set.end());
|
||||
preferences::set("encountered_terrain_list", t_translation::write_list(terrain));
|
||||
|
||||
/* Structure of the history
|
||||
|
@ -1097,7 +1097,7 @@ std::set<std::string> &encountered_units() {
|
|||
return encountered_units_set;
|
||||
}
|
||||
|
||||
std::set<t_translation::t_terrain> &encountered_terrains() {
|
||||
std::set<t_translation::terrain_code> &encountered_terrains() {
|
||||
return encountered_terrains_set;
|
||||
}
|
||||
|
||||
|
@ -1167,9 +1167,9 @@ static void encounter_recallable_units(const std::vector<team>& teams){
|
|||
void encounter_map_terrain(const gamemap& map)
|
||||
{
|
||||
map.for_each_loc([&](const map_location& loc) {
|
||||
const t_translation::t_terrain terrain = map.get_terrain(loc);
|
||||
const t_translation::terrain_code terrain = map.get_terrain(loc);
|
||||
preferences::encountered_terrains().insert(terrain);
|
||||
for (t_translation::t_terrain t : map.underlying_union_terrain(loc)) {
|
||||
for (t_translation::terrain_code t : map.underlying_union_terrain(loc)) {
|
||||
preferences::encountered_terrains().insert(t);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -258,7 +258,7 @@ class acquaintance;
|
|||
compression::format save_compression_format();
|
||||
|
||||
std::set<std::string> &encountered_units();
|
||||
std::set<t_translation::t_terrain> &encountered_terrains();
|
||||
std::set<t_translation::terrain_code> &encountered_terrains();
|
||||
|
||||
std::string custom_command();
|
||||
void set_custom_command(const std::string& command);
|
||||
|
|
|
@ -95,7 +95,7 @@ game_state::~game_state() {}
|
|||
static int placing_score(const config& side, const gamemap& map, const map_location& pos)
|
||||
{
|
||||
int positions = 0, liked = 0;
|
||||
const t_translation::t_list terrain = t_translation::read_list(side["terrain_liked"]);
|
||||
const t_translation::ter_list terrain = t_translation::read_list(side["terrain_liked"]);
|
||||
|
||||
for(int i = -8; i != 8; ++i) {
|
||||
for(int j = -8; j != +8; ++j) {
|
||||
|
|
|
@ -89,7 +89,7 @@ cave_map_generator::cave_map_generator_job::cave_map_generator_job(const cave_ma
|
|||
: params(pparams)
|
||||
, flipx_(false)
|
||||
, flipy_(false)
|
||||
, map_(t_translation::t_map(params.width_ + 2 * gamemap::default_border, params.height_ + 2 * gamemap::default_border/*, params.wall_*/))
|
||||
, map_(t_translation::ter_map(params.width_ + 2 * gamemap::default_border, params.height_ + 2 * gamemap::default_border/*, params.wall_*/))
|
||||
, starting_positions_()
|
||||
, chamber_ids_()
|
||||
, chambers_()
|
||||
|
@ -279,8 +279,8 @@ void cave_map_generator::cave_map_generator_job::place_chamber(const chamber& c)
|
|||
|
||||
struct passage_path_calculator : pathfind::cost_calculator
|
||||
{
|
||||
passage_path_calculator(const t_translation::t_map& mapdata,
|
||||
const t_translation::t_terrain & wall,
|
||||
passage_path_calculator(const t_translation::ter_map& mapdata,
|
||||
const t_translation::terrain_code & wall,
|
||||
double laziness, size_t windiness,
|
||||
boost::random::mt19937& rng) :
|
||||
map_(mapdata), wall_(wall), laziness_(laziness), windiness_(windiness), rng_(rng)
|
||||
|
@ -288,8 +288,8 @@ struct passage_path_calculator : pathfind::cost_calculator
|
|||
|
||||
virtual double cost(const map_location& loc, const double so_far) const;
|
||||
private:
|
||||
const t_translation::t_map& map_;
|
||||
t_translation::t_terrain wall_;
|
||||
const t_translation::ter_map& map_;
|
||||
t_translation::terrain_code wall_;
|
||||
double laziness_;
|
||||
size_t windiness_;
|
||||
boost::random::mt19937& rng_;
|
||||
|
@ -336,10 +336,10 @@ void cave_map_generator::cave_map_generator_job::place_passage(const passage& p)
|
|||
}
|
||||
}
|
||||
|
||||
void cave_map_generator::cave_map_generator_job::set_terrain(map_location loc, const t_translation::t_terrain & t)
|
||||
void cave_map_generator::cave_map_generator_job::set_terrain(map_location loc, const t_translation::terrain_code & t)
|
||||
{
|
||||
if (params.on_board(loc)) {
|
||||
t_translation::t_terrain& c = map_.get(loc.x + gamemap::default_border, loc.y + gamemap::default_border);
|
||||
t_translation::terrain_code& c = map_.get(loc.x + gamemap::default_border, loc.y + gamemap::default_border);
|
||||
|
||||
if(c == params.clear_ || c == params.wall_ || c == params.village_) {
|
||||
// Change this terrain.
|
||||
|
|
|
@ -70,7 +70,7 @@ private:
|
|||
|
||||
void place_passage(const passage& p);
|
||||
|
||||
void set_terrain(map_location loc, const t_translation::t_terrain & t);
|
||||
void set_terrain(map_location loc, const t_translation::terrain_code & t);
|
||||
void place_castle(int starting_position, const map_location &loc);
|
||||
|
||||
size_t translate_x(size_t x) const;
|
||||
|
@ -80,7 +80,7 @@ private:
|
|||
const cave_map_generator& params;
|
||||
bool flipx_, flipy_;
|
||||
|
||||
t_translation::t_map map_;
|
||||
t_translation::ter_map map_;
|
||||
t_translation::tstarting_positions starting_positions_;
|
||||
std::map<std::string,size_t> chamber_ids_;
|
||||
std::vector<chamber> chambers_;
|
||||
|
@ -94,7 +94,7 @@ private:
|
|||
return loc.x >= 0 && loc.y >= 0 && loc.x < width_ && loc.y < height_;
|
||||
}
|
||||
|
||||
t_translation::t_terrain wall_, clear_, village_, castle_, keep_;
|
||||
t_translation::terrain_code wall_, clear_, village_, castle_, keep_;
|
||||
|
||||
config cfg_;
|
||||
int width_, height_, village_density_;
|
||||
|
|
|
@ -41,7 +41,7 @@ static lg::log_domain log_mapgen("mapgen");
|
|||
#define LOG_NG LOG_STREAM(info, log_mapgen)
|
||||
|
||||
typedef std::vector<std::vector<int> > height_map;
|
||||
typedef t_translation::t_map terrain_map;
|
||||
typedef t_translation::ter_map terrain_map;
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -77,7 +77,7 @@ namespace {
|
|||
const config& cfg_;
|
||||
int windiness_;
|
||||
int seed_;
|
||||
mutable std::map<t_translation::t_terrain, double> cache_;
|
||||
mutable std::map<t_translation::terrain_code, double> cache_;
|
||||
};
|
||||
|
||||
double road_path_calculator::cost(const map_location& loc, const double /*so_far*/) const
|
||||
|
@ -110,8 +110,8 @@ namespace {
|
|||
windiness += noise;
|
||||
}
|
||||
|
||||
const t_translation::t_terrain c = map_[loc.x][loc.y];
|
||||
const std::map<t_translation::t_terrain, double>::const_iterator itor = cache_.find(c);
|
||||
const t_translation::terrain_code c = map_[loc.x][loc.y];
|
||||
const std::map<t_translation::terrain_code, double>::const_iterator itor = cache_.find(c);
|
||||
if(itor != cache_.end()) {
|
||||
return itor->second*windiness;
|
||||
}
|
||||
|
@ -123,21 +123,21 @@ namespace {
|
|||
res = child["cost"].to_double();
|
||||
}
|
||||
|
||||
cache_.insert(std::pair<t_translation::t_terrain, double>(c,res));
|
||||
cache_.insert(std::pair<t_translation::terrain_code, double>(c,res));
|
||||
return windiness*res;
|
||||
}
|
||||
|
||||
|
||||
struct is_valid_terrain
|
||||
{
|
||||
is_valid_terrain(const t_translation::t_map& map, const t_translation::t_list& terrain_list);
|
||||
is_valid_terrain(const t_translation::ter_map& map, const t_translation::ter_list& terrain_list);
|
||||
bool operator()(int x, int y) const;
|
||||
private:
|
||||
t_translation::t_map map_;
|
||||
const t_translation::t_list& terrain_;
|
||||
t_translation::ter_map map_;
|
||||
const t_translation::ter_list& terrain_;
|
||||
};
|
||||
|
||||
is_valid_terrain::is_valid_terrain(const t_translation::t_map& map, const t_translation::t_list& terrain_list)
|
||||
is_valid_terrain::is_valid_terrain(const t_translation::ter_map& map, const t_translation::ter_list& terrain_list)
|
||||
: map_(map), terrain_(terrain_list)
|
||||
{
|
||||
}
|
||||
|
@ -168,11 +168,11 @@ namespace {
|
|||
explicit terrain_height_mapper(const config& cfg);
|
||||
|
||||
bool convert_terrain(const int height) const;
|
||||
t_translation::t_terrain convert_to() const;
|
||||
t_translation::terrain_code convert_to() const;
|
||||
|
||||
private:
|
||||
int terrain_height;
|
||||
t_translation::t_terrain to;
|
||||
t_translation::terrain_code to;
|
||||
};
|
||||
|
||||
terrain_height_mapper::terrain_height_mapper(const config& cfg) :
|
||||
|
@ -190,7 +190,7 @@ namespace {
|
|||
return height >= terrain_height;
|
||||
}
|
||||
|
||||
t_translation::t_terrain terrain_height_mapper::convert_to() const
|
||||
t_translation::terrain_code terrain_height_mapper::convert_to() const
|
||||
{
|
||||
return to;
|
||||
}
|
||||
|
@ -201,13 +201,13 @@ namespace {
|
|||
public:
|
||||
explicit terrain_converter(const config& cfg);
|
||||
|
||||
bool convert_terrain(const t_translation::t_terrain & terrain, const int height, const int temperature) const;
|
||||
t_translation::t_terrain convert_to() const;
|
||||
bool convert_terrain(const t_translation::terrain_code & terrain, const int height, const int temperature) const;
|
||||
t_translation::terrain_code convert_to() const;
|
||||
|
||||
private:
|
||||
int min_temp, max_temp, min_height, max_height;
|
||||
t_translation::t_list from;
|
||||
t_translation::t_terrain to;
|
||||
t_translation::ter_list from;
|
||||
t_translation::terrain_code to;
|
||||
};
|
||||
|
||||
terrain_converter::terrain_converter(const config& cfg)
|
||||
|
@ -224,13 +224,13 @@ namespace {
|
|||
}
|
||||
}
|
||||
|
||||
bool terrain_converter::convert_terrain(const t_translation::t_terrain & terrain,
|
||||
bool terrain_converter::convert_terrain(const t_translation::terrain_code & terrain,
|
||||
const int height, const int temperature) const
|
||||
{
|
||||
return std::find(from.begin(),from.end(),terrain) != from.end() && height >= min_height && height <= max_height && temperature >= min_temp && temperature <= max_temp && to != t_translation::NONE_TERRAIN;
|
||||
}
|
||||
|
||||
t_translation::t_terrain terrain_converter::convert_to() const
|
||||
t_translation::terrain_code terrain_converter::convert_to() const
|
||||
{
|
||||
return to;
|
||||
}
|
||||
|
@ -614,9 +614,9 @@ static int rank_castle_location(int x, int y, const is_valid_terrain& valid_terr
|
|||
return surrounding_ranking + current_ranking;
|
||||
}
|
||||
|
||||
typedef std::map<t_translation::t_terrain, t_translation::t_list> tcode_list_cache;
|
||||
typedef std::map<t_translation::terrain_code, t_translation::ter_list> tcode_list_cache;
|
||||
|
||||
static map_location place_village(const t_translation::t_map& map,
|
||||
static map_location place_village(const t_translation::ter_map& map,
|
||||
const size_t x, const size_t y, const size_t radius, const config& cfg,
|
||||
tcode_list_cache &adj_liked_cache)
|
||||
{
|
||||
|
@ -632,11 +632,11 @@ static map_location place_village(const t_translation::t_map& map,
|
|||
continue;
|
||||
}
|
||||
|
||||
const t_translation::t_terrain t = map[i.x][i.y];
|
||||
const t_translation::terrain_code t = map[i.x][i.y];
|
||||
const std::string str = t_translation::write_terrain_code(t);
|
||||
if(const config &child = cfg.find_child("village", "terrain", str)) {
|
||||
tcode_list_cache::iterator l = adj_liked_cache.find(t);
|
||||
t_translation::t_list *adjacent_liked;
|
||||
t_translation::ter_list *adjacent_liked;
|
||||
if(l != adj_liked_cache.end()) {
|
||||
adjacent_liked = &(l->second);
|
||||
} else {
|
||||
|
@ -655,7 +655,7 @@ static map_location place_village(const t_translation::t_map& map,
|
|||
continue;
|
||||
}
|
||||
|
||||
const t_translation::t_terrain t2 = map[adj[n].x][adj[n].y];
|
||||
const t_translation::terrain_code t2 = map[adj[n].x][adj[n].y];
|
||||
rating += std::count(adjacent_liked->begin(),adjacent_liked->end(),t2);
|
||||
}
|
||||
|
||||
|
@ -671,7 +671,7 @@ static map_location place_village(const t_translation::t_map& map,
|
|||
|
||||
// "flood fill" a tile name to adjacent tiles of certain terrain
|
||||
static void flood_name(const map_location& start, const std::string& name, std::map<map_location,std::string>& tile_names,
|
||||
const t_translation::t_match& tile_types, const terrain_map& terrain,
|
||||
const t_translation::ter_match& tile_types, const terrain_map& terrain,
|
||||
unsigned width, unsigned height,
|
||||
size_t label_count, std::map<map_location,std::string>* labels, const std::string& full_name) {
|
||||
map_location adj[6];
|
||||
|
@ -685,7 +685,7 @@ static void flood_name(const map_location& start, const std::string& name, std::
|
|||
continue;
|
||||
}
|
||||
|
||||
const t_translation::t_terrain terr = terrain[adj[n].x + (width / 3)][adj[n].y + (height / 3)];
|
||||
const t_translation::terrain_code terr = terrain[adj[n].x + (width / 3)][adj[n].y + (height / 3)];
|
||||
const map_location loc(adj[n].x, adj[n].y);
|
||||
if((t_translation::terrain_matches(terr, tile_types)) && (tile_names.find(loc) == tile_names.end())) {
|
||||
tile_names.insert(std::pair<map_location, std::string>(loc, name));
|
||||
|
@ -764,7 +764,7 @@ std::string default_map_generator_job::default_generate_map(generator_data data,
|
|||
flatland = t_translation::write_terrain_code(t_translation::GRASS_LAND);
|
||||
}
|
||||
|
||||
const t_translation::t_terrain grassland = t_translation::read_terrain_code(flatland);
|
||||
const t_translation::terrain_code grassland = t_translation::read_terrain_code(flatland);
|
||||
|
||||
std::vector<terrain_height_mapper> height_conversion;
|
||||
for(const config& h : cfg.child_range("height")) {
|
||||
|
@ -921,7 +921,7 @@ std::string default_map_generator_job::default_generate_map(generator_data data,
|
|||
* Castle configuration tag contains a 'valid_terrain' attribute which is a
|
||||
* list of terrains that the castle may appear on.
|
||||
*/
|
||||
const t_translation::t_list list =
|
||||
const t_translation::ter_list list =
|
||||
t_translation::read_list(castle_config["valid_terrain"]);
|
||||
|
||||
const is_valid_terrain terrain_tester(terrain, list);
|
||||
|
@ -1122,7 +1122,7 @@ std::string default_map_generator_job::default_generate_map(generator_data data,
|
|||
// Just a plain terrain substitution for a road
|
||||
const std::string& convert_to = child["convert_to"];
|
||||
if(!convert_to.empty()) {
|
||||
const t_translation::t_terrain letter = t_translation::read_terrain_code(convert_to);
|
||||
const t_translation::terrain_code letter = t_translation::read_terrain_code(convert_to);
|
||||
if(misc_labels != nullptr && terrain[x][y] != letter && name_count++ == name_frequency && !on_bridge) {
|
||||
misc_labels->insert(std::pair<map_location,std::string>(map_location(x-data.width/3,y-data.height/3),road_name));
|
||||
name_count = 0;
|
||||
|
@ -1181,7 +1181,7 @@ std::string default_map_generator_job::default_generate_map(generator_data data,
|
|||
for(int y = data.height / 3; y < (data.height / 3) * 2;y++) {
|
||||
//check the terrain of the tile
|
||||
const map_location loc(x - data.width / 3, y - data.height / 3);
|
||||
const t_translation::t_terrain terr = terrain[x][y];
|
||||
const t_translation::terrain_code terr = terrain[x][y];
|
||||
std::string name, base_name;
|
||||
std::set<std::string> used_names;
|
||||
|
||||
|
@ -1310,11 +1310,11 @@ std::string default_map_generator_job::default_generate_map(generator_data data,
|
|||
get_adjacent_tiles(loc,adj);
|
||||
|
||||
std::string name_type = "village";
|
||||
const t_translation::t_list
|
||||
field = t_translation::t_list(1, t_translation::GRASS_LAND),
|
||||
forest = t_translation::t_list(1, t_translation::FOREST),
|
||||
mountain = t_translation::t_list(1, t_translation::MOUNTAIN),
|
||||
hill = t_translation::t_list(1, t_translation::HILL);
|
||||
const t_translation::ter_list
|
||||
field = t_translation::ter_list(1, t_translation::GRASS_LAND),
|
||||
forest = t_translation::ter_list(1, t_translation::FOREST),
|
||||
mountain = t_translation::ter_list(1, t_translation::MOUNTAIN),
|
||||
hill = t_translation::ter_list(1, t_translation::HILL);
|
||||
|
||||
size_t field_count = 0, forest_count = 0, mountain_count = 0, hill_count = 0;
|
||||
|
||||
|
@ -1372,7 +1372,7 @@ std::string default_map_generator_job::default_generate_map(generator_data data,
|
|||
break;
|
||||
}
|
||||
|
||||
const t_translation::t_terrain terr = terrain[adj[n].x+data.width/3][adj[n].y+data.height/3];
|
||||
const t_translation::terrain_code terr = terrain[adj[n].x+data.width/3][adj[n].y+data.height/3];
|
||||
|
||||
if(std::count(field.begin(),field.end(),terr) > 0) {
|
||||
++field_count;
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
|
||||
private:
|
||||
typedef std::vector<std::vector<int> > height_map;
|
||||
typedef t_translation::t_map terrain_map;
|
||||
typedef t_translation::ter_map terrain_map;
|
||||
|
||||
bool generate_river_internal(const height_map& heights,
|
||||
terrain_map& terrain, int x, int y, std::vector<map_location>& river,
|
||||
|
@ -54,7 +54,7 @@ private:
|
|||
size_t iterations, size_t hill_size,
|
||||
size_t island_size, size_t island_off_center);
|
||||
|
||||
bool generate_lake(t_translation::t_map& terrain, int x, int y, int lake_fall_off, std::set<map_location>& locs_touched);
|
||||
bool generate_lake(t_translation::ter_map& terrain, int x, int y, int lake_fall_off, std::set<map_location>& locs_touched);
|
||||
map_location random_point_at_side(size_t width, size_t height);
|
||||
|
||||
boost::random::mt19937 rng_;
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "serialization/unicode_cast.hpp" // for unicode_cast
|
||||
#include "serialization/unicode_types.hpp" // for char_t, etc
|
||||
#include "terrain/terrain.hpp" // for terrain_type
|
||||
#include "terrain/translation.hpp" // for operator==, t_list, etc
|
||||
#include "terrain/translation.hpp" // for operator==, ter_list, etc
|
||||
#include "terrain/type_data.hpp" // for terrain_type_data, etc
|
||||
#include "time_of_day.hpp" // for time_of_day
|
||||
#include "tod_manager.hpp" // for tod_manager
|
||||
|
@ -836,9 +836,9 @@ void generate_terrain_sections(const config* /*help_cfg*/, section& sec, int /*l
|
|||
|
||||
std::map<std::string, section> base_map;
|
||||
|
||||
const t_translation::t_list& t_listi = tdata->list();
|
||||
const t_translation::ter_list& t_listi = tdata->list();
|
||||
|
||||
for (const t_translation::t_terrain& t : t_listi) {
|
||||
for (const t_translation::terrain_code& t : t_listi) {
|
||||
|
||||
const terrain_type& info = tdata->get_terrain_info(t);
|
||||
|
||||
|
@ -853,8 +853,8 @@ void generate_terrain_sections(const config* /*help_cfg*/, section& sec, int /*l
|
|||
terrain_topic.id = hidden_symbol(hidden) + terrain_prefix + info.id();
|
||||
terrain_topic.text = new terrain_topic_generator(info);
|
||||
|
||||
t_translation::t_list base_terrains = tdata->underlying_union_terrain(t);
|
||||
for (const t_translation::t_terrain& base : base_terrains) {
|
||||
t_translation::ter_list base_terrains = tdata->underlying_union_terrain(t);
|
||||
for (const t_translation::terrain_code& base : base_terrains) {
|
||||
|
||||
const terrain_type& base_info = tdata->get_terrain_info(base);
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "movetype.hpp" // for movetype, movetype::effects, etc
|
||||
#include "units/race.hpp" // for unit_race, etc
|
||||
#include "terrain/terrain.hpp" // for terrain_type
|
||||
#include "terrain/translation.hpp" // for operator==, t_list, etc
|
||||
#include "terrain/translation.hpp" // for operator==, ter_list, etc
|
||||
#include "terrain/type_data.hpp" // for terrain_type_data, etc
|
||||
#include "tstring.hpp" // for t_string, operator<<
|
||||
#include "units/helper.hpp" // for resistance_color
|
||||
|
@ -49,8 +49,8 @@ static std::string best_str(bool best) {
|
|||
return "<format>color='" + color_policy + "' text='" + lang_policy + "'</format>";
|
||||
}
|
||||
|
||||
typedef t_translation::t_list::const_iterator t_it;
|
||||
// Gets an english desription of a terrain t_list alias behavior: "Best of cave, hills", "Worst of Swamp, Forest" etc.
|
||||
typedef t_translation::ter_list::const_iterator t_it;
|
||||
// Gets an english desription of a terrain ter_list alias behavior: "Best of cave, hills", "Worst of Swamp, Forest" etc.
|
||||
static std::string print_behavior_description(t_it start, t_it end, const tdata_cache & tdata, bool first_level = true, bool begin_best = true)
|
||||
{
|
||||
|
||||
|
@ -137,12 +137,12 @@ std::string terrain_topic_generator::operator()() const {
|
|||
|
||||
if (!(type_.union_type().size() == 1 && type_.union_type()[0] == type_.number() && type_.is_nonnull())) {
|
||||
|
||||
const t_translation::t_list& underlying_mvt_terrains = tdata->underlying_mvt_terrain(type_.number());
|
||||
const t_translation::ter_list& underlying_mvt_terrains = tdata->underlying_mvt_terrain(type_.number());
|
||||
|
||||
ss << "\n" << _("Base Terrain: ");
|
||||
|
||||
bool first = true;
|
||||
for (const t_translation::t_terrain& underlying_terrain : underlying_mvt_terrains) {
|
||||
for (const t_translation::terrain_code& underlying_terrain : underlying_mvt_terrains) {
|
||||
const terrain_type& mvt_base = tdata->get_terrain_info(underlying_terrain);
|
||||
|
||||
if (mvt_base.editor_name().empty()) continue;
|
||||
|
@ -161,7 +161,7 @@ std::string terrain_topic_generator::operator()() const {
|
|||
ss << "\n" << _("Movement properties: ");
|
||||
ss << print_behavior_description(underlying_mvt_terrains.begin(), underlying_mvt_terrains.end(), tdata) << "\n";
|
||||
|
||||
const t_translation::t_list& underlying_def_terrains = tdata->underlying_def_terrain(type_.number());
|
||||
const t_translation::ter_list& underlying_def_terrains = tdata->underlying_def_terrain(type_.number());
|
||||
ss << "\n" << _("Defense properties: ");
|
||||
ss << print_behavior_description(underlying_def_terrains.begin(), underlying_def_terrains.end(), tdata) << "\n";
|
||||
}
|
||||
|
@ -197,15 +197,15 @@ std::string terrain_topic_generator::operator()() const {
|
|||
ss << "\nEditor Image: " << type_.editor_image() << "\n";
|
||||
}
|
||||
|
||||
const t_translation::t_list& underlying_mvt_terrains = tdata->underlying_mvt_terrain(type_.number());
|
||||
const t_translation::ter_list& underlying_mvt_terrains = tdata->underlying_mvt_terrain(type_.number());
|
||||
ss << "\nDebug Mvt Description String:";
|
||||
for (const t_translation::t_terrain & t : underlying_mvt_terrains) {
|
||||
for (const t_translation::terrain_code & t : underlying_mvt_terrains) {
|
||||
ss << " " << t;
|
||||
}
|
||||
|
||||
const t_translation::t_list& underlying_def_terrains = tdata->underlying_def_terrain(type_.number());
|
||||
const t_translation::ter_list& underlying_def_terrains = tdata->underlying_def_terrain(type_.number());
|
||||
ss << "\nDebug Def Description String:";
|
||||
for (const t_translation::t_terrain & t : underlying_def_terrains) {
|
||||
for (const t_translation::terrain_code & t : underlying_def_terrains) {
|
||||
ss << " " << t;
|
||||
}
|
||||
|
||||
|
@ -626,12 +626,12 @@ std::string unit_topic_generator::operator()() const {
|
|||
}
|
||||
|
||||
table.push_back(first_row);
|
||||
std::set<t_translation::t_terrain>::const_iterator terrain_it =
|
||||
std::set<t_translation::terrain_code>::const_iterator terrain_it =
|
||||
preferences::encountered_terrains().begin();
|
||||
|
||||
for (; terrain_it != preferences::encountered_terrains().end();
|
||||
++terrain_it) {
|
||||
const t_translation::t_terrain terrain = *terrain_it;
|
||||
const t_translation::terrain_code terrain = *terrain_it;
|
||||
if (terrain == t_translation::FOGGED || terrain == t_translation::VOID_TERRAIN || terrain == t_translation::OFF_MAP_USER) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ namespace image {
|
|||
typedef cache_type<surface> image_cache;
|
||||
typedef cache_type<bool> bool_cache;
|
||||
|
||||
typedef std::map<t_translation::t_terrain, surface> mini_terrain_cache_map;
|
||||
typedef std::map<t_translation::terrain_code, surface> mini_terrain_cache_map;
|
||||
extern mini_terrain_cache_map mini_terrain_cache;
|
||||
extern mini_terrain_cache_map mini_fogged_terrain_cache;
|
||||
extern mini_terrain_cache_map mini_highlighted_terrain_cache;
|
||||
|
|
|
@ -43,7 +43,7 @@ static lg::log_domain log_config("config");
|
|||
#define DBG_G LOG_STREAM(debug, lg::general())
|
||||
|
||||
/** Gets the list of terrains. */
|
||||
const t_translation::t_list& gamemap::get_terrain_list() const
|
||||
const t_translation::ter_list& gamemap::get_terrain_list() const
|
||||
{
|
||||
return tdata_->list();
|
||||
}
|
||||
|
@ -54,11 +54,11 @@ const terrain_type& gamemap::get_terrain_info(const map_location &loc) const
|
|||
return tdata_->get_terrain_info(get_terrain(loc));
|
||||
}
|
||||
|
||||
const t_translation::t_list& gamemap::underlying_mvt_terrain(const map_location& loc) const
|
||||
const t_translation::ter_list& gamemap::underlying_mvt_terrain(const map_location& loc) const
|
||||
{ return underlying_mvt_terrain(get_terrain(loc)); }
|
||||
const t_translation::t_list& gamemap::underlying_def_terrain(const map_location& loc) const
|
||||
const t_translation::ter_list& gamemap::underlying_def_terrain(const map_location& loc) const
|
||||
{ return underlying_def_terrain(get_terrain(loc)); }
|
||||
const t_translation::t_list& gamemap::underlying_union_terrain(const map_location& loc) const
|
||||
const t_translation::ter_list& gamemap::underlying_union_terrain(const map_location& loc) const
|
||||
{ return underlying_union_terrain(get_terrain(loc)); }
|
||||
std::string gamemap::get_terrain_string(const map_location& loc) const
|
||||
{ return get_terrain_string(get_terrain(loc)); }
|
||||
|
@ -76,28 +76,28 @@ bool gamemap::is_keep(const map_location& loc) const
|
|||
|
||||
|
||||
/* Forwarded methods of tdata_ */
|
||||
const t_translation::t_list& gamemap::underlying_mvt_terrain(const t_translation::t_terrain & terrain) const
|
||||
const t_translation::ter_list& gamemap::underlying_mvt_terrain(const t_translation::terrain_code & terrain) const
|
||||
{ return tdata_->underlying_mvt_terrain(terrain); }
|
||||
const t_translation::t_list& gamemap::underlying_def_terrain(const t_translation::t_terrain & terrain) const
|
||||
const t_translation::ter_list& gamemap::underlying_def_terrain(const t_translation::terrain_code & terrain) const
|
||||
{ return tdata_->underlying_def_terrain(terrain); }
|
||||
const t_translation::t_list& gamemap::underlying_union_terrain(const t_translation::t_terrain & terrain) const
|
||||
const t_translation::ter_list& gamemap::underlying_union_terrain(const t_translation::terrain_code & terrain) const
|
||||
{ return tdata_->underlying_union_terrain(terrain); }
|
||||
std::string gamemap::get_terrain_string(const t_translation::t_terrain & terrain) const
|
||||
std::string gamemap::get_terrain_string(const t_translation::terrain_code & terrain) const
|
||||
{ return tdata_->get_terrain_string(terrain); }
|
||||
std::string gamemap::get_terrain_editor_string(const t_translation::t_terrain & terrain) const
|
||||
std::string gamemap::get_terrain_editor_string(const t_translation::terrain_code & terrain) const
|
||||
{ return tdata_->get_terrain_editor_string(terrain); }
|
||||
std::string gamemap::get_underlying_terrain_string(const t_translation::t_terrain& terrain) const
|
||||
std::string gamemap::get_underlying_terrain_string(const t_translation::terrain_code& terrain) const
|
||||
{ return tdata_->get_underlying_terrain_string(terrain); }
|
||||
bool gamemap::is_village(const t_translation::t_terrain & terrain) const
|
||||
bool gamemap::is_village(const t_translation::terrain_code & terrain) const
|
||||
{ return tdata_->get_terrain_info(terrain).is_village(); }
|
||||
int gamemap::gives_healing(const t_translation::t_terrain & terrain) const
|
||||
int gamemap::gives_healing(const t_translation::terrain_code & terrain) const
|
||||
{ return tdata_->get_terrain_info(terrain).gives_healing(); }
|
||||
bool gamemap::is_castle(const t_translation::t_terrain & terrain) const
|
||||
bool gamemap::is_castle(const t_translation::terrain_code & terrain) const
|
||||
{ return tdata_->get_terrain_info(terrain).is_castle(); }
|
||||
bool gamemap::is_keep(const t_translation::t_terrain & terrain) const
|
||||
bool gamemap::is_keep(const t_translation::terrain_code & terrain) const
|
||||
{ return tdata_->get_terrain_info(terrain).is_keep(); }
|
||||
|
||||
const terrain_type& gamemap::get_terrain_info(const t_translation::t_terrain & terrain) const
|
||||
const terrain_type& gamemap::get_terrain_info(const t_translation::terrain_code & terrain) const
|
||||
{ return tdata_->get_terrain_info(terrain); }
|
||||
|
||||
void gamemap::write_terrain(const map_location &loc, config& cfg) const
|
||||
|
@ -123,7 +123,7 @@ gamemap::~gamemap()
|
|||
|
||||
void gamemap::read(const std::string& data, const bool allow_invalid)
|
||||
{
|
||||
tiles_ = t_translation::t_map();
|
||||
tiles_ = t_translation::ter_map();
|
||||
villages_.clear();
|
||||
starting_positions_.clear();
|
||||
|
||||
|
@ -158,7 +158,7 @@ void gamemap::read(const std::string& data, const bool allow_invalid)
|
|||
for(int y = 0; y < total_height(); ++y) {
|
||||
|
||||
// Is the terrain valid?
|
||||
t_translation::t_terrain t = tiles_.get(x, y);
|
||||
t_translation::terrain_code t = tiles_.get(x, y);
|
||||
if(tdata_->map().count(t) == 0) {
|
||||
if(!tdata_->try_merge_terrains(t)) {
|
||||
std::stringstream ss;
|
||||
|
@ -213,10 +213,10 @@ namespace
|
|||
{
|
||||
struct overlay_rule
|
||||
{
|
||||
t_translation::t_list old_;
|
||||
t_translation::t_list new_;
|
||||
t_translation::ter_list old_;
|
||||
t_translation::ter_list new_;
|
||||
terrain_type_data::tmerge_mode mode_;
|
||||
boost::optional<t_translation::t_terrain> terrain_;
|
||||
boost::optional<t_translation::terrain_code> terrain_;
|
||||
bool use_old_;
|
||||
bool replace_if_failed_;
|
||||
|
||||
|
@ -244,7 +244,7 @@ void gamemap::overlay(const gamemap& m, const config& rules_cfg, map_location lo
|
|||
rules[i].old_ = t_translation::read_list(cfg["old"]);
|
||||
rules[i].new_ = t_translation::read_list(cfg["new"]);
|
||||
rules[i].mode_ = cfg["layer"] == "base" ? terrain_type_data::BASE : cfg["layer"] == "overlay" ? terrain_type_data::OVERLAY : terrain_type_data::BOTH;
|
||||
const t_translation::t_list& terrain = t_translation::read_list(cfg["terrain"]);
|
||||
const t_translation::ter_list& terrain = t_translation::read_list(cfg["terrain"]);
|
||||
if(!terrain.empty()) {
|
||||
rules[i].terrain_ = terrain[0];
|
||||
}
|
||||
|
@ -262,8 +262,8 @@ void gamemap::overlay(const gamemap& m, const config& rules_cfg, map_location lo
|
|||
const int x2 = x1 + xpos;
|
||||
const int y2 = y1 + ypos + ((xpos & 1) && (x1 & 1) ? 1 : 0);
|
||||
|
||||
const t_translation::t_terrain t = m[{x1,y1}];
|
||||
const t_translation::t_terrain current = (*this)[{x2, y2}];
|
||||
const t_translation::terrain_code t = m[{x1,y1}];
|
||||
const t_translation::terrain_code current = (*this)[{x2, y2}];
|
||||
|
||||
if(t == t_translation::FOGGED || t == t_translation::VOID_TERRAIN) {
|
||||
continue;
|
||||
|
@ -300,14 +300,14 @@ void gamemap::overlay(const gamemap& m, const config& rules_cfg, map_location lo
|
|||
}
|
||||
}
|
||||
|
||||
t_translation::t_terrain gamemap::get_terrain(const map_location& loc) const
|
||||
t_translation::terrain_code gamemap::get_terrain(const map_location& loc) const
|
||||
{
|
||||
|
||||
if(on_board_with_border(loc)) {
|
||||
return (*this)[loc];
|
||||
}
|
||||
|
||||
return loc == map_location::null_location() ? t_translation::NONE_TERRAIN : t_translation::t_terrain();
|
||||
return loc == map_location::null_location() ? t_translation::NONE_TERRAIN : t_translation::terrain_code();
|
||||
}
|
||||
|
||||
map_location gamemap::special_location(const std::string& id) const
|
||||
|
@ -380,13 +380,13 @@ bool gamemap::on_board_with_border(const map_location& loc) const
|
|||
loc.y >= -border_size() && loc.y < h_ + border_size();
|
||||
}
|
||||
|
||||
void gamemap::set_terrain(const map_location& loc, const t_translation::t_terrain & terrain, const terrain_type_data::tmerge_mode mode, bool replace_if_failed) {
|
||||
void gamemap::set_terrain(const map_location& loc, const t_translation::terrain_code & terrain, const terrain_type_data::tmerge_mode mode, bool replace_if_failed) {
|
||||
if(!on_board_with_border(loc)) {
|
||||
// off the map: ignore request
|
||||
return;
|
||||
}
|
||||
|
||||
t_translation::t_terrain new_terrain = tdata_->merge_terrains(get_terrain(loc), terrain, mode, replace_if_failed);
|
||||
t_translation::terrain_code new_terrain = tdata_->merge_terrains(get_terrain(loc), terrain, mode, replace_if_failed);
|
||||
|
||||
if(new_terrain == t_translation::NONE_TERRAIN) {
|
||||
return;
|
||||
|
@ -454,7 +454,7 @@ std::vector<map_location> gamemap::parse_location_range(const std::string &x, co
|
|||
|
||||
void gamemap::add_fog_border()
|
||||
{
|
||||
t_translation::t_map tiles_new(tiles_.w + 1, tiles_.h + 1);
|
||||
t_translation::ter_map tiles_new(tiles_.w + 1, tiles_.h + 1);
|
||||
for (int x = 0, x_end = tiles_new.w; x != x_end; ++x) {
|
||||
for (int y = 0, y_end = tiles_new.h; y != y_end; ++y) {
|
||||
tiles_new.get(x, y) = (x == 0 || y == 0) ? t_translation::VOID_TERRAIN : tiles_.get(x - 1, y - 1);
|
||||
|
|
|
@ -37,9 +37,9 @@ class gamemap
|
|||
public:
|
||||
|
||||
/* Get info from the terrain_type_data object about the terrain at a location */
|
||||
const t_translation::t_list& underlying_mvt_terrain(const map_location& loc) const;
|
||||
const t_translation::t_list& underlying_def_terrain(const map_location& loc) const;
|
||||
const t_translation::t_list& underlying_union_terrain(const map_location& loc) const;
|
||||
const t_translation::ter_list& underlying_mvt_terrain(const map_location& loc) const;
|
||||
const t_translation::ter_list& underlying_def_terrain(const map_location& loc) const;
|
||||
const t_translation::ter_list& underlying_union_terrain(const map_location& loc) const;
|
||||
std::string get_terrain_string(const map_location& loc) const;
|
||||
std::string get_terrain_editor_string(const map_location& loc) const;
|
||||
|
||||
|
@ -49,20 +49,20 @@ public:
|
|||
bool is_keep(const map_location& loc) const;
|
||||
|
||||
/* The above wrappers, but which takes a terrain. This is the old syntax, preserved for brevity in certain cases. */
|
||||
const t_translation::t_list& underlying_mvt_terrain(const t_translation::t_terrain & terrain) const;
|
||||
const t_translation::t_list& underlying_def_terrain(const t_translation::t_terrain & terrain) const;
|
||||
const t_translation::t_list& underlying_union_terrain(const t_translation::t_terrain & terrain) const;
|
||||
std::string get_terrain_string(const t_translation::t_terrain& terrain) const;
|
||||
std::string get_terrain_editor_string(const t_translation::t_terrain& terrain) const;
|
||||
std::string get_underlying_terrain_string(const t_translation::t_terrain& terrain) const;
|
||||
const t_translation::ter_list& underlying_mvt_terrain(const t_translation::terrain_code & terrain) const;
|
||||
const t_translation::ter_list& underlying_def_terrain(const t_translation::terrain_code & terrain) const;
|
||||
const t_translation::ter_list& underlying_union_terrain(const t_translation::terrain_code & terrain) const;
|
||||
std::string get_terrain_string(const t_translation::terrain_code& terrain) const;
|
||||
std::string get_terrain_editor_string(const t_translation::terrain_code& terrain) const;
|
||||
std::string get_underlying_terrain_string(const t_translation::terrain_code& terrain) const;
|
||||
|
||||
bool is_village(const t_translation::t_terrain & terrain) const;
|
||||
int gives_healing(const t_translation::t_terrain & terrain) const;
|
||||
bool is_castle(const t_translation::t_terrain & terrain) const;
|
||||
bool is_keep(const t_translation::t_terrain & terrain) const;
|
||||
bool is_village(const t_translation::terrain_code & terrain) const;
|
||||
int gives_healing(const t_translation::terrain_code & terrain) const;
|
||||
bool is_castle(const t_translation::terrain_code & terrain) const;
|
||||
bool is_keep(const t_translation::terrain_code & terrain) const;
|
||||
|
||||
// Also expose this for the same reason:
|
||||
const terrain_type& get_terrain_info(const t_translation::t_terrain & terrain) const;
|
||||
const terrain_type& get_terrain_info(const t_translation::terrain_code & terrain) const;
|
||||
|
||||
/* Get the underlying terrain_type_data object. */
|
||||
const tdata_cache & tdata() const { return tdata_; }
|
||||
|
@ -102,13 +102,13 @@ public:
|
|||
/** Real height of the map, including borders */
|
||||
int total_height() const { return tiles_.h; }
|
||||
|
||||
const t_translation::t_terrain operator[](const map_location& loc) const
|
||||
const t_translation::terrain_code operator[](const map_location& loc) const
|
||||
{
|
||||
return tiles_.get(loc.x + border_size(), loc.y + border_size());
|
||||
}
|
||||
private:
|
||||
//private method, use set_terrain instead which also updates villages_.
|
||||
t_translation::t_terrain& operator[](const map_location& loc)
|
||||
t_translation::terrain_code& operator[](const map_location& loc)
|
||||
{
|
||||
return tiles_.get(loc.x + border_size(), loc.y + border_size());
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ public:
|
|||
* Hexes off the map may be looked up, and their 'emulated' terrain will
|
||||
* also be returned. This allows proper drawing of the edges of the map.
|
||||
*/
|
||||
t_translation::t_terrain get_terrain(const map_location& loc) const;
|
||||
t_translation::terrain_code get_terrain(const map_location& loc) const;
|
||||
|
||||
/** Writes the terrain at loc to cfg. */
|
||||
void write_terrain(const map_location &loc, config& cfg) const;
|
||||
|
@ -161,13 +161,13 @@ public:
|
|||
const terrain_type& get_terrain_info(const map_location &loc) const;
|
||||
|
||||
/** Gets the list of terrains. */
|
||||
const t_translation::t_list& get_terrain_list() const;
|
||||
const t_translation::ter_list& get_terrain_list() const;
|
||||
|
||||
/**
|
||||
* Clobbers over the terrain at location 'loc', with the given terrain.
|
||||
* Uses mode and replace_if_failed like merge_terrains().
|
||||
*/
|
||||
void set_terrain(const map_location& loc, const t_translation::t_terrain & terrain, const terrain_type_data::tmerge_mode mode=terrain_type_data::BOTH, bool replace_if_failed = false);
|
||||
void set_terrain(const map_location& loc, const t_translation::terrain_code & terrain, const terrain_type_data::tmerge_mode mode=terrain_type_data::BOTH, bool replace_if_failed = false);
|
||||
|
||||
/**
|
||||
* Maximum number of players supported.
|
||||
|
@ -208,7 +208,7 @@ public:
|
|||
}
|
||||
void add_fog_border();
|
||||
protected:
|
||||
t_translation::t_map tiles_;
|
||||
t_translation::ter_map tiles_;
|
||||
|
||||
tstarting_positions starting_positions_;
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
|
|||
// shrouded hex are not considered fogged (no need to fog a black image)
|
||||
const bool fogged = (vw != nullptr && !shrouded && vw->fogged(loc));
|
||||
|
||||
const t_translation::t_terrain terrain = shrouded ?
|
||||
const t_translation::terrain_code terrain = shrouded ?
|
||||
t_translation::VOID_TERRAIN : map[loc];
|
||||
const terrain_type& terrain_info = tdata.get_terrain_info(terrain);
|
||||
|
||||
|
@ -190,8 +190,8 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
|
|||
col = int_to_color(it->second.rep());
|
||||
|
||||
bool first = true;
|
||||
const t_translation::t_list& underlying_terrains = tdata.underlying_union_terrain(terrain);
|
||||
for(const t_translation::t_terrain& underlying_terrain : underlying_terrains) {
|
||||
const t_translation::ter_list& underlying_terrains = tdata.underlying_union_terrain(terrain);
|
||||
for(const t_translation::terrain_code& underlying_terrain : underlying_terrains) {
|
||||
|
||||
const std::string& terrain_id = tdata.get_terrain_info(underlying_terrain).id();
|
||||
it = game_config::team_rgb_range.find(terrain_id);
|
||||
|
|
|
@ -116,7 +116,7 @@ public:
|
|||
/// Read-only access to our parameters.
|
||||
const parameters & params() const { return params_; }
|
||||
/// Returns the value associated with the given terrain.
|
||||
int value(const t_translation::t_terrain & terrain,
|
||||
int value(const t_translation::terrain_code & terrain,
|
||||
const terrain_info * fallback) const
|
||||
{ return value(terrain, fallback, 0); }
|
||||
/// If there is data, writes it to the config.
|
||||
|
@ -127,14 +127,14 @@ public:
|
|||
|
||||
private:
|
||||
/// Calculates the value associated with the given terrain.
|
||||
int calc_value(const t_translation::t_terrain & terrain,
|
||||
int calc_value(const t_translation::terrain_code & terrain,
|
||||
const terrain_info * fallback, unsigned recurse_count) const;
|
||||
/// Returns the value associated with the given terrain (possibly cached).
|
||||
int value(const t_translation::t_terrain & terrain,
|
||||
int value(const t_translation::terrain_code & terrain,
|
||||
const terrain_info * fallback, unsigned recurse_count) const;
|
||||
|
||||
private:
|
||||
typedef std::map<t_translation::t_terrain, int> cache_t;
|
||||
typedef std::map<t_translation::terrain_code, int> cache_t;
|
||||
|
||||
/// Config describing the terrain values.
|
||||
config cfg_;
|
||||
|
@ -268,7 +268,7 @@ void movetype::terrain_info::data::write(
|
|||
* @param[in] recurse_count Detects (probable) infinite recursion.
|
||||
*/
|
||||
int movetype::terrain_info::data::calc_value(
|
||||
const t_translation::t_terrain & terrain,
|
||||
const t_translation::terrain_code & terrain,
|
||||
const terrain_info * fallback,
|
||||
unsigned recurse_count) const
|
||||
{
|
||||
|
@ -288,7 +288,7 @@ int movetype::terrain_info::data::calc_value(
|
|||
assert(tdata);
|
||||
|
||||
// Get a list of underlying terrains.
|
||||
const t_translation::t_list & underlying = params_.use_move ?
|
||||
const t_translation::ter_list & underlying = params_.use_move ?
|
||||
tdata->underlying_mvt_terrain(terrain) :
|
||||
tdata->underlying_def_terrain(terrain);
|
||||
assert(!underlying.empty());
|
||||
|
@ -340,7 +340,7 @@ int movetype::terrain_info::data::calc_value(
|
|||
params_.max_value;
|
||||
|
||||
// Loop through all underlying terrains.
|
||||
t_translation::t_list::const_iterator i;
|
||||
t_translation::ter_list::const_iterator i;
|
||||
for ( i = underlying.begin(); i != underlying.end(); ++i )
|
||||
{
|
||||
if ( *i == t_translation::PLUS ) {
|
||||
|
@ -373,7 +373,7 @@ int movetype::terrain_info::data::calc_value(
|
|||
* @param[in] recurse_count Detects (probable) infinite recursion.
|
||||
*/
|
||||
int movetype::terrain_info::data::value(
|
||||
const t_translation::t_terrain & terrain,
|
||||
const t_translation::terrain_code & terrain,
|
||||
const terrain_info * fallback,
|
||||
unsigned recurse_count) const
|
||||
{
|
||||
|
@ -540,7 +540,7 @@ void movetype::terrain_info::merge(const config & new_values, bool overwrite)
|
|||
/**
|
||||
* Returns the value associated with the given terrain.
|
||||
*/
|
||||
int movetype::terrain_info::value(const t_translation::t_terrain & terrain) const
|
||||
int movetype::terrain_info::value(const t_translation::terrain_code & terrain) const
|
||||
{
|
||||
return data_->value(terrain, fallback_);
|
||||
}
|
||||
|
@ -737,8 +737,8 @@ movetype::movetype(const movetype & that) :
|
|||
/**
|
||||
* Checks if we have a defense cap (nontrivial min value) for any of the given terrain types.
|
||||
*/
|
||||
bool movetype::has_terrain_defense_caps(const std::set<t_translation::t_terrain> & ts) const {
|
||||
for (const t_translation::t_terrain & t : ts) {
|
||||
bool movetype::has_terrain_defense_caps(const std::set<t_translation::terrain_code> & ts) const {
|
||||
for (const t_translation::terrain_code & t : ts) {
|
||||
if (defense_.capped(t))
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "serialization/string_utils.hpp"
|
||||
|
||||
class attack_type;
|
||||
namespace t_translation { struct t_terrain; }
|
||||
namespace t_translation { struct terrain_code; }
|
||||
|
||||
|
||||
/// The basic "size" of the unit - flying, small land, large land, etc.
|
||||
|
@ -57,7 +57,7 @@ class movetype
|
|||
/// Merges the given config over the existing values.
|
||||
void merge(const config & new_values, bool overwrite);
|
||||
/// Returns the value associated with the given terrain.
|
||||
int value(const t_translation::t_terrain & terrain) const;
|
||||
int value(const t_translation::terrain_code & terrain) const;
|
||||
/// Writes our data to a config.
|
||||
void write(config & cfg, const std::string & child_name="", bool merged=true) const;
|
||||
|
||||
|
@ -104,7 +104,7 @@ public:
|
|||
|
||||
/// Returns the cost associated with the given terrain.
|
||||
/// Costs are doubled when @a slowed is true.
|
||||
int cost(const t_translation::t_terrain & terrain, bool slowed=false) const
|
||||
int cost(const t_translation::terrain_code & terrain, bool slowed=false) const
|
||||
{ int result = value(terrain);
|
||||
return slowed && result != movetype::UNREACHABLE ? 2 * result : result; }
|
||||
|
||||
|
@ -126,10 +126,10 @@ public:
|
|||
{}
|
||||
|
||||
/// Returns the defense associated with the given terrain.
|
||||
int defense(const t_translation::t_terrain & terrain) const
|
||||
int defense(const t_translation::terrain_code & terrain) const
|
||||
{ return std::max(min_.value(terrain), max_.value(terrain)); }
|
||||
/// Returns whether there is a defense cap associated to this terrain.
|
||||
bool capped(const t_translation::t_terrain & terrain) const
|
||||
bool capped(const t_translation::terrain_code & terrain) const
|
||||
{ return min_.value(terrain) != 0; }
|
||||
/// Merges the given config over the existing costs.
|
||||
/// (Not overwriting implies adding.)
|
||||
|
@ -194,17 +194,17 @@ public:
|
|||
void set_flying(bool flies=true) { flying_ = flies; }
|
||||
|
||||
/// Returns the cost to move through the indicated terrain.
|
||||
int movement_cost(const t_translation::t_terrain & terrain, bool slowed=false) const
|
||||
int movement_cost(const t_translation::terrain_code & terrain, bool slowed=false) const
|
||||
{ return movement_.cost(terrain, slowed); }
|
||||
/// Returns the cost to see through the indicated terrain.
|
||||
int vision_cost(const t_translation::t_terrain & terrain, bool slowed=false) const
|
||||
int vision_cost(const t_translation::terrain_code & terrain, bool slowed=false) const
|
||||
{ return vision_.cost(terrain, slowed); }
|
||||
/// Returns the cost to "jam" through the indicated terrain.
|
||||
int jamming_cost(const t_translation::t_terrain & terrain, bool slowed=false) const
|
||||
int jamming_cost(const t_translation::terrain_code & terrain, bool slowed=false) const
|
||||
{ return jamming_.cost(terrain, slowed); }
|
||||
|
||||
/// Returns the defensive value of the indicated terrain.
|
||||
int defense_modifier(const t_translation::t_terrain & terrain) const
|
||||
int defense_modifier(const t_translation::terrain_code & terrain) const
|
||||
{ return defense_.defense(terrain); }
|
||||
|
||||
/// Returns the resistance against the indicated attack.
|
||||
|
@ -218,7 +218,7 @@ public:
|
|||
{ return resist_.damage_table(); }
|
||||
|
||||
/// Returns whether or not there are any terrain caps with respect to a set of terrains.
|
||||
bool has_terrain_defense_caps(const std::set<t_translation::t_terrain> & ts) const;
|
||||
bool has_terrain_defense_caps(const std::set<t_translation::terrain_code> & ts) const;
|
||||
/// Returns whether or not there are any vision-specific costs.
|
||||
bool has_vision_data() const { return !vision_.empty(); }
|
||||
/// Returns whether or not there are any jamming-specific costs.
|
||||
|
|
|
@ -705,7 +705,7 @@ double shortest_path_calculator::cost(const map_location& loc, const double so_f
|
|||
if (!see_all_ && viewing_team_.shrouded(loc))
|
||||
return getNoPathValue();
|
||||
|
||||
const t_translation::t_terrain terrain = map_[loc];
|
||||
const t_translation::terrain_code terrain = map_[loc];
|
||||
const int terrain_cost = unit_.movement_cost(terrain);
|
||||
// Pathfinding heuristic: the cost must be at least 1
|
||||
VALIDATE(terrain_cost >= 1, _("Terrain with a movement cost less than 1 encountered."));
|
||||
|
@ -788,7 +788,7 @@ double move_type_path_calculator::cost(const map_location& loc, const double so_
|
|||
if (viewing_team_.shrouded(loc))
|
||||
return getNoPathValue();
|
||||
|
||||
const t_translation::t_terrain terrain = map_[loc];
|
||||
const t_translation::terrain_code terrain = map_[loc];
|
||||
const int terrain_cost = movement_type_.movement_cost(terrain);
|
||||
|
||||
if (total_movement_ < terrain_cost)
|
||||
|
|
|
@ -516,17 +516,17 @@ static config unit_defense(reports::context & rc, const unit* u, const map_locat
|
|||
return config();
|
||||
}
|
||||
|
||||
const t_translation::t_terrain &terrain = map[displayed_unit_hex];
|
||||
const t_translation::terrain_code &terrain = map[displayed_unit_hex];
|
||||
int def = 100 - u->defense_modifier(terrain);
|
||||
SDL_Color color = int_to_color(game_config::red_to_green(def));
|
||||
str << span_color(color) << def << '%' << naps;
|
||||
tooltip << _("Terrain: ") << "<b>" << map.get_terrain_info(terrain).description() << "</b>\n";
|
||||
|
||||
const t_translation::t_list &underlyings = map.underlying_def_terrain(terrain);
|
||||
const t_translation::ter_list &underlyings = map.underlying_def_terrain(terrain);
|
||||
if (underlyings.size() != 1 || underlyings.front() != terrain)
|
||||
{
|
||||
bool revert = false;
|
||||
for (const t_translation::t_terrain &t : underlyings)
|
||||
for (const t_translation::terrain_code &t : underlyings)
|
||||
{
|
||||
if (t == t_translation::MINUS) {
|
||||
revert = true;
|
||||
|
@ -590,13 +590,13 @@ static config unit_moves(reports::context & rc, const unit* u)
|
|||
movement_frac = 1.0;
|
||||
}
|
||||
|
||||
std::set<t_translation::t_terrain>::const_iterator terrain_it =
|
||||
std::set<t_translation::terrain_code>::const_iterator terrain_it =
|
||||
preferences::encountered_terrains().begin();
|
||||
|
||||
tooltip << _("Movement Costs:") << "\n";
|
||||
for (; terrain_it != preferences::encountered_terrains().end();
|
||||
++terrain_it) {
|
||||
const t_translation::t_terrain terrain = *terrain_it;
|
||||
const t_translation::terrain_code terrain = *terrain_it;
|
||||
if (terrain == t_translation::FOGGED || terrain == t_translation::VOID_TERRAIN || terrain == t_translation::OFF_MAP_USER)
|
||||
continue;
|
||||
|
||||
|
@ -1184,7 +1184,7 @@ static config unit_box_at(reports::context & rc, const map_location& mouseover_h
|
|||
else if (local_tod.bonus_modified < 0) local_tod_image += "~DARKEN()";
|
||||
|
||||
const gamemap &map = rc.map();
|
||||
t_translation::t_terrain terrain = map.get_terrain(mouseover_hex);
|
||||
t_translation::terrain_code terrain = map.get_terrain(mouseover_hex);
|
||||
|
||||
//if (terrain == t_translation::OFF_MAP_USER)
|
||||
// return config();
|
||||
|
@ -1193,11 +1193,11 @@ static config unit_box_at(reports::context & rc, const map_location& mouseover_h
|
|||
// add_image(cfg, "icons/terrain/terrain_type_keep.png", "");
|
||||
//}
|
||||
|
||||
const t_translation::t_list& underlying_terrains = map.underlying_union_terrain(terrain);
|
||||
const t_translation::ter_list& underlying_terrains = map.underlying_union_terrain(terrain);
|
||||
|
||||
std::string bg_terrain_image;
|
||||
|
||||
for (const t_translation::t_terrain& underlying_terrain : underlying_terrains) {
|
||||
for (const t_translation::terrain_code& underlying_terrain : underlying_terrains) {
|
||||
const std::string& terrain_id = map.get_terrain_info(underlying_terrain).id();
|
||||
bg_terrain_image = "~BLIT(unit_env/terrain/terrain-" + terrain_id + ".png)" + bg_terrain_image;
|
||||
}
|
||||
|
@ -1347,7 +1347,7 @@ REPORT_GENERATOR(terrain_info, rc)
|
|||
if (!map.on_board(mouseover_hex))
|
||||
return config();
|
||||
|
||||
t_translation::t_terrain terrain = map.get_terrain(mouseover_hex);
|
||||
t_translation::terrain_code terrain = map.get_terrain(mouseover_hex);
|
||||
if (terrain == t_translation::OFF_MAP_USER)
|
||||
return config();
|
||||
|
||||
|
@ -1367,8 +1367,8 @@ REPORT_GENERATOR(terrain_info, rc)
|
|||
// blit_tced_icon(cfg, "keep", high_res);
|
||||
// }
|
||||
|
||||
const t_translation::t_list& underlying_terrains = map.underlying_union_terrain(terrain);
|
||||
for (const t_translation::t_terrain& underlying_terrain : underlying_terrains) {
|
||||
const t_translation::ter_list& underlying_terrains = map.underlying_union_terrain(terrain);
|
||||
for (const t_translation::terrain_code& underlying_terrain : underlying_terrains) {
|
||||
|
||||
if (underlying_terrain == t_translation::OFF_MAP_USER)
|
||||
continue;
|
||||
|
@ -1391,7 +1391,7 @@ REPORT_GENERATOR(terrain, rc)
|
|||
if (!map.on_board(mouseover_hex) || viewing_team.shrouded(mouseover_hex))
|
||||
return config();
|
||||
|
||||
t_translation::t_terrain terrain = map.get_terrain(mouseover_hex);
|
||||
t_translation::terrain_code terrain = map.get_terrain(mouseover_hex);
|
||||
if (terrain == t_translation::OFF_MAP_USER)
|
||||
return config();
|
||||
|
||||
|
@ -1446,7 +1446,7 @@ REPORT_GENERATOR(position, rc)
|
|||
}
|
||||
}
|
||||
|
||||
t_translation::t_terrain terrain = map[mouseover_hex];
|
||||
t_translation::terrain_code terrain = map[mouseover_hex];
|
||||
if (terrain == t_translation::OFF_MAP_USER)
|
||||
return config();
|
||||
|
||||
|
|
|
@ -801,7 +801,7 @@ int game_lua_kernel::intf_get_terrain(lua_State *L)
|
|||
{
|
||||
map_location loc = luaW_checklocation(L, 1);
|
||||
|
||||
t_translation::t_terrain const &t = board().map().
|
||||
t_translation::terrain_code const &t = board().map().
|
||||
get_terrain(loc);
|
||||
lua_pushstring(L, t_translation::write_terrain_code(t).c_str());
|
||||
return 1;
|
||||
|
@ -848,7 +848,7 @@ int game_lua_kernel::intf_set_terrain(lua_State *L)
|
|||
int game_lua_kernel::intf_get_terrain_info(lua_State *L)
|
||||
{
|
||||
char const *m = luaL_checkstring(L, 1);
|
||||
t_translation::t_terrain t = t_translation::read_terrain_code(m);
|
||||
t_translation::terrain_code t = t_translation::read_terrain_code(m);
|
||||
if (t == t_translation::NONE_TERRAIN) return 0;
|
||||
terrain_type const &info = board().map().tdata()->get_terrain_info(t);
|
||||
|
||||
|
@ -2214,7 +2214,7 @@ static int intf_unit_movement_cost(lua_State *L)
|
|||
{
|
||||
const unit& u = luaW_checkunit(L, 1);
|
||||
char const *m = luaL_checkstring(L, 2);
|
||||
t_translation::t_terrain t = t_translation::read_terrain_code(m);
|
||||
t_translation::terrain_code t = t_translation::read_terrain_code(m);
|
||||
lua_pushinteger(L, u.movement_cost(t));
|
||||
return 1;
|
||||
}
|
||||
|
@ -2229,7 +2229,7 @@ static int intf_unit_vision_cost(lua_State *L)
|
|||
{
|
||||
const unit& u = luaW_checkunit(L, 1);
|
||||
char const *m = luaL_checkstring(L, 2);
|
||||
t_translation::t_terrain t = t_translation::read_terrain_code(m);
|
||||
t_translation::terrain_code t = t_translation::read_terrain_code(m);
|
||||
lua_pushinteger(L, u.vision_cost(t));
|
||||
return 1;
|
||||
}
|
||||
|
@ -2244,7 +2244,7 @@ static int intf_unit_jamming_cost(lua_State *L)
|
|||
{
|
||||
const unit& u = luaW_checkunit(L, 1);
|
||||
char const *m = luaL_checkstring(L, 2);
|
||||
t_translation::t_terrain t = t_translation::read_terrain_code(m);
|
||||
t_translation::terrain_code t = t_translation::read_terrain_code(m);
|
||||
lua_pushinteger(L, u.jamming_cost(t));
|
||||
return 1;
|
||||
}
|
||||
|
@ -2259,7 +2259,7 @@ static int intf_unit_defense(lua_State *L)
|
|||
{
|
||||
const unit& u = luaW_checkunit(L, 1);
|
||||
char const *m = luaL_checkstring(L, 2);
|
||||
t_translation::t_terrain t = t_translation::read_terrain_code(m);
|
||||
t_translation::terrain_code t = t_translation::read_terrain_code(m);
|
||||
lua_pushinteger(L, u.defense_modifier(t));
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -738,7 +738,7 @@ void terrain_builder::add_images_from_config(rule_imagelist& images, const confi
|
|||
terrain_builder::terrain_constraint &terrain_builder::add_constraints(
|
||||
terrain_builder::constraint_set& constraints,
|
||||
const map_location& loc,
|
||||
const t_translation::t_match& type, const config& global_images)
|
||||
const t_translation::ter_match& type, const config& global_images)
|
||||
{
|
||||
terrain_constraint *cons = nullptr;
|
||||
for (terrain_constraint &c : constraints) {
|
||||
|
@ -770,7 +770,7 @@ void terrain_builder::add_constraints(terrain_builder::constraint_set &constrain
|
|||
|
||||
{
|
||||
terrain_constraint& constraint = add_constraints(constraints, loc,
|
||||
t_translation::t_match(cfg["type"], t_translation::WILDCARD), global_images);
|
||||
t_translation::ter_match(cfg["type"], t_translation::WILDCARD), global_images);
|
||||
|
||||
|
||||
std::vector<std::string> item_string = utils::square_parenthetical_split(cfg["set_flag"],',',"[","]");
|
||||
|
@ -802,7 +802,7 @@ void terrain_builder::parse_mapstring(const std::string &mapstring,
|
|||
const config& global_images)
|
||||
{
|
||||
|
||||
const t_translation::t_map map = t_translation::read_builder_map(mapstring);
|
||||
const t_translation::ter_map map = t_translation::read_builder_map(mapstring);
|
||||
|
||||
// If there is an empty map leave directly.
|
||||
// Determine after conversion, since a
|
||||
|
@ -817,7 +817,7 @@ void terrain_builder::parse_mapstring(const std::string &mapstring,
|
|||
for(int y_off = 0; y_off < map.w; ++y_off) {
|
||||
for(int x_off = x; x_off < map.h; ++x_off) {
|
||||
|
||||
const t_translation::t_terrain terrain = map.get(y_off, x_off);
|
||||
const t_translation::terrain_code terrain = map.get(y_off, x_off);
|
||||
|
||||
if(terrain.base == t_translation::TB_DOT) {
|
||||
// Dots are simple placeholders,
|
||||
|
@ -1152,7 +1152,7 @@ void terrain_builder::build_terrains()
|
|||
for(int x = -2; x <= map().w(); ++x) {
|
||||
for(int y = -2; y <= map().h(); ++y) {
|
||||
const map_location loc(x,y);
|
||||
const t_translation::t_terrain t = map().get_terrain(loc);
|
||||
const t_translation::terrain_code t = map().get_terrain(loc);
|
||||
|
||||
terrain_by_type_[t].push_back(loc);
|
||||
}
|
||||
|
@ -1164,19 +1164,19 @@ void terrain_builder::build_terrains()
|
|||
// We will keep a track of the matching terrains of this constraint
|
||||
// and later try to apply the rule only on them
|
||||
size_t min_size = INT_MAX;
|
||||
t_translation::t_list min_types = t_translation::t_list(); // <-- This must be explicitly initialized, just as min_constraint is, at start of loop, or we get a null pointer dereference when we go through on later times.
|
||||
t_translation::ter_list min_types = t_translation::ter_list(); // <-- This must be explicitly initialized, just as min_constraint is, at start of loop, or we get a null pointer dereference when we go through on later times.
|
||||
const terrain_constraint *min_constraint = nullptr;
|
||||
|
||||
for(const terrain_constraint &constraint : rule.constraints)
|
||||
{
|
||||
const t_translation::t_match& match = constraint.terrain_types_match;
|
||||
t_translation::t_list matching_types;
|
||||
const t_translation::ter_match& match = constraint.terrain_types_match;
|
||||
t_translation::ter_list matching_types;
|
||||
size_t constraint_size = 0;
|
||||
|
||||
for (terrain_by_type_map::iterator type_it = terrain_by_type_.begin();
|
||||
type_it != terrain_by_type_.end(); ++type_it) {
|
||||
|
||||
const t_translation::t_terrain t = type_it->first;
|
||||
const t_translation::terrain_code t = type_it->first;
|
||||
if (terrain_matches(t, match)) {
|
||||
const size_t match_size = type_it->second.size();
|
||||
constraint_size += match_size;
|
||||
|
@ -1200,7 +1200,7 @@ void terrain_builder::build_terrains()
|
|||
}
|
||||
|
||||
//NOTE: if min_types is not empty, we have found a valid min_constraint;
|
||||
for(t_translation::t_list::const_iterator t = min_types.begin();
|
||||
for(t_translation::ter_list::const_iterator t = min_types.begin();
|
||||
t != min_types.end(); ++t) {
|
||||
|
||||
const std::vector<map_location>* locations = &terrain_by_type_[*t];
|
||||
|
|
|
@ -271,7 +271,7 @@ public:
|
|||
{}
|
||||
|
||||
map_location loc;
|
||||
t_translation::t_match terrain_types_match;
|
||||
t_translation::ter_match terrain_types_match;
|
||||
std::vector<std::string> set_flag;
|
||||
std::vector<std::string> no_flag;
|
||||
std::vector<std::string> has_flag;
|
||||
|
@ -656,7 +656,7 @@ private:
|
|||
* describing rule-global images.
|
||||
*/
|
||||
terrain_constraint &add_constraints(constraint_set& constraints,
|
||||
const map_location &loc, const t_translation::t_match& type,
|
||||
const map_location &loc, const t_translation::ter_match& type,
|
||||
const config& global_images);
|
||||
|
||||
/**
|
||||
|
@ -744,7 +744,7 @@ private:
|
|||
* @return returns true if "tcode" matches the list or the list is empty,
|
||||
* else false.
|
||||
*/
|
||||
bool terrain_matches(const t_translation::t_terrain & tcode, const t_translation::t_list& terrains) const
|
||||
bool terrain_matches(const t_translation::terrain_code & tcode, const t_translation::ter_list& terrains) const
|
||||
{ return terrains.empty()? true : t_translation::terrain_matches(tcode, terrains); }
|
||||
|
||||
/**
|
||||
|
@ -757,7 +757,7 @@ private:
|
|||
* @return returns true if "tcode" matches the list or the list is empty,
|
||||
* else false.
|
||||
*/
|
||||
bool terrain_matches(const t_translation::t_terrain & tcode, const t_translation::t_match &terrain) const
|
||||
bool terrain_matches(const t_translation::terrain_code & tcode, const t_translation::ter_match &terrain) const
|
||||
{ return terrain.is_empty ? true : t_translation::terrain_matches(tcode, terrain); }
|
||||
|
||||
/**
|
||||
|
@ -802,7 +802,7 @@ private:
|
|||
/**
|
||||
* Shorthand typedef for a map associating a list of locations to a terrain type.
|
||||
*/
|
||||
typedef std::map<t_translation::t_terrain, std::vector<map_location> > terrain_by_type_map;
|
||||
typedef std::map<t_translation::terrain_code, std::vector<map_location> > terrain_by_type_map;
|
||||
|
||||
/**
|
||||
* A map representing all locations whose terrain is of a given type.
|
||||
|
|
|
@ -119,10 +119,10 @@ bool terrain_filter::match_internal(const map_location& loc, const bool ignore_x
|
|||
|
||||
if(cfg_.has_attribute("terrain")) {
|
||||
if(cache_.parsed_terrain == nullptr) {
|
||||
cache_.parsed_terrain = new t_translation::t_match(cfg_["terrain"]);
|
||||
cache_.parsed_terrain = new t_translation::ter_match(cfg_["terrain"]);
|
||||
}
|
||||
if(!cache_.parsed_terrain->is_empty) {
|
||||
const t_translation::t_terrain letter = fc_->get_disp_context().map().get_terrain_info(loc).number();
|
||||
const t_translation::terrain_code letter = fc_->get_disp_context().map().get_terrain_info(loc).number();
|
||||
if(!t_translation::terrain_matches(letter, *cache_.parsed_terrain)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ bool terrain_filter::match_internal(const map_location& loc, const bool ignore_x
|
|||
if(cfg_.has_attribute("formula")) {
|
||||
try {
|
||||
const gamemap& map = fc_->get_disp_context().map();
|
||||
t_translation::t_terrain t = map.get_terrain(loc);
|
||||
t_translation::terrain_code t = map.get_terrain(loc);
|
||||
const terrain_type& ter = map.tdata()->get_terrain_info(t);
|
||||
const terrain_callable callable(ter,loc);
|
||||
const game_logic::formula form(cfg_["formula"]);
|
||||
|
|
|
@ -70,7 +70,7 @@ private:
|
|||
~terrain_filter_cache();
|
||||
|
||||
//parsed_terrain: optimizes handling of terrain="..."
|
||||
t_translation::t_match *parsed_terrain;
|
||||
t_translation::ter_match *parsed_terrain;
|
||||
|
||||
//adjacent_matches: optimize handling of [filter_adjacent_location] for get_locations()
|
||||
std::vector< std::set<map_location> > *adjacent_matches;
|
||||
|
|
|
@ -131,24 +131,24 @@ terrain_type::terrain_type(const config& cfg) :
|
|||
def_type_.push_back(number_);
|
||||
vision_type_.push_back(number_);
|
||||
|
||||
const t_translation::t_list& alias = t_translation::read_list(cfg["aliasof"]);
|
||||
const t_translation::ter_list& alias = t_translation::read_list(cfg["aliasof"]);
|
||||
if(!alias.empty()) {
|
||||
mvt_type_ = alias;
|
||||
vision_type_ = alias;
|
||||
def_type_ = alias;
|
||||
}
|
||||
|
||||
const t_translation::t_list& mvt_alias = t_translation::read_list(cfg["mvt_alias"]);
|
||||
const t_translation::ter_list& mvt_alias = t_translation::read_list(cfg["mvt_alias"]);
|
||||
if(!mvt_alias.empty()) {
|
||||
mvt_type_ = mvt_alias;
|
||||
}
|
||||
|
||||
const t_translation::t_list& def_alias = t_translation::read_list(cfg["def_alias"]);
|
||||
const t_translation::ter_list& def_alias = t_translation::read_list(cfg["def_alias"]);
|
||||
if(!def_alias.empty()) {
|
||||
def_type_ = def_alias;
|
||||
}
|
||||
|
||||
const t_translation::t_list& vision_alias = t_translation::read_list(cfg["vision_alias"]);
|
||||
const t_translation::ter_list& vision_alias = t_translation::read_list(cfg["vision_alias"]);
|
||||
if(!vision_alias.empty()) {
|
||||
vision_type_ = vision_alias;
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ terrain_type::terrain_type(const terrain_type& base, const terrain_type& overlay
|
|||
editor_name_((base.editor_name_.empty() ? base.name_ : base.editor_name_) + " / " + (overlay.editor_name_.empty() ? overlay.name_ : overlay.editor_name_)),
|
||||
description_(overlay.description()),
|
||||
help_topic_text_(),
|
||||
number_(t_translation::t_terrain(base.number_.base, overlay.number_.overlay)),
|
||||
number_(t_translation::terrain_code(base.number_.base, overlay.number_.overlay)),
|
||||
mvt_type_(overlay.mvt_type_),
|
||||
vision_type_(overlay.vision_type_),
|
||||
def_type_(overlay.def_type_),
|
||||
|
@ -282,9 +282,9 @@ terrain_type::terrain_type(const terrain_type& base, const terrain_type& overlay
|
|||
|
||||
}
|
||||
|
||||
t_translation::t_terrain terrain_type::terrain_with_default_base() const {
|
||||
t_translation::terrain_code terrain_type::terrain_with_default_base() const {
|
||||
if(overlay_ && editor_default_base_ != t_translation::NONE_TERRAIN) {
|
||||
return t_translation::t_terrain(editor_default_base_.base, number_.overlay);
|
||||
return t_translation::terrain_code(editor_default_base_.base, number_.overlay);
|
||||
}
|
||||
return number_;
|
||||
}
|
||||
|
@ -314,8 +314,8 @@ bool terrain_type::operator==(const terrain_type& other) const {
|
|||
}
|
||||
|
||||
void create_terrain_maps(const config::const_child_itors &cfgs,
|
||||
t_translation::t_list& terrain_list,
|
||||
std::map<t_translation::t_terrain, terrain_type>& letter_to_terrain)
|
||||
t_translation::ter_list& terrain_list,
|
||||
std::map<t_translation::terrain_code, terrain_type>& letter_to_terrain)
|
||||
{
|
||||
for (const config &terrain_data : cfgs)
|
||||
{
|
||||
|
@ -323,7 +323,7 @@ void create_terrain_maps(const config::const_child_itors &cfgs,
|
|||
DBG_G << "create_terrain_maps: " << terrain.number() << " "
|
||||
<< terrain.id() << " " << terrain.name() << " : " << terrain.editor_group() << "\n";
|
||||
|
||||
std::pair<std::map<t_translation::t_terrain, terrain_type>::iterator, bool> res;
|
||||
std::pair<std::map<t_translation::terrain_code, terrain_type>::iterator, bool> res;
|
||||
res = letter_to_terrain.insert(std::make_pair(terrain.number(), terrain));
|
||||
if (!res.second) {
|
||||
terrain_type& curr = res.first->second;
|
||||
|
@ -364,12 +364,12 @@ void create_terrain_maps(const config::const_child_itors &cfgs,
|
|||
}
|
||||
}
|
||||
|
||||
void merge_alias_lists(t_translation::t_list& first, const t_translation::t_list& second)
|
||||
void merge_alias_lists(t_translation::ter_list& first, const t_translation::ter_list& second)
|
||||
{
|
||||
// Insert second vector into first when the terrain _ref^base is encountered
|
||||
|
||||
bool revert = (first.front() == t_translation::MINUS ? true : false);
|
||||
t_translation::t_list::iterator i;
|
||||
t_translation::ter_list::iterator i;
|
||||
|
||||
for(i = first.begin(); i != first.end(); ++i) {
|
||||
if(*i == t_translation::PLUS) {
|
||||
|
@ -381,7 +381,7 @@ void merge_alias_lists(t_translation::t_list& first, const t_translation::t_list
|
|||
}
|
||||
|
||||
if(*i == t_translation::BASE) {
|
||||
t_translation::t_list::iterator insert_it = first.erase(i);
|
||||
t_translation::ter_list::iterator insert_it = first.erase(i);
|
||||
//if we are in reverse mode, insert PLUS before and MINUS after the base list
|
||||
//so calculation of base aliases will work normal
|
||||
if(revert) {
|
||||
|
|
|
@ -40,13 +40,13 @@ public:
|
|||
bool hide_in_editor() const { return hide_in_editor_; }
|
||||
|
||||
//the character representing this terrain
|
||||
t_translation::t_terrain number() const { return number_; }
|
||||
t_translation::terrain_code number() const { return number_; }
|
||||
|
||||
//the underlying type of the terrain
|
||||
const t_translation::t_list& mvt_type() const { return mvt_type_; }
|
||||
const t_translation::t_list& def_type() const { return def_type_; }
|
||||
const t_translation::t_list& vision_type() const { return vision_type_; }
|
||||
const t_translation::t_list& union_type() const { return union_type_; }
|
||||
const t_translation::ter_list& mvt_type() const { return mvt_type_; }
|
||||
const t_translation::ter_list& def_type() const { return def_type_; }
|
||||
const t_translation::ter_list& vision_type() const { return vision_type_; }
|
||||
const t_translation::ter_list& union_type() const { return union_type_; }
|
||||
|
||||
bool is_nonnull() const { return (number_ != t_translation::NONE_TERRAIN) &&
|
||||
(number_ != t_translation::VOID_TERRAIN ); }
|
||||
|
@ -76,8 +76,8 @@ public:
|
|||
bool is_overlay() const { return overlay_; }
|
||||
bool is_combined() const { return combined_; }
|
||||
|
||||
t_translation::t_terrain default_base() const { return editor_default_base_; }
|
||||
t_translation::t_terrain terrain_with_default_base() const;
|
||||
t_translation::terrain_code default_base() const { return editor_default_base_; }
|
||||
t_translation::terrain_code terrain_with_default_base() const;
|
||||
|
||||
bool operator==(const terrain_type& other) const;
|
||||
private:
|
||||
|
@ -104,11 +104,11 @@ private:
|
|||
//terrain type. The 'type' is a list of the 'underlying types'
|
||||
//of the terrain. This may simply be the same as the number.
|
||||
//This is the internal number used, WML still uses character strings.
|
||||
t_translation::t_terrain number_;
|
||||
t_translation::t_list mvt_type_;
|
||||
t_translation::t_list vision_type_;
|
||||
t_translation::t_list def_type_;
|
||||
t_translation::t_list union_type_;
|
||||
t_translation::terrain_code number_;
|
||||
t_translation::ter_list mvt_type_;
|
||||
t_translation::ter_list vision_type_;
|
||||
t_translation::ter_list def_type_;
|
||||
t_translation::ter_list union_type_;
|
||||
|
||||
int height_adjust_;
|
||||
bool height_adjust_set_;
|
||||
|
@ -131,14 +131,14 @@ private:
|
|||
bool village_, castle_, keep_;
|
||||
|
||||
bool overlay_, combined_;
|
||||
t_translation::t_terrain editor_default_base_;
|
||||
t_translation::terrain_code editor_default_base_;
|
||||
bool hide_help_, hide_in_editor_;
|
||||
};
|
||||
|
||||
void create_terrain_maps(const config::const_child_itors &cfgs,
|
||||
t_translation::t_list& terrain_list,
|
||||
std::map<t_translation::t_terrain, terrain_type>& letter_to_terrain);
|
||||
t_translation::ter_list& terrain_list,
|
||||
std::map<t_translation::terrain_code, terrain_type>& letter_to_terrain);
|
||||
|
||||
void merge_alias_lists(t_translation::t_list& first, const t_translation::t_list& second);
|
||||
void merge_alias_lists(t_translation::ter_list& first, const t_translation::ter_list& second);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace t_translation {
|
|||
*
|
||||
* @return Mask for that layer.
|
||||
*/
|
||||
static t_layer get_layer_mask_(t_layer terrain); //inlined
|
||||
static ter_layer get_layer_mask_(ter_layer terrain); //inlined
|
||||
|
||||
/**
|
||||
* Gets a mask for a terrain, this mask is used for wildcard matching.
|
||||
|
@ -60,7 +60,7 @@ namespace t_translation {
|
|||
*
|
||||
* @return The mask for this terrain.
|
||||
*/
|
||||
static t_terrain get_mask_(const t_terrain& terrain);
|
||||
static terrain_code get_mask_(const terrain_code& terrain);
|
||||
|
||||
/**
|
||||
* Converts a string to a layer.
|
||||
|
@ -70,8 +70,8 @@ namespace t_translation {
|
|||
*
|
||||
* @return The converted layer.
|
||||
*/
|
||||
static t_layer string_to_layer_(const char* begin, const char* end);
|
||||
static t_layer string_to_layer_(const std::string& str)
|
||||
static ter_layer string_to_layer_(const char* begin, const char* end);
|
||||
static ter_layer string_to_layer_(const std::string& str)
|
||||
{
|
||||
return string_to_layer_(str.c_str(), str.c_str() + str.size());
|
||||
}
|
||||
|
@ -88,8 +88,8 @@ namespace t_translation {
|
|||
* @return The terrain code found in the string if no
|
||||
* valid terrain is found VOID will be returned.
|
||||
*/
|
||||
static t_terrain string_to_number_(std::string str, std::string& start_position, const t_layer filler);
|
||||
static t_terrain string_to_number_(const std::string& str, const t_layer filler = NO_LAYER);
|
||||
static terrain_code string_to_number_(std::string str, std::string& start_position, const ter_layer filler);
|
||||
static terrain_code string_to_number_(const std::string& str, const ter_layer filler = NO_LAYER);
|
||||
|
||||
/**
|
||||
* Converts a terrain number to a string
|
||||
|
@ -102,7 +102,7 @@ namespace t_translation {
|
|||
* position given it's padded to 4 chars else
|
||||
* padded to 7 chars.
|
||||
*/
|
||||
static std::string number_to_string_(t_terrain terrain, const std::string& start_position = "");
|
||||
static std::string number_to_string_(terrain_code terrain, const std::string& start_position = "");
|
||||
|
||||
/**
|
||||
* Converts a terrain string to a number for the builder.
|
||||
|
@ -112,52 +112,52 @@ namespace t_translation {
|
|||
*
|
||||
* @return Number for the builder map.
|
||||
*/
|
||||
static t_terrain string_to_builder_number_(std::string str);
|
||||
static terrain_code string_to_builder_number_(std::string str);
|
||||
|
||||
/***************************************************************************************/
|
||||
|
||||
const t_terrain OFF_MAP_USER = string_to_number_("_off^_usr");
|
||||
const terrain_code OFF_MAP_USER = string_to_number_("_off^_usr");
|
||||
|
||||
const t_terrain VOID_TERRAIN = string_to_number_("_s");
|
||||
const t_terrain FOGGED = string_to_number_("_f");
|
||||
const terrain_code VOID_TERRAIN = string_to_number_("_s");
|
||||
const terrain_code FOGGED = string_to_number_("_f");
|
||||
|
||||
const t_terrain HUMAN_CASTLE = string_to_number_("Ch");
|
||||
const t_terrain HUMAN_KEEP = string_to_number_("Kh");
|
||||
const t_terrain SHALLOW_WATER = string_to_number_("Ww");
|
||||
const t_terrain DEEP_WATER = string_to_number_("Wo");
|
||||
const t_terrain GRASS_LAND = string_to_number_("Gg");
|
||||
const t_terrain FOREST = string_to_number_("Gg^Ff");
|
||||
const t_terrain MOUNTAIN = string_to_number_("Mm");
|
||||
const t_terrain HILL = string_to_number_("Hh");
|
||||
const terrain_code HUMAN_CASTLE = string_to_number_("Ch");
|
||||
const terrain_code HUMAN_KEEP = string_to_number_("Kh");
|
||||
const terrain_code SHALLOW_WATER = string_to_number_("Ww");
|
||||
const terrain_code DEEP_WATER = string_to_number_("Wo");
|
||||
const terrain_code GRASS_LAND = string_to_number_("Gg");
|
||||
const terrain_code FOREST = string_to_number_("Gg^Ff");
|
||||
const terrain_code MOUNTAIN = string_to_number_("Mm");
|
||||
const terrain_code HILL = string_to_number_("Hh");
|
||||
|
||||
const t_terrain CAVE_WALL = string_to_number_("Xu");
|
||||
const t_terrain CAVE = string_to_number_("Uu");
|
||||
const t_terrain UNDERGROUND_VILLAGE = string_to_number_("Uu^Vu");
|
||||
const t_terrain DWARVEN_CASTLE = string_to_number_("Cud");
|
||||
const t_terrain DWARVEN_KEEP = string_to_number_("Kud");
|
||||
const terrain_code CAVE_WALL = string_to_number_("Xu");
|
||||
const terrain_code CAVE = string_to_number_("Uu");
|
||||
const terrain_code UNDERGROUND_VILLAGE = string_to_number_("Uu^Vu");
|
||||
const terrain_code DWARVEN_CASTLE = string_to_number_("Cud");
|
||||
const terrain_code DWARVEN_KEEP = string_to_number_("Kud");
|
||||
|
||||
const t_terrain PLUS = string_to_number_("+");
|
||||
const t_terrain MINUS = string_to_number_("-");
|
||||
const t_terrain NOT = string_to_number_("!");
|
||||
const t_terrain STAR = string_to_number_("*");
|
||||
const t_terrain BASE = string_to_number_("_bas");
|
||||
const terrain_code PLUS = string_to_number_("+");
|
||||
const terrain_code MINUS = string_to_number_("-");
|
||||
const terrain_code NOT = string_to_number_("!");
|
||||
const terrain_code STAR = string_to_number_("*");
|
||||
const terrain_code BASE = string_to_number_("_bas");
|
||||
|
||||
const t_match ALL_FORESTS("F*,*^F*");
|
||||
const t_match ALL_HILLS("!,*^V*,!,H*");
|
||||
const t_match ALL_MOUNTAINS("!,*^V*,!,M*"); //excluding impassable mountains
|
||||
const t_match ALL_SWAMPS("!,*^V*,*^B*,!,S*"); //excluding swamp villages and bridges
|
||||
const ter_match ALL_FORESTS("F*,*^F*");
|
||||
const ter_match ALL_HILLS("!,*^V*,!,H*");
|
||||
const ter_match ALL_MOUNTAINS("!,*^V*,!,M*"); //excluding impassable mountains
|
||||
const ter_match ALL_SWAMPS("!,*^V*,*^B*,!,S*"); //excluding swamp villages and bridges
|
||||
|
||||
/***************************************************************************************/
|
||||
|
||||
t_terrain::t_terrain(const std::string& b, t_layer o) :
|
||||
terrain_code::terrain_code(const std::string& b, ter_layer o) :
|
||||
base(string_to_layer_(b)), overlay(o)
|
||||
{}
|
||||
|
||||
t_terrain::t_terrain(const std::string& b, const std::string& o) :
|
||||
terrain_code::terrain_code(const std::string& b, const std::string& o) :
|
||||
base(string_to_layer_(b)), overlay(string_to_layer_(o))
|
||||
{}
|
||||
|
||||
t_match::t_match() :
|
||||
ter_match::ter_match() :
|
||||
terrain(),
|
||||
mask(),
|
||||
masked_terrain(),
|
||||
|
@ -165,7 +165,7 @@ t_match::t_match() :
|
|||
is_empty(true)
|
||||
{}
|
||||
|
||||
t_match::t_match(const std::string& str, const t_layer filler) :
|
||||
ter_match::ter_match(const std::string& str, const ter_layer filler) :
|
||||
terrain(t_translation::read_list(str, filler)),
|
||||
mask(),
|
||||
masked_terrain(),
|
||||
|
@ -182,8 +182,8 @@ t_match::t_match(const std::string& str, const t_layer filler) :
|
|||
}
|
||||
}
|
||||
|
||||
t_match::t_match(const t_terrain& tcode):
|
||||
terrain(t_list(1, tcode)),
|
||||
ter_match::ter_match(const terrain_code& tcode):
|
||||
terrain(ter_list(1, tcode)),
|
||||
mask(),
|
||||
masked_terrain(),
|
||||
has_wildcard(t_translation::has_wildcard(terrain)),
|
||||
|
@ -198,20 +198,20 @@ t_match::t_match(const t_terrain& tcode):
|
|||
}
|
||||
}
|
||||
|
||||
t_terrain read_terrain_code(const std::string& str, const t_layer filler)
|
||||
terrain_code read_terrain_code(const std::string& str, const ter_layer filler)
|
||||
{
|
||||
return string_to_number_(str, filler);
|
||||
}
|
||||
|
||||
std::string write_terrain_code(const t_terrain& tcode)
|
||||
std::string write_terrain_code(const terrain_code& tcode)
|
||||
{
|
||||
return number_to_string_(tcode);
|
||||
}
|
||||
|
||||
t_list read_list(const std::string& str, const t_layer filler)
|
||||
ter_list read_list(const std::string& str, const ter_layer filler)
|
||||
{
|
||||
// Handle an empty string
|
||||
t_list result;
|
||||
ter_list result;
|
||||
|
||||
if(str.empty()) {
|
||||
return result;
|
||||
|
@ -226,7 +226,7 @@ t_list read_list(const std::string& str, const t_layer filler)
|
|||
const std::string terrain = str.substr(offset, pos_separator - offset);
|
||||
|
||||
// Process the chunk
|
||||
const t_terrain tile = string_to_number_(terrain, filler);
|
||||
const terrain_code tile = string_to_number_(terrain, filler);
|
||||
|
||||
// Add the resulting terrain number
|
||||
result.push_back(tile);
|
||||
|
@ -242,11 +242,11 @@ t_list read_list(const std::string& str, const t_layer filler)
|
|||
return result;
|
||||
}
|
||||
|
||||
std::string write_list(const t_list& list)
|
||||
std::string write_list(const ter_list& list)
|
||||
{
|
||||
std::stringstream result;
|
||||
|
||||
t_list::const_iterator itor = list.begin();
|
||||
ter_list::const_iterator itor = list.begin();
|
||||
for( ; itor != list.end(); ++itor) {
|
||||
if(itor == list.begin()) {
|
||||
result << number_to_string_(*itor);
|
||||
|
@ -282,7 +282,7 @@ static std::pair<int, int> get_map_size(const char* begin, const char* end)
|
|||
return{ w, h };
|
||||
}
|
||||
|
||||
t_map read_game_map(const std::string& str, tstarting_positions& starting_positions, coordinate border_offset)
|
||||
ter_map read_game_map(const std::string& str, tstarting_positions& starting_positions, coordinate border_offset)
|
||||
{
|
||||
size_t offset = 0;
|
||||
int x = 0, y = 0, width = 0;
|
||||
|
@ -294,11 +294,11 @@ t_map read_game_map(const std::string& str, tstarting_positions& starting_positi
|
|||
|
||||
// Did we get an empty map?
|
||||
if((offset + 1) >= str.length()) {
|
||||
return t_map();
|
||||
return ter_map();
|
||||
}
|
||||
|
||||
auto map_size = get_map_size(&str[offset], str.c_str() + str.size());
|
||||
t_map result(map_size.first, map_size.second);
|
||||
ter_map result(map_size.first, map_size.second);
|
||||
|
||||
while(offset < str.length()) {
|
||||
|
||||
|
@ -310,7 +310,7 @@ t_map read_game_map(const std::string& str, tstarting_positions& starting_positi
|
|||
// Process the chunk
|
||||
std::string starting_position;
|
||||
// The gamemap never has a wildcard
|
||||
const t_terrain tile = string_to_number_(terrain, starting_position, NO_LAYER);
|
||||
const terrain_code tile = string_to_number_(terrain, starting_position, NO_LAYER);
|
||||
|
||||
// Add to the resulting starting position
|
||||
if(!starting_position.empty()) {
|
||||
|
@ -380,7 +380,7 @@ t_map read_game_map(const std::string& str, tstarting_positions& starting_positi
|
|||
return result;
|
||||
}
|
||||
|
||||
std::string write_game_map(const t_map& map, const tstarting_positions& starting_positions, coordinate border_offset)
|
||||
std::string write_game_map(const ter_map& map, const tstarting_positions& starting_positions, coordinate border_offset)
|
||||
{
|
||||
std::stringstream str;
|
||||
|
||||
|
@ -410,12 +410,12 @@ std::string write_game_map(const t_map& map, const tstarting_positions& starting
|
|||
return str.str();
|
||||
}
|
||||
|
||||
bool terrain_matches(const t_terrain& src, const t_terrain& dest)
|
||||
bool terrain_matches(const terrain_code& src, const terrain_code& dest)
|
||||
{
|
||||
return terrain_matches(src, t_list(1, dest));
|
||||
return terrain_matches(src, ter_list(1, dest));
|
||||
}
|
||||
|
||||
bool terrain_matches(const t_terrain& src, const t_list& dest)
|
||||
bool terrain_matches(const terrain_code& src, const ter_list& dest)
|
||||
{
|
||||
// NOTE we impose some code duplication.
|
||||
// It could have been rewritten to get a match structure
|
||||
|
@ -434,7 +434,7 @@ bool terrain_matches(const t_terrain& src, const t_list& dest)
|
|||
#endif
|
||||
|
||||
bool result = true;
|
||||
t_list::const_iterator itor = dest.begin();
|
||||
ter_list::const_iterator itor = dest.begin();
|
||||
|
||||
// Try to match the terrains if matched jump out of the loop.
|
||||
for(; itor != dest.end(); ++itor) {
|
||||
|
@ -456,8 +456,8 @@ bool terrain_matches(const t_terrain& src, const t_list& dest)
|
|||
}
|
||||
|
||||
// Does the destination wildcard match
|
||||
const t_terrain dest_mask = get_mask_(*itor);
|
||||
const t_terrain masked_dest = (*itor & dest_mask);
|
||||
const terrain_code dest_mask = get_mask_(*itor);
|
||||
const terrain_code masked_dest = (*itor & dest_mask);
|
||||
const bool dest_has_wildcard = has_wildcard(*itor);
|
||||
#if 0
|
||||
std::cerr << std::hex << "dest= "
|
||||
|
@ -498,7 +498,7 @@ bool terrain_matches(const t_terrain& src, const t_list& dest)
|
|||
// This routine is used for the terrain building,
|
||||
// so it's one of the delays while loading a map.
|
||||
// This routine is optimized a bit at the loss of readability.
|
||||
bool terrain_matches(const t_terrain& src, const t_match& dest)
|
||||
bool terrain_matches(const terrain_code& src, const ter_match& dest)
|
||||
{
|
||||
if(dest.is_empty) {
|
||||
return false;
|
||||
|
@ -512,8 +512,8 @@ bool terrain_matches(const t_terrain& src, const t_match& dest)
|
|||
// Since dest.mask and dest.masked_terrain need to be in sync,
|
||||
// they are less often looked up, so no iterator for them.
|
||||
size_t i = 0;
|
||||
t_list::const_iterator end = dest.terrain.end();
|
||||
for(t_list::const_iterator terrain_itor = dest.terrain.begin();
|
||||
ter_list::const_iterator end = dest.terrain.end();
|
||||
for(ter_list::const_iterator terrain_itor = dest.terrain.begin();
|
||||
terrain_itor != end;
|
||||
++i, ++terrain_itor) {
|
||||
|
||||
|
@ -563,7 +563,7 @@ bool terrain_matches(const t_terrain& src, const t_match& dest)
|
|||
return !result;
|
||||
}
|
||||
|
||||
bool has_wildcard(const t_terrain& tcode)
|
||||
bool has_wildcard(const terrain_code& tcode)
|
||||
{
|
||||
if(tcode.overlay == NO_LAYER) {
|
||||
return get_layer_mask_(tcode.base) != NO_LAYER;
|
||||
|
@ -572,14 +572,14 @@ bool has_wildcard(const t_terrain& tcode)
|
|||
}
|
||||
}
|
||||
|
||||
bool has_wildcard(const t_list& list)
|
||||
bool has_wildcard(const ter_list& list)
|
||||
{
|
||||
if(list.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Test all items for a wildcard
|
||||
t_list::const_iterator itor = list.begin();
|
||||
ter_list::const_iterator itor = list.begin();
|
||||
for(; itor != list.end(); ++itor) {
|
||||
if(has_wildcard(*itor)) {
|
||||
return true;
|
||||
|
@ -590,9 +590,9 @@ bool has_wildcard(const t_list& list)
|
|||
return false;
|
||||
}
|
||||
|
||||
t_map read_builder_map(const std::string& str)
|
||||
ter_map read_builder_map(const std::string& str)
|
||||
{
|
||||
boost::multi_array<int, sizeof(t_map)> a;
|
||||
boost::multi_array<int, sizeof(ter_map)> a;
|
||||
|
||||
size_t offset = 0;
|
||||
// Skip the leading newlines
|
||||
|
@ -601,11 +601,11 @@ t_map read_builder_map(const std::string& str)
|
|||
}
|
||||
// Did we get an empty map?
|
||||
if((offset + 1) >= str.length()) {
|
||||
return t_map();
|
||||
return ter_map();
|
||||
}
|
||||
|
||||
auto map_size = get_map_size(&str[offset], str.c_str() + str.size());
|
||||
t_map result(map_size.second, map_size.first, t_terrain(t_translation::TB_DOT, t_layer()));
|
||||
ter_map result(map_size.second, map_size.first, terrain_code(t_translation::TB_DOT, ter_layer()));
|
||||
|
||||
int x = 0, y = 0;
|
||||
while(offset < str.length()) {
|
||||
|
@ -621,7 +621,7 @@ t_map read_builder_map(const std::string& str)
|
|||
}
|
||||
|
||||
// Process the chunk
|
||||
const t_terrain tile = string_to_builder_number_(terrain);
|
||||
const terrain_code tile = string_to_builder_number_(terrain);
|
||||
|
||||
// Make space for the new item
|
||||
if (result.h <= x || result.w <= y) {
|
||||
|
@ -663,7 +663,7 @@ t_map read_builder_map(const std::string& str)
|
|||
/***************************************************************************************/
|
||||
// Internal
|
||||
|
||||
inline t_layer get_layer_mask_(t_layer terrain)
|
||||
inline ter_layer get_layer_mask_(ter_layer terrain)
|
||||
{
|
||||
// Test for the star 0x2A in every position
|
||||
// and return the appropriate mask
|
||||
|
@ -688,22 +688,22 @@ inline t_layer get_layer_mask_(t_layer terrain)
|
|||
return 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
static t_terrain get_mask_(const t_terrain& terrain)
|
||||
static terrain_code get_mask_(const terrain_code& terrain)
|
||||
{
|
||||
if(terrain.overlay == NO_LAYER) {
|
||||
return t_terrain(get_layer_mask_(terrain.base), 0xFFFFFFFF);
|
||||
return terrain_code(get_layer_mask_(terrain.base), 0xFFFFFFFF);
|
||||
} else {
|
||||
return t_terrain(get_layer_mask_(terrain.base), get_layer_mask_(terrain.overlay));
|
||||
return terrain_code(get_layer_mask_(terrain.base), get_layer_mask_(terrain.overlay));
|
||||
}
|
||||
}
|
||||
|
||||
static t_layer string_to_layer_(const char* begin, const char* end)
|
||||
static ter_layer string_to_layer_(const char* begin, const char* end)
|
||||
{
|
||||
size_t size = end - begin;
|
||||
if (begin == end) {
|
||||
return NO_LAYER;
|
||||
}
|
||||
t_layer result = 0;
|
||||
ter_layer result = 0;
|
||||
|
||||
// Validate the string
|
||||
VALIDATE(size <= 4, _("A terrain with a string with more "
|
||||
|
@ -727,17 +727,17 @@ static t_layer string_to_layer_(const char* begin, const char* end)
|
|||
return result;
|
||||
}
|
||||
|
||||
static t_terrain string_to_number_(const std::string& str, const t_layer filler) {
|
||||
static terrain_code string_to_number_(const std::string& str, const ter_layer filler) {
|
||||
std::string dummy;
|
||||
return string_to_number_(str, dummy, filler);
|
||||
}
|
||||
|
||||
static t_terrain string_to_number_(std::string str, std::string& start_position, const t_layer filler)
|
||||
static terrain_code string_to_number_(std::string str, std::string& start_position, const ter_layer filler)
|
||||
{
|
||||
const char* c_str = str.c_str();
|
||||
size_t begin = 0;
|
||||
size_t end = str.size();
|
||||
t_terrain result;
|
||||
terrain_code result;
|
||||
|
||||
// Strip the spaces around us
|
||||
const std::string& whitespace = " \t";
|
||||
|
@ -760,9 +760,9 @@ static t_terrain string_to_number_(std::string str, std::string& start_position,
|
|||
|
||||
offset = str.find('^', 0);
|
||||
if(offset != std::string::npos) {
|
||||
result = t_terrain { string_to_layer_(c_str + begin, c_str + offset), string_to_layer_(c_str + offset + 1, c_str + end) };
|
||||
result = terrain_code { string_to_layer_(c_str + begin, c_str + offset), string_to_layer_(c_str + offset + 1, c_str + end) };
|
||||
} else {
|
||||
result = t_terrain { string_to_layer_(c_str + begin, c_str + end), filler };
|
||||
result = terrain_code { string_to_layer_(c_str + begin, c_str + end), filler };
|
||||
|
||||
// Ugly hack
|
||||
if(filler == WILDCARD && (result.base == NOT.base ||
|
||||
|
@ -775,7 +775,7 @@ static t_terrain string_to_number_(std::string str, std::string& start_position,
|
|||
return result;
|
||||
}
|
||||
|
||||
static std::string number_to_string_(t_terrain terrain, const std::string& start_position)
|
||||
static std::string number_to_string_(terrain_code terrain, const std::string& start_position)
|
||||
{
|
||||
std::string result = "";
|
||||
|
||||
|
@ -821,7 +821,7 @@ static std::string number_to_string_(t_terrain terrain, const std::string& start
|
|||
return result;
|
||||
}
|
||||
|
||||
static t_terrain string_to_builder_number_(std::string str)
|
||||
static terrain_code string_to_builder_number_(std::string str)
|
||||
{
|
||||
// Strip the spaces around us
|
||||
const std::string& whitespace = " \t";
|
||||
|
@ -832,7 +832,7 @@ static t_terrain string_to_builder_number_(std::string str)
|
|||
|
||||
// Empty string is allowed here, so handle it
|
||||
if(str.empty()) {
|
||||
return t_terrain();
|
||||
return terrain_code();
|
||||
}
|
||||
|
||||
const int number = lexical_cast_default(str, -1);
|
||||
|
@ -840,9 +840,9 @@ static t_terrain string_to_builder_number_(std::string str)
|
|||
// At this point we have a single char
|
||||
// which should be interpreted by the
|
||||
// map builder, so return this number
|
||||
return t_terrain(str[0] << 24, 0);
|
||||
return terrain_code(str[0] << 24, 0);
|
||||
} else {
|
||||
return t_terrain(0, number);
|
||||
return terrain_code(0, number);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -857,9 +857,9 @@ int main(int argc, char** argv)
|
|||
if(argc > 1) {
|
||||
|
||||
if(std::string(argv[1]) == "match" && argc == 4) {
|
||||
t_translation::t_terrain src = t_translation::read_terrain_code(std::string(argv[2]));
|
||||
t_translation::terrain_code src = t_translation::read_terrain_code(std::string(argv[2]));
|
||||
|
||||
t_translation::t_list dest = t_translation::read_list(std::string(argv[3]));
|
||||
t_translation::ter_list dest = t_translation::read_list(std::string(argv[3]));
|
||||
|
||||
if(t_translation::terrain_matches(src, dest)) {
|
||||
std::cout << "Match\n" ;
|
||||
|
|
|
@ -35,9 +35,9 @@ namespace t_translation {
|
|||
*/
|
||||
int max_map_size();
|
||||
|
||||
typedef uint32_t t_layer;
|
||||
const t_layer WILDCARD = 0x2A000000;
|
||||
const t_layer NO_LAYER = 0xFFFFFFFF;
|
||||
typedef uint32_t ter_layer;
|
||||
const ter_layer WILDCARD = 0x2A000000;
|
||||
const ter_layer NO_LAYER = 0xFFFFFFFF;
|
||||
|
||||
// The definitions for a terrain
|
||||
/**
|
||||
|
@ -46,57 +46,57 @@ namespace t_translation {
|
|||
* if no second layer is defined it is stored as 0xFFFFFFFF, if the second layer
|
||||
* is empty (needed for matching) the layer has the value 0.
|
||||
*/
|
||||
struct t_terrain {
|
||||
t_terrain(const std::string& b, const std::string& o);
|
||||
t_terrain(const std::string& b, t_layer o = NO_LAYER);
|
||||
t_terrain(t_layer b, t_layer o) : base(b), overlay(o) {}
|
||||
t_terrain() : base(0), overlay(NO_LAYER) {}
|
||||
struct terrain_code {
|
||||
terrain_code(const std::string& b, const std::string& o);
|
||||
terrain_code(const std::string& b, ter_layer o = NO_LAYER);
|
||||
terrain_code(ter_layer b, ter_layer o) : base(b), overlay(o) {}
|
||||
terrain_code() : base(0), overlay(NO_LAYER) {}
|
||||
|
||||
t_layer base;
|
||||
t_layer overlay;
|
||||
ter_layer base;
|
||||
ter_layer overlay;
|
||||
};
|
||||
const t_terrain NONE_TERRAIN = t_terrain();
|
||||
const terrain_code NONE_TERRAIN = terrain_code();
|
||||
|
||||
inline bool operator<(const t_terrain& a, const t_terrain& b)
|
||||
inline bool operator<(const terrain_code& a, const terrain_code& b)
|
||||
{ return a.base < b.base || (a.base == b.base && a.overlay < b.overlay); }
|
||||
|
||||
inline bool operator==(const t_terrain& a, const t_terrain& b)
|
||||
inline bool operator==(const terrain_code& a, const terrain_code& b)
|
||||
{ return a.base == b.base && a.overlay == b.overlay; }
|
||||
|
||||
inline bool operator!=(const t_terrain& a, const t_terrain& b)
|
||||
inline bool operator!=(const terrain_code& a, const terrain_code& b)
|
||||
{ return a.base != b.base || a.overlay != b.overlay; }
|
||||
|
||||
inline t_terrain operator&(const t_terrain& a, const t_terrain& b)
|
||||
{ return t_terrain(a.base & b.base, a.overlay & b.overlay); }
|
||||
inline terrain_code operator&(const terrain_code& a, const terrain_code& b)
|
||||
{ return terrain_code(a.base & b.base, a.overlay & b.overlay); }
|
||||
|
||||
inline t_terrain operator|(const t_terrain& a, const t_terrain& b)
|
||||
{ return t_terrain(a.base | b.base, a.overlay | b.overlay); }
|
||||
inline terrain_code operator|(const terrain_code& a, const terrain_code& b)
|
||||
{ return terrain_code(a.base | b.base, a.overlay | b.overlay); }
|
||||
|
||||
// operator<< is defined later
|
||||
|
||||
typedef std::vector<t_terrain> t_list;
|
||||
struct t_map {
|
||||
typedef std::vector<terrain_code> ter_list;
|
||||
struct ter_map {
|
||||
|
||||
t_map() = default;
|
||||
t_map(const t_map&) = default;
|
||||
ter_map() = default;
|
||||
ter_map(const ter_map&) = default;
|
||||
#if !defined(_MSC_VER) || _MSC_VER >= 1900
|
||||
t_map(t_map&&) = default;
|
||||
ter_map(ter_map&&) = default;
|
||||
#endif
|
||||
t_map(int w, int h, t_terrain fill = t_terrain()) : data(w * h, fill), w(w), h(h) {}
|
||||
ter_map(int w, int h, terrain_code fill = terrain_code()) : data(w * h, fill), w(w), h(h) {}
|
||||
|
||||
t_map & operator= (const t_map &) = default;
|
||||
ter_map & operator= (const ter_map &) = default;
|
||||
#if !defined(_MSC_VER) || _MSC_VER >= 1900
|
||||
t_map & operator= (t_map &&) = default;
|
||||
ter_map & operator= (ter_map &&) = default;
|
||||
#endif
|
||||
|
||||
t_terrain& get(int x, int y) { return data[x * h + y]; }
|
||||
const t_terrain& get(int x, int y) const { return data[x * h + y]; }
|
||||
terrain_code& get(int x, int y) { return data[x * h + y]; }
|
||||
const terrain_code& get(int x, int y) const { return data[x * h + y]; }
|
||||
|
||||
std::vector<t_terrain> data;
|
||||
std::vector<terrain_code> data;
|
||||
int w;
|
||||
int h;
|
||||
std::vector<t_terrain>::iterator operator[](int x) { return data.begin() + h * x; }
|
||||
std::vector<t_terrain>::const_iterator operator[](int x) const { return data.begin() + h * x; }
|
||||
std::vector<terrain_code>::iterator operator[](int x) { return data.begin() + h * x; }
|
||||
std::vector<terrain_code>::const_iterator operator[](int x) const { return data.begin() + h * x; }
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -104,14 +104,14 @@ namespace t_translation {
|
|||
* It optimized for strings that need to be matched often,
|
||||
* and caches the wildcard info required for matching.
|
||||
*/
|
||||
struct t_match{
|
||||
t_match();
|
||||
t_match(const std::string& str, const t_layer filler = NO_LAYER);
|
||||
t_match(const t_terrain& tcode);
|
||||
struct ter_match{
|
||||
ter_match();
|
||||
ter_match(const std::string& str, const ter_layer filler = NO_LAYER);
|
||||
ter_match(const terrain_code& tcode);
|
||||
|
||||
t_list terrain;
|
||||
t_list mask;
|
||||
t_list masked_terrain;
|
||||
ter_list terrain;
|
||||
ter_list mask;
|
||||
ter_list masked_terrain;
|
||||
bool has_wildcard;
|
||||
bool is_empty;
|
||||
};
|
||||
|
@ -130,37 +130,37 @@ namespace t_translation {
|
|||
// be loaded in dynamically because they're special.
|
||||
// It's asserted that there will be corresponding entries for
|
||||
// these types of terrain in the terrain configuration file.
|
||||
extern const t_terrain VOID_TERRAIN;
|
||||
extern const t_terrain FOGGED;
|
||||
extern const terrain_code VOID_TERRAIN;
|
||||
extern const terrain_code FOGGED;
|
||||
|
||||
// On the map the user can use this type to make odd shaped maps look good.
|
||||
extern const t_terrain OFF_MAP_USER;
|
||||
extern const terrain_code OFF_MAP_USER;
|
||||
|
||||
extern const t_terrain HUMAN_CASTLE;
|
||||
extern const t_terrain HUMAN_KEEP;
|
||||
extern const t_terrain SHALLOW_WATER;
|
||||
extern const t_terrain DEEP_WATER;
|
||||
extern const t_terrain GRASS_LAND;
|
||||
extern const t_terrain FOREST;
|
||||
extern const t_terrain MOUNTAIN;
|
||||
extern const t_terrain HILL;
|
||||
extern const terrain_code HUMAN_CASTLE;
|
||||
extern const terrain_code HUMAN_KEEP;
|
||||
extern const terrain_code SHALLOW_WATER;
|
||||
extern const terrain_code DEEP_WATER;
|
||||
extern const terrain_code GRASS_LAND;
|
||||
extern const terrain_code FOREST;
|
||||
extern const terrain_code MOUNTAIN;
|
||||
extern const terrain_code HILL;
|
||||
|
||||
extern const t_terrain CAVE_WALL;
|
||||
extern const t_terrain CAVE;
|
||||
extern const t_terrain UNDERGROUND_VILLAGE;
|
||||
extern const t_terrain DWARVEN_CASTLE;
|
||||
extern const t_terrain DWARVEN_KEEP;
|
||||
extern const terrain_code CAVE_WALL;
|
||||
extern const terrain_code CAVE;
|
||||
extern const terrain_code UNDERGROUND_VILLAGE;
|
||||
extern const terrain_code DWARVEN_CASTLE;
|
||||
extern const terrain_code DWARVEN_KEEP;
|
||||
|
||||
extern const t_terrain PLUS; // +
|
||||
extern const t_terrain MINUS; // -
|
||||
extern const t_terrain NOT; // !
|
||||
extern const t_terrain STAR; // *
|
||||
extern const t_terrain BASE; // references the base terrain in movement/defense aliases
|
||||
extern const terrain_code PLUS; // +
|
||||
extern const terrain_code MINUS; // -
|
||||
extern const terrain_code NOT; // !
|
||||
extern const terrain_code STAR; // *
|
||||
extern const terrain_code BASE; // references the base terrain in movement/defense aliases
|
||||
|
||||
extern const t_match ALL_FORESTS;
|
||||
extern const t_match ALL_HILLS;
|
||||
extern const t_match ALL_MOUNTAINS; //excluding impassable mountains
|
||||
extern const t_match ALL_SWAMPS;
|
||||
extern const ter_match ALL_FORESTS;
|
||||
extern const ter_match ALL_HILLS;
|
||||
extern const ter_match ALL_MOUNTAINS; //excluding impassable mountains
|
||||
extern const ter_match ALL_SWAMPS;
|
||||
|
||||
/**
|
||||
* Reads a single terrain from a string.
|
||||
|
@ -183,7 +183,7 @@ namespace t_translation {
|
|||
*
|
||||
* @return A single terrain code
|
||||
*/
|
||||
t_terrain read_terrain_code(const std::string& str, const t_layer filler = NO_LAYER);
|
||||
terrain_code read_terrain_code(const std::string& str, const ter_layer filler = NO_LAYER);
|
||||
|
||||
/**
|
||||
* Writes a single terrain code to a string.
|
||||
|
@ -193,8 +193,8 @@ namespace t_translation {
|
|||
*
|
||||
* @return A string containing the terrain code
|
||||
*/
|
||||
std::string write_terrain_code(const t_terrain& tcode);
|
||||
inline std::ostream &operator<<(std::ostream &s, const t_terrain &a)
|
||||
std::string write_terrain_code(const terrain_code& tcode);
|
||||
inline std::ostream &operator<<(std::ostream &s, const terrain_code &a)
|
||||
{ s << write_terrain_code(a); return s; }
|
||||
|
||||
/**
|
||||
|
@ -205,7 +205,7 @@ namespace t_translation {
|
|||
*
|
||||
* @returns A vector which contains the terrain codes found in the string
|
||||
*/
|
||||
t_list read_list(const std::string& str, const t_layer filler = NO_LAYER);
|
||||
ter_list read_list(const std::string& str, const ter_layer filler = NO_LAYER);
|
||||
|
||||
/**
|
||||
* Writes a list of terrains to a string, only writes the new format.
|
||||
|
@ -215,7 +215,7 @@ namespace t_translation {
|
|||
* @returns A string with the terrain codes, comma separated
|
||||
* and a space behind the commas. Not padded.
|
||||
*/
|
||||
std::string write_list(const t_list& list);
|
||||
std::string write_list(const ter_list& list);
|
||||
|
||||
using tstarting_positions = boost::bimaps::bimap<boost::bimaps::set_of<std::string>, boost::bimaps::multiset_of<coordinate>>;
|
||||
/**
|
||||
|
@ -250,7 +250,7 @@ namespace t_translation {
|
|||
* @returns A 2D vector with the terrains found the vector data is stored
|
||||
* like result[x][y] where x the column number is and y the row number.
|
||||
*/
|
||||
t_map read_game_map(const std::string& str, tstarting_positions& starting_positions, coordinate border_offset = coordinate{ 0, 0 });
|
||||
ter_map read_game_map(const std::string& str, tstarting_positions& starting_positions, coordinate border_offset = coordinate{ 0, 0 });
|
||||
|
||||
/**
|
||||
* Write a gamemap in to a vector string.
|
||||
|
@ -262,7 +262,7 @@ namespace t_translation {
|
|||
* For readability the map is padded to groups of 12 chars,
|
||||
* followed by a comma and space.
|
||||
*/
|
||||
std::string write_game_map(const t_map& map, const tstarting_positions& starting_positions = tstarting_positions(), coordinate border_offset = coordinate{ 0, 0 });
|
||||
std::string write_game_map(const ter_map& map, const tstarting_positions& starting_positions = tstarting_positions(), coordinate border_offset = coordinate{ 0, 0 });
|
||||
|
||||
/**
|
||||
* Tests whether a specific terrain matches a list of expressions.
|
||||
|
@ -298,7 +298,7 @@ namespace t_translation {
|
|||
*
|
||||
* @returns the result of the match (depending on the !'s)
|
||||
*/
|
||||
bool terrain_matches(const t_terrain& src, const t_list& dest);
|
||||
bool terrain_matches(const terrain_code& src, const ter_list& dest);
|
||||
|
||||
/**
|
||||
* Tests whether a specific terrain matches an expression,
|
||||
|
@ -309,7 +309,7 @@ namespace t_translation {
|
|||
*
|
||||
* @returns the result of the match (depending on the !'s)
|
||||
*/
|
||||
bool terrain_matches(const t_terrain& src, const t_terrain& dest);
|
||||
bool terrain_matches(const terrain_code& src, const terrain_code& dest);
|
||||
|
||||
/**
|
||||
* Tests whether a certain terrain matches a list of expressions, for matching
|
||||
|
@ -322,7 +322,7 @@ namespace t_translation {
|
|||
*
|
||||
* @returns the result of the match (depending on the !'s)
|
||||
*/
|
||||
bool terrain_matches(const t_terrain& src, const t_match& dest);
|
||||
bool terrain_matches(const terrain_code& src, const ter_match& dest);
|
||||
|
||||
/**
|
||||
* Tests whether a terrain code contains a wildcard
|
||||
|
@ -331,7 +331,7 @@ namespace t_translation {
|
|||
*
|
||||
* @returns true if wildcard found, else false
|
||||
*/
|
||||
bool has_wildcard(const t_terrain& tcode);
|
||||
bool has_wildcard(const terrain_code& tcode);
|
||||
|
||||
/**
|
||||
* Tests whether a terrain-code list contains at least
|
||||
|
@ -341,12 +341,12 @@ namespace t_translation {
|
|||
*
|
||||
* @returns true if a wildcard found, else false
|
||||
*/
|
||||
bool has_wildcard(const t_list& list);
|
||||
bool has_wildcard(const ter_list& list);
|
||||
|
||||
// These terrain letters are in the builder format,
|
||||
// and not usable in other parts of the engine
|
||||
const t_layer TB_STAR = '*' << 24; // It can be assumed this is the equivalent of STAR
|
||||
const t_layer TB_DOT = '.' << 24;
|
||||
const ter_layer TB_STAR = '*' << 24; // It can be assumed this is the equivalent of STAR
|
||||
const ter_layer TB_DOT = '.' << 24;
|
||||
|
||||
/**
|
||||
* Reads a builder map.
|
||||
|
@ -362,7 +362,7 @@ namespace t_translation {
|
|||
* @returns A 2D vector with the data found the vector data is stored
|
||||
* like result[y][x] where x the column number is and y the row number.
|
||||
*/
|
||||
t_map read_builder_map(const std::string& str);
|
||||
ter_map read_builder_map(const std::string& str);
|
||||
|
||||
} // end namespace t_translation
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ terrain_type_data::terrain_type_data(const config & game_config)
|
|||
{
|
||||
}
|
||||
|
||||
const t_translation::t_list & terrain_type_data::list() const
|
||||
const t_translation::ter_list & terrain_type_data::list() const
|
||||
{
|
||||
if (!initialized_) {
|
||||
create_terrain_maps(game_config_.child_range("terrain_type"), terrainList_, tcodeToTerrain_);
|
||||
|
@ -39,7 +39,7 @@ const t_translation::t_list & terrain_type_data::list() const
|
|||
}
|
||||
|
||||
|
||||
const std::map<t_translation::t_terrain, terrain_type> & terrain_type_data::map() const
|
||||
const std::map<t_translation::terrain_code, terrain_type> & terrain_type_data::map() const
|
||||
{
|
||||
if (!initialized_) {
|
||||
create_terrain_maps(game_config_.child_range("terrain_type"), terrainList_, tcodeToTerrain_);
|
||||
|
@ -50,10 +50,10 @@ const std::map<t_translation::t_terrain, terrain_type> & terrain_type_data::map(
|
|||
}
|
||||
|
||||
|
||||
const terrain_type& terrain_type_data::get_terrain_info(const t_translation::t_terrain & terrain) const
|
||||
const terrain_type& terrain_type_data::get_terrain_info(const t_translation::terrain_code & terrain) const
|
||||
{
|
||||
static const terrain_type default_terrain;
|
||||
const std::map<t_translation::t_terrain,terrain_type>::const_iterator i =
|
||||
const std::map<t_translation::terrain_code,terrain_type>::const_iterator i =
|
||||
tcodeToTerrain_.find(terrain);
|
||||
|
||||
if(i != tcodeToTerrain_.end())
|
||||
|
@ -62,13 +62,13 @@ const terrain_type& terrain_type_data::get_terrain_info(const t_translation::t_t
|
|||
return default_terrain;
|
||||
}
|
||||
|
||||
const t_translation::t_list& terrain_type_data::underlying_mvt_terrain(const t_translation::t_terrain & terrain) const
|
||||
const t_translation::ter_list& terrain_type_data::underlying_mvt_terrain(const t_translation::terrain_code & terrain) const
|
||||
{
|
||||
const std::map<t_translation::t_terrain,terrain_type>::const_iterator i =
|
||||
const std::map<t_translation::terrain_code,terrain_type>::const_iterator i =
|
||||
tcodeToTerrain_.find(terrain);
|
||||
|
||||
if(i == tcodeToTerrain_.end()) {
|
||||
static t_translation::t_list result(1);
|
||||
static t_translation::ter_list result(1);
|
||||
result[0] = terrain;
|
||||
return result;
|
||||
} else {
|
||||
|
@ -76,13 +76,13 @@ const t_translation::t_list& terrain_type_data::underlying_mvt_terrain(const t_t
|
|||
}
|
||||
}
|
||||
|
||||
const t_translation::t_list& terrain_type_data::underlying_def_terrain(const t_translation::t_terrain & terrain) const
|
||||
const t_translation::ter_list& terrain_type_data::underlying_def_terrain(const t_translation::terrain_code & terrain) const
|
||||
{
|
||||
const std::map<t_translation::t_terrain, terrain_type>::const_iterator i =
|
||||
const std::map<t_translation::terrain_code, terrain_type>::const_iterator i =
|
||||
tcodeToTerrain_.find(terrain);
|
||||
|
||||
if(i == tcodeToTerrain_.end()) {
|
||||
static t_translation::t_list result(1);
|
||||
static t_translation::ter_list result(1);
|
||||
result[0] = terrain;
|
||||
return result;
|
||||
} else {
|
||||
|
@ -90,13 +90,13 @@ const t_translation::t_list& terrain_type_data::underlying_def_terrain(const t_t
|
|||
}
|
||||
}
|
||||
|
||||
const t_translation::t_list& terrain_type_data::underlying_union_terrain(const t_translation::t_terrain & terrain) const
|
||||
const t_translation::ter_list& terrain_type_data::underlying_union_terrain(const t_translation::terrain_code & terrain) const
|
||||
{
|
||||
const std::map<t_translation::t_terrain,terrain_type>::const_iterator i =
|
||||
const std::map<t_translation::terrain_code,terrain_type>::const_iterator i =
|
||||
tcodeToTerrain_.find(terrain);
|
||||
|
||||
if(i == tcodeToTerrain_.end()) {
|
||||
static t_translation::t_list result(1);
|
||||
static t_translation::ter_list result(1);
|
||||
result[0] = terrain;
|
||||
return result;
|
||||
} else {
|
||||
|
@ -106,7 +106,7 @@ const t_translation::t_list& terrain_type_data::underlying_union_terrain(const t
|
|||
|
||||
|
||||
|
||||
std::string terrain_type_data::get_terrain_string(const t_translation::t_terrain& terrain) const
|
||||
std::string terrain_type_data::get_terrain_string(const t_translation::terrain_code& terrain) const
|
||||
{
|
||||
std::string str =
|
||||
get_terrain_info(terrain).description();
|
||||
|
@ -116,7 +116,7 @@ std::string terrain_type_data::get_terrain_string(const t_translation::t_terrain
|
|||
return str;
|
||||
}
|
||||
|
||||
std::string terrain_type_data::get_terrain_editor_string(const t_translation::t_terrain& terrain) const
|
||||
std::string terrain_type_data::get_terrain_editor_string(const t_translation::terrain_code& terrain) const
|
||||
{
|
||||
std::string str =
|
||||
get_terrain_info(terrain).editor_name();
|
||||
|
@ -133,16 +133,16 @@ std::string terrain_type_data::get_terrain_editor_string(const t_translation::t_
|
|||
return str;
|
||||
}
|
||||
|
||||
std::string terrain_type_data::get_underlying_terrain_string(const t_translation::t_terrain& terrain) const
|
||||
std::string terrain_type_data::get_underlying_terrain_string(const t_translation::terrain_code& terrain) const
|
||||
{
|
||||
std::string str;
|
||||
|
||||
const t_translation::t_list& underlying = underlying_union_terrain(terrain);
|
||||
const t_translation::ter_list& underlying = underlying_union_terrain(terrain);
|
||||
assert(!underlying.empty());
|
||||
|
||||
if(underlying.size() > 1 || underlying[0] != terrain) {
|
||||
str += " (";
|
||||
t_translation::t_list::const_iterator i = underlying.begin();
|
||||
t_translation::ter_list::const_iterator i = underlying.begin();
|
||||
str += get_terrain_info(*i).name();
|
||||
while (++i != underlying.end()) {
|
||||
str += ", " + get_terrain_info(*i).name();
|
||||
|
@ -153,13 +153,13 @@ std::string terrain_type_data::get_underlying_terrain_string(const t_translation
|
|||
return str;
|
||||
}
|
||||
|
||||
bool terrain_type_data::try_merge_terrains(const t_translation::t_terrain & terrain) {
|
||||
bool terrain_type_data::try_merge_terrains(const t_translation::terrain_code & terrain) {
|
||||
|
||||
if(tcodeToTerrain_.count(terrain) == 0) {
|
||||
const std::map<t_translation::t_terrain, terrain_type>::const_iterator base_iter =
|
||||
tcodeToTerrain_.find(t_translation::t_terrain(terrain.base, t_translation::NO_LAYER));
|
||||
const std::map<t_translation::t_terrain, terrain_type>::const_iterator overlay_iter =
|
||||
tcodeToTerrain_.find(t_translation::t_terrain(t_translation::NO_LAYER, terrain.overlay));
|
||||
const std::map<t_translation::terrain_code, terrain_type>::const_iterator base_iter =
|
||||
tcodeToTerrain_.find(t_translation::terrain_code(terrain.base, t_translation::NO_LAYER));
|
||||
const std::map<t_translation::terrain_code, terrain_type>::const_iterator overlay_iter =
|
||||
tcodeToTerrain_.find(t_translation::terrain_code(t_translation::NO_LAYER, terrain.overlay));
|
||||
|
||||
if(base_iter == tcodeToTerrain_.end() || overlay_iter == tcodeToTerrain_.end()) {
|
||||
return false;
|
||||
|
@ -167,24 +167,24 @@ bool terrain_type_data::try_merge_terrains(const t_translation::t_terrain & terr
|
|||
|
||||
terrain_type new_terrain(base_iter->second, overlay_iter->second);
|
||||
terrainList_.push_back(new_terrain.number());
|
||||
tcodeToTerrain_.insert(std::pair<t_translation::t_terrain, terrain_type>(
|
||||
tcodeToTerrain_.insert(std::pair<t_translation::terrain_code, terrain_type>(
|
||||
new_terrain.number(), new_terrain));
|
||||
return true;
|
||||
}
|
||||
return true; // Terrain already exists, nothing to do
|
||||
}
|
||||
|
||||
t_translation::t_terrain terrain_type_data::merge_terrains(const t_translation::t_terrain & old_t, const t_translation::t_terrain & new_t, const tmerge_mode mode, bool replace_if_failed) {
|
||||
t_translation::t_terrain result = t_translation::NONE_TERRAIN;
|
||||
t_translation::terrain_code terrain_type_data::merge_terrains(const t_translation::terrain_code & old_t, const t_translation::terrain_code & new_t, const tmerge_mode mode, bool replace_if_failed) {
|
||||
t_translation::terrain_code result = t_translation::NONE_TERRAIN;
|
||||
|
||||
if(mode == OVERLAY) {
|
||||
const t_translation::t_terrain t = t_translation::t_terrain(old_t.base, new_t.overlay);
|
||||
const t_translation::terrain_code t = t_translation::terrain_code(old_t.base, new_t.overlay);
|
||||
if (try_merge_terrains(t)) {
|
||||
result = t;
|
||||
}
|
||||
}
|
||||
else if(mode == BASE) {
|
||||
const t_translation::t_terrain t = t_translation::t_terrain(new_t.base, old_t.overlay);
|
||||
const t_translation::terrain_code t = t_translation::terrain_code(new_t.base, old_t.overlay);
|
||||
if (try_merge_terrains(t)) {
|
||||
result = t;
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
class terrain_type_data {
|
||||
private:
|
||||
mutable t_translation::t_list terrainList_;
|
||||
mutable std::map<t_translation::t_terrain, terrain_type> tcodeToTerrain_;
|
||||
mutable t_translation::ter_list terrainList_;
|
||||
mutable std::map<t_translation::terrain_code, terrain_type> tcodeToTerrain_;
|
||||
|
||||
mutable bool initialized_;
|
||||
const config & game_config_;
|
||||
|
@ -30,36 +30,36 @@ private:
|
|||
public:
|
||||
terrain_type_data(const config & game_config);
|
||||
|
||||
const t_translation::t_list & list() const;
|
||||
const std::map<t_translation::t_terrain, terrain_type> & map() const;
|
||||
const t_translation::ter_list & list() const;
|
||||
const std::map<t_translation::terrain_code, terrain_type> & map() const;
|
||||
|
||||
/**
|
||||
* Get the corresponding terrain_type information object
|
||||
* for a given type of terrain.
|
||||
*/
|
||||
const terrain_type& get_terrain_info(const t_translation::t_terrain & terrain) const;
|
||||
const terrain_type& get_terrain_info(const t_translation::terrain_code & terrain) const;
|
||||
|
||||
// The name of the terrain is the terrain itself,
|
||||
// The underlying terrain is the name of the terrain for game-logic purposes.
|
||||
// I.e. if the terrain is simply an alias, the underlying terrain name
|
||||
// is the name of the terrain that it's aliased to.
|
||||
const t_translation::t_list& underlying_mvt_terrain(const t_translation::t_terrain & terrain) const;
|
||||
const t_translation::t_list& underlying_def_terrain(const t_translation::t_terrain & terrain) const;
|
||||
const t_translation::t_list& underlying_union_terrain(const t_translation::t_terrain & terrain) const;
|
||||
const t_translation::ter_list& underlying_mvt_terrain(const t_translation::terrain_code & terrain) const;
|
||||
const t_translation::ter_list& underlying_def_terrain(const t_translation::terrain_code & terrain) const;
|
||||
const t_translation::ter_list& underlying_union_terrain(const t_translation::terrain_code & terrain) const;
|
||||
/**
|
||||
* Get a formatted terrain name -- terrain (underlying, terrains)
|
||||
*/
|
||||
std::string get_terrain_string(const t_translation::t_terrain& terrain) const;
|
||||
std::string get_terrain_editor_string(const t_translation::t_terrain& terrain) const;
|
||||
std::string get_underlying_terrain_string(const t_translation::t_terrain& terrain) const;
|
||||
std::string get_terrain_string(const t_translation::terrain_code& terrain) const;
|
||||
std::string get_terrain_editor_string(const t_translation::terrain_code& terrain) const;
|
||||
std::string get_underlying_terrain_string(const t_translation::terrain_code& terrain) const;
|
||||
|
||||
bool is_village(const t_translation::t_terrain & terrain) const
|
||||
bool is_village(const t_translation::terrain_code & terrain) const
|
||||
{ return get_terrain_info(terrain).is_village(); }
|
||||
int gives_healing(const t_translation::t_terrain & terrain) const
|
||||
int gives_healing(const t_translation::terrain_code & terrain) const
|
||||
{ return get_terrain_info(terrain).gives_healing(); }
|
||||
bool is_castle(const t_translation::t_terrain & terrain) const
|
||||
bool is_castle(const t_translation::terrain_code & terrain) const
|
||||
{ return get_terrain_info(terrain).is_castle(); }
|
||||
bool is_keep(const t_translation::t_terrain & terrain) const
|
||||
bool is_keep(const t_translation::terrain_code & terrain) const
|
||||
{ return get_terrain_info(terrain).is_keep(); }
|
||||
|
||||
enum tmerge_mode {
|
||||
|
@ -76,14 +76,14 @@ public:
|
|||
* (using the default base if new terrain is an overlay terrain)
|
||||
* Will return the resulting terrain or NONE_TERRAIN if merging failed
|
||||
*/
|
||||
t_translation::t_terrain merge_terrains(const t_translation::t_terrain & old_t, const t_translation::t_terrain & new_t, const tmerge_mode mode, bool replace_if_failed = false);
|
||||
t_translation::terrain_code merge_terrains(const t_translation::terrain_code & old_t, const t_translation::terrain_code & new_t, const tmerge_mode mode, bool replace_if_failed = false);
|
||||
|
||||
/**
|
||||
* Tries to find out if "terrain" can be created by combining two existing
|
||||
* terrains Will add the resulting terrain to the terrain list if
|
||||
* successful
|
||||
*/
|
||||
bool try_merge_terrains(const t_translation::t_terrain & terrain);
|
||||
bool try_merge_terrains(const t_translation::terrain_code & terrain);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ class unit_animation
|
|||
bool cycles_;
|
||||
|
||||
};
|
||||
t_translation::t_list terrain_types_;
|
||||
t_translation::ter_list terrain_types_;
|
||||
std::vector<config> unit_filter_;
|
||||
std::vector<config> secondary_unit_filter_;
|
||||
std::vector<map_location::DIRECTION> directions_;
|
||||
|
|
|
@ -160,7 +160,7 @@ bool unit_animation_component::invalidate (const display & disp)
|
|||
if(get_animation()) {
|
||||
frame_parameters params;
|
||||
const gamemap & map = disp.get_map();
|
||||
const t_translation::t_terrain terrain = map.get_terrain(u_.loc_);
|
||||
const t_translation::terrain_code terrain = map.get_terrain(u_.loc_);
|
||||
const terrain_type& terrain_info = map.get_terrain_info(terrain);
|
||||
|
||||
int height_adjust = static_cast<int>(terrain_info.unit_height_adjust() * disp.get_zoom_factor());
|
||||
|
|
|
@ -95,7 +95,7 @@ void unit_drawer::redraw_unit (const unit & u) const
|
|||
|
||||
ac.anim_->update_last_draw_time();
|
||||
frame_parameters params;
|
||||
const t_translation::t_terrain terrain = map.get_terrain(loc);
|
||||
const t_translation::terrain_code terrain = map.get_terrain(loc);
|
||||
const terrain_type& terrain_info = map.get_terrain_info(terrain);
|
||||
|
||||
// do not set to 0 so we can distinguish the flying from the "not on submerge terrain"
|
||||
|
@ -317,7 +317,7 @@ void unit_drawer::redraw_unit (const unit & u) const
|
|||
// Smooth unit movements from terrain of different elevation.
|
||||
// Do this separately from above so that the health bar doesn't go up and down.
|
||||
|
||||
const t_translation::t_terrain terrain_dst = map.get_terrain(dst);
|
||||
const t_translation::terrain_code terrain_dst = map.get_terrain(dst);
|
||||
const terrain_type& terrain_dst_info = map.get_terrain_info(terrain_dst);
|
||||
|
||||
int height_adjust_unit = static_cast<int>((terrain_info.unit_height_adjust() * (1.0 - adjusted_params.offset) +
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
#include <SDL_video.h> // for SDL_Color
|
||||
|
||||
|
||||
namespace t_translation { struct t_terrain; }
|
||||
namespace t_translation { struct terrain_code; }
|
||||
|
||||
static lg::log_domain log_unit("unit");
|
||||
#define DBG_UT LOG_STREAM(debug, log_unit)
|
||||
|
@ -1519,7 +1519,7 @@ bool unit::loyal() const
|
|||
return boost::get<upkeep_loyal>(&upkeep_) != nullptr;
|
||||
}
|
||||
|
||||
int unit::defense_modifier(const t_translation::t_terrain & terrain) const
|
||||
int unit::defense_modifier(const t_translation::terrain_code & terrain) const
|
||||
{
|
||||
int def = movement_type_.defense_modifier(terrain);
|
||||
#if 0
|
||||
|
|
|
@ -297,13 +297,13 @@ public:
|
|||
bool is_flying() const { return movement_type_.is_flying(); }
|
||||
bool is_fearless() const { return is_fearless_; }
|
||||
bool is_healthy() const { return is_healthy_; }
|
||||
int movement_cost(const t_translation::t_terrain & terrain) const
|
||||
int movement_cost(const t_translation::terrain_code & terrain) const
|
||||
{ return movement_type_.movement_cost(terrain, get_state(STATE_SLOWED)); }
|
||||
int vision_cost(const t_translation::t_terrain & terrain) const
|
||||
int vision_cost(const t_translation::terrain_code & terrain) const
|
||||
{ return movement_type_.vision_cost(terrain, get_state(STATE_SLOWED)); }
|
||||
int jamming_cost(const t_translation::t_terrain & terrain) const
|
||||
int jamming_cost(const t_translation::terrain_code & terrain) const
|
||||
{ return movement_type_.jamming_cost(terrain, get_state(STATE_SLOWED)); }
|
||||
int defense_modifier(const t_translation::t_terrain & terrain) const;
|
||||
int defense_modifier(const t_translation::terrain_code & terrain) const;
|
||||
int resistance_against(const std::string& damage_name,bool attacker,const map_location& loc) const;
|
||||
int resistance_against(const attack_type& damage_type,bool attacker,const map_location& loc) const
|
||||
{ return resistance_against(damage_type.type(), attacker, loc); }
|
||||
|
|
Loading…
Add table
Reference in a new issue