diff --git a/data/missions/alba/01 - patrol #1.json b/data/missions/alba/01 - patrol #1.json index eb96ccf..f4c471a 100644 --- a/data/missions/alba/01 - patrol #1.json +++ b/data/missions/alba/01 - patrol #1.json @@ -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, diff --git a/data/missions/alba/02 - patrol #2.json b/data/missions/alba/02 - patrol #2.json index 352b6f2..813c74c 100644 --- a/data/missions/alba/02 - patrol #2.json +++ b/data/missions/alba/02 - patrol #2.json @@ -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, diff --git a/data/missions/clarke/01 - clarke defence #1.json b/data/missions/clarke/01 - clarke defence #1.json index 39b0db7..65d8c79 100644 --- a/data/missions/clarke/01 - clarke defence #1.json +++ b/data/missions/clarke/01 - clarke defence #1.json @@ -22,7 +22,7 @@ "pilot" : "(Multiple)", "squadron" : "(Multiple)" }, - "fighterGroups" : [ + "fighters" : [ { "name" : "ALLIES", "types" : "Firefly;Nymph;Leopard;Hyena-A;Hyena-B", diff --git a/data/missions/coyote/01 - coyote assault #1.json b/data/missions/coyote/01 - coyote assault #1.json index c51c68b..9991626 100644 --- a/data/missions/coyote/01 - coyote assault #1.json +++ b/data/missions/coyote/01 - coyote assault #1.json @@ -26,7 +26,7 @@ "pilot" : "Simon Dodds", "squadron" : "White Knights" }, - "fighterGroups" : [ + "fighters" : [ { "name" : "ATAF", "types" : "ATAF", diff --git a/data/missions/coyote/02 - coyote assault #2.json b/data/missions/coyote/02 - coyote assault #2.json index a34190f..6b1f5e7 100644 --- a/data/missions/coyote/02 - coyote assault #2.json +++ b/data/missions/coyote/02 - coyote assault #2.json @@ -22,7 +22,7 @@ "pilot" : "(Multiple)", "squadron" : "(Multiple)" }, - "fighterGroups" : [ + "fighters" : [ { "name" : "ALLIES", "types" : "Firefly;Nymph;TAF;Ray;Leopard;Hyena-A;Hyena-B;Kingfisher", diff --git a/data/missions/coyote/03 - coyote assault #3.json b/data/missions/coyote/03 - coyote assault #3.json index fdfef50..f6defe2 100644 --- a/data/missions/coyote/03 - coyote assault #3.json +++ b/data/missions/coyote/03 - coyote assault #3.json @@ -59,7 +59,7 @@ "pilot" : "(Multiple)", "squadron" : "(Multiple)" }, - "fighterGroups" : [ + "fighters" : [ { "name" : "ALLIES", "types" : "Firefly;Nymph;TAF;Ray;Leopard;Hyena-A;Hyena-B;Kingfisher", diff --git a/data/missions/granada/01 - suspect packages #1.json b/data/missions/granada/01 - suspect packages #1.json index 0df212f..dc3a0f4 100644 --- a/data/missions/granada/01 - suspect packages #1.json +++ b/data/missions/granada/01 - suspect packages #1.json @@ -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, diff --git a/data/missions/iliad/01 - iliad defence #1.json b/data/missions/iliad/01 - iliad defence #1.json index 09c772a..8127275 100644 --- a/data/missions/iliad/01 - iliad defence #1.json +++ b/data/missions/iliad/01 - iliad defence #1.json @@ -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", diff --git a/data/missions/iliad/02 - iliad defence #2.json b/data/missions/iliad/02 - iliad defence #2.json index 537331b..0772595 100644 --- a/data/missions/iliad/02 - iliad defence #2.json +++ b/data/missions/iliad/02 - iliad defence #2.json @@ -22,7 +22,7 @@ "pilot" : "(Multiple)", "squadron" : "(Multiple)" }, - "fighterGroups" : [ + "fighters" : [ { "name" : "ALLIES", "types" : "Firefly;Nymph", diff --git a/data/missions/sol/02 - weapons.json b/data/missions/sol/02 - weapons.json index 1bb3c8c..0df0d3e 100644 --- a/data/missions/sol/02 - weapons.json +++ b/data/missions/sol/02 - weapons.json @@ -21,7 +21,7 @@ "fighters" : [ { "name" : "Dart", - "type" : "StaticDart", + "types" : "StaticDart", "side" : "SIDE_PIRATE", "x" : 25.5, "y" : 24.5 diff --git a/data/missions/sol/03 - moving target.json b/data/missions/sol/03 - moving target.json index 8a759c9..8c71f15 100644 --- a/data/missions/sol/03 - moving target.json +++ b/data/missions/sol/03 - moving target.json @@ -21,7 +21,7 @@ "fighters" : [ { "name" : "Dart", - "type" : "UnarmedDart", + "types" : "UnarmedDart", "side" : "SIDE_PIRATE", "x" : 25, "y" : 24 diff --git a/data/missions/sol/04 - real target.json b/data/missions/sol/04 - real target.json index 9a3edba..e3834cd 100644 --- a/data/missions/sol/04 - real target.json +++ b/data/missions/sol/04 - real target.json @@ -21,7 +21,7 @@ "fighters" : [ { "name" : "Dart", - "type" : "SimpleDart", + "types" : "SimpleDart", "side" : "SIDE_PIRATE", "x" : 25, "y" : 24 diff --git a/data/missions/sol/05 - wingmates.json b/data/missions/sol/05 - wingmates.json index d42a4e4..63bcb60 100644 --- a/data/missions/sol/05 - wingmates.json +++ b/data/missions/sol/05 - wingmates.json @@ -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", diff --git a/data/missions/sol/06 - final.json b/data/missions/sol/06 - final.json index a551d25..6d645a5 100644 --- a/data/missions/sol/06 - final.json +++ b/data/missions/sol/06 - final.json @@ -32,7 +32,7 @@ "pilot" : "Jim Goddard", "squadron" : "Midnight Runners" }, - "fighterGroups" : [ + "fighters" : [ { "name" : "Dart", "types" : "SimpleDart", diff --git a/data/missions/temper/01 - pirate uprising #1.json b/data/missions/temper/01 - pirate uprising #1.json index fa71c07..26fa408 100644 --- a/data/missions/temper/01 - pirate uprising #1.json +++ b/data/missions/temper/01 - pirate uprising #1.json @@ -32,7 +32,7 @@ "pilot" : "Katherine Strickland", "squadron" : "Steel Bulls" }, - "fighterGroups" : [ + "fighters" : [ { "name" : "Ally", "types" : "TAF", diff --git a/data/missions/temper/02 - pirate uprising #2.json b/data/missions/temper/02 - pirate uprising #2.json index bde76a5..3bde788 100644 --- a/data/missions/temper/02 - pirate uprising #2.json +++ b/data/missions/temper/02 - pirate uprising #2.json @@ -33,7 +33,7 @@ "pilot" : "Katherine Strickland", "squadron" : "Steel Bulls" }, - "fighterGroups" : [ + "fighters" : [ { "name" : "Ally", "types" : "TAF", diff --git a/data/missions/temper/03 - pirate uprising #3.json b/data/missions/temper/03 - pirate uprising #3.json index 2f5a34a..a0a31b4 100644 --- a/data/missions/temper/03 - pirate uprising #3.json +++ b/data/missions/temper/03 - pirate uprising #3.json @@ -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", diff --git a/data/missions/temper/04 - pirate uprising #4.json b/data/missions/temper/04 - pirate uprising #4.json index 9f992f3..ab82529 100644 --- a/data/missions/temper/04 - pirate uprising #4.json +++ b/data/missions/temper/04 - pirate uprising #4.json @@ -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", diff --git a/data/missions/warro/01 - evacuation #1.json b/data/missions/warro/01 - evacuation #1.json index 2e62764..b5cfe1d 100644 --- a/data/missions/warro/01 - evacuation #1.json +++ b/data/missions/warro/01 - evacuation #1.json @@ -18,7 +18,7 @@ "type" : "Firefly", "side" : "SIDE_ALLIES" }, - "fighterGroups" : [ + "fighters" : [ { "name" : "Ally", "number" : 3, diff --git a/data/missions/warro/02 - evacuation #2.json b/data/missions/warro/02 - evacuation #2.json index a31d4fe..10ae43a 100644 --- a/data/missions/warro/02 - evacuation #2.json +++ b/data/missions/warro/02 - evacuation #2.json @@ -26,7 +26,7 @@ "type" : "Firefly", "side" : "SIDE_ALLIES" }, - "fighterGroups" : [ + "fighters" : [ { "name" : "Ally", "number" : 3, diff --git a/data/missions/warro/03 - evacuation #3.json b/data/missions/warro/03 - evacuation #3.json index 8b18d71..be75f26 100644 --- a/data/missions/warro/03 - evacuation #3.json +++ b/data/missions/warro/03 - evacuation #3.json @@ -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, diff --git a/src/galaxy/mission.c b/src/galaxy/mission.c index c9354ea..82cee44 100644 --- a/src/galaxy/mission.c +++ b/src/galaxy/mission.c @@ -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);