Formatting cleanup: T const& -> const T&
This commit is contained in:
parent
f4e9ac3f8f
commit
f23305f7e2
100 changed files with 349 additions and 349 deletions
|
@ -481,7 +481,7 @@ addons_client::install_result addons_client::install_addon_with_checks(const add
|
|||
|
||||
bool addons_client::update_last_error(config& response_cfg)
|
||||
{
|
||||
if(config const &error = response_cfg.child("error")) {
|
||||
if(const config& error = response_cfg.child("error")) {
|
||||
this->last_error_ = font::escape_text(error["message"].str());
|
||||
this->last_error_data_ = font::escape_text(error["extra_data"].str());
|
||||
ERR_ADDONS << "server error: " << error << '\n';
|
||||
|
|
|
@ -1121,32 +1121,32 @@ void sim_gamestate_changed(action_result *result, bool gamestate_changed){
|
|||
} //end of namespace ai
|
||||
|
||||
|
||||
std::ostream &operator<<(std::ostream &s, ai::attack_result const &r) {
|
||||
std::ostream &operator<<(std::ostream &s, const ai::attack_result& r) {
|
||||
s << r.do_describe();
|
||||
return s;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &s, ai::move_result const &r) {
|
||||
std::ostream &operator<<(std::ostream &s, const ai::move_result& r) {
|
||||
s << r.do_describe();
|
||||
return s;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &s, ai::recall_result const &r) {
|
||||
std::ostream &operator<<(std::ostream &s, const ai::recall_result& r) {
|
||||
s << r.do_describe();
|
||||
return s;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &s, ai::recruit_result const &r) {
|
||||
std::ostream &operator<<(std::ostream &s, const ai::recruit_result& r) {
|
||||
s << r.do_describe();
|
||||
return s;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &s, ai::stopunit_result const &r) {
|
||||
std::ostream &operator<<(std::ostream &s, const ai::stopunit_result& r) {
|
||||
s << r.do_describe();
|
||||
return s;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &s, ai::synced_command_result const &r) {
|
||||
std::ostream &operator<<(std::ostream &s, const ai::synced_command_result& r) {
|
||||
s << r.do_describe();
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -453,10 +453,10 @@ static std::map<int,std::string> error_names_;
|
|||
|
||||
} //end of namespace ai
|
||||
|
||||
std::ostream &operator<<(std::ostream &s, ai::attack_result const &r);
|
||||
std::ostream &operator<<(std::ostream &s, ai::move_result const &r);
|
||||
std::ostream &operator<<(std::ostream &s, ai::recall_result const &r);
|
||||
std::ostream &operator<<(std::ostream &s, ai::recruit_result const &r);
|
||||
std::ostream &operator<<(std::ostream &s, ai::stopunit_result const &r);
|
||||
std::ostream &operator<<(std::ostream &s, ai::synced_command_result const &r);
|
||||
std::ostream &operator<<(std::ostream &s, const ai::attack_result& r);
|
||||
std::ostream &operator<<(std::ostream &s, const ai::move_result& r);
|
||||
std::ostream &operator<<(std::ostream &s, const ai::recall_result& r);
|
||||
std::ostream &operator<<(std::ostream &s, const ai::recruit_result& r);
|
||||
std::ostream &operator<<(std::ostream &s, const ai::stopunit_result& r);
|
||||
std::ostream &operator<<(std::ostream &s, const ai::synced_command_result& r);
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ bool candidate_action_factory::is_duplicate(const std::string& name)
|
|||
|
||||
//============================================================================
|
||||
|
||||
std::ostream &operator<<(std::ostream &s, ai::candidate_action const &ca) {
|
||||
std::ostream &operator<<(std::ostream &s, const ai::candidate_action& ca) {
|
||||
s << "candidate action with name ["<< ca.get_name() <<"]";
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ public:
|
|||
|
||||
//============================================================================
|
||||
|
||||
std::ostream &operator<<(std::ostream &s, ai::candidate_action const &ca);
|
||||
std::ostream &operator<<(std::ostream &s, const ai::candidate_action& ca);
|
||||
|
||||
} //end of namespace ai
|
||||
|
||||
|
|
|
@ -207,7 +207,7 @@ public:
|
|||
|
||||
|
||||
//@note: following part is in alphabetic order
|
||||
virtual defensive_position const& best_defensive_position(const map_location& unit,
|
||||
virtual const defensive_position& best_defensive_position(const map_location& unit,
|
||||
const move_map& dstsrc, const move_map& srcdst, const move_map& enemy_dstsrc) const = 0;
|
||||
|
||||
|
||||
|
@ -616,7 +616,7 @@ public:
|
|||
}
|
||||
|
||||
//@note: following part is in alphabetic order
|
||||
defensive_position const& best_defensive_position(const map_location& unit,
|
||||
const defensive_position& best_defensive_position(const map_location& unit,
|
||||
const move_map& dstsrc, const move_map& srcdst, const move_map& enemy_dstsrc) const override
|
||||
{
|
||||
return target_->best_defensive_position(unit,dstsrc,srcdst,enemy_dstsrc);
|
||||
|
@ -1308,7 +1308,7 @@ public:
|
|||
|
||||
|
||||
//@note: following functions are in alphabetic order
|
||||
defensive_position const& best_defensive_position(const map_location& unit,
|
||||
const defensive_position& best_defensive_position(const map_location& unit,
|
||||
const move_map& dstsrc, const move_map& srcdst, const move_map& enemy_dstsrc) const override;
|
||||
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ void arrow::show()
|
|||
SCREEN->add_arrow(*this);
|
||||
}
|
||||
|
||||
void arrow::set_path(arrow_path_t const& path)
|
||||
void arrow::set_path(const arrow_path_t& path)
|
||||
{
|
||||
if (valid_path(path))
|
||||
{
|
||||
|
@ -120,23 +120,23 @@ void arrow::set_style(const std::string& style)
|
|||
}
|
||||
}
|
||||
|
||||
arrow_path_t const& arrow::get_path() const
|
||||
const arrow_path_t& arrow::get_path() const
|
||||
{
|
||||
return path_;
|
||||
}
|
||||
|
||||
arrow_path_t const& arrow::get_previous_path() const
|
||||
const arrow_path_t& arrow::get_previous_path() const
|
||||
{
|
||||
return previous_path_;
|
||||
}
|
||||
|
||||
bool arrow::path_contains(map_location const& hex) const
|
||||
bool arrow::path_contains(const map_location& hex) const
|
||||
{
|
||||
bool contains = symbols_map_.find(hex) != symbols_map_.end();
|
||||
return contains;
|
||||
}
|
||||
|
||||
void arrow::draw_hex(map_location const& hex)
|
||||
void arrow::draw_hex(const map_location& hex)
|
||||
{
|
||||
if(path_contains(hex))
|
||||
{
|
||||
|
@ -145,7 +145,7 @@ void arrow::draw_hex(map_location const& hex)
|
|||
}
|
||||
}
|
||||
|
||||
bool arrow::valid_path(arrow_path_t const& path)
|
||||
bool arrow::valid_path(const arrow_path_t& path)
|
||||
{
|
||||
if (path.size() >= 2)
|
||||
return true;
|
||||
|
@ -283,11 +283,11 @@ void arrow::update_symbols()
|
|||
}
|
||||
}
|
||||
|
||||
void arrow::invalidate_arrow_path(arrow_path_t const& path)
|
||||
void arrow::invalidate_arrow_path(const arrow_path_t& path)
|
||||
{
|
||||
if(!SCREEN) return;
|
||||
|
||||
for (map_location const& loc : path)
|
||||
for (const map_location& loc : path)
|
||||
{
|
||||
SCREEN->invalidate(loc);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
void hide();
|
||||
void show();
|
||||
|
||||
virtual void set_path(arrow_path_t const& path);
|
||||
virtual void set_path(const arrow_path_t& path);
|
||||
|
||||
///invalidates and clears the present path, forgets the previous path, clears the symbols map
|
||||
virtual void reset();
|
||||
|
@ -68,17 +68,17 @@ public:
|
|||
static const std::string STYLE_FOCUS;
|
||||
static const std::string STYLE_FOCUS_INVALID;
|
||||
|
||||
arrow_path_t const& get_path() const;
|
||||
arrow_path_t const& get_previous_path() const;
|
||||
const arrow_path_t& get_path() const;
|
||||
const arrow_path_t& get_previous_path() const;
|
||||
|
||||
bool path_contains(map_location const& hex) const;
|
||||
bool path_contains(const map_location& hex) const;
|
||||
|
||||
virtual void draw_hex(map_location const& hex);
|
||||
virtual void draw_hex(const map_location& hex);
|
||||
|
||||
/// Checks that the path is not of length 0 or 1
|
||||
static bool valid_path(arrow_path_t const& path);
|
||||
static bool valid_path(const arrow_path_t& path);
|
||||
/// Invalidates every hex along the given path
|
||||
static void invalidate_arrow_path(arrow_path_t const& path);
|
||||
static void invalidate_arrow_path(const arrow_path_t& path);
|
||||
|
||||
virtual void notify_arrow_changed();
|
||||
|
||||
|
|
|
@ -256,13 +256,13 @@ public:
|
|||
// Constructor stores the default value.
|
||||
attribute_numeric_visitor(T def) : def_(def) {}
|
||||
|
||||
T operator()(boost::blank const &) const { return def_; }
|
||||
T operator()(const boost::blank&) const { return def_; }
|
||||
T operator()(bool) const { return def_; }
|
||||
T operator()(int i) const { return static_cast<T>(i); }
|
||||
T operator()(unsigned long long u) const { return static_cast<T>(u); }
|
||||
T operator()(double d) const { return static_cast<T>(d); }
|
||||
T operator()(const std::string& s) const { return lexical_cast_default<T>(s, def_); }
|
||||
T operator()(t_string const &) const { return def_; }
|
||||
T operator()(const t_string&) const { return def_; }
|
||||
|
||||
private:
|
||||
const T def_;
|
||||
|
@ -314,7 +314,7 @@ public:
|
|||
std::string operator()(unsigned long long u) const { return lexical_cast<std::string>(u); }
|
||||
std::string operator()(double d) const { return lexical_cast<std::string>(d); }
|
||||
std::string operator()(const std::string& s) const { return s; }
|
||||
std::string operator()(t_string const &s) const { return s.str(); }
|
||||
std::string operator()(const t_string& s) const { return s.str(); }
|
||||
};
|
||||
|
||||
std::string config_attribute_value::str(const std::string& fallback) const
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
return sdl::point_in_rect(x, y, location());
|
||||
}
|
||||
|
||||
void mouse_up(SDL_MouseButtonEvent const &e)
|
||||
void mouse_up(const SDL_MouseButtonEvent& e)
|
||||
{
|
||||
if (!(hit(e.x, e.y)))
|
||||
return;
|
||||
|
|
|
@ -222,7 +222,7 @@ void tristate_button::draw_contents() {
|
|||
image = base;
|
||||
|
||||
const int image_w = image->w;
|
||||
SDL_Rect const &loc = location();
|
||||
const SDL_Rect& loc = location();
|
||||
SDL_Rect clipArea = loc;
|
||||
const int texty = loc.y + loc.h / 2 - textRect_.h / 2 + offset;
|
||||
int textx;
|
||||
|
@ -266,7 +266,7 @@ bool tristate_button::hit(int x, int y) const {
|
|||
return sdl::point_in_rect(x, y, location());
|
||||
}
|
||||
|
||||
void tristate_button::mouse_motion(SDL_MouseMotionEvent const &event) {
|
||||
void tristate_button::mouse_motion(const SDL_MouseMotionEvent& event) {
|
||||
|
||||
if (hit(event.x, event.y))
|
||||
{ // the cursor is over the widget
|
||||
|
@ -321,7 +321,7 @@ void tristate_button::mouse_motion(SDL_MouseMotionEvent const &event) {
|
|||
}
|
||||
}
|
||||
|
||||
void tristate_button::mouse_down(SDL_MouseButtonEvent const &event) {
|
||||
void tristate_button::mouse_down(const SDL_MouseButtonEvent& event) {
|
||||
|
||||
if (!hit(event.x, event.y))
|
||||
return;
|
||||
|
@ -347,7 +347,7 @@ void tristate_button::release() {
|
|||
draw_contents();
|
||||
}
|
||||
|
||||
void tristate_button::mouse_up(SDL_MouseButtonEvent const &event) {
|
||||
void tristate_button::mouse_up(const SDL_MouseButtonEvent& event) {
|
||||
|
||||
if (!(hit(event.x, event.y)))
|
||||
return;
|
||||
|
|
|
@ -50,7 +50,7 @@ fake_unit_ptr & fake_unit_ptr::operator=(fake_unit_ptr other) {
|
|||
* The overriding function can be almost the same, except "new (this)" should
|
||||
* be followed by the derived class instead of "fake_unit(a)".
|
||||
*/
|
||||
/*fake_unit & fake_unit::operator=(unit const & a)
|
||||
/*fake_unit & fake_unit::operator=(const unit& a)
|
||||
{
|
||||
if ( this != &a ) {
|
||||
fake_unit_manager * mgr = my_manager_;
|
||||
|
|
|
@ -61,8 +61,8 @@ struct text_chunk
|
|||
{
|
||||
}
|
||||
|
||||
bool operator==(text_chunk const & t) const { return subset == t.subset && text == t.text; }
|
||||
bool operator!=(text_chunk const & t) const { return !operator==(t); }
|
||||
bool operator==(const text_chunk& t) const { return subset == t.subset && text == t.text; }
|
||||
bool operator!=(const text_chunk& t) const { return !operator==(t); }
|
||||
|
||||
subset_id subset;
|
||||
std::string text;
|
||||
|
|
|
@ -342,7 +342,7 @@ SDL_Rect draw_text_line(surface& gui_surface, const SDL_Rect& area, int size,
|
|||
{
|
||||
size = preferences::font_scaled(size);
|
||||
if (gui_surface.null()) {
|
||||
text_surface const &u = text_cache::find(text_surface(text, size, color, style));
|
||||
const text_surface& u = text_cache::find(text_surface(text, size, color, style));
|
||||
return sdl::create_rect(0, 0, u.width(), u.height());
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ void text_cache::resize(unsigned int size)
|
|||
max_size_ = size;
|
||||
}
|
||||
|
||||
text_surface &text_cache::find(text_surface const &t)
|
||||
text_surface &text_cache::find(const text_surface& t)
|
||||
{
|
||||
static size_t lookup_ = 0, hit_ = 0;
|
||||
text_list::iterator it_bgn = cache_.begin(), it_end = cache_.end();
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace font {
|
|||
class text_cache
|
||||
{
|
||||
public:
|
||||
static text_surface &find(text_surface const &t);
|
||||
static text_surface &find(const text_surface& t);
|
||||
static void resize(unsigned int size);
|
||||
private:
|
||||
typedef std::list< text_surface > text_list;
|
||||
|
|
|
@ -134,7 +134,7 @@ void text_surface::measure() const
|
|||
w_ = 0;
|
||||
h_ = 0;
|
||||
|
||||
for(text_chunk const &chunk : chunks_)
|
||||
for(const text_chunk& chunk : chunks_)
|
||||
{
|
||||
TTF_Font* ttfont = sdl_ttf::get_font(font_id(chunk.subset, font_size_, style_));
|
||||
if(ttfont == nullptr) {
|
||||
|
@ -168,7 +168,7 @@ size_t text_surface::height() const
|
|||
return h_;
|
||||
}
|
||||
|
||||
std::vector<surface> const &text_surface::get_surfaces() const
|
||||
const std::vector<surface>& text_surface::get_surfaces() const
|
||||
{
|
||||
if(initialized_)
|
||||
return surfs_;
|
||||
|
@ -180,7 +180,7 @@ std::vector<surface> const &text_surface::get_surfaces() const
|
|||
if(width() > max_text_line_width)
|
||||
return surfs_;
|
||||
|
||||
for(text_chunk const &chunk : chunks_)
|
||||
for(const text_chunk& chunk : chunks_)
|
||||
{
|
||||
TTF_Font* ttfont = sdl_ttf::get_font(font_id(chunk.subset, font_size_, style_));
|
||||
|
||||
|
@ -192,7 +192,7 @@ std::vector<surface> const &text_surface::get_surfaces() const
|
|||
return surfs_;
|
||||
}
|
||||
|
||||
bool text_surface::operator==(text_surface const &t) const {
|
||||
bool text_surface::operator==(const text_surface& t) const {
|
||||
return hash_ == t.hash_ && font_size_ == t.font_size_
|
||||
&& color_ == t.color_ && style_ == t.style_ && str_ == t.str_;
|
||||
}
|
||||
|
|
|
@ -42,10 +42,10 @@ public:
|
|||
#ifdef HAVE_FRIBIDI
|
||||
bool is_rtl() const { return is_rtl_; } // Right-To-Left alignment
|
||||
#endif
|
||||
std::vector<surface> const & get_surfaces() const;
|
||||
const std::vector<surface>& get_surfaces() const;
|
||||
|
||||
bool operator==(text_surface const &t) const;
|
||||
bool operator!=(text_surface const &t) const { return !operator==(t); }
|
||||
bool operator==(const text_surface& t) const;
|
||||
bool operator!=(const text_surface& t) const { return !operator==(t); }
|
||||
private:
|
||||
int hash_;
|
||||
int font_size_;
|
||||
|
|
|
@ -144,8 +144,8 @@ namespace {
|
|||
* before running this function.
|
||||
*/
|
||||
template <typename MapT>
|
||||
typename MapT::mapped_type const& const_at(typename MapT::key_type const& key,
|
||||
MapT const& map)
|
||||
typename const MapT::mapped_type& const_at(typename const MapT::key_type& key,
|
||||
const MapT& map)
|
||||
{
|
||||
typename MapT::const_iterator it = map.find(key);
|
||||
if(it == map.end()) {
|
||||
|
|
|
@ -67,7 +67,7 @@ REGISTER_DIALOG(simple_item_selector)
|
|||
|
||||
simple_item_selector::simple_item_selector(const std::string& title,
|
||||
const std::string& message,
|
||||
list_type const& items,
|
||||
const list_type& items,
|
||||
bool title_uses_markup,
|
||||
bool message_uses_markup)
|
||||
: index_(-1)
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
|
||||
simple_item_selector(const std::string& title,
|
||||
const std::string& message,
|
||||
list_type const& items,
|
||||
const list_type& items,
|
||||
bool title_uses_markup = false,
|
||||
bool message_uses_markup = false);
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ void help_browser::adjust_layout()
|
|||
set_dirty(true);
|
||||
}
|
||||
|
||||
void help_browser::update_location(SDL_Rect const &)
|
||||
void help_browser::update_location(const SDL_Rect&)
|
||||
{
|
||||
adjust_layout();
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
void show_topic(const std::string &topic_id);
|
||||
|
||||
protected:
|
||||
virtual void update_location(SDL_Rect const &rect);
|
||||
virtual void update_location(const SDL_Rect& rect);
|
||||
virtual void process_event();
|
||||
virtual void handle_event(const SDL_Event &event);
|
||||
|
||||
|
|
|
@ -252,7 +252,7 @@ section parse_config(const config *cfg)
|
|||
{
|
||||
section sec;
|
||||
if (cfg != nullptr) {
|
||||
config const &toplevel_cfg = cfg->child("toplevel");
|
||||
const config& toplevel_cfg = cfg->child("toplevel");
|
||||
parse_config_internal(cfg, toplevel_cfg ? &toplevel_cfg : nullptr, sec);
|
||||
}
|
||||
return sec;
|
||||
|
@ -332,7 +332,7 @@ topic_text::~topic_text()
|
|||
delete generator_;
|
||||
}
|
||||
|
||||
topic_text::topic_text(topic_text const &t): parsed_text_(t.parsed_text_), generator_(t.generator_)
|
||||
topic_text::topic_text(const topic_text& t): parsed_text_(t.parsed_text_), generator_(t.generator_)
|
||||
{
|
||||
if (generator_)
|
||||
++generator_->count;
|
||||
|
@ -510,10 +510,10 @@ std::vector<topic> generate_ability_topics(const bool sort_generated)
|
|||
desc_vecs[1] = &type.adv_ability_tooltips();
|
||||
|
||||
for(int i=0; i<2; ++i) {
|
||||
std::vector<t_string> const& abil_vec = *abil_vecs[i];
|
||||
std::vector<t_string> const& desc_vec = *desc_vecs[i];
|
||||
const std::vector<t_string>& abil_vec = *abil_vecs[i];
|
||||
const std::vector<t_string>& desc_vec = *desc_vecs[i];
|
||||
for(size_t j=0; j < abil_vec.size(); ++j) {
|
||||
t_string const& abil_name = abil_vec[j];
|
||||
const t_string& abil_name = abil_vec[j];
|
||||
const std::string abil_desc =
|
||||
j >= desc_vec.size() ? "" : desc_vec[j].str();
|
||||
|
||||
|
@ -1030,7 +1030,7 @@ std::string generate_about_text()
|
|||
|
||||
std::string generate_contents_links(const std::string& section_name, config const *help_cfg)
|
||||
{
|
||||
config const §ion_cfg = help_cfg->find_child("section", "id", section_name);
|
||||
const config& section_cfg = help_cfg->find_child("section", "id", section_name);
|
||||
if (!section_cfg) {
|
||||
return std::string();
|
||||
}
|
||||
|
@ -1046,7 +1046,7 @@ std::string generate_contents_links(const std::string& section_name, config cons
|
|||
std::vector<std::string>::iterator t;
|
||||
// Find all topics in this section.
|
||||
for (t = topics.begin(); t != topics.end(); ++t) {
|
||||
if (config const &topic_cfg = help_cfg->find_child("topic", "id", *t)) {
|
||||
if (const config& topic_cfg = help_cfg->find_child("topic", "id", *t)) {
|
||||
std::string id = topic_cfg["id"];
|
||||
if (is_visible_id(id))
|
||||
topics_links.emplace_back(topic_cfg["title"], id);
|
||||
|
|
|
@ -101,7 +101,7 @@ public:
|
|||
{
|
||||
}
|
||||
topic_text &operator=(topic_generator *g);
|
||||
topic_text(topic_text const &t);
|
||||
topic_text(const topic_text& t);
|
||||
|
||||
const std::vector<std::string>& parsed_text() const;
|
||||
};
|
||||
|
|
|
@ -29,7 +29,7 @@ class CVideo; // lines 56-56
|
|||
|
||||
namespace help {
|
||||
|
||||
help_menu::help_menu(CVideo &video, section const &toplevel, int max_height) :
|
||||
help_menu::help_menu(CVideo &video, const section& toplevel, int max_height) :
|
||||
gui::menu(video, empty_string_vector, true, max_height, -1, nullptr, &gui::menu::bluebg_style),
|
||||
visible_items_(),
|
||||
toplevel_(toplevel),
|
||||
|
|
|
@ -48,7 +48,7 @@ help_text_area::help_text_area(CVideo &video, const section &toplevel) :
|
|||
set_scroll_rate(40);
|
||||
}
|
||||
|
||||
void help_text_area::set_inner_location(SDL_Rect const &rect)
|
||||
void help_text_area::set_inner_location(const SDL_Rect& rect)
|
||||
{
|
||||
bg_register(rect);
|
||||
if (shown_topic_)
|
||||
|
@ -113,7 +113,7 @@ void help_text_area::set_items()
|
|||
down_one_line();
|
||||
}
|
||||
// Parse and add the text.
|
||||
std::vector<std::string> const &parsed_items = shown_topic_->text.parsed_text();
|
||||
const std::vector<std::string>& parsed_items = shown_topic_->text.parsed_text();
|
||||
std::vector<std::string>::const_iterator it;
|
||||
for (it = parsed_items.begin(); it != parsed_items.end(); ++it) {
|
||||
if (!(*it).empty() && (*it)[0] == '[') {
|
||||
|
@ -527,7 +527,7 @@ int help_text_area::get_remaining_width()
|
|||
|
||||
void help_text_area::draw_contents()
|
||||
{
|
||||
SDL_Rect const &loc = inner_location();
|
||||
const SDL_Rect& loc = inner_location();
|
||||
bg_restore();
|
||||
surface& screen = video().getSurface();
|
||||
clip_rect_setter clip_rect_set(screen, &loc);
|
||||
|
|
|
@ -648,7 +648,7 @@ REGISTER_MOD_PARSER(TC, args)
|
|||
// This side is not initialized; use default "n"
|
||||
try {
|
||||
team_color = std::to_string(side_n);
|
||||
} catch(bad_lexical_cast const&) {
|
||||
} catch(const bad_lexical_cast&) {
|
||||
ERR_DP << "bad things happen" << std::endl;
|
||||
|
||||
return nullptr;
|
||||
|
@ -672,7 +672,7 @@ REGISTER_MOD_PARSER(TC, args)
|
|||
const std::vector<color_t>& old_color = game_config::tc_info(params[1]);
|
||||
|
||||
rc_map = recolor_range(new_color,old_color);
|
||||
} catch(config::error const& e) {
|
||||
} catch(const config::error& e) {
|
||||
ERR_DP << "caught config::error while processing TC: "
|
||||
<< e.message
|
||||
<< '\n'
|
||||
|
@ -760,7 +760,7 @@ REGISTER_MOD_PARSER(FL, args)
|
|||
// Rotations
|
||||
REGISTER_MOD_PARSER(ROTATE, args)
|
||||
{
|
||||
std::vector<std::string> const& slice_params = utils::split(args, ',', utils::STRIP_SPACES);
|
||||
const std::vector<std::string>& slice_params = utils::split(args, ',', utils::STRIP_SPACES);
|
||||
const size_t s = slice_params.size();
|
||||
|
||||
switch(s) {
|
||||
|
@ -972,7 +972,7 @@ REGISTER_MOD_PARSER(BLEND, args)
|
|||
// Crop/slice
|
||||
REGISTER_MOD_PARSER(CROP, args)
|
||||
{
|
||||
std::vector<std::string> const& slice_params = utils::split(args, ',', utils::STRIP_SPACES);
|
||||
const std::vector<std::string>& slice_params = utils::split(args, ',', utils::STRIP_SPACES);
|
||||
const size_t s = slice_params.size();
|
||||
|
||||
if(s == 0 || (s == 1 && slice_params[0].empty())) {
|
||||
|
@ -1087,7 +1087,7 @@ REGISTER_MOD_PARSER(L, args)
|
|||
// Scale
|
||||
REGISTER_MOD_PARSER(SCALE, args)
|
||||
{
|
||||
std::vector<std::string> const& scale_params = utils::split(args, ',', utils::STRIP_SPACES);
|
||||
const std::vector<std::string>& scale_params = utils::split(args, ',', utils::STRIP_SPACES);
|
||||
const size_t s = scale_params.size();
|
||||
|
||||
if(s == 0 || (s == 1 && scale_params[0].empty())) {
|
||||
|
@ -1108,7 +1108,7 @@ REGISTER_MOD_PARSER(SCALE, args)
|
|||
|
||||
REGISTER_MOD_PARSER(SCALE_SHARP, args)
|
||||
{
|
||||
std::vector<std::string> const& scale_params = utils::split(args, ',', utils::STRIP_SPACES);
|
||||
const std::vector<std::string>& scale_params = utils::split(args, ',', utils::STRIP_SPACES);
|
||||
const size_t s = scale_params.size();
|
||||
|
||||
if(s == 0 || (s == 1 && scale_params[0].empty())) {
|
||||
|
@ -1129,7 +1129,7 @@ REGISTER_MOD_PARSER(SCALE_SHARP, args)
|
|||
|
||||
REGISTER_MOD_PARSER(SCALE_INTO, args)
|
||||
{
|
||||
std::vector<std::string> const& scale_params = utils::split(args, ',', utils::STRIP_SPACES);
|
||||
const std::vector<std::string>& scale_params = utils::split(args, ',', utils::STRIP_SPACES);
|
||||
const size_t s = scale_params.size();
|
||||
|
||||
if(s == 0 || (s == 1 && scale_params[0].empty())) {
|
||||
|
@ -1150,7 +1150,7 @@ REGISTER_MOD_PARSER(SCALE_INTO, args)
|
|||
|
||||
REGISTER_MOD_PARSER(SCALE_INTO_SHARP, args)
|
||||
{
|
||||
std::vector<std::string> const& scale_params = utils::split(args, ',', utils::STRIP_SPACES);
|
||||
const std::vector<std::string>& scale_params = utils::split(args, ',', utils::STRIP_SPACES);
|
||||
const size_t s = scale_params.size();
|
||||
|
||||
if(s == 0 || (s == 1 && scale_params[0].empty())) {
|
||||
|
|
|
@ -580,7 +580,7 @@ private:
|
|||
*/
|
||||
struct background_modification : modification
|
||||
{
|
||||
background_modification(color_t const &c): color_(c) {}
|
||||
background_modification(const color_t& c): color_(c) {}
|
||||
virtual surface operator()(const surface &src) const;
|
||||
|
||||
const color_t& get_color() const
|
||||
|
|
|
@ -207,7 +207,7 @@ static void print_precise_timestamp(std::ostream & out) NOEXCEPT
|
|||
} catch(...) {}
|
||||
}
|
||||
|
||||
std::ostream &logger::operator()(log_domain const &domain, bool show_names, bool do_indent) const
|
||||
std::ostream &logger::operator()(const log_domain& domain, bool show_names, bool do_indent) const
|
||||
{
|
||||
if (severity_ > domain.domain_->second) {
|
||||
return null_ostream;
|
||||
|
@ -237,7 +237,7 @@ std::ostream &logger::operator()(log_domain const &domain, bool show_names, bool
|
|||
}
|
||||
}
|
||||
|
||||
void scope_logger::do_log_entry(log_domain const &domain, const std::string& str) NOEXCEPT
|
||||
void scope_logger::do_log_entry(const log_domain& domain, const std::string& str) NOEXCEPT
|
||||
{
|
||||
output_ = &debug()(domain, false, true);
|
||||
str_ = str;
|
||||
|
|
10
src/log.hpp
10
src/log.hpp
|
@ -117,10 +117,10 @@ class logger {
|
|||
int severity_;
|
||||
public:
|
||||
logger(char const *name, int severity): name_(name), severity_(severity) {}
|
||||
std::ostream &operator()(log_domain const &domain,
|
||||
std::ostream &operator()(const log_domain& domain,
|
||||
bool show_names = true, bool do_indent = false) const;
|
||||
|
||||
bool dont_log(log_domain const &domain) const
|
||||
bool dont_log(const log_domain& domain) const
|
||||
{
|
||||
return severity_ > domain.domain_->second;
|
||||
}
|
||||
|
@ -150,12 +150,12 @@ class scope_logger
|
|||
std::ostream *output_;
|
||||
std::string str_;
|
||||
public:
|
||||
scope_logger(log_domain const &domain, const char* str) :
|
||||
scope_logger(const log_domain& domain, const char* str) :
|
||||
output_(nullptr)
|
||||
{
|
||||
if (!debug().dont_log(domain)) do_log_entry(domain, str);
|
||||
}
|
||||
scope_logger(log_domain const &domain, const std::string& str) :
|
||||
scope_logger(const log_domain& domain, const std::string& str) :
|
||||
output_(nullptr)
|
||||
{
|
||||
if (!debug().dont_log(domain)) do_log_entry(domain, str);
|
||||
|
@ -166,7 +166,7 @@ public:
|
|||
}
|
||||
void do_indent() const;
|
||||
private:
|
||||
void do_log_entry(log_domain const &domain, const std::string& str) NOEXCEPT;
|
||||
void do_log_entry(const log_domain& domain, const std::string& str) NOEXCEPT;
|
||||
void do_log_exit() NOEXCEPT;
|
||||
};
|
||||
|
||||
|
|
|
@ -32,11 +32,11 @@
|
|||
static lg::log_domain log_config("config");
|
||||
#define ERR_CF LOG_STREAM(err, log_config)
|
||||
|
||||
std::ostream &operator<<(std::ostream &s, map_location const &l) {
|
||||
std::ostream &operator<<(std::ostream &s, const map_location& l) {
|
||||
s << (l.wml_x()) << ',' << (l.wml_y());
|
||||
return s;
|
||||
}
|
||||
std::ostream &operator<<(std::ostream &s, std::vector<map_location> const &v) {
|
||||
std::ostream &operator<<(std::ostream &s, const std::vector<map_location>& v) {
|
||||
std::vector<map_location>::const_iterator i = v.begin();
|
||||
for(; i!= v.end(); ++i) {
|
||||
s << "(" << *i << ") ";
|
||||
|
@ -55,7 +55,7 @@ const std::vector<map_location::DIRECTION> & map_location::default_dirs() {
|
|||
return dirs;
|
||||
}
|
||||
|
||||
std::size_t hash_value(map_location const & a){
|
||||
std::size_t hash_value(const map_location& a){
|
||||
std::hash<size_t> h;
|
||||
return h( (static_cast<uint32_t>(a.x) << 16) ^ static_cast<uint32_t>(a.y) );
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ struct map_location {
|
|||
// Rotates the map_location clockwise in 60 degree increments around a center point. Negative numbers of steps are permitted.
|
||||
map_location rotate_right_around_center(const map_location & center, int k) const;
|
||||
|
||||
friend std::size_t hash_value(map_location const &a);
|
||||
friend std::size_t hash_value(const map_location& a);
|
||||
|
||||
int wml_x() const { return x + 1; }
|
||||
int wml_y() const { return y + 1; }
|
||||
|
@ -159,9 +159,9 @@ void read_locations(const config& cfg, std::vector<map_location>& locs);
|
|||
void write_locations(const std::vector<map_location>& locs, config& cfg);
|
||||
|
||||
/** Dumps a position on a stream, for debug purposes. */
|
||||
std::ostream &operator<<(std::ostream &s, map_location const &l);
|
||||
std::ostream &operator<<(std::ostream &s, const map_location& l);
|
||||
/** Dumps a vector of positions on a stream, for debug purposes. */
|
||||
std::ostream &operator<<(std::ostream &s, std::vector<map_location> const &v);
|
||||
std::ostream &operator<<(std::ostream &s, const std::vector<map_location>& v);
|
||||
|
||||
namespace std {
|
||||
template<>
|
||||
|
|
|
@ -416,7 +416,7 @@ map_location mouse_handler::current_unit_attacks_from(const map_location& loc) c
|
|||
|
||||
// Check the unit TARGET of the attack
|
||||
|
||||
team const& viewer = viewing_team();
|
||||
const team& viewer = viewing_team();
|
||||
|
||||
// Check that there's a unit at the target location
|
||||
const unit_map::const_iterator target_unit = find_unit(loc);
|
||||
|
|
|
@ -133,8 +133,8 @@ map_location find_vacant_castle(const unit & leader)
|
|||
*
|
||||
* @return true iff a visible enemy exerts zone of control over loc.
|
||||
*/
|
||||
bool enemy_zoc(team const ¤t_team, map_location const &loc,
|
||||
team const &viewing_team, bool see_all)
|
||||
bool enemy_zoc(const team& current_team, const map_location& loc,
|
||||
const team& viewing_team, bool see_all)
|
||||
{
|
||||
// Check the adjacent tiles.
|
||||
map_location locs[6];
|
||||
|
@ -540,7 +540,7 @@ paths::paths(const unit& u, bool force_ignore_zoc,
|
|||
int additional_turns, bool see_all, bool ignore_units)
|
||||
: destinations()
|
||||
{
|
||||
std::vector<team> const &teams = resources::gameboard->teams();
|
||||
const std::vector<team>& teams = resources::gameboard->teams();
|
||||
if (u.side() < 1 || u.side() > int(teams.size())) {
|
||||
return;
|
||||
}
|
||||
|
@ -572,7 +572,7 @@ paths::~paths()
|
|||
* @param loc The location from which the viewing occurs
|
||||
* (does not have to be the unit's location).
|
||||
*/
|
||||
vision_path::vision_path(const unit& viewer, map_location const &loc,
|
||||
vision_path::vision_path(const unit& viewer, const map_location& loc,
|
||||
const std::map<map_location, int>& jamming_map)
|
||||
: paths(), edges()
|
||||
{
|
||||
|
@ -580,7 +580,7 @@ vision_path::vision_path(const unit& viewer, map_location const &loc,
|
|||
|
||||
// The three nullptr parameters indicate (in order):
|
||||
// ignore units, ignore ZoC (no effect), and don't build a cost_map.
|
||||
team const& viewing_team = resources::gameboard->teams()[resources::screen->viewing_team()];
|
||||
const team& viewing_team = resources::gameboard->teams()[resources::screen->viewing_team()];
|
||||
find_routes(loc, viewer.movement_type().get_vision(),
|
||||
viewer.get_state(unit::STATE_SLOWED), sight_range, sight_range,
|
||||
0, destinations, &edges, &viewer, nullptr, nullptr, &viewing_team, &jamming_map, nullptr, true);
|
||||
|
@ -604,7 +604,7 @@ vision_path::vision_path(const movetype::terrain_costs & view_costs, bool slowed
|
|||
{
|
||||
// The three nullptr parameters indicate (in order):
|
||||
// ignore units, ignore ZoC (no effect), and don't build a cost_map.
|
||||
team const& viewing_team = resources::gameboard->teams()[resources::screen->viewing_team()];
|
||||
const team& viewing_team = resources::gameboard->teams()[resources::screen->viewing_team()];
|
||||
const unit_map::const_iterator u = resources::gameboard->units().find(loc);
|
||||
find_routes(loc, view_costs, slowed, sight_range, sight_range, 0,
|
||||
destinations, &edges, u.valid() ? &*u : nullptr, nullptr, nullptr, &viewing_team, &jamming_map, nullptr, true);
|
||||
|
@ -625,7 +625,7 @@ vision_path::~vision_path()
|
|||
* @param loc The location from which the jamming occurs
|
||||
* (does not have to be the unit's location).
|
||||
*/
|
||||
jamming_path::jamming_path(const unit& jammer, map_location const &loc)
|
||||
jamming_path::jamming_path(const unit& jammer, const map_location& loc)
|
||||
: paths()
|
||||
{
|
||||
const int jamming_range = jammer.jamming();
|
||||
|
@ -651,7 +651,7 @@ marked_route mark_route(const plain_route &rt)
|
|||
|
||||
unit_map::const_iterator it = resources::gameboard->units().find(rt.steps.front());
|
||||
if (it == resources::gameboard->units().end()) return marked_route();
|
||||
unit const& u = *it;
|
||||
const unit& u = *it;
|
||||
|
||||
int turns = 0;
|
||||
int movement = u.movement_left();
|
||||
|
@ -667,7 +667,7 @@ marked_route mark_route(const plain_route &rt)
|
|||
assert(last_step || resources::gameboard->map().on_board(*(i+1)));
|
||||
const int move_cost = last_step ? 0 : u.movement_cost((resources::gameboard->map())[*(i+1)]);
|
||||
|
||||
team const& viewing_team = resources::gameboard->teams()[resources::screen->viewing_team()];
|
||||
const team& viewing_team = resources::gameboard->teams()[resources::screen->viewing_team()];
|
||||
|
||||
if (last_step || zoc || move_cost > movement) {
|
||||
// check if we stop an a village and so maybe capture it
|
||||
|
@ -704,8 +704,8 @@ marked_route mark_route(const plain_route &rt)
|
|||
return res;
|
||||
}
|
||||
|
||||
shortest_path_calculator::shortest_path_calculator(unit const &u, team const &t,
|
||||
std::vector<team> const &teams, gamemap const &map,
|
||||
shortest_path_calculator::shortest_path_calculator(const unit& u, const team& t,
|
||||
const std::vector<team>& teams, const gamemap& map,
|
||||
bool ignore_unit, bool ignore_defense, bool see_all)
|
||||
: unit_(u), viewing_team_(t), teams_(teams), map_(map),
|
||||
movement_left_(unit_.movement_left()),
|
||||
|
@ -795,7 +795,7 @@ double shortest_path_calculator::cost(const map_location& loc, const double so_f
|
|||
return move_cost + (defense_subcost + other_unit_subcost) / 10000.0;
|
||||
}
|
||||
|
||||
move_type_path_calculator::move_type_path_calculator(const movetype& mt, int movement_left, int total_movement, team const &t, gamemap const &map)
|
||||
move_type_path_calculator::move_type_path_calculator(const movetype& mt, int movement_left, int total_movement, const team& t, const gamemap& map)
|
||||
: movement_type_(mt), movement_left_(movement_left),
|
||||
total_movement_(total_movement), viewing_team_(t), map_(map)
|
||||
{}
|
||||
|
@ -892,7 +892,7 @@ full_cost_map::full_cost_map(bool force_ignore_zoc,
|
|||
*/
|
||||
void full_cost_map::add_unit(const unit& u, bool use_max_moves)
|
||||
{
|
||||
std::vector<team> const &teams = resources::gameboard->teams();
|
||||
const std::vector<team>& teams = resources::gameboard->teams();
|
||||
if (u.side() < 1 || u.side() > int(teams.size())) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -49,8 +49,8 @@ map_location find_vacant_tile(const map_location& loc,
|
|||
map_location find_vacant_castle(const unit & leader);
|
||||
|
||||
/** Determines if a given location is in an enemy zone of control. */
|
||||
bool enemy_zoc(team const ¤t_team, map_location const &loc,
|
||||
team const &viewing_team, bool see_all=false);
|
||||
bool enemy_zoc(const team& current_team, const map_location& loc,
|
||||
const team& viewing_team, bool see_all=false);
|
||||
|
||||
|
||||
struct cost_calculator
|
||||
|
@ -105,7 +105,7 @@ struct paths
|
|||
struct vision_path : public paths
|
||||
{
|
||||
/// Construct a list of seen hexes for a unit.
|
||||
vision_path(const unit& viewer, map_location const &loc,
|
||||
vision_path(const unit& viewer, const map_location& loc,
|
||||
const std::map<map_location, int>& jamming_map);
|
||||
vision_path(const movetype::terrain_costs & view_costs, bool slowed,
|
||||
int sight_range, const map_location & loc,
|
||||
|
@ -122,7 +122,7 @@ struct vision_path : public paths
|
|||
struct jamming_path : public paths
|
||||
{
|
||||
/// Construct a list of jammed hexes for a unit.
|
||||
jamming_path(const unit& jammer, map_location const &loc);
|
||||
jamming_path(const unit& jammer, const map_location& loc);
|
||||
virtual ~jamming_path();
|
||||
};
|
||||
|
||||
|
@ -189,7 +189,7 @@ struct marked_route
|
|||
mark_map marks;
|
||||
};
|
||||
|
||||
plain_route a_star_search(map_location const &src, map_location const &dst,
|
||||
plain_route a_star_search(const map_location& src, const map_location& dst,
|
||||
double stop_at, const cost_calculator& costCalculator,
|
||||
const size_t parWidth, const size_t parHeight,
|
||||
const teleport_map* teleports = nullptr, bool border = false);
|
||||
|
@ -209,10 +209,10 @@ struct shortest_path_calculator : cost_calculator
|
|||
virtual double cost(const map_location& loc, const double so_far) const;
|
||||
|
||||
private:
|
||||
unit const &unit_;
|
||||
team const &viewing_team_;
|
||||
std::vector<team> const &teams_;
|
||||
gamemap const &map_;
|
||||
const unit& unit_;
|
||||
const team& viewing_team_;
|
||||
const std::vector<team>& teams_;
|
||||
const gamemap& map_;
|
||||
const int movement_left_;
|
||||
const int total_movement_;
|
||||
bool const ignore_unit_;
|
||||
|
@ -229,8 +229,8 @@ private:
|
|||
const movetype &movement_type_;
|
||||
const int movement_left_;
|
||||
const int total_movement_;
|
||||
team const &viewing_team_;
|
||||
gamemap const &map_;
|
||||
const team& viewing_team_;
|
||||
const gamemap& map_;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -243,8 +243,8 @@ struct emergency_path_calculator : cost_calculator
|
|||
virtual double cost(const map_location& loc, const double so_far) const;
|
||||
|
||||
private:
|
||||
unit const &unit_;
|
||||
gamemap const &map_;
|
||||
const unit& unit_;
|
||||
const gamemap& map_;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -233,9 +233,9 @@ void get_tiles_radius(const gamemap& map, const std::vector<map_location>& locs,
|
|||
* locs by a chain of at most @a radius tiles, each of which matches @a pred.
|
||||
* @a result must be a std::set of locations.
|
||||
*/
|
||||
void get_tiles_radius(gamemap const &map, std::vector<map_location> const &locs,
|
||||
void get_tiles_radius(const gamemap& map, const std::vector<map_location>& locs,
|
||||
size_t radius, std::set<map_location> &result,
|
||||
bool with_border, xy_pred const &pred)
|
||||
bool with_border, const xy_pred& pred)
|
||||
{
|
||||
typedef std::set<map_location> location_set;
|
||||
|
||||
|
@ -252,7 +252,7 @@ void get_tiles_radius(gamemap const &map, std::vector<map_location> const &locs,
|
|||
map_location adj[6];
|
||||
get_adjacent_tiles(*it, adj);
|
||||
for(size_t i = 0; i != 6; ++i) {
|
||||
map_location const &loc = adj[i];
|
||||
const map_location& loc = adj[i];
|
||||
if ( with_border ? map.on_board_with_border(loc) :
|
||||
map.on_board(loc) ) {
|
||||
if ( !result.count(loc) && !filtered_out.count(loc) ) {
|
||||
|
|
|
@ -23,7 +23,7 @@ class gamemap;
|
|||
class xy_pred
|
||||
{
|
||||
public:
|
||||
virtual bool operator()(map_location const&) const = 0;
|
||||
virtual bool operator()(const map_location&) const = 0;
|
||||
protected:
|
||||
virtual ~xy_pred() {}
|
||||
};
|
||||
|
|
|
@ -169,10 +169,10 @@ struct map_locker
|
|||
};
|
||||
|
||||
|
||||
void game_lua_kernel::extract_preload_scripts(config const &game_config)
|
||||
void game_lua_kernel::extract_preload_scripts(const config& game_config)
|
||||
{
|
||||
game_lua_kernel::preload_scripts.clear();
|
||||
for (config const &cfg : game_config.child_range("lua")) {
|
||||
for (const config& cfg : game_config.child_range("lua")) {
|
||||
game_lua_kernel::preload_scripts.push_back(cfg);
|
||||
}
|
||||
game_lua_kernel::preload_config = game_config.child("game_config");
|
||||
|
@ -885,7 +885,7 @@ int game_lua_kernel::intf_shroud_op(lua_State *L, bool place_shroud)
|
|||
std::set<map_location> locs(locs_v.begin(), locs_v.end());
|
||||
team &t = board().get_team(side_num);
|
||||
|
||||
for (map_location const &loc : locs)
|
||||
for (const map_location& loc : locs)
|
||||
{
|
||||
if (place_shroud) {
|
||||
t.place_shroud(loc);
|
||||
|
@ -973,7 +973,7 @@ int game_lua_kernel::intf_get_terrain(lua_State *L)
|
|||
{
|
||||
map_location loc = luaW_checklocation(L, 1);
|
||||
|
||||
t_translation::terrain_code const &t = board().map().
|
||||
const t_translation::terrain_code& t = board().map().
|
||||
get_terrain(loc);
|
||||
lua_pushstring(L, t_translation::write_terrain_code(t).c_str());
|
||||
return 1;
|
||||
|
@ -1022,7 +1022,7 @@ int game_lua_kernel::intf_get_terrain_info(lua_State *L)
|
|||
char const *m = luaL_checkstring(L, 1);
|
||||
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);
|
||||
const terrain_type& info = board().map().tdata()->get_terrain_info(t);
|
||||
|
||||
lua_newtable(L);
|
||||
lua_pushstring(L, info.id().c_str());
|
||||
|
@ -2837,7 +2837,7 @@ int game_lua_kernel::intf_get_locations(lua_State *L)
|
|||
|
||||
lua_createtable(L, res.size(), 0);
|
||||
int i = 1;
|
||||
for (map_location const &loc : res)
|
||||
for (const map_location& loc : res)
|
||||
{
|
||||
lua_createtable(L, 2, 0);
|
||||
lua_pushinteger(L, loc.wml_x());
|
||||
|
@ -4350,7 +4350,7 @@ void game_lua_kernel::save_game(config &cfg)
|
|||
* Executes the game_events.on_event function.
|
||||
* Returns false if there was no lua handler for this event
|
||||
*/
|
||||
bool game_lua_kernel::run_event(game_events::queued_event const &ev)
|
||||
bool game_lua_kernel::run_event(const game_events::queued_event& ev)
|
||||
{
|
||||
lua_State *L = mState;
|
||||
|
||||
|
@ -4485,8 +4485,8 @@ void game_lua_kernel::set_wml_condition(const std::string& cmd, wml_conditional_
|
|||
* @note @a cfg should be either volatile or long-lived since the Lua
|
||||
* code may grab it for an arbitrary long time.
|
||||
*/
|
||||
bool game_lua_kernel::run_wml_action(const std::string& cmd, vconfig const &cfg,
|
||||
game_events::queued_event const &ev)
|
||||
bool game_lua_kernel::run_wml_action(const std::string& cmd, const vconfig& cfg,
|
||||
const game_events::queued_event& ev)
|
||||
{
|
||||
lua_State *L = mState;
|
||||
|
||||
|
@ -4546,7 +4546,7 @@ bool game_lua_kernel::run_filter(char const *name, const map_location& l)
|
|||
* Runs a script from a unit filter.
|
||||
* The script is an already compiled function given by its name.
|
||||
*/
|
||||
bool game_lua_kernel::run_filter(char const *name, unit const &u)
|
||||
bool game_lua_kernel::run_filter(char const *name, const unit& u)
|
||||
{
|
||||
lua_State *L = mState;
|
||||
unit_map::const_unit_iterator ui = units().find(u.get_location());
|
||||
|
|
|
@ -61,7 +61,7 @@ class game_lua_kernel : public lua_kernel_base
|
|||
|
||||
const game_events::queued_event & get_event_info();
|
||||
|
||||
static void extract_preload_scripts(config const & game_config);
|
||||
static void extract_preload_scripts(const config& game_config);
|
||||
static std::vector<config> preload_scripts;
|
||||
static config preload_config;
|
||||
|
||||
|
@ -199,16 +199,16 @@ public:
|
|||
void initialize(const config& level);
|
||||
void save_game(config & level);
|
||||
void load_game(const config& level);
|
||||
bool run_event(game_events::queued_event const &);
|
||||
bool run_event(const game_events::queued_event&);
|
||||
void push_builtin_effect();
|
||||
void set_wml_action(const std::string&, game_events::wml_action::handler);
|
||||
void set_wml_condition(const std::string&, bool(*)(const vconfig&));
|
||||
bool run_wml_action(const std::string&, vconfig const &,
|
||||
game_events::queued_event const &);
|
||||
bool run_filter(char const *name, unit const &u);
|
||||
bool run_filter(char const *name, map_location const &l);
|
||||
bool run_wml_action(const std::string&, const vconfig&,
|
||||
const game_events::queued_event&);
|
||||
bool run_filter(char const *name, const unit& u);
|
||||
bool run_filter(char const *name, const map_location& l);
|
||||
bool run_filter(char const *name, int nArgs);
|
||||
bool run_wml_conditional(const std::string&, vconfig const &);
|
||||
bool run_wml_conditional(const std::string&, const vconfig&);
|
||||
|
||||
virtual void log_error(char const* msg, char const* context = "Lua error") override;
|
||||
|
||||
|
|
|
@ -495,13 +495,13 @@ bool luaW_getmetafield(lua_State *L, int idx, const char* key)
|
|||
return luaL_getmetafield(L, idx, key) != 0;
|
||||
}
|
||||
|
||||
void luaW_pushvconfig(lua_State *L, vconfig const &cfg)
|
||||
void luaW_pushvconfig(lua_State *L, const vconfig& cfg)
|
||||
{
|
||||
new(L) vconfig(cfg);
|
||||
luaL_setmetatable(L, vconfigKey);
|
||||
}
|
||||
|
||||
void luaW_pushtstring(lua_State *L, t_string const &v)
|
||||
void luaW_pushtstring(lua_State *L, const t_string& v)
|
||||
{
|
||||
new(L) t_string(v);
|
||||
luaL_setmetatable(L, tstringKey);
|
||||
|
@ -514,7 +514,7 @@ namespace {
|
|||
lua_State *L;
|
||||
luaW_pushscalar_visitor(lua_State *l): L(l) {}
|
||||
|
||||
void operator()(boost::blank const &) const
|
||||
void operator()(const boost::blank&) const
|
||||
{ lua_pushnil(L); }
|
||||
void operator()(bool b) const
|
||||
{ lua_pushboolean(L, b); }
|
||||
|
@ -526,12 +526,12 @@ namespace {
|
|||
{ lua_pushnumber(L, d); }
|
||||
void operator()(const std::string& s) const
|
||||
{ lua_pushstring(L, s.c_str()); }
|
||||
void operator()(t_string const &s) const
|
||||
void operator()(const t_string& s) const
|
||||
{ luaW_pushtstring(L, s); }
|
||||
};
|
||||
}//unnamed namespace for luaW_pushscalar_visitor
|
||||
|
||||
void luaW_pushscalar(lua_State *L, config::attribute_value const &v)
|
||||
void luaW_pushscalar(lua_State *L, const config::attribute_value& v)
|
||||
{
|
||||
v.apply_visitor(luaW_pushscalar_visitor(L));
|
||||
}
|
||||
|
@ -596,7 +596,7 @@ t_string luaW_checktstring(lua_State *L, int index)
|
|||
return result;
|
||||
}
|
||||
|
||||
void luaW_filltable(lua_State *L, config const &cfg)
|
||||
void luaW_filltable(lua_State *L, const config& cfg)
|
||||
{
|
||||
if (!lua_checkstack(L, LUA_MINSTACK))
|
||||
return;
|
||||
|
@ -687,7 +687,7 @@ map_location luaW_checklocation(lua_State *L, int index)
|
|||
return result;
|
||||
}
|
||||
|
||||
void luaW_pushconfig(lua_State *L, config const &cfg)
|
||||
void luaW_pushconfig(lua_State *L, const config& cfg)
|
||||
{
|
||||
lua_newtable(L);
|
||||
luaW_filltable(L, cfg);
|
||||
|
|
|
@ -51,17 +51,17 @@ bool luaW_getmetafield(lua_State *L, int idx, const char* key);
|
|||
/**
|
||||
* Pushes a vconfig on the top of the stack.
|
||||
*/
|
||||
void luaW_pushvconfig(lua_State *L, vconfig const &cfg);
|
||||
void luaW_pushvconfig(lua_State *L, const vconfig& cfg);
|
||||
|
||||
/**
|
||||
* Pushes a t_string on the top of the stack.
|
||||
*/
|
||||
void luaW_pushtstring(lua_State *L, t_string const &v);
|
||||
void luaW_pushtstring(lua_State *L, const t_string& v);
|
||||
|
||||
/**
|
||||
* Converts an attribute value into a Lua object pushed at the top of the stack.
|
||||
*/
|
||||
void luaW_pushscalar(lua_State *L, config::attribute_value const &v);
|
||||
void luaW_pushscalar(lua_State *L, const config::attribute_value& v);
|
||||
|
||||
/**
|
||||
* Converts the value at the top of the stack to an attribute value
|
||||
|
@ -83,12 +83,12 @@ t_string luaW_checktstring(lua_State *L, int index);
|
|||
* The destination table should be at the top of the stack on entry. It is
|
||||
* still at the top on exit.
|
||||
*/
|
||||
void luaW_filltable(lua_State *L, config const &cfg);
|
||||
void luaW_filltable(lua_State *L, const config& cfg);
|
||||
|
||||
/**
|
||||
* Converts a map location object to a Lua table pushed at the top of the stack.
|
||||
*/
|
||||
void luaW_pushlocation(lua_State *L, map_location const &loc);
|
||||
void luaW_pushlocation(lua_State *L, const map_location& loc);
|
||||
|
||||
/**
|
||||
* Converts an optional table or pair of integers to a map location object.
|
||||
|
@ -107,7 +107,7 @@ map_location luaW_checklocation(lua_State *L, int index);
|
|||
/**
|
||||
* Converts a config object to a Lua table pushed at the top of the stack.
|
||||
*/
|
||||
void luaW_pushconfig(lua_State *L, config const &cfg);
|
||||
void luaW_pushconfig(lua_State *L, const config& cfg);
|
||||
|
||||
/**
|
||||
* Converts an optional table or vconfig to a config object.
|
||||
|
|
|
@ -46,7 +46,7 @@ static int impl_race_get(lua_State* L)
|
|||
lua_rawget(L, 1);
|
||||
const unit_race* raceptr = unit_types.find_race(lua_tostring(L, -1));
|
||||
if(!raceptr) return luaL_argerror(L, 1, "unknown race");
|
||||
unit_race const &race = *raceptr;
|
||||
const unit_race& race = *raceptr;
|
||||
|
||||
return_tstring_attrib("description", race.description());
|
||||
return_tstring_attrib("name", race.name());
|
||||
|
|
|
@ -88,7 +88,7 @@ static int impl_side_get(lua_State *L)
|
|||
return_bool_attrib("share_view", t.share_view());
|
||||
|
||||
if (strcmp(m, "recruit") == 0) {
|
||||
std::set<std::string> const &recruits = t.recruits();
|
||||
const std::set<std::string>& recruits = t.recruits();
|
||||
lua_createtable(L, recruits.size(), 0);
|
||||
int i = 1;
|
||||
for (const std::string& r : t.recruits()) {
|
||||
|
|
|
@ -263,7 +263,7 @@ static int impl_unit_get(lua_State *L)
|
|||
return luaL_argerror(L, 1, "unknown unit");
|
||||
}
|
||||
|
||||
unit const &u = *pu;
|
||||
const unit& u = *pu;
|
||||
|
||||
// Find the corresponding attribute.
|
||||
return_int_attrib("x", u.get_location().wml_x());
|
||||
|
|
|
@ -82,7 +82,7 @@ class lua_unit
|
|||
unit_ptr ptr;
|
||||
int side;
|
||||
unit* c_ptr;
|
||||
lua_unit(lua_unit const &) = delete;
|
||||
lua_unit(const lua_unit&) = delete;
|
||||
lua_unit& operator=(const lua_unit&) = delete;
|
||||
|
||||
template<typename... Args>
|
||||
|
|
|
@ -36,7 +36,7 @@ bool rects_overlap(const SDL_Rect& rect1, const SDL_Rect& rect2)
|
|||
rect1.y < rect2.y+rect2.h && rect2.y < rect1.y+rect1.h);
|
||||
}
|
||||
|
||||
SDL_Rect intersect_rects(SDL_Rect const &rect1, SDL_Rect const &rect2)
|
||||
SDL_Rect intersect_rects(const SDL_Rect& rect1, const SDL_Rect& rect2)
|
||||
{
|
||||
SDL_Rect res;
|
||||
if(!SDL_IntersectRect(&rect1, &rect2, &res)) {
|
||||
|
@ -46,7 +46,7 @@ SDL_Rect intersect_rects(SDL_Rect const &rect1, SDL_Rect const &rect2)
|
|||
return res;
|
||||
}
|
||||
|
||||
SDL_Rect union_rects(SDL_Rect const &rect1, SDL_Rect const &rect2)
|
||||
SDL_Rect union_rects(const SDL_Rect& rect1, const SDL_Rect& rect2)
|
||||
{
|
||||
SDL_Rect res;
|
||||
SDL_UnionRect(&rect1, &rect2, &res);
|
||||
|
|
|
@ -75,7 +75,7 @@ bool rects_overlap(const SDL_Rect& rect1, const SDL_Rect& rect2);
|
|||
* @return The intersection of rect1 and rect2, or
|
||||
* empty_rect if they don't overlap.
|
||||
*/
|
||||
SDL_Rect intersect_rects(SDL_Rect const &rect1, SDL_Rect const &rect2);
|
||||
SDL_Rect intersect_rects(const SDL_Rect& rect1, const SDL_Rect& rect2);
|
||||
|
||||
/**
|
||||
* Calculates the union of two rectangles. Note: "union" here doesn't mean the
|
||||
|
|
|
@ -57,7 +57,7 @@ surface_restorer::~surface_restorer()
|
|||
restore();
|
||||
}
|
||||
|
||||
void surface_restorer::restore(SDL_Rect const &dst) const
|
||||
void surface_restorer::restore(const SDL_Rect& dst) const
|
||||
{
|
||||
if(surface_.null()) {
|
||||
return;
|
||||
|
|
|
@ -107,7 +107,7 @@ struct surface_restorer
|
|||
~surface_restorer();
|
||||
|
||||
void restore() const;
|
||||
void restore(SDL_Rect const &dst) const;
|
||||
void restore(const SDL_Rect& dst) const;
|
||||
void update();
|
||||
void cancel();
|
||||
|
||||
|
|
|
@ -1741,7 +1741,7 @@ surface blur_alpha_surface(const surface &surf, int depth)
|
|||
return res;
|
||||
}
|
||||
|
||||
surface cut_surface(const surface &surf, SDL_Rect const &r)
|
||||
surface cut_surface(const surface &surf, const SDL_Rect& r)
|
||||
{
|
||||
if(surf == nullptr)
|
||||
return nullptr;
|
||||
|
|
|
@ -240,7 +240,7 @@ void blur_surface(surface& surf, SDL_Rect rect, int depth = 1);
|
|||
surface blur_alpha_surface(const surface &surf, int depth = 1);
|
||||
|
||||
/** Cuts a rectangle from a surface. */
|
||||
surface cut_surface(const surface &surf, SDL_Rect const &r);
|
||||
surface cut_surface(const surface &surf, const SDL_Rect& r);
|
||||
|
||||
/**
|
||||
* Blends a surface with a color.
|
||||
|
|
|
@ -524,7 +524,7 @@ public:
|
|||
|
||||
// Generic visitor just streams "key=value".
|
||||
template<typename T>
|
||||
void operator()(T const& v) const
|
||||
void operator()(const T& v) const
|
||||
{
|
||||
indent();
|
||||
out_ << key_ << '=' << v << '\n';
|
||||
|
@ -534,7 +534,7 @@ public:
|
|||
// Specialized visitors for things that go in quotes:
|
||||
//
|
||||
|
||||
void operator()(boost::blank const&) const
|
||||
void operator()(const boost::blank&) const
|
||||
{
|
||||
// Treat blank values as nonexistent which fits better than treating them as empty strings.
|
||||
}
|
||||
|
@ -545,7 +545,7 @@ public:
|
|||
out_ << key_ << '=' << '"' << escaped_string(s) << '"' << '\n';
|
||||
}
|
||||
|
||||
void operator()(t_string const& s) const;
|
||||
void operator()(const t_string& s) const;
|
||||
|
||||
private:
|
||||
void indent() const
|
||||
|
@ -569,7 +569,7 @@ private:
|
|||
* That is the reason for not outputting the key beforehand and
|
||||
* letting this function do it.
|
||||
*/
|
||||
void write_key_val_visitor::operator()(t_string const& value) const
|
||||
void write_key_val_visitor::operator()(const t_string& value) const
|
||||
{
|
||||
bool first = true;
|
||||
|
||||
|
@ -695,7 +695,7 @@ void write_close_child(std::ostream& out, const std::string& child, unsigned int
|
|||
out << std::string(level, '\t') << "[/" << child << "]\n";
|
||||
}
|
||||
|
||||
static void write_internal(config const& cfg, std::ostream& out, std::string& textdomain, size_t tab = 0)
|
||||
static void write_internal(const config& cfg, std::ostream& out, std::string& textdomain, size_t tab = 0)
|
||||
{
|
||||
if(tab > max_recursion_levels) {
|
||||
throw config::error("Too many recursion levels in config write");
|
||||
|
@ -722,7 +722,7 @@ static void write_internal(config const& cfg, std::ostream& out, std::string& te
|
|||
}
|
||||
}
|
||||
|
||||
static void write_internal(configr_of const& cfg, std::ostream& out, std::string& textdomain, size_t tab = 0)
|
||||
static void write_internal(const configr_of& cfg, std::ostream& out, std::string& textdomain, size_t tab = 0)
|
||||
{
|
||||
if(tab > max_recursion_levels) {
|
||||
throw config::error("Too many recursion levels in config write");
|
||||
|
@ -746,14 +746,14 @@ static void write_internal(configr_of const& cfg, std::ostream& out, std::string
|
|||
}
|
||||
}
|
||||
|
||||
void write(std::ostream& out, configr_of const& cfg, unsigned int level)
|
||||
void write(std::ostream& out, const configr_of& cfg, unsigned int level)
|
||||
{
|
||||
std::string textdomain = PACKAGE;
|
||||
write_internal(cfg, out, textdomain, level);
|
||||
}
|
||||
|
||||
template<typename compressor>
|
||||
void write_compressed(std::ostream& out, configr_of const& cfg)
|
||||
void write_compressed(std::ostream& out, const configr_of& cfg)
|
||||
{
|
||||
boost::iostreams::filtering_stream<boost::iostreams::output> filter;
|
||||
filter.push(compressor());
|
||||
|
@ -765,12 +765,12 @@ void write_compressed(std::ostream& out, configr_of const& cfg)
|
|||
filter << "\n";
|
||||
}
|
||||
|
||||
void write_gz(std::ostream& out, configr_of const& cfg)
|
||||
void write_gz(std::ostream& out, const configr_of& cfg)
|
||||
{
|
||||
write_compressed<boost::iostreams::gzip_compressor>(out, cfg);
|
||||
}
|
||||
|
||||
void write_bz2(std::ostream& out, configr_of const& cfg)
|
||||
void write_bz2(std::ostream& out, const configr_of& cfg)
|
||||
{
|
||||
write_compressed<boost::iostreams::bzip2_compressor>(out, cfg);
|
||||
}
|
||||
|
|
|
@ -28,9 +28,9 @@ void read(config& cfg, const std::string& in, abstract_validator* validator = nu
|
|||
void read_gz(config& cfg, std::istream& in, abstract_validator* validator = nullptr);
|
||||
void read_bz2(config& cfg, std::istream& in, abstract_validator* validator = nullptr);
|
||||
|
||||
void write(std::ostream& out, configr_of const& cfg, unsigned int level = 0);
|
||||
void write_gz(std::ostream& out, configr_of const& cfg);
|
||||
void write_bz2(std::ostream& out, configr_of const& cfg);
|
||||
void write(std::ostream& out, const configr_of& cfg, unsigned int level = 0);
|
||||
void write_gz(std::ostream& out, const configr_of& cfg);
|
||||
void write_bz2(std::ostream& out, const configr_of& cfg);
|
||||
void write_key_val(std::ostream& out,
|
||||
const std::string& key,
|
||||
const config::attribute_value& value,
|
||||
|
|
|
@ -86,11 +86,11 @@ struct preproc_define
|
|||
|
||||
static preproc_map::value_type read_pair(const config&);
|
||||
|
||||
bool operator==(preproc_define const&) const;
|
||||
bool operator==(const preproc_define&) const;
|
||||
|
||||
bool operator<(preproc_define const&) const;
|
||||
bool operator<(const preproc_define&) const;
|
||||
|
||||
bool operator!=(preproc_define const& v) const
|
||||
bool operator!=(const preproc_define& v) const
|
||||
{
|
||||
return !operator==(v);
|
||||
}
|
||||
|
|
|
@ -252,7 +252,7 @@ void class_tag::printl(std::ostream &os,int level, int step){
|
|||
return nullptr;
|
||||
|
||||
}
|
||||
// class_tag & class_tag::operator= (class_tag const& t){
|
||||
// class_tag & class_tag::operator= (const class_tag& t){
|
||||
// if (&t != this){
|
||||
// name_ = t.name_;
|
||||
// min_ = t.min_;
|
||||
|
|
|
@ -297,7 +297,7 @@ public:
|
|||
class_tag & root) ;
|
||||
#endif
|
||||
|
||||
// class_tag & operator= (class_tag const& );
|
||||
// class_tag & operator= (const class_tag&);
|
||||
|
||||
private:
|
||||
/** name of tag*/
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace ucs4
|
|||
update();
|
||||
}
|
||||
|
||||
iterator_base(typename string_type::const_iterator const &begin, typename string_type::const_iterator const &end)
|
||||
iterator_base(typename const string_type::const_iterator& begin, typename const string_type::const_iterator& end)
|
||||
: current_char(0)
|
||||
, string_end(end)
|
||||
, current_substr(std::make_pair(begin, begin))
|
||||
|
|
|
@ -1242,10 +1242,10 @@ void game::process_whiteboard(simple_wml::document& data, const socket_ptr user)
|
|||
return;
|
||||
}
|
||||
|
||||
simple_wml::node const& wb_node = *data.child("whiteboard");
|
||||
const simple_wml::node& wb_node = *data.child("whiteboard");
|
||||
|
||||
// Ensure "side" attribute match with user
|
||||
simple_wml::string_span const& to_sides = wb_node["to_sides"];
|
||||
const simple_wml::string_span& to_sides = wb_node["to_sides"];
|
||||
size_t const side_index = wb_node["side"].to_int() - 1;
|
||||
|
||||
if(side_index >= sides_.size() || sides_[side_index] != user) {
|
||||
|
@ -1269,7 +1269,7 @@ void game::process_change_turns_wml(simple_wml::document& data, const socket_ptr
|
|||
return;
|
||||
}
|
||||
|
||||
simple_wml::node const& ctw_node = *data.child("change_turns_wml");
|
||||
const simple_wml::node& ctw_node = *data.child("change_turns_wml");
|
||||
const int current_turn = ctw_node["current"].to_int();
|
||||
const int num_turns = ctw_node["max"].to_int();
|
||||
if(num_turns > 10000 || current_turn > 10000) {
|
||||
|
|
|
@ -112,7 +112,7 @@ dialog_frame::dimension_measurements::dimension_measurements() :
|
|||
interior(sdl::empty_rect), exterior(sdl::empty_rect), title(sdl::empty_rect), button_row(sdl::empty_rect)
|
||||
{}
|
||||
|
||||
dialog_frame::dimension_measurements dialog_frame::layout(SDL_Rect const& rect) {
|
||||
dialog_frame::dimension_measurements dialog_frame::layout(const SDL_Rect& rect) {
|
||||
return layout(rect.x, rect.y, rect.w, rect.h);
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
~dialog_frame();
|
||||
|
||||
dimension_measurements layout(int x, int y, int w, int h);
|
||||
dimension_measurements layout(SDL_Rect const& frame_area);
|
||||
dimension_measurements layout(const SDL_Rect& frame_area);
|
||||
void set_layout(dimension_measurements &new_dim) { dim_ = new_dim; }
|
||||
dimension_measurements get_layout() const { return dim_; }
|
||||
|
||||
|
|
|
@ -139,12 +139,12 @@ public:
|
|||
return data_;
|
||||
}
|
||||
|
||||
bool operator==(sound_cache_chunk const& scc) const
|
||||
bool operator==(const sound_cache_chunk& scc) const
|
||||
{
|
||||
return file == scc.file;
|
||||
}
|
||||
|
||||
bool operator!=(sound_cache_chunk const& scc) const
|
||||
bool operator!=(const sound_cache_chunk& scc) const
|
||||
{
|
||||
return !operator==(scc);
|
||||
}
|
||||
|
|
|
@ -442,7 +442,7 @@ private:
|
|||
*/
|
||||
bool local;
|
||||
|
||||
bool operator<(building_rule const& that) const
|
||||
bool operator<(const building_rule& that) const
|
||||
{
|
||||
return precedence < that.precedence;
|
||||
}
|
||||
|
|
|
@ -240,8 +240,8 @@ BOOST_AUTO_TEST_CASE(test_pal_modification_decoding)
|
|||
// The dynamic_cast returns nullptr if the argument doesn't match the type
|
||||
BOOST_REQUIRE(mod != nullptr);
|
||||
|
||||
std::vector<color_t> const& old_palette = game_config::tc_info("000000,005000");
|
||||
std::vector<color_t> const& new_palette = game_config::tc_info("FFFFFF,FF00FF");
|
||||
const std::vector<color_t>& old_palette = game_config::tc_info("000000,005000");
|
||||
const std::vector<color_t>& new_palette = game_config::tc_info("FFFFFF,FF00FF");
|
||||
color_range_map expected;
|
||||
|
||||
for(size_t i = 0; i < old_palette.size() && i < new_palette.size(); ++i) {
|
||||
|
|
|
@ -354,7 +354,7 @@ void tod_manager::add_time_area(const gamemap & map, const config& cfg)
|
|||
area.xsrc = cfg["x"].str();
|
||||
area.ysrc = cfg["y"].str();
|
||||
area.currentTime = cfg["current_time"].to_int(0);
|
||||
std::vector<map_location> const& locs (map.parse_location_range(area.xsrc, area.ysrc, true));
|
||||
const std::vector<map_location>& locs (map.parse_location_range(area.xsrc, area.ysrc, true));
|
||||
area.hexes.insert(locs.begin(), locs.end());
|
||||
time_of_day::parse_times(cfg, area.times);
|
||||
has_tod_bonus_changed_ = true;
|
||||
|
|
|
@ -268,7 +268,7 @@ std::vector<std::tuple<t_string, t_string, t_string> > unit::ability_tooltips(bo
|
|||
{
|
||||
if ( !active_list || ability_active(ab.key, ab.cfg, loc_) )
|
||||
{
|
||||
t_string const &name =
|
||||
const t_string& name =
|
||||
gender_value(ab.cfg, gender_, "name", "female_name", "name").t_str();
|
||||
|
||||
if (!name.empty()) {
|
||||
|
@ -283,10 +283,10 @@ std::vector<std::tuple<t_string, t_string, t_string> > unit::ability_tooltips(bo
|
|||
else
|
||||
{
|
||||
// See if an inactive name was specified.
|
||||
config::attribute_value const &inactive_value =
|
||||
const config::attribute_value& inactive_value =
|
||||
gender_value(ab.cfg, gender_, "name_inactive",
|
||||
"female_name_inactive", "name_inactive");
|
||||
t_string const &name = !inactive_value.blank() ? inactive_value.t_str() :
|
||||
const t_string& name = !inactive_value.blank() ? inactive_value.t_str() :
|
||||
gender_value(ab.cfg, gender_, "name", "female_name", "name").t_str();
|
||||
|
||||
if (!name.empty()) {
|
||||
|
@ -420,12 +420,12 @@ public:
|
|||
// Constructor stores the default value.
|
||||
get_ability_value_visitor(T def, const TFuncFormula& formula_handler) : def_(def), formula_handler_(formula_handler) {}
|
||||
|
||||
T operator()(boost::blank const &) const { return def_; }
|
||||
T operator()(const boost::blank&) const { return def_; }
|
||||
T operator()(bool) const { return def_; }
|
||||
T operator()(int i) const { return static_cast<T>(i); }
|
||||
T operator()(unsigned long long u) const { return static_cast<T>(u); }
|
||||
T operator()(double d) const { return static_cast<T>(d); }
|
||||
T operator()(t_string const &) const { return def_; }
|
||||
T operator()(const t_string&) const { return def_; }
|
||||
T operator()(const std::string& s) const
|
||||
{
|
||||
if(s.size() >= 2 && s[0] == '(') {
|
||||
|
@ -482,7 +482,7 @@ std::pair<int,map_location> unit_ability_list::get_extremum(const std::string& k
|
|||
int abs_max = 0;
|
||||
int flat = 0;
|
||||
int stack = 0;
|
||||
for (unit_ability const &p : cfgs_)
|
||||
for (const unit_ability& p : cfgs_)
|
||||
{
|
||||
int value = get_single_ability_value((*p.first)[key], def, p.second, loc(),[&](const wfl::formula& formula, wfl::map_formula_callable& callable) {
|
||||
return formula.evaluate(callable).as_int();
|
||||
|
@ -649,7 +649,7 @@ std::vector<std::pair<t_string, t_string> > attack_type::special_tooltips(
|
|||
active_list->push_back(true);
|
||||
}
|
||||
} else {
|
||||
t_string const &name = default_value(sp.cfg, "name_inactive", "name").t_str();
|
||||
const t_string& name = default_value(sp.cfg, "name_inactive", "name").t_str();
|
||||
if (!name.empty()) {
|
||||
res.emplace_back(name, default_value(sp.cfg, "description_inactive", "description").t_str() );
|
||||
active_list->push_back(false);
|
||||
|
|
|
@ -195,9 +195,9 @@ public:
|
|||
|
||||
|
||||
template<typename T>
|
||||
bool operator()(T const &) const { return false; }
|
||||
bool operator()(const T&) const { return false; }
|
||||
|
||||
bool operator()(t_string const&) const { return true; }
|
||||
bool operator()(const t_string&) const { return true; }
|
||||
|
||||
bool operator()(const std::string& s) const
|
||||
{
|
||||
|
|
|
@ -550,7 +550,7 @@ private:
|
|||
}
|
||||
|
||||
template<typename X>
|
||||
unit_map::unit_iterator make_unit_iterator(X const& i)
|
||||
unit_map::unit_iterator make_unit_iterator(const X& i)
|
||||
{
|
||||
if(!is_found(i)) {
|
||||
return unit_iterator(umap_.end(), this);
|
||||
|
@ -560,7 +560,7 @@ private:
|
|||
}
|
||||
|
||||
template<typename X>
|
||||
unit_map::const_unit_iterator make_const_unit_iterator(X const& i) const
|
||||
unit_map::const_unit_iterator make_const_unit_iterator(const X& i) const
|
||||
{
|
||||
if(!is_found(i)) {
|
||||
return const_unit_iterator(umap_.end(), this);
|
||||
|
|
|
@ -2357,7 +2357,7 @@ bool unit::invisible(const map_location& loc, const display_context& dc, bool se
|
|||
|
||||
bool unit::is_visible_to_team(const team& team,const display_context& dc, bool const see_all) const
|
||||
{
|
||||
map_location const& loc = get_location();
|
||||
const map_location& loc = get_location();
|
||||
if(!dc.map().on_board(loc)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -38,8 +38,8 @@ public:
|
|||
enum {NEW=0, NOT_COUNTED = -1};
|
||||
|
||||
explicit ref_counter(T_integral x = 0) : count_(x) {}
|
||||
ref_counter(ref_counter const &a) : count_(a.count_) {}
|
||||
ref_counter & operator=(ref_counter const &a){count_ = a.count_; return *this;}
|
||||
ref_counter(const ref_counter& a) : count_(a.count_) {}
|
||||
ref_counter & operator=(const ref_counter& a){count_ = a.count_; return *this;}
|
||||
|
||||
operator T_integral const () const {return count_;}
|
||||
|
||||
|
|
|
@ -297,7 +297,7 @@ namespace {
|
|||
config::attribute_value &result;
|
||||
|
||||
vconfig_expand_visitor(config::attribute_value &r): result(r) {}
|
||||
template<typename T> void operator()(T const &) const {}
|
||||
template<typename T> void operator()(const T&) const {}
|
||||
void operator()(const std::string &s) const
|
||||
{
|
||||
result = utils::interpolate_variables_into_string(s, *(resources::gamedata));
|
||||
|
|
|
@ -238,7 +238,7 @@ public:
|
|||
: scoped_wml_variable(var_name), data_(data) {}
|
||||
void activate();
|
||||
private:
|
||||
config const &data_;
|
||||
const config& data_;
|
||||
};
|
||||
|
||||
class scoped_xy_unit : public scoped_wml_variable
|
||||
|
|
|
@ -56,7 +56,7 @@ config action::to_config() const
|
|||
}
|
||||
|
||||
/* static */
|
||||
action_ptr action::from_config(config const& cfg, bool hidden)
|
||||
action_ptr action::from_config(const config& cfg, bool hidden)
|
||||
{
|
||||
std::string type = cfg["type"];
|
||||
|
||||
|
@ -71,7 +71,7 @@ action_ptr action::from_config(config const& cfg, bool hidden)
|
|||
return action_ptr(new recall(cfg,hidden));
|
||||
else if(type=="suppose_dead")
|
||||
return action_ptr(new suppose_dead(cfg,hidden));
|
||||
} catch(action::ctor_err const&) {}
|
||||
} catch(const action::ctor_err&) {}
|
||||
|
||||
return action_ptr();
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ action::action(size_t team_index, bool hidden)
|
|||
{
|
||||
}
|
||||
|
||||
action::action(config const& cfg, bool hidden)
|
||||
action::action(const config& cfg, bool hidden)
|
||||
: team_index_()
|
||||
, hidden_(hidden)
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@ class action : public std::enable_shared_from_this<action>
|
|||
{
|
||||
public:
|
||||
action(size_t team_index, bool hidden);
|
||||
action(config const&, bool hidden); // For deserialization
|
||||
action(const config&, bool hidden); // For deserialization
|
||||
virtual ~action();
|
||||
|
||||
virtual std::ostream& print(std::ostream& s) const = 0;
|
||||
|
@ -88,7 +88,7 @@ public:
|
|||
/** Constructs and returns a config object representing this object. */
|
||||
virtual config to_config() const;
|
||||
/** Constructs an object of a subclass of wb::action using a config. Current behavior is to return a null pointer for unrecognized config. */
|
||||
static action_ptr from_config(config const&, bool hidden);
|
||||
static action_ptr from_config(const config&, bool hidden);
|
||||
|
||||
struct ctor_err : public game::error
|
||||
{
|
||||
|
|
|
@ -63,7 +63,7 @@ attack::attack(size_t team_index, bool hidden, unit& u, const map_location& targ
|
|||
this->init();
|
||||
}
|
||||
|
||||
attack::attack(config const& cfg, bool hidden)
|
||||
attack::attack(const config& cfg, bool hidden)
|
||||
: move(cfg,hidden)
|
||||
, target_hex_(cfg.child("target_hex_")["x"],cfg.child("target_hex_")["y"], wml_loc())
|
||||
, weapon_choice_(cfg["weapon_choice_"].to_int(-1)) //default value: -1
|
||||
|
|
|
@ -28,7 +28,7 @@ class attack: public move
|
|||
public:
|
||||
attack(size_t team_index, bool hidden, unit& mover, const map_location& target_hex, int weapon_choice, const pathfind::marked_route& route,
|
||||
arrow_ptr arrow, fake_unit_ptr fake_unit);
|
||||
attack(config const&, bool hidden); // For deserialization
|
||||
attack(const config&, bool hidden); // For deserialization
|
||||
virtual ~attack();
|
||||
|
||||
virtual std::ostream& print(std::ostream& s) const;
|
||||
|
@ -55,7 +55,7 @@ public:
|
|||
/** Redrawing function, called each time the action situation might have changed. */
|
||||
virtual void redraw();
|
||||
|
||||
map_location const& get_target_hex() const {return target_hex_; }
|
||||
const map_location& get_target_hex() const {return target_hex_; }
|
||||
|
||||
virtual config to_config() const;
|
||||
|
||||
|
|
|
@ -258,7 +258,7 @@ bool manager::can_enable_reorder_hotkeys() const
|
|||
return can_enable_modifier_hotkeys() && highlighter_ && highlighter_->get_bump_target();
|
||||
}
|
||||
|
||||
bool manager::allow_leader_to_move(unit const& leader) const
|
||||
bool manager::allow_leader_to_move(const unit& leader) const
|
||||
{
|
||||
if(!has_actions())
|
||||
return true;
|
||||
|
@ -439,7 +439,7 @@ void manager::validate_viewer_actions()
|
|||
}
|
||||
|
||||
//helper fcn
|
||||
static void draw_numbers(map_location const& hex, side_actions::numbers_t numbers)
|
||||
static void draw_numbers(const map_location& hex, side_actions::numbers_t numbers)
|
||||
{
|
||||
std::vector<int>& numbers_to_draw = numbers.numbers_to_draw;
|
||||
std::vector<size_t>& team_numbers = numbers.team_numbers;
|
||||
|
@ -492,7 +492,7 @@ namespace
|
|||
action->accept(*this);
|
||||
}
|
||||
|
||||
std::set<size_t> const& get_units_owning_moves() {
|
||||
const std::set<size_t>& get_units_owning_moves() {
|
||||
return move_owners_;
|
||||
}
|
||||
|
||||
|
@ -628,20 +628,20 @@ void manager::send_network_data()
|
|||
}
|
||||
}
|
||||
|
||||
void manager::process_network_data(config const& cfg)
|
||||
void manager::process_network_data(const config& cfg)
|
||||
{
|
||||
if(config const& wb_cfg = cfg.child("whiteboard"))
|
||||
if(const config& wb_cfg = cfg.child("whiteboard"))
|
||||
{
|
||||
size_t count = wb_cfg.child_count("net_cmd");
|
||||
LOG_WB << "Received wb data (" << count << ").\n";
|
||||
|
||||
team& team_from = resources::gameboard->get_team(wb_cfg["side"]);
|
||||
for(side_actions::net_cmd const& cmd : wb_cfg.child_range("net_cmd"))
|
||||
for(const side_actions::net_cmd& cmd : wb_cfg.child_range("net_cmd"))
|
||||
team_from.get_side_actions()->execute_net_cmd(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
void manager::queue_net_cmd(size_t team_index, side_actions::net_cmd const& cmd)
|
||||
void manager::queue_net_cmd(size_t team_index, const side_actions::net_cmd& cmd)
|
||||
{
|
||||
assert(team_index < net_buffer_.size());
|
||||
net_buffer_[team_index].add_child("net_cmd",cmd);
|
||||
|
@ -659,7 +659,7 @@ void manager::create_temp_move()
|
|||
if ( !active_ || !can_modify_game_state() )
|
||||
return;
|
||||
|
||||
pathfind::marked_route const& route =
|
||||
const pathfind::marked_route& route =
|
||||
resources::controller->get_mouse_handler_base().get_current_route();
|
||||
|
||||
if (route.steps.empty() || route.steps.size() < 2) return;
|
||||
|
@ -752,7 +752,7 @@ void manager::create_temp_move()
|
|||
void manager::erase_temp_move()
|
||||
{
|
||||
move_arrows_.clear();
|
||||
for(fake_unit_ptr const& tmp : fake_units_) {
|
||||
for(const fake_unit_ptr& tmp : fake_units_) {
|
||||
if(tmp) {
|
||||
tmp->anim_comp().invalidate(*game_display::get_singleton());
|
||||
}
|
||||
|
@ -908,7 +908,7 @@ bool manager::save_recall(const unit& unit, int side_num, const map_location& re
|
|||
return created_planned_recall;
|
||||
}
|
||||
|
||||
void manager::save_suppose_dead(unit& curr_unit, map_location const& loc)
|
||||
void manager::save_suppose_dead(unit& curr_unit, const map_location& loc)
|
||||
{
|
||||
if(active_ && !executing_actions_ && !resources::controller->is_linger_mode())
|
||||
{
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
/** Used to ask the whiteboard if its action reordering hotkeys should be available to the user */
|
||||
bool can_enable_reorder_hotkeys() const;
|
||||
/** Used to ask permission to the wb to move a leader, to avoid invalidating planned recruits */
|
||||
bool allow_leader_to_move(unit const& leader) const;
|
||||
bool allow_leader_to_move(const unit& leader) const;
|
||||
/** @ return true if the whiteboard is ready to end turn. Triggers the execution of remaining planned actions. */
|
||||
bool allow_end_turn();
|
||||
/**
|
||||
|
@ -101,9 +101,9 @@ public:
|
|||
/** Called by replay_network_sender to add whiteboard data to the outgoing network packets */
|
||||
void send_network_data();
|
||||
/** Called by turn_info::process_network_data() when network data needs to be processed */
|
||||
void process_network_data(config const&);
|
||||
void process_network_data(const config&);
|
||||
/** Adds a side_actions::net_cmd to net_buffer_[team_index], whereupon it will (later) be sent to all allies */
|
||||
void queue_net_cmd(size_t team_index, side_actions::net_cmd const&);
|
||||
void queue_net_cmd(size_t team_index, const side_actions::net_cmd&);
|
||||
|
||||
/** Whether the current side has actions in the first turn of its planned actions queue */
|
||||
static bool current_side_has_actions();
|
||||
|
@ -154,7 +154,7 @@ public:
|
|||
bool save_recall(const unit& unit, int side_num, const map_location& recall_hex);
|
||||
|
||||
/** Creates a suppose-dead action for the current side */
|
||||
void save_suppose_dead(unit& curr_unit, map_location const& loc);
|
||||
void save_suppose_dead(unit& curr_unit, const map_location& loc);
|
||||
|
||||
/** Executes first action in the queue for current side */
|
||||
void contextual_execute();
|
||||
|
|
|
@ -85,7 +85,7 @@ move::move(size_t team_index, bool hidden, unit& u, const pathfind::marked_route
|
|||
this->init();
|
||||
}
|
||||
|
||||
move::move(config const& cfg, bool hidden)
|
||||
move::move(const config& cfg, bool hidden)
|
||||
: action(cfg,hidden)
|
||||
, unit_underlying_id_(0)
|
||||
, unit_id_()
|
||||
|
@ -106,14 +106,14 @@ move::move(config const& cfg, bool hidden)
|
|||
unit_underlying_id_ = unit_itor->underlying_id();
|
||||
|
||||
// Construct and validate route_
|
||||
config const& route_cfg = cfg.child("route_");
|
||||
const config& route_cfg = cfg.child("route_");
|
||||
if(!route_cfg)
|
||||
throw action::ctor_err("move: Invalid route_");
|
||||
route_->move_cost = route_cfg["move_cost"];
|
||||
for(config const& loc_cfg : route_cfg.child_range("step")) {
|
||||
for(const config& loc_cfg : route_cfg.child_range("step")) {
|
||||
route_->steps.emplace_back(loc_cfg["x"],loc_cfg["y"], wml_loc());
|
||||
}
|
||||
for(config const& mark_cfg : route_cfg.child_range("mark")) {
|
||||
for(const config& mark_cfg : route_cfg.child_range("mark")) {
|
||||
route_->marks[map_location(mark_cfg["x"],mark_cfg["y"], wml_loc())]
|
||||
= pathfind::marked_route::mark(mark_cfg["turns"],
|
||||
mark_cfg["zoc"].to_bool(),
|
||||
|
@ -122,7 +122,7 @@ move::move(config const& cfg, bool hidden)
|
|||
}
|
||||
|
||||
// Validate route_ some more
|
||||
std::vector<map_location> const& steps = route_->steps;
|
||||
const std::vector<map_location>& steps = route_->steps;
|
||||
if(steps.empty())
|
||||
throw action::ctor_err("move: Invalid route_");
|
||||
|
||||
|
@ -384,7 +384,7 @@ void move::remove_temp_modifier(unit_map&)
|
|||
mover_.reset();
|
||||
}
|
||||
|
||||
void move::draw_hex(map_location const& hex)
|
||||
void move::draw_hex(const map_location& hex)
|
||||
{
|
||||
//display turn info for turns 2 and above
|
||||
if (hex == get_dest_hex() && turn_number_ >= 2)
|
||||
|
@ -504,7 +504,7 @@ config move::to_config() const
|
|||
//Serialize route_
|
||||
config route_cfg;
|
||||
route_cfg["move_cost"]=route_->move_cost;
|
||||
for(map_location const& loc : route_->steps)
|
||||
for(const map_location& loc : route_->steps)
|
||||
{
|
||||
config loc_cfg;
|
||||
loc_cfg["x"]=loc.wml_x();
|
||||
|
@ -512,7 +512,7 @@ config move::to_config() const
|
|||
route_cfg.add_child("step", std::move(loc_cfg));
|
||||
}
|
||||
typedef std::pair<map_location,pathfind::marked_route::mark> pair_loc_mark;
|
||||
for(pair_loc_mark const& item : route_->marks)
|
||||
for(const pair_loc_mark& item : route_->marks)
|
||||
{
|
||||
config mark_cfg;
|
||||
mark_cfg["x"]=item.first.wml_x();
|
||||
|
|
|
@ -33,7 +33,7 @@ class move : public action
|
|||
public:
|
||||
move(size_t team_index, bool hidden, unit& mover, const pathfind::marked_route& route,
|
||||
arrow_ptr arrow, fake_unit_ptr fake_unit);
|
||||
move(config const&, bool hidden); // For deserialization
|
||||
move(const config&, bool hidden); // For deserialization
|
||||
virtual ~move();
|
||||
|
||||
virtual std::ostream& print(std::ostream& s) const;
|
||||
|
@ -72,7 +72,7 @@ public:
|
|||
virtual void remove_temp_modifier(unit_map& unit_map);
|
||||
|
||||
/** Gets called by display when drawing a hex, to allow actions to draw to the screen. */
|
||||
virtual void draw_hex(map_location const& hex);
|
||||
virtual void draw_hex(const map_location& hex);
|
||||
/** Redrawing function, called each time the action situation might have changed. */
|
||||
void redraw();
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ recall::recall(size_t team_index, bool hidden, const unit& unit, const map_locat
|
|||
this->init();
|
||||
}
|
||||
|
||||
recall::recall(config const& cfg, bool hidden)
|
||||
recall::recall(const config& cfg, bool hidden)
|
||||
: action(cfg,hidden)
|
||||
, temp_unit_()
|
||||
, recall_hex_(cfg.child("recall_hex_")["x"],cfg.child("recall_hex_")["y"], wml_loc())
|
||||
|
@ -173,7 +173,7 @@ void recall::remove_temp_modifier(unit_map& unit_map)
|
|||
resources::gameboard->teams().at(team_index()).recall_list().add(temp_unit_);
|
||||
}
|
||||
|
||||
void recall::draw_hex(map_location const& hex)
|
||||
void recall::draw_hex(const map_location& hex)
|
||||
{
|
||||
if (hex == recall_hex_)
|
||||
{
|
||||
|
|
|
@ -28,7 +28,7 @@ class recall: public action
|
|||
{
|
||||
public:
|
||||
recall(size_t team_index, bool hidden, const unit& unit, const map_location& recall_hex);
|
||||
recall(config const&, bool hidden); // For deserialization
|
||||
recall(const config&, bool hidden); // For deserialization
|
||||
virtual ~recall();
|
||||
|
||||
virtual std::ostream& print(std::ostream& s) const;
|
||||
|
|
|
@ -64,7 +64,7 @@ recruit::recruit(size_t team_index, bool hidden, const std::string& unit_name, c
|
|||
this->init();
|
||||
}
|
||||
|
||||
recruit::recruit(config const& cfg, bool hidden)
|
||||
recruit::recruit(const config& cfg, bool hidden)
|
||||
: action(cfg,hidden)
|
||||
, unit_name_(cfg["unit_name_"])
|
||||
, recruit_hex_(cfg.child("recruit_hex_")["x"],cfg.child("recruit_hex_")["y"], wml_loc())
|
||||
|
@ -144,7 +144,7 @@ void recruit::remove_temp_modifier(unit_map& unit_map)
|
|||
assert(temp_unit_.get());
|
||||
}
|
||||
|
||||
void recruit::draw_hex(map_location const& hex)
|
||||
void recruit::draw_hex(const map_location& hex)
|
||||
{
|
||||
if (hex == recruit_hex_)
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@ class recruit: public action
|
|||
{
|
||||
public:
|
||||
recruit(size_t team_index, bool hidden, const std::string& unit_name, const map_location& recruit_hex);
|
||||
recruit(config const&, bool hidden); // For deserialization
|
||||
recruit(const config&, bool hidden); // For deserialization
|
||||
virtual ~recruit();
|
||||
|
||||
virtual std::ostream& print(std::ostream& s) const;
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
virtual void remove_temp_modifier(unit_map& unit_map);
|
||||
|
||||
/** Gets called by display when drawing a hex, to allow actions to draw to the screen. */
|
||||
virtual void draw_hex(map_location const& hex);
|
||||
virtual void draw_hex(const map_location& hex);
|
||||
/** Redrawing function, called each time the action situation might have changed. */
|
||||
virtual void redraw();
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace wb
|
|||
{
|
||||
|
||||
/** Dumps side_actions on a stream, for debug purposes. */
|
||||
std::ostream &operator<<(std::ostream &out, wb::side_actions const& side_actions)
|
||||
std::ostream &operator<<(std::ostream &out, const wb::side_actions& side_actions)
|
||||
{
|
||||
out << "Content of side_actions:";
|
||||
for(size_t turn = 0; turn < side_actions.num_turns(); ++turn) {
|
||||
|
@ -559,21 +559,21 @@ side_actions::iterator side_actions::find_first_action_at(map_location hex)
|
|||
return find_first_action_of(actions_.get<container::by_hex>().equal_range(hex), begin(), std::less<iterator>());
|
||||
}
|
||||
|
||||
side_actions::iterator side_actions::find_first_action_of(unit const& unit, side_actions::iterator start_position)
|
||||
side_actions::iterator side_actions::find_first_action_of(const unit& unit, side_actions::iterator start_position)
|
||||
{
|
||||
return find_first_action_of(actions_.get<container::by_unit>().equal_range(unit.underlying_id()), start_position, std::less<iterator>());
|
||||
}
|
||||
|
||||
side_actions::const_iterator side_actions::find_last_action_of(unit const& unit, side_actions::const_iterator start_position) const {
|
||||
side_actions::const_iterator side_actions::find_last_action_of(const unit& unit, side_actions::const_iterator start_position) const {
|
||||
return find_first_action_of(actions_.get<container::by_unit>().equal_range(unit.underlying_id()), start_position, std::greater<iterator>());
|
||||
}
|
||||
|
||||
side_actions::iterator side_actions::find_last_action_of(unit const& unit, side_actions::iterator start_position)
|
||||
side_actions::iterator side_actions::find_last_action_of(const unit& unit, side_actions::iterator start_position)
|
||||
{
|
||||
return find_first_action_of(actions_.get<container::by_unit>().equal_range(unit.underlying_id()), start_position, std::greater<iterator>());
|
||||
}
|
||||
|
||||
side_actions::const_iterator side_actions::find_last_action_of(unit const& unit) const
|
||||
side_actions::const_iterator side_actions::find_last_action_of(const unit& unit) const
|
||||
{
|
||||
if(end() == begin()) {
|
||||
return end();
|
||||
|
@ -581,7 +581,7 @@ side_actions::const_iterator side_actions::find_last_action_of(unit const& unit)
|
|||
return find_last_action_of(unit, end() - 1);
|
||||
}
|
||||
|
||||
side_actions::iterator side_actions::find_last_action_of(unit const& unit)
|
||||
side_actions::iterator side_actions::find_last_action_of(const unit& unit)
|
||||
{
|
||||
if(end() == begin()) {
|
||||
return end();
|
||||
|
@ -589,17 +589,17 @@ side_actions::iterator side_actions::find_last_action_of(unit const& unit)
|
|||
return find_last_action_of(unit, end() - 1);
|
||||
}
|
||||
|
||||
bool side_actions::unit_has_actions(unit const& unit)
|
||||
bool side_actions::unit_has_actions(const unit& unit)
|
||||
{
|
||||
return actions_.get<container::by_unit>().find(unit.underlying_id()) != actions_.get<container::by_unit>().end();
|
||||
}
|
||||
|
||||
size_t side_actions::count_actions_of(unit const& unit)
|
||||
size_t side_actions::count_actions_of(const unit& unit)
|
||||
{
|
||||
return actions_.get<container::by_unit>().count(unit.underlying_id());
|
||||
}
|
||||
|
||||
std::deque<action_ptr> side_actions::actions_of(unit const &target)
|
||||
std::deque<action_ptr> side_actions::actions_of(const unit& target)
|
||||
{
|
||||
typedef container::action_set::index<container::by_unit>::type::iterator unit_iterator;
|
||||
std::pair<unit_iterator, unit_iterator> action_its = actions_.get<container::by_unit>().equal_range(target.underlying_id());
|
||||
|
@ -608,7 +608,7 @@ std::deque<action_ptr> side_actions::actions_of(unit const &target)
|
|||
return actions;
|
||||
}
|
||||
|
||||
size_t side_actions::get_turn_num_of(unit const& u) const
|
||||
size_t side_actions::get_turn_num_of(const unit& u) const
|
||||
{
|
||||
const_iterator itor = find_last_action_of(u);
|
||||
if(itor == end()) {
|
||||
|
@ -664,7 +664,7 @@ side_actions::iterator side_actions::synced_enqueue(size_t turn_num, action_ptr
|
|||
return result;
|
||||
}
|
||||
|
||||
side_actions::iterator side_actions::safe_erase(iterator const& itor)
|
||||
side_actions::iterator side_actions::safe_erase(const iterator& itor)
|
||||
{
|
||||
action_ptr action = *itor;
|
||||
resources::whiteboard->pre_delete_action(action); //misc cleanup
|
||||
|
@ -696,13 +696,13 @@ side_actions::iterator side_actions::queue_recall(size_t turn, const unit& unit,
|
|||
return queue_action(turn, new_recall);
|
||||
}
|
||||
|
||||
side_actions::iterator side_actions::queue_suppose_dead(size_t turn, unit& curr_unit, map_location const& loc)
|
||||
side_actions::iterator side_actions::queue_suppose_dead(size_t turn, unit& curr_unit, const map_location& loc)
|
||||
{
|
||||
suppose_dead_ptr new_suppose_dead(std::make_shared<suppose_dead>(team_index(), hidden_, std::ref(curr_unit), loc));
|
||||
return queue_action(turn, new_suppose_dead);
|
||||
}
|
||||
|
||||
void side_actions::execute_net_cmd(net_cmd const& cmd)
|
||||
void side_actions::execute_net_cmd(const net_cmd& cmd)
|
||||
{
|
||||
std::string type = cmd["type"];
|
||||
|
||||
|
@ -792,7 +792,7 @@ void side_actions::execute_net_cmd(net_cmd const& cmd)
|
|||
} else if(type=="refresh") {
|
||||
LOG_WB << "Command received: refresh\n";
|
||||
clear();
|
||||
for(net_cmd const& sub_cmd : cmd.child_range("net_cmd"))
|
||||
for(const net_cmd& sub_cmd : cmd.child_range("net_cmd"))
|
||||
execute_net_cmd(sub_cmd);
|
||||
} else {
|
||||
ERR_WB << "side_actions::execute_network_command(): received invalid type!" << std::endl;
|
||||
|
@ -811,7 +811,7 @@ side_actions::net_cmd side_actions::make_net_cmd_insert(size_t turn_num, size_t
|
|||
result.add_child("action", act->to_config());
|
||||
return result;
|
||||
}
|
||||
side_actions::net_cmd side_actions::make_net_cmd_insert(const_iterator const& pos, action_const_ptr act) const
|
||||
side_actions::net_cmd side_actions::make_net_cmd_insert(const const_iterator& pos, action_const_ptr act) const
|
||||
{
|
||||
if(pos == begin()) {
|
||||
return make_net_cmd_insert(0,0,act);
|
||||
|
@ -820,7 +820,7 @@ side_actions::net_cmd side_actions::make_net_cmd_insert(const_iterator const& po
|
|||
return make_net_cmd_insert(get_turn(prec), actions_.position_in_turn(prec)+1, act);
|
||||
}
|
||||
}
|
||||
side_actions::net_cmd side_actions::make_net_cmd_replace(const_iterator const& pos, action_const_ptr act) const
|
||||
side_actions::net_cmd side_actions::make_net_cmd_replace(const const_iterator& pos, action_const_ptr act) const
|
||||
{
|
||||
net_cmd result;
|
||||
result["type"] = "replace";
|
||||
|
@ -829,7 +829,7 @@ side_actions::net_cmd side_actions::make_net_cmd_replace(const_iterator const& p
|
|||
result.add_child("action", act->to_config());
|
||||
return result;
|
||||
}
|
||||
side_actions::net_cmd side_actions::make_net_cmd_remove(const_iterator const& pos) const
|
||||
side_actions::net_cmd side_actions::make_net_cmd_remove(const const_iterator& pos) const
|
||||
{
|
||||
net_cmd result;
|
||||
result["type"] = "remove";
|
||||
|
@ -837,7 +837,7 @@ side_actions::net_cmd side_actions::make_net_cmd_remove(const_iterator const& po
|
|||
result["pos"] = static_cast<int>(actions_.position_in_turn(pos));
|
||||
return result;
|
||||
}
|
||||
side_actions::net_cmd side_actions::make_net_cmd_bump_later(const_iterator const& pos) const
|
||||
side_actions::net_cmd side_actions::make_net_cmd_bump_later(const const_iterator& pos) const
|
||||
{
|
||||
net_cmd result;
|
||||
result["type"] = "bump_later";
|
||||
|
@ -867,7 +867,7 @@ void side_actions::raw_turn_shift()
|
|||
{
|
||||
//find units who still have plans for turn 0 (i.e. were too lazy to finish their jobs)
|
||||
std::set<unit_const_ptr> lazy_units;
|
||||
for(action_ptr const& act : iter_turn(0)) {
|
||||
for(const action_ptr& act : iter_turn(0)) {
|
||||
unit_const_ptr u = act->get_unit();
|
||||
if(u) {
|
||||
lazy_units.insert(u);
|
||||
|
|
|
@ -159,7 +159,7 @@ public:
|
|||
template <typename T>
|
||||
typename action_set::index<T>::type& get(){ return actions_.get<T>(); }
|
||||
template <typename T>
|
||||
typename action_set::index<T>::type const& get() const { return actions_.get<T>(); }
|
||||
typename const action_set::index<T>::type& get() const { return actions_.get<T>(); }
|
||||
|
||||
/**
|
||||
* Projects an iterator on a given index.
|
||||
|
@ -252,7 +252,7 @@ public:
|
|||
size_t turn_size(size_t turn_num) const { return turn_end(turn_num) - turn_begin(turn_num); }
|
||||
|
||||
/** Get the underlying action container */
|
||||
action_set const& actions() const { return actions_; }
|
||||
const action_set& actions() const { return actions_; }
|
||||
|
||||
|
||||
private:
|
||||
|
@ -464,25 +464,25 @@ public:
|
|||
* Finds the first action that belongs to this unit, starting the search at the specified position.
|
||||
* @return The position, or end() if not found.
|
||||
*/
|
||||
iterator find_first_action_of(unit const& unit, iterator start_position);
|
||||
iterator find_first_action_of(const unit& unit, iterator start_position);
|
||||
/** Variant of this method that always start searching at the beginning of the queue */
|
||||
iterator find_first_action_of(unit const& unit){ return find_first_action_of(unit, begin()); }
|
||||
iterator find_first_action_of(const unit& unit){ return find_first_action_of(unit, begin()); }
|
||||
|
||||
/**
|
||||
* Finds the last action that belongs to this unit, starting the search backwards from the specified position.
|
||||
* @return The position, or end() if not found.
|
||||
*/
|
||||
iterator find_last_action_of(unit const& unit, iterator start_position);
|
||||
iterator find_last_action_of(const unit& unit, iterator start_position);
|
||||
/** const variant of the previous function */
|
||||
const_iterator find_last_action_of(unit const& unit, const_iterator start_position) const;
|
||||
const_iterator find_last_action_of(const unit& unit, const_iterator start_position) const;
|
||||
/** Variant of the previous method that always start searching at the end of the queue */
|
||||
iterator find_last_action_of(unit const& unit);
|
||||
iterator find_last_action_of(const unit& unit);
|
||||
/** const variant of the previous function */
|
||||
const_iterator find_last_action_of(unit const& unit) const;
|
||||
const_iterator find_last_action_of(const unit& unit) const;
|
||||
|
||||
bool unit_has_actions(unit const& unit);
|
||||
size_t count_actions_of(unit const& unit);
|
||||
std::deque<action_ptr> actions_of(unit const& unit);
|
||||
bool unit_has_actions(const unit& unit);
|
||||
size_t count_actions_of(const unit& unit);
|
||||
std::deque<action_ptr> actions_of(const unit& unit);
|
||||
|
||||
/**
|
||||
* Determines the appropriate turn number for the next action planned for this unit
|
||||
|
@ -491,7 +491,7 @@ public:
|
|||
*
|
||||
* @retval 0 if the unit doesn't have any planned action
|
||||
*/
|
||||
size_t get_turn_num_of(unit const&) const;
|
||||
size_t get_turn_num_of(const unit&) const;
|
||||
|
||||
/** Used to track gold spending by recruits/recalls when building the future unit map */
|
||||
int get_gold_spent() const { return gold_spent_; }
|
||||
|
@ -533,7 +533,7 @@ public:
|
|||
* Queues a suppose_dead to be executed last
|
||||
* @return The queued suppose_dead's position (an iterator to it)
|
||||
*/
|
||||
iterator queue_suppose_dead(size_t turn_num, unit& curr_unit, map_location const& loc);
|
||||
iterator queue_suppose_dead(size_t turn_num, unit& curr_unit, const map_location& loc);
|
||||
|
||||
/**
|
||||
* Network code. A net_cmd object (a config in disguise) represents a modification
|
||||
|
@ -542,12 +542,12 @@ public:
|
|||
* convenient for building specific types of net_cmds.
|
||||
*/
|
||||
typedef config net_cmd;
|
||||
void execute_net_cmd(net_cmd const&);
|
||||
void execute_net_cmd(const net_cmd&);
|
||||
net_cmd make_net_cmd_insert(size_t turn_num, size_t pos, action_const_ptr) const;
|
||||
net_cmd make_net_cmd_insert(const_iterator const& pos, action_const_ptr) const;
|
||||
net_cmd make_net_cmd_replace(const_iterator const& pos, action_const_ptr) const;
|
||||
net_cmd make_net_cmd_remove(const_iterator const& pos) const;
|
||||
net_cmd make_net_cmd_bump_later(const_iterator const& pos) const;
|
||||
net_cmd make_net_cmd_insert(const const_iterator& pos, action_const_ptr) const;
|
||||
net_cmd make_net_cmd_replace(const const_iterator& pos, action_const_ptr) const;
|
||||
net_cmd make_net_cmd_remove(const const_iterator& pos) const;
|
||||
net_cmd make_net_cmd_bump_later(const const_iterator& pos) const;
|
||||
net_cmd make_net_cmd_clear() const;
|
||||
net_cmd make_net_cmd_refresh() const;
|
||||
|
||||
|
@ -556,7 +556,7 @@ private:
|
|||
iterator synced_erase(iterator itor);
|
||||
iterator synced_insert(iterator itor, action_ptr to_insert);
|
||||
iterator synced_enqueue(size_t turn_num, action_ptr to_insert);
|
||||
iterator safe_erase(iterator const& itor);
|
||||
iterator safe_erase(const iterator& itor);
|
||||
|
||||
container actions_;
|
||||
|
||||
|
@ -570,7 +570,7 @@ private:
|
|||
};
|
||||
|
||||
/** Dumps side_actions on a stream, for debug purposes. */
|
||||
std::ostream& operator<<(std::ostream &out, wb::side_actions const &side_actions);
|
||||
std::ostream& operator<<(std::ostream &out, const wb::side_actions& side_actions);
|
||||
|
||||
struct side_actions::numbers_t
|
||||
{
|
||||
|
|
|
@ -57,7 +57,7 @@ std::ostream& suppose_dead::print(std::ostream &s) const
|
|||
return s;
|
||||
}
|
||||
|
||||
suppose_dead::suppose_dead(size_t team_index, bool hidden, unit& curr_unit, map_location const& loc)
|
||||
suppose_dead::suppose_dead(size_t team_index, bool hidden, unit& curr_unit, const map_location& loc)
|
||||
: action(team_index,hidden)
|
||||
, unit_underlying_id_(curr_unit.underlying_id())
|
||||
, unit_id_(curr_unit.id())
|
||||
|
@ -66,7 +66,7 @@ suppose_dead::suppose_dead(size_t team_index, bool hidden, unit& curr_unit, map_
|
|||
this->init();
|
||||
}
|
||||
|
||||
suppose_dead::suppose_dead(config const& cfg, bool hidden)
|
||||
suppose_dead::suppose_dead(const config& cfg, bool hidden)
|
||||
: action(cfg,hidden)
|
||||
, unit_underlying_id_(0)
|
||||
, unit_id_()
|
||||
|
|
|
@ -29,8 +29,8 @@ namespace wb {
|
|||
class suppose_dead: public action
|
||||
{
|
||||
public:
|
||||
suppose_dead(size_t team_index, bool hidden, unit& curr_unit, map_location const& loc);
|
||||
suppose_dead(config const&, bool hidden); // For deserialization
|
||||
suppose_dead(size_t team_index, bool hidden, unit& curr_unit, const map_location& loc);
|
||||
suppose_dead(const config&, bool hidden); // For deserialization
|
||||
virtual ~suppose_dead();
|
||||
|
||||
/** Return the unit targeted by this action. Null if unit doesn't exist. */
|
||||
|
|
|
@ -76,7 +76,7 @@ unit_const_ptr find_backup_leader(const unit & leader)
|
|||
return unit_const_ptr();
|
||||
}
|
||||
|
||||
unit* find_recruiter(size_t team_index, map_location const& hex)
|
||||
unit* find_recruiter(size_t team_index, const map_location& hex)
|
||||
{
|
||||
if ( !resources::gameboard->map().is_castle(hex) )
|
||||
return nullptr;
|
||||
|
@ -110,20 +110,20 @@ unit* future_visible_unit(int on_side, map_location hex, int viewer_side)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
int path_cost(std::vector<map_location> const& path, unit const& u)
|
||||
int path_cost(const std::vector<map_location>& path, const unit& u)
|
||||
{
|
||||
if(path.size() < 2)
|
||||
return 0;
|
||||
|
||||
team const& u_team = resources::gameboard->get_team(u.side());
|
||||
map_location const& dest = path.back();
|
||||
const team& u_team = resources::gameboard->get_team(u.side());
|
||||
const map_location& dest = path.back();
|
||||
if ( (resources::gameboard->map().is_village(dest) && !u_team.owns_village(dest))
|
||||
|| pathfind::enemy_zoc(u_team, dest, u_team) )
|
||||
return u.total_movement();
|
||||
|
||||
int result = 0;
|
||||
gamemap const& map = resources::gameboard->map();
|
||||
for(map_location const& loc : std::make_pair(path.begin()+1,path.end())) {
|
||||
const gamemap& map = resources::gameboard->map();
|
||||
for(const map_location& loc : std::make_pair(path.begin()+1,path.end())) {
|
||||
result += u.movement_cost(map[loc]);
|
||||
}
|
||||
return result;
|
||||
|
@ -207,7 +207,7 @@ action_ptr find_action_at(map_location hex, team_filter team_filter)
|
|||
return result;
|
||||
}
|
||||
|
||||
std::deque<action_ptr> find_actions_of(unit const &target)
|
||||
std::deque<action_ptr> find_actions_of(const unit& target)
|
||||
{
|
||||
return resources::gameboard->get_team(target.side()).get_side_actions()->actions_of(target);
|
||||
}
|
||||
|
|
|
@ -46,13 +46,13 @@ side_actions_ptr current_side_actions();
|
|||
* For a given leader on a keep, find another leader on another keep in the same castle.
|
||||
* @retval nullptr if no such leader has been found
|
||||
*/
|
||||
unit_const_ptr find_backup_leader(unit const& leader);
|
||||
unit_const_ptr find_backup_leader(const unit& leader);
|
||||
|
||||
/**
|
||||
* @return a leader from the specified team who can recruit on the specified hex
|
||||
* @retval nullptr if no such leader has been found
|
||||
*/
|
||||
unit* find_recruiter(size_t team_index, map_location const&);
|
||||
unit* find_recruiter(size_t team_index, const map_location&);
|
||||
|
||||
/// Applies the future unit map and @return a pointer to the unit at hex
|
||||
/// @retval nullptr if none is visible to the specified viewer side
|
||||
|
@ -64,7 +64,7 @@ unit* future_visible_unit(map_location hex, int viewer_side = wb::viewer_side())
|
|||
unit* future_visible_unit(int on_side, map_location hex, int viewer_side = wb::viewer_side());
|
||||
|
||||
/// Computes the MP cost for u to travel path
|
||||
int path_cost(std::vector<map_location> const& path, unit const& u);
|
||||
int path_cost(const std::vector<map_location>& path, const unit& u);
|
||||
|
||||
struct temporary_unit_hider {
|
||||
temporary_unit_hider(unit& u);
|
||||
|
@ -145,6 +145,6 @@ action_ptr find_action_at(map_location hex, team_filter team_filter = team_has_v
|
|||
*
|
||||
* @param target the unit owning the actions.
|
||||
*/
|
||||
std::deque<action_ptr> find_actions_of(unit const &target);
|
||||
std::deque<action_ptr> find_actions_of(const unit& target);
|
||||
|
||||
} //end namespace wb
|
||||
|
|
|
@ -208,7 +208,7 @@ void button::calculate_size()
|
|||
set_location(loc_image);
|
||||
return;
|
||||
}
|
||||
SDL_Rect const &loc = location();
|
||||
const SDL_Rect& loc = location();
|
||||
bool change_size = loc.h == 0 || loc.w == 0;
|
||||
|
||||
if (!change_size) {
|
||||
|
@ -328,7 +328,7 @@ void button::draw_contents()
|
|||
break;
|
||||
}
|
||||
|
||||
SDL_Rect const &loc = location();
|
||||
const SDL_Rect& loc = location();
|
||||
SDL_Rect clipArea = loc;
|
||||
const int texty = loc.y + loc.h / 2 - textRect_.h / 2 + offset;
|
||||
int textx;
|
||||
|
@ -437,7 +437,7 @@ void button::set_label(const std::string& val)
|
|||
set_dirty(true);
|
||||
}
|
||||
|
||||
void button::mouse_motion(SDL_MouseMotionEvent const &event)
|
||||
void button::mouse_motion(const SDL_MouseMotionEvent& event)
|
||||
{
|
||||
if (hit(event.x, event.y)) {
|
||||
// the cursor is over the widget
|
||||
|
@ -471,7 +471,7 @@ void button::mouse_motion(SDL_MouseMotionEvent const &event)
|
|||
}
|
||||
}
|
||||
|
||||
void button::mouse_down(SDL_MouseButtonEvent const &event)
|
||||
void button::mouse_down(const SDL_MouseButtonEvent& event)
|
||||
{
|
||||
if (hit(event.x, event.y) && event.button == SDL_BUTTON_LEFT) {
|
||||
|
||||
|
@ -499,7 +499,7 @@ void button::release(){
|
|||
draw_contents();
|
||||
}
|
||||
|
||||
void button::mouse_up(SDL_MouseButtonEvent const &event)
|
||||
void button::mouse_up(const SDL_MouseButtonEvent& event)
|
||||
{
|
||||
if (!(hit(event.x, event.y) && event.button == SDL_BUTTON_LEFT))
|
||||
return;
|
||||
|
|
|
@ -352,7 +352,7 @@ void menu::update_size()
|
|||
}
|
||||
|
||||
use_ellipsis_ = false;
|
||||
std::vector<int> const &widths = column_widths();
|
||||
const std::vector<int>& widths = column_widths();
|
||||
int w = std::accumulate(widths.begin(), widths.end(), 0);
|
||||
if (items_.size() > max_items_onscreen())
|
||||
w += scrollbar_width();
|
||||
|
@ -375,7 +375,7 @@ int menu::selection() const
|
|||
return items_[selected_].id;
|
||||
}
|
||||
|
||||
void menu::set_inner_location(SDL_Rect const &rect)
|
||||
void menu::set_inner_location(const SDL_Rect& rect)
|
||||
{
|
||||
itemRects_.clear();
|
||||
update_scrollbar_grip_height();
|
||||
|
@ -912,8 +912,8 @@ void menu::draw_row(const size_t row_index, const SDL_Rect& rect, ROW_TYPE type)
|
|||
{
|
||||
//called from style, draws one row's contents in a generic and adaptable way
|
||||
const std::vector<std::string>& row = (type == HEADING_ROW) ? heading_ : items_[row_index].fields;
|
||||
SDL_Rect const &area = video().screen_area();
|
||||
SDL_Rect const &loc = inner_location();
|
||||
const SDL_Rect& area = video().screen_area();
|
||||
const SDL_Rect& loc = inner_location();
|
||||
const std::vector<int>& widths = column_widths();
|
||||
bool lang_rtl = current_language_rtl();
|
||||
int dir = (lang_rtl) ? -1 : 1;
|
||||
|
@ -1060,7 +1060,7 @@ void menu::draw()
|
|||
|
||||
int menu::hit(int x, int y) const
|
||||
{
|
||||
SDL_Rect const &loc = inner_location();
|
||||
const SDL_Rect& loc = inner_location();
|
||||
if (x >= loc.x && x < loc.x + loc.w && y >= loc.y && y < loc.y + loc.h) {
|
||||
for(size_t i = 0; i != items_.size(); ++i) {
|
||||
const SDL_Rect& rect = get_item_rect(i);
|
||||
|
@ -1074,7 +1074,7 @@ int menu::hit(int x, int y) const
|
|||
|
||||
int menu::hit_column(int x) const
|
||||
{
|
||||
std::vector<int> const &widths = column_widths();
|
||||
const std::vector<int>& widths = column_widths();
|
||||
int j = -1, j_end = widths.size();
|
||||
for(x -= location().x; x >= 0; x -= widths[j]) {
|
||||
if(++j == j_end) {
|
||||
|
@ -1127,7 +1127,7 @@ SDL_Rect menu::get_item_rect_internal(size_t item) const
|
|||
if(i != itemRects_.end())
|
||||
return i->second;
|
||||
|
||||
SDL_Rect const &loc = inner_location();
|
||||
const SDL_Rect& loc = inner_location();
|
||||
|
||||
int y = loc.y + heading_height();
|
||||
if (item != first_item_on_screen) {
|
||||
|
@ -1137,7 +1137,7 @@ SDL_Rect menu::get_item_rect_internal(size_t item) const
|
|||
|
||||
SDL_Rect res = sdl::create_rect(loc.x, y, loc.w, get_item_height(item));
|
||||
|
||||
SDL_Rect const &screen_area = video().screen_area();
|
||||
const SDL_Rect& screen_area = video().screen_area();
|
||||
|
||||
if(res.x > screen_area.w) {
|
||||
return sdl::empty_rect;
|
||||
|
|
|
@ -42,7 +42,7 @@ sdl_handler_vector scrollarea::handler_members()
|
|||
return h;
|
||||
}
|
||||
|
||||
void scrollarea::update_location(SDL_Rect const &rect)
|
||||
void scrollarea::update_location(const SDL_Rect& rect)
|
||||
{
|
||||
SDL_Rect r = rect;
|
||||
shown_scrollbar_ = has_scrollbar();
|
||||
|
|
|
@ -35,11 +35,11 @@ public:
|
|||
|
||||
protected:
|
||||
virtual sdl_handler_vector handler_members();
|
||||
virtual void update_location(SDL_Rect const &rect);
|
||||
virtual void update_location(const SDL_Rect& rect);
|
||||
virtual void handle_event(const SDL_Event& event);
|
||||
virtual void process_event();
|
||||
virtual void scroll(unsigned int pos) = 0;
|
||||
virtual void set_inner_location(SDL_Rect const &rect) = 0;
|
||||
virtual void set_inner_location(const SDL_Rect& rect) = 0;
|
||||
|
||||
SDL_Rect inner_location() const;
|
||||
unsigned scrollbar_width() const;
|
||||
|
|
|
@ -81,7 +81,7 @@ sdl_handler_vector scrollbar::handler_members()
|
|||
return h;
|
||||
}
|
||||
|
||||
void scrollbar::update_location(SDL_Rect const &rect)
|
||||
void scrollbar::update_location(const SDL_Rect& rect)
|
||||
{
|
||||
int uh = uparrow_.height(), dh = downarrow_.height();
|
||||
uparrow_.set_location(rect.x, rect.y);
|
||||
|
@ -220,7 +220,7 @@ SDL_Rect scrollbar::groove_area() const
|
|||
|
||||
SDL_Rect scrollbar::grip_area() const
|
||||
{
|
||||
SDL_Rect const &loc = groove_area();
|
||||
const SDL_Rect& loc = groove_area();
|
||||
if (full_height_ == grip_height_)
|
||||
return loc;
|
||||
int h = static_cast<int>(loc.h) * grip_height_ / full_height_;
|
||||
|
@ -323,21 +323,21 @@ void scrollbar::handle_event(const SDL_Event& event)
|
|||
return;
|
||||
|
||||
STATE new_state = state_;
|
||||
SDL_Rect const &grip = grip_area();
|
||||
SDL_Rect const &groove = groove_area();
|
||||
const SDL_Rect& grip = grip_area();
|
||||
const SDL_Rect& groove = groove_area();
|
||||
|
||||
|
||||
switch (event.type) {
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
{
|
||||
SDL_MouseButtonEvent const &e = event.button;
|
||||
const SDL_MouseButtonEvent& e = event.button;
|
||||
bool on_grip = sdl::point_in_rect(e.x, e.y, grip);
|
||||
new_state = on_grip ? ACTIVE : NORMAL;
|
||||
break;
|
||||
}
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
{
|
||||
SDL_MouseButtonEvent const &e = event.button;
|
||||
const SDL_MouseButtonEvent& e = event.button;
|
||||
bool on_grip = sdl::point_in_rect(e.x, e.y, grip);
|
||||
bool on_groove = sdl::point_in_rect(e.x, e.y, groove);
|
||||
if (on_grip && e.button == SDL_BUTTON_LEFT) {
|
||||
|
@ -357,7 +357,7 @@ void scrollbar::handle_event(const SDL_Event& event)
|
|||
}
|
||||
case SDL_MOUSEMOTION:
|
||||
{
|
||||
SDL_MouseMotionEvent const &e = event.motion;
|
||||
const SDL_MouseMotionEvent& e = event.motion;
|
||||
if (state_ == NORMAL || state_ == ACTIVE) {
|
||||
bool on_grip = sdl::point_in_rect(e.x, e.y, grip);
|
||||
new_state = on_grip ? ACTIVE : NORMAL;
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
|
||||
protected:
|
||||
virtual sdl_handler_vector handler_members();
|
||||
virtual void update_location(SDL_Rect const &rect);
|
||||
virtual void update_location(const SDL_Rect& rect);
|
||||
virtual void handle_event(const SDL_Event& event);
|
||||
virtual void process_event();
|
||||
virtual void draw_contents();
|
||||
|
|
|
@ -50,14 +50,14 @@ textbox::~textbox()
|
|||
{
|
||||
}
|
||||
|
||||
void textbox::update_location(SDL_Rect const &rect)
|
||||
void textbox::update_location(const SDL_Rect& rect)
|
||||
{
|
||||
scrollarea::update_location(rect);
|
||||
update_text_cache(true);
|
||||
set_dirty(true);
|
||||
}
|
||||
|
||||
void textbox::set_inner_location(SDL_Rect const &rect)
|
||||
void textbox::set_inner_location(const SDL_Rect& rect)
|
||||
{
|
||||
bg_register(rect);
|
||||
if (text_image_.null()) return;
|
||||
|
@ -184,7 +184,7 @@ void textbox::draw_cursor(int pos) const
|
|||
|
||||
void textbox::draw_contents()
|
||||
{
|
||||
SDL_Rect const &loc = inner_location();
|
||||
const SDL_Rect& loc = inner_location();
|
||||
|
||||
surface& surf = video().getSurface();
|
||||
|
||||
|
@ -631,7 +631,7 @@ void textbox::handle_event(const SDL_Event& event, bool was_forwarded)
|
|||
grabmouse_ = false;
|
||||
}
|
||||
|
||||
SDL_Rect const &loc = inner_location();
|
||||
const SDL_Rect& loc = inner_location();
|
||||
bool clicked_inside = !mouse_locked() && (event.type == SDL_MOUSEBUTTONDOWN
|
||||
&& (mousebuttons & SDL_BUTTON(1))
|
||||
&& sdl::point_in_rect(mousex, mousey, loc));
|
||||
|
|
|
@ -50,8 +50,8 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void draw_contents();
|
||||
virtual void update_location(SDL_Rect const &rect);
|
||||
virtual void set_inner_location(SDL_Rect const &);
|
||||
virtual void update_location(const SDL_Rect& rect);
|
||||
virtual void set_inner_location(const SDL_Rect& );
|
||||
virtual void scroll(unsigned int pos);
|
||||
|
||||
private:
|
||||
|
|
|
@ -80,7 +80,7 @@ void widget::bg_cancel()
|
|||
restorer_.clear();
|
||||
}
|
||||
|
||||
void widget::set_location(SDL_Rect const &rect)
|
||||
void widget::set_location(const SDL_Rect& rect)
|
||||
{
|
||||
if(rect_.x == rect.x && rect_.y == rect.y && rect_.w == rect.w && rect_.h == rect.h)
|
||||
return;
|
||||
|
@ -94,7 +94,7 @@ void widget::set_location(SDL_Rect const &rect)
|
|||
update_location(rect);
|
||||
}
|
||||
|
||||
void widget::update_location(SDL_Rect const &rect)
|
||||
void widget::update_location(const SDL_Rect& rect)
|
||||
{
|
||||
bg_register(rect);
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ const SDL_Rect* widget::clip_rect() const
|
|||
return clip_ ? &clip_rect_ : nullptr;
|
||||
}
|
||||
|
||||
void widget::bg_register(SDL_Rect const &rect)
|
||||
void widget::bg_register(const SDL_Rect& rect)
|
||||
{
|
||||
restorer_.emplace_back(&video(), rect);
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ void widget::bg_restore() const
|
|||
}
|
||||
}
|
||||
|
||||
void widget::bg_restore(SDL_Rect const &rect) const
|
||||
void widget::bg_restore(const SDL_Rect& rect) const
|
||||
{
|
||||
clip_rect_setter clipper(video().getSurface(), &clip_rect_, clip_);
|
||||
|
||||
|
@ -335,14 +335,14 @@ void widget::process_tooltip_string(int mousex, int mousey)
|
|||
}
|
||||
}
|
||||
|
||||
void widget::handle_event(SDL_Event const &event) {
|
||||
void widget::handle_event(const SDL_Event& event) {
|
||||
if (event.type == DRAW_ALL_EVENT) {
|
||||
set_dirty();
|
||||
draw();
|
||||
}
|
||||
}
|
||||
|
||||
void widget::handle_window_event(SDL_Event const &event) {
|
||||
void widget::handle_window_event(const SDL_Event& event) {
|
||||
if (event.type == SDL_WINDOWEVENT) {
|
||||
switch (event.window.event) {
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
|
|
|
@ -26,8 +26,8 @@ namespace gui {
|
|||
class widget : public events::sdl_handler
|
||||
{
|
||||
public:
|
||||
SDL_Rect const &location() const;
|
||||
virtual void set_location(SDL_Rect const &rect);
|
||||
const SDL_Rect& location() const;
|
||||
virtual void set_location(const SDL_Rect& rect);
|
||||
void set_location(int x, int y);
|
||||
void set_width(int w);
|
||||
void set_height(int h);
|
||||
|
@ -69,15 +69,15 @@ public:
|
|||
virtual void process_tooltip_string(int mousex, int mousey);
|
||||
|
||||
protected:
|
||||
widget(widget const &o);
|
||||
widget(const widget& o);
|
||||
widget(CVideo& video, const bool auto_join=true);
|
||||
virtual ~widget();
|
||||
|
||||
// During each relocation, this function should be called to register
|
||||
// the rectangles the widget needs to refresh automatically
|
||||
void bg_register(SDL_Rect const &rect);
|
||||
void bg_register(const SDL_Rect& rect);
|
||||
void bg_restore() const;
|
||||
void bg_restore(SDL_Rect const &rect) const;
|
||||
void bg_restore(const SDL_Rect& rect) const;
|
||||
void bg_update();
|
||||
void bg_cancel();
|
||||
|
||||
|
@ -87,13 +87,13 @@ public:
|
|||
virtual void draw();
|
||||
protected:
|
||||
virtual void draw_contents() {}
|
||||
virtual void update_location(SDL_Rect const &rect);
|
||||
virtual void update_location(const SDL_Rect& rect);
|
||||
|
||||
const SDL_Rect* clip_rect() const;
|
||||
virtual sdl_handler_vector member_handlers() { return sdl_handler::handler_members(); }
|
||||
|
||||
virtual void handle_event(SDL_Event const &);
|
||||
virtual void handle_window_event(SDL_Event const &event);
|
||||
virtual void handle_event(const SDL_Event&);
|
||||
virtual void handle_window_event(const SDL_Event& event);
|
||||
bool focus_; // Should user input be ignored?
|
||||
|
||||
bool mouse_locked() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue