From 4ef796bf9235a915f0e95aa82d25cf7ef49a7f94 Mon Sep 17 00:00:00 2001 From: Steve Date: Wed, 16 Mar 2016 06:54:34 +0000 Subject: [PATCH] Added id to objective, to allow script to function in non-English languages. --- src/battle/objectives.c | 2 +- src/galaxy/mission.c | 5 +++-- src/structs.h | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/battle/objectives.c b/src/battle/objectives.c index c3d57a5..8fd3c39 100644 --- a/src/battle/objectives.c +++ b/src/battle/objectives.c @@ -205,7 +205,7 @@ void activateObjectives(char *objectives) { for (o = battle.objectiveHead.next ; o != NULL ; o = o->next) { - if (strcmp(token, o->description) == 0) + if (strcmp(token, o->id) == 0) { addHudMessage(colors.cyan, _("New Objective : %s"), o->description); o->active = 1; diff --git a/src/galaxy/mission.c b/src/galaxy/mission.c index 14844eb..88099cc 100644 --- a/src/galaxy/mission.c +++ b/src/galaxy/mission.c @@ -329,6 +329,7 @@ static void loadObjectives(cJSON *node) battle.objectiveTail->next = o; battle.objectiveTail = o; + STRNCPY(o->id, cJSON_GetObjectItem(node, "description")->valuestring, MAX_DESCRIPTION_LENGTH); STRNCPY(o->description, _(cJSON_GetObjectItem(node, "description")->valuestring), MAX_DESCRIPTION_LENGTH); STRNCPY(o->targetName, cJSON_GetObjectItem(node, "targetName")->valuestring, MAX_NAME_LENGTH); o->targetValue = cJSON_GetObjectItem(node, "targetValue")->valueint; @@ -793,8 +794,8 @@ static void loadSpawners(cJSON *node) s->types = toTypeArray(cJSON_GetObjectItem(node, "types")->valuestring, &s->numTypes); s->side = lookup(cJSON_GetObjectItem(node, "side")->valuestring); s->interval = cJSON_GetObjectItem(node, "interval")->valueint * FPS; - s->limit = cJSON_GetObjectItem(node, "limit")->valueint; - s->total = cJSON_GetObjectItem(node, "total")->valueint; + s->limit = getJSONValue(node, "limit", 0); + s->total = getJSONValue(node, "total", 0); s->step = cJSON_GetObjectItem(node, "step")->valueint; s->offscreen = getJSONValue(node, "offscreen", 0); s->active = active = getJSONValue(node, "active", 1); diff --git a/src/structs.h b/src/structs.h index 9bbc0f8..9ddee64 100644 --- a/src/structs.h +++ b/src/structs.h @@ -226,6 +226,7 @@ struct Location { struct Objective { int active; + char id[MAX_DESCRIPTION_LENGTH]; char description[MAX_DESCRIPTION_LENGTH]; char targetName[MAX_NAME_LENGTH]; int targetType;