53 teamName: Name of the playing team |
53 teamName: Name of the playing team |
54 */ |
54 */ |
55 bool isMissionWon(QString & campaignName, int missionInList, QString & teamName) |
55 bool isMissionWon(QString & campaignName, int missionInList, QString & teamName) |
56 { |
56 { |
57 QSettings* teamfile = getCampTeamFile(campaignName, teamName); |
57 QSettings* teamfile = getCampTeamFile(campaignName, teamName); |
58 int won = teamfile->value("Campaign " + campaignName + "/Won", false).toBool(); |
|
59 int progress = teamfile->value("Campaign " + campaignName + "/Progress", 0).toInt(); |
58 int progress = teamfile->value("Campaign " + campaignName + "/Progress", 0).toInt(); |
60 int unlockedMissions = teamfile->value("Campaign " + campaignName + "/UnlockedMissions", 0).toInt(); |
59 int unlockedMissions = teamfile->value("Campaign " + campaignName + "/UnlockedMissions", 0).toInt(); |
61 if(progress>0 and unlockedMissions==0) |
60 if(progress>0 and unlockedMissions==0) |
62 { |
61 { |
63 return (progress > (progress - missionInList)) || won; |
62 QSettings campfile("physfs://Missions/Campaign/" + campaignName + "/campaign.ini", QSettings::IniFormat, 0); |
|
63 campfile.setIniCodec("UTF-8"); |
|
64 int totalMissions = campfile.value("MissionNum", 1).toInt(); |
|
65 return (progress > (progress - missionInList)) || (progress >= totalMissions); |
64 } |
66 } |
65 else if(unlockedMissions>0) |
67 else if(unlockedMissions>0) |
66 { |
68 { |
67 int fileMissionId = missionInList + 1; |
69 int fileMissionId = missionInList + 1; |
68 int actualMissionId = teamfile->value(QString("Campaign %1/Mission%2").arg(campaignName, QString::number(fileMissionId)), false).toInt(); |
70 int actualMissionId = teamfile->value(QString("Campaign %1/Mission%2").arg(campaignName, QString::number(fileMissionId)), false).toInt(); |