mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-08-12 16:35:11 +09:00
Fix arity and return value mismatches
`assert` returns every argument it is given, so `return assert(x, msg)` was leaking the message as a second return value. `get_tile` is documented as taking x and y. The async function class declared `@operator call` with no parameters, which made every async call look over supplied. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -22,13 +22,8 @@
|
||||
"globals": [ "__DebugAdapter", "__Profiler" ],
|
||||
"disable": [
|
||||
"assign-type-mismatch",
|
||||
"missing-parameter",
|
||||
"param-type-mismatch",
|
||||
"preferred-local-alias",
|
||||
"redefined-local",
|
||||
"redundant-parameter",
|
||||
"redundant-return-value",
|
||||
"return-type-mismatch",
|
||||
"unnecessary-assert",
|
||||
"unnecessary-if",
|
||||
"unused"
|
||||
|
||||
@@ -47,10 +47,10 @@ end
|
||||
function Gui.get_player(input)
|
||||
if type(input) == "table" and not input.player_index then
|
||||
--- @cast input { element: LuaGuiElement }
|
||||
return assert(game.get_player(input.element.player_index))
|
||||
return (assert(game.get_player(input.element.player_index)))
|
||||
end
|
||||
--- @cast input LuaGuiElement | { player_index: uint }
|
||||
return assert(game.get_player(input.player_index))
|
||||
return (assert(game.get_player(input.player_index)))
|
||||
end
|
||||
|
||||
--- Toggle the enable state of an element
|
||||
@@ -116,7 +116,7 @@ end
|
||||
--- @param player LuaPlayer
|
||||
--- @return LuaGuiElement
|
||||
function Gui.get_top_element(define, player)
|
||||
return assert(assert(player_elements[player.index]).top[define.name], "Element is not on the top flow")
|
||||
return (assert(assert(player_elements[player.index]).top[define.name], "Element is not on the top flow"))
|
||||
end
|
||||
|
||||
--- Register a element define to be drawn to the left flow on join
|
||||
@@ -124,7 +124,7 @@ end
|
||||
--- @param player LuaPlayer
|
||||
--- @return LuaGuiElement
|
||||
function Gui.get_left_element(define, player)
|
||||
return assert(assert(player_elements[player.index]).left[define.name], "Element is not on the left flow")
|
||||
return (assert(assert(player_elements[player.index]).left[define.name], "Element is not on the left flow"))
|
||||
end
|
||||
|
||||
--- Register a element define to be drawn to the relative flow on join
|
||||
@@ -132,7 +132,7 @@ end
|
||||
--- @param player LuaPlayer
|
||||
--- @return LuaGuiElement
|
||||
function Gui.get_relative_element(define, player)
|
||||
return assert(assert(player_elements[player.index]).relative[define.name], "Element is not on the relative flow")
|
||||
return (assert(assert(player_elements[player.index]).relative[define.name], "Element is not on the relative flow"))
|
||||
end
|
||||
|
||||
--- Ensure all the correct elements are visible and exist
|
||||
|
||||
@@ -52,7 +52,7 @@ Elements.bar = Gui.define("bar")
|
||||
|
||||
--- A label which is centered
|
||||
--- @class Gui.elements.centered_label: ExpElement
|
||||
--- @overload fun(parent: LuaGuiElement, width: number, caption: LocalisedString, tooltip: LocalisedString?): LuaGuiElement
|
||||
--- @overload fun(parent: LuaGuiElement, width: number, caption: LocalisedString?, tooltip: LocalisedString?): LuaGuiElement
|
||||
Elements.centered_label = Gui.define("centered_label")
|
||||
:draw{
|
||||
type = "label",
|
||||
@@ -319,7 +319,7 @@ Elements.screen_frame = Gui.define("screen_frame")
|
||||
--- @param screen_frame LuaGuiElement
|
||||
--- @return LuaGuiElement
|
||||
function Elements.screen_frame.get_button_flow(screen_frame)
|
||||
return assert(Elements.screen_frame.data[screen_frame.parent], "Screen frame has no button flow")
|
||||
return (assert(Elements.screen_frame.data[screen_frame.parent], "Screen frame has no button flow"))
|
||||
end
|
||||
|
||||
--- Get the root element of a screen frame
|
||||
|
||||
@@ -166,7 +166,7 @@ end
|
||||
--- @param name string
|
||||
--- @return ExpElement
|
||||
function ExpElement.get(name)
|
||||
return assert(ExpElement._elements[name], "ExpElement is not defined: " .. tostring(name))
|
||||
return (assert(ExpElement._elements[name], "ExpElement is not defined: " .. tostring(name)))
|
||||
end
|
||||
|
||||
--- Create a new instance of this element definition
|
||||
|
||||
@@ -24,6 +24,7 @@ local afk_time_units = {
|
||||
}
|
||||
|
||||
return {
|
||||
--- @type table<string, LocalisedString | fun(player: LuaPlayer, is_command: boolean): LocalisedString>
|
||||
messages = { --- @setting messages will trigger when ever the word is said
|
||||
["discord"] = { "info.discord" },
|
||||
["expgaming"] = { "info.website" },
|
||||
@@ -66,6 +67,7 @@ return {
|
||||
command_admin_only = false, --- @setting command_admin_only when true will only allow chat commands for admins
|
||||
command_permission = "command/chat-commands", --- @setting command_permission the permission used to allow command prefixes
|
||||
command_prefix = "!", --- @setting command_prefix prefix used for commands below and to print to all players (if enabled above)
|
||||
--- @type table<string, LocalisedString | fun(player: LuaPlayer, is_command: boolean): LocalisedString>
|
||||
commands = { --- @setting commands will trigger only when command prefix is given
|
||||
["dev"] = { "exp_chat-auto-reply.reply-dev" },
|
||||
["magic"] = { "exp_chat-auto-reply.reply-magic" },
|
||||
|
||||
@@ -50,7 +50,7 @@ local servers = External.get_servers()
|
||||
]]
|
||||
function External.get_servers()
|
||||
assert(ext, "No external data was found, use External.valid() to ensure external data exists.")
|
||||
return assert(ext.servers, "No server list was found, please ensure that the external service is running")
|
||||
return (assert(ext.servers, "No server list was found, please ensure that the external service is running"))
|
||||
end
|
||||
|
||||
--[[-- Gets a table of all the servers filtered by name, key is the server id, value is the server details
|
||||
@@ -85,7 +85,7 @@ function External.get_current_server()
|
||||
assert(ext, "No external data was found, use External.valid() to ensure external data exists.")
|
||||
local servers = assert(ext.servers, "No server list was found, please ensure that the external service is running")
|
||||
local server_id = assert(ext.current, "No current id was found, please ensure that the external service is running")
|
||||
return assert(servers[server_id], "No details found for server with id: " .. tostring(server_id))
|
||||
return (assert(servers[server_id], "No details found for server with id: " .. tostring(server_id)))
|
||||
end
|
||||
|
||||
--[[-- Gets the details of the given server
|
||||
@@ -99,7 +99,7 @@ local server = External.get_server_details('eu-01')
|
||||
function External.get_server_details(server_id)
|
||||
assert(ext, "No external data was found, use External.valid() to ensure external data exists.")
|
||||
local servers = assert(ext.servers, "No server list was found, please ensure that the external service is running")
|
||||
return assert(servers[server_id], "No details found for server with id: " .. tostring(server_id))
|
||||
return (assert(servers[server_id], "No details found for server with id: " .. tostring(server_id)))
|
||||
end
|
||||
|
||||
--[[-- Gets the status of the given server
|
||||
|
||||
@@ -376,7 +376,7 @@ function Roles.get_player_highest_role(player)
|
||||
end
|
||||
end
|
||||
|
||||
return assert(highest, "Player has no roles")
|
||||
return (assert(highest, "Player has no roles"))
|
||||
end
|
||||
|
||||
--- Assignment.
|
||||
|
||||
@@ -18,7 +18,7 @@ end
|
||||
--- @param surface LuaSurface
|
||||
--- @param position MapPosition.struct
|
||||
local function degrade_tile(surface, position)
|
||||
local tile = surface.get_tile(position)
|
||||
local tile = surface.get_tile(position.x, position.y)
|
||||
local tile_name = tile.name
|
||||
local degrade_tile_name = config.degrade_order[tile_name]
|
||||
if not degrade_tile_name then return end
|
||||
@@ -61,7 +61,7 @@ end
|
||||
--- @param position MapPosition.struct
|
||||
--- @return number?
|
||||
local function get_tile_strength(surface, position)
|
||||
local tile = surface.get_tile(position)
|
||||
local tile = surface.get_tile(position.x, position.y)
|
||||
local tile_name = tile.name
|
||||
local strength = config.strengths[tile_name]
|
||||
if not strength then return end
|
||||
|
||||
@@ -166,7 +166,7 @@ local function clear_spawn_area(surface, offset)
|
||||
local get_tile = surface.get_tile
|
||||
|
||||
-- Make sure a non water tile is used for filling
|
||||
local starting_tile = get_tile(offset)
|
||||
local starting_tile = get_tile(offset.x, offset.y)
|
||||
local fill_tile = starting_tile.collides_with("player") and "landfill" or starting_tile.name
|
||||
local fill_radius = config.spawn_area.landfill_radius
|
||||
local fill_radius_sqr = fill_radius ^ 2
|
||||
@@ -186,7 +186,7 @@ local function clear_spawn_area(surface, offset)
|
||||
if dst < tile_radius_sqr then
|
||||
-- If it is inside the decon radius always set the tile
|
||||
tiles_to_make[#tiles_to_make + 1] = { name = decon_tile, position = pos }
|
||||
elseif dst < fill_radius_sqr and get_tile(pos).collides_with("player") then
|
||||
elseif dst < fill_radius_sqr and get_tile(pos.x, pos.y).collides_with("player") then
|
||||
-- If it is inside the fill radius only set the tile if it is water
|
||||
tiles_to_make[#tiles_to_make + 1] = { name = fill_tile, position = pos }
|
||||
end
|
||||
|
||||
@@ -94,7 +94,7 @@ Async.status = {}
|
||||
|
||||
--- @class Async.AsyncFunction
|
||||
--- @field id string The id of this async function
|
||||
--- @operator call: Async.AsyncReturn<any>
|
||||
--- @overload fun(...: any): Async.AsyncReturn<any>
|
||||
Async._function_prototype = {}
|
||||
|
||||
Async._function_metatable = {
|
||||
|
||||
Reference in New Issue
Block a user