@@ -371,7 +371,8 @@ bool SoldierDiary::manageCommendations(Ruleset *rules)
371371 // match nouns and decoration levels
372372 for (std::map<std::string, int >::const_iterator k = _weaponTotal.begin (); k != _weaponTotal.end (); ++k)
373373 {
374- manageModularCommendations (_nextCommendationLevel, _modularCommendations, (*k), (*j).second .at (_nextCommendationLevel.at ((*k).first )));
374+ int _criteria = _nextCommendationLevel[" " ] == 0 ? 0 : (*j).second .at (_nextCommendationLevel.at ((*k).first ));
375+ manageModularCommendations (_nextCommendationLevel, _modularCommendations, (*k), _criteria);
375376 }
376377 // If it is still empty, we did not get a commendation
377378 if (_modularCommendations.empty ())
@@ -384,7 +385,8 @@ bool SoldierDiary::manageCommendations(Ruleset *rules)
384385 {
385386 for (std::map<std::string, int >::const_iterator k = _regionTotal.begin (); k != _regionTotal.end (); ++k)
386387 {
387- manageModularCommendations (_nextCommendationLevel, _modularCommendations, (*k), (*j).second .at (_nextCommendationLevel.at ((*k).first )));
388+ int _criteria = _nextCommendationLevel[" " ] == 0 ? 0 : (*j).second .at (_nextCommendationLevel.at ((*k).first ));
389+ manageModularCommendations (_nextCommendationLevel, _modularCommendations, (*k), _criteria);
388390 }
389391 if (_modularCommendations.empty ())
390392 {
@@ -396,7 +398,8 @@ bool SoldierDiary::manageCommendations(Ruleset *rules)
396398 {
397399 for (std::map<std::string, int >::const_iterator k = _alienRaceTotal.begin (); k != _alienRaceTotal.end (); ++k)
398400 {
399- manageModularCommendations (_nextCommendationLevel, _modularCommendations, (*k), (*j).second .at (_nextCommendationLevel.at ((*k).first )));
401+ int _criteria = _nextCommendationLevel[" " ] == 0 ? 0 : (*j).second .at (_nextCommendationLevel.at ((*k).first ));
402+ manageModularCommendations (_nextCommendationLevel, _modularCommendations, (*k), _criteria);
400403 }
401404 if (_modularCommendations.empty ())
402405 {
@@ -408,7 +411,8 @@ bool SoldierDiary::manageCommendations(Ruleset *rules)
408411 {
409412 for (std::map<std::string, int >::const_iterator k = _alienRankTotal.begin (); k != _alienRankTotal.end (); ++k)
410413 {
411- manageModularCommendations (_nextCommendationLevel, _modularCommendations, (*k), (*j).second .at (_nextCommendationLevel.at ((*k).first )));
414+ int _criteria = _nextCommendationLevel[" " ] == 0 ? 0 : (*j).second .at (_nextCommendationLevel.at ((*k).first ));
415+ manageModularCommendations (_nextCommendationLevel, _modularCommendations, (*k), _criteria);
412416 }
413417 if (_modularCommendations.empty ())
414418 {
@@ -427,7 +431,7 @@ bool SoldierDiary::manageCommendations(Ruleset *rules)
427431 }
428432 for (std::map<std::string, int >::const_iterator j = _modularCommendations.begin (); j != _modularCommendations.end (); ++j)
429433 {
430- awardCommendation ((*i).first , (*i).second ->getDescription (), (*j).first );
434+ awardCommendation ((*i).first , (*i).second ->getDescription (), (*j).first , (*i). second -> getSprite () );
431435 _awardedCommendation = true ;
432436 }
433437 }
@@ -439,26 +443,25 @@ bool SoldierDiary::manageCommendations(Ruleset *rules)
439443/* *
440444 * Manage modular commendations (private)
441445 */
442- void SoldierDiary::manageModularCommendations (std::map<std::string, int > progress , std::map<std::string, int > modularCommendations, std::pair<std::string, int > weaponTotal , int currentLevel )
446+ void SoldierDiary::manageModularCommendations (std::map<std::string, int > nextCommendationLevel , std::map<std::string, int > modularCommendations, std::pair<std::string, int > statTotal , int criteria )
443447{
444- int _criteria = progress[" " ] == 0 ? 0 : currentLevel;
445448 // If criteria is 0, we don't have this noun
446- if (_criteria == 0 && weaponTotal .second >= _criteria )
449+ if (criteria == 0 && statTotal .second >= criteria )
447450 {
448- modularCommendations[weaponTotal .first ]++;
451+ modularCommendations[statTotal .first ]++;
449452 }
450453 // If we meet the criteria, remember the noun for award purposes
451- else if (_criteria != 0 && progress .at (weaponTotal .first ) >= _criteria )
454+ else if (criteria != 0 && nextCommendationLevel .at (statTotal .first ) >= criteria )
452455 {
453- modularCommendations[weaponTotal .first ]++;
456+ modularCommendations[statTotal .first ]++;
454457 }
455458}
456459
457460/* *
458461 * Award commendations to the soldier.
459462 * @param string Commendation Name.
460463 */
461- void SoldierDiary::awardCommendation (std::string _commendationName, std::string _commendationDescription, std::string _noun)
464+ void SoldierDiary::awardCommendation (std::string _commendationName, std::string _commendationDescription, std::string _noun, int sprite )
462465{
463466 bool _newCommendation = true ;
464467
@@ -473,7 +476,7 @@ void SoldierDiary::awardCommendation(std::string _commendationName, std::string
473476 }
474477 if (_newCommendation)
475478 {
476- _commendations.push_back (new SoldierCommendations (_commendationName, _commendationDescription, _noun, 0 , true ));
479+ _commendations.push_back (new SoldierCommendations (_commendationName, _commendationDescription, _noun, 0 , true , sprite ));
477480 }
478481}
479482
@@ -812,7 +815,7 @@ SoldierCommendations::SoldierCommendations(const YAML::Node &node)
812815/* *
813816 * Initializes a soldier commendation.
814817 */
815- SoldierCommendations::SoldierCommendations (std::string commendationName, std::string commendationDescription, std::string noun, int decorationLevel, bool isNew) : _commendationName(commendationName), _commendationDescription(commendationDescription), _noun(noun), _decorationLevel(decorationLevel), _isNew(isNew)
818+ SoldierCommendations::SoldierCommendations (std::string commendationName, std::string commendationDescription, std::string noun, int decorationLevel, bool isNew, int sprite ) : _commendationName(commendationName), _commendationDescription(commendationDescription), _noun(noun), _decorationLevel(decorationLevel), _isNew(isNew), _sprite(sprite )
816819{
817820
818821}
@@ -835,6 +838,7 @@ void SoldierCommendations::load(const YAML::Node &node)
835838 _noun = node[" noun" ].as <std::string>(_noun);
836839 _decorationLevel = node[" decorationLevel" ].as <int >(_decorationLevel);
837840 _isNew = node[" isNew" ].as <bool >(_isNew);
841+ _sprite = node[" sprite" ].as <int >(_sprite);
838842}
839843
840844/* *
@@ -849,6 +853,7 @@ YAML::Node SoldierCommendations::save() const
849853 node[" noun" ] = _noun;
850854 node[" decorationLevel" ] = _decorationLevel;
851855 node[" isNew" ] = _isNew;
856+ node[" sprite" ] = _sprite;
852857 return node;
853858}
854859
@@ -960,4 +965,13 @@ void SoldierCommendations::addDecoration()
960965 _isNew = true ;
961966}
962967
968+ /* *
969+ * Get the sprite int
970+ * @return sprite int
971+ */
972+ int SoldierCommendations::getSprite () const
973+ {
974+ return _sprite;
975+ }
976+
963977}
0 commit comments