Skip to content

Commit

Permalink
Fixed stamina waiting error handling: remember initial stamina and do…
Browse files Browse the repository at this point in the history
…n't report debug message if not required.
  • Loading branch information
ipcyborg committed Sep 28, 2019
1 parent b59c207 commit 6264f34
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/activity_handlers.cpp
Expand Up @@ -2946,7 +2946,11 @@ void activity_handlers::wait_stamina_do_turn( player_activity *act, player *p )
{
int stamina_threshold = p->get_stamina_max();
if( !act->values.empty() ) {
stamina_threshold = act->values.front();
stamina_threshold = act->values[0];
// remember initial stamina, only for waiting-with-threshold
if( act->values.size() == 1 ) {
act->values.push_back( p->stamina );
}
}
if( p->stamina >= stamina_threshold ) {
wait_stamina_finish( act, p );
Expand All @@ -2956,7 +2960,9 @@ void activity_handlers::wait_stamina_do_turn( player_activity *act, player *p )
void activity_handlers::wait_stamina_finish( player_activity *act, player *p )
{
if( !act->values.empty() ) {
if( p->stamina < act->values.front() ) {
const int stamina_threshold = act->values[0];
const int stamina_initial = ( act->values.size() > 1 ) ? act->values[1] : p->stamina;
if( p->stamina < stamina_threshold && p->stamina <= stamina_initial ) {
debugmsg( "Failed to wait until stamina threshold %d reached, only at %d. You may not be regaining stamina.",
act->values.front(), p->stamina );
}
Expand Down

0 comments on commit 6264f34

Please sign in to comment.