Simplified mission loading (merged fighterGroup in to fighters, etc.)
This commit is contained in:
parent
5c20693933
commit
d444b0ab68
|
@ -19,7 +19,7 @@
|
|||
"pilot" : "Curtis Rice",
|
||||
"squadron" : "Eightballers"
|
||||
},
|
||||
"fighterGroups" : [
|
||||
"fighters" : [
|
||||
{
|
||||
"name" : "Ally",
|
||||
"types" : "Firefly;Nymph",
|
||||
|
@ -30,7 +30,7 @@
|
|||
"scatter" : 64
|
||||
}
|
||||
],
|
||||
"entityGroups" : [
|
||||
"entities" : [
|
||||
{
|
||||
"type" : "ET_WAYPOINT",
|
||||
"number" : 5,
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
"pilot" : "Curtis Rice",
|
||||
"squadron" : "Eightballers"
|
||||
},
|
||||
"fighterGroups" : [
|
||||
"fighters" : [
|
||||
{
|
||||
"name" : "Ally",
|
||||
"types" : "Firefly;Nymph",
|
||||
|
@ -63,7 +63,7 @@
|
|||
"active" : 0
|
||||
}
|
||||
],
|
||||
"entityGroups" : [
|
||||
"entities" : [
|
||||
{
|
||||
"type" : "ET_WAYPOINT",
|
||||
"number" : 5,
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
"pilot" : "(Multiple)",
|
||||
"squadron" : "(Multiple)"
|
||||
},
|
||||
"fighterGroups" : [
|
||||
"fighters" : [
|
||||
{
|
||||
"name" : "ALLIES",
|
||||
"types" : "Firefly;Nymph;Leopard;Hyena-A;Hyena-B",
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
"pilot" : "Simon Dodds",
|
||||
"squadron" : "White Knights"
|
||||
},
|
||||
"fighterGroups" : [
|
||||
"fighters" : [
|
||||
{
|
||||
"name" : "ATAF",
|
||||
"types" : "ATAF",
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
"pilot" : "(Multiple)",
|
||||
"squadron" : "(Multiple)"
|
||||
},
|
||||
"fighterGroups" : [
|
||||
"fighters" : [
|
||||
{
|
||||
"name" : "ALLIES",
|
||||
"types" : "Firefly;Nymph;TAF;Ray;Leopard;Hyena-A;Hyena-B;Kingfisher",
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
"pilot" : "(Multiple)",
|
||||
"squadron" : "(Multiple)"
|
||||
},
|
||||
"fighterGroups" : [
|
||||
"fighters" : [
|
||||
{
|
||||
"name" : "ALLIES",
|
||||
"types" : "Firefly;Nymph;TAF;Ray;Leopard;Hyena-A;Hyena-B;Kingfisher",
|
||||
|
|
|
@ -22,20 +22,20 @@
|
|||
"fighters" : [
|
||||
{
|
||||
"name" : "Ally",
|
||||
"type" : "TAF",
|
||||
"types" : "TAF",
|
||||
"side" : "SIDE_ALLIES",
|
||||
"x" : 25.1,
|
||||
"y" : 25
|
||||
},
|
||||
{
|
||||
"name" : "Ally",
|
||||
"type" : "Shuttle",
|
||||
"types" : "Shuttle",
|
||||
"side" : "SIDE_ALLIES",
|
||||
"x" : 24.9,
|
||||
"y" : 25
|
||||
}
|
||||
],
|
||||
"itemGroups" : [
|
||||
"items" : [
|
||||
{
|
||||
"name" : "package",
|
||||
"number" : 6,
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
"fighters" : [
|
||||
{
|
||||
"name" : "Scarab",
|
||||
"type" : "Scarab",
|
||||
"types" : "Scarab",
|
||||
"side" : "SIDE_PANDORAN",
|
||||
"x" : 27,
|
||||
"y" : 35,
|
||||
|
@ -38,7 +38,7 @@
|
|||
},
|
||||
{
|
||||
"name" : "Scarab",
|
||||
"type" : "Scarab",
|
||||
"types" : "Scarab",
|
||||
"side" : "SIDE_PANDORAN",
|
||||
"x" : 20,
|
||||
"y" : 30,
|
||||
|
@ -46,14 +46,12 @@
|
|||
},
|
||||
{
|
||||
"name" : "Scarab",
|
||||
"type" : "Scarab",
|
||||
"types" : "Scarab",
|
||||
"side" : "SIDE_PANDORAN",
|
||||
"x" : 35,
|
||||
"y" : 25,
|
||||
"flags" : "EF_MISSION_TARGET"
|
||||
}
|
||||
],
|
||||
"fighterGroups" : [
|
||||
},
|
||||
{
|
||||
"name" : "ALLIES",
|
||||
"types" : "Firefly;Nymph;Leopard",
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
"pilot" : "(Multiple)",
|
||||
"squadron" : "(Multiple)"
|
||||
},
|
||||
"fighterGroups" : [
|
||||
"fighters" : [
|
||||
{
|
||||
"name" : "ALLIES",
|
||||
"types" : "Firefly;Nymph",
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
"fighters" : [
|
||||
{
|
||||
"name" : "Dart",
|
||||
"type" : "StaticDart",
|
||||
"types" : "StaticDart",
|
||||
"side" : "SIDE_PIRATE",
|
||||
"x" : 25.5,
|
||||
"y" : 24.5
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
"fighters" : [
|
||||
{
|
||||
"name" : "Dart",
|
||||
"type" : "UnarmedDart",
|
||||
"types" : "UnarmedDart",
|
||||
"side" : "SIDE_PIRATE",
|
||||
"x" : 25,
|
||||
"y" : 24
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
"fighters" : [
|
||||
{
|
||||
"name" : "Dart",
|
||||
"type" : "SimpleDart",
|
||||
"types" : "SimpleDart",
|
||||
"side" : "SIDE_PIRATE",
|
||||
"x" : 25,
|
||||
"y" : 24
|
||||
|
|
|
@ -21,20 +21,18 @@
|
|||
"fighters" : [
|
||||
{
|
||||
"name" : "TAF",
|
||||
"type" : "TAF",
|
||||
"types" : "TAF",
|
||||
"side" : "SIDE_ALLIES",
|
||||
"x" : 24.9,
|
||||
"y" : 25.5
|
||||
},
|
||||
{
|
||||
"name" : "TAF",
|
||||
"type" : "TAF",
|
||||
"types" : "TAF",
|
||||
"side" : "SIDE_ALLIES",
|
||||
"x" : 25.1,
|
||||
"y" : 25.5
|
||||
}
|
||||
],
|
||||
"fighterGroups" : [
|
||||
},
|
||||
{
|
||||
"name" : "Dart",
|
||||
"types" : "SimpleDart",
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
"pilot" : "Jim Goddard",
|
||||
"squadron" : "Midnight Runners"
|
||||
},
|
||||
"fighterGroups" : [
|
||||
"fighters" : [
|
||||
{
|
||||
"name" : "Dart",
|
||||
"types" : "SimpleDart",
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
"pilot" : "Katherine Strickland",
|
||||
"squadron" : "Steel Bulls"
|
||||
},
|
||||
"fighterGroups" : [
|
||||
"fighters" : [
|
||||
{
|
||||
"name" : "Ally",
|
||||
"types" : "TAF",
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
"pilot" : "Katherine Strickland",
|
||||
"squadron" : "Steel Bulls"
|
||||
},
|
||||
"fighterGroups" : [
|
||||
"fighters" : [
|
||||
{
|
||||
"name" : "Ally",
|
||||
"types" : "TAF",
|
||||
|
|
|
@ -52,15 +52,13 @@
|
|||
"fighters" : [
|
||||
{
|
||||
"name" : "Pirate Lieutenant",
|
||||
"type" : "Dart",
|
||||
"types" : "Dart",
|
||||
"side" : "SIDE_PIRATE",
|
||||
"x" : 12,
|
||||
"y" : 25,
|
||||
"flags" : "EF_NO_KILL+EF_MUST_DISABLE+EF_MISSION_TARGET",
|
||||
"aiFlags" : "AIF_RETREATS"
|
||||
}
|
||||
],
|
||||
"fighterGroups" : [
|
||||
},
|
||||
{
|
||||
"name" : "Ally",
|
||||
"types" : "TAF",
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
{
|
||||
"description" : "Destroy all remaining opposition",
|
||||
"targetName" : "Dart",
|
||||
"targetValue" : 30,
|
||||
"targetValue" : 26,
|
||||
"targetType" : "TT_DESTROY"
|
||||
},
|
||||
{
|
||||
|
@ -34,7 +34,7 @@
|
|||
"x" : 10,
|
||||
"y" : 25
|
||||
},
|
||||
"fighterGroups" : [
|
||||
"fighters" : [
|
||||
{
|
||||
"name" : "Ally",
|
||||
"types" : "TAF;Ray",
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
"type" : "Firefly",
|
||||
"side" : "SIDE_ALLIES"
|
||||
},
|
||||
"fighterGroups" : [
|
||||
"fighters" : [
|
||||
{
|
||||
"name" : "Ally",
|
||||
"number" : 3,
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
"type" : "Firefly",
|
||||
"side" : "SIDE_ALLIES"
|
||||
},
|
||||
"fighterGroups" : [
|
||||
"fighters" : [
|
||||
{
|
||||
"name" : "Ally",
|
||||
"number" : 3,
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
"fighters" : [
|
||||
{
|
||||
"name" : "Civilian",
|
||||
"type" : "Civilian",
|
||||
"types" : "Civilian",
|
||||
"side" : "SIDE_ALLIES",
|
||||
"x" : 18,
|
||||
"y" : 26,
|
||||
|
@ -37,7 +37,7 @@
|
|||
},
|
||||
{
|
||||
"name" : "Civilian",
|
||||
"type" : "Civilian",
|
||||
"types" : "Civilian",
|
||||
"side" : "SIDE_ALLIES",
|
||||
"x" : 28,
|
||||
"y" : 20,
|
||||
|
@ -45,7 +45,7 @@
|
|||
},
|
||||
{
|
||||
"name" : "Civilian",
|
||||
"type" : "Civilian",
|
||||
"types" : "Civilian",
|
||||
"side" : "SIDE_ALLIES",
|
||||
"x" : 37,
|
||||
"y" : 22,
|
||||
|
@ -53,14 +53,12 @@
|
|||
},
|
||||
{
|
||||
"name" : "Civilian",
|
||||
"type" : "Civilian",
|
||||
"types" : "Civilian",
|
||||
"side" : "SIDE_ALLIES",
|
||||
"x" : 32,
|
||||
"y" : 32,
|
||||
"flags" : "EF_DISABLED+EF_NO_KILL+EF_MISSION_TARGET"
|
||||
}
|
||||
],
|
||||
"fighterGroups" : [
|
||||
},
|
||||
{
|
||||
"name" : "Ally",
|
||||
"number" : 3,
|
||||
|
|
|
@ -24,11 +24,8 @@ static void loadObjectives(cJSON *node);
|
|||
static void loadTriggers(cJSON *node);
|
||||
static void loadPlayer(cJSON *node);
|
||||
static void loadFighters(cJSON *node);
|
||||
static void loadFighterGroups(cJSON *node);
|
||||
static void loadEntities(cJSON *node);
|
||||
static void loadEntityGroups(cJSON *node);
|
||||
static void loadItems(cJSON *node);
|
||||
static void loadItemGroups(cJSON *node);
|
||||
static unsigned long hashcode(const char *str);
|
||||
static char **toFighterTypeArray(char *types, int *numTypes);
|
||||
static void loadEpicData(cJSON *node);
|
||||
|
@ -61,16 +58,10 @@ void loadMission(char *filename)
|
|||
|
||||
loadFighters(cJSON_GetObjectItem(root, "fighters"));
|
||||
|
||||
loadFighterGroups(cJSON_GetObjectItem(root, "fighterGroups"));
|
||||
|
||||
loadEntities(cJSON_GetObjectItem(root, "entities"));
|
||||
|
||||
loadEntityGroups(cJSON_GetObjectItem(root, "entityGroups"));
|
||||
|
||||
loadItems(cJSON_GetObjectItem(root, "items"));
|
||||
|
||||
loadItemGroups(cJSON_GetObjectItem(root, "itemGroups"));
|
||||
|
||||
STRNCPY(music, cJSON_GetObjectItem(root, "music")->valuestring, MAX_NAME_LENGTH);
|
||||
|
||||
if (cJSON_GetObjectItem(root, "epic"))
|
||||
|
@ -233,48 +224,6 @@ static void loadPlayer(cJSON *node)
|
|||
}
|
||||
|
||||
static void loadFighters(cJSON *node)
|
||||
{
|
||||
Entity *f;
|
||||
char *type;
|
||||
int side;
|
||||
float x, y;
|
||||
|
||||
if (node)
|
||||
{
|
||||
node = node->child;
|
||||
|
||||
while (node)
|
||||
{
|
||||
type = cJSON_GetObjectItem(node, "type")->valuestring;
|
||||
side = lookup(cJSON_GetObjectItem(node, "side")->valuestring);
|
||||
x = cJSON_GetObjectItem(node, "x")->valuedouble * GRID_CELL_WIDTH;
|
||||
y = cJSON_GetObjectItem(node, "y")->valuedouble * GRID_CELL_HEIGHT;
|
||||
|
||||
f = spawnFighter(type, x, y, side);
|
||||
|
||||
STRNCPY(f->name, cJSON_GetObjectItem(node, "name")->valuestring, MAX_NAME_LENGTH);
|
||||
|
||||
if (cJSON_GetObjectItem(node, "flags"))
|
||||
{
|
||||
f->flags = flagsToLong(cJSON_GetObjectItem(node, "flags")->valuestring);
|
||||
}
|
||||
|
||||
if (cJSON_GetObjectItem(node, "aiFlags"))
|
||||
{
|
||||
f->aiFlags = flagsToLong(cJSON_GetObjectItem(node, "aiFlags")->valuestring);
|
||||
}
|
||||
|
||||
if (cJSON_GetObjectItem(node, "active"))
|
||||
{
|
||||
f->active = cJSON_GetObjectItem(node, "active")->valueint;
|
||||
}
|
||||
|
||||
node = node->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void loadFighterGroups(cJSON *node)
|
||||
{
|
||||
Entity *f;
|
||||
char **types, *name, *groupName, *type;
|
||||
|
@ -283,9 +232,6 @@ static void loadFighterGroups(cJSON *node)
|
|||
long flags;
|
||||
float x, y;
|
||||
|
||||
scatter = 1;
|
||||
active = 1;
|
||||
|
||||
if (node)
|
||||
{
|
||||
node = node->child;
|
||||
|
@ -294,10 +240,12 @@ static void loadFighterGroups(cJSON *node)
|
|||
{
|
||||
groupName = NULL;
|
||||
flags = -1;
|
||||
scatter = 1;
|
||||
active = 1;
|
||||
number = 1;
|
||||
|
||||
types = toFighterTypeArray(cJSON_GetObjectItem(node, "types")->valuestring, &numTypes);
|
||||
side = lookup(cJSON_GetObjectItem(node, "side")->valuestring);
|
||||
number = cJSON_GetObjectItem(node, "number")->valueint;
|
||||
name = cJSON_GetObjectItem(node, "name")->valuestring;
|
||||
x = cJSON_GetObjectItem(node, "x")->valuedouble * GRID_CELL_WIDTH;
|
||||
y = cJSON_GetObjectItem(node, "y")->valuedouble * GRID_CELL_HEIGHT;
|
||||
|
@ -307,6 +255,11 @@ static void loadFighterGroups(cJSON *node)
|
|||
groupName = cJSON_GetObjectItem(node, "groupName")->valuestring;
|
||||
}
|
||||
|
||||
if (cJSON_GetObjectItem(node, "number"))
|
||||
{
|
||||
number = cJSON_GetObjectItem(node, "number")->valueint;
|
||||
}
|
||||
|
||||
if (cJSON_GetObjectItem(node, "scatter"))
|
||||
{
|
||||
scatter = cJSON_GetObjectItem(node, "scatter")->valueint;
|
||||
|
@ -354,55 +307,6 @@ static void loadFighterGroups(cJSON *node)
|
|||
}
|
||||
|
||||
static void loadEntities(cJSON *node)
|
||||
{
|
||||
Entity *e;
|
||||
int type;
|
||||
|
||||
if (node)
|
||||
{
|
||||
node = node->child;
|
||||
|
||||
while (node)
|
||||
{
|
||||
type = lookup(cJSON_GetObjectItem(node, "type")->valuestring);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case ET_WAYPOINT:
|
||||
e = spawnWaypoint();
|
||||
break;
|
||||
|
||||
case ET_EXTRACTION_POINT:
|
||||
e = spawnExtractionPoint();
|
||||
break;
|
||||
}
|
||||
|
||||
if (cJSON_GetObjectItem(node, "name"))
|
||||
{
|
||||
STRNCPY(e->name, cJSON_GetObjectItem(node, "name")->valuestring, MAX_NAME_LENGTH);
|
||||
}
|
||||
|
||||
e->x = cJSON_GetObjectItem(node, "x")->valuedouble * GRID_CELL_WIDTH;
|
||||
e->y = cJSON_GetObjectItem(node, "y")->valuedouble * GRID_CELL_HEIGHT;
|
||||
|
||||
if (cJSON_GetObjectItem(node, "active"))
|
||||
{
|
||||
e->active = cJSON_GetObjectItem(node, "active")->valueint;
|
||||
}
|
||||
|
||||
if (cJSON_GetObjectItem(node, "flags"))
|
||||
{
|
||||
e->flags = flagsToLong(cJSON_GetObjectItem(node, "flags")->valuestring);
|
||||
}
|
||||
|
||||
SDL_QueryTexture(e->texture, NULL, NULL, &e->w, &e->h);
|
||||
|
||||
node = node->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void loadEntityGroups(cJSON *node)
|
||||
{
|
||||
Entity *e;
|
||||
char *name, *groupName;
|
||||
|
@ -417,12 +321,13 @@ static void loadEntityGroups(cJSON *node)
|
|||
|
||||
while (node)
|
||||
{
|
||||
e = NULL;
|
||||
type = lookup(cJSON_GetObjectItem(node, "type")->valuestring);
|
||||
number = cJSON_GetObjectItem(node, "number")->valueint;
|
||||
x = cJSON_GetObjectItem(node, "x")->valuedouble * GRID_CELL_WIDTH;
|
||||
y = cJSON_GetObjectItem(node, "y")->valuedouble * GRID_CELL_HEIGHT;
|
||||
name = NULL;
|
||||
groupName = NULL;
|
||||
number = 1;
|
||||
|
||||
if (cJSON_GetObjectItem(node, "name"))
|
||||
{
|
||||
|
@ -434,6 +339,11 @@ static void loadEntityGroups(cJSON *node)
|
|||
groupName = cJSON_GetObjectItem(node, "groupName")->valuestring;
|
||||
}
|
||||
|
||||
if (cJSON_GetObjectItem(node, "number"))
|
||||
{
|
||||
number = cJSON_GetObjectItem(node, "number")->valueint;
|
||||
}
|
||||
|
||||
if (cJSON_GetObjectItem(node, "scatter"))
|
||||
{
|
||||
scatter = cJSON_GetObjectItem(node, "scatter")->valueint;
|
||||
|
@ -446,6 +356,15 @@ static void loadEntityGroups(cJSON *node)
|
|||
case ET_WAYPOINT:
|
||||
e = spawnWaypoint();
|
||||
break;
|
||||
|
||||
case ET_EXTRACTION_POINT:
|
||||
e = spawnExtractionPoint();
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Error: Unhandled entity type: %s\n", cJSON_GetObjectItem(node, "type")->valuestring);
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (name)
|
||||
|
@ -473,14 +392,10 @@ static void loadEntityGroups(cJSON *node)
|
|||
}
|
||||
|
||||
static void loadItems(cJSON *node)
|
||||
{
|
||||
}
|
||||
|
||||
static void loadItemGroups(cJSON *node)
|
||||
{
|
||||
Entity *e;
|
||||
char *name, *groupName, *type;
|
||||
int i, scatter, number;
|
||||
int i, scatter, number, active;
|
||||
long flags;
|
||||
float x, y;
|
||||
|
||||
|
@ -494,11 +409,12 @@ static void loadItemGroups(cJSON *node)
|
|||
while (node)
|
||||
{
|
||||
type = cJSON_GetObjectItem(node, "type")->valuestring;
|
||||
number = cJSON_GetObjectItem(node, "number")->valueint;
|
||||
x = cJSON_GetObjectItem(node, "x")->valuedouble * GRID_CELL_WIDTH;
|
||||
y = cJSON_GetObjectItem(node, "y")->valuedouble * GRID_CELL_HEIGHT;
|
||||
name = NULL;
|
||||
groupName = NULL;
|
||||
number = 1;
|
||||
active = 1;
|
||||
|
||||
if (cJSON_GetObjectItem(node, "name"))
|
||||
{
|
||||
|
@ -510,6 +426,11 @@ static void loadItemGroups(cJSON *node)
|
|||
groupName = cJSON_GetObjectItem(node, "groupName")->valuestring;
|
||||
}
|
||||
|
||||
if (cJSON_GetObjectItem(node, "number"))
|
||||
{
|
||||
number = cJSON_GetObjectItem(node, "number")->valueint;
|
||||
}
|
||||
|
||||
if (cJSON_GetObjectItem(node, "scatter"))
|
||||
{
|
||||
scatter = cJSON_GetObjectItem(node, "scatter")->valueint;
|
||||
|
@ -520,6 +441,11 @@ static void loadItemGroups(cJSON *node)
|
|||
flags = flagsToLong(cJSON_GetObjectItem(node, "flags")->valuestring);
|
||||
}
|
||||
|
||||
if (cJSON_GetObjectItem(node, "active"))
|
||||
{
|
||||
active = cJSON_GetObjectItem(node, "active")->valueint;
|
||||
}
|
||||
|
||||
for (i = 0 ; i < number ; i++)
|
||||
{
|
||||
e = spawnItem(type);
|
||||
|
@ -541,6 +467,7 @@ static void loadItemGroups(cJSON *node)
|
|||
|
||||
e->x = x;
|
||||
e->y = y;
|
||||
e->active = active;
|
||||
|
||||
e->x += (rand() % scatter) - (rand() % scatter);
|
||||
e->y += (rand() % scatter) - (rand() % scatter);
|
||||
|
|
Loading…
Reference in New Issue