Allow AI Flags to be set in mission data.

This commit is contained in:
Steve 2015-12-02 07:24:12 +00:00
parent b3c2313235
commit 26c4bd4aea
1 changed files with 12 additions and 1 deletions

View File

@ -199,7 +199,7 @@ static void loadFighters(cJSON *node)
char **types, *name, *groupName, *type; char **types, *name, *groupName, *type;
int side, scatter, number, active; int side, scatter, number, active;
int i, numTypes; int i, numTypes;
long flags; long flags, aiFlags;
float x, y; float x, y;
if (node) if (node)
@ -211,6 +211,7 @@ static void loadFighters(cJSON *node)
name = NULL; name = NULL;
groupName = NULL; groupName = NULL;
flags = -1; flags = -1;
aiFlags = -1;
scatter = 1; scatter = 1;
active = 1; active = 1;
number = 1; number = 1;
@ -250,6 +251,11 @@ static void loadFighters(cJSON *node)
flags = flagsToLong(cJSON_GetObjectItem(node, "flags")->valuestring); flags = flagsToLong(cJSON_GetObjectItem(node, "flags")->valuestring);
} }
if (cJSON_GetObjectItem(node, "aiFlags"))
{
aiFlags = flagsToLong(cJSON_GetObjectItem(node, "aiFlags")->valuestring);
}
for (i = 0 ; i < number ; i++) for (i = 0 ; i < number ; i++)
{ {
type = types[rand() % numTypes]; type = types[rand() % numTypes];
@ -266,6 +272,11 @@ static void loadFighters(cJSON *node)
f->flags = flags; f->flags = flags;
} }
if (aiFlags != -1)
{
f->aiFlags = aiFlags;
}
if (name) if (name)
{ {
STRNCPY(f->name, name, MAX_NAME_LENGTH); STRNCPY(f->name, name, MAX_NAME_LENGTH);