From cad139f572d29c95f4aa274029169371430b7f45 Mon Sep 17 00:00:00 2001 From: "J. Tyne" Date: Wed, 19 Sep 2012 13:43:05 +0000 Subject: [PATCH] Make the new parameter to unit::set_movement() optional, ...with the default to not have side-effects (not the behavior before the parameter). --- src/game_events.cpp | 4 ++-- src/mouse_events.cpp | 4 ++-- src/scripting/lua.cpp | 2 +- src/unit.hpp | 2 +- src/whiteboard/mapbuilder.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/game_events.cpp b/src/game_events.cpp index 8407372423f..703d84d72f8 100644 --- a/src/game_events.cpp +++ b/src/game_events.cpp @@ -2616,13 +2616,13 @@ WML_HANDLER_FUNCTION(heal_unit, event_info, cfg) } if(!moves.blank()) { - if(moves == "full") u->set_movement(u->total_movement(), false); + if(moves == "full") u->set_movement(u->total_movement()); else { // set_movement doesn't set below 0 u->set_movement(std::min( u->total_movement(), u->movement_left() + lexical_cast_default (moves, 0) - ), false); + )); } } diff --git a/src/mouse_events.cpp b/src/mouse_events.cpp index 7a1090f380c..f434c9a6f46 100644 --- a/src/mouse_events.cpp +++ b/src/mouse_events.cpp @@ -514,7 +514,7 @@ bool mouse_handler::left_click(int x, int y, const bool browse) // update movement_left as if we did the move int move_left_dst = itor->move_left; int move_left_src = u->movement_left(); - u->set_movement(move_left_dst, false); + u->set_movement(move_left_dst); // block where we temporary move the unit { @@ -525,7 +525,7 @@ bool mouse_handler::left_click(int x, int y, const bool browse) } // restore unit as before u = units_.find(src); - u->set_movement(move_left_src, false); + u->set_movement(move_left_src); u->set_standing(); if (choice < 0) { diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index bd1bb6a3e38..49c6f324600 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -1055,7 +1055,7 @@ static int impl_unit_set(lua_State *L) // Find the corresponding attribute. modify_int_attrib_check_range("side", u.set_side(value), 1, static_cast(resources::teams->size())); - modify_int_attrib("moves", u.set_movement(value, false)); + modify_int_attrib("moves", u.set_movement(value)); modify_int_attrib("hitpoints", u.set_hitpoints(value)); modify_int_attrib("experience", u.set_experience(value)); modify_int_attrib("attacks_left", u.set_attacks(value)); diff --git a/src/unit.hpp b/src/unit.hpp index 3bfbe1bf112..ec473fa1ba3 100644 --- a/src/unit.hpp +++ b/src/unit.hpp @@ -176,7 +176,7 @@ public: bool user_end_turn() const { return end_turn_; } int attacks_left() const { return (attacks_left_ == 0 || incapacitated()) ? 0 : attacks_left_; } int max_attacks() const { return max_attacks_; } - void set_movement(int moves, bool unit_action); + void set_movement(int moves, bool unit_action=false); void set_attacks(int left) { attacks_left_ = std::max(0, left); } void new_turn(); void end_turn(); diff --git a/src/whiteboard/mapbuilder.cpp b/src/whiteboard/mapbuilder.cpp index 94b9c183496..46a645cb82f 100644 --- a/src/whiteboard/mapbuilder.cpp +++ b/src/whiteboard/mapbuilder.cpp @@ -122,7 +122,7 @@ void mapbuilder::process(side_actions &sa, side_actions::iterator action_it) if(acted_this_turn_.find(unit) == acted_this_turn_.end()) { //reset MP - unit->set_movement(unit->total_movement(), false); + unit->set_movement(unit->total_movement()); acted=true; }