@@ -564,10 +564,7 @@ command_result autoclothing(color_ostream &out, vector <string> & parameters)
564564
565565static void find_needed_clothing_items ()
566566{
567- vector<df::unit *> citizens;
568- Units::getCitizens (citizens);
569- for (auto & unit : citizens)
570- {
567+ Units::forCitizens ([&](auto unit) {
571568 // now check each clothing order to see what the unit might be missing.
572569 for (auto & clothingOrder : clothingOrders)
573570 {
@@ -607,7 +604,7 @@ static void find_needed_clothing_items()
607604 // technically, there's some leeway in sizes, but only caring about exact sizes is simpler.
608605 clothingOrder.total_needed_per_race [unit->race ] += neededAmount;
609606 }
610- }
607+ });
611608}
612609
613610static void remove_available_clothing ()
@@ -760,10 +757,8 @@ static void generate_control(color_ostream& out)
760757 map<int , int > missingHelms;
761758 map<int , int > missingGloves;
762759 map<int , int > missingPants;
763- vector<df::unit *> citizens;
764- Units::getCitizens (citizens);
765- for (df::unit* unit : citizens)
766- {
760+
761+ Units::forCitizens ([&](auto unit) {
767762 fullUnitList[unit->race ]++;
768763 int numArmor = 0 , numShoes = 0 , numHelms = 0 , numGloves = 0 , numPants = 0 ;
769764 for (auto itemId : unit->owned_items )
@@ -808,7 +803,8 @@ static void generate_control(color_ostream& out)
808803 if (numPants == 0 )
809804 missingPants[unit->race ]++;
810805 DEBUG (control,out) << Translation::TranslateName (Units::getVisibleName (unit)) << " has " << numArmor << " armor, " << numShoes << " shoes, " << numHelms << " helms, " << numGloves << " gloves, " << numPants << " pants" << endl;
811- }
806+ });
807+
812808 if (missingArmor.size () + missingShoes.size () + missingHelms.size () + missingGloves.size () + missingPants.size () == 0 )
813809 {
814810 out << " Everybody has a full set of clothes to wear, congrats!" << endl;
0 commit comments