fix item inventoryFilters handling

This commit is contained in:
Kae 2024-12-27 08:47:40 +11:00
parent 1210a75fb7
commit 3205f3b283
2 changed files with 5 additions and 3 deletions

View File

@ -12,5 +12,7 @@
"maxWireTrans" : 0.4 "maxWireTrans" : 0.4
}, },
"inventoryFilters" : { "default" : {} },
"swapDance" : null // Set this to a valid dance to trigger on character swap. "swapDance" : null // Set this to a valid dance to trigger on character swap.
} }

View File

@ -947,14 +947,14 @@ bool PlayerInventory::checkInventoryFilter(ItemPtr const& items, String const& f
auto itemFilters = items->instanceValue("inventoryFilters"); auto itemFilters = items->instanceValue("inventoryFilters");
if (itemFilters.isType(Json::Type::Object)) { if (itemFilters.isType(Json::Type::Object)) {
filterConfig = itemFilters.get(filterName); filterConfig = itemFilters.opt(filterName).value();
if (!filterConfig.isType(Json::Type::Object)) if (!filterConfig.isType(Json::Type::Object))
filterConfig = itemFilters.get("default"); filterConfig = itemFilters.opt("default").value();
} }
if (!filterConfig.isType(Json::Type::Object)) { if (!filterConfig.isType(Json::Type::Object)) {
auto config = Root::singleton().assets()->json("/player.config:inventoryFilters"); auto config = Root::singleton().assets()->json("/player.config:inventoryFilters");
filterConfig = config.get(filterName); filterConfig = config.opt(filterName).value();
if (!filterConfig.isType(Json::Type::Object)) if (!filterConfig.isType(Json::Type::Object))
filterConfig = config.get("default"); filterConfig = config.get("default");
} }