diff --git a/cutest b/cutest index 0b718dde0..d83cec09a 160000 --- a/cutest +++ b/cutest @@ -1 +1 @@ -Subproject commit 0b718dde0939afdd1f424f5030fc1621d38ba6db +Subproject commit d83cec09a52835274ab8ed4849de16fb8658982a diff --git a/src/json.c b/src/json.c index b826b1926..9a43879ab 100644 --- a/src/json.c +++ b/src/json.c @@ -4,6 +4,7 @@ #include "json.h" #include +#include #include #include #include @@ -58,10 +59,23 @@ int json_export(stream * out, unsigned int flags) { cJSON *json, *root = cJSON_CreateObject(); assert(out && out->api); if (regions && (flags & EXPORT_REGIONS)) { + char id[32]; region * r; + plane * p; + cJSON_AddItemToObject(root, "planes", json = cJSON_CreateObject()); + for (p=planes;p;p=p->next) { + cJSON *data; + _snprintf(id, sizeof(id), "%u", p->id); + cJSON_AddItemToObject(json, id, data = cJSON_CreateObject()); + cJSON_AddNumberToObject(data, "x", p->minx); + cJSON_AddNumberToObject(data, "y", p->miny); + cJSON_AddNumberToObject(data, "width", p->maxx-p->minx); + cJSON_AddNumberToObject(data, "height", p->maxy-p->miny); + cJSON_AddStringToObject(data, "name", p->name); + } + cJSON_AddItemToObject(root, "regions", json = cJSON_CreateObject()); for (r = regions; r; r = r->next) { - char id[32]; cJSON *data; _snprintf(id, sizeof(id), "%u", r->uid); cJSON_AddItemToObject(json, id, data = cJSON_CreateObject()); diff --git a/src/json_test.c b/src/json_test.c index c2706f79f..7c1027596 100644 --- a/src/json_test.c +++ b/src/json_test.c @@ -63,10 +63,10 @@ static cJSON *export_a_region(CuTest * tc, const struct terrain_type *terrain, r json = cJSON_Parse(buf); CuAssertPtrNotNull(tc, json); CuAssertIntEquals(tc, cJSON_Object, json->type); - json = json->child; - CuAssertPtrEquals(tc, 0, json->next); + CuAssertPtrEquals(tc, 0, cJSON_GetObjectItem(json, "factions")); + CuAssertPtrEquals(tc, 0, cJSON_GetObjectItem(json, "units")); + CuAssertPtrNotNull(tc, json = cJSON_GetObjectItem(json, "regions")); CuAssertIntEquals(tc, cJSON_Object, json->type); - CuAssertStrEquals(tc, "regions", json->string); json = json->child; CuAssertIntEquals(tc, r->uid, atoi(json->string)); CuAssertPtrNotNull(tc, attr = cJSON_GetObjectItem(json, "x")); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index d2a47054a..9652d4201 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -2355,7 +2355,7 @@ static int parse_main(xmlDocPtr doc) } } if (k == MAXKEYWORDS) { - log_error("trying to disable unknown comand %s\n", (const char *)propName); + log_error("trying to disable unknown command %s\n", (const char *)propName); } } xmlFree(propName); diff --git a/src/modules/autoseed.c b/src/modules/autoseed.c index cc0d0752c..862bd5768 100644 --- a/src/modules/autoseed.c +++ b/src/modules/autoseed.c @@ -922,6 +922,8 @@ static void oceans_around(region * r, region * rn[]) } } +#define SWAP_INTS(a, b) { a^=b; b^=a; a^=b; } + static void smooth_island(region_list * island) { region *rn[MAXDIRECTIONS]; diff --git a/src/util/goodies.h b/src/util/goodies.h index 39bf6a54c..b774bbb04 100644 --- a/src/util/goodies.h +++ b/src/util/goodies.h @@ -53,7 +53,6 @@ extern "C" { #define HASH1 JENKINS_HASH1 #define HASH2 JENKINS_HASH2 -#define SWAP_INTS(a, b) { a^=b; b^=a; a^=b; } #ifdef __cplusplus } #endif