Skip to content

Commit

Permalink
Strip trailing whitespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
mordante committed Jun 9, 2014
1 parent 7efb1ba commit e35f4bb
Show file tree
Hide file tree
Showing 93 changed files with 436 additions and 436 deletions.
42 changes: 21 additions & 21 deletions src/actions/attack.cpp
Expand Up @@ -898,27 +898,27 @@ namespace {
resources::gamedata->get_variable("damage_inflicted") = damage;
}


// Make sure that if we're serializing a game here,
// we got the same results as the game did originally.
const config local_results = config_of("chance", attacker.cth_)("hits", hits)("damage", damage);
config replay_results;
bool equals_replay = checkup_instance->local_checkup(local_results, replay_results);
if (!equals_replay)
{

int results_chance = replay_results["chance"];
bool results_hits = replay_results["hits"].to_bool();
int results_damage = replay_results["damage"];
/*
errbuf_ << "SYNC: In attack " << a_.dump() << " vs " << d_.dump()
errbuf_ << "SYNC: In attack " << a_.dump() << " vs " << d_.dump()
<< " replay data differs from local calculated data:"
<< " chance to hit in data source: " << results_chance
<< " chance to hit in data source: " << results_chance
<< " chance to hit in calculated: " << attacker.cth_
<< " chance to hit in data source: " << results_chance
<< " chance to hit in data source: " << results_chance
<< " chance to hit in calculated: " << attacker.cth_
;
attacker.cth_ = results_chance;
hits = results_hits;
damage = results_damage;
Expand Down Expand Up @@ -1011,7 +1011,7 @@ namespace {
: statistics::attack_context::MISSES, damage_done, drains_damage);
}


replay_results.clear();
// there was also a attribute cfg["unit_hit"] which was never used so i deleted.
equals_replay = checkup_instance->local_checkup(config_of("dies", dies), replay_results);
Expand Down Expand Up @@ -1370,34 +1370,34 @@ namespace
public:
unit_advancement_choice(const map_location& loc, int total_opt, int side_num, const ai::unit_advancements_aspect& ai_advancement, bool force_dialog)
: loc_ (loc), nb_options_(total_opt), side_num_(side_num), ai_advancement_(ai_advancement), force_dialog_(force_dialog)
{
{
}
virtual ~unit_advancement_choice()

virtual ~unit_advancement_choice()
{
}

virtual config query_user(int /*side*/) const
{
//the 'side' parameter might differ from side_num_-
//the 'side' parameter might differ from side_num_-
int res = 0;
team t = (*resources::teams)[side_num_ - 1];
//i wonder how this got included here ?
//i wonder how this got included here ?
bool is_mp = network::nconnections() != 0;
bool is_current_side = resources::controller->current_side() == side_num_;
//note, that the advancements for networked sides are also determined on the current playing side.

//to make mp games equal we only allow selecting advancements to the current side.
//otherwise we'd give an unfair advantage to the side that hosts ai sides if units advance during ai turns.
if(!non_interactive() && (force_dialog_ || (t.is_human() && (is_current_side || !is_mp))))
{
res = dialogs::advance_unit_dialog(loc_);
res = dialogs::advance_unit_dialog(loc_);
}
else if(t.is_ai() || t.is_network_ai() || t.is_empty() || t.is_idle())
{
res = rand() % nb_options_;

//if ai_advancement_ is the default advancement the following code will
//if ai_advancement_ is the default advancement the following code will
//have no effect because get_advancements returns an empty list.
unit_map::iterator u = resources::units->find(loc_);
const std::vector<std::string>& options = u->advances_to();
Expand All @@ -1424,7 +1424,7 @@ namespace
return retv;

}
virtual config random_choice(int /*side*/) const
virtual config random_choice(int /*side*/) const
{
config retv;
retv["value"] = 0;
Expand Down Expand Up @@ -1453,18 +1453,18 @@ void advance_unit_at(const map_location& loc, const ai::unit_advancements_aspect
if(!unit_helper::will_certainly_advance(u)) {
return;
}

//we don't want to let side 1 decide it during start/prestart.
int side_for = resources::gamedata->phase() == game_data::PLAY ? 0: u->side();
config selected = mp_sync::get_user_choice("choose",
unit_advancement_choice(loc, unit_helper::number_of_possible_advances(*u),u->side(), ai_advancement, force_dialog), side_for);
unit_advancement_choice(loc, unit_helper::number_of_possible_advances(*u),u->side(), ai_advancement, force_dialog), side_for);
//calls actions::advance_unit.
bool result = dialogs::animate_unit_advancement(loc, selected["value"], true, true);

DBG_NG << "animate_unit_advancement result = " << result << std::endl;
u = resources::units->find(loc);
// level 10 unit gives 80 XP and the highest mainline is level 5
if (u.valid() && u->experience() > 80)
if (u.valid() && u->experience() > 80)
{
ERR_NG << "Unit has too many (" << u->experience() << ") XP left; cascade leveling goes on still." << std::endl;
}
Expand All @@ -1474,7 +1474,7 @@ void advance_unit_at(const map_location& loc, const ai::unit_advancements_aspect


void attack_unit_and_advance(const map_location &attacker, const map_location &defender,
int attack_with, int defend_with, bool update_display,
int attack_with, int defend_with, bool update_display,
const ai::unit_advancements_aspect& ai_advancement)
{ try
{
Expand All @@ -1484,7 +1484,7 @@ void attack_unit_and_advance(const map_location &attacker, const map_location &d
{

unit_map::const_iterator atku = resources::units->find(attacker);

if (atku != resources::units->end()) {
advance_unit_at(attacker, ai_advancement);
}
Expand Down
4 changes: 2 additions & 2 deletions src/actions/attack.hpp
Expand Up @@ -198,10 +198,10 @@ void attack_unit(const map_location &attacker, const map_location &defender,

/** Performs an attack, and advanced the units afterwards */
void attack_unit_and_advance(const map_location &attacker, const map_location &defender,
int attack_with, int defend_with, bool update_display = true,
int attack_with, int defend_with, bool update_display = true,
const ai::unit_advancements_aspect& ai_advancement = ai::unit_advancements_aspect());

/**
/**
advances the unit at loc if it has enough experience, maximum 20 times.
if the unit is on the currently active side, and that side is controlled by a human, a dialog pops up.
if we are in a non mp game, and the side is controlled by a human then a dialog is shown too.
Expand Down
4 changes: 2 additions & 2 deletions src/actions/create.cpp
Expand Up @@ -980,7 +980,7 @@ void recruit_unit(const unit_type & u_type, int side_num, const map_location & l
if ( use_undo ) {
resources::undo_stack->add_recruit(new_unit, loc, from);
// Check for information uncovered or randomness used.

if ( mutated || !synced_context::can_undo()) {
resources::undo_stack->clear();
}
Expand All @@ -1006,7 +1006,7 @@ bool recall_unit(const std::string & id, team & current_team,
std::vector<unit>::iterator recall_it = find_if_matches_id(recall_list, id);
if ( recall_it == recall_list.end() )
return false;


// Make a copy of the unit before erasing it from the list.
unit recall(*recall_it);
Expand Down
12 changes: 6 additions & 6 deletions src/actions/move.cpp
Expand Up @@ -927,7 +927,7 @@ namespace { // Private helpers for move_unit()
static const std::string enter_hex_str("enter_hex");
static const std::string exit_hex_str("exit_hex");


bool obstructed_stop = false;


Expand Down Expand Up @@ -1183,18 +1183,18 @@ static size_t move_unit_internal(undo_list* undo_stack,

// Attempt moving.
mover.try_actual_movement(show_move);

config co;
config cn = config_of("stopped_early", mover.stopped_early())("final_hex_x", mover.final_hex().x + 1)("final_hex_y", mover.final_hex().y + 1);
bool matches_replay = checkup_instance->local_checkup(cn,co);
if(!matches_replay)
{
replay::process_error("calculated movement destination (x="+ cn["final_hex_x"].str() + " y=" + cn["final_hex_y"].str() +
replay::process_error("calculated movement destination (x="+ cn["final_hex_x"].str() + " y=" + cn["final_hex_y"].str() +
")didn't match the original destination(x="+ co["final_hex_x"].str() + " y=" + co["final_hex_y"].str());

//TODO: move the unit by force to the desired destination with something like mover.reset_final_hex(co["x"], co["y"]);
}

// Bookkeeping, etc.
// also fires the moveto event
mover.post_move(undo_stack);
Expand Down Expand Up @@ -1235,7 +1235,7 @@ size_t move_unit_and_record(const std::vector<map_location> &steps,
bool* interrupted,
move_unit_spectator* move_spectator)
{

// Avoid some silliness.
if ( steps.size() < 2 || (steps.size() == 2 && steps.front() == steps.back()) ) {
DBG_NG << "Ignoring a unit trying to jump on its hex at " <<
Expand Down Expand Up @@ -1279,7 +1279,7 @@ size_t move_unit_from_replay(const std::vector<map_location> &steps,
{
// Evaluate this move.
unit_mover mover(steps, NULL, continued_move,skip_ally_sighted, NULL);
if ( !mover.check_expected_movement() )
if ( !mover.check_expected_movement() )
{
replay::process_error("found corrupt movement in replay.");
return 0;
Expand Down
4 changes: 2 additions & 2 deletions src/actions/move.hpp
Expand Up @@ -102,7 +102,7 @@ bool get_village(const map_location& loc, int side, int *time_bonus = NULL);
/// And enters the synced context.
size_t move_unit_and_record(const std::vector<map_location> &steps,
undo_list* undo_stack,
bool continued_move = false,
bool continued_move = false,
bool show_move = true,
bool* interrupted = NULL,
move_unit_spectator* move_spectator = NULL);
Expand All @@ -111,7 +111,7 @@ size_t move_unit_and_record(const std::vector<map_location> &steps,
/// to be called from replay when we are already in the synced context.
size_t move_unit_from_replay(const std::vector<map_location> &steps,
undo_list* undo_stack,
bool continued_move, bool skip_ally_sighted,
bool continued_move, bool skip_ally_sighted,
bool show_move = true);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/actions/undo.cpp
Expand Up @@ -777,7 +777,7 @@ bool undo_list::update_shroud_action::undo(int /*side*/, undo_list & undos)
undos.undo();
// Now keep the shroud update at the top of the undo stack.
recorder.add_synced_command("update_shroud", replay_helper::get_update_shroud());

undos.add_update_shroud();
// Shroud actions never get moved to the redo stack, so claim an error.
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/actions/undo.hpp
Expand Up @@ -91,7 +91,7 @@ class undo_list : boost::noncopyable {

// Data:
/// the replay data to do this action, this is only !empty() when this action is on the redo stack
/// we need this because we dont recalculate the redos like they would be in real game,
/// we need this because we dont recalculate the redos like they would be in real game,
/// but even undoable comands can have "dependent" (= user_input) commands, which we save here.
config replay_data;

Expand Down
12 changes: 6 additions & 6 deletions src/ai/actions.cpp
Expand Up @@ -290,7 +290,7 @@ void attack_result::do_execute()
{
attack_unit_and_advance(attacker_loc_, defender_loc_, attacker_weapon, defender_weapon, true, advancements_);
}


set_gamestate_changed();
//start of ugly hack. @todo 1.9 rework that via extended event system
Expand Down Expand Up @@ -611,9 +611,9 @@ void recall_result::do_execute()
// Do the actual recalling.
//we ignore possible erros (=unit doesnt exist on the recall list)
//becasue that was the previous behaviour.
synced_context::run_in_synced_context_if_not_already("recall",
synced_context::run_in_synced_context_if_not_already("recall",
replay_helper::get_recall(unit_id_, recall_location_, recall_from_),
false,
false,
preferences::show_ai_moves(),
synced_context::ignore_error_function);

Expand Down Expand Up @@ -752,7 +752,7 @@ void recruit_result::do_execute()
// This should be implied by is_success() once check_before() has been
// called, so this is a guard against future breakage.
assert(location_checked_ && u != NULL);

synced_context::run_in_synced_context_if_not_already("recruit", replay_helper::get_recruit(u->id(), recruit_location_, recruit_from_), false, preferences::show_ai_moves());
//TODO: should we do something to pass use_undo = false in replays and ai moves ?
//::actions::recruit_unit(*u, get_side(), recruit_location_, recruit_from_,
Expand Down Expand Up @@ -903,9 +903,9 @@ void synced_command_result::do_execute()
s << "local x1 = " << location_.x << " local y1 = " << location_.y << " ";
}
s << lua_code_;

synced_context::run_in_synced_context_if_not_already("lua_ai", replay_helper::get_lua_ai(s.str()));

try {
set_gamestate_changed();
manager::raise_gamestate_changed();
Expand Down
2 changes: 1 addition & 1 deletion src/ai/testing/ca.cpp
Expand Up @@ -1959,7 +1959,7 @@ simple_move_and_targeting_phase::~simple_move_and_targeting_phase()

double simple_move_and_targeting_phase::evaluate()
{
// Pick first enemy leader, move all units as close to
// Pick first enemy leader, move all units as close to
// enemy leader as possible.
// Own leader should not be moved.
// Code does not support multiple leaders per side.
Expand Down
2 changes: 1 addition & 1 deletion src/carryover.cpp
Expand Up @@ -242,7 +242,7 @@ void carryover_info::transfer_to(config& level){

}

const config carryover_info::to_config()
const config carryover_info::to_config()
{
config cfg;

Expand Down
2 changes: 1 addition & 1 deletion src/config_assign.hpp
Expand Up @@ -29,7 +29,7 @@ class config_of
{
this->operator()(tagname, child);
}

template <typename AT>
config_of& operator()(const std::string& attrname, AT value)
{
Expand Down
6 changes: 3 additions & 3 deletions src/controller_base.cpp
Expand Up @@ -181,18 +181,18 @@ bool controller_base::handle_scroll(CKey& key, int mousex, int mousey, int mouse
}
if ((mouse_flags & SDL_BUTTON_MMASK) != 0 && preferences::middle_click_scrolls()) {
const map_location original_loc = get_mouse_handler_base().get_scroll_start();

if (get_mouse_handler_base().scroll_started()) {
const SDL_Rect& rect = get_display().map_outside_area();
if (sdl::point_in_rect(mousex, mousey,rect) &&
if (sdl::point_in_rect(mousex, mousey,rect) &&
get_mouse_handler_base().scroll_started()) {
// Scroll speed is proportional from the distance from the first
// middle click and scrolling speed preference.
const double speed = 0.04 * sqrt(static_cast<double>(scroll_speed));
const double snap_dist = 16; // Snap to horizontal/vertical scrolling
const double x_diff = (mousex - original_loc.x);
const double y_diff = (mousey - original_loc.y);

if (fabs(x_diff) > snap_dist || fabs(y_diff) <= snap_dist) dx += speed * x_diff;
if (fabs(y_diff) > snap_dist || fabs(x_diff) <= snap_dist) dy += speed * y_diff;
}
Expand Down
4 changes: 2 additions & 2 deletions src/dialogs.cpp
Expand Up @@ -532,7 +532,7 @@ int recall_dialog(display& disp, std::vector< const unit* >& units, int side, co
options.push_back(option.str());
options_to_filter.push_back(option_to_filter.str());
}

gui::dialog rmenu(disp, _("Recall") + title_suffix,
_("Select unit:") + std::string("\n"),
gui::OK_CANCEL, gui::dialog::default_style);
Expand Down Expand Up @@ -843,7 +843,7 @@ void save_preview_pane::draw_contents()
case game_classification::TEST:
str << _("Test scenario");
break;
}
}
} catch (bad_lexical_cast &) {
str << campaign_type;
}
Expand Down
4 changes: 2 additions & 2 deletions src/editor/editor_controller.cpp
Expand Up @@ -159,7 +159,7 @@ editor_controller::~editor_controller()
resources::units = NULL;
resources::tod_manager = NULL;
resources::teams = NULL;

resources::classification = NULL;
resources::mp_settings = NULL;
}
Expand Down Expand Up @@ -960,7 +960,7 @@ void editor_controller::show_menu(const std::vector<std::string>& items_arg, int

const hotkey::hotkey_command& command = hotkey::get_hotkey_command(*i);

if ( ( can_execute_command(command)
if ( ( can_execute_command(command)
&& (!context_menu || in_context_menu(command.id)) )
|| command.id == hotkey::HOTKEY_NULL) {
items.push_back(*i);
Expand Down
4 changes: 2 additions & 2 deletions src/editor/map/context_manager.cpp
Expand Up @@ -86,7 +86,7 @@ class map_context_refresher
context_manager_.gui().replace_overlay_map(&context_manager_.get_map_context().get_overlays());

resources::teams = &context_manager_.get_map_context().get_teams();

resources::classification = &context_manager_.get_map_context().get_game_state().classification();
resources::mp_settings = &context_manager_.get_map_context().get_game_state().mp_settings();

Expand Down Expand Up @@ -567,7 +567,7 @@ void context_manager::save_map_as_dialog()
input_name = get_dir(default_dir_ + "/maps");
}
const std::string old_input_name = input_name;

int overwrite_res = 1;
do {
input_name = old_input_name;
Expand Down

0 comments on commit e35f4bb

Please sign in to comment.