1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-02 16:38:41 +00:00

Try to fix cdb aliases for games

This commit is contained in:
Nathanaëlle Courant 2025-05-18 20:23:58 +02:00
parent 9b2ee1dd5d
commit 4be8fc59a7

View file

@ -169,15 +169,17 @@ function contentdb.get_package_by_id(id)
return contentdb.package_by_id[id]
end
local function strip_game_suffix(type, name)
if (type == nil or type == "game") and #name > 5 and name:sub(#name - 4) == "_game" then
return name:sub(1, #name - 5)
else
return name
end
end
function contentdb.calculate_package_id(type, author, name)
local id = author:lower() .. "/"
if (type == nil or type == "game") and #name > 5 and name:sub(#name - 4) == "_game" then
id = id .. name:sub(1, #name - 5)
else
id = id .. name
end
return id
return author:lower() .. "/" .. strip_game_suffix(type, name)
end
@ -427,11 +429,12 @@ function contentdb.set_packages_from_api(packages)
-- We currently don't support name changing
local suffix = "/" .. package.name
if alias:sub(-#suffix) == suffix then
contentdb.aliases[alias:lower()] = package.id
contentdb.aliases[strip_game_suffix(packages.type, alias:lower())] = package.id
end
end
end
end
print(dump(contentdb.aliases))
contentdb.load_ok = true
contentdb.load_error = false