forked from github/server
Merge pull request #301 from ennorehling/develop
fix terrains.json in E2
This commit is contained in:
commit
2dcd69cb46
|
@ -229,21 +229,21 @@
|
||||||
"production": {
|
"production": {
|
||||||
"iron": {
|
"iron": {
|
||||||
"chance": 0.5,
|
"chance": 0.5,
|
||||||
"level": 1,
|
"level": "1",
|
||||||
"base": 50,
|
"base": "50",
|
||||||
"div": 50
|
"div": "50"
|
||||||
},
|
},
|
||||||
"stone": {
|
"stone": {
|
||||||
"chance": 0.5,
|
"chance": 0.5,
|
||||||
"level": 1,
|
"level": "1",
|
||||||
"base": 100,
|
"base": "100",
|
||||||
"div": 100
|
"div": "100"
|
||||||
},
|
},
|
||||||
"laen": {
|
"laen": {
|
||||||
"chance": 0.075,
|
"chance": 0.075,
|
||||||
"level": 1,
|
"level": "1",
|
||||||
"base": 4,
|
"base": "4",
|
||||||
"div": 100
|
"div": "100"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -254,21 +254,21 @@
|
||||||
"production": {
|
"production": {
|
||||||
"iron": {
|
"iron": {
|
||||||
"chance": 0.5,
|
"chance": 0.5,
|
||||||
"level": 1,
|
"level": "1",
|
||||||
"base": 50,
|
"base": "50",
|
||||||
"div": 50
|
"div": "50"
|
||||||
},
|
},
|
||||||
"stone": {
|
"stone": {
|
||||||
"chance": 0.5,
|
"chance": 0.5,
|
||||||
"level": 1,
|
"level": "1",
|
||||||
"base": 100,
|
"base": "100",
|
||||||
"div": 100
|
"div": "100"
|
||||||
},
|
},
|
||||||
"laen": {
|
"laen": {
|
||||||
"chance": 0.075,
|
"chance": 0.075,
|
||||||
"level": 1,
|
"level": "1",
|
||||||
"base": 4,
|
"base": "4",
|
||||||
"div": 100
|
"div": "100"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -192,32 +192,38 @@ static void json_terrain_production(cJSON *json, terrain_production *prod) {
|
||||||
assert(json->type == cJSON_Object);
|
assert(json->type == cJSON_Object);
|
||||||
cJSON *child;
|
cJSON *child;
|
||||||
for (child = json->child; child; child = child->next) {
|
for (child = json->child; child; child = child->next) {
|
||||||
|
char **dst = 0;
|
||||||
switch (child->type) {
|
switch (child->type) {
|
||||||
case cJSON_String:
|
|
||||||
if (strcmp(child->string, "base") == 0) {
|
|
||||||
prod->base = _strdup(child->valuestring);
|
|
||||||
}
|
|
||||||
else if (strcmp(child->string, "level") == 0) {
|
|
||||||
prod->startlevel = _strdup(child->valuestring);
|
|
||||||
}
|
|
||||||
else if (strcmp(child->string, "div") == 0) {
|
|
||||||
prod->divisor = _strdup(child->valuestring);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
log_error("terrain_production %s contains unknown attribute %s", json->string, child->string);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case cJSON_Number:
|
case cJSON_Number:
|
||||||
if (strcmp(child->string, "chance") == 0) {
|
if (strcmp(child->string, "chance") == 0) {
|
||||||
prod->chance = (float)child->valuedouble;
|
prod->chance = (float)child->valuedouble;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_error("terrain_production %s contains unknown attribute %s", json->string, child->string);
|
log_error("terrain_production %s contains unknown number %s", json->string, child->string);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case cJSON_String:
|
||||||
|
if (strcmp(child->string, "base") == 0) {
|
||||||
|
dst = &prod->base;
|
||||||
|
}
|
||||||
|
else if (strcmp(child->string, "level") == 0) {
|
||||||
|
dst = &prod->startlevel;
|
||||||
|
}
|
||||||
|
else if (strcmp(child->string, "div") == 0) {
|
||||||
|
dst = &prod->divisor;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log_error("terrain_production %s contains unknown string %s", json->string, child->string);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log_error("terrain_production %s contains unknown attribute %s", json->string, child->string);
|
log_error("terrain_production %s contains unknown attribute %s", json->string, child->string);
|
||||||
}
|
}
|
||||||
|
if (dst) {
|
||||||
|
free(*dst);
|
||||||
|
assert(child->type == cJSON_String);
|
||||||
|
*dst = _strdup(child->valuestring);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue