From 4be8fc59a7f5260b4d3b5f465c5539c9cf437b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathana=C3=ABlle=20Courant?= Date: Sun, 18 May 2025 20:23:58 +0200 Subject: [PATCH] Try to fix cdb aliases for games --- builtin/mainmenu/content/contentdb.lua | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/builtin/mainmenu/content/contentdb.lua b/builtin/mainmenu/content/contentdb.lua index be148841a..83f22b97b 100644 --- a/builtin/mainmenu/content/contentdb.lua +++ b/builtin/mainmenu/content/contentdb.lua @@ -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