+ cerr << (*j)->name() << " adding " << num << " units of type " << i->first << endl;
}
}
}
@@ -227,6+236,33 @@ void Fleet::addToThis(std::vector<Fleet*> fleets, int tick = 0)
//
void Fleet::distributeLossesGains(std::vector<Fleet*> fleets, int tick = 0)
{
+ for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); ++i)
+ {
+ string unittype = i->first;
+
+
+ if (m_Fleet[unittype].size() < 1)
+ continue;
+ if (m_Fleet[unittype][0] == 0)
+ continue;
+
+
+ int totallost = fleet(unittype,1) - fleet(unittype, 0);
+
+
+ cerr << "Distributing type: " << unittype << " with a total loss of " << totallost << " units" << endl;
+
+ cerr << "Total number of units before: " << fleet(unittype, 0) << " and after : " << fleet(unittype, 1) << endl;
+
+ for (vector<Fleet*>::iterator j = fleets.begin(); j != fleets.end(); ++j)
+ {
+ int fl1 = (*j)->fleet(unittype, tick - 1);
+ float part = float(fl1) / fleet(unittype, 0) ;
+ int lost = totallost * part;
+ cerr << (*j)->name() << " gaining " << lost << " " << unittype << " since it's " << part * 100 << "% of the whole fleet, and it had : " << fl1 << " units last tick.." << endl;