Made name option for fighters.

This commit is contained in:
Steve 2015-11-29 12:56:15 +00:00
parent a4dc4f3e05
commit 146bd1ef45
1 changed files with 10 additions and 2 deletions

View File

@ -206,6 +206,7 @@ static void loadFighters(cJSON *node)
while (node) while (node)
{ {
name = NULL;
groupName = NULL; groupName = NULL;
flags = -1; flags = -1;
scatter = 1; scatter = 1;
@ -214,10 +215,14 @@ static void loadFighters(cJSON *node)
types = toFighterTypeArray(cJSON_GetObjectItem(node, "types")->valuestring, &numTypes); types = toFighterTypeArray(cJSON_GetObjectItem(node, "types")->valuestring, &numTypes);
side = lookup(cJSON_GetObjectItem(node, "side")->valuestring); side = lookup(cJSON_GetObjectItem(node, "side")->valuestring);
name = cJSON_GetObjectItem(node, "name")->valuestring;
x = cJSON_GetObjectItem(node, "x")->valuedouble * GRID_CELL_WIDTH; x = cJSON_GetObjectItem(node, "x")->valuedouble * GRID_CELL_WIDTH;
y = cJSON_GetObjectItem(node, "y")->valuedouble * GRID_CELL_HEIGHT; y = cJSON_GetObjectItem(node, "y")->valuedouble * GRID_CELL_HEIGHT;
if (cJSON_GetObjectItem(node, "name"))
{
name = cJSON_GetObjectItem(node, "name")->valuestring;
}
if (cJSON_GetObjectItem(node, "groupName")) if (cJSON_GetObjectItem(node, "groupName"))
{ {
groupName = cJSON_GetObjectItem(node, "groupName")->valuestring; groupName = cJSON_GetObjectItem(node, "groupName")->valuestring;
@ -259,7 +264,10 @@ static void loadFighters(cJSON *node)
f->flags = flags; f->flags = flags;
} }
if (name)
{
STRNCPY(f->name, name, MAX_NAME_LENGTH); STRNCPY(f->name, name, MAX_NAME_LENGTH);
}
if (groupName) if (groupName)
{ {