From 90d0a122cd7799cc8d1f2398567836ea0177b51c Mon Sep 17 00:00:00 2001 From: Cooldude2606 <25043174+Cooldude2606@users.noreply.github.com> Date: Sat, 19 Oct 2024 17:49:04 +0100 Subject: [PATCH] Fixed more breaking changes --- exp_legacy/module/async.lua | 0 .../config/expcore/permission_groups.lua | 6 ++- exp_legacy/module/config/gui/autofill.lua | 2 - exp_legacy/module/control.lua | 1 + .../module/modules/commands/interface.lua | 10 ++--- exp_legacy/module/modules/gui/autofill.lua | 1 - .../module/modules/gui/debug/event_view.lua | 1 - exp_legacy/module/modules/gui/debug/model.lua | 1 - exp_util/module/async.lua | 42 ++++++++++++------- exp_util/module/common.lua | 4 +- 10 files changed, 39 insertions(+), 29 deletions(-) delete mode 100644 exp_legacy/module/async.lua diff --git a/exp_legacy/module/async.lua b/exp_legacy/module/async.lua deleted file mode 100644 index e69de29b..00000000 diff --git a/exp_legacy/module/config/expcore/permission_groups.lua b/exp_legacy/module/config/expcore/permission_groups.lua index 3aff936a..397a619f 100644 --- a/exp_legacy/module/config/expcore/permission_groups.lua +++ b/exp_legacy/module/config/expcore/permission_groups.lua @@ -60,7 +60,8 @@ Permission_Groups.new_group("Standard") "admin_action", -- trusted "change_programmable_speaker_alert_parameters", -- standard "drop_item", - "change_rocket_silo_mode", + "open_new_platform_button_from_rocket_silo", + "set_rocket_silo_send_to_orbit_automated_mode", } Permission_Groups.new_group("Guest") @@ -81,7 +82,8 @@ Permission_Groups.new_group("Guest") "admin_action", -- trusted "change_programmable_speaker_alert_parameters", -- standard "drop_item", - "change_rocket_silo_mode", + "open_new_platform_button_from_rocket_silo", + "set_rocket_silo_send_to_orbit_automated_mode", "change_programmable_speaker_parameters", -- guest "change_train_stop_station", -- 'deconstruct', diff --git a/exp_legacy/module/config/gui/autofill.lua b/exp_legacy/module/config/gui/autofill.lua index e20e1ee3..bcade17c 100644 --- a/exp_legacy/module/config/gui/autofill.lua +++ b/exp_legacy/module/config/gui/autofill.lua @@ -1,8 +1,6 @@ --- This file contains all the different settings for the autofill system and gui -- @config Autofill -local table = require("modules.exp_legacy.overrides.table") -- @dep overrides.table - local config = { -- General config icon = "item/piercing-rounds-magazine", -- @setting icon that will be used for the toolbar diff --git a/exp_legacy/module/control.lua b/exp_legacy/module/control.lua index abaa2359..8cbda5b0 100644 --- a/exp_legacy/module/control.lua +++ b/exp_legacy/module/control.lua @@ -33,6 +33,7 @@ local function error_handler(err) log("[ERROR] Failed to load: " .. currently_loading) errors[error_count] = debug.traceback(error_format:format(currently_loading, err)) end + return err end -- Loads all files from the config and logs that they are loaded diff --git a/exp_legacy/module/modules/commands/interface.lua b/exp_legacy/module/modules/commands/interface.lua index 59929b40..01787747 100644 --- a/exp_legacy/module/modules/commands/interface.lua +++ b/exp_legacy/module/modules/commands/interface.lua @@ -11,11 +11,11 @@ local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore local interface_modules = { ["Commands"] = Commands, ["output"] = Commands.print, - ["Group"] = "expcore.permission_groups", - ["Roles"] = "expcore.roles", - ["Gui"] = "expcore.gui", - ["Datastore"] = "expcore.datastore", - ["External"] = "expcore.external", + ["Group"] = "modules.exp_legacy.expcore.permission_groups", + ["Roles"] = "modules.exp_legacy.expcore.roles", + ["Gui"] = "modules.exp_legacy.expcore.gui", + ["Datastore"] = "modules.exp_legacy.expcore.datastore", + ["External"] = "modules.exp_legacy.expcore.external", } -- loads all the modules given in the above table diff --git a/exp_legacy/module/modules/gui/autofill.lua b/exp_legacy/module/modules/gui/autofill.lua index ccb1c00d..833f8ade 100644 --- a/exp_legacy/module/modules/gui/autofill.lua +++ b/exp_legacy/module/modules/gui/autofill.lua @@ -10,7 +10,6 @@ local Roles = require("modules.exp_legacy.expcore.roles") -- @dep expcore.gui local Storage = require("modules/exp_util/storage") -- @dep utils.global local config = require("modules.exp_legacy.config.gui.autofill") -- @dep config.gui.autofill local Event = require("modules/exp_legacy/utils/event") -- @dep utils.event -local table = require("modules.exp_legacy.overrides.table") -- @dep overrides.table --- Table that stores if autofill is enabled or not local autofill_player_settings = {} diff --git a/exp_legacy/module/modules/gui/debug/event_view.lua b/exp_legacy/module/modules/gui/debug/event_view.lua index 6867cc59..f358d77b 100644 --- a/exp_legacy/module/modules/gui/debug/event_view.lua +++ b/exp_legacy/module/modules/gui/debug/event_view.lua @@ -1,5 +1,4 @@ local Event = require("modules/exp_legacy/utils/event") -local table = require("modules.exp_legacy.overrides.table") local Gui = require("modules.exp_legacy.utils.gui") local Model = require("modules.exp_legacy.modules.gui.debug.model") diff --git a/exp_legacy/module/modules/gui/debug/model.lua b/exp_legacy/module/modules/gui/debug/model.lua index 80082369..652344e1 100644 --- a/exp_legacy/module/modules/gui/debug/model.lua +++ b/exp_legacy/module/modules/gui/debug/model.lua @@ -1,5 +1,4 @@ local Gui = require("modules.exp_legacy.utils.gui") --- @dep utils.gui -local table = require("modules.exp_legacy.overrides.table") --- @dep overrides.table local gui_names = Gui.names local type = type diff --git a/exp_util/module/async.lua b/exp_util/module/async.lua index 1f166493..fd77ed52 100644 --- a/exp_util/module/async.lua +++ b/exp_util/module/async.lua @@ -245,13 +245,17 @@ end --- Status Returns. -- Return values used by async functions +--- @alias Async.Status (fun(...: any): Async.Status, any[]) | (fun(...: any): Async.Status, number, any[]) + local empty_table = setmetatable({}, { __index = function() error("Field 'Returned' is Immutable") end, __newindex = function() error("Field 'Returned' is Immutable") end, }) --- Default status, will raise on_function_complete --- @param ... The return value of the async call +--- @param ... any The return value of the async call +--- @return Async.Status, any[] +--- @type Async.Status function Async.status.complete(...) if ... == nil then return Async.status.complete, empty_table @@ -260,7 +264,9 @@ function Async.status.complete(...) end --- Will queue the function to be called again on the next tick using the new arguments --- @param ... The arguments to call the function with +--- @param ... any The arguments to call the function with +--- @return Async.Status, any[] +--- @type Async.Status function Async.status.continue(...) if ... == nil then return Async.status.continue, empty_table @@ -269,7 +275,10 @@ function Async.status.continue(...) end --- Will queue the function to be called again on a later tick using the new arguments --- @param ... The arguments to call the function with +--- @param ticks number The number of ticks to delay for +--- @param ... any The arguments to call the function with +--- @return Async.Status, number, any[] +--- @type Async.Status function Async.status.delay(ticks, ...) ExpUtil.assert_argument_type(ticks, "number", 1, "ticks") assert(ticks > 0, "Ticks must be a positive number") @@ -285,9 +294,12 @@ end local new_next, new_queue = {}, {} -- File scope to allow for reuse --- Executes an async function and processes the return value +--- @param pending Async.AsyncReturn +--- @param tick number local function exec(pending, tick) - if pending.cancelled then return end - local status, rtn1, rtn2 = Async._functions[pending.id](table.unpack(pending.args)) + local async_func = Async._functions[pending.func_id] + if pending.canceled or async_func == nil then return end + local status, rtn1, rtn2 = async_func(table.unpack(pending.args)) if status == Async.status.continue then resolve_next[#resolve_next + 1] = pending pending.tick = nil @@ -298,7 +310,7 @@ local function exec(pending, tick) pending.args = rtn2 elseif status == Async.status.complete or status == nil then -- The function has finished execution, raise the custom event - Async._queue_pressure[pending.id] = Async._queue_pressure[pending.id] - 1 + Async._queue_pressure[pending.func_id] = Async._queue_pressure[pending.func_id] - 1 pending.returned = rtn1 if pending.next_id then resolve_next[#resolve_next + 1] = setmetatable({ @@ -307,7 +319,7 @@ local function exec(pending, tick) }, Async._return_metatable) end else - error("Async function " .. pending.id .. " returned an invalid status: " .. table.inspect(status)) + error("Async function " .. pending.func_id .. " returned an invalid status: " .. table.inspect(status)) end end @@ -358,22 +370,20 @@ function Async.on_load() -- Rebuild the queue pressure table for _, pending in ipairs(resolve_next) do - local count = Async._queue_pressure[pending.id] + local count = Async._queue_pressure[pending.func_id] if count then - Async._queue_pressure[pending.id] = count + 1 + Async._queue_pressure[pending.func_id] = count + 1 else - log("Warning: Pending async function missing after load: " .. pending.id) - pending.canceled = true + log("Warning: Pending async function missing after load: " .. pending.func_id) end end for _, pending in ipairs(resolve_queue) do - local count = Async._queue_pressure[pending.id] + local count = Async._queue_pressure[pending.func_id] if count then - Async._queue_pressure[pending.id] = count + 1 + Async._queue_pressure[pending.func_id] = count + 1 else - log("Warning: Pending async function missing after load: " .. pending.id) - pending.canceled = true + log("Warning: Pending async function missing after load: " .. pending.func_id) end end end @@ -381,7 +391,9 @@ end --- On init and server startup initialise the storage data function Async.on_init() if storage.exp_async_next == nil then + --- @type Async.AsyncReturn[] storage.exp_async_next = {} + --- @type Async.AsyncReturn[] storage.exp_async_queue = {} end Async.on_load() diff --git a/exp_util/module/common.lua b/exp_util/module/common.lua index 6aeca732..c0c9c06e 100644 --- a/exp_util/module/common.lua +++ b/exp_util/module/common.lua @@ -136,7 +136,7 @@ end function Common.optional_require(module_path) local success, rtn = xpcall(require, traceback, module_path) if success then return rtn end - if not rtn:find("not found; no such file", 0, true) then + if not rtn:find("no such file", 0, true) then error(rtn, 2) end end @@ -382,7 +382,7 @@ end --- @param options Common.format_time_factory_param --- @return fun(ticks: number|nil): LocalisedString function Common.format_time_factory_locale(options) - local formatter, format, coefficient = Common.format_local_time, options.format, options.coefficient + local formatter, format, coefficient = Common.format_time_locale, options.format, options.coefficient if coefficient then return function(ticks) return formatter(ticks and ticks * coefficient or nil, format, options) end end