Advertisement
MageKing17

badges.patch

Dec 12th, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 8.02 KB | None | 0 0
  1. Index: code/missionui/missiondebrief.cpp
  2. ===================================================================
  3. --- code/missionui/missiondebrief.cpp   (revision 11197)
  4. +++ code/missionui/missiondebrief.cpp   (working copy)
  5. @@ -493,7 +493,7 @@
  6.  
  7.     } else if (!stricmp(str, NOX("@Badge"))) {
  8.         if (Badge_bitmap >= 0){
  9. -           return Medals[Player->stats.m_badge_earned].name;
  10. +           return Medals[Player->stats.m_badge_earned.back()].name;
  11.         }
  12.     }
  13.  
  14. @@ -1021,8 +1021,8 @@
  15.  
  16.     // handle badge earned
  17.     // only grant badge if earned and allowed.  (no_promotion really means no promotion and no badges)
  18. -   if ( Player->stats.m_badge_earned != -1 ) {
  19. -       debrief_choose_medal_variant(buf, Player->stats.m_badge_earned, Player->stats.medal_counts[Player->stats.m_badge_earned] - 1);
  20. +   if ( Player->stats.m_badge_earned.size() ) {
  21. +       debrief_choose_medal_variant(buf, Player->stats.m_badge_earned.back(), Player->stats.medal_counts[Player->stats.m_badge_earned.back()] - 1);
  22.         Badge_bitmap = bm_load(buf);
  23.  
  24.         // see if we have a persona
  25. @@ -1029,17 +1029,17 @@
  26.         int persona_index = debrief_find_persona_index();
  27.  
  28.         // use persona-specific badge text if it exists; otherwise, use default
  29. -       if (Medals[Player->stats.m_badge_earned].promotion_text.find(persona_index) != Medals[Player->stats.m_badge_earned].promotion_text.end()) {
  30. -           Badge_stage.text = Medals[Player->stats.m_badge_earned].promotion_text[persona_index];
  31. +       if (Medals[Player->stats.m_badge_earned.back()].promotion_text.find(persona_index) != Medals[Player->stats.m_badge_earned.back()].promotion_text.end()) {
  32. +           Badge_stage.text = Medals[Player->stats.m_badge_earned.back()].promotion_text[persona_index];
  33.         } else {
  34. -           Badge_stage.text = Medals[Player->stats.m_badge_earned].promotion_text[-1];
  35. +           Badge_stage.text = Medals[Player->stats.m_badge_earned.back()].promotion_text[-1];
  36.         }
  37.         Badge_stage.recommendation_text = "";
  38.  
  39.         // choose appropriate badge voice for this mission
  40. -       debrief_choose_voice(Badge_stage.voice, Medals[Player->stats.m_badge_earned].voice_base, persona_index);
  41. +       debrief_choose_voice(Badge_stage.voice, Medals[Player->stats.m_badge_earned.back()].voice_base, persona_index);
  42.  
  43. -       debrief_add_award_text(Medals[Player->stats.m_badge_earned].name);
  44. +       debrief_add_award_text(Medals[Player->stats.m_badge_earned.back()].name);
  45.     }
  46.  
  47.     if ((Rank_bitmap >= 0) || (Medal_bitmap >= 0) || (Badge_bitmap >= 0)) {
  48. Index: code/pilotfile/pilotfile.cpp
  49. ===================================================================
  50. --- code/pilotfile/pilotfile.cpp    (revision 11197)
  51. +++ code/pilotfile/pilotfile.cpp    (working copy)
  52. @@ -130,26 +130,28 @@
  53.     p_stats->missions_flown++;
  54.  
  55.     // badges
  56. -   if (stats->m_badge_earned >= 0) {
  57. +   if (stats->m_badge_earned.size()) {
  58.         list_size = (int)p_stats->medals_earned.size();
  59. +       for (size_t medal = 0; medal < stats->m_badge_earned.size(); medal++) {
  60. +           j = -1;
  61.  
  62. -       j = -1;
  63. -
  64. -       for (idx = 0; idx < list_size; idx++) {
  65. -           if ( p_stats->medals_earned[idx].name.compare(Medals[stats->m_badge_earned].name) == 0 ) {
  66. -               j = idx;
  67. -               break;
  68. +           for (idx = 0; idx < list_size; idx++) {
  69. +               if ( p_stats->medals_earned[idx].name.compare(Medals[stats->m_badge_earned[medal]].name) == 0 ) {
  70. +                   j = idx;
  71. +                   break;
  72. +               }
  73.             }
  74. -       }
  75.  
  76. -       if (j >= 0) {
  77. -           p_stats->medals_earned[j].val = 1;
  78. -       } else {
  79. -           ilist.name = Medals[stats->m_badge_earned].name;
  80. -           ilist.index = stats->m_badge_earned;
  81. -           ilist.val = 1;
  82. +           if (j >= 0) {
  83. +               p_stats->medals_earned[j].val = 1;
  84. +           } else {
  85. +               ilist.name = Medals[stats->m_badge_earned[medal]].name;
  86. +               ilist.index = stats->m_badge_earned[medal];
  87. +               ilist.val = 1;
  88.  
  89. -           p_stats->medals_earned.push_back(ilist);
  90. +               p_stats->medals_earned.push_back(ilist);
  91. +               list_size++;
  92. +           }
  93.         }
  94.     }
  95.  
  96. @@ -250,23 +252,24 @@
  97.     }
  98.  
  99.     // badges
  100. -   if (stats->m_badge_earned >= 0) {
  101. +   if (stats->m_badge_earned.size()) {
  102.         list_size = p_stats->medals_earned.size();
  103. +       for (size_t medal = 0; medal < stats->m_badge_earned.size(); medal++) {
  104. +           j = -1;
  105.  
  106. -       j = -1;
  107. +           for (idx = 0; idx < list_size; idx++) {
  108. +               if ( p_stats->medals_earned[idx].name.compare(Medals[stats->m_badge_earned[medal]].name) == 0 ) {
  109. +                   j = idx;
  110. +                   break;
  111. +               }
  112. +           }
  113.  
  114. -       for (idx = 0; idx < list_size; idx++) {
  115. -           if ( p_stats->medals_earned[idx].name.compare(Medals[stats->m_badge_earned].name) == 0 ) {
  116. -               j = idx;
  117. -               break;
  118. +           if (j >= 0) {
  119. +               p_stats->medals_earned[j].val = 0;
  120. +           } else {
  121. +               Assertion (false, "Badge '%s' not found, should have been added by pilotfile::update_stats.", Medals[stats->m_badge_earned[medal]].name);
  122.             }
  123.         }
  124. -
  125. -       if (j >= 0) {
  126. -           p_stats->medals_earned[j].val = 0;
  127. -       } else {
  128. -           Assertion (false, "Badge '%s' not found, should have been added by pilotfile::update_stats.", Medals[stats->m_badge_earned].name);
  129. -       }
  130.     }
  131.  
  132.     // ship kills
  133. Index: code/stats/scoring.cpp
  134. ===================================================================
  135. --- code/stats/scoring.cpp  (revision 11197)
  136. +++ code/stats/scoring.cpp  (working copy)
  137. @@ -146,7 +146,7 @@
  138.  
  139.     m_medal_earned = -1;        // hasn't earned a medal yet
  140.     m_promotion_earned = -1;
  141. -   m_badge_earned = -1;
  142. +   m_badge_earned.clear();
  143.  
  144.     m_score = 0;
  145.     memset(m_kills, 0, MAX_SHIP_CLASSES * sizeof(int));
  146. @@ -221,7 +221,7 @@
  147.  {
  148.     scp->m_medal_earned = -1;       // hasn't earned a medal yet
  149.     scp->m_promotion_earned = -1;
  150. -   scp->m_badge_earned = -1;
  151. +   scp->m_badge_earned.clear();
  152.     scp->m_score = 0;
  153.     scp->m_assists = 0;
  154.     scp->mp_shots_fired = 0;
  155. @@ -305,8 +305,7 @@
  156.     }
  157.  
  158.     // total_kills should now reflect the number of kills on hostile fighters/bombers.  Check this number
  159. -   // against badge kill numbers, and return the badge index if we would get a new one.
  160. -   int badge = -1;
  161. +   // against badge kill numbers, and award the appropriate badges as neccessary.
  162.     int last_badge_kills = 0;
  163.     for (i = 0; i < Num_medals; i++ ) {
  164.         if ( total_kills >= Medals[i].kills_needed
  165. @@ -314,16 +313,12 @@
  166.             && Medals[i].kills_needed > 0 )
  167.         {
  168.             last_badge_kills = Medals[i].kills_needed;
  169. -           badge = i;
  170. +           if (sc->medal_counts[i] < 1) {
  171. +               sc->medal_counts[i] = 1;
  172. +               sc->m_badge_earned.push_back(i);
  173. +           }
  174.         }
  175.     }
  176. -
  177. -   // if player could have a badge based on kills, and doesn't currently have this badge, then
  178. -   // return the badge id.
  179. -   if ( (badge != -1 ) && (sc->medal_counts[badge] < 1) ) {
  180. -       sc->medal_counts[badge] = 1;
  181. -       sc->m_badge_earned = badge;
  182. -   }
  183.  }
  184.  
  185.  // central point for dealing with accepting the score for a misison.
  186. @@ -381,8 +376,10 @@
  187.     int idx;
  188.  
  189.     // if a badge was earned, take it back
  190. -   if ( score->m_badge_earned != -1){
  191. -       score->medal_counts[score->m_badge_earned] = 0;
  192. +   if ( score->m_badge_earned.size() ){
  193. +       for (size_t medal = 0; medal < score->m_badge_earned.size(); medal++) {
  194. +           score->medal_counts[score->m_badge_earned[medal]] = 0;
  195. +       }
  196.     }
  197.  
  198.     // return when in training mission.  We can grant a medal in training, but don't
  199. @@ -473,9 +470,11 @@
  200.             }
  201.  
  202.             // if a badge was earned, take it back
  203. -           if ( Player->stats.m_badge_earned != -1){
  204. -               Player->stats.medal_counts[Player->stats.m_badge_earned] = 0;
  205. -               Player->stats.m_badge_earned = -1;
  206. +           if ( Player->stats.m_badge_earned.size() ){
  207. +               for (size_t medal = 0; medal < Player->stats.m_badge_earned.size(); medal++) {
  208. +                   Player->stats.medal_counts[Player->stats.m_badge_earned[medal]] = 0;
  209. +               }
  210. +               Player->stats.m_badge_earned.clear();
  211.             }
  212.         }
  213.  
  214. Index: code/stats/scoring.h
  215. ===================================================================
  216. --- code/stats/scoring.h    (revision 11197)
  217. +++ code/stats/scoring.h    (working copy)
  218. @@ -104,7 +104,7 @@
  219.  
  220.     // Mission total
  221.     int m_medal_earned;                 // which medal (if any) earned this mission
  222. -   int m_badge_earned;                 // which badge was earned.  Calculated after mission is over
  223. +   SCP_vector<int> m_badge_earned;     // which badge(s) was(/were) earned.  Calculated after mission is over
  224.     int m_promotion_earned;             // was a promotion earned.  Calculated after mission is over
  225.  
  226.     int m_score;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement