diff --git a/src/cdogs.c b/src/cdogs.c index 3788777c1..90dff0457 100644 --- a/src/cdogs.c +++ b/src/cdogs.c @@ -611,7 +611,7 @@ static void CleanupMission(void) KillAllMobileObjects(&gMobObjList); KillAllObjects(); FreeTriggersAndWatches(); - gPlayer1 = gPlayer2 = gPrisoner = NULL; + gPlayer1 = gPlayer2 = NULL; } static void InitPlayers(int twoPlayers, int maxHealth, int mission) diff --git a/src/cdogs/actors.c b/src/cdogs/actors.c index 7c13ac919..b04ebc45b 100644 --- a/src/cdogs/actors.c +++ b/src/cdogs/actors.c @@ -73,7 +73,6 @@ TActor *gPlayer1 = NULL; TActor *gPlayer2 = NULL; -TActor *gPrisoner = NULL; TranslationTable tableFlamed; TranslationTable tableGreen; diff --git a/src/cdogs/actors.h b/src/cdogs/actors.h index 3bf27d529..0ed59e3bb 100644 --- a/src/cdogs/actors.h +++ b/src/cdogs/actors.h @@ -172,7 +172,6 @@ typedef struct Actor TActor; extern TActor *gPlayer1; extern TActor *gPlayer2; -extern TActor *gPrisoner; extern struct CharacterDescription gCharacterDesc[CHARACTER_COUNT]; diff --git a/src/cdogs/ai.c b/src/cdogs/ai.c index 8d74ea0c6..c539ea60f 100644 --- a/src/cdogs/ai.c +++ b/src/cdogs/ai.c @@ -661,20 +661,20 @@ void InitializeBadGuys(void) } for (i = 0; i < gMission.missionData->objectiveCount; i++) - if (gMission.missionData->objectives[i].type == - OBJECTIVE_RESCUE) { - if (!gPrisoner) { - gMission.objectives[i].count = 1; - gMission.objectives[i].required = 1; - gPrisoner = AddActor(CHARACTER_PRISONER); - gPrisoner->tileItem.flags |= ObjectiveToTileItem(i); + { + if (gMission.missionData->objectives[i].type == OBJECTIVE_RESCUE) + { + for (j = 0; j < gMission.objectives[i].count; j++) + { + actor = AddActor(CHARACTER_PRISONER); + actor->tileItem.flags |= ObjectiveToTileItem(i); if (HasLockedRooms()) { - PlacePrisoner(gPrisoner); + PlacePrisoner(actor); } else { - if (!TryPlaceBaddie(gPrisoner)) + if (!TryPlaceBaddie(actor)) { // Can't place prisoner when it's the objective // Fatal error, can't recover @@ -684,13 +684,8 @@ void InitializeBadGuys(void) } } } - else - { - // This is an error! - gMission.objectives[i].count = 0; - gMission.objectives[i].required = 0; - } } + } gBaddieCount = gMission.index * 4; gAreGoodGuysPresent = 0; diff --git a/src/cdogs/mission.c b/src/cdogs/mission.c index 1868bde63..79364e2df 100644 --- a/src/cdogs/mission.c +++ b/src/cdogs/mission.c @@ -975,6 +975,9 @@ int CanCompleteMission(struct MissionOptions *options) int IsMissionComplete(struct MissionOptions *options) { + int rescuesRequired = 0; + int i; + if (!CanCompleteMission(options)) { return 0; @@ -989,9 +992,34 @@ int IsMissionComplete(struct MissionOptions *options) { return 0; } - if (gPrisoner && !IsTileInExit(&gPrisoner->tileItem, options)) + // Find number of rescues required + // TODO: support multiple rescue objectives + for (i = 0; i < gMission.missionData->objectiveCount; i++) { - return 0; + if (gMission.missionData->objectives[i].type == OBJECTIVE_RESCUE) + { + rescuesRequired = gMission.objectives[i].required; + break; + } + } + // Check that enough prisoners are in exit zone + if (rescuesRequired > 0) + { + int prisonersRescued = 0; + TActor *a = ActorList(); + while (a != NULL) + { + if (a->character == CHARACTER_PRISONER && + IsTileInExit(&a->tileItem, options)) + { + prisonersRescued++; + } + a = a->next; + } + if (prisonersRescued < rescuesRequired) + { + return 0; + } } return 1; diff --git a/src/cdogsed.c b/src/cdogsed.c index 802035b24..7722a5c87 100644 --- a/src/cdogsed.c +++ b/src/cdogsed.c @@ -1472,9 +1472,9 @@ static void Save(int asCode) } c = KeyGetTyped(&gInputDevices.keyboard); if (c && c != '*' && - (strlen(filename) > 1 || c != '-') && c != '/' && + (strlen(filename) > 1 || c != '-') && c != ':' && c != '<' && c != '>' && c != '?' && - c != '\\' && c != '|') + c != '|') { size_t si = strlen(filename); filename[si + 1] = 0;