Skip to content

Commit

Permalink
Expand weary-related debugging info.
Browse files Browse the repository at this point in the history
Intermittent errors in weary tests (see CleverRaven#46256) are hard to debug
without more information. While this information has been expanded
in CleverRaven#46473, this does not give enough examples, nor is it able to
tell what in "normal" builds is causing intermittent weary test
problems.
  • Loading branch information
actual-nh committed Jan 15, 2021
1 parent 4b24660 commit bd9dae8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -2689,6 +2689,8 @@ class Character : public Creature, public visitable
time_duration get_consume_time( const item &it );

int weariness_level() const;
int weary_threshold() const;
int weariness() const;
float activity_level() const;
float exertion_adjusted_move_multiplier( float level = -1.0f ) const;
void try_reduce_weariness( float exertion );
Expand Down Expand Up @@ -2754,8 +2756,6 @@ class Character : public Creature, public visitable
int healthy_mod = 0;

weariness_tracker weary;
int weary_threshold() const;
int weariness() const;
// Our bmr at no activity level
int base_bmr() const;

Expand Down
15 changes: 11 additions & 4 deletions tests/activity_scheduling_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ weariness_events do_activity( tasklist tasks )
tasks.advance( task.interval );
// If we're more weary than we were when we started, report it
if( new_weariness != weariness_lvl ) {
activity_log.log( weariness_lvl, new_weariness, spent );
int new_weary = guy.weariness();
int new_thresh = guy.weary_threshold();
activity_log.log( weariness_lvl, new_weariness, spent,
new_weary, new_thresh );
weariness_lvl = new_weariness;
}
}
Expand Down Expand Up @@ -167,12 +170,15 @@ time_duration tasklist::duration()
return ret;
}

void weariness_events::log( const int old_level, const int new_level, const time_duration &when )
void weariness_events::log( const int old_level, const int new_level, const time_duration &when,
const int new_weariness, const int new_threshold )
{
weary_transition added;
added.from = old_level;
added.to = new_level;
added.minutes = to_minutes<int>( when );
added.new_weariness = new_weariness;
added.new_threshold = new_threshold;

transitions.insert( transitions.end(), added );
}
Expand All @@ -196,8 +202,9 @@ std::string weariness_events::summarize() const
{
std::string buffer;
for( const weary_transition &change : transitions ) {
buffer += string_format( "Transition: Weariness from %d to %d at %d minutes\n", change.from,
change.to, change.minutes );
buffer += string_format( "Transition: Weariness lvl from %d to %d at %d min (W %d Th %d)\n",
change.from, change.to, change.minutes,
change.new_weariness, change.new_threshold );
}
return buffer;
}
Expand Down
5 changes: 4 additions & 1 deletion tests/activity_scheduling_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,15 @@ struct weariness_events {
int minutes = 0;
int from = 0;
int to = 0;
int new_weariness = 0;
int new_threshold = 0;
};

std::vector<weary_transition> transitions;

public:
void log( int old_level, int new_level, const time_duration &when );
void log( int old_level, int new_level, const time_duration &when,
int new_weariness, int new_threshold );

// Return the first time a transition between `from` and `to` occurs, in minutes
// if around = 0_seconds or equivalent, otherwise return the time closest to around
Expand Down

0 comments on commit bd9dae8

Please sign in to comment.