Make every possible param a const reference
This is important for performance. If a parameter doesn't have to be modified, it should be a constant reference to the original.
This commit is contained in:
parent
0ed106c4e2
commit
fe5296aefd
192 changed files with 466 additions and 466 deletions
|
@ -77,7 +77,7 @@ battle_context_unit_stats::battle_context_unit_stats(nonempty_unit_const_ptr up,
|
|||
bool attacking,
|
||||
nonempty_unit_const_ptr oppp,
|
||||
const map_location& opp_loc,
|
||||
const_attack_ptr opp_weapon)
|
||||
const const_attack_ptr& opp_weapon)
|
||||
: weapon(nullptr)
|
||||
, attack_num(u_attack_num)
|
||||
, is_attacker(attacking)
|
||||
|
@ -229,7 +229,7 @@ battle_context_unit_stats::battle_context_unit_stats(const unit_type* u_type,
|
|||
const_attack_ptr att_weapon,
|
||||
bool attacking,
|
||||
const unit_type* opp_type,
|
||||
const_attack_ptr opp_weapon,
|
||||
const const_attack_ptr& opp_weapon,
|
||||
unsigned int opp_terrain_defense,
|
||||
int lawful_bonus)
|
||||
: weapon(att_weapon)
|
||||
|
@ -523,7 +523,7 @@ bool battle_context::better_combat(const combatant& us_a,
|
|||
}
|
||||
|
||||
battle_context battle_context::choose_attacker_weapon(nonempty_unit_const_ptr attacker,
|
||||
nonempty_unit_const_ptr defender,
|
||||
const nonempty_unit_const_ptr& defender,
|
||||
const map_location& attacker_loc,
|
||||
const map_location& defender_loc,
|
||||
double harm_weight,
|
||||
|
|
|
@ -85,14 +85,14 @@ struct battle_context_unit_stats
|
|||
bool attacking,
|
||||
nonempty_unit_const_ptr opp,
|
||||
const map_location& opp_loc,
|
||||
const_attack_ptr opp_weapon);
|
||||
const const_attack_ptr& opp_weapon);
|
||||
|
||||
/** Used by AI for combat analysis, and by statistics_dialog */
|
||||
battle_context_unit_stats(const unit_type* u_type,
|
||||
const_attack_ptr att_weapon,
|
||||
bool attacking,
|
||||
const unit_type* opp_type,
|
||||
const_attack_ptr opp_weapon,
|
||||
const const_attack_ptr& opp_weapon,
|
||||
unsigned int opp_terrain_defense,
|
||||
int lawful_bonus = 0);
|
||||
|
||||
|
@ -227,7 +227,7 @@ private:
|
|||
int defender_weapon);
|
||||
|
||||
static battle_context choose_attacker_weapon(nonempty_unit_const_ptr attacker,
|
||||
nonempty_unit_const_ptr defender,
|
||||
const nonempty_unit_const_ptr& defender,
|
||||
const map_location& attacker_loc,
|
||||
const map_location& defender_loc,
|
||||
double harm_weight,
|
||||
|
|
|
@ -127,7 +127,7 @@ namespace { // Helpers for get_recalls()
|
|||
* that can be skipped (because they are already in @a result), and the
|
||||
* underlying ID of units added to @a result will be added to @a already_added.
|
||||
*/
|
||||
void add_leader_filtered_recalls(const unit_const_ptr leader,
|
||||
void add_leader_filtered_recalls(const unit_const_ptr& leader,
|
||||
std::vector< unit_const_ptr > & result,
|
||||
std::set<std::size_t> * already_added = nullptr)
|
||||
{
|
||||
|
@ -617,7 +617,7 @@ namespace { // Helpers for place_recruit()
|
|||
}
|
||||
}// anonymous namespace
|
||||
//Used by recalls and recruits
|
||||
place_recruit_result place_recruit(unit_ptr u, const map_location &recruit_location, const map_location& recruited_from,
|
||||
place_recruit_result place_recruit(const unit_ptr& u, const map_location &recruit_location, const map_location& recruited_from,
|
||||
int cost, bool is_recall, map_location::direction facing, bool show, bool fire_event, bool full_movement,
|
||||
bool wml_triggered)
|
||||
{
|
||||
|
|
|
@ -158,7 +158,7 @@ typedef std::tuple<bool /*event modified*/, int /*previous village owner side*/,
|
|||
* @param wml_triggered whether this was triggered via WML.
|
||||
* @returns true if an event (or fog clearing) has mutated the game state.
|
||||
*/
|
||||
place_recruit_result place_recruit(unit_ptr u, const map_location &recruit_location, const map_location& recruited_from,
|
||||
place_recruit_result place_recruit(const unit_ptr& u, const map_location &recruit_location, const map_location& recruited_from,
|
||||
int cost, bool is_recall, map_location::direction facing = map_location::direction::indeterminate, bool show = false, bool fire_event = true, bool full_movement = false, bool wml_triggered = false);
|
||||
|
||||
/**
|
||||
|
|
|
@ -85,7 +85,7 @@ void undo_list::add_auto_shroud(bool turned_on)
|
|||
/**
|
||||
* Adds a dismissal to the undo stack.
|
||||
*/
|
||||
void undo_list::add_dismissal(const unit_const_ptr u)
|
||||
void undo_list::add_dismissal(const unit_const_ptr& u)
|
||||
{
|
||||
add(std::make_unique<undo::dismiss_action>(u));
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ void undo_list::add_dismissal(const unit_const_ptr u)
|
|||
/**
|
||||
* Adds a move to the undo stack.
|
||||
*/
|
||||
void undo_list::add_move(const unit_const_ptr u,
|
||||
void undo_list::add_move(const unit_const_ptr& u,
|
||||
const std::vector<map_location>::const_iterator & begin,
|
||||
const std::vector<map_location>::const_iterator & end,
|
||||
int start_moves,
|
||||
|
@ -105,7 +105,7 @@ void undo_list::add_move(const unit_const_ptr u,
|
|||
/**
|
||||
* Adds a recall to the undo stack.
|
||||
*/
|
||||
void undo_list::add_recall(const unit_const_ptr u, const map_location& loc,
|
||||
void undo_list::add_recall(const unit_const_ptr& u, const map_location& loc,
|
||||
const map_location& from)
|
||||
{
|
||||
add(std::make_unique<undo::recall_action>(u, loc, from));
|
||||
|
@ -114,7 +114,7 @@ void undo_list::add_recall(const unit_const_ptr u, const map_location& loc,
|
|||
/**
|
||||
* Adds a recruit to the undo stack.
|
||||
*/
|
||||
void undo_list::add_recruit(const unit_const_ptr u, const map_location& loc,
|
||||
void undo_list::add_recruit(const unit_const_ptr& u, const map_location& loc,
|
||||
const map_location& from)
|
||||
{
|
||||
add(std::make_unique<undo::recruit_action>(u, loc, from));
|
||||
|
|
|
@ -49,18 +49,18 @@ public:
|
|||
/** Adds an auto-shroud toggle to the undo stack. */
|
||||
void add_auto_shroud(bool turned_on);
|
||||
/** Adds a dismissal to the undo stack. */
|
||||
void add_dismissal(const unit_const_ptr u);
|
||||
void add_dismissal(const unit_const_ptr& u);
|
||||
/** Adds a move to the undo stack. */
|
||||
void add_move(const unit_const_ptr u,
|
||||
void add_move(const unit_const_ptr& u,
|
||||
const std::vector<map_location>::const_iterator & begin,
|
||||
const std::vector<map_location>::const_iterator & end,
|
||||
int start_moves,
|
||||
const map_location::direction dir=map_location::direction::indeterminate);
|
||||
/** Adds a recall to the undo stack. */
|
||||
void add_recall(const unit_const_ptr u, const map_location& loc,
|
||||
void add_recall(const unit_const_ptr& u, const map_location& loc,
|
||||
const map_location& from);
|
||||
/** Adds a recruit to the undo stack. */
|
||||
void add_recruit(const unit_const_ptr u, const map_location& loc,
|
||||
void add_recruit(const unit_const_ptr& u, const map_location& loc,
|
||||
const map_location& from);
|
||||
|
||||
template<class T, class... Args>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
namespace actions::undo
|
||||
{
|
||||
dismiss_action::dismiss_action(const unit_const_ptr dismissed)
|
||||
dismiss_action::dismiss_action(const unit_const_ptr& dismissed)
|
||||
: undo_action()
|
||||
, dismissed_unit(dismissed->clone())
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@ struct dismiss_action : undo_action
|
|||
{
|
||||
unit_ptr dismissed_unit;
|
||||
|
||||
explicit dismiss_action(const unit_const_ptr dismissed);
|
||||
explicit dismiss_action(const unit_const_ptr& dismissed);
|
||||
explicit dismiss_action(const config& cfg);
|
||||
|
||||
static const char* get_type_impl() { return "dismiss"; }
|
||||
|
|
|
@ -29,7 +29,7 @@ static lg::log_domain log_engine("engine");
|
|||
|
||||
namespace actions::undo
|
||||
{
|
||||
move_action::move_action(const unit_const_ptr moved,
|
||||
move_action::move_action(const unit_const_ptr& moved,
|
||||
const std::vector<map_location>::const_iterator & begin,
|
||||
const std::vector<map_location>::const_iterator & end,
|
||||
int sm, const map_location::direction dir)
|
||||
|
|
|
@ -27,7 +27,7 @@ struct move_action : undo_action, shroud_clearing_action
|
|||
map_location goto_hex;
|
||||
|
||||
|
||||
move_action(const unit_const_ptr moved,
|
||||
move_action(const unit_const_ptr& moved,
|
||||
const std::vector<map_location>::const_iterator & begin,
|
||||
const std::vector<map_location>::const_iterator & end,
|
||||
int sm, const map_location::direction dir);
|
||||
|
|
|
@ -32,7 +32,7 @@ static lg::log_domain log_engine("engine");
|
|||
|
||||
namespace actions::undo
|
||||
{
|
||||
recall_action::recall_action(const unit_const_ptr recalled, const map_location& loc,
|
||||
recall_action::recall_action(const unit_const_ptr& recalled, const map_location& loc,
|
||||
const map_location& from)
|
||||
: undo_action()
|
||||
, shroud_clearing_action(recalled, loc)
|
||||
|
|
|
@ -26,7 +26,7 @@ struct recall_action : undo_action, shroud_clearing_action
|
|||
map_location recall_from;
|
||||
|
||||
|
||||
recall_action(const unit_const_ptr recalled, const map_location& loc,
|
||||
recall_action(const unit_const_ptr& recalled, const map_location& loc,
|
||||
const map_location& from);
|
||||
recall_action(const config & cfg);
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ static lg::log_domain log_engine("engine");
|
|||
|
||||
namespace actions::undo
|
||||
{
|
||||
recruit_action::recruit_action(const unit_const_ptr recruited, const map_location& loc,
|
||||
recruit_action::recruit_action(const unit_const_ptr& recruited, const map_location& loc,
|
||||
const map_location& from)
|
||||
: undo_action()
|
||||
, shroud_clearing_action(recruited, loc)
|
||||
|
|
|
@ -30,7 +30,7 @@ struct recruit_action : undo_action, shroud_clearing_action
|
|||
map_location recruit_from;
|
||||
|
||||
|
||||
recruit_action(const unit_const_ptr recruited, const map_location& loc,
|
||||
recruit_action(const unit_const_ptr& recruited, const map_location& loc,
|
||||
const map_location& from);
|
||||
recruit_action(const config & cfg);
|
||||
|
||||
|
|
|
@ -306,7 +306,7 @@ static void unarchive_file(const std::string& path, const config& cfg)
|
|||
filesystem::write_file(path + '/' + cfg["name"].str(), unencode_binary(cfg["contents"]));
|
||||
}
|
||||
|
||||
static void unarchive_dir(const std::string& path, const config& cfg, std::function<void()> file_callback = {})
|
||||
static void unarchive_dir(const std::string& path, const config& cfg, const std::function<void()>& file_callback = {})
|
||||
{
|
||||
std::string dir;
|
||||
if (cfg["name"].empty())
|
||||
|
|
|
@ -102,7 +102,7 @@ void ai_composite::create_engine(std::vector<engine_ptr> &engines, const config
|
|||
engine::parse_engine_from_config(*this,cfg,std::back_inserter(engines));
|
||||
}
|
||||
|
||||
void ai_composite::replace_aspect(std::map<std::string,aspect_ptr> &aspects, const config &cfg, std::string id)
|
||||
void ai_composite::replace_aspect(std::map<std::string,aspect_ptr> &aspects, const config &cfg, const std::string& id)
|
||||
{
|
||||
std::vector<aspect_ptr> temp_aspects;
|
||||
engine::parse_aspect_from_config(*this,cfg,id,std::back_inserter(temp_aspects));
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
|
||||
void create_engine(std::vector<engine_ptr> &engines, const config &cfg);
|
||||
|
||||
void replace_aspect(std::map<std::string,aspect_ptr> &aspects, const config &cfg, std::string id);
|
||||
void replace_aspect(std::map<std::string,aspect_ptr> &aspects, const config &cfg, const std::string& id);
|
||||
|
||||
void on_create();
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ static lg::log_domain log_ai("ai/attack");
|
|||
|
||||
namespace ai {
|
||||
|
||||
extern ai_context& get_ai_context(wfl::const_formula_callable_ptr for_fai);
|
||||
extern ai_context& get_ai_context(const wfl::const_formula_callable_ptr& for_fai);
|
||||
|
||||
void attack_analysis::analyze(const gamemap& map, unit_map& units,
|
||||
const readonly_context& ai_obj,
|
||||
|
|
|
@ -1093,7 +1093,7 @@ struct attack_simulation {
|
|||
|
||||
attack_simulation(const unit_type* attacker, const unit_type* defender,
|
||||
double attacker_defense, double defender_defense,
|
||||
const_attack_ptr att_weapon, const_attack_ptr def_weapon,
|
||||
const const_attack_ptr& att_weapon, const const_attack_ptr& def_weapon,
|
||||
int average_lawful_bonus) :
|
||||
attacker_type(attacker),
|
||||
defender_type(defender),
|
||||
|
|
|
@ -173,7 +173,7 @@ std::string formula_ai::evaluate(const std::string& formula_str)
|
|||
}
|
||||
}
|
||||
|
||||
wfl::variant formula_ai::make_action(wfl::const_formula_ptr formula_, const wfl::formula_callable& variables)
|
||||
wfl::variant formula_ai::make_action(const wfl::const_formula_ptr& formula_, const wfl::formula_callable& variables)
|
||||
{
|
||||
if (!formula_) {
|
||||
throw formula_error("null formula passed to make_action","","formula",0);
|
||||
|
@ -250,7 +250,7 @@ pathfind::teleport_map formula_ai::get_allowed_teleports(unit_map::iterator& uni
|
|||
return pathfind::get_teleport_locations(*unit_it, current_team(), true);
|
||||
}
|
||||
|
||||
void formula_ai::add_formula_function(const std::string& name, const_formula_ptr formula, const_formula_ptr precondition, const std::vector<std::string>& args)
|
||||
void formula_ai::add_formula_function(const std::string& name, const const_formula_ptr& formula, const const_formula_ptr& precondition, const std::vector<std::string>& args)
|
||||
{
|
||||
function_table_.add_function(name, std::make_shared<user_formula_function>(name, formula, precondition, args));
|
||||
}
|
||||
|
@ -655,13 +655,13 @@ void formula_ai::on_create(){
|
|||
|
||||
}
|
||||
|
||||
void formula_ai::evaluate_candidate_action(ca_ptr fai_ca)
|
||||
void formula_ai::evaluate_candidate_action(const ca_ptr& fai_ca)
|
||||
{
|
||||
fai_ca->evaluate(this,resources::gameboard->units());
|
||||
|
||||
}
|
||||
|
||||
bool formula_ai::execute_candidate_action(ca_ptr fai_ca)
|
||||
bool formula_ai::execute_candidate_action(const ca_ptr& fai_ca)
|
||||
{
|
||||
map_formula_callable callable(fake_ptr());
|
||||
fai_ca->update_callable_map( callable );
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
|
||||
std::string evaluate(const std::string& formula_str);
|
||||
|
||||
virtual void add_formula_function(const std::string& name, wfl::const_formula_ptr formula, wfl::const_formula_ptr precondition, const std::vector<std::string>& args);
|
||||
virtual void add_formula_function(const std::string& name, const wfl::const_formula_ptr& formula, const wfl::const_formula_ptr& precondition, const std::vector<std::string>& args);
|
||||
|
||||
#if 0
|
||||
//class responsible for looking for possible infinite loops when calling set_var or set_unit_var
|
||||
|
@ -133,18 +133,18 @@ public:
|
|||
wfl::candidate_action_ptr load_candidate_action_from_config(const config& cfg);
|
||||
|
||||
/** Evaluate the fai candidate action */
|
||||
void evaluate_candidate_action(wfl::candidate_action_ptr fai_ca);
|
||||
void evaluate_candidate_action(const wfl::candidate_action_ptr& fai_ca);
|
||||
|
||||
/**
|
||||
* Execute the fai candidate action
|
||||
* @return true if game state was changed
|
||||
* @return false if game state was not changed
|
||||
*/
|
||||
bool execute_candidate_action(wfl::candidate_action_ptr fai_ca);
|
||||
bool execute_candidate_action(const wfl::candidate_action_ptr& fai_ca);
|
||||
|
||||
void set_ai_context(ai_context *context);
|
||||
|
||||
wfl::variant make_action(wfl::const_formula_ptr formula_, const wfl::formula_callable& variables);
|
||||
wfl::variant make_action(const wfl::const_formula_ptr& formula_, const wfl::formula_callable& variables);
|
||||
|
||||
private:
|
||||
ai_context *ai_ptr_;
|
||||
|
@ -165,7 +165,7 @@ private:
|
|||
mutable wfl::ai_function_symbol_table function_table_;
|
||||
|
||||
friend class ai_default;
|
||||
friend ai_context& get_ai_context(wfl::const_formula_callable_ptr for_fai);
|
||||
friend ai_context& get_ai_context(const wfl::const_formula_callable_ptr& for_fai);
|
||||
};
|
||||
|
||||
} //end of namespace ai
|
||||
|
|
|
@ -34,7 +34,7 @@ static lg::log_domain log_formula_ai("ai/engine/fai");
|
|||
|
||||
namespace ai {
|
||||
|
||||
ai_context& get_ai_context(wfl::const_formula_callable_ptr for_fai) {
|
||||
ai_context& get_ai_context(const wfl::const_formula_callable_ptr& for_fai) {
|
||||
auto fai = std::dynamic_pointer_cast<const formula_ai>(for_fai);
|
||||
assert(fai != nullptr);
|
||||
return *std::const_pointer_cast<formula_ai>(fai)->ai_ptr_;
|
||||
|
|
|
@ -75,7 +75,7 @@ candidate_action_with_filters::candidate_action_with_filters(
|
|||
}
|
||||
}
|
||||
|
||||
variant candidate_action_with_filters::do_filtering(ai::formula_ai* ai, variant& input, const_formula_ptr formula)
|
||||
variant candidate_action_with_filters::do_filtering(ai::formula_ai* ai, variant& input, const const_formula_ptr& formula)
|
||||
{
|
||||
map_formula_callable callable(ai->fake_ptr());
|
||||
callable.add("input", input);
|
||||
|
|
|
@ -72,7 +72,7 @@ class candidate_action_with_filters : public base_candidate_action {
|
|||
public:
|
||||
candidate_action_with_filters(const std::string& name, const std::string& type,const config& cfg, function_symbol_table* function_table);
|
||||
protected:
|
||||
variant do_filtering(ai::formula_ai* ai, variant& input, const_formula_ptr formula);
|
||||
variant do_filtering(ai::formula_ai* ai, variant& input, const const_formula_ptr& formula);
|
||||
|
||||
candidate_action_filters filter_map_;
|
||||
};
|
||||
|
|
|
@ -125,7 +125,7 @@ void lua_ai_context::push_ai_table()
|
|||
lua_ai_load ctx(*this, false);
|
||||
}
|
||||
|
||||
static int transform_ai_action(lua_State *L, ai::action_result_ptr action_result)
|
||||
static int transform_ai_action(lua_State *L, const ai::action_result_ptr& action_result)
|
||||
{
|
||||
lua_newtable(L);
|
||||
lua_pushboolean(L,action_result->is_ok());
|
||||
|
@ -1098,7 +1098,7 @@ lua_ai_context::~lua_ai_context()
|
|||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
void lua_ai_action_handler::handle(const config &cfg, const config &filter_own, bool read_only, lua_object_ptr l_obj)
|
||||
void lua_ai_action_handler::handle(const config &cfg, const config &filter_own, bool read_only, const lua_object_ptr& l_obj)
|
||||
{
|
||||
int initial_top = lua_gettop(L);//get the old stack size
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ private:
|
|||
public:
|
||||
~lua_ai_action_handler();
|
||||
//void handle(const config &cfg, bool read_only, lua_object_ptr l_obj);
|
||||
void handle(const config &cfg, const config &filter_own, bool read_only, lua_object_ptr l_obj);
|
||||
void handle(const config &cfg, const config &filter_own, bool read_only, const lua_object_ptr& l_obj);
|
||||
friend class ::game_lua_kernel;
|
||||
};
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ void ai_testing::log_draw()
|
|||
resources::recorder->add_log_data("ai_log","result","draw");
|
||||
}
|
||||
|
||||
void ai_testing::log_victory(std::set<unsigned int> winners)
|
||||
void ai_testing::log_victory(const std::set<unsigned int>& winners)
|
||||
{
|
||||
resources::recorder->add_log_data("ai_log","result","victory");
|
||||
for(std::set<unsigned int>::const_iterator w = winners.begin(); w != winners.end(); ++w) {
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
* Log in case of victory
|
||||
* teams vector of winner teams
|
||||
*/
|
||||
static void log_victory( std::set<unsigned int> teams );
|
||||
static void log_victory( const std::set<unsigned int>& teams );
|
||||
|
||||
/*
|
||||
* Log at game start
|
||||
|
|
|
@ -2053,8 +2053,8 @@ void complex_fight(attack_prediction_mode mode,
|
|||
double& self_not_hit,
|
||||
double& opp_not_hit,
|
||||
bool levelup_considered,
|
||||
std::vector<combat_slice> split,
|
||||
std::vector<combat_slice> opp_split,
|
||||
const std::vector<combat_slice>& split,
|
||||
const std::vector<combat_slice>& opp_split,
|
||||
double initially_slowed_chance,
|
||||
double opp_initially_slowed_chance)
|
||||
{
|
||||
|
|
|
@ -651,7 +651,7 @@ void config::remove_child(config_key_type key, std::size_t index)
|
|||
remove_child(i, index);
|
||||
}
|
||||
|
||||
void config::remove_children(config_key_type key, std::function<bool(const config&)> p)
|
||||
void config::remove_children(config_key_type key, const std::function<bool(const config&)>& p)
|
||||
{
|
||||
child_map::iterator pos = children_.find(key);
|
||||
if(pos == children_.end()) {
|
||||
|
|
|
@ -626,7 +626,7 @@ public:
|
|||
* Removes all children with tag @a key for which @a p returns true.
|
||||
* If no predicate is provided, all @a key tags will be removed.
|
||||
*/
|
||||
void remove_children(config_key_type key, std::function<bool(const config&)> p = {});
|
||||
void remove_children(config_key_type key, const std::function<bool(const config&)>& p = {});
|
||||
|
||||
void recursive_clear_value(config_key_type key);
|
||||
|
||||
|
|
|
@ -94,14 +94,14 @@ void config_cache::get_config(const std::string& file_path, config& cfg, abstrac
|
|||
load_configs(file_path, cfg, validator);
|
||||
}
|
||||
|
||||
void config_cache::write_file(std::string file_path, const config& cfg)
|
||||
void config_cache::write_file(const std::string& file_path, const config& cfg)
|
||||
{
|
||||
filesystem::scoped_ostream stream = filesystem::ostream_file(file_path);
|
||||
config_writer writer(*stream, true, game_config::cache_compression_level);
|
||||
writer.write(cfg);
|
||||
}
|
||||
|
||||
void config_cache::write_file(std::string file_path, const preproc_map& defines)
|
||||
void config_cache::write_file(const std::string& file_path, const preproc_map& defines)
|
||||
{
|
||||
if(defines.empty()) {
|
||||
if(filesystem::file_exists(file_path)) {
|
||||
|
|
|
@ -160,8 +160,8 @@ private:
|
|||
std::string cache_file_prefix_;
|
||||
|
||||
void read_file(const std::string& file, config& cfg);
|
||||
void write_file(std::string file, const config& cfg);
|
||||
void write_file(std::string file, const preproc_map& defines);
|
||||
void write_file(const std::string& file, const config& cfg);
|
||||
void write_file(const std::string& file, const preproc_map& defines);
|
||||
|
||||
void read_cache(const std::string& path, config& cfg, abstract_validator* validator = nullptr);
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ std::ostream& operator<<(std::ostream& os, const path_info& pinf)
|
|||
return os << pinf.name << " [" << pinf.label << "] - " << pinf.path;
|
||||
}
|
||||
|
||||
std::vector<path_info> game_paths(std::set<GAME_PATH_TYPES> paths)
|
||||
std::vector<path_info> game_paths(const std::set<GAME_PATH_TYPES>& paths)
|
||||
{
|
||||
static const std::string& game_bin_dir = pretty_path(filesystem::get_exe_dir());
|
||||
static const std::string& game_data_dir = pretty_path(game_config::path);
|
||||
|
@ -225,7 +225,7 @@ std::vector<path_info> game_paths(std::set<GAME_PATH_TYPES> paths)
|
|||
return res;
|
||||
}
|
||||
|
||||
std::vector<path_info> system_paths(std::set<SYSTEM_PATH_TYPES> paths)
|
||||
std::vector<path_info> system_paths(const std::set<SYSTEM_PATH_TYPES>& paths)
|
||||
{
|
||||
static const std::string& home_dir = user_profile_dir();
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ enum SYSTEM_PATH_TYPES
|
|||
* These paths are guaranteed to be their canonical forms (with links and dot
|
||||
* entries resolved) and using the platform's preferred path delimiter.
|
||||
*/
|
||||
std::vector<path_info> game_paths(std::set<GAME_PATH_TYPES> paths);
|
||||
std::vector<path_info> game_paths(const std::set<GAME_PATH_TYPES>& paths);
|
||||
|
||||
/**
|
||||
* Returns a list of system-defined paths.
|
||||
|
@ -87,7 +87,7 @@ std::vector<path_info> game_paths(std::set<GAME_PATH_TYPES> paths);
|
|||
* These paths are guaranteed to be their canonical forms (with links and dot
|
||||
* entries resolved) and using the platform's preferred path delimiter.
|
||||
*/
|
||||
std::vector<path_info> system_paths(std::set<SYSTEM_PATH_TYPES> paths);
|
||||
std::vector<path_info> system_paths(const std::set<SYSTEM_PATH_TYPES>& paths);
|
||||
|
||||
struct bookmark_info
|
||||
{
|
||||
|
|
|
@ -2317,7 +2317,7 @@ void display::queue_repaint()
|
|||
draw_manager::invalidate_all();
|
||||
}
|
||||
|
||||
void display::add_redraw_observer(std::function<void(display&)> f)
|
||||
void display::add_redraw_observer(const std::function<void(display&)>& f)
|
||||
{
|
||||
redraw_observers_.push_back(f);
|
||||
}
|
||||
|
|
|
@ -382,7 +382,7 @@ public:
|
|||
|
||||
/** Adds a redraw observer, a function object to be called when a
|
||||
* full rerender is queued. */
|
||||
void add_redraw_observer(std::function<void(display&)> f);
|
||||
void add_redraw_observer(const std::function<void(display&)>& f);
|
||||
|
||||
/** Clear the redraw observers */
|
||||
void clear_redraw_observers();
|
||||
|
|
|
@ -297,7 +297,7 @@ void editor_controller::custom_tods_dialog()
|
|||
}
|
||||
}
|
||||
|
||||
void editor_controller::update_map_schedule(std::vector<time_of_day> schedule)
|
||||
void editor_controller::update_map_schedule(const std::vector<time_of_day>& schedule)
|
||||
{
|
||||
get_current_map_context().replace_schedule(schedule);
|
||||
gui_->update_tod();
|
||||
|
|
|
@ -87,7 +87,7 @@ class editor_controller : public controller_base,
|
|||
void custom_tods_dialog();
|
||||
|
||||
/** Updates schedule and the map display */
|
||||
void update_map_schedule(std::vector<time_of_day> schedule);
|
||||
void update_map_schedule(const std::vector<time_of_day>& schedule);
|
||||
|
||||
/** Save the map, open dialog if not named yet. */
|
||||
void save_map() override {context_manager_->save_map();}
|
||||
|
|
|
@ -146,7 +146,7 @@ void editor_toolkit::clear_mouseover_overlay()
|
|||
gui_.clear_mouseover_hex_overlay();
|
||||
}
|
||||
|
||||
void editor_toolkit::set_brush(std::string id) {
|
||||
void editor_toolkit::set_brush(const std::string& id) {
|
||||
|
||||
for (brush& i : brushes_) {
|
||||
if (i.id() == id) {
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
/** Cycle to the next brush. */
|
||||
void cycle_brush();
|
||||
|
||||
void set_brush(std::string id);
|
||||
void set_brush(const std::string& id);
|
||||
|
||||
bool is_active_brush(std::string id) const { return brush_->id() == id; }
|
||||
|
||||
|
|
|
@ -1395,7 +1395,7 @@ std::string normalize_path(const std::string& fpath, bool normalize_separators,
|
|||
}
|
||||
}
|
||||
|
||||
bool to_asset_path(std::string& path, std::string addon_id, std::string asset_type)
|
||||
bool to_asset_path(std::string& path, const std::string& addon_id, const std::string& asset_type)
|
||||
{
|
||||
std::string rel_path = "";
|
||||
std::string core_asset_dir = get_dir(game_config::path + "/data/core/" + asset_type);
|
||||
|
|
|
@ -378,8 +378,8 @@ std::string normalize_path(const std::string& path,
|
|||
|
||||
/** Helper function to convert absolute path to wesnoth relative path */
|
||||
bool to_asset_path(std::string& abs_path,
|
||||
std::string addon_id,
|
||||
std::string asset_type);
|
||||
const std::string& addon_id,
|
||||
const std::string& asset_type);
|
||||
|
||||
/**
|
||||
* Sanitizes a path to remove references to the user's name.
|
||||
|
|
|
@ -436,7 +436,7 @@ void pango_text::add_attribute_fg_color(const unsigned start_offset, const unsig
|
|||
}
|
||||
}
|
||||
|
||||
void pango_text::add_attribute_font_family(const unsigned start_offset, const unsigned end_offset, std::string family)
|
||||
void pango_text::add_attribute_font_family(const unsigned start_offset, const unsigned end_offset, const std::string& family)
|
||||
{
|
||||
attribute_start_offset_ = start_offset;
|
||||
attribute_end_offset_ = end_offset;
|
||||
|
|
|
@ -382,7 +382,7 @@ public:
|
|||
* @param end_offset Byte index of the cursor where size change ends
|
||||
* @param family The font family
|
||||
*/
|
||||
void add_attribute_font_family(const unsigned start_offset, const unsigned end_offset, std::string family);
|
||||
void add_attribute_font_family(const unsigned start_offset, const unsigned end_offset, const std::string& family);
|
||||
|
||||
/** Clears all attributes from the global attribute list */
|
||||
void clear_attribute_list();
|
||||
|
|
|
@ -1198,7 +1198,7 @@ static void parse_set_args(const tk::token* i1, const tk::token* i2,
|
|||
}
|
||||
}
|
||||
|
||||
static void parse_where_clauses(const tk::token* i1, const tk::token* i2, expr_table_ptr res, function_symbol_table* symbols)
|
||||
static void parse_where_clauses(const tk::token* i1, const tk::token* i2, const expr_table_ptr& res, function_symbol_table* symbols)
|
||||
{
|
||||
int parens = 0;
|
||||
const tk::token* original_i1_cached = i1;
|
||||
|
|
|
@ -1542,7 +1542,7 @@ function_expression_ptr user_formula_function::generate_function_expression(
|
|||
return std::make_shared<formula_function_expression>(name_, args, formula_, precondition_, args_);
|
||||
}
|
||||
|
||||
function_symbol_table::function_symbol_table(std::shared_ptr<function_symbol_table> parent)
|
||||
function_symbol_table::function_symbol_table(const std::shared_ptr<function_symbol_table>& parent)
|
||||
: parent(parent ? parent : get_builtins())
|
||||
{
|
||||
}
|
||||
|
@ -1670,7 +1670,7 @@ std::shared_ptr<function_symbol_table> function_symbol_table::get_builtins()
|
|||
return std::shared_ptr<function_symbol_table>(&functions_table, [](function_symbol_table*) {});
|
||||
}
|
||||
|
||||
action_function_symbol_table::action_function_symbol_table(std::shared_ptr<function_symbol_table> parent)
|
||||
action_function_symbol_table::action_function_symbol_table(const std::shared_ptr<function_symbol_table>& parent)
|
||||
: function_symbol_table(parent)
|
||||
{
|
||||
using namespace actions;
|
||||
|
|
|
@ -232,7 +232,7 @@ typedef std::map<std::string, formula_function_ptr> functions_map;
|
|||
class function_symbol_table
|
||||
{
|
||||
public:
|
||||
explicit function_symbol_table(std::shared_ptr<function_symbol_table> parent = nullptr);
|
||||
explicit function_symbol_table(const std::shared_ptr<function_symbol_table>& parent = nullptr);
|
||||
|
||||
void add_function(const std::string& name, formula_function_ptr&& fcn);
|
||||
|
||||
|
@ -260,7 +260,7 @@ private:
|
|||
class action_function_symbol_table : public function_symbol_table
|
||||
{
|
||||
public:
|
||||
action_function_symbol_table(std::shared_ptr<function_symbol_table> parent = nullptr);
|
||||
action_function_symbol_table(const std::shared_ptr<function_symbol_table>& parent = nullptr);
|
||||
};
|
||||
|
||||
class wrapper_formula : public formula_expression
|
||||
|
|
|
@ -443,7 +443,7 @@ DEFINE_WFL_FUNCTION(base_tod_bonus, 0, 2)
|
|||
|
||||
} // namespace gamestate
|
||||
|
||||
gamestate_function_symbol_table::gamestate_function_symbol_table(std::shared_ptr<function_symbol_table> parent) : function_symbol_table(parent) {
|
||||
gamestate_function_symbol_table::gamestate_function_symbol_table(const std::shared_ptr<function_symbol_table>& parent) : function_symbol_table(parent) {
|
||||
using namespace gamestate;
|
||||
function_symbol_table& functions_table = *this;
|
||||
DECLARE_WFL_FUNCTION(get_unit_type);
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace wfl {
|
|||
|
||||
class gamestate_function_symbol_table : public function_symbol_table {
|
||||
public:
|
||||
gamestate_function_symbol_table(std::shared_ptr<function_symbol_table> parent = nullptr);
|
||||
gamestate_function_symbol_table(const std::shared_ptr<function_symbol_table>& parent = nullptr);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace tokenizer
|
|||
|
||||
namespace {
|
||||
|
||||
[[noreturn]] void raise_exception(iterator& i1, iterator i2, std::string str) {
|
||||
[[noreturn]] void raise_exception(iterator& i1, iterator i2, const std::string& str) {
|
||||
std::ostringstream expr;
|
||||
while( (i1 != i2) && (*i1 != '\n') ) {
|
||||
if( (*i1 != '\t') )
|
||||
|
|
|
@ -296,7 +296,7 @@ variant_list::variant_list(const variant_vector& vec)
|
|||
{
|
||||
}
|
||||
|
||||
variant variant_list::list_op(value_base_ptr second, std::function<variant(variant&, variant&)> op_func)
|
||||
variant variant_list::list_op(value_base_ptr second, const std::function<variant(variant&, variant&)>& op_func)
|
||||
{
|
||||
const auto& other_list = value_cast<variant_list>(second);
|
||||
|
||||
|
|
|
@ -493,7 +493,7 @@ public:
|
|||
/**
|
||||
* Applies the provided function to the corresponding variants in this and another list.
|
||||
*/
|
||||
variant list_op(value_base_ptr second, std::function<variant(variant&, variant&)> op_func);
|
||||
variant list_op(value_base_ptr second, const std::function<variant(variant&, variant&)>& op_func);
|
||||
|
||||
virtual bool equals(variant_value_base& other) const override;
|
||||
virtual bool less_than(variant_value_base& other) const override;
|
||||
|
|
|
@ -283,7 +283,7 @@ bool game_board::team_is_defeated(const team& t) const
|
|||
}
|
||||
}
|
||||
|
||||
bool game_board::try_add_unit_to_recall_list(const map_location&, const unit_ptr u)
|
||||
bool game_board::try_add_unit_to_recall_list(const map_location&, const unit_ptr& u)
|
||||
{
|
||||
get_team(u->side()).recall_list().add(u);
|
||||
return true;
|
||||
|
|
|
@ -152,7 +152,7 @@ public:
|
|||
|
||||
// Manipulator from actionwml
|
||||
|
||||
bool try_add_unit_to_recall_list(const map_location& loc, const unit_ptr u);
|
||||
bool try_add_unit_to_recall_list(const map_location& loc, const unit_ptr& u);
|
||||
utils::optional<std::string> replace_map(const gamemap & r);
|
||||
|
||||
bool change_terrain(const map_location &loc, const std::string &t, const std::string & mode, bool replace_if_failed); //used only by lua and debug commands
|
||||
|
|
|
@ -278,7 +278,7 @@ void load_config(const config &v)
|
|||
std::vector<std::string> zoom_levels_str = utils::split(v["zoom_levels"]);
|
||||
if(!zoom_levels_str.empty()) {
|
||||
zoom_levels.clear();
|
||||
std::transform(zoom_levels_str.begin(), zoom_levels_str.end(), std::back_inserter(zoom_levels), [](const std::string zoom) {
|
||||
std::transform(zoom_levels_str.begin(), zoom_levels_str.end(), std::back_inserter(zoom_levels), [](const std::string& zoom) {
|
||||
int z = std::stoi(zoom);
|
||||
if((z / 4) * 4 != z) {
|
||||
ERR_NG << "zoom level " << z << " is not divisible by 4."
|
||||
|
|
|
@ -756,7 +756,7 @@ void game_config_manager::load_game_config_for_create(bool is_mp, bool is_test)
|
|||
}
|
||||
}
|
||||
|
||||
void game_config_manager::set_enabled_addon(std::set<std::string> addon_ids)
|
||||
void game_config_manager::set_enabled_addon(const std::set<std::string>& addon_ids)
|
||||
{
|
||||
auto& vec = game_config_view_.data();
|
||||
vec.clear();
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
static game_config_manager * get();
|
||||
|
||||
private:
|
||||
void set_enabled_addon(std::set<std::string> addon_ids);
|
||||
void set_enabled_addon(const std::set<std::string>& addon_ids);
|
||||
void set_enabled_addon_all();
|
||||
|
||||
void load_game_config(bool reload_everything, const game_classification* classification, const std::string& scenario_id);
|
||||
|
|
|
@ -202,7 +202,7 @@ void manager::write_events(config& cfg, bool include_nonserializable) const
|
|||
wml_menu_items_.to_config(cfg);
|
||||
}
|
||||
|
||||
void manager::execute_on_events(const std::string& event_id, manager::event_func_t func)
|
||||
void manager::execute_on_events(const std::string& event_id, const manager::event_func_t& func)
|
||||
{
|
||||
const std::string standardized_event_id = event_handlers::standardize_name(event_id);
|
||||
const game_data* gd = resources::gamedata;
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
void write_events(config& cfg, bool include_nonserializable=false) const;
|
||||
|
||||
using event_func_t = std::function<void(game_events::manager&, handler_ptr&)>;
|
||||
void execute_on_events(const std::string& event_id, event_func_t func);
|
||||
void execute_on_events(const std::string& event_id, const event_func_t& func);
|
||||
|
||||
bool is_event_running() const;
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ std::string event_handlers::standardize_name(const std::string& name)
|
|||
return retval;
|
||||
}
|
||||
|
||||
bool event_handlers::cmp(const handler_ptr lhs, const handler_ptr rhs)
|
||||
bool event_handlers::cmp(const handler_ptr& lhs, const handler_ptr& rhs)
|
||||
{
|
||||
return lhs->priority() < rhs->priority();
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ pending_event_handler event_handlers::add_event_handler(const std::string& name,
|
|||
return {*this, handler};
|
||||
}
|
||||
|
||||
void event_handlers::finish_adding_event_handler(handler_ptr handler)
|
||||
void event_handlers::finish_adding_event_handler(const handler_ptr& handler)
|
||||
{
|
||||
// Someone decided to register an empty event... bail.
|
||||
if(handler->empty()) {
|
||||
|
@ -204,7 +204,7 @@ void event_handlers::clean_up_expired_handlers(const std::string& event_name)
|
|||
|
||||
// And finally remove any now-unlockable weak_ptrs from the with-variables name list.
|
||||
dynamic_.remove_if(
|
||||
[](weak_handler_ptr ptr) { return ptr.expired(); }
|
||||
[](const weak_handler_ptr& ptr) { return ptr.expired(); }
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -78,14 +78,14 @@ private:
|
|||
void log_handlers();
|
||||
|
||||
friend pending_event_handler;
|
||||
void finish_adding_event_handler(handler_ptr new_handler);
|
||||
void finish_adding_event_handler(const handler_ptr& new_handler);
|
||||
|
||||
public:
|
||||
/** Utility to standardize the event names used in by_name_. */
|
||||
static std::string standardize_name(const std::string& name);
|
||||
|
||||
/** Compare function to sort event handlers by priority. */
|
||||
static bool cmp(const handler_ptr lhs, const handler_ptr rhs);
|
||||
static bool cmp(const handler_ptr& lhs, const handler_ptr& rhs);
|
||||
|
||||
event_handlers()
|
||||
: active_()
|
||||
|
|
|
@ -369,7 +369,7 @@ std::multimap<std::string, config> side_engine::get_side_children()
|
|||
return children;
|
||||
}
|
||||
|
||||
void side_engine::set_side_children(std::multimap<std::string, config> children)
|
||||
void side_engine::set_side_children(const std::multimap<std::string, config>& children)
|
||||
{
|
||||
for(const std::string& children_to_remove : children_to_swap) {
|
||||
cfg_.clear_children(children_to_remove);
|
||||
|
|
|
@ -196,7 +196,7 @@ public:
|
|||
unsigned team() const { return team_; }
|
||||
void set_team(unsigned team) { team_ = team; }
|
||||
std::multimap<std::string, config> get_side_children();
|
||||
void set_side_children(std::multimap<std::string, config> children);
|
||||
void set_side_children(const std::multimap<std::string, config>& children);
|
||||
int color() const { return color_; }
|
||||
void set_color(int color) { color_ = color; color_id_ = color_options_[color]; }
|
||||
int gold() const { return gold_; }
|
||||
|
|
|
@ -617,7 +617,7 @@ std::vector<create_engine::extras_metadata_ptr> create_engine::active_mods_data(
|
|||
const std::vector<extras_metadata_ptr>& mods = get_const_extras_by_type(MP_EXTRA::MOD);
|
||||
|
||||
std::vector<extras_metadata_ptr> data_vec;
|
||||
std::copy_if(mods.begin(), mods.end(), std::back_inserter(data_vec), [this](extras_metadata_ptr mod) {
|
||||
std::copy_if(mods.begin(), mods.end(), std::back_inserter(data_vec), [this](const extras_metadata_ptr& mod) {
|
||||
return dependency_manager_->is_modification_active(mod->id);
|
||||
});
|
||||
|
||||
|
|
|
@ -430,7 +430,7 @@ bool manager::is_modification_active(int index) const
|
|||
return std::find(mods_.begin(), mods_.end(), id) != mods_.end();
|
||||
}
|
||||
|
||||
bool manager::is_modification_active(const std::string id) const
|
||||
bool manager::is_modification_active(const std::string& id) const
|
||||
{
|
||||
return std::find(mods_.begin(), mods_.end(), id) != mods_.end();
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ public:
|
|||
*
|
||||
* @return true if activated, false is not
|
||||
*/
|
||||
bool is_modification_active(const std::string id) const;
|
||||
bool is_modification_active(const std::string& id) const;
|
||||
|
||||
/**
|
||||
* Returns the selected era
|
||||
|
|
|
@ -113,7 +113,7 @@ private:
|
|||
};
|
||||
|
||||
/** Opens a new server connection and prompts the client for login credentials, if necessary. */
|
||||
std::unique_ptr<wesnothd_connection> open_connection(std::string host);
|
||||
std::unique_ptr<wesnothd_connection> open_connection(const std::string& host);
|
||||
|
||||
/** Opens the MP lobby. */
|
||||
bool enter_lobby_mode();
|
||||
|
@ -152,7 +152,7 @@ public:
|
|||
return session_info;
|
||||
}
|
||||
|
||||
auto add_network_handler(decltype(process_handlers)::value_type func)
|
||||
auto add_network_handler(const decltype(process_handlers)::value_type& func)
|
||||
{
|
||||
return [this, iter = process_handlers.insert(process_handlers.end(), func)]() { process_handlers.erase(iter); };
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ mp_manager::mp_manager(const utils::optional<std::string> host)
|
|||
manager = this;
|
||||
}
|
||||
|
||||
std::unique_ptr<wesnothd_connection> mp_manager::open_connection(std::string host)
|
||||
std::unique_ptr<wesnothd_connection> mp_manager::open_connection(const std::string& host)
|
||||
{
|
||||
DBG_MP << "opening connection";
|
||||
|
||||
|
@ -832,7 +832,7 @@ void send_to_server(const config& data)
|
|||
}
|
||||
}
|
||||
|
||||
network_registrar::network_registrar(handler func)
|
||||
network_registrar::network_registrar(const handler& func)
|
||||
{
|
||||
if(manager /*&& manager->connection*/) {
|
||||
remove_handler = manager->add_network_handler(func);
|
||||
|
|
|
@ -80,7 +80,7 @@ class network_registrar
|
|||
public:
|
||||
using handler = std::function<void(const config&)>;
|
||||
|
||||
network_registrar(handler func);
|
||||
network_registrar(const handler& func);
|
||||
~network_registrar();
|
||||
|
||||
private:
|
||||
|
|
|
@ -83,7 +83,7 @@ bool select_campaign(saved_game& state, jump_to_campaign_info jump_to_campaign)
|
|||
// if we should quit the game or return to the main menu
|
||||
|
||||
// Checking for valid campaign name
|
||||
const auto campaign = std::find_if(campaigns.begin(), campaigns.end(), [&jump_to_campaign](ng::create_engine::level_ptr level) {
|
||||
const auto campaign = std::find_if(campaigns.begin(), campaigns.end(), [&jump_to_campaign](const ng::create_engine::level_ptr& level) {
|
||||
return level->data()["id"] == jump_to_campaign.campaign_id;
|
||||
});
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ namespace
|
|||
class wesnoth_message_format : public bl::message_format<char>
|
||||
{
|
||||
public:
|
||||
wesnoth_message_format(std::locale base, const std::set<std::string>& domains, const std::set<std::string>& paths)
|
||||
wesnoth_message_format(const std::locale& base, const std::set<std::string>& domains, const std::set<std::string>& paths)
|
||||
: base_loc_(base)
|
||||
{
|
||||
const bl::info& inf = std::use_facet<bl::info>(base);
|
||||
|
|
|
@ -278,7 +278,7 @@ private:
|
|||
* which to execute the hotkey callback, false
|
||||
* otherwise.
|
||||
*/
|
||||
bool hotkey_pressed(const hotkey::hotkey_ptr key);
|
||||
bool hotkey_pressed(const hotkey::hotkey_ptr& key);
|
||||
|
||||
/**
|
||||
* Fires a key down event.
|
||||
|
@ -786,7 +786,7 @@ void sdl_event_handler::text_editing(const std::string& unicode, int32_t start,
|
|||
}
|
||||
}
|
||||
|
||||
bool sdl_event_handler::hotkey_pressed(const hotkey::hotkey_ptr key)
|
||||
bool sdl_event_handler::hotkey_pressed(const hotkey::hotkey_ptr& key)
|
||||
{
|
||||
if(dispatcher* dispatcher = keyboard_dispatcher()) {
|
||||
return dispatcher->execute_hotkey(hotkey::get_hotkey_command(key->get_command()).command);
|
||||
|
|
|
@ -599,7 +599,7 @@ void addon_manager::load_addon_list()
|
|||
apply_filters();
|
||||
}
|
||||
|
||||
void addon_manager::reload_list_and_reselect_item(const std::string id)
|
||||
void addon_manager::reload_list_and_reselect_item(const std::string& id)
|
||||
{
|
||||
load_addon_list();
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ private:
|
|||
void fetch_addons_list();
|
||||
void load_addon_list();
|
||||
|
||||
void reload_list_and_reselect_item(const std::string id);
|
||||
void reload_list_and_reselect_item(const std::string& id);
|
||||
|
||||
/** Config which contains the list with the campaigns. */
|
||||
config cfg_;
|
||||
|
|
|
@ -58,7 +58,7 @@ static custom_tod::string_pair tod_getter_sound(const time_of_day& tod)
|
|||
|
||||
REGISTER_DIALOG(custom_tod)
|
||||
|
||||
custom_tod::custom_tod(const std::vector<time_of_day>& times, int current_time, const std::string addon_id)
|
||||
custom_tod::custom_tod(const std::vector<time_of_day>& times, int current_time, const std::string& addon_id)
|
||||
: modal_dialog(window_id())
|
||||
, addon_id_(addon_id)
|
||||
, times_(times)
|
||||
|
@ -323,7 +323,7 @@ void custom_tod::update_selected_tod_info()
|
|||
update_tod_display();
|
||||
}
|
||||
|
||||
void custom_tod::copy_to_clipboard_callback(std::pair<std::string, tod_attribute_getter> data)
|
||||
void custom_tod::copy_to_clipboard_callback(const std::pair<std::string, tod_attribute_getter>& data)
|
||||
{
|
||||
auto& [type, getter] = data;
|
||||
button& copy_w = find_widget<button>("copy_" + type);
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace dialogs
|
|||
class custom_tod : public modal_dialog
|
||||
{
|
||||
public:
|
||||
custom_tod(const std::vector<time_of_day>& times, int current_time, const std::string addon_id = "");
|
||||
custom_tod(const std::vector<time_of_day>& times, int current_time, const std::string& addon_id = "");
|
||||
|
||||
/** The execute function. See @ref modal_dialog for more information. */
|
||||
DEFINE_SIMPLE_EXECUTE_WRAPPER(custom_tod)
|
||||
|
@ -82,7 +82,7 @@ private:
|
|||
|
||||
void update_selected_tod_info();
|
||||
|
||||
void copy_to_clipboard_callback(std::pair<std::string, tod_attribute_getter> data);
|
||||
void copy_to_clipboard_callback(const std::pair<std::string, tod_attribute_getter>& data);
|
||||
|
||||
/** Update current TOD with values from the GUI */
|
||||
void update_schedule();
|
||||
|
|
|
@ -52,7 +52,7 @@ void editor_edit_label::pre_show()
|
|||
add_to_tab_order(find_widget<text_box>("category", false, true));
|
||||
}
|
||||
|
||||
void editor_edit_label::register_color_component(std::string widget_id, uint8_t color_t::* component) {
|
||||
void editor_edit_label::register_color_component(const std::string& widget_id, uint8_t color_t::* component) {
|
||||
register_integer(widget_id, true,
|
||||
std::bind(&editor_edit_label::load_color_component, this, component),
|
||||
std::bind(&editor_edit_label::save_color_component, this, component, std::placeholders::_1));
|
||||
|
|
|
@ -51,7 +51,7 @@ private:
|
|||
color_t& color_store;
|
||||
int load_color_component(uint8_t color_t::* component);
|
||||
void save_color_component(uint8_t color_t::* component, const int value);
|
||||
void register_color_component(std::string widget_id, uint8_t color_t::* component);
|
||||
void register_color_component(const std::string& widget_id, uint8_t color_t::* component);
|
||||
virtual const std::string& window_id() const override;
|
||||
virtual void pre_show() override;
|
||||
};
|
||||
|
|
|
@ -844,7 +844,7 @@ void editor_edit_unit::load_movetype() {
|
|||
tabs.select_tab(prev_tab);
|
||||
}
|
||||
|
||||
void editor_edit_unit::write_macro(std::ostream& out, unsigned level, const std::string macro_name)
|
||||
void editor_edit_unit::write_macro(std::ostream& out, unsigned level, const std::string& macro_name)
|
||||
{
|
||||
for(unsigned i = 0; i < level; i++)
|
||||
{
|
||||
|
@ -1006,7 +1006,7 @@ void editor_edit_unit::update_image(const std::string& id_stem) {
|
|||
queue_redraw();
|
||||
}
|
||||
|
||||
bool editor_edit_unit::check_id(std::string id) {
|
||||
bool editor_edit_unit::check_id(const std::string& id) {
|
||||
for(char c : id) {
|
||||
if (!(std::isalnum(c) || c == '_' || c == ' ')) {
|
||||
// One bad char means entire id string is invalid
|
||||
|
|
|
@ -83,7 +83,7 @@ private:
|
|||
void save_unit_type();
|
||||
|
||||
/** Write macro to a stream at specified tab level */
|
||||
void write_macro(std::ostream& out, unsigned level, const std::string macro_name);
|
||||
void write_macro(std::ostream& out, unsigned level, const std::string& macro_name);
|
||||
|
||||
/** Update wml preview */
|
||||
void update_wml_view();
|
||||
|
@ -132,7 +132,7 @@ private:
|
|||
void quit_confirmation();
|
||||
|
||||
/** Utility method to check if ID contains any invalid characters */
|
||||
bool check_id(std::string id);
|
||||
bool check_id(const std::string& id);
|
||||
|
||||
void set_selected_from_string(menu_button& list, std::vector<config> values, std::string item) {
|
||||
for (unsigned i = 0; i < values.size(); ++i) {
|
||||
|
|
|
@ -84,7 +84,7 @@ static int resize_grid_xy_to_idx(const int x, const int y)
|
|||
}
|
||||
}
|
||||
|
||||
void editor_resize_map::set_direction_icon(int index, std::string icon)
|
||||
void editor_resize_map::set_direction_icon(int index, const std::string& icon)
|
||||
{
|
||||
if(index < 9) {
|
||||
direction_buttons_[index]->set_icon_name("icons/arrows/arrows_blank_"
|
||||
|
|
|
@ -102,7 +102,7 @@ private:
|
|||
|
||||
void update_expand_direction();
|
||||
|
||||
void set_direction_icon(int index, std::string icon);
|
||||
void set_direction_icon(int index, const std::string& icon);
|
||||
|
||||
virtual void pre_show() override;
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ inline std::string config_to_string(const config& cfg)
|
|||
return s.str();
|
||||
}
|
||||
|
||||
inline std::string config_to_string(const config& cfg, std::string only_children)
|
||||
inline std::string config_to_string(const config& cfg, const std::string& only_children)
|
||||
{
|
||||
config filtered;
|
||||
for(const config& child : cfg.child_range(only_children)) {
|
||||
|
|
|
@ -212,7 +212,7 @@ loading_screen::~loading_screen()
|
|||
singleton_ = nullptr;
|
||||
}
|
||||
|
||||
void loading_screen::display(std::function<void()> f)
|
||||
void loading_screen::display(const std::function<void()>& f)
|
||||
{
|
||||
if(singleton_ || video::headless()) {
|
||||
LOG_LS << "Directly executing loading function.";
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
|
||||
~loading_screen();
|
||||
|
||||
static void display(std::function<void()> f);
|
||||
static void display(const std::function<void()>& f);
|
||||
static bool displaying() { return singleton_ != nullptr; }
|
||||
|
||||
/**
|
||||
|
|
|
@ -136,7 +136,7 @@ void log_settings::post_show()
|
|||
}
|
||||
}
|
||||
|
||||
void log_settings::set_logger(const std::string log_domain)
|
||||
void log_settings::set_logger(const std::string& log_domain)
|
||||
{
|
||||
std::string active_value = groups_[log_domain].get_active_member_value();
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
DEFINE_SIMPLE_DISPLAY_WRAPPER(log_settings)
|
||||
|
||||
private:
|
||||
void set_logger(const std::basic_string<char> log_domain);
|
||||
void set_logger(const std::basic_string<char>& log_domain);
|
||||
|
||||
std::map<std::string, group<std::string>> groups_;
|
||||
std::vector<std::string> domain_list_, widget_id_;
|
||||
|
|
|
@ -73,8 +73,8 @@ bool modal_dialog::show(const unsigned auto_close_time)
|
|||
if (pm && pm->any_running())
|
||||
{
|
||||
plugins_context pc("Dialog");
|
||||
pc.set_callback("skip_dialog", [this](config) { retval_ = retval::OK; }, false);
|
||||
pc.set_callback("quit", [](config) {}, false);
|
||||
pc.set_callback("skip_dialog", [this](const config&) { retval_ = retval::OK; }, false);
|
||||
pc.set_callback("quit", [](const config&) {}, false);
|
||||
pc.play_slice();
|
||||
}
|
||||
|
||||
|
@ -128,9 +128,9 @@ T* modal_dialog::register_field(Args&&... args)
|
|||
field_bool* modal_dialog::register_bool(
|
||||
const std::string& id,
|
||||
const bool mandatory,
|
||||
const std::function<bool()> callback_load_value,
|
||||
const std::function<void(bool)> callback_save_value,
|
||||
const std::function<void(widget&)> callback_change,
|
||||
const std::function<bool()>& callback_load_value,
|
||||
const std::function<void(bool)>& callback_save_value,
|
||||
const std::function<void(widget&)>& callback_change,
|
||||
const bool initial_fire)
|
||||
{
|
||||
field_bool* field = new field_bool(id,
|
||||
|
@ -148,7 +148,7 @@ field_bool*
|
|||
modal_dialog::register_bool(const std::string& id,
|
||||
const bool mandatory,
|
||||
bool& linked_variable,
|
||||
const std::function<void(widget&)> callback_change,
|
||||
const std::function<void(widget&)>& callback_change,
|
||||
const bool initial_fire)
|
||||
{
|
||||
field_bool* field
|
||||
|
@ -161,8 +161,8 @@ modal_dialog::register_bool(const std::string& id,
|
|||
field_integer* modal_dialog::register_integer(
|
||||
const std::string& id,
|
||||
const bool mandatory,
|
||||
const std::function<int()> callback_load_value,
|
||||
const std::function<void(const int)> callback_save_value)
|
||||
const std::function<int()>& callback_load_value,
|
||||
const std::function<void(const int)>& callback_save_value)
|
||||
{
|
||||
field_integer* field = new field_integer(
|
||||
id, mandatory, callback_load_value, callback_save_value);
|
||||
|
@ -184,8 +184,8 @@ field_integer* modal_dialog::register_integer(const std::string& id,
|
|||
field_text* modal_dialog::register_text(
|
||||
const std::string& id,
|
||||
const bool mandatory,
|
||||
const std::function<std::string()> callback_load_value,
|
||||
const std::function<void(const std::string&)> callback_save_value,
|
||||
const std::function<std::string()>& callback_load_value,
|
||||
const std::function<void(const std::string&)>& callback_save_value,
|
||||
const bool capture_focus)
|
||||
{
|
||||
field_text* field = new field_text(
|
||||
|
|
|
@ -228,9 +228,9 @@ protected:
|
|||
field_bool*
|
||||
register_bool(const std::string& id,
|
||||
const bool mandatory,
|
||||
const std::function<bool()> callback_load_value = nullptr,
|
||||
const std::function<void(bool)> callback_save_value = nullptr,
|
||||
const std::function<void(widget&)> callback_change = nullptr,
|
||||
const std::function<bool()>& callback_load_value = nullptr,
|
||||
const std::function<void(bool)>& callback_save_value = nullptr,
|
||||
const std::function<void(widget&)>& callback_change = nullptr,
|
||||
const bool initial_fire = false);
|
||||
|
||||
/**
|
||||
|
@ -253,7 +253,7 @@ protected:
|
|||
register_bool(const std::string& id,
|
||||
const bool mandatory,
|
||||
bool& linked_variable,
|
||||
const std::function<void(widget&)> callback_change = nullptr,
|
||||
const std::function<void(widget&)>& callback_change = nullptr,
|
||||
const bool initial_fire = false);
|
||||
|
||||
/**
|
||||
|
@ -264,8 +264,8 @@ protected:
|
|||
field_integer*
|
||||
register_integer(const std::string& id,
|
||||
const bool mandatory,
|
||||
const std::function<int()> callback_load_value = nullptr,
|
||||
const std::function<void(int)> callback_save_value = nullptr);
|
||||
const std::function<int()>& callback_load_value = nullptr,
|
||||
const std::function<void(int)>& callback_save_value = nullptr);
|
||||
|
||||
/**
|
||||
* Creates a new integer field.
|
||||
|
@ -283,8 +283,8 @@ protected:
|
|||
field_text* register_text(
|
||||
const std::string& id,
|
||||
const bool mandatory,
|
||||
const std::function<std::string()> callback_load_value = nullptr,
|
||||
const std::function<void(const std::string&)> callback_save_value = nullptr,
|
||||
const std::function<std::string()>& callback_load_value = nullptr,
|
||||
const std::function<void(const std::string&)>& callback_save_value = nullptr,
|
||||
const bool capture_focus = false);
|
||||
|
||||
/**
|
||||
|
|
|
@ -190,7 +190,7 @@ void faction_select::profile_button_callback()
|
|||
}
|
||||
}
|
||||
|
||||
void faction_select::on_gender_select(const std::string val)
|
||||
void faction_select::on_gender_select(const std::string& val)
|
||||
{
|
||||
flg_manager_.set_current_gender(val);
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ private:
|
|||
|
||||
void profile_button_callback();
|
||||
|
||||
void on_gender_select(const std::string val);
|
||||
void on_gender_select(const std::string& val);
|
||||
|
||||
void update_leader_image();
|
||||
};
|
||||
|
|
|
@ -66,7 +66,7 @@ mp_connect::mp_connect()
|
|||
, host_name_(register_text("host_name",
|
||||
true,
|
||||
[]() {return prefs::get().network_host();},
|
||||
[](std::string v) {prefs::get().set_network_host(v);},
|
||||
[](const std::string& v) {prefs::get().set_network_host(v);},
|
||||
true))
|
||||
, builtin_servers_(prefs::get().builtin_servers_list())
|
||||
, user_servers_(prefs::get().user_servers_list())
|
||||
|
|
|
@ -543,7 +543,7 @@ void mp_create_game::on_tab_select()
|
|||
find_widget<stacked_widget>("pager").select_layer(i);
|
||||
}
|
||||
|
||||
void mp_create_game::on_mod_toggle(const std::string id, toggle_button* sender)
|
||||
void mp_create_game::on_mod_toggle(const std::string& id, toggle_button* sender)
|
||||
{
|
||||
if(sender && (sender->get_value_bool() == create_engine_.dependency_manager().is_modification_active(id))) {
|
||||
ERR_MP << "ignoring on_mod_toggle that is already set";
|
||||
|
|
|
@ -99,7 +99,7 @@ private:
|
|||
void on_game_select();
|
||||
void on_tab_select();
|
||||
void on_era_select();
|
||||
void on_mod_toggle(const std::string id, toggle_button* sender);
|
||||
void on_mod_toggle(const std::string& id, toggle_button* sender);
|
||||
void on_random_faction_mode_select();
|
||||
|
||||
std::vector<std::string> get_active_mods();
|
||||
|
|
|
@ -35,7 +35,7 @@ mp_login::mp_login(const std::string& host, const std::string& label, const bool
|
|||
register_label("login_label", false, label);
|
||||
username_ = register_text("user_name", true,
|
||||
[]() {return prefs::get().login();},
|
||||
[](std::string v) {prefs::get().set_login(v);},
|
||||
[](const std::string& v) {prefs::get().set_login(v);},
|
||||
!focus_password);
|
||||
|
||||
register_bool("remember_password", false,
|
||||
|
|
|
@ -128,7 +128,7 @@ void mp_staging::pre_show()
|
|||
plugins_context_->set_callback("chat", [&chat](const config& cfg) { chat.send_chat_message(cfg["message"], false); }, true);
|
||||
}
|
||||
|
||||
int mp_staging::get_side_node_position(ng::side_engine_ptr side) const
|
||||
int mp_staging::get_side_node_position(const ng::side_engine_ptr& side) const
|
||||
{
|
||||
int position = 0;
|
||||
for(const auto& side_engine : connect_engine_.side_engines()) {
|
||||
|
@ -141,7 +141,7 @@ int mp_staging::get_side_node_position(ng::side_engine_ptr side) const
|
|||
}
|
||||
|
||||
template<typename... T>
|
||||
tree_view_node& mp_staging::add_side_to_team_node(ng::side_engine_ptr side, T&&... params)
|
||||
tree_view_node& mp_staging::add_side_to_team_node(const ng::side_engine_ptr& side, T&&... params)
|
||||
{
|
||||
static const widget_data empty_map;
|
||||
|
||||
|
@ -168,7 +168,7 @@ tree_view_node& mp_staging::add_side_to_team_node(ng::side_engine_ptr side, T&&.
|
|||
return team_node->add_child(std::forward<T>(params)...);
|
||||
}
|
||||
|
||||
void mp_staging::add_side_node(ng::side_engine_ptr side)
|
||||
void mp_staging::add_side_node(const ng::side_engine_ptr& side)
|
||||
{
|
||||
widget_data data;
|
||||
widget_item item;
|
||||
|
@ -373,7 +373,7 @@ void mp_staging::add_side_node(ng::side_engine_ptr side)
|
|||
}
|
||||
}
|
||||
|
||||
void mp_staging::on_controller_select(ng::side_engine_ptr side, grid& row_grid)
|
||||
void mp_staging::on_controller_select(const ng::side_engine_ptr& side, grid& row_grid)
|
||||
{
|
||||
menu_button& ai_selection = row_grid.find_widget<menu_button>("ai_controller");
|
||||
menu_button& controller_selection = row_grid.find_widget<menu_button>("controller");
|
||||
|
@ -385,7 +385,7 @@ void mp_staging::on_controller_select(ng::side_engine_ptr side, grid& row_grid)
|
|||
}
|
||||
}
|
||||
|
||||
void mp_staging::on_ai_select(ng::side_engine_ptr side, menu_button& ai_menu, const bool saved_game)
|
||||
void mp_staging::on_ai_select(const ng::side_engine_ptr& side, menu_button& ai_menu, const bool saved_game)
|
||||
{
|
||||
// If this is a saved game, we need to reduce the index by one, to account for
|
||||
// the "Keep saved AI" option having been added to the computer player menu
|
||||
|
@ -403,7 +403,7 @@ void mp_staging::on_ai_select(ng::side_engine_ptr side, menu_button& ai_menu, co
|
|||
set_state_changed();
|
||||
}
|
||||
|
||||
void mp_staging::on_color_select(ng::side_engine_ptr side, grid& row_grid)
|
||||
void mp_staging::on_color_select(const ng::side_engine_ptr& side, grid& row_grid)
|
||||
{
|
||||
side->set_color(row_grid.find_widget<menu_button>("side_color").get_value());
|
||||
|
||||
|
@ -412,7 +412,7 @@ void mp_staging::on_color_select(ng::side_engine_ptr side, grid& row_grid)
|
|||
set_state_changed();
|
||||
}
|
||||
|
||||
void mp_staging::on_team_select(ng::side_engine_ptr side, menu_button& team_menu)
|
||||
void mp_staging::on_team_select(const ng::side_engine_ptr& side, menu_button& team_menu)
|
||||
{
|
||||
// Since we're not necessarily displaying every every team in the menu, we can't just
|
||||
// use the selected index to set a side's team. Instead, we grab the index we stored
|
||||
|
@ -451,7 +451,7 @@ void mp_staging::on_team_select(ng::side_engine_ptr side, menu_button& team_menu
|
|||
set_state_changed();
|
||||
}
|
||||
|
||||
void mp_staging::select_leader_callback(ng::side_engine_ptr side, grid& row_grid)
|
||||
void mp_staging::select_leader_callback(const ng::side_engine_ptr& side, grid& row_grid)
|
||||
{
|
||||
if(gui2::dialogs::faction_select::execute(side->flg(), side->color_id(), side->index() + 1)) {
|
||||
update_leader_display(side, row_grid);
|
||||
|
@ -461,14 +461,14 @@ void mp_staging::select_leader_callback(ng::side_engine_ptr side, grid& row_grid
|
|||
}
|
||||
|
||||
template<void(ng::side_engine::*fptr)(int)>
|
||||
void mp_staging::on_side_slider_change(ng::side_engine_ptr side, slider& slider)
|
||||
void mp_staging::on_side_slider_change(const ng::side_engine_ptr& side, slider& slider)
|
||||
{
|
||||
std::invoke(fptr, side, slider.get_value());
|
||||
|
||||
set_state_changed();
|
||||
}
|
||||
|
||||
void mp_staging::update_leader_display(ng::side_engine_ptr side, grid& row_grid)
|
||||
void mp_staging::update_leader_display(const ng::side_engine_ptr& side, grid& row_grid)
|
||||
{
|
||||
// BIG FAT TODO: get rid of this shitty "null" string value in the FLG manager
|
||||
std::string current_leader = side->flg().current_leader() != "null" ? side->flg().current_leader() : font::unicode_em_dash;
|
||||
|
|
|
@ -52,9 +52,9 @@ private:
|
|||
virtual void post_show() override;
|
||||
|
||||
template<typename... T>
|
||||
tree_view_node& add_side_to_team_node(ng::side_engine_ptr side, T&&... params);
|
||||
tree_view_node& add_side_to_team_node(const ng::side_engine_ptr& side, T&&... params);
|
||||
|
||||
void add_side_node(ng::side_engine_ptr side);
|
||||
void add_side_node(const ng::side_engine_ptr& side);
|
||||
|
||||
/**
|
||||
* Find an appropriate position to insert a side node.
|
||||
|
@ -62,19 +62,19 @@ private:
|
|||
* This ensures the side nodes are always arranged by descending index order
|
||||
* in each team group.
|
||||
*/
|
||||
int get_side_node_position(ng::side_engine_ptr side) const;
|
||||
int get_side_node_position(const ng::side_engine_ptr& side) const;
|
||||
|
||||
void on_controller_select(ng::side_engine_ptr side, grid& row_grid);
|
||||
void on_ai_select(ng::side_engine_ptr side, menu_button& ai_menu, const bool saved_game);
|
||||
void on_color_select(ng::side_engine_ptr side, grid& row_grid);
|
||||
void on_team_select(ng::side_engine_ptr side, menu_button& team_menu);
|
||||
void on_controller_select(const ng::side_engine_ptr& side, grid& row_grid);
|
||||
void on_ai_select(const ng::side_engine_ptr& side, menu_button& ai_menu, const bool saved_game);
|
||||
void on_color_select(const ng::side_engine_ptr& side, grid& row_grid);
|
||||
void on_team_select(const ng::side_engine_ptr& side, menu_button& team_menu);
|
||||
|
||||
template<void(ng::side_engine::*fptr)(int)>
|
||||
void on_side_slider_change(ng::side_engine_ptr side, slider& slider);
|
||||
void on_side_slider_change(const ng::side_engine_ptr& side, slider& slider);
|
||||
|
||||
void select_leader_callback(ng::side_engine_ptr side, grid& row_grid);
|
||||
void select_leader_callback(const ng::side_engine_ptr& side, grid& row_grid);
|
||||
|
||||
void update_leader_display(ng::side_engine_ptr side, grid& row_grid);
|
||||
void update_leader_display(const ng::side_engine_ptr& side, grid& row_grid);
|
||||
void update_status_label_and_buttons();
|
||||
|
||||
void network_handler();
|
||||
|
|
|
@ -86,7 +86,7 @@ title_screen::~title_screen()
|
|||
{
|
||||
}
|
||||
|
||||
void title_screen::register_button(const std::string& id, hotkey::HOTKEY_COMMAND hk, std::function<void()> callback)
|
||||
void title_screen::register_button(const std::string& id, hotkey::HOTKEY_COMMAND hk, const std::function<void()>& callback)
|
||||
{
|
||||
if(hk != hotkey::HOTKEY_NULL) {
|
||||
register_hotkey(hk, std::bind(callback));
|
||||
|
|
|
@ -71,7 +71,7 @@ private:
|
|||
|
||||
void init_callbacks();
|
||||
|
||||
void register_button(const std::string& id, hotkey::HOTKEY_COMMAND hk, std::function<void()> callback);
|
||||
void register_button(const std::string& id, hotkey::HOTKEY_COMMAND hk, const std::function<void()>& callback);
|
||||
|
||||
/***** ***** ***** ***** Callbacks ***** ***** ****** *****/
|
||||
|
||||
|
|
|
@ -58,12 +58,12 @@ static std::string format_level_string(const int level)
|
|||
|
||||
}
|
||||
|
||||
static std::string format_if_leader(unit_const_ptr u, const std::string& str)
|
||||
static std::string format_if_leader(const unit_const_ptr& u, const std::string& str)
|
||||
{
|
||||
return u->can_recruit() ? markup::span_color("#cdad00", str) : str;
|
||||
}
|
||||
|
||||
static std::string format_movement_string(unit_const_ptr u)
|
||||
static std::string format_movement_string(const unit_const_ptr& u)
|
||||
{
|
||||
const int moves_left = u->movement_left();
|
||||
const int moves_max = u->total_movement();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue