define core plain and ocean in JSON for E2.

This commit is contained in:
Enno Rehling 2015-09-11 12:52:18 +02:00
parent a582c69523
commit 9df5799efd
2 changed files with 62 additions and 15 deletions

View File

@ -2,6 +2,47 @@
"include": [ "include": [
"keywords.json" "keywords.json"
], ],
"terrains": {
"ocean": {
"size": 100,
"flags": [ "swim", "sea", "sail", "fly" ]
},
"plain": {
"size": 10000,
"herbs": [ "h0", "h1", "h2", "h3", "h4", "h5" ],
"seed": 3,
"road": 50,
"flags": [ "land", "walk", "sail", "fly" ],
"production": {
"iron": {
"chance": 0.1,
"base": "5d8",
"div": "2d20+10",
"level": "2d4-1"
},
"stone": {
"chance": 0.15,
"base": "5d8",
"div": "2d30+20",
"level": "1d4"
},
"laen": {
"chance": 0.01,
"base": "1d4",
"div": "2d20+50",
"level": "1d4"
}
}
},
"default": {
"size": 0,
"herbs": [],
"seed": 0,
"road": 0,
"flags": [ "land", "walk", "sail", "fly" ],
"production": {}
}
},
"settings": { "settings": {
"game.id": 2, "game.id": 2,
"game.name": "Eressea", "game.name": "Eressea",

View File

@ -229,16 +229,19 @@ static void json_terrain(cJSON *json, terrain_type *ter) {
case cJSON_Object: case cJSON_Object:
if (strcmp(child->string, "production") == 0) { if (strcmp(child->string, "production") == 0) {
cJSON *entry; cJSON *entry;
int n, size = cJSON_GetArraySize(child); int size = cJSON_GetArraySize(child);
ter->production = (terrain_production *)calloc(size + 1, sizeof(terrain_production)); if (size > 0) {
ter->production[size].type = 0; int n;
for (n = 0, entry = child->child; entry; entry = entry->next, ++n) { ter->production = (terrain_production *)calloc(size + 1, sizeof(terrain_production));
ter->production[n].type = rt_get_or_create(entry->string); ter->production[size].type = 0;
if (entry->type != cJSON_Object) { for (n = 0, entry = child->child; entry; entry = entry->next, ++n) {
log_error("terrain %s contains invalid production %s", json->string, entry->string); ter->production[n].type = rt_get_or_create(entry->string);
} if (entry->type != cJSON_Object) {
else { log_error("terrain %s contains invalid production %s", json->string, entry->string);
json_terrain_production(entry, ter->production + n); }
else {
json_terrain_production(entry, ter->production + n);
}
} }
} }
} }
@ -255,11 +258,14 @@ static void json_terrain(cJSON *json, terrain_type *ter) {
} }
else if (strcmp(child->string, "herbs") == 0) { else if (strcmp(child->string, "herbs") == 0) {
cJSON *entry; cJSON *entry;
int n, size = cJSON_GetArraySize(child); int size = cJSON_GetArraySize(child);
ter->herbs = malloc(sizeof(const item_type *) * (size+1)); if (size > 0) {
ter->herbs[size] = 0; int n;
for (n = 0, entry = child->child; entry; entry = entry->next) { ter->herbs = malloc(sizeof(const item_type *) * (size + 1));
ter->herbs[n++] = it_get_or_create(rt_get_or_create(entry->valuestring)); ter->herbs[size] = 0;
for (n = 0, entry = child->child; entry; entry = entry->next) {
ter->herbs[n++] = it_get_or_create(rt_get_or_create(entry->valuestring));
}
} }
} }
else { else {