Make the new parameter to unit::set_movement() optional,

...with the default to not have side-effects (not the behavior before
the parameter).
This commit is contained in:
J. Tyne 2012-09-19 13:43:05 +00:00
parent 651c127dab
commit cad139f572
5 changed files with 7 additions and 7 deletions

View File

@ -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<int>(
u->total_movement(),
u->movement_left() + lexical_cast_default<int, config::attribute_value> (moves, 0)
), false);
));
}
}

View File

@ -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) {

View File

@ -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<int>(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));

View File

@ -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<int>(0, left); }
void new_turn();
void end_turn();

View File

@ -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;
}