Skip to content

Commit

Permalink
Updating contingents only after the morning hour so that contingent t…
Browse files Browse the repository at this point in the history
…asks don't randomly pop up at midnight.
  • Loading branch information
Brotcrunsher committed Jan 7, 2025
1 parent bd4b3ed commit 31af980
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Examples/ExampleMother/EMTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,13 +583,16 @@ void SubsystemTask::update()
if (t.contingentTask)
{
const bbe::TimePoint today = bbe::TimePoint().toMorning();
const int32_t days = (today - t.previousContingentSubtraction).toDays();
if (days > 0)
if (today < bbe::TimePoint()) // Only update the contingent when we are after the current morning.
{
t.previousContingentSubtraction = today;
requiresWrite = true;
t.collectedContingentSeconds -= days * t.contingentSecondsPerDay;
if (t.collectedContingentSeconds < 0) t.collectedContingentSeconds = 0;
const int32_t days = (today - t.previousContingentSubtraction).toDays();
if (days > 0)
{
t.previousContingentSubtraction = today;
requiresWrite = true;
t.collectedContingentSeconds -= days * t.contingentSecondsPerDay;
if (t.collectedContingentSeconds < 0) t.collectedContingentSeconds = 0;
}
}

if (t.stopContingentWhenLocked)
Expand Down

0 comments on commit 31af980

Please sign in to comment.