Fix a whole bunch of bad indentation.

Mostly spaces where tabs should have been used.
This commit is contained in:
Tommy 2022-06-25 15:22:53 +12:00
parent a0daa2ddce
commit 738392069d
78 changed files with 370 additions and 343 deletions

View file

@ -62,8 +62,8 @@ struct battle_context_unit_stats
bool poisons; /**< Attack poisons opponent when it hits. */
bool backstab_pos; /**<
* True if the attacker is in *position* to backstab the defender (this is used to
* determine whether to apply the backstab bonus in case the attacker has backstab).
*/
* determine whether to apply the backstab bonus in case the attacker has backstab).
*/
bool swarm; /**< Attack has swarm special. */
bool firststrike; /**< Attack has firststrike special. */
bool disable; /**< Attack has disable special. */

View file

@ -611,8 +611,8 @@ 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,
int cost, bool is_recall, map_location::DIRECTION facing, bool show, bool fire_event, bool full_movement,
bool wml_triggered)
int cost, bool is_recall, map_location::DIRECTION facing, bool show, bool fire_event, bool full_movement,
bool wml_triggered)
{
place_recruit_result res(false, 0, false);
LOG_NG << "placing new unit on location " << recruit_location << "\n";

View file

@ -1165,9 +1165,7 @@ namespace { // Private helpers for move_unit()
static std::size_t move_unit_internal(undo_list* undo_stack,
bool show_move,
bool* interrupted,
unit_mover& mover)
bool show_move, bool* interrupted, unit_mover& mover)
{
const events::command_disabler disable_commands;
// Default return value.
@ -1230,10 +1228,8 @@ static std::size_t move_unit_internal(undo_list* undo_stack,
* than steps.size() ).
*/
std::size_t move_unit_and_record(const std::vector<map_location> &steps,
undo_list* undo_stack,
bool continued_move, bool show_move,
bool* interrupted,
move_unit_spectator* move_spectator)
undo_list* undo_stack, bool continued_move, bool show_move,
bool* interrupted, move_unit_spectator* move_spectator)
{
// Avoid some silliness.
@ -1276,8 +1272,8 @@ std::size_t move_unit_and_record(const std::vector<map_location> &steps,
}
std::size_t move_unit_from_replay(const std::vector<map_location> &steps,
undo_list* undo_stack,
bool continued_move,bool skip_ally_sighted, bool show_move)
undo_list* undo_stack, bool continued_move, bool skip_ally_sighted,
bool show_move)
{
// Evaluate this move.
unit_mover mover(steps, nullptr, continued_move,skip_ally_sighted);

View file

@ -104,20 +104,23 @@ game_events::pump_result_t get_village(const map_location& loc, int side, bool *
* Moves a unit across the board.
* And enters the synced context.
*/
std::size_t move_unit_and_record(const std::vector<map_location> &steps,
undo_list* undo_stack,
bool continued_move = false,
bool show_move = true,
bool* interrupted = nullptr,
move_unit_spectator* move_spectator = nullptr);
std::size_t move_unit_and_record(
const std::vector<map_location> &steps,
undo_list* undo_stack,
bool continued_move = false,
bool show_move = true,
bool* interrupted = nullptr,
move_unit_spectator* move_spectator = nullptr);
/**
* Moves a unit across the board.
* to be called from replay when we are already in the synced context.
*/
std::size_t move_unit_from_replay(const std::vector<map_location> &steps,
undo_list* undo_stack,
bool continued_move, bool skip_ally_sighted,
bool show_move = true);
std::size_t move_unit_from_replay(
const std::vector<map_location> &steps,
undo_list* undo_stack,
bool continued_move,
bool skip_ally_sighted,
bool show_move = true);
}//namespace actions

View file

@ -47,7 +47,7 @@ static const std::string sighted_str("sighted");
void actions::create_jamming_map(std::map<map_location, int> & jamming,
const team & view_team)
const team & view_team)
{
// Reset the map.
jamming.clear();

View file

@ -173,8 +173,9 @@ bool check_names_legal(const config& dir, std::vector<std::string>* badlist)
return check_names_legal_internal(dir, "", badlist);
}
bool check_case_insensitive_duplicates(const config& dir, std::vector<std::string>* badlist){
return check_case_insensitive_duplicates_internal(dir, "", badlist);
bool check_case_insensitive_duplicates(const config& dir, std::vector<std::string>* badlist)
{
return check_case_insensitive_duplicates_internal(dir, "", badlist);
}
ADDON_TYPE get_addon_type(const std::string& str)

View file

@ -79,9 +79,9 @@ public:
vector_property_handler(const std::string &property, ptr_vector &values, std::function<void(ptr_vector&, const config&)> &construction_factory)
: factory_(construction_factory), property_(property), values_(values){}
component* handle_get(const path_element &child)
component* handle_get(const path_element &child)
{
typename ptr_vector::iterator i = std::find_if(values_.begin(),values_.end(),path_element_matches<ptr>(child));
typename ptr_vector::iterator i = std::find_if(values_.begin(),values_.end(),path_element_matches<ptr>(child));
if (i!=values_.end()){
return &*(*i);
}
@ -220,7 +220,7 @@ public:
{
}
component* handle_get(const path_element &child)
component* handle_get(const path_element &child)
{
typename aspect_map::const_iterator a = aspects_.find(child.id);
if (a!=aspects_.end()){

View file

@ -405,10 +405,10 @@ public:
static void value_to_variant(const attacks_vector &value, wfl::variant &var)
{
std::vector<wfl::variant> vars;
for(attacks_vector::const_iterator i = value.begin(); i != value.end(); ++i) {
vars.emplace_back(std::make_shared<attack_analysis>(*i));
}
std::vector<wfl::variant> vars;
for(attacks_vector::const_iterator i = value.begin(); i != value.end(); ++i) {
vars.emplace_back(std::make_shared<attack_analysis>(*i));
}
var = wfl::variant(vars);
}
@ -433,7 +433,7 @@ public:
static void variant_to_value(const wfl::variant &/*var*/, terrain_filter &/*value*/)
{
assert(false);//not implemented
assert(false);//not implemented
}
static void value_to_variant(const terrain_filter &/*value*/, wfl::variant &/*var*/)

View file

@ -152,10 +152,10 @@ std::vector<description*> configuration::get_available_ais()
// Sort by mp_rank. For same mp_rank, keep alphabetical order.
std::stable_sort(ais_list.begin(), ais_list.end(),
[](const description* a, const description* b) {
[](const description* a, const description* b) {
return a->mp_rank < b->mp_rank;
}
);
);
return ais_list;
}

View file

@ -334,7 +334,7 @@ void readonly_context_impl::calculate_moves(const unit_map& units, std::map<map_
move_map& dstsrc, bool enemy, bool assume_full_movement,
const terrain_filter* remove_destinations,
bool see_all
) const
) const
{
for(unit_map::const_iterator un_it = units.begin(); un_it != units.end(); ++un_it) {

View file

@ -295,20 +295,20 @@ double attack_analysis::rating(double aggression, const readonly_context& ai_obj
// Prefer to attack already damaged targets.
value += ((target_starting_damage/3 + avg_damage_inflicted) - (1.0-aggression)*avg_damage_taken)/10.0;
// If the unit is surrounded and there is no support,
// or if the unit is surrounded and the average damage is 0,
// the unit skips its sanity check and tries to break free as good as possible.
if(!is_surrounded || (support != 0 && avg_damage_taken != 0))
{
// Sanity check: if we're putting ourselves at major risk,
// and have no chance to kill, and we're not aiding our allies
// who are also attacking, then don't do it.
if(vulnerability > 50.0 && vulnerability > support*2.0
&& chance_to_kill < 0.02 && aggression < 0.75
&& !attack_close(target)) {
return -1.0;
}
}
// If the unit is surrounded and there is no support,
// or if the unit is surrounded and the average damage is 0,
// the unit skips its sanity check and tries to break free as good as possible.
if(!is_surrounded || (support != 0 && avg_damage_taken != 0))
{
// Sanity check: if we're putting ourselves at major risk,
// and have no chance to kill, and we're not aiding our allies
// who are also attacking, then don't do it.
if(vulnerability > 50.0 && vulnerability > support*2.0
&& chance_to_kill < 0.02 && aggression < 0.75
&& !attack_close(target)) {
return -1.0;
}
}
if(!leader_threat && vulnerability*terrain_quality > 0.0 && support != 0) {
value *= support/(vulnerability*terrain_quality);

View file

@ -205,58 +205,59 @@ pathfind::plain_route formula_ai::shortest_path_calculator(const map_location &s
const map_location &dst, unit_map::iterator &unit_it,
pathfind::teleport_map& allowed_teleports) const
{
map_location destination = dst;
map_location destination = dst;
unit_map &units_ = resources::gameboard->units();
pathfind::shortest_path_calculator calc(*unit_it, current_team(), resources::gameboard->teams(), resources::gameboard->map());
unit_map &units_ = resources::gameboard->units();
pathfind::shortest_path_calculator calc(*unit_it, current_team(), resources::gameboard->teams(), resources::gameboard->map());
unit_map::const_iterator dst_un = units_.find(destination);
unit_map::const_iterator dst_un = units_.find(destination);
map_location res;
map_location res;
if( dst_un != units_.end() ) {
//there is unit standing at dst, let's try to find free hex to move to
const map_location::DIRECTION preferred = destination.get_relative_dir(src);
if( dst_un != units_.end() ) {
//there is unit standing at dst, let's try to find free hex to move to
const map_location::DIRECTION preferred = destination.get_relative_dir(src);
int best_rating = 100;//smaller is better
int best_rating = 100;//smaller is better
const auto adj = get_adjacent_tiles(destination);
for(std::size_t n = 0; n < adj.size(); ++n) {
if(resources::gameboard->map().on_board(adj[n]) == false) {
continue;
}
for(std::size_t n = 0; n < adj.size(); ++n) {
if(resources::gameboard->map().on_board(adj[n]) == false) {
continue;
}
if(units_.find(adj[n]) != units_.end()) {
continue;
}
if(units_.find(adj[n]) != units_.end()) {
continue;
}
static const std::size_t NDIRECTIONS = map_location::NDIRECTIONS;
unsigned int difference = std::abs(static_cast<int>(preferred - n));
if(difference > NDIRECTIONS/2) {
difference = NDIRECTIONS - difference;
}
static const std::size_t NDIRECTIONS = map_location::NDIRECTIONS;
unsigned int difference = std::abs(static_cast<int>(preferred - n));
if(difference > NDIRECTIONS/2) {
difference = NDIRECTIONS - difference;
}
const int rating = difference * 2;
if(rating < best_rating || res.valid() == false) {
best_rating = rating;
res = adj[n];
}
}
}
const int rating = difference * 2;
if(rating < best_rating || res.valid() == false) {
best_rating = rating;
res = adj[n];
}
}
}
if( res != map_location() ) {
destination = res;
}
if( res != map_location() ) {
destination = res;
}
pathfind::plain_route route = pathfind::a_star_search(src, destination, 1000.0, calc,
resources::gameboard->map().w(), resources::gameboard->map().h(), &allowed_teleports);
pathfind::plain_route route = pathfind::a_star_search(src, destination,
1000.0, calc, resources::gameboard->map().w(),
resources::gameboard->map().h(), &allowed_teleports);
return route;
return route;
}
pathfind::teleport_map formula_ai::get_allowed_teleports(unit_map::iterator& unit_it) const
{
return pathfind::get_teleport_locations(*unit_it, current_team(), true);
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)

View file

@ -51,10 +51,10 @@ variant move_map_callable::get_value(const std::string& key) const
if(key == "moves") {
std::vector<variant> vars;
for(move_map::const_iterator i = srcdst_.begin(); i != srcdst_.end(); ++i) {
if( i->first == i->second || units_.count(i->second) == 0) {
auto item = std::make_shared<move_callable>(i->first, i->second);
vars.emplace_back(item);
}
if( i->first == i->second || units_.count(i->second) == 0) {
auto item = std::make_shared<move_callable>(i->first, i->second);
vars.emplace_back(item);
}
}
return variant(vars);
@ -159,12 +159,12 @@ void outcome_callable::get_inputs(formula_input_vector& inputs) const {
}
attack_callable::attack_callable(const map_location& move_from,
const map_location& src, const map_location& dst, int weapon)
const map_location& src, const map_location& dst, int weapon)
: move_from_(move_from), src_(src), dst_(dst),
bc_(resources::gameboard->units(), src, dst, weapon, -1, 1.0, nullptr,
resources::gameboard->units().find(move_from).get_shared_ptr())
{
type_ = ATTACK_C;
type_ = ATTACK_C;
}
variant attack_callable::get_value(const std::string& key) const {

View file

@ -190,7 +190,7 @@ class move_map_callable : public formula_callable {
typedef std::multimap<map_location, map_location> move_map;
const move_map& srcdst_;
const move_map& dstsrc_;
const unit_map& units_;
const unit_map& units_;
variant get_value(const std::string& key) const override;
void get_inputs(formula_input_vector& inputs) const override;

View file

@ -73,7 +73,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_formula_ptr formula);
candidate_action_filters filter_map_;
};

View file

@ -88,7 +88,7 @@ bool stage_unit_formulas::do_play_stage()
units_with_formulas.insert( wfl::unit_formula_pair( i, priority ) );
}
}
}
}
for(wfl::unit_formula_set::iterator pair_it = units_with_formulas.begin() ; pair_it != units_with_formulas.end() ; ++pair_it)
{

View file

@ -291,7 +291,7 @@ version_table_manager::version_table_manager()
#endif
#ifdef __APPLE__
// Always compiled in.
// Always compiled in.
features.emplace_back(N_("feature^Cocoa notifications back end"));
features.back().enabled = true;
#endif /* __APPLE__ */

View file

@ -275,7 +275,7 @@ commandline_options::commandline_options(const std::vector<std::string>& args)
("parm", po::value<std::vector<std::string>>()->composing(), "sets additional parameters for this side. <arg> should have format side:name:value.")
("scenario", po::value<std::string>(), "selects a multiplayer scenario. The default scenario is \"multiplayer_The_Freelands\".")
("side", po::value<std::vector<std::string>>()->composing(), "selects a faction of the current era for this side by id. <arg> should have format side:value.")
("turns", po::value<std::string>(), "sets the number of turns. By default no turn limit is set.")
("turns", po::value<std::string>(), "sets the number of turns. By default no turn limit is set.")
;
po::options_description testing_opts("Testing options");

View file

@ -26,7 +26,7 @@
class bad_commandline_resolution : public boost::program_options::error
{
public:
bad_commandline_resolution(const std::string& resolution);
bad_commandline_resolution(const std::string& resolution);
};
class bad_commandline_tuple : public boost::program_options::error

View file

@ -550,7 +550,7 @@ static void BF_swap(BF_word *x, int count)
#endif
static void BF_set_key(const char *key, BF_key expanded, BF_key initial,
unsigned char flags)
unsigned char flags)
{
const char *ptr = key;
unsigned int bug, i, j;

View file

@ -1,6 +1,6 @@
/*
Copyright (C) 2018 - 2022
by Martin Hrubý <hrubymar10@gmail.com>
by Martin Hrubý <hrubymar10@gmail.com>
Part of the Battle for Wesnoth Project https://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify

View file

@ -2186,7 +2186,7 @@ void display::scroll_to_tile(const map_location& loc, SCROLL_TYPE scroll_type, b
void display::scroll_to_tiles(map_location loc1, map_location loc2,
SCROLL_TYPE scroll_type, bool check_fogged,
double add_spacing, bool force)
double add_spacing, bool force)
{
std::vector<map_location> locs;
locs.push_back(loc1);

View file

@ -858,7 +858,7 @@ bool editor_controller::do_execute_command(const hotkey::hotkey_command& cmd, in
context_manager_->perform_refresh(editor_action_select_none());
return true;
case HOTKEY_EDITOR_SELECTION_FILL:
context_manager_->fill_selection();
context_manager_->fill_selection();
return true;
case HOTKEY_EDITOR_SELECTION_RANDOMIZE:
context_manager_->perform_refresh(editor_action_shuffle_area(

View file

@ -39,7 +39,7 @@ struct item_group
std::string id;
t_string name;
std::string icon;
bool core;
bool core;
};
@ -77,7 +77,7 @@ public:
/** Menu expanding for palette group list */
virtual void expand_palette_groups_menu(std::vector<config>& items, int i) = 0;
//item
//item
virtual std::size_t num_items() = 0;
virtual std::size_t start_num() = 0;
virtual void set_start_item(std::size_t index) = 0;

View file

@ -180,17 +180,17 @@ protected:
* Index of the item at the top-left of the visible area, used for scrolling up and down.
*/
std::size_t items_start_;
std::set<std::string> non_core_items_;
std::set<std::string> non_core_items_;
private:
std::string active_group_;
std::string selected_fg_item_;
std::string selected_bg_item_;
editor_toolkit& toolkit_;
std::vector<gui::tristate_button> buttons_;
editor_toolkit& toolkit_;
std::vector<gui::tristate_button> buttons_;
int help_handle_;
int help_handle_;
};

View file

@ -69,7 +69,7 @@ public:
items.erase(items.begin() + i);
}
//item
//item
virtual std::size_t num_items() override {return 0;}
virtual std::size_t start_num() override {return 0;}
virtual void set_start_item(std::size_t /*index*/) override {}

View file

@ -120,7 +120,7 @@ private:
std::unique_ptr<location_palette_button> button_add_;
std::unique_ptr<location_palette_button> button_delete_;
std::unique_ptr<location_palette_button> button_goto_;
int help_handle_;
int help_handle_;
editor_display& disp_;
};

View file

@ -78,8 +78,8 @@ public:
pango_text();
pango_text(const pango_text &) = delete;
pango_text & operator = (const pango_text &) = delete;
pango_text(const pango_text &) = delete;
pango_text & operator = (const pango_text &) = delete;
/**
* Returns the rendered text as a texture.
@ -299,12 +299,12 @@ private:
bool link_aware_;
/**
* The color to render links in.
*
* Links are formatted using pango &lt;span> as follows:
*
* &lt;span underline="single" color=" + link_color_ + ">
*/
* The color to render links in.
*
* Links are formatted using pango &lt;span> as follows:
*
* &lt;span underline="single" color=" + link_color_ + ">
*/
color_t link_color_;
/** The font family class used. */

View file

@ -1138,8 +1138,7 @@ static void parse_function_args(const tk::token* &i1, const tk::token* i2, std::
}
static void parse_args(const tk::token* i1, const tk::token* i2,
std::vector<expression_ptr>* res,
function_symbol_table* symbols)
std::vector<expression_ptr>* res, function_symbol_table* symbols)
{
int parens = 0;
const tk::token* beg = i1;
@ -1162,8 +1161,7 @@ static void parse_args(const tk::token* i1, const tk::token* i2,
}
static void parse_set_args(const tk::token* i1, const tk::token* i2,
std::vector<expression_ptr>* res,
function_symbol_table* symbols)
std::vector<expression_ptr>* res, function_symbol_table* symbols)
{
int parens = 0;
bool check_pointer = false;

View file

@ -164,7 +164,7 @@ variant::variant(double n, variant::DECIMAL_VARIANT_TYPE)
}
variant::variant(const std::vector<variant>& vec)
: value_((std::make_shared<variant_list>(vec)))
: value_((std::make_shared<variant_list>(vec)))
{
assert(value_.get());
}

View file

@ -411,10 +411,10 @@ void load_config(const config &v)
server_list.clear();
for(const config& server : v.child_range("server")) {
server_info sinf;
sinf.name = server["name"].str();
sinf.address = server["address"].str();
server_list.push_back(sinf);
server_info sinf;
sinf.name = server["name"].str();
sinf.address = server["address"].str();
server_list.push_back(sinf);
}
if(const config& s = v.child("sounds")) {

View file

@ -27,13 +27,12 @@ class game_config_view
public:
game_config_view()
{
{}
}
static game_config_view wrap(const config& cfg) {
return game_config_view(cfg);
}
static game_config_view wrap(const config& cfg)
{
return game_config_view(cfg);
}
config_array_view child_range(config_key_type key) const;
@ -46,17 +45,17 @@ public:
game_config_view merged_children_view(config_key_type key) const;
config_array_view& data()
{
return cfgs_;
}
config_array_view& data()
{
return cfgs_;
}
private:
explicit game_config_view(const config& cfg)
: cfgs_()
{
cfgs_.push_back(cfg);
}
config_array_view cfgs_;
: cfgs_()
{
cfgs_.push_back(cfg);
}
config_array_view cfgs_;
};

View file

@ -373,7 +373,7 @@ void game_display::draw_sidebar()
return;
refresh_report("report_clock");
refresh_report("report_battery");
refresh_report("report_battery");
refresh_report("report_countdown");
if (invalidateGameStatus_)

View file

@ -559,7 +559,7 @@ void connect_engine::start_game_commandline(const commandline_options& cmdline_o
}
}
}
}
}
save_reserved_sides_information();

View file

@ -754,10 +754,10 @@ void create_engine::init_all_levels()
// Sort sp campaigns by rank.
std::stable_sort(sp_campaigns.begin(), sp_campaigns.end(),
[](const create_engine::level_ptr& a, const create_engine::level_ptr& b) {
[](const create_engine::level_ptr& a, const create_engine::level_ptr& b) {
return a->data()["rank"].to_int(1000) < b->data()["rank"].to_int(1000);
}
);
);
}
void create_engine::init_extras(const MP_EXTRA extra_type)
@ -813,7 +813,7 @@ std::vector<create_engine::level_ptr> create_engine::get_levels_by_type_unfilter
std::vector<create_engine::level_ptr> create_engine::get_levels_by_type(level_type::type type) const
{
auto& g_list = type_map_.at(type);
auto& g_list = type_map_.at(type);
std::vector<level_ptr> levels;
for(std::size_t level : g_list.games_filtered) {

View file

@ -33,8 +33,8 @@ std::set<std::string>& registered_window_types()
void register_window(const std::string& id)
{
bool added = false;
std::tie(std::ignore, added) = registered_window_types().emplace(id);
bool added = false;
std::tie(std::ignore, added) = registered_window_types().emplace(id);
if(!added) {
WRN_GUI_P << "Window '" << id << "' already registered. Ignoring." << std::endl;

View file

@ -104,10 +104,10 @@ std::set<std::string>& registered_window_types();
struct registered_widget_parser
{
/** The widget definition WML parser function. */
/** The widget definition WML parser function. */
widget_parser_t parser;
/** The tag containing the definition WML. */
/** The tag containing the definition WML. */
const char* key;
};

View file

@ -45,10 +45,10 @@ public:
game_cache_options();
/**
* The display function.
* The display function.
*
* See @ref modal_dialog for more information.
*/
*/
DEFINE_SIMPLE_DISPLAY_WRAPPER(game_cache_options)
private:

View file

@ -34,7 +34,7 @@ public:
game_delete();
/** The execute function. See @ref modal_dialog for more information. */
DEFINE_SIMPLE_EXECUTE_WRAPPER(game_delete)
DEFINE_SIMPLE_EXECUTE_WRAPPER(game_delete)
private:
virtual const std::string& window_id() const override;

View file

@ -39,15 +39,15 @@
// TODO duplicated from attack_predictions.cpp
static std::string get_probability_string(const double prob)
{
std::ostringstream ss;
std::ostringstream ss;
if(prob > 0.9995) {
ss << "100";
} else {
ss << std::fixed << std::setprecision(1) << 100.0 * prob;
}
if(prob > 0.9995) {
ss << "100";
} else {
ss << std::fixed << std::setprecision(1) << 100.0 * prob;
}
return ss.str();
return ss.str();
}
namespace gui2::dialogs

View file

@ -233,8 +233,8 @@ void debug_layout_graph::widget_generate_info(std::ostream& out,
= dynamic_cast<const class scrollbar_container*>(widget);
if(scrollbar_container) {
widget_generate_info(
out, scrollbar_container->content_grid_.get(), id + "_C", true);
widget_generate_info(out,
scrollbar_container->content_grid_.get(), id + "_C", true);
out << "\t" << id << " -> " << id << "_C"
<< " [label=\"(content)\"];\n";
}
@ -318,7 +318,7 @@ void debug_layout_graph::widget_generate_state_info(std::ostream& out,
<< "<tr><td>\n"
<< "active=" << control->get_active() << '\n' << "</td></tr>\n"
<< "<tr><td>\n"
<< "visible=" << static_cast<int>(control->get_visible()) << '\n' << "</td></tr>\n"
<< "visible=" << static_cast<int>(control->get_visible()) << '\n' << "</td></tr>\n"
<< "<tr><td>\n"
<< "drawing action=" << static_cast<int>(control->get_drawing_action()) << '\n'
<< "</td></tr>\n"
@ -403,7 +403,7 @@ void debug_layout_graph::grid_generate_info(std::ostream& out,
for(unsigned row = 0; row < grid->get_rows(); ++row) {
for(unsigned col = 0; col < grid->get_cols(); ++col) {
const widget* widget = grid->get_widget(row, col);
const widget* widget = grid->get_widget(row, col);
assert(widget);
widget_generate_info(

View file

@ -31,13 +31,13 @@ enum retval : int
/** Default, unset return value. */
NONE = 0,
/** Dialog was closed with the OK button. */
/** Dialog was closed with the OK button. */
OK = -1,
/** Dialog was closed with the CANCEL button. */
/** Dialog was closed with the CANCEL button. */
CANCEL = -2,
/** The dialog was closed automatically as its timeout had been reached. */
/** The dialog was closed automatically as its timeout had been reached. */
AUTO_CLOSE = -3,
};

View file

@ -113,7 +113,7 @@ public:
/** See @ref styled_widget::get_state. */
virtual unsigned get_state() const override;
/**
/**
* Possible states of the widget.
*
* Note the order of the states must be the same as defined in settings.hpp.

View file

@ -130,8 +130,8 @@ help_manager::~help_manager()
game_cfg = nullptr;
default_toplevel.clear();
hidden_sections.clear();
// These last numbers must be reset so that the content is regenerated.
// Upon next start.
// These last numbers must be reset so that the content is regenerated.
// Upon next start.
last_num_encountered_units = -1;
last_num_encountered_terrains = -1;
}
@ -218,14 +218,15 @@ void show_with_toplevel(const section &toplevel_sec,
f.layout(xloc, yloc, width, height);
f.draw();
// Find all unit_types that have not been constructed yet and fill in the information
// needed to create the help topics
// Find all unit_types that have not been constructed yet and fill in the information
// needed to create the help topics
unit_types.build_all(unit_type::HELP_INDEXED);
if (preferences::encountered_units().size() != size_t(last_num_encountered_units) ||
preferences::encountered_terrains().size() != size_t(last_num_encountered_terrains) ||
last_debug_state != game_config::debug ||
last_num_encountered_units < 0) {
preferences::encountered_terrains().size() != size_t(last_num_encountered_terrains) ||
last_debug_state != game_config::debug ||
last_num_encountered_units < 0)
{
// More units or terrains encountered, update the contents.
last_num_encountered_units = preferences::encountered_units().size();
last_num_encountered_terrains = preferences::encountered_terrains().size();

View file

@ -185,16 +185,20 @@ private:
class title_less
{
public:
bool operator()(const topic &t1, const topic &t2) {
return translation::compare(t1.title, t2.title) < 0; }
bool operator()(const topic &t1, const topic &t2)
{
return translation::compare(t1.title, t2.title) < 0;
}
};
/** To be used as a function object when sorting section lists on the title. */
class section_less
{
public:
bool operator()(const section& s1, const section& s2) {
return translation::compare(s1.title, s2.title) < 0; }
bool operator()(const section& s1, const section& s2)
{
return translation::compare(s1.title, s2.title) < 0;
}
};
class string_less

View file

@ -160,9 +160,9 @@ int help_menu::process()
int mousex, mousey;
sdl::get_mouse_state(&mousex, &mousey);
if (!visible_items_.empty() &&
static_cast<std::size_t>(res) < visible_items_.size()) {
if (!visible_items_.empty()
&& static_cast<std::size_t>(res) < visible_items_.size())
{
selected_item_ = visible_items_[res];
const section* sec = selected_item_.sec;
if (sec != nullptr) {

View file

@ -283,7 +283,7 @@ void help_text_area::handle_jump_cfg(const config &cfg)
jump_to = to;
}
if (jump_to != 0 && static_cast<int>(jump_to) <
get_max_x(curr_loc_.first, curr_row_height_)) {
get_max_x(curr_loc_.first, curr_row_height_)) {
curr_loc_.first = jump_to;
}

View file

@ -624,7 +624,7 @@ void command_executor::execute_command_wrap(const command_executor::queued_comma
if (!command.press) {
return; // none of the commands here respond to a key release
}
}
switch(command.command->command) {
case HOTKEY_FULLSCREEN:

View file

@ -189,7 +189,7 @@ public:
* Constructor.
*
* @pre zoom >= offset Otherwise the result will have empty pixels.
* @pre offset > 0 Otherwise the procedure will not return.
* @pre offset > 0 Otherwise the procedure will not return.
*
* @param degrees Amount of rotation (in degrees).
* Positive values are clockwise; negative are counter-clockwise.

View file

@ -38,7 +38,7 @@ struct language_def
{}
language_def(const std::string& name, const t_string& lang, const std::string& dir,
const std::string &salternates = "", const std::string& sort_name = "", const std::string& percent = "100") :
const std::string &salternates = "", const std::string& sort_name = "", const std::string& percent = "100") :
localename(name),
alternates(utils::split(salternates)),
language(lang),
@ -50,7 +50,7 @@ struct language_def
} catch(const std::invalid_argument&) {
this->percent = 100;
}
}
}
std::string localename;
std::vector<std::string> alternates;

View file

@ -88,7 +88,7 @@ static std::vector<char*> gArgs;
setenv ("SDL_ENABLEAPPEVENTS", "1", 1);
setenv ("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 1);
/* Set config files for pango and fontconfig, so the data they need can be found */
/* Set config files for pango and fontconfig, so the data they need can be found */
setenv ("PANGO_RC_FILE", "./pangorc", 1);
setenv ("PANGO_SYSCONFDIR", ".", 1);
setenv ("PANGO_LIBDIR", ".", 1);

View file

@ -101,7 +101,7 @@ struct map_location {
bool operator==(const map_location& a) const { return x == a.x && y == a.y; }
bool operator!=(const map_location& a) const { return !operator==(a); }
/** three-way comparator */
/** three-way comparator */
int do_compare(const map_location& a) const {return x == a.x ? y - a.y : x - a.x; }
// Location arithmetic operations treating the locations as vectors in

View file

@ -25,8 +25,8 @@ struct map_location;
namespace image {
/**
* function to create the minimap for a given map
* the surface returned must be freed by the user
*/
* function to create the minimap for a given map
* the surface returned must be freed by the user
*/
surface getMinimap(int w, int h, const gamemap &map_, const team *vm = nullptr, const std::map<map_location,unsigned int> *reach_map = nullptr, bool ignore_terrain_disabled = false);
}

View file

@ -268,7 +268,7 @@ bool mouse_handler_base::is_right_click(const SDL_MouseButtonEvent& event) const
(void) event;
return false;
#else
if(event.which == SDL_TOUCH_MOUSEID) {
if(event.which == SDL_TOUCH_MOUSEID) {
return false;
}
return event.button == SDL_BUTTON_RIGHT

View file

@ -38,10 +38,10 @@ public:
/**
* Same as uint32_t version, but uses a stringstream to convert given
* hex string.
* @param seed A hex string. Should not have 0x leading.
* @param call_count Value to set internal call counter to after seeding.
*/
* hex string.
* @param seed A hex string. Should not have 0x leading.
* @param call_count Value to set internal call counter to after seeding.
*/
void seed_random(const std::string & seed, const unsigned int call_count = 0);
/**

View file

@ -141,7 +141,7 @@ void prefs_event_handler::handle_window_event(const SDL_Event& event)
void write_preferences()
{
#ifndef _WIN32
bool prefs_file_existed = access(filesystem::get_prefs_file().c_str(), F_OK) == 0;
bool prefs_file_existed = access(filesystem::get_prefs_file().c_str(), F_OK) == 0;
#endif
try {
@ -154,13 +154,11 @@ void write_preferences()
preferences::save_credentials();
#ifndef _WIN32
if(!prefs_file_existed) {
if(chmod(filesystem::get_prefs_file().c_str(), 0600) == -1) {
if(!prefs_file_existed) {
if(chmod(filesystem::get_prefs_file().c_str(), 0600) == -1) {
ERR_FS << "error setting permissions of preferences file '" << filesystem::get_prefs_file() << "'" << std::endl;
}
}
}
}
#endif
}

View file

@ -475,7 +475,7 @@ int game_lua_kernel::intf_get_displayed_unit(lua_State *L)
* Gets all the units matching a given filter.
* - Arg 1: optional table containing a filter
* - Arg 2: optional location (to find all units that would match on that location)
OR unit (to find all units that would match adjacent to that unit)
* OR unit (to find all units that would match adjacent to that unit)
* - Ret 1: table containing full userdata with __index pointing to
* impl_unit_get and __newindex pointing to impl_unit_set.
*/

View file

@ -1182,7 +1182,7 @@ int lua_kernel_base::intf_require(lua_State* L)
if (!this->protected_call(L, 0, 1, std::bind(&lua_kernel_base::log_error, this, std::placeholders::_1, std::placeholders::_2))) {
// historically if wesnoth.require fails it just yields nil and some logging messages, not a lua error
return 0;
}
}
// stack is now [packagename] [wesnoth] [package] [results]
lua_pushvalue(L, 1);

View file

@ -22,10 +22,10 @@ template<typename T>
class enable_lua_ptr
{
public:
enable_lua_ptr(T* tp) : self_(std::make_shared<T*>(tp)) {}
enable_lua_ptr(T* tp) : self_(std::make_shared<T*>(tp)) {}
private:
friend class lua_ptr<T>;
std::shared_ptr<T*> self_;
friend class lua_ptr<T>;
std::shared_ptr<T*> self_;
};
/** Tmust inherit enable_lua_ptr<T> */
@ -33,13 +33,13 @@ template<typename T>
class lua_ptr
{
public:
lua_ptr(enable_lua_ptr<T>& o) : self_(o.self_) { }
T* get_ptr()
{
if(auto pp = self_.lock()) {
return *pp;
}
return nullptr;
}
std::weak_ptr<T*> self_;
lua_ptr(enable_lua_ptr<T>& o) : self_(o.self_) { }
T* get_ptr()
{
if(auto pp = self_.lock()) {
return *pp;
}
return nullptr;
}
std::weak_ptr<T*> self_;
};

View file

@ -62,8 +62,8 @@ static lg::log_domain log_scripting_lua("scripting/lua");
static gui2::widget* find_child_by_index(gui2::widget& w, int i)
{
assert(i > 0);
if(gui2::listbox* list = dynamic_cast<gui2::listbox*>(&w)) {
assert(i > 0);
if(gui2::listbox* list = dynamic_cast<gui2::listbox*>(&w)) {
int n = list->get_item_count();
if(i > n) {
for(; n < i; ++n) {
@ -104,7 +104,7 @@ static gui2::widget* find_child_by_index(gui2::widget& w, int i)
static gui2::widget* find_child_by_name(gui2::widget& w, const std::string& m)
{
return w.find(m, false);
return w.find(m, false);
}
using tgetters = std::map<std::string, std::vector<std::function<bool(lua_State*, gui2::widget&, bool)>>>;

View file

@ -2010,29 +2010,29 @@ void blit_surface(const surface& surf,
src_rect.h = srcrect->h;
if (src_rect.x < 0) {
if (src_rect.x + src_rect.w <= 0 || src_rect.x + dst_rect.w <= 0 )
return;
if (src_rect.x + src_rect.w <= 0 || src_rect.x + dst_rect.w <= 0 )
return;
dst_rect.x -= src_rect.x;
dst_rect.w += src_rect.x;
src_rect.w += src_rect.x;
src_rect.x = 0;
}
if (src_rect.y < 0) {
if (src_rect.y + src_rect.h <= 0 || src_rect.y + dst_rect.h <= 0 )
return;
if (src_rect.y + src_rect.h <= 0 || src_rect.y + dst_rect.h <= 0 )
return;
dst_rect.y -= src_rect.y;
dst_rect.h += src_rect.y;
src_rect.h += src_rect.y;
src_rect.y = 0;
}
if (src_rect.x + src_rect.w > surf->w) {
if (src_rect.x >= surf->w)
return;
if (src_rect.x >= surf->w)
return;
src_rect.w = surf->w - src_rect.x;
}
if (src_rect.y + src_rect.h > surf->h) {
if (src_rect.y >= surf->h)
return;
if (src_rect.y >= surf->h)
return;
src_rect.h = surf->h - src_rect.y;
}
}

View file

@ -103,7 +103,7 @@ surface scale_surface_nn(const surface & surf, int w, int h);
surface scale_surface(const surface &surf, int w, int h);
/** Scale a surface using simple bilinear filtering (discarding rgb from source
pixels with 0 alpha)
* pixels with 0 alpha)
* @param surf The source surface.
* @param w The width of the resulting surface.
* @param h The height of the resulting surface.

View file

@ -411,7 +411,7 @@ schema_self_validator::schema_self_validator()
, type_nesting_()
, condition_nesting_()
{
defined_types_.insert("t_string");
defined_types_.insert("t_string");
}

View file

@ -602,7 +602,7 @@ static bool is_username_char(char c) {
}
static bool is_wildcard_char(char c) {
return ((c == '?') || (c == '*'));
return ((c == '?') || (c == '*'));
}
bool isvalid_username(const std::string& username) {
@ -618,13 +618,13 @@ bool isvalid_username(const std::string& username) {
}
bool isvalid_wildcard(const std::string& username) {
const std::size_t alnum = std::count_if(username.begin(), username.end(), isalnum);
const std::size_t alnum = std::count_if(username.begin(), username.end(), isalnum);
const std::size_t valid_char =
std::count_if(username.begin(), username.end(), is_username_char);
const std::size_t wild_char =
std::count_if(username.begin(), username.end(), is_wildcard_char);
std::count_if(username.begin(), username.end(), is_username_char);
const std::size_t wild_char =
std::count_if(username.begin(), username.end(), is_wildcard_char);
if ((alnum + valid_char + wild_char != username.size())
|| valid_char == username.size() || username.empty() )
|| valid_char == username.size() || username.empty() )
{
return false;
}

View file

@ -18,8 +18,8 @@
class rs_base
{
public:
rs_base(){}
virtual ~rs_base(){}
virtual void read(mariadb::result_set_ref rslt) =0;
public:
rs_base() {}
virtual ~rs_base() {}
virtual void read(mariadb::result_set_ref rslt) = 0;
};

View file

@ -103,8 +103,8 @@ public:
char* duplicate() const;
private:
const char* str_;
unsigned int size_;
const char* str_;
unsigned int size_;
};
std::ostream& operator<<(std::ostream& o, const string_span& s);

View file

@ -74,8 +74,8 @@ void wesnothd::player::mark_available(const int game_id,
void wesnothd::player::mark_registered(bool registered)
{
cfg_.set_attr("registered", registered ? "yes" : "no");
registered_ = registered;
cfg_.set_attr("registered", registered ? "yes" : "no");
registered_ = registered;
}
bool wesnothd::player::is_message_flooding()

View file

@ -357,14 +357,14 @@ void merge_alias_lists(t_translation::ter_list& first, const t_translation::ter_
if(*i == t_translation::BASE) {
t_translation::ter_list::iterator insert_it = first.erase(i);
//if we are in reverse mode, insert PLUS before and MINUS after the base list
//so calculation of base aliases will work normal
//so calculation of base aliases will work normal
if(revert) {
// insert_it = first.insert(insert_it, t_translation::PLUS);
// insert_it++;
insert_it = first.insert(insert_it, t_translation::MINUS);
}
else {
//else insert PLUS after the base aliases to restore previous "reverse state"
//else insert PLUS after the base aliases to restore previous "reverse state"
insert_it = first.insert(insert_it, t_translation::PLUS);
}

View file

@ -29,11 +29,11 @@
namespace t_translation {
/**
* Return the maximum allowed map size (in either dimension),
* the maximum map area is, therefore, this value squared.
*/
int max_map_size();
/**
* Return the maximum allowed map size (in either dimension),
* the maximum map area is, therefore, this value squared.
*/
int max_map_size();
typedef uint32_t ter_layer;
const ter_layer WILDCARD = 0x2A000000;
@ -116,7 +116,7 @@ namespace t_translation {
/** Contains an x and y coordinate used for starting positions in maps. */
using coordinate = map_location;
// Exception thrown if there's an error with the terrain.
// Exception thrown if there's an error with the terrain.
// Note: atm most thrown result in a crash, but I like
// an uncatched exception better than an assert.
struct error : public game::error {
@ -154,7 +154,7 @@ namespace t_translation {
extern const terrain_code STAR; // *
extern const terrain_code BASE; // references the base terrain in movement/defense aliases
extern const ter_match ALL_OFF_MAP;
extern const ter_match ALL_OFF_MAP;
extern const ter_match ALL_FORESTS;
extern const ter_match ALL_HILLS;
extern const ter_match ALL_MOUNTAINS; //excluding impassable mountains
@ -163,23 +163,23 @@ namespace t_translation {
/**
* Reads a single terrain from a string.
*
* @param str The string which should contain 1 terrain code;
the new format of a terrain code
* is 2 to 4 characters in the set
* @param str The string which should contain 1 terrain code;
* the new format of a terrain code
* is 2 to 4 characters in the set
*@verbatim
* [a-Z][A-Z]/|\_
* [a-Z][A-Z]/|\_
*@endverbatim
* The underscore is intended for internal use.
* Other letters and characters are not validated but
* users of these letters can get nasty surprises.
* The * is used as wildcard in some cases.
* The terrain code can be two groups separated by a caret,
* the first group is the base terrain,
* the second the overlay terrain.
* The underscore is intended for internal use.
* Other letters and characters are not validated but
* users of these letters can get nasty surprises.
* The * is used as wildcard in some cases.
* The terrain code can be two groups separated by a caret,
* the first group is the base terrain,
* the second the overlay terrain.
*
* @param filler if there's no layer this value will be used as the second layer
* @param filler if there's no layer this value will be used as the second layer
*
* @return A single terrain code
* @return A single terrain code
*/
terrain_code read_terrain_code(std::string_view str, const ter_layer filler = NO_LAYER);

View file

@ -192,11 +192,11 @@ t_string terrain_type_data::get_underlying_terrain_string(const t_translation::t
if(underlying.size() > 1 || underlying[0] != terrain) {
str += " (";
t_translation::ter_list::const_iterator i = underlying.begin();
str += get_terrain_info(*i).name();
while (++i != underlying.end()) {
t_translation::ter_list::const_iterator i = underlying.begin();
str += get_terrain_info(*i).name();
while (++i != underlying.end()) {
str += ", " + get_terrain_info(*i).name();
}
}
str += ")";
}

View file

@ -68,7 +68,7 @@ struct time_of_day
bool operator==(const time_of_day& o) const {
return lawful_bonus == o.lawful_bonus
&& bonus_modified == o.bonus_modified
&& bonus_modified == o.bonus_modified
&& image == o.image
&& name == o.name
&& id == o.id

View file

@ -940,8 +940,16 @@ std::string attack_type::weapon_specials_value(const std::set<std::string> check
return weapon_abilities;
}
void attack_type::weapon_specials_impl_self(std::string& temp_string, unit_const_ptr self, const_attack_ptr self_attack, const_attack_ptr other_attack, const map_location& self_loc, AFFECTS whom,
std::set<std::string>& checking_name, const std::set<std::string>& checking_tags, bool leader_bool)
void attack_type::weapon_specials_impl_self(
std::string& temp_string,
unit_const_ptr self,
const_attack_ptr self_attack,
const_attack_ptr other_attack,
const map_location& self_loc,
AFFECTS whom,
std::set<std::string>& checking_name,
const std::set<std::string>& checking_tags,
bool leader_bool)
{
if(self){
for (const config::any_child sp : self->abilities().all_children_range()){
@ -952,8 +960,17 @@ void attack_type::weapon_specials_impl_self(std::string& temp_string, unit_const
}
}
void attack_type::weapon_specials_impl_adj(std::string& temp_string, unit_const_ptr self, const_attack_ptr self_attack, const_attack_ptr other_attack, const map_location& self_loc, AFFECTS whom,
std::set<std::string>& checking_name, const std::set<std::string>& checking_tags, const std::string& affect_adjacents, bool leader_bool)
void attack_type::weapon_specials_impl_adj(
std::string& temp_string,
unit_const_ptr self,
const_attack_ptr self_attack,
const_attack_ptr other_attack,
const map_location& self_loc,
AFFECTS whom,
std::set<std::string>& checking_name,
const std::set<std::string>& checking_tags,
const std::string& affect_adjacents,
bool leader_bool)
{
assert(display::get_singleton());
const unit_map& units = display::get_singleton()->get_units();
@ -988,13 +1005,14 @@ void attack_type::weapon_specials_impl_adj(std::string& temp_string, unit_const_
* @param[in] attacking Whether or not the unit with this weapon is the attacker.
* @param[in] other_attack The attack used by the other unit.
*/
attack_type::specials_context_t::specials_context_t(const attack_type& weapon,
const_attack_ptr other_attack,
unit_const_ptr self,
unit_const_ptr other,
const map_location& unit_loc,
const map_location& other_loc,
bool attacking)
attack_type::specials_context_t::specials_context_t(
const attack_type& weapon,
const_attack_ptr other_attack,
unit_const_ptr self,
unit_const_ptr other,
const map_location& unit_loc,
const map_location& other_loc,
bool attacking)
: parent(weapon.shared_from_this())
{
weapon.self_ = self;
@ -1541,8 +1559,14 @@ bool attack_type::special_active(const config& special, AFFECTS whom, const std:
* for elsewhere)
* @param filter_self the filter to use
*/
bool attack_type::special_active_impl(const_attack_ptr self_attack, const_attack_ptr other_attack, const config& special, AFFECTS whom, const std::string& tag_name,
bool include_backstab, const std::string& filter_self)
bool attack_type::special_active_impl(
const_attack_ptr self_attack,
const_attack_ptr other_attack,
const config& special,
AFFECTS whom,
const std::string& tag_name,
bool include_backstab,
const std::string& filter_self)
{
assert(self_attack || other_attack);
bool is_attacker = self_attack ? self_attack->is_attacker_ : !other_attack->is_attacker_;

View file

@ -780,7 +780,7 @@ const frame_parameters unit_frame::merge_parameters(int current_time, const fram
/**
* The engine provides a string for "petrified" and "team color" modifications.
* Note that image_mod is the complete modification and halo_mod is only the TC part.
* Note that image_mod is the complete modification and halo_mod is only the TC part.
*/
result.image_mod = current_val.image_mod + animation_val.image_mod;
if(primary) {

View file

@ -113,7 +113,7 @@ unit_race::unit_race(const config& cfg) :
std::string unit_race::generate_name(unit_race::GENDER gender) const
{
return name_generator_[gender]->generate();
return name_generator_[gender]->generate();
}
const name_generator& unit_race::generator(unit_race::GENDER gender) const
@ -133,7 +133,7 @@ const config::const_child_itors &unit_race::additional_traits() const
const config::const_child_itors &unit_race::additional_topics() const
{
return topics_;
return topics_;
}
unsigned int unit_race::num_traits() const { return ntraits_; }

View file

@ -600,7 +600,9 @@ void unit_die(const map_location& loc, unit& loser,
void unit_attack(display * disp, game_board & board,
const map_location& a, const map_location& b, int damage,
const attack_type& attack, const_attack_ptr secondary_attack,
int swing,const std::string& hit_text,int drain_amount,const std::string& att_text, const std::vector<std::string>* extra_hit_sounds,
int swing, const std::string& hit_text, int drain_amount,
const std::string& att_text,
const std::vector<std::string>* extra_hit_sounds,
bool attacking)
{
if(do_not_show_anims(disp) || (disp->fogged(a) && disp->fogged(b)) || !preferences::show_combat()) {

View file

@ -22,60 +22,60 @@ namespace utils {
template <typename T>
class shared_reference
{
std::shared_ptr<T> m_ptr;
std::shared_ptr<T> m_ptr;
public:
template<typename Y>
shared_reference(const shared_reference<Y>& p)
: m_ptr(p.m_ptr)
{ }
template<typename Y>
shared_reference(shared_reference<Y>&& p)
: m_ptr(std::move(p.m_ptr))
{ }
template<typename Y>
explicit shared_reference(const std::shared_ptr<Y>& p)
: m_ptr(p)
{
if(!p) {
throw std::invalid_argument("invalid shared_reference");
}
}
template<typename Y>
explicit shared_reference(std::shared_ptr<Y>&& p)
: m_ptr(p)
{
if(!p) {
throw std::invalid_argument("invalid shared_reference");
}
}
template<typename Y>
shared_reference(const shared_reference<Y>& p)
: m_ptr(p.m_ptr)
{ }
template<typename Y>
shared_reference(shared_reference<Y>&& p)
: m_ptr(std::move(p.m_ptr))
{ }
template<typename Y>
explicit shared_reference(const std::shared_ptr<Y>& p)
: m_ptr(p)
{
if(!p) {
throw std::invalid_argument("invalid shared_reference");
}
}
template<typename Y>
explicit shared_reference(std::shared_ptr<Y>&& p)
: m_ptr(p)
{
if(!p) {
throw std::invalid_argument("invalid shared_reference");
}
}
template<typename Y>
shared_reference& operator=(shared_reference<Y>&& p)
{
m_ptr = std::move(p.m_ptr);
return *this;
}
template<typename Y>
shared_reference& operator=(const shared_reference<Y>& p)
{
m_ptr = p.m_ptr;
return *this;
}
template<typename Y>
shared_reference& operator=(shared_reference<Y>&& p)
{
m_ptr = std::move(p.m_ptr);
return *this;
}
template<typename Y>
shared_reference& operator=(const shared_reference<Y>& p)
{
m_ptr = p.m_ptr;
return *this;
}
~shared_reference() = default;
~shared_reference() = default;
operator std::shared_ptr<T>()
{ return m_ptr; }
operator std::shared_ptr<T>()
{ return m_ptr; }
T* operator->() { return m_ptr.get(); }
const T* operator->() const { return m_ptr.get(); }
T* operator->() { return m_ptr.get(); }
const T* operator->() const { return m_ptr.get(); }
T& operator*() { return *m_ptr.get(); }
const T& operator*() const { return *m_ptr.get(); }
T& operator*() { return *m_ptr.get(); }
const T& operator*() const { return *m_ptr.get(); }
template <typename XT, typename...XTypes>
friend shared_reference<XT> make_shared_reference(XTypes&&...args);
template <typename XT, typename...XTypes>
friend shared_reference<XT> make_shared_reference(XTypes&&...args);
};
@ -83,7 +83,7 @@ public:
template <typename T, typename...Types>
shared_reference<T> make_shared_reference(Types&&...args)
{
return shared_reference<T>(std::make_shared<T>(std::forward<Types>(args)...));
return shared_reference<T>(std::make_shared<T>(std::forward<Types>(args)...));
}

View file

@ -403,7 +403,7 @@ public:
if(endindex > 0) {
// NOTE: currently this is only called from as_range_visitor_base<vi_policy_create>
// Based on that assumption we use vi_policy_create::get_child_at here instead of making this
// a class template.
// a class template.
vi_policy_create::get_child_at(child, key, endindex - 1);
}

View file

@ -52,10 +52,10 @@ class button : public widget
{
public:
struct error : public game::error {
error()
: game::error("GUI1 button error")
{}
};
error()
: game::error("GUI1 button error")
{}
};
enum TYPE { TYPE_PRESS, TYPE_CHECK, TYPE_TURBO, TYPE_IMAGE, TYPE_RADIO };
TYPE get_type() const { return type_; }
@ -64,7 +64,7 @@ public:
button(CVideo& video, const std::string& label, TYPE type=TYPE_PRESS,
std::string button_image="", SPACE_CONSUMPTION spacing=DEFAULT_SPACE,
const bool auto_join=true, std::string overlay_image="", int font_size = -1);
const bool auto_join=true, std::string overlay_image="", int font_size = -1);
/** Default implementation, but defined out-of-line for efficiency reasons. */