Add const to some more functions
This commit is contained in:
parent
343eb9ab1b
commit
94e73a7ccc
22 changed files with 43 additions and 43 deletions
|
@ -105,7 +105,7 @@ public:
|
|||
msg_label->set_label("");
|
||||
}
|
||||
|
||||
int count_of_pages()
|
||||
int count_of_pages() const
|
||||
{
|
||||
int size = chat_log_history.size();
|
||||
return (size % COUNT_PER_PAGE == 0) ? (size / COUNT_PER_PAGE)
|
||||
|
|
|
@ -102,7 +102,7 @@ class gamestate_inspector::model
|
|||
public:
|
||||
std::string name;
|
||||
|
||||
std::string get_data_full()
|
||||
std::string get_data_full() const
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
@ -251,9 +251,9 @@ protected:
|
|||
gamestate_inspector::model& model();
|
||||
gamestate_inspector::view& view();
|
||||
gamestate_inspector::controller& c;
|
||||
const config& vars();
|
||||
const game_events::manager& events();
|
||||
const display_context& dc();
|
||||
const config& vars() const;
|
||||
const game_events::manager& events() const;
|
||||
const display_context& dc() const;
|
||||
};
|
||||
|
||||
class variable_mode_controller : public single_mode_controller
|
||||
|
@ -495,15 +495,15 @@ gamestate_inspector::view& single_mode_controller::view() {
|
|||
return c.view_;
|
||||
}
|
||||
|
||||
const config& single_mode_controller::vars() {
|
||||
const config& single_mode_controller::vars() const {
|
||||
return c.vars_;
|
||||
}
|
||||
|
||||
const game_events::manager& single_mode_controller::events() {
|
||||
const game_events::manager& single_mode_controller::events() const {
|
||||
return c.events_;
|
||||
}
|
||||
|
||||
const display_context& single_mode_controller::dc() {
|
||||
const display_context& single_mode_controller::dc() const {
|
||||
return c.dc_;
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ game_data & menu_handler::gamedata() { return gamestate().gamedata_; }
|
|||
game_board & menu_handler::board() const { return gamestate().board_; }
|
||||
unit_map& menu_handler::units() { return gamestate().board_.units_; }
|
||||
std::vector<team>& menu_handler::teams() const { return gamestate().board_.teams_; }
|
||||
const gamemap& menu_handler::map() { return gamestate().board_.map(); }
|
||||
const gamemap& menu_handler::map() const { return gamestate().board_.map(); }
|
||||
|
||||
gui::floating_textbox& menu_handler::get_textbox(){
|
||||
return textbox_info_;
|
||||
|
@ -1412,7 +1412,7 @@ void console_handler::do_theme() {
|
|||
struct save_id_matches
|
||||
{
|
||||
save_id_matches(const std::string& save_id) : save_id_(save_id) {}
|
||||
bool operator()(const team& t)
|
||||
bool operator()(const team& t) const
|
||||
{
|
||||
return t.save_id() == save_id_;
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ private:
|
|||
game_board & board() const;
|
||||
unit_map& units();
|
||||
std::vector<team>& teams() const;
|
||||
const gamemap& map();
|
||||
const gamemap& map() const;
|
||||
|
||||
const config& game_config_;
|
||||
|
||||
|
|
|
@ -168,8 +168,8 @@ public:
|
|||
* Called when the middle click scrolling
|
||||
*/
|
||||
void set_scroll_start (int x, int y) { scroll_start_x_ = x; scroll_start_y_ = y; }
|
||||
const SDL_Point get_scroll_start() { return{ scroll_start_x_, scroll_start_y_ }; }
|
||||
bool scroll_started() { return scroll_started_; }
|
||||
const SDL_Point get_scroll_start() const { return{ scroll_start_x_, scroll_start_y_ }; }
|
||||
bool scroll_started() const { return scroll_started_; }
|
||||
|
||||
protected:
|
||||
void cancel_dragging();
|
||||
|
|
|
@ -122,7 +122,7 @@ class comp {
|
|||
|
||||
public:
|
||||
comp(const std::vector<node>& n) : nodes_(n) { }
|
||||
bool operator()(int a, int b) {
|
||||
bool operator()(int a, int b) const {
|
||||
return nodes_[b] < nodes_[a];
|
||||
}
|
||||
};
|
||||
|
@ -132,7 +132,7 @@ class indexer {
|
|||
|
||||
public:
|
||||
indexer(size_t w) : w_(w) { }
|
||||
size_t operator()(const map_location& loc) {
|
||||
size_t operator()(const map_location& loc) const {
|
||||
return loc.y * w_ + loc.x;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -385,7 +385,7 @@ const std::vector<chat_msg>& replay::build_chat_log() const
|
|||
return message_log;
|
||||
}
|
||||
|
||||
config replay::get_data_range(int cmd_start, int cmd_end, DATA_TYPE data_type)
|
||||
config replay::get_data_range(int cmd_start, int cmd_end, DATA_TYPE data_type) const
|
||||
{
|
||||
config res;
|
||||
|
||||
|
@ -624,7 +624,7 @@ void replay::set_to_end()
|
|||
base_->set_to_end();
|
||||
}
|
||||
|
||||
bool replay::empty()
|
||||
bool replay::empty() const
|
||||
{
|
||||
return ncommands() == 0;
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ public:
|
|||
//undoable data includes moves such as placing a label or speaking, which is
|
||||
//ignored by the undo system.
|
||||
enum DATA_TYPE { ALL_DATA, NON_UNDO_DATA };
|
||||
config get_data_range(int cmd_start, int cmd_end, DATA_TYPE data_type=ALL_DATA);
|
||||
config get_data_range(int cmd_start, int cmd_end, DATA_TYPE data_type=ALL_DATA) const;
|
||||
|
||||
void undo();
|
||||
/*
|
||||
|
@ -117,7 +117,7 @@ public:
|
|||
bool at_end() const;
|
||||
void set_to_end();
|
||||
|
||||
bool empty();
|
||||
bool empty() const;
|
||||
|
||||
enum MARK_SENT { MARK_AS_UNSENT, MARK_AS_SENT };
|
||||
void add_config(const config& cfg, MARK_SENT mark=MARK_AS_UNSENT);
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
bool can_execute_command(const hotkey::hotkey_command& cmd, int index) const;
|
||||
bool is_controlling_view() const { return vision_.is_initialized(); }
|
||||
bool allow_reset_replay() const { return reset_state_.get() != nullptr; }
|
||||
const std::shared_ptr<config>& get_reset_state() { return reset_state_; };
|
||||
const std::shared_ptr<config>& get_reset_state() const { return reset_state_; };
|
||||
void return_to_play_side(bool r = true) { return_to_play_side_ = r; }
|
||||
void replay_show_everything();
|
||||
void replay_show_each();
|
||||
|
|
|
@ -449,7 +449,7 @@ void saved_game::expand_carryover()
|
|||
}
|
||||
}
|
||||
|
||||
bool saved_game::valid()
|
||||
bool saved_game::valid() const
|
||||
{
|
||||
return this->starting_pos_type_ != STARTINGPOS_INVALID;
|
||||
}
|
||||
|
|
|
@ -79,13 +79,13 @@ public:
|
|||
/// takes care of generate_map=, generate_scenario=, map= attributes
|
||||
/// This should be called before expanding carryover or mp_events because this might completely replace starting_pos_.
|
||||
void expand_random_scenario();
|
||||
bool valid();
|
||||
bool valid() const;
|
||||
/// @return the snapshot in the savefile (get_starting_pos)
|
||||
config& set_snapshot(config snapshot);
|
||||
void set_scenario(config scenario);
|
||||
void remove_snapshot();
|
||||
|
||||
bool is_mid_game_save()
|
||||
bool is_mid_game_save() const
|
||||
{
|
||||
return starting_pos_type_ == STARTINGPOS_SNAPSHOT;
|
||||
}
|
||||
|
|
|
@ -191,8 +191,8 @@ protected:
|
|||
/** Customize the standard error message */
|
||||
void set_error_message(const std::string& error_message) { error_message_ = error_message; }
|
||||
|
||||
const std::string& title() { return title_; }
|
||||
const saved_game& gamestate() { return gamestate_; }
|
||||
const std::string& title() const { return title_; }
|
||||
const saved_game& gamestate() const { return gamestate_; }
|
||||
|
||||
/** If there needs to be some data fiddling before saving the game, this is the place to go. */
|
||||
void before_save();
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <iostream>
|
||||
|
||||
struct compare_samples_to_stringspan {
|
||||
bool operator()(const simple_wml::string_span& a, const simple_wml::string_span& b)
|
||||
bool operator()(const simple_wml::string_span& a, const simple_wml::string_span& b) const
|
||||
{
|
||||
return a < b;
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ positional_source::~positional_source()
|
|||
sound::reposition_sound(id_, DISTANCE_SILENT);
|
||||
}
|
||||
|
||||
bool positional_source::is_global()
|
||||
bool positional_source::is_global() const
|
||||
{
|
||||
return locations_.empty();
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
positional_source(const sourcespec &spec);
|
||||
~positional_source();
|
||||
|
||||
bool is_global();
|
||||
bool is_global() const;
|
||||
|
||||
void update(unsigned int time, const display &disp);
|
||||
void update_positions(unsigned int time, const display &disp);
|
||||
|
|
|
@ -94,17 +94,17 @@ class user_choice_manager : events::pump_monitor
|
|||
void search_in_replay();
|
||||
public:
|
||||
void pull();
|
||||
bool finished()
|
||||
bool finished() const
|
||||
{ return required_.size() == res_.size(); }
|
||||
bool has_local_choice()
|
||||
bool has_local_choice() const
|
||||
{ return local_choice_ != 0; }
|
||||
/// Note: currently finished() does not imply !waiting() so you may need to check both.
|
||||
bool waiting()
|
||||
bool waiting() const
|
||||
{ return local_choice_ == 0 && !oos_; }
|
||||
void update_local_choice();
|
||||
void ask_local_choice();
|
||||
void fix_oos();
|
||||
const std::string& wait_message() { return wait_message_; }
|
||||
const std::string& wait_message() const { return wait_message_; }
|
||||
/// @param name: the tagname for this user choice in the replay
|
||||
/// @param sides: an array of team numbers (beginning with 1). the specified sides may not have an empty controller.
|
||||
static std::map<int, config> get_user_choice_internal(const std::string &name, const mp_sync::user_choice &uch, const std::set<int>& sides);
|
||||
|
|
|
@ -91,7 +91,7 @@ terrain_filter::terrain_filter_cache::terrain_filter_cache() :
|
|||
|
||||
namespace {
|
||||
struct cfg_isor {
|
||||
bool operator() (std::pair<const std::string,const vconfig> val) {
|
||||
bool operator() (std::pair<const std::string,const vconfig> val) const {
|
||||
return val.first == "or";
|
||||
}
|
||||
};
|
||||
|
|
|
@ -516,7 +516,7 @@ bool tod_manager::next_turn(game_data* vars)
|
|||
}
|
||||
|
||||
|
||||
bool tod_manager::is_time_left()
|
||||
bool tod_manager::is_time_left() const
|
||||
{
|
||||
return num_turns_ == -1 || turn_ <= num_turns_;
|
||||
}
|
||||
|
|
|
@ -171,12 +171,12 @@ class tod_manager
|
|||
*
|
||||
* @returns True if time has not expired.
|
||||
*/
|
||||
bool is_time_left();
|
||||
bool has_turn_event_fired()
|
||||
bool is_time_left() const;
|
||||
bool has_turn_event_fired() const
|
||||
{ return has_turn_event_fired_; }
|
||||
void turn_event_fired()
|
||||
{ has_turn_event_fired_ = true; }
|
||||
bool has_tod_bonus_changed()
|
||||
bool has_tod_bonus_changed() const
|
||||
{ return has_tod_bonus_changed_; }
|
||||
private:
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ CVideo::~CVideo()
|
|||
LOG_DP << "called SDL_Quit()\n";
|
||||
}
|
||||
|
||||
bool CVideo::non_interactive()
|
||||
bool CVideo::non_interactive() const
|
||||
{
|
||||
return fake_interactive ? false : (window == nullptr);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
|
||||
static CVideo& get_singleton() { return *singleton_; }
|
||||
|
||||
bool non_interactive();
|
||||
bool non_interactive() const;
|
||||
|
||||
const static int DefaultBpp = 32;
|
||||
|
||||
|
|
|
@ -185,8 +185,8 @@ public:
|
|||
void set_max_height(const int new_max_height);
|
||||
void set_max_width(const int new_max_width);
|
||||
|
||||
int get_max_height() { return max_height_; }
|
||||
int get_max_width() { return max_width_; }
|
||||
int get_max_height() const { return max_height_; }
|
||||
int get_max_width() const { return max_width_; }
|
||||
|
||||
size_t number_of_items() const { return items_.size(); }
|
||||
|
||||
|
@ -203,8 +203,8 @@ public:
|
|||
//this should be changed to a more object-oriented approach
|
||||
void set_sorter(sorter *s);
|
||||
void sort_by(int column);
|
||||
int get_sort_by() {return sortby_;}
|
||||
bool get_sort_reversed() {return sortreversed_;}
|
||||
int get_sort_by() const {return sortby_;}
|
||||
bool get_sort_reversed() const {return sortreversed_;}
|
||||
|
||||
protected:
|
||||
bool item_ends_with_image(const std::string& item) const;
|
||||
|
|
Loading…
Add table
Reference in a new issue