Merge reset_resting() into calculate_healing().
This removes the burden of doing things in the right order from play_controller.
This commit is contained in:
parent
c68c31c89f
commit
7647293521
3 changed files with 7 additions and 20 deletions
|
@ -39,14 +39,6 @@ static lg::log_domain log_engine("engine");
|
|||
#define DBG_NG LOG_STREAM(debug, log_engine)
|
||||
|
||||
|
||||
void reset_resting(unit_map& units, int side)
|
||||
{
|
||||
BOOST_FOREACH(unit &u, units) {
|
||||
if (u.side() == side)
|
||||
u.set_resting(true);
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// Contains the data needed to display healing.
|
||||
|
@ -258,8 +250,11 @@ void calculate_healing(int side, bool update_display)
|
|||
// We look for all allied units, then we see if our healer is near them.
|
||||
BOOST_FOREACH(unit &patient, *resources::units) {
|
||||
|
||||
if ( patient.get_state("unhealable") || patient.incapacitated() )
|
||||
if ( patient.get_state("unhealable") || patient.incapacitated() ) {
|
||||
if ( patient.side() == side )
|
||||
patient.set_resting(true);
|
||||
continue;
|
||||
}
|
||||
|
||||
DBG_NG << "found healable unit at (" << patient.get_location() << ")\n";
|
||||
|
||||
|
@ -269,9 +264,11 @@ void calculate_healing(int side, bool update_display)
|
|||
|
||||
|
||||
// Rest healing.
|
||||
if ( patient.side() == side )
|
||||
if ( patient.side() == side ) {
|
||||
if ( patient.resting() || patient.is_healthy() )
|
||||
healing += game_config::rest_heal_amount;
|
||||
patient.set_resting(true);
|
||||
}
|
||||
|
||||
// Main healing.
|
||||
if ( !patient.get_state(unit::STATE_POISONED) ) {
|
||||
|
|
|
@ -21,15 +21,6 @@
|
|||
#ifndef ACTIONS_HEAL_H_INCLUDED
|
||||
#define ACTIONS_HEAL_H_INCLUDED
|
||||
|
||||
class unit_map;
|
||||
|
||||
|
||||
/**
|
||||
* Resets resting for all units on this side: should be called after calculate_healing().
|
||||
* @todo FIXME: Try moving this to unit::new_turn, then move it above calculate_healing().
|
||||
*/
|
||||
void reset_resting(unit_map& units, int side);
|
||||
|
||||
/**
|
||||
* Calculates healing for all units for the given side.
|
||||
* Should be called at the beginning of a side's turn.
|
||||
|
|
|
@ -643,7 +643,6 @@ void play_controller::do_init_side(const unsigned int team_index, bool is_replay
|
|||
}
|
||||
|
||||
calculate_healing(player_number_, !skip_replay_);
|
||||
reset_resting(units_, player_number_);
|
||||
}
|
||||
|
||||
if (!loading_game_) {
|
||||
|
|
Loading…
Add table
Reference in a new issue