+ if (m_Fleet[j->first].size() == 1)
+ m_Fleet[j->first].push_back(m_Fleet[j->first][0]);
+
+ //cerr << "Target is class: " << j->second.type() << endl;
+
+ if (m_Fleet[j->first][1] > 0 && ( ta == j->second.unitClass() || ta == "All"))
+ {
+
+ // cerr << "Looking at target: " << j->first << endl;
+ targets[j->first] = &m_Fleet[j->first][1];
+ }
+
+ }
+
+ if (targets.size() == 0)
+ break;
+
+ int total = 0;
+ for (map<string, int*>::iterator j = targets.begin(); j != targets.end(); ++j)
+ total += (*j->second);
+
+ for (map<string, int*>::iterator j = targets.begin(); j != targets.end(); ++j)
+ {
+ int maxguns = (*j->second)/total * guns;
+ cerr << "Now shooting at target: " << j->first << endl;
+
+ double k = maxguns;
+
+ int hits = 0;
+
+ while (k > 0)
+ {
+
+ if (*(j->second) <= 0)
+ break;
+
+ int eres = s_Units[j->first].EMP();
+
+ k -= float(100)/(100-eres);
+ hits++;
+ blockFleet(j->first, 1);
+ }
+
+ cerr << hits << " units of type: " << j->first << " blocked\n";
+ if (k <= 0)
+ gunsleft -= maxguns;
+ else
+ gunsleft -= maxguns - k;
+ }
+ }
+ }