diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index b8db55d5b..dbc999d85 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -450,6 +450,9 @@ void json_config(cJSON *json) { if (strcmp(child->string, "races")==0) { json_races(child); } + else if (strcmp(child->string, "items")==0) { + json_items(child); + } else if (strcmp(child->string, "ships")==0) { json_ships(child); } diff --git a/src/kernel/jsonconf.test.c b/src/kernel/jsonconf.test.c index 26827ae42..9b9d3ed61 100644 --- a/src/kernel/jsonconf.test.c +++ b/src/kernel/jsonconf.test.c @@ -4,6 +4,7 @@ #include "building.h" #include "direction.h" +#include "item.h" #include "keyword.h" #include "race.h" #include "ship.h" @@ -82,6 +83,27 @@ static void test_races(CuTest * tc) test_cleanup(); } +static void test_items(CuTest * tc) +{ + const char * data = "{\"items\": { " + "\"axe\" : {}," + "\"horse\" : {}" + "}}"; + cJSON *json = cJSON_Parse(data); + + test_cleanup(); + + CuAssertPtrNotNull(tc, json); + CuAssertPtrEquals(tc, 0, it_find("axe")); + CuAssertPtrEquals(tc, 0, rt_find("axe")); + CuAssertPtrEquals(tc, 0, (void *)get_resourcetype(R_HORSE)); + + json_config(json); + CuAssertPtrNotNull(tc, it_find("axe")); + CuAssertPtrNotNull(tc, rt_find("axe")); + CuAssertPtrNotNull(tc, (void *)get_resourcetype(R_HORSE)); +} + static void test_ships(CuTest * tc) { const char * data = "{\"ships\": { \"boat\" : { " @@ -234,6 +256,7 @@ CuSuite *get_jsonconf_suite(void) SUITE_ADD_TEST(suite, test_keywords); SUITE_ADD_TEST(suite, test_skills); SUITE_ADD_TEST(suite, test_directions); + SUITE_ADD_TEST(suite, test_items); SUITE_ADD_TEST(suite, test_ships); SUITE_ADD_TEST(suite, test_buildings); SUITE_ADD_TEST(suite, test_terrains);