Removed trailing tabs and whitespaces from C++ source

[ci skip]

I ran the command used in 9b7b1751fd, excluding results in lua/ and spirit_po/.

Also, once again, for some reason actions/vision.hpp gets registered as massively changed
(similar to f11fa0652a) despite nothing really having changed at all.
This commit is contained in:
Charles Dang 2017-05-16 06:21:46 +11:00
parent 9eb28eb70d
commit 96ea0eb6b9
45 changed files with 258 additions and 258 deletions

View file

@ -67,7 +67,7 @@ using advancement_option = boost::variant<std::string /*change type*/, const con
/**
* Function which will advance the unit at @a loc to 'advance_to'.
* which is eigher a type to advance to or a config containing the
* which is eigher a type to advance to or a config containing the
* [advancement] to perform an amla.
* Note that 'loc' is not a reference, because if it were a reference,
* we couldn't safely pass in a reference to the item in the map

View file

@ -62,12 +62,12 @@ struct shroud_clearing_action
int original_village_owner;
/// Whether this actions got a timebonus becasue it took a village.
bool take_village_timebonus;
/// Change village owner on undo.
void return_village();
/// Change village owner on redo.
void take_village();
void write(config & cfg) const
{
write_locations(route, cfg);

View file

@ -413,7 +413,7 @@ void undo_list::redo()
resources::recorder->redo(const_cast<const config&>(*action));
// synced_context::run readds the undo command with the normal undo_lis::add function whihc clears the
// redo stack which makes redoign of more than one move impossible. to work around that we save redo stack here and set it later.
redos_list temp;

View file

@ -22,7 +22,7 @@
namespace actions {
class undo_list;
struct undo_event {
config commands, data;
map_location loc1, loc2, filter_loc1, filter_loc2;

View file

@ -1,157 +1,157 @@
/*
Copyright (C) 2003 - 2017 by David White <dave@whitevine.net>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
/**
* @file
* Various functions implementing vision (through fog of war and shroud).
*/
#pragma once
#include "movetype.hpp"
struct map_location;
class team;
class unit;
#include <cstring>
#include <map>
#include <set>
#include <vector>
namespace actions {
class move_unit_spectator;
/// Class that stores the part of a unit's data that is needed for fog clearing.
/// (Used by the undo stack as that cannot rely on a unit sticking around, and
/// we do not really need to copy the entire unit.)
struct clearer_info {
size_t underlying_id;
int sight_range;
bool slowed;
movetype::terrain_costs costs;
clearer_info(const unit & viewer);
clearer_info(const config & cfg);
void write(config & cfg) const;
};
/// Class to encapsulate fog/shroud clearing and the resultant sighted events.
/// Note: This class uses teams as parameters (instead of sides) since a
/// function using this should first check to see if fog/shroud is in use (to
/// save processing when it is not), which implies the team is readily available.
class shroud_clearer {
public:
shroud_clearer(const shroud_clearer&) = delete;
shroud_clearer& operator=(const shroud_clearer&) = delete;
shroud_clearer();
~shroud_clearer();
/// Function to be called if units have moved or otherwise changed.
/// It can also be called if it is desirable to calculate the cache
/// in advance of fog clearing.
/// @param[in] new_team The team whose vision will be used. If left as
/// nullptr, the cache will be just be cleared (to be
/// recalculated later as needed).
void cache_units(const team * new_team=nullptr) { calculate_jamming(new_team); }
// cache_units() is currently a near-synonym for calculate_jamming(). The
// reason for the two names is so the private function says what it does,
// while the public one says why it might be invoked.
/// Clears shroud (and fog) around the provided location for @a view_team
/// based on @a sight_range, @a costs, and @a slowed.
bool clear_unit(const map_location &view_loc, team &view_team,
size_t viewer_id, int sight_range, bool slowed,
const movetype::terrain_costs & costs,
const map_location & real_loc,
const std::set<map_location>* known_units = nullptr,
size_t * enemy_count = nullptr, size_t * friend_count = nullptr,
move_unit_spectator * spectator = nullptr, bool instant = true);
/// Clears shroud (and fog) around the provided location for @a view_team
/// as if @a viewer was standing there.
bool clear_unit(const map_location &view_loc,
const unit &viewer, team &view_team,
const std::set<map_location>* known_units = nullptr,
size_t * enemy_count = nullptr, size_t * friend_count = nullptr,
move_unit_spectator * spectator = nullptr, bool instant = true);
/// Clears shroud (and fog) around the provided location for @a view_team
/// as if @a viewer was standing there. Setting @a instant to false
/// allows some drawing delays that are used to make movement look better.
bool clear_unit(const map_location &view_loc, const unit &viewer,
team &view_team, bool instant)
{ return clear_unit(view_loc, viewer, view_team, nullptr, nullptr, nullptr, nullptr, instant); }
/// Clears shroud (and fog) around the provided location for @a view_team
/// as if @a viewer was standing there.
bool clear_unit(const map_location &view_loc, team &view_team,
const clearer_info &viewer, bool instant);
/// Clears shroud (and fog) around the provided location as if @a viewer
/// was standing there.
bool clear_unit(const map_location &view_loc, const unit &viewer,
bool can_delay = false, bool invalidate = true,
bool instant = true);
/// Clears shroud (and fog) at the provided location and its immediate neighbors.
bool clear_dest(const map_location &dest, const unit &viewer);
/// Erases the record of sighted events from earlier fog/shroud clearing.
void drop_events();
/// Fires the sighted events that were earlier recorded by fog/shroud clearing.
bool fire_events();
/// The invalidations that should occur after invoking clear_unit().
void invalidate_after_clear();
private:
/// A record of a sighting event.
struct sight_data;
/// Causes this object's "jamming" map to be recalculated.
void calculate_jamming(const team * new_team);
/// Clears shroud from a single location.
bool clear_loc(team &tm, const map_location &loc, const map_location &view_loc,
const map_location &event_non_loc, size_t viewer_id,
bool check_units, size_t &enemy_count, size_t &friend_count,
move_unit_spectator * spectator = nullptr);
/// Convenience wrapper for adding sighting data to the sightings_ vector.
inline void record_sighting(const unit & seen, const map_location & seen_loc,
size_t sighter_id, const map_location & sighter_loc);
private: // data
std::map<map_location, int> jamming_;
std::vector<sight_data> sightings_;
/// Keeps track of the team associated with jamming_.
const team * view_team_;
};
/// Returns the sides that cannot currently see @a target.
std::vector<int> get_sides_not_seeing(const unit & target);
/// Fires sighted events for the sides that can see @a target.
bool actor_sighted(const unit & target, const std::vector<int> * cache = nullptr);
/// Function that recalculates the fog of war.
void recalculate_fog(int side);
/// Function that will clear shroud (and fog) based on current unit positions.
bool clear_shroud(int side, bool reset_fog = false, bool fire_events = true);
}//namespace actions
/*
Copyright (C) 2003 - 2017 by David White <dave@whitevine.net>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
/**
* @file
* Various functions implementing vision (through fog of war and shroud).
*/
#pragma once
#include "movetype.hpp"
struct map_location;
class team;
class unit;
#include <cstring>
#include <map>
#include <set>
#include <vector>
namespace actions {
class move_unit_spectator;
/// Class that stores the part of a unit's data that is needed for fog clearing.
/// (Used by the undo stack as that cannot rely on a unit sticking around, and
/// we do not really need to copy the entire unit.)
struct clearer_info {
size_t underlying_id;
int sight_range;
bool slowed;
movetype::terrain_costs costs;
clearer_info(const unit & viewer);
clearer_info(const config & cfg);
void write(config & cfg) const;
};
/// Class to encapsulate fog/shroud clearing and the resultant sighted events.
/// Note: This class uses teams as parameters (instead of sides) since a
/// function using this should first check to see if fog/shroud is in use (to
/// save processing when it is not), which implies the team is readily available.
class shroud_clearer {
public:
shroud_clearer(const shroud_clearer&) = delete;
shroud_clearer& operator=(const shroud_clearer&) = delete;
shroud_clearer();
~shroud_clearer();
/// Function to be called if units have moved or otherwise changed.
/// It can also be called if it is desirable to calculate the cache
/// in advance of fog clearing.
/// @param[in] new_team The team whose vision will be used. If left as
/// nullptr, the cache will be just be cleared (to be
/// recalculated later as needed).
void cache_units(const team * new_team=nullptr) { calculate_jamming(new_team); }
// cache_units() is currently a near-synonym for calculate_jamming(). The
// reason for the two names is so the private function says what it does,
// while the public one says why it might be invoked.
/// Clears shroud (and fog) around the provided location for @a view_team
/// based on @a sight_range, @a costs, and @a slowed.
bool clear_unit(const map_location &view_loc, team &view_team,
size_t viewer_id, int sight_range, bool slowed,
const movetype::terrain_costs & costs,
const map_location & real_loc,
const std::set<map_location>* known_units = nullptr,
size_t * enemy_count = nullptr, size_t * friend_count = nullptr,
move_unit_spectator * spectator = nullptr, bool instant = true);
/// Clears shroud (and fog) around the provided location for @a view_team
/// as if @a viewer was standing there.
bool clear_unit(const map_location &view_loc,
const unit &viewer, team &view_team,
const std::set<map_location>* known_units = nullptr,
size_t * enemy_count = nullptr, size_t * friend_count = nullptr,
move_unit_spectator * spectator = nullptr, bool instant = true);
/// Clears shroud (and fog) around the provided location for @a view_team
/// as if @a viewer was standing there. Setting @a instant to false
/// allows some drawing delays that are used to make movement look better.
bool clear_unit(const map_location &view_loc, const unit &viewer,
team &view_team, bool instant)
{ return clear_unit(view_loc, viewer, view_team, nullptr, nullptr, nullptr, nullptr, instant); }
/// Clears shroud (and fog) around the provided location for @a view_team
/// as if @a viewer was standing there.
bool clear_unit(const map_location &view_loc, team &view_team,
const clearer_info &viewer, bool instant);
/// Clears shroud (and fog) around the provided location as if @a viewer
/// was standing there.
bool clear_unit(const map_location &view_loc, const unit &viewer,
bool can_delay = false, bool invalidate = true,
bool instant = true);
/// Clears shroud (and fog) at the provided location and its immediate neighbors.
bool clear_dest(const map_location &dest, const unit &viewer);
/// Erases the record of sighted events from earlier fog/shroud clearing.
void drop_events();
/// Fires the sighted events that were earlier recorded by fog/shroud clearing.
bool fire_events();
/// The invalidations that should occur after invoking clear_unit().
void invalidate_after_clear();
private:
/// A record of a sighting event.
struct sight_data;
/// Causes this object's "jamming" map to be recalculated.
void calculate_jamming(const team * new_team);
/// Clears shroud from a single location.
bool clear_loc(team &tm, const map_location &loc, const map_location &view_loc,
const map_location &event_non_loc, size_t viewer_id,
bool check_units, size_t &enemy_count, size_t &friend_count,
move_unit_spectator * spectator = nullptr);
/// Convenience wrapper for adding sighting data to the sightings_ vector.
inline void record_sighting(const unit & seen, const map_location & seen_loc,
size_t sighter_id, const map_location & sighter_loc);
private: // data
std::map<map_location, int> jamming_;
std::vector<sight_data> sightings_;
/// Keeps track of the team associated with jamming_.
const team * view_team_;
};
/// Returns the sides that cannot currently see @a target.
std::vector<int> get_sides_not_seeing(const unit & target);
/// Fires sighted events for the sides that can see @a target.
bool actor_sighted(const unit & target, const std::vector<int> * cache = nullptr);
/// Function that recalculates the fog of war.
void recalculate_fog(int side);
/// Function that will clear shroud (and fog) based on current unit positions.
bool clear_shroud(int side, bool reset_fog = false, bool fire_events = true);
}//namespace actions

View file

@ -212,7 +212,7 @@ namespace {
"*.wesnoth",
"*.project",
};
static const std::vector<std::string> default_ignored_dirs {
".*",
/* macOS metadata-like cruft (http://floatingsun.net/2007/02/07/whats-with-__macosx-in-zip-files/) */

View file

@ -107,7 +107,7 @@ public:
virtual std::string get_id() const;
virtual std::string get_name() const;
virtual std::string get_engine() const;
static config preparse_cfg(ai_context& ctx, const config& cfg);
protected:

View file

@ -147,7 +147,7 @@ readonly_context& engine::get_readonly_context()
{
return ai_;
}
// This is defined in the source file so that it can easily access the logger
bool engine_factory::is_duplicate(const std::string& name)
{

View file

@ -244,7 +244,7 @@ bool configuration::parse_side_config(side_number side, const config& original_c
return true;
}
static const std::set<std::string> non_aspect_attributes {"turns", "time_of_day", "engine", "ai_algorithm", "id", "description"};
static const std::set<std::string> just_copy_tags {"engine", "stage", "aspect", "goal", "modify_ai"};
static const std::set<std::string> old_goal_tags {"target", "target_location", "protect_unit", "protect_location"};

View file

@ -802,7 +802,7 @@ static int impl_ai_aspect_get(lua_State* L)
if(iter == aspects.end()) {
return 0;
}
typedef std::vector<std::string> string_list;
if(typesafe_aspect<bool>* aspect_as_bool = try_aspect_as<bool>(iter->second)) {
lua_pushboolean(L, aspect_as_bool->get());
@ -1036,20 +1036,20 @@ lua_ai_context* lua_ai_context::create(lua_State *L, char const *code, ai::engin
void lua_ai_context::update_state()
{
lua_ai_load ctx(*this, true); // [-1: AI state table]
// Load the AI code and arguments
lua_getfield(L, -1, "update_self"); // [-1: AI code -2: AI state]
lua_getfield(L, -2, "params"); // [-1: Arguments -2: AI code -3: AI state]
lua_getfield(L, -3, "data"); // [-1: Persistent data -2: Arguments -3: AI code -4: AI state]
// Call the function
if (!luaW_pcall(L, 2, 1, true)) { // [-1: Result -2: AI state]
return; // return with stack size 0 []
}
// Store the state for use by components
lua_setfield(L, -2, "self"); // [-1: AI state]
// And return with empty stack.
lua_pop(L, 1);
}
@ -1100,7 +1100,7 @@ lua_ai_load::lua_ai_load(lua_ai_context& ctx, bool read_only) : L(ctx.L), was_re
lua_getfield(L, LUA_REGISTRYINDEX, aisKey); // [-1: AI registry]
lua_rawgeti(L, -1, ctx.num_); // [-1: AI state -2: AI registry]
lua_remove(L,-2); // [-1: AI state]
// Load the AI functions table into global scope
lua_getfield(L, -1, "ai"); // [-1: AI functions -2: AI state]
lua_pushstring(L, "read_only"); // [-1: key -2: AI functions -3: AI state]
@ -1138,7 +1138,7 @@ lua_ai_context::~lua_ai_context()
void lua_ai_action_handler::handle(const config &cfg, bool read_only, lua_object_ptr l_obj)
{
int initial_top = lua_gettop(L);//get the old stack size
// Load the context
lua_ai_load ctx(context_, read_only); // [-1: AI state table]
@ -1146,13 +1146,13 @@ void lua_ai_action_handler::handle(const config &cfg, bool read_only, lua_object
lua_getfield(L, LUA_REGISTRYINDEX, aisKey); // [-1: AI registry -2: AI state]
lua_rawgeti(L, -1, num_); // [-1: AI action -2: AI registry -3: AI state]
lua_remove(L, -2); // [-1: AI action -2: AI state]
// Load the arguments
int iState = lua_absindex(L, -2);
lua_getfield(L, iState, "self");
luaW_pushconfig(L, cfg);
lua_getfield(L, iState, "data");
// Call the function
luaW_pcall(L, 3, l_obj ? 1 : 0, true);
if (l_obj) {

View file

@ -32,10 +32,10 @@ namespace ai {
{
// empty
}
// MSVC fails to compile without this line
template class lua_object<aspect_attacks_lua_filter>;
template <>
std::shared_ptr<aspect_attacks_lua_filter> lua_object<aspect_attacks_lua_filter>::to_type(lua_State *L, int n)
{

View file

@ -45,7 +45,7 @@ template<typename Map, typename Key>
typename Map::mapped_type& map_get(Map& map, Key&& key)
{
auto res = map.lower_bound(key);
if (res == map.end() || key != res->first) {
res = map.emplace_hint(res, std::piecewise_construct, std::forward_as_tuple(key), std::tuple<>());
}
@ -493,7 +493,7 @@ void config::splice_children(config &src, const std::string &key)
child_list &dst = map_get(children_, key);
child_map::iterator i_dst = children_.find(key);
unsigned before = dst.size();
dst.insert(dst.end(), std::make_move_iterator(i_src->second.begin()), std::make_move_iterator(i_src->second.end()));
src.children_.erase(i_src);
@ -580,7 +580,7 @@ config::attribute_value& config::operator[](config_key_type key)
check_valid();
auto res = values_.lower_bound(key);
if (res == values_.end() || key != res->first) {
res = values_.emplace_hint(res, std::piecewise_construct, std::forward_as_tuple(key), std::tuple<>());
}

View file

@ -1,14 +1,14 @@
/*
* Copyright (C) 2008 - 2017 by Mark de Wever <koraq@xs4all.nl>
* Part of the Battle for Wesnoth Project http://www.wesnoth.org/
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY.
*
*
* See the COPYING file for more details.
*/

View file

@ -85,7 +85,7 @@ class key_value_pair : public formula_callable {
void get_inputs(formula_input_vector& inputs) const override;
public:
explicit key_value_pair(const variant& key, const variant& value) : key_(key), value_(value) {}
void serialize_to_string(std::string& str) const override;
};

View file

@ -82,7 +82,7 @@ struct transient_end_level{
bool carryover_report; /**< Should a summary of the scenario outcome be displayed? */
bool linger_mode; /**< Should linger mode be invoked? */
bool reveal_map; /**< Should we reveal map when game is ended? (Multiplayer only) */
void write(config& cfg) const;
};

View file

@ -294,7 +294,7 @@ WML_HANDLER_FUNCTION(do_command,, cfg)
if(!resources::controller->current_team().is_local() && synced_context::get_synced_state() == synced_context::UNSYNCED)
{
ERR_NG << "[do_command] can only be used from clients that control the currently playing side" << std::endl;
return;
return;
}
for(vconfig::all_children_iterator i = cfg.ordered_begin(); i != cfg.ordered_end(); ++i)
{

View file

@ -312,7 +312,7 @@ void wml_menu_item::update(const vconfig & vcfg)
hotkey_updated = true;
}
if ( vcfg.has_attribute("needs_select") ) {
if ( vcfg.has_attribute("needs_select") ) {
ERR_NG << "needs_select= is deprecated\n";
needs_select_ = vcfg["needs_select"].to_bool();
}

View file

@ -995,7 +995,7 @@ config side_engine::new_config() const
{
config res = cfg_;
// In case of 'shuffle sides' the side index in cfg_ might be wrong which will confuse the team constuctor later.
// In case of 'shuffle sides' the side index in cfg_ might be wrong which will confuse the team constuctor later.
res["side"] = index_ + 1;
// If the user is allowed to change type, faction, leader etc, then import their new values in the config.

View file

@ -47,7 +47,7 @@ namespace
*
* This works since this click_callback function is called before widgets' left-button-up handlers.
*
* Additionally, this is done before row deselection so selecting/deselecting a toggle button doesn't also leave
* Additionally, this is done before row deselection so selecting/deselecting a toggle button doesn't also leave
* the list with no row visually selected. Oddly, the visial deselection doesn't seem to cause any crashes, and
* the previously selected row is reselected when the menu is opened again. Still, it's odd to see your selection
* vanish.

View file

@ -132,7 +132,7 @@ void loading_screen::pre_show(window& window)
cursor_setter_.reset(new cursor::setter(cursor::WAIT));
progress_stage_label_ = &find_widget<label>(&window, "status", false);
animation_label_ = &find_widget<label>(&window, "test_animation", false);
window.set_enter_disabled(true);
window.set_escape_disabled(true);
}

View file

@ -38,7 +38,7 @@ class network_transmission : public modal_dialog
{
public:
//A wrapper of either a wesnothd_connection or a network_asio::connection
class connection_data
class connection_data
{
public:
virtual size_t total() { return 0; }

View file

@ -42,7 +42,7 @@ public:
const bool have_campaign_options = std::any_of(campaign_mods.begin(), campaign_mods.end(), [](config& mod) {
return !mod.empty();
});
// Check active mod options.
bool have_mod_options = false;

View file

@ -254,7 +254,7 @@ void title_screen::pre_show(window& win)
//
if(game_config::images::game_title.empty()) {
ERR_CF << "No title image defined" << std::endl;
}
}
win.get_canvas(0).set_variable("title_image", wfl::variant(game_config::images::game_title));

View file

@ -74,7 +74,7 @@ void unit_advance::pre_show(window& window)
string_map column;
std::string image_string, name = sample.type_name();
// This checks if we've finished iterating over the last unit type advancements
// and are into the modification-based advancements.
if(i >= last_real_advancement_) {

View file

@ -40,7 +40,7 @@ void one_item::set_item_shown(const unsigned index, const bool show)
do_deselect_item(index);
for(unsigned i = 1; i < get_item_count(); ++i) {
unsigned new_index = (index + i) % get_item_count();
unsigned new_index = (index + i) % get_item_count();
if(get_item_shown(new_index)) {
do_select_item(new_index);
break;

View file

@ -63,7 +63,7 @@ public:
*
* @param type the id of the [page_definition] that shoduol be used
*
* @param insert_pos the position where th new page is inserted, usually
* @param insert_pos the position where th new page is inserted, usually
* -1 for 'at end'
*
* @returns The grid of the newly added page.
@ -105,7 +105,7 @@ public:
*
* @param type the id of the [page_definition] that shoduol be used
*
* @param insert_pos the position where th new page is inserted, usually
* @param insert_pos the position where th new page is inserted, usually
* -1 for 'at end'
*
* @returns The grid of the newly added page.

View file

@ -137,8 +137,8 @@ repeating_button::signal_handler_left_button_down(const event::ui_event event,
window* window = get_window();
if(window) {
repeat_timer_ = add_timer(settings::repeat_button_repeat_time,
[this, window](unsigned int) {
window->fire(event::LEFT_BUTTON_DOWN, *this);
[this, window](unsigned int) {
window->fire(event::LEFT_BUTTON_DOWN, *this);
},true);
window->mouse_capture();

View file

@ -168,7 +168,7 @@ void stacked_widget::select_layer(const int layer)
{
update_selected_layer_index(layer);
select_layer_impl([this](unsigned int i)
select_layer_impl([this](unsigned int i)
{
return i == static_cast<unsigned int>(selected_layer_);
});

View file

@ -170,7 +170,7 @@ private:
template<tree_view_node* (tree_view_node::*func) ()>
tree_view_node* get_next_node();
template<tree_view_node* (tree_view_node::*func) ()>
bool handle_up_down_arrow();
};

View file

@ -319,7 +319,7 @@ private:
virtual void impl_draw_children(surface& frame_buffer,
int x_offset,
int y_offset) override;
/** See selectable_item::set_callback_state_change. */
std::function<void(widget&)> callback_state_change_;

View file

@ -80,7 +80,7 @@ class halo_record
public:
halo_record(const halo_record&) = delete;
halo_record& operator=(const halo_record&) = delete;
halo_record();
halo_record(int id, const std::shared_ptr<halo_impl> & my_manager);
~halo_record();

View file

@ -471,7 +471,7 @@ bool mouse_handler::right_click_show_menu(int x, int y, const bool /*browse*/)
void mouse_handler::select_or_action(bool browse)
{
if (!pc_.get_map_const().on_board(last_hex_)){
tooltips::click(drag_from_x_, drag_from_y_);
tooltips::click(drag_from_x_, drag_from_y_);
return;
}

View file

@ -221,7 +221,7 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg
ERR_NW << "unknown controller type issued from server on side drop: " << side_drop_c["controller"] << std::endl;
throw ingame_wesnothd_error("");
}
if (ctrl == team::CONTROLLER::AI) {
resources::gameboard->side_drop_to(side_drop, ctrl);
return restart ? PROCESS_RESTART_TURN:PROCESS_CONTINUE;
@ -297,7 +297,7 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg
if (action < control_change_options) {
// Grant control to selected ally
{
// Server thinks this side is ours now so in case of error transferring side we have to make local state to same as what server thinks it is.
resources::gameboard->side_drop_to(side_drop, team::CONTROLLER::HUMAN, team::PROXY_CONTROLLER::PROXY_IDLE);

View file

@ -413,12 +413,12 @@ void replay::redo(const config& cfg, bool set_to_end)
base_->add_child() = cmd;
}
if(set_to_end) {
//The engine does not execute related wml events so mark ad dpendent actions as handled
//The engine does not execute related wml events so mark ad dpendent actions as handled
base_->set_to_end();
}
else {
//The engine does execute related wml events so it needs to reprocess depndent choices
base_->set_pos(old_pos + 1);
//The engine does execute related wml events so it needs to reprocess depndent choices
base_->set_pos(old_pos + 1);
}
}

View file

@ -118,7 +118,7 @@ public:
{
return load_data_;
}
/** GUI Dialog sequence which confirms attempts to load saves from previous game versions. */
static bool check_version_compatibility(const version_info & version, CVideo & video);

View file

@ -638,11 +638,11 @@ bool luaW_tolocation(lua_State *L, int index, map_location& loc) {
// Need this special check because luaW_tovconfig returns true in this case
return false;
}
vconfig dummy_vcfg = vconfig::unconstructed_vconfig();
index = lua_absindex(L, index);
if (lua_istable(L, index) || luaW_tounit(L, index) || luaW_tovconfig(L, index, dummy_vcfg)) {
map_location result;
int x_was_num = 0, y_was_num = 0;

View file

@ -142,7 +142,7 @@ int intf_have_file(lua_State *L)
int intf_read_file(lua_State *L)
{
std::string p = luaL_checkstring(L, 1);
if(!resolve_filename(p, get_calling_file(L))) {
return luaL_argerror(L, -1, "file not found");
}
@ -172,7 +172,7 @@ int intf_read_file(lua_State *L)
luaL_Buffer b;
luaL_buffinit(L, &b);
//throws an exception if malloc failed.
char* out = luaL_prepbuffsize(&b, size);
char* out = luaL_prepbuffsize(&b, size);
fs->read(out, size);
if(fs->good()) {
luaL_addsize(&b, size);
@ -232,7 +232,7 @@ int load_file(lua_State *L)
{
std::string p = luaL_checkstring(L, -1);
std::string rel;
if(!resolve_filename(p, get_calling_file(L), &rel)) {
return luaL_argerror(L, -1, "file not found");
}

View file

@ -87,7 +87,7 @@ static int intf_find_path(lua_State *L)
src.set_wml_y(luaL_checkinteger(L, 2));
dst.set_wml_x(luaL_checkinteger(L, 3));
dst.set_wml_y(luaL_checkinteger(L, 4));
if(lua_isfunction(L, arg)) {
if(lua_isfunction(L, arg)) {
const char *msg = lua_pushfstring(L, "%s expected, got %s", lua_typename(L, LUA_TFUNCTION), luaL_typename(L, 5));
return luaL_argerror(L, 5, msg);
}

View file

@ -282,7 +282,7 @@ namespace {
, const std::string& id)
{
for(const resolution& resolution : resolutions) {
CVideo& video = test_utils::get_fake_display(resolution.first, resolution.second).video();
std::vector<std::string>& list =
@ -802,13 +802,13 @@ struct wesnothd_connection_init
wesnothd_connection_init(wesnothd_connection& conn)
{
//Swallow the 'cannot connect' execption so that the connection object doesn't throw while we test the dialog.
try
try
{
while (true) {
conn.poll();
}
}
catch (...)
catch (...)
{
}

View file

@ -1,14 +1,14 @@
/*
Copyright (C) 2008 - 2017
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
@ -31,7 +31,7 @@ class mock_char : public formula_callable {
} else if(key == "agility") {
return variant(12);
}
return variant(10);
}
};
@ -46,7 +46,7 @@ class mock_party : public formula_callable {
for(int n = 0; n != 3; ++n) {
members.emplace_back(i_[n].fake_ptr());
}
return variant(members);
} else if(key == "char") {
return variant(c_.fake_ptr());
@ -54,10 +54,10 @@ class mock_party : public formula_callable {
return variant(0);
}
}
mock_char c_;
mutable map_formula_callable i_[3];
public:
mock_party() {}
};
@ -71,16 +71,16 @@ BOOST_AUTO_TEST_CASE(test_formula_basic_arithmetic)
{
BOOST_CHECK_EQUAL(formula("strength").evaluate(c).as_int(), 15);
BOOST_CHECK_EQUAL(formula("17").evaluate().as_int(), 17);
BOOST_CHECK_EQUAL(formula("strength/2 + agility").evaluate(c).as_int(), 19);
BOOST_CHECK_EQUAL(formula("(strength+agility)/2").evaluate(c).as_int(), 13);
BOOST_CHECK_EQUAL(formula("20 % 3").evaluate().as_int(), 2);
BOOST_CHECK_EQUAL(formula("19.5 % 3").evaluate().as_decimal(),
static_cast<int>(1000.0 * 1.5));
BOOST_CHECK_EQUAL(formula("-5").evaluate().as_int(), -5);
BOOST_CHECK_EQUAL(formula("4^2").evaluate().as_int(), 16);
BOOST_CHECK_EQUAL(formula("2+3^3").evaluate().as_int(), 29);
BOOST_CHECK_EQUAL(formula("2*3^3+2").evaluate().as_int(), 56);
@ -93,14 +93,14 @@ BOOST_AUTO_TEST_CASE(test_formula_basic_logic)
{
BOOST_CHECK_EQUAL(formula("strength > 12").evaluate(c).as_int(), 1);
BOOST_CHECK_EQUAL(formula("strength > 18").evaluate(c).as_int(), 0);
BOOST_CHECK_EQUAL(formula("if(strength > 12, 7, 2)").evaluate(c).as_int(), 7);
BOOST_CHECK_EQUAL(formula("if(strength > 18, 7, 2)").evaluate(c).as_int(), 2);
BOOST_CHECK_EQUAL(formula("2 and 1").evaluate().as_int(), 1);
BOOST_CHECK_EQUAL(formula("2 and 0").evaluate().as_int(), 0);
BOOST_CHECK_EQUAL(formula("2 or 0").evaluate().as_int(), 2);
BOOST_CHECK_EQUAL(formula("not 5").evaluate().as_int(), 0);
BOOST_CHECK_EQUAL(formula("not 0").evaluate().as_int(), 1);
}
@ -111,7 +111,7 @@ BOOST_AUTO_TEST_CASE(test_formula_callable)
// I wasn't sure how to classify them.
BOOST_CHECK_EQUAL(formula("char.strength").evaluate(p).as_int(), 15);
BOOST_CHECK_EQUAL(formula("choose(members,strength).strength").evaluate(p).as_int(), 16);
BOOST_CHECK_EQUAL(formula("char.sum([strength, agility, intelligence])").evaluate(p).as_int(), 37);
}
@ -119,7 +119,7 @@ BOOST_AUTO_TEST_CASE(test_formula_where_clause)
{
BOOST_CHECK_EQUAL(formula("x*5 where x=1").evaluate().as_int(), 5);
BOOST_CHECK_EQUAL(formula("x*5 where x=2").evaluate().as_int(), 10);
BOOST_CHECK_EQUAL(formula("x*(a*b where a=2,b=1) where x=5").evaluate().as_int(), 10);
BOOST_CHECK_EQUAL(formula("char.strength * ability where ability=3").evaluate(p).as_int(), 45);
}
@ -128,12 +128,12 @@ BOOST_AUTO_TEST_CASE(test_formula_strings)
{
BOOST_CHECK_EQUAL(formula("'abcd' = 'abcd'").evaluate().as_bool(), true);
BOOST_CHECK_EQUAL(formula("'abcd' = 'acd'").evaluate().as_bool(), false);
BOOST_CHECK_EQUAL(formula("'ab' .. 'cd'").evaluate().as_string(), "abcd");
BOOST_CHECK_EQUAL(formula("'strength, agility: [strength], [agility]'").evaluate(c).as_string(),
"strength, agility: 15, 12");
BOOST_CHECK_EQUAL(formula("'String with [']quotes['] and [(]brackets[)]!'").evaluate().as_string(),
"String with 'quotes' and [brackets]!");
BOOST_CHECK_EQUAL(formula("'String with ['embedded ' .. 'string']!'").evaluate().as_string(),
@ -151,12 +151,12 @@ BOOST_AUTO_TEST_CASE(test_formula_containers) {
BOOST_CHECK_EQUAL(myarray[0].as_int(), 1);
BOOST_CHECK_EQUAL(myarray[1].as_int(), 2);
BOOST_CHECK_EQUAL(myarray[2].as_int(), 3);
variant mydict = formula("['foo' -> 5, 'bar' ->7]").evaluate();
BOOST_CHECK_EQUAL(mydict.num_elements(), 2);
BOOST_CHECK_EQUAL(mydict[variant("foo")].as_int(), 5);
BOOST_CHECK_EQUAL(mydict[variant("bar")].as_int(), 7);
variant myrange = formula("-2~2").evaluate();
BOOST_CHECK_EQUAL(myrange.num_elements(), 5);
BOOST_CHECK_EQUAL(myrange[0].as_int(), -2);
@ -164,7 +164,7 @@ BOOST_AUTO_TEST_CASE(test_formula_containers) {
BOOST_CHECK_EQUAL(myrange[2].as_int(), 0);
BOOST_CHECK_EQUAL(myrange[3].as_int(), 1);
BOOST_CHECK_EQUAL(myrange[4].as_int(), 2);
variant myslice = formula("(10~20)[[1,3,7,9]]").evaluate();
BOOST_CHECK_EQUAL(myslice.num_elements(), 4);
BOOST_CHECK_EQUAL(myslice[0].as_int(), 11);

View file

@ -149,16 +149,16 @@ BOOST_AUTO_TEST_CASE(test_formula_function_math)
BOOST_CHECK_EQUAL(formula("abs(-5)").evaluate().as_int(), 5);
BOOST_CHECK_EQUAL(formula("abs(5.0)").evaluate().as_int(), 5);
BOOST_CHECK_EQUAL(formula("abs(-5.0)").evaluate().as_int(), 5);
BOOST_CHECK_EQUAL(formula("min(3,5)").evaluate().as_int(), 3);
BOOST_CHECK_EQUAL(formula("min(5,2)").evaluate().as_int(), 2);
BOOST_CHECK_EQUAL(formula("max(3,5)").evaluate().as_int(), 5);
BOOST_CHECK_EQUAL(formula("max(5,2)").evaluate().as_int(), 5);
BOOST_CHECK_EQUAL(formula("max(5.5,5)").evaluate().as_decimal(),
static_cast<int>(1000.0 * 5.5));
BOOST_CHECK_EQUAL(formula("max(4,5,[2,18,7])").evaluate().as_int(), 18);
BOOST_CHECK_EQUAL(formula("log(8,2)").evaluate().as_int(), 3);
BOOST_CHECK_EQUAL(formula("log(12)").evaluate().as_decimal(),
static_cast<int>(round(1000.0 * log(12))));

View file

@ -40,7 +40,7 @@ public:
* @param source the definition of the context-free grammar to use
*/
context_free_grammar_generator(const std::string& source);
/** Initialisation
* @param source A map of nonterminals to lists of possibilities
*/

View file

@ -1,13 +1,13 @@
/*
Copyright (C) by the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
@ -43,47 +43,47 @@ namespace detail {
private:
std::function<Ret(T...)> fcn;
};
template<typename Ret, typename... T>
apply<Ret, T...> make_apply(std::function<Ret(T...)> fcn) {
return apply<Ret, T...>(fcn);
}
template<typename F>
struct function_base {
using type = typename function_base<decltype(&F::operator())>::type;
};
template<typename Ret, typename... P>
struct function_base<Ret(P...)> {
typedef Ret type(P...);
};
template<typename Ret, typename... P>
struct function_base<Ret(*)(P...)> {
typedef Ret type(P...);
};
template<typename Ret, typename Class, typename... P>
struct function_base<Ret(Class::*)(P...)> {
typedef Ret type(Class,P...);
};
template<typename Ret, typename Class, typename... P>
struct function_base<Ret(Class::*)(P...)const> {
typedef Ret type(const Class,P...);
};
template<typename Ret, typename Class, typename... P>
struct function_base<Ret(Class::*)(P...)volatile > {
typedef Ret type(volatile Class,P...);
};
template<typename Ret, typename Class, typename... P>
struct function_base<Ret(Class::*)(P...)const volatile> {
typedef Ret type(const volatile Class,P...);
};
template<typename Ret, typename... P>
struct function_base<std::function<Ret(P...)>> {
typedef Ret type(P...);

View file

@ -1,14 +1,14 @@
/*
Copyright (C) 2014 - 2017 by David White <dave@whitevine.net>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/

View file

@ -23,7 +23,7 @@ struct wesnothd_error : public game::error
wesnothd_error(const std::string& error) : game::error(error) {}
};
///We received invalid data from wesnothd during a game
///We received invalid data from wesnothd during a game
///This means we cannot continue with the game but we can stay connected to wesnothd and start a new game
///TODO: find a short name
struct ingame_wesnothd_error : public wesnothd_error ,public lua_jailbreak_exception