Switch item definitions to a JSON-driven runtime registry

Replaces the build-time item.json/tools.item.py code generator with a
single item_t ITEM registry populated at runtime by parsing
assets/items.jsonc, so items/types can grow without a rebuild. Adds
itemGetDefById/itemGetTypeById/itemGetIdByName/itemTypeGetOrCreate,
updates inventory/backpack to size off the new *_DEF_COUNT_MAX caps
and look up types dynamically, and reorders engine init so rpgInit
(which loads items) runs before uiInit (which needs the item type
count to size the backpack's tabs).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
2026-09-13 11:36:50 -05:00
co-authored by Claude Sonnet 5
parent 804f8aa1fa
commit 109ddc9e1e
15 changed files with 216 additions and 174 deletions
+6 -2
View File
@@ -10,6 +10,10 @@
#include "ui/rpg/textbox/uitextboxmain.h"
#include "ui/focus/uifocus.h"
// An arbitrary, non-null itemid_t -- entityItemSet just stores/reports it
// verbatim, it doesn't need a real item registered in ITEM.
#define TEST_ITEM_ID ((itemid_t)1)
static entity_t *setUpItemEntity(void) {
entityTestFixtureReset();
uiFocusInit();
@@ -32,8 +36,8 @@ static void test_entityItemSet(void **state) {
entity_t *item = setUpItemEntity();
entityItemSet(item, ITEM_ID_POTION, 3);
assert_int_equal(item->data.item.item, ITEM_ID_POTION);
entityItemSet(item, TEST_ITEM_ID, 3);
assert_int_equal(item->data.item.item, TEST_ITEM_ID);
assert_int_equal(item->data.item.quantity, 3);
assert_false(item->data.item.collected);
}