QTfrontend/util/namegen.cpp
changeset 12502 f4b0e164a0d5
parent 12501 92c597704e57
child 12505 82c75a317d48
--- a/QTfrontend/util/namegen.cpp	Sat Sep 23 09:12:35 2017 +0200
+++ b/QTfrontend/util/namegen.cpp	Sat Sep 23 09:35:45 2017 +0200
@@ -101,10 +101,6 @@
             hh.Hat = TypesHatnames[kind][rand()%(TypesHatnames[kind].size())];
             team.setHedgehog(i,hh);
         }
-        else if (mode == HWNamegen::rtmHats)
-        {
-            HWNamegen::teamRandomHat(team,i);
-        }
 
         // there is a chance that this hog has the same hat as the previous one
         // let's reuse the hat-specific dict in this case
@@ -121,6 +117,24 @@
 
 }
 
+// Set random hats for entire team
+void HWNamegen::teamRandomHats(HWTeam & team, bool withDLC)
+{
+    // 50% chance that all hogs are set to the same hat.
+    // 50% chance that each hog gets a random head individually.
+
+    bool sameHogs = (rand()%2) == 0;
+    for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
+    {
+        HWHog hh = team.hedgehog(i);
+        if (sameHogs and i > 0)
+            hh.Hat = team.hedgehog(i-1).Hat;
+        else
+            hh.Hat = getRandomHat(withDLC);
+        team.setHedgehog(i, hh);
+    }
+}
+
 void HWNamegen::teamRandomHat(HWTeam & team, const int HedgehogNumber, bool withDLC)
 {
     HWHog hh = team.hedgehog(HedgehogNumber);