mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-20 14:21:08 +00:00
Updates for newer luacheck.
This commit is contained in:
parent
8e7029fc51
commit
a5e7986b3e
|
@ -12,7 +12,4 @@ quiet=1
|
||||||
global=false
|
global=false
|
||||||
-- don't show unused variables
|
-- don't show unused variables
|
||||||
unused=false
|
unused=false
|
||||||
-- excluded files due to using lua 5.4 syntax that currently gets flagged as a syntax error
|
exclude_files={"src/modules/lua/testes/*.lua"}
|
||||||
-- clear out once a newer Ubuntu LTS base is used for our docker images, which would then also have a newer luacheck available
|
|
||||||
-- leave the lua module exclusion however
|
|
||||||
exclude_files={"data/lua/core/wml.lua","data/lua/wml-flow.lua","data/lua/wml/find_path.lua","data/lua/wml/harm_unit.lua","data/lua/wml/modify_unit.lua","data/lua/wml/random_placement.lua","data/lua/functional.lua","src/modules/lua/testes/*.lua"}
|
|
||||||
|
|
|
@ -59,9 +59,9 @@ function wesnoth.wml_actions.find_path(cfg)
|
||||||
ignore_visibility = ignore_visibility
|
ignore_visibility = ignore_visibility
|
||||||
} )
|
} )
|
||||||
|
|
||||||
if #path == 0 or cost >= 42424241 then
|
-- it's a reachable hex.
|
||||||
-- it's not a reachable hex. 42424242 is the high value returned for unwalkable or busy terrains
|
-- it's not 0, and less than 42424242 which is the high value returned for unwalkable or busy terrains
|
||||||
else
|
if #path ~= 0 and cost < 42424241 then
|
||||||
local steps = #path
|
local steps = #path
|
||||||
|
|
||||||
local is_better = false
|
local is_better = false
|
||||||
|
|
|
@ -78,7 +78,6 @@ function wml_actions.harm_unit(cfg)
|
||||||
damage_multiplier = damage_multiplier - tod_bonus
|
damage_multiplier = damage_multiplier - tod_bonus
|
||||||
elseif alignment == "liminal" then
|
elseif alignment == "liminal" then
|
||||||
damage_multiplier = damage_multiplier + math.max(0, wesnoth.current.schedule.liminal_bonus - math.abs(tod_bonus))
|
damage_multiplier = damage_multiplier + math.max(0, wesnoth.current.schedule.liminal_bonus - math.abs(tod_bonus))
|
||||||
else -- neutral, do nothing
|
|
||||||
end
|
end
|
||||||
local resistance_modified = resistance * modifier
|
local resistance_modified = resistance * modifier
|
||||||
damage_multiplier = damage_multiplier * resistance_modified
|
damage_multiplier = damage_multiplier * resistance_modified
|
||||||
|
|
|
@ -10,20 +10,20 @@ function wml_actions.modify_unit(cfg)
|
||||||
|
|
||||||
local replace_mode = cfg.mode == "replace"
|
local replace_mode = cfg.mode == "replace"
|
||||||
|
|
||||||
local function handle_attributes(cfg, unit_path, toplevel)
|
local function handle_attributes(child_cfg, unit_path, toplevel)
|
||||||
for current_key, current_value in pairs(wml.shallow_parsed(cfg)) do
|
for current_key, current_value in pairs(wml.shallow_parsed(child_cfg)) do
|
||||||
if type(current_value) ~= "table" and (not toplevel or (current_key ~= "type" and current_key ~= "mode")) then
|
if type(current_value) ~= "table" and (not toplevel or (current_key ~= "type" and current_key ~= "mode")) then
|
||||||
wml.variables[string.format("%s.%s", unit_path, current_key)] = current_value
|
wml.variables[string.format("%s.%s", unit_path, current_key)] = current_value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function handle_child(cfg, unit_path)
|
local function handle_child(child_cfg, unit_path)
|
||||||
local children_handled = {}
|
local children_handled = {}
|
||||||
local cfg = wml.shallow_parsed(cfg)
|
child_cfg = wml.shallow_parsed(child_cfg)
|
||||||
handle_attributes(cfg, unit_path)
|
handle_attributes(child_cfg, unit_path)
|
||||||
|
|
||||||
for current_index, current_table in ipairs(cfg) do
|
for current_index, current_table in ipairs(child_cfg) do
|
||||||
local current_tag = current_table[1]
|
local current_tag = current_table[1]
|
||||||
local tag_index = children_handled[current_tag] or 0
|
local tag_index = children_handled[current_tag] or 0
|
||||||
handle_child(current_table[2], string.format("%s.%s[%u]",
|
handle_child(current_table[2], string.format("%s.%s[%u]",
|
||||||
|
@ -43,7 +43,7 @@ function wml_actions.modify_unit(cfg)
|
||||||
for current_index, current_table in ipairs(wml.shallow_parsed(cfg)) do
|
for current_index, current_table in ipairs(wml.shallow_parsed(cfg)) do
|
||||||
local current_tag = current_table[1]
|
local current_tag = current_table[1]
|
||||||
if current_tag == "filter" then
|
if current_tag == "filter" then
|
||||||
-- nothing
|
goto skip
|
||||||
elseif current_tag == "object" or current_tag == "trait" or current_tag == "advancement" then
|
elseif current_tag == "object" or current_tag == "trait" or current_tag == "advancement" then
|
||||||
local mod = current_table[2]
|
local mod = current_table[2]
|
||||||
if mod.delayed_variable_substitution then
|
if mod.delayed_variable_substitution then
|
||||||
|
@ -85,6 +85,7 @@ function wml_actions.modify_unit(cfg)
|
||||||
unit_path, current_tag, tag_index))
|
unit_path, current_tag, tag_index))
|
||||||
children_handled[current_tag] = tag_index + 1
|
children_handled[current_tag] = tag_index + 1
|
||||||
end
|
end
|
||||||
|
::skip::
|
||||||
end
|
end
|
||||||
|
|
||||||
if cfg.type then
|
if cfg.type then
|
||||||
|
|
|
@ -43,6 +43,7 @@ wesnoth.wml_actions.random_placement = function(cfg)
|
||||||
wml.variables[variable .. ".terrain"] = wesnoth.current.map[point]
|
wml.variables[variable .. ".terrain"] = wesnoth.current.map[point]
|
||||||
if distance < 0 then
|
if distance < 0 then
|
||||||
-- optimisation: nothing to do for distance < 0
|
-- optimisation: nothing to do for distance < 0
|
||||||
|
goto skip
|
||||||
elseif distance == 0 then
|
elseif distance == 0 then
|
||||||
-- optimisation: for distance = 0 we just need to remove the element at index
|
-- optimisation: for distance = 0 we just need to remove the element at index
|
||||||
-- optimisation: swapping elements and storing size in an extra variable is faster than table.remove(locs, j)
|
-- optimisation: swapping elements and storing size in an extra variable is faster than table.remove(locs, j)
|
||||||
|
@ -77,6 +78,7 @@ wesnoth.wml_actions.random_placement = function(cfg)
|
||||||
::continue::
|
::continue::
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
::skip::
|
||||||
-- TODO: This should really be "do" but is kept as "command" for compatibility
|
-- TODO: This should really be "do" but is kept as "command" for compatibility
|
||||||
for do_child in wml.child_range(cfg, "command") do
|
for do_child in wml.child_range(cfg, "command") do
|
||||||
local action = utils.handle_event_commands(do_child, "loop")
|
local action = utils.handle_event_commands(do_child, "loop")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user