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:
parent
9b2ee1dd5d
commit
4be8fc59a7
1 changed files with 11 additions and 8 deletions
|
@ -169,15 +169,17 @@ function contentdb.get_package_by_id(id)
|
||||||
return contentdb.package_by_id[id]
|
return contentdb.package_by_id[id]
|
||||||
end
|
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)
|
function contentdb.calculate_package_id(type, author, name)
|
||||||
local id = author:lower() .. "/"
|
return author:lower() .. "/" .. strip_game_suffix(type, name)
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -427,11 +429,12 @@ function contentdb.set_packages_from_api(packages)
|
||||||
-- We currently don't support name changing
|
-- We currently don't support name changing
|
||||||
local suffix = "/" .. package.name
|
local suffix = "/" .. package.name
|
||||||
if alias:sub(-#suffix) == suffix then
|
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
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
print(dump(contentdb.aliases))
|
||||||
|
|
||||||
contentdb.load_ok = true
|
contentdb.load_ok = true
|
||||||
contentdb.load_error = false
|
contentdb.load_error = false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue