Skip to content

Commit

Permalink
simplify coverage recording
Browse files Browse the repository at this point in the history
  • Loading branch information
myk002 committed Aug 10, 2024
1 parent 1ab9c17 commit 6162a1b
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions timestream.lua
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ local function clamp_coverage(timeskip)
end

local function record_coverage()
local coverage_slot = (df.global.cur_year_tick+1) % 50
local coverage_slot = df.global.cur_year_tick % 50
if DEBUG >= 3 and not tick_coverage[coverage_slot] then
print('recording coverage for slot:', coverage_slot)
end
Expand Down Expand Up @@ -171,8 +171,7 @@ local function clamp_timeskip(timeskip)
local next_tick = df.global.cur_year_tick + 1
timeskip = math.min(timeskip, get_next_trigger_year_tick(next_tick)-next_tick)
timeskip = math.min(timeskip, get_next_birthday(next_tick)-next_tick)
timeskip = math.min(timeskip, clamp_coverage(timeskip))
return timeskip
return clamp_coverage(timeskip)
end

local function increment_counter(obj, counter_name, timeskip)
Expand Down Expand Up @@ -334,7 +333,9 @@ local function adjust_activities(timeskip)
end
end

local function on_tick_impl()
local function on_tick()
record_coverage()

if df.global.cur_year_tick % 10 == 0 then
season_tick_throttled = false
if df.global.cur_year_tick % 1000 == 0 then
Expand Down Expand Up @@ -368,8 +369,8 @@ local function on_tick_impl()
timeskip_deficit = math.min(desired_timeskip - timeskip, 100.0)

if DEBUG >= 2 then
print(('cur_year_tick: %d, timeskip: (%d, +%.2f)'):format(
df.global.cur_year_tick, timeskip, timeskip_deficit))
print(('cur_year_tick: %d, real_fps: %d, timeskip: (%d, +%.2f)'):format(
df.global.cur_year_tick, real_fps, timeskip, timeskip_deficit))
end
if timeskip <= 0 then return end

Expand All @@ -380,11 +381,6 @@ local function on_tick_impl()
adjust_activities(timeskip)
end

local function on_tick()
on_tick_impl()
record_coverage()
end

------------------------------------
-- hook management

Expand Down

0 comments on commit 6162a1b

Please sign in to comment.