fix(audit-M1): tile_at 3-arg form accepts nil map_id with current_map fallback
This commit is contained in:
10
init.lua
10
init.lua
@@ -169,16 +169,18 @@ function M.tile_size(map_id)
|
|||||||
return map_registry[id].tile_size
|
return map_registry[id].tile_size
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Arity-flex sugar: tile_at(tx, ty) uses current_map_id; tile_at(map_id, tx, ty) is explicit.
|
-- Arity-flex sugar: tile_at(tx, ty) uses current_map_id; tile_at(map_id, tx, ty)
|
||||||
|
-- is explicit. Both forms accept nil map_id and fall back to current_map_id.
|
||||||
function M.tile_at(a, b, c)
|
function M.tile_at(a, b, c)
|
||||||
local map_id, tx, ty
|
local map_id, tx, ty
|
||||||
if c == nil then
|
if c == nil then
|
||||||
map_id, tx, ty = current_map_id, a, b
|
map_id, tx, ty = current_map_id, a, b
|
||||||
if not map_id then
|
|
||||||
error("maps.tile_at: no current map; call set_current() first or pass map_id")
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
map_id, tx, ty = a, b, c
|
map_id, tx, ty = a, b, c
|
||||||
|
if map_id == nil then map_id = current_map_id end
|
||||||
|
end
|
||||||
|
if not map_id then
|
||||||
|
error("maps.tile_at: no current map; call set_current() first or pass map_id")
|
||||||
end
|
end
|
||||||
local m = map_registry[map_id]
|
local m = map_registry[map_id]
|
||||||
if not m then
|
if not m then
|
||||||
|
|||||||
Reference in New Issue
Block a user