Skip to content

Commit

Permalink
Check on weary ticks.
Browse files Browse the repository at this point in the history
This monitors, with weary level transitions, the low_activity_ticks
and tick_counter, to see if this can help figure out why weary.tracker
is increasing while resting.

(cherry picked from commit 4c4b9cd)
  • Loading branch information
actual-nh committed Feb 19, 2021
1 parent ab4ba67 commit c01a661
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
10 changes: 10 additions & 0 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5079,6 +5079,16 @@ int Character::weary_intake() const
return weary.intake;
}

int Character::weary_low_activity_ticks() const
{
return weary.low_activity_ticks;
}

int Character::weary_tick_counter() const
{
return weary.tick_counter;
}

void weariness_tracker::clear()
{
tracker = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -2732,6 +2732,8 @@ class Character : public Creature, public visitable
int weariness() const;
int weary_tracker() const;
int weary_intake() const;
int weary_low_activity_ticks() const;
int weary_tick_counter() const;
float activity_level() const;
float exertion_adjusted_move_multiplier( float level = -1.0f ) const;
void try_reduce_weariness( float exertion );
Expand Down
17 changes: 12 additions & 5 deletions tests/activity_scheduling_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,17 @@ weariness_events do_activity( tasklist tasks )
int new_weariness = guy.weariness_level();
spent += task.interval;
tasks.advance( task.interval );
// If we're more weary than we were when we started, report it
// If we're more or less weary than we were when we started, report it
if( new_weariness != weariness_lvl ) {
int new_weary = guy.weariness();
int new_thresh = guy.weary_threshold();
int new_tracker = guy.weary_tracker();
int new_intake = guy.weary_intake();
int new_low_activity_ticks = guy.weary_low_activity_ticks();
int new_tick_counter = guy.weary_tick_counter();
activity_log.log( weariness_lvl, new_weariness, spent,
new_weary, new_thresh, new_tracker, new_intake );
new_weary, new_thresh, new_tracker, new_intake,
new_low_activity_ticks, new_tick_counter );
weariness_lvl = new_weariness;
}
}
Expand Down Expand Up @@ -174,7 +177,8 @@ time_duration tasklist::duration()

void weariness_events::log( const int old_level, const int new_level, const time_duration &when,
const int new_weariness, const int new_threshold,
const int new_tracker, const int new_intake )
const int new_tracker, const int new_intake,
const int new_low_activity_ticks, const int new_tick_counter )
{
weary_transition added;
added.from = old_level;
Expand All @@ -184,6 +188,8 @@ void weariness_events::log( const int old_level, const int new_level, const time
added.new_threshold = new_threshold;
added.new_tracker = new_tracker;
added.new_intake = new_intake;
added.new_low_activity_ticks = new_low_activity_ticks;
added.new_tick_counter = new_tick_counter;

transitions.insert( transitions.end(), added );
}
Expand Down Expand Up @@ -229,10 +235,11 @@ std::string weariness_events::summarize() const
{
std::string buffer;
for( const weary_transition &change : transitions ) {
buffer += string_format( "Transition: Weary lvl %d to %d at %d min (W %d Th %d Tr %d In %d)\n",
buffer += string_format( "Chng: Weary lv %d to %d at %d min (W %d Th %d Tr %d In %d Lt %d Tk %d)\n",
change.from, change.to, change.minutes,
change.new_weariness, change.new_threshold,
change.new_tracker, change.new_intake );
change.new_tracker, change.new_intake,
change.new_low_activity_ticks, change.new_tick_counter );
}
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 @@ -97,13 +97,16 @@ struct weariness_events {
int new_threshold = 0;
int new_tracker = 0;
int new_intake = 0;
int new_low_activity_ticks = 0;
int new_tick_counter = 0;
};

std::vector<weary_transition> transitions;

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

// 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 c01a661

Please sign in to comment.