mirror of
https://github.com/Xevion/project-cybersyn.git
synced 2025-12-10 16:08:13 -06:00
Fix edge case where manager script.on_nth_tick could clobber main script.on_nth_tick
This commit is contained in:
@@ -847,6 +847,14 @@ local function grab_all_settings()
|
|||||||
end
|
end
|
||||||
local function register_tick()
|
local function register_tick()
|
||||||
script.on_nth_tick(nil)
|
script.on_nth_tick(nil)
|
||||||
|
--edge case catch to register both main and manager tick if they're scheduled to run on the same ticks
|
||||||
|
if mod_settings.manager_enabled and mod_settings.manager_ups == mod_settings.tps and mod_settings.tps > DELTA then
|
||||||
|
local nth_tick = ceil(60/mod_settings.tps)
|
||||||
|
script.on_nth_tick(nth_tick, function()
|
||||||
|
tick(global, mod_settings)
|
||||||
|
manager.tick(global)
|
||||||
|
end)
|
||||||
|
else
|
||||||
if mod_settings.tps > DELTA then
|
if mod_settings.tps > DELTA then
|
||||||
local nth_tick_main = ceil(60/mod_settings.tps)--[[@as uint]]
|
local nth_tick_main = ceil(60/mod_settings.tps)--[[@as uint]]
|
||||||
script.on_nth_tick(nth_tick_main, function()
|
script.on_nth_tick(nth_tick_main, function()
|
||||||
@@ -860,6 +868,7 @@ local function register_tick()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
local function on_settings_changed(event)
|
local function on_settings_changed(event)
|
||||||
grab_all_settings()
|
grab_all_settings()
|
||||||
if event.setting == "cybersyn-ticks-per-second" or event.setting == "cybersyn-manager-updates-per-second" then
|
if event.setting == "cybersyn-ticks-per-second" or event.setting == "cybersyn-manager-updates-per-second" then
|
||||||
|
|||||||
Reference in New Issue
Block a user