mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-01 18:19:10 +00:00
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:
parent
651c127dab
commit
cad139f572
@ -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);
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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));
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user