Skip to content

Commit a360331

Browse files
committed
Fixed per turn kills
1 parent 2e8efd4 commit a360331

5 files changed

Lines changed: 24 additions & 13 deletions

File tree

bin/data/Ruleset/Commendations.rul

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ commendations:
271271
kills_with_criteria_career: [3, 5, 10, 15, 20, 25, 30, 35, 40, 50]
272272
killCriteria:
273273
-
274-
1: ["FACTION_HOSTILE", "STATUS_DEAD"]
274+
1: ["STATUS_DEAD"]
275275
- type: STR_MEDAL_MILITARY_CROSS_NAME
276276
description: STR_MEDAL_MILITARY_CROSS_DESCRIPTION
277277
sprite: 1

src/Ruleset/RuleCommendations.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ std::map<std::string, std::vector<int> > *RuleCommendations::getCriteria()
8484
* Get commendation award kill criteria
8585
* @return vecotr<string> Commendation kill criteria
8686
*/
87-
std::vector<std::vector<std::vector<std::string> > > *RuleCommendations::getKillCriteria()
87+
std::vector<std::map< int, std::vector<std::string> > > *RuleCommendations::getKillCriteria()
8888
{
8989
return &_killCriteria;
9090
}

src/Ruleset/RuleCommendations.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class RuleCommendations
5151
/// Get commendation award criteria
5252
std::map<std::string, std::vector<int> > *getCriteria();
5353
/// Get commendation award kill related criteria
54-
std::vector<std::vector<std::vector<std::string> > > *getKillCriteria();
54+
std::vector<std::map< int, std::vector<std::string> > > *getKillCriteria();
5555
/// Get sprite
5656
int getSprite() const;
5757

src/Savegame/SoldierDiary.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -449,11 +449,11 @@ bool SoldierDiary::manageCommendations(Ruleset *rules)
449449
{
450450
int count = 0; // Each AND vector has to match the award criteria
451451
// Loop over the KILLS
452-
for (std::vector<SoldierDiaryKills*>::const_iterator singleKill = _killList->begin(); singleKill != _killList->end(); ++singleKill)
452+
for (std::vector<SoldierDiaryKills*>::const_iterator singleKill = _killList.begin(); singleKill != _killList.end(); ++singleKill)
453453
{
454454
bool foundMatch = true;
455455
// Loop over the DETAILs of the AND vector
456-
for (std::vector<std::string>::const_iterator detail = (*andCriteria).second->begin(); detail != (*andCriteria).second->end(); ++detail)
456+
for (std::vector<std::string>::const_iterator detail = andCriteria->second.begin(); detail != andCriteria->second.end(); ++detail)
457457
{
458458
// See if we find no matches with any criteria. If so, break and try the next kill.
459459
if ( (*singleKill)->getAlienRank() != (*detail) && (*singleKill)->getAlienRace() != (*detail) &&
@@ -482,15 +482,15 @@ bool SoldierDiary::manageCommendations(Ruleset *rules)
482482
{
483483
int count = 0; // Each AND vector has to match the award criteria
484484
// Loop over MISSIONS
485-
for (std::vector<SoldierDiaryEntries*>::const_iterator singleMission = _diaryEntries->begin(); singleMission != _diaryEntries->end(); ++singleMission)
485+
for (std::vector<SoldierDiaryEntries*>::const_iterator singleMission = _diaryEntries.begin(); singleMission != _diaryEntries.end(); ++singleMission)
486486
{
487487
// Loop over KILLS
488488
// These kills are confined to the mission; kills won't be borrowed from other missions for commendation purposes
489-
for (std::vector<SoldierDiaryKills*>::const_iterator singleKill = (*singleMission)->getMissionKills()->begin(); singleKill != (*singleMission)->getMissionKills()->end(); ++singleKill)
489+
for (std::vector<SoldierDiaryKills*>::const_iterator singleKill = (*singleMission)->getMissionKillsReference()->begin(); singleKill != (*singleMission)->getMissionKillsReference()->end(); ++singleKill)
490490
{
491491
bool foundMatch = true;
492492
// Loop over the DETAILs of the AND vector
493-
for (std::vector<std::string>::const_iterator detail = (*andCriteria).second->begin(); detail != (*andCriteria).second->end(); ++detail)
493+
for (std::vector<std::string>::const_iterator detail = andCriteria->second.begin(); detail != andCriteria->second.end(); ++detail)
494494
{
495495
// See if we find no matches with any criteria. If so, break and try the next kill.
496496
if ( (*singleKill)->getAlienRank() != (*detail) && (*singleKill)->getAlienRace() != (*detail) &&
@@ -524,32 +524,33 @@ bool SoldierDiary::manageCommendations(Ruleset *rules)
524524
// Loop over the AND vectors
525525
for (std::map<int, std::vector<std::string> >::const_iterator andCriteria = orCriteria->begin(); andCriteria != orCriteria->end(); ++andCriteria)
526526
{
527-
int count = 0; // How many AND vectors (list of DETAILs) have been successful
527+
int count = 1; // How many AND vectors (list of DETAILs) have been successful
528528
int killThisTurn = 0;
529529
int killLastTurn = -1;
530530
bool goToNextTurn = false;
531531
// Loop over the KILLS
532-
for (std::vector<SoldierDiaryKills*>::const_iterator singleKill = _killList->begin(); singleKill != _killList->end(); ++singleKill)
532+
for (std::vector<SoldierDiaryKills*>::const_iterator singleKill = _killList.begin(); singleKill != _killList.end(); ++singleKill)
533533
{
534534
// Set kill turns
535535
killThisTurn = (*singleKill)->getTurn();
536-
if (singleKill != _killList->begin())
536+
if (singleKill != _killList.begin())
537537
{
538538
--singleKill;
539539
killLastTurn = (*singleKill)->getTurn();
540540
++singleKill;
541541
}
542542
// Skip kill-groups that we already got an award for
543543
// Skip kills that are inbetween turns
544-
if ( killThisTurn == killLastTurn && goToNextKill) continue;
544+
if ( killThisTurn == killLastTurn && goToNextTurn) continue;
545545
else if ( killThisTurn != killLastTurn )
546546
{
547+
count = 1; // Reset
547548
goToNextTurn = false;
548549
continue;
549550
}
550551
bool foundMatch = true;
551552
// Loop over the DETAILs of the AND vector
552-
for (std::vector<std::string>::const_iterator detail = (*andCriteria).second->begin(); detail != (*andCriteria).second->end(); ++detail)
553+
for (std::vector<std::string>::const_iterator detail = andCriteria->second.begin(); detail != andCriteria->second.end(); ++detail)
553554
{
554555
// See if we find no matches with any criteria. If so, break and try the next kill.
555556
if ( (*singleKill)->getAlienRank() != (*detail) && (*singleKill)->getAlienRace() != (*detail) &&
@@ -783,6 +784,14 @@ std::vector<SoldierDiaryKills*> SoldierDiaryEntries::getMissionKills() const
783784
return _missionStatistics->kills;
784785
}
785786

787+
/**
788+
*
789+
*/
790+
std::vector<SoldierDiaryKills*> *SoldierDiaryEntries::getMissionKillsReference()
791+
{
792+
return &_missionStatistics->kills;
793+
}
794+
786795
/**
787796
*
788797
*/

src/Savegame/SoldierDiary.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ class SoldierDiaryEntries
157157
/// Get
158158
std::vector<SoldierDiaryKills*> getMissionKills() const;
159159
/// Get
160+
std::vector<SoldierDiaryKills*> *getMissionKillsReference();
161+
/// Get
160162
bool getMissionSuccess() const;
161163
/// Get
162164
std::string getMissionRating() const;

0 commit comments

Comments
 (0)