Skip to content

Commit

Permalink
Fix callback not starting after save load
Browse files Browse the repository at this point in the history
ScanManager: StartScanCallback had no way to determine if the current ScanManager was loaded from save when it needed to set up a callback.
  • Loading branch information
Max5377 committed Sep 28, 2023
1 parent a6c5722 commit 443d3e9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions data/modules/Scout/ScanManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -501,15 +501,18 @@ function ScanManager:OnEnteredFrame(body)
end

-- Start the scanner callback
---@param force boolean
---@package
function ScanManager:StartScanCallback()
function ScanManager:StartScanCallback(force)
local updateRate = self.activeScan.orbital and ORBITAL_SCAN_UPDATE_RATE or SURFACE_SCAN_UPDATE_RATE

-- Immediately trigger a scan update for responsiveness
self:OnUpdateScan(self.activeScan)

-- Don't queue a new scan callback if we're already running one at the right frequency
if updateRate == self.activeCallback then
-- Force this check if this function was called from ScanManager:Unserialize() because
-- callback is not yet setted up
if updateRate == self.activeCallback and not force then
return
end

Expand Down Expand Up @@ -610,7 +613,7 @@ function ScanManager:Unserialize()

-- Restore the scanning callback on loading a saved game
if self.activeCallback then
self:StartScanCallback()
self:StartScanCallback(true)
end

return self
Expand Down

0 comments on commit 443d3e9

Please sign in to comment.