]> ruin.nu Git - hbs.git/blobdiff - bs/fleet.cpp
some
[hbs.git] / bs / fleet.cpp
index 3df0972e0584f0b3d4e541b0de0b9964237b0b19..73923b5c22449e43c8702fdf9b376be5a39c201a 100644 (file)
@@ -1,9 +1,9 @@
 /***************************************************************************
-                          fleet.cpp  -  description
-                             -------------------
-    begin                : Tue Jan 22 2002
-    copyright            : (C) 2002 by Michael Andreen
-    email                : whale@linux.nu
+  fleet.cpp  -  description
+  -------------------
+begin                : Tue Jan 22 2002
+copyright            : (C) 2002 by Michael Andreen
+email                : whale@linux.nu
  ***************************************************************************/
 
 /***************************************************************************
@@ -118,29 +118,29 @@ void Fleet::setUnits(UnitList& units)
 {
        s_Units = units;
 
-       
-/*
-       for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); i++)
-       {
-               cerr << s_Units[(*i).first].Name() << "\t\t"
-                       << s_Units[(*i).first].race() <<"\t"
-                       << s_Units[(*i).first].unitClass() << "\t"
-                       << s_Units[(*i).first].target(0) << "\t"
-                       << s_Units[(*i).first].target(1) << "\t"
-                       << s_Units[(*i).first].target(2) << "\t"
-                       << s_Units[(*i).first].initiative() << "\t"
-                       << s_Units[(*i).first].agility() << "\t"
-                       << s_Units[(*i).first].weaponSpeed() << "\t"
-                       << s_Units[(*i).first].guns() << "\t"
-                       << s_Units[(*i).first].power() << "\t"
-                       << s_Units[(*i).first].armor() << "\t"
-                       << s_Units[(*i).first].EMP() << "\t"
-                       << s_Units[(*i).first].totRes() << "\t"
-                       << s_Units[(*i).first].fuel() << "\t"
-                       << s_Units[(*i).first].ETA() << "\t"
-                       << s_Units[(*i).first].type() << endl;
-       }
-*/     
+
+/*     
+          for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); i++)
+          {
+                  cerr << s_Units[(*i).first].Name() << "\t\t"
+                  << s_Units[(*i).first].race() <<"\t"
+                  << s_Units[(*i).first].unitClass() << "\t"
+                  << s_Units[(*i).first].target(0) << "\t"
+                  << s_Units[(*i).first].target(1) << "\t"
+                  << s_Units[(*i).first].target(2) << "\t"
+                  << s_Units[(*i).first].initiative() << "\t"
+                  << s_Units[(*i).first].agility() << "\t"
+                  << s_Units[(*i).first].weaponSpeed() << "\t"
+                  << s_Units[(*i).first].guns() << "\t"
+                  << s_Units[(*i).first].power() << "\t"
+                  << s_Units[(*i).first].armor() << "\t"
+                  << s_Units[(*i).first].EMP() << "\t"
+                  << s_Units[(*i).first].totRes() << "\t"
+                  << s_Units[(*i).first].fuel() << "\t"
+                  << s_Units[(*i).first].ETA() << "\t"
+                  << s_Units[(*i).first].type() << endl;
+          }
+          */
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -166,7 +166,7 @@ vector<int> Fleet::RacesAllowed() const
 
 //////////////////////////////////////////////////////////////////////////
 //
-unsigned Fleet::score(int tick = 0) const
+unsigned Fleet::score(int tick) const
 {
        unsigned tot_score = 0;
 
@@ -187,7 +187,7 @@ unsigned Fleet::score(int tick = 0) const
 
 //////////////////////////////////////////////////////////////////////////
 //
-void Fleet::setFleet(string unittype, int number, int tick = 0)
+void Fleet::setFleet(string unittype, int number, int tick)
 {
        int earlier = 0;
        int ticks = m_Fleet[unittype].size();
@@ -204,7 +204,7 @@ void Fleet::setFleet(string unittype, int number, int tick = 0)
 
 //////////////////////////////////////////////////////////////////////////
 //
-void Fleet::addFleet(std::string unittype, int number, int tick = 0)
+void Fleet::addFleet(std::string unittype, int number, int tick)
 {
        int earlier = 0;
        int ticks = m_Fleet[unittype].size();
@@ -221,12 +221,16 @@ void Fleet::addFleet(std::string unittype, int number, int tick = 0)
 
 //////////////////////////////////////////////////////////////////////////
 //
-int     Fleet::fleet(string unittype, int tick = 0)
+int     Fleet::fleet(string unittype, int tick)
 {
+
        int ticks = m_Fleet[unittype].size();
        if (ticks == 0)
                return 0;
 
+       if (tick < 0)
+               return m_Fleet[unittype][0];
+
        --ticks;
 
        if (ticks < tick)
@@ -237,7 +241,7 @@ int  Fleet::fleet(string unittype, int tick = 0)
 
 //////////////////////////////////////////////////////////////////////////
 //
-int Fleet::blockedFleet(std::string unittype, int tick = 0)
+int Fleet::blockedFleet(std::string unittype, int tick)
 {
        int ticks = m_BlockedFleet[unittype].size();
        if (ticks == 0)
@@ -253,7 +257,7 @@ int Fleet::blockedFleet(std::string unittype, int tick = 0)
 
 //////////////////////////////////////////////////////////////////////////
 //
-void Fleet::setBlockedFleet(std::string unittype, int number, int tick = 0)
+void Fleet::setBlockedFleet(std::string unittype, int number, int tick)
 {
        int ticks = m_BlockedFleet[unittype].size();
 
@@ -268,13 +272,13 @@ void Fleet::setBlockedFleet(std::string unittype, int number, int tick = 0)
 }
 
 //////////////////////////////////////////////////////////////////////////
-//FIXME
-void Fleet::addToThis(std::vector<Fleet*> fleets, int tick = 0)
+//
+void Fleet::addToThis(std::vector<Fleet*> fleets, int tick)
 {
        for (UnitList::iterator i = s_Units.begin();  i != s_Units.end(); ++i)
        {
                if (m_Fleet[i->first].size() == 0)
-                               m_Fleet[i->first].push_back(0);
+                       m_Fleet[i->first].push_back(0);
 
                for (vector<Fleet*>::iterator j = fleets.begin(); j != fleets.end(); ++j)
                {
@@ -288,7 +292,7 @@ void Fleet::addToThis(std::vector<Fleet*> fleets, int tick = 0)
 
 //////////////////////////////////////////////////////////////////////////
 //
-void Fleet::distributeLossesGains(std::vector<Fleet*> fleets, int tick = 0)
+void Fleet::distributeLossesGains(std::vector<Fleet*> fleets, int tick)
 {
        for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); ++i)
        {
@@ -297,27 +301,27 @@ void Fleet::distributeLossesGains(std::vector<Fleet*> fleets, int tick = 0)
 
                if (m_Fleet[unittype].size() < 1)
                        continue;
-               if (m_Fleet[unittype][0] == 0)
+               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;
+                       int lost =  int(totallost * part);
                        (*j)->setFleet(unittype, (*j)->fleet(unittype, tick - 1) + lost, tick);
 
                        cerr << (*j)->name() << " gaining " << lost << " " << unittype  << " since it's " << part * 100 << "% of the whole fleet, and it had : " << fl1 << " units last tick.." <<  endl;
 
-                       lost = part * blockedFleet(unittype, 0);
+                       lost = int(part * blockedFleet(unittype, 0));
 
                        cerr << (*j)->name() << " got " << lost << " blocked " << unittype  << ", the total number of blocked ships was: " << blockedFleet(unittype, 0) << endl; 
 
@@ -328,12 +332,14 @@ void Fleet::distributeLossesGains(std::vector<Fleet*> fleets, int tick = 0)
 
 //////////////////////////////////////////////////////////////////////////
 //
-std::vector<Fleet*> Fleet::calculateSide(std::vector<Fleet*> fleets, int stays = 0, int tick = 0)
+std::vector<Fleet*> Fleet::calculateSide(std::vector<Fleet*> fleets, int tick)
 {
        vector<Fleet*> fl;
        for (vector<Fleet*>::iterator i = fleets.begin(); i != fleets.end(); ++i)
        {
-               if (( tick - (*i)->ETA()) >= 0 && (tick - (*i)->ETA()) < (*i)->stays())
+               if ((*i)->stays() == 0)
+                       continue;
+               else if (( tick - (*i)->ETA()) >= 0 && (tick - (*i)->ETA()) < (*i)->stays())
                {
                        fl.push_back((*i));
                        cerr << "Using fleet " << (*i)->name() << " for tick " << tick << endl;
@@ -346,7 +352,7 @@ std::vector<Fleet*> Fleet::calculateSide(std::vector<Fleet*> fleets, int stays =
 
 //////////////////////////////////////////////////////////////////////////
 //
-int Fleet::freeFleet(std:: string unittype, int tick = 0)
+int Fleet::freeFleet(std:: string unittype, int tick)
 {
        int bticks = m_BlockedFleet[unittype].size();
 
@@ -370,61 +376,31 @@ void Fleet::takeShoot(std::string unittype, int number, std::map<std::string, in
 
        float guns = s_Units[unittype].guns() * number;
 
-       
+
        if (guns == 0)
                return;
 
-       cerr << number << " " << unittype << ": with " << guns << " guns\n";
-
        float gunsleft = guns;
-       for (int count = 0; count < 3; ++count)//vector<string>::iterator i = s_Units[unittype].target().begin(); i != s_Units[unittype].target().end(); ++i)
+       for (int count = 0; count < 3; ++count)
        {
                string ta = s_Units[unittype].target(count);
-       cerr << "Shooting at target class: " << ta << endl;
+
                while (gunsleft > 0)
                {
-       
-                       map<string, int*> targets;
-
-                       for (UnitList::iterator j = s_Units.begin(); j != s_Units.end(); ++j)
-                       {
-
-                               if (m_Fleet[j->first].size() == 0)
-                                       continue;
-
-
-                               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];
-                               }
-
-                       }
+                       int total = 0;
+                       map<string, int*> targets = findTargets(ta,total, 0);
 
                        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)
                        {
                                float maxguns = float((*j->second))/total * guns;
-                               //cerr << "Now shooting at target: " << j->first << endl;
 
                                if (m_Armor[j->first] <= 0 || m_Armor[j->first] > s_Units[j->first].armor())
                                        m_Armor[j->first] = s_Units[j->first].armor();
                                double k = maxguns;
 
-                               //cerr << "Targets agility: " << s_Units[j->first].agility() << endl;
-                               //cerr << "Weaponspeed: " << s_Units[unittype].weaponSpeed() << endl;
                                while (k > 0)   
                                {
 
@@ -435,8 +411,6 @@ void Fleet::takeShoot(std::string unittype, int number, std::map<std::string, in
                                        int agil = s_Units[j->first].agility();
 
                                        k -= float(100)/(25 + wpsp - agil);
-                                       //cout << "Used " << blaha << " guns to hit with one shot.\n";
-                                       //cout << "WPSP: " << wpsp << "\nAgil: " << agil << endl;
 
                                        m_Armor[j->first] -= s_Units[unittype].power();
                                        if (m_Armor[j->first] <= 0)
@@ -444,25 +418,9 @@ void Fleet::takeShoot(std::string unittype, int number, std::map<std::string, in
                                                m_Armor[j->first] = s_Units[j->first].armor();
                                                (*j->second)--;
                                                hitunits[j->first]++;
-                                               
-                                               //There is a chance that we're hitting a blocked ship.
-                                               if (m_BlockedFleet[j->first].size() >= 1)
-                                               {
-                                                       int test = rand() % m_BlockedFleet[j->first][0];
-                                                       if (test == 1
-                                                               && m_BlockedFleet[j->first][0] > 0)
-                                                       {
-                                                               if (m_BlockedFleet[j->first].size() == 1)
-                                                                       m_BlockedFleet[j->first].push_back(m_BlockedFleet[j->first][0] - 1);
-                                                               else if (m_BlockedFleet[j->first][1] > 0)
-                                                                       m_BlockedFleet[j->first][1]--;
-                                                       }
-                                               }
                                        }
 
                                }
-
-                               cerr << hitunits[j->first] << " units of type: " << j->first << "killed\n";
                                if (k <= 0)
                                        gunsleft -= maxguns;
                                else
@@ -474,63 +432,29 @@ void Fleet::takeShoot(std::string unittype, int number, std::map<std::string, in
 
 //////////////////////////////////////////////////////////////////////////
 //
-void Fleet::takeEMP(std::string unittype, int number)
+void Fleet::takeEMP(std::string unittype, int number, std::map<std::string, int>& hitunits)
 {
        int guns = s_Units[unittype].guns() * number;
        if (guns == 0)
                return;
 
-       cerr << unittype << ": with " << guns << " guns\n";
-
        float gunsleft = guns;
-       for (int count = 0; count < 3; ++count)//vector<string>::iterator i = s_Units[unittype].target().begin(); i != s_Units[unittype].target().end(); ++i)
+       for (int count = 0; count < 3; ++count)
        {
                string ta = s_Units[unittype].target(count);
-       cerr << "Shooting at target class: " << ta << endl;
+
                while (gunsleft > 0)
                {
-       
-                       map<string, int*> targets;
-
-                       for (UnitList::iterator j = s_Units.begin(); j != s_Units.end(); ++j)
-                       {
-                               if (j->second.type() == "PDS")
-                                       continue;
-
-                               if (freeFleet(j->first, 1) <= 0)
-                                       continue;
-
-                               if (m_Fleet[j->first].size() == 0)
-                                       continue;
-
-                               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];
-                               }
-
-                       }
+                       int total = 0;
+                       map<string, int*> targets = findTargets(ta, total, 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)
                        {
-                               float maxguns = float((*j->second))/total * guns;
-                               cerr << "Now shooting at target: " << j->first << endl;
-
+                               float maxguns = float((*j->second))/total * gunsleft;
                                double k = maxguns;
-
                                int hits = 0;
 
                                while (k > 0)   
@@ -543,10 +467,9 @@ void Fleet::takeEMP(std::string unittype, int number)
 
                                        k -= float(100)/(100-eres);
                                        hits++;
+                                       hitunits[j->first]++;
                                        blockFleet(j->first, 1);
                                }
-
-                               cerr << hits << " units of type: " << j->first << " blocked\n";
                                if (k <= 0)
                                        gunsleft -= maxguns;
                                else
@@ -558,7 +481,7 @@ void Fleet::takeEMP(std::string unittype, int number)
 
 //////////////////////////////////////////////////////////////////////////
 //
-void Fleet::killFleet(std::string unittype, int number, int tick = 0)
+void Fleet::killFleet(std::string unittype, int number, int tick)
 {
        int earlier = 0;
        int ticks = m_Fleet[unittype].size();
@@ -575,7 +498,7 @@ void Fleet::killFleet(std::string unittype, int number, int tick = 0)
 
 //////////////////////////////////////////////////////////////////////////
 //
-void Fleet::setResource(std::string type, int number, int tick = 0)
+void Fleet::setResource(std::string type, int number, int tick)
 {
 
        int ticks = m_Resources[type].size();
@@ -586,7 +509,7 @@ void Fleet::setResource(std::string type, int number, int tick = 0)
 
 //////////////////////////////////////////////////////////////////////////
 //
-void Fleet::addResource(std::string type, int number, int tick = 0)
+void Fleet::addResource(std::string type, int number, int tick)
 {
 
        int ticks = m_Resources[type].size();
@@ -599,7 +522,7 @@ void Fleet::addResource(std::string type, int number, int tick = 0)
 
 //////////////////////////////////////////////////////////////////////////
 //
-int Fleet::resource(std::string type, int tick = 0) const
+int Fleet::resource(std::string type, int tick) const
 {
        if (tick < 0)
                return 0;
@@ -654,7 +577,7 @@ void Fleet::printFleet()
 
 //////////////////////////////////////////////////////////////////////////
 //
-void Fleet::blockFleet(std::string unittype, int number, int tick = 0)
+void Fleet::blockFleet(std::string unittype, int number, int tick)
 {
        if (m_BlockedFleet[unittype].size() >= 1)
        {
@@ -673,7 +596,7 @@ void Fleet::blockFleet(std::string unittype, int number, int tick = 0)
 
 //////////////////////////////////////////////////////////////////////////
 //
-void Fleet::distributeCappedRoids(std::vector<Fleet*> fleets, int tick = 0)
+void Fleet::distributeCappedRoids(std::vector<Fleet*> fleets, int tick)
 {
        for (ResourceList::iterator i = m_Resources.begin(); i != m_Resources.end(); ++i)
        {
@@ -686,22 +609,22 @@ void Fleet::distributeCappedRoids(std::vector<Fleet*> fleets, int tick = 0)
 
                if (m_Resources[res].size() < 2)
                        continue;
-               if (m_Resources[res][1] == 0)
+               if (m_Resources[res][1] == 0)
                        continue;
 
-                
+
                int totcapped = resource(res,1) - resource(res, 0);
 
 
                cerr << "Distributing type: " << res << " with a total gain of " << totcapped << " roids" << endl;
 
                cerr << "Total number of roids before: " << resource(res, 0)  << " and after : " << resource(res, 1) << endl;
-               
+
                for (vector<Fleet*>::iterator j = fleets.begin(); j != fleets.end(); ++j)
                {
                        unsigned fl1 = (*j)->score(tick - 1);
                        float part = float(fl1) / score(0) ;
-                       int lost =  totcapped * part;
+                       int lost =  int(totcapped * part);
 
                        cerr << (*j)->name() << " gaining " << lost << " " << res  << " since it's " << part * 100 << "% of the whole score, and it had : " << fl1 << " score last tick.. compared to fleet total of: " << score(0) <<  endl;
 
@@ -713,7 +636,7 @@ void Fleet::distributeCappedRoids(std::vector<Fleet*> fleets, int tick = 0)
 
 //////////////////////////////////////////////////////////////////////////
 //
-void Fleet::addFleet(std::map<string, int> units, int tick = 0)
+void Fleet::addFleet(std::map<string, int> units, int tick)
 {
        for (map<string, int>::iterator i = units.begin(); i != units.end(); ++i)
                addFleet(i->first, i->second, tick);
@@ -735,16 +658,156 @@ void Fleet::setStays(int ticks)
 
 //////////////////////////////////////////////////////////////////////////
 //
-void Fleet::calculateLostStealships(string unittype, std::map<std::string, int> stolen, int tick = 1)
+void Fleet::calculateLostStealships(string unittype, std::map<std::string, int> stolen, int tick)
 {
        int stealscore = 0;
        for (map<string, int>::iterator i = stolen.begin(); i != stolen.end(); ++i)
        {
-               stealscore += stolen[i->first] * (s_Units[i->first].totRes() / 10.0);   
+               stealscore += int(stolen[i->first] * (s_Units[i->first].totRes() / 10.0));      
        }
 
-       int lost = stealscore / (s_Units[unittype].totRes() / 10.0);
+       int lost = int(stealscore / (s_Units[unittype].totRes() / 10.0));
 
        cerr << "Lost " << lost << " " << unittype << " due to stealing ships worth: " << stealscore << endl; 
        killFleet(unittype, lost, tick);
 }
+
+//////////////////////////////////////////////////////////////////////////
+//
+void Fleet::distributeStolenShips(std::map<std::string, std::map<std::string, int> > stolen, std::vector<Fleet*> fleets, int tick)
+{
+       for(map<string, map<string, int> >::iterator i = stolen.begin(); i != stolen.end(); ++i)
+       {
+               int totalstealers = 0;
+               for (vector<Fleet*>::iterator j = fleets.begin(); j != fleets.end(); ++j)
+                       totalstealers += (*j)->fleet(i->first, tick - 1);
+
+               for (map<string, int>::iterator j = i->second.begin(); j != i->second.end(); ++j)
+               {
+                       for (vector<Fleet*>::iterator k = fleets.begin(); k != fleets.end(); ++k)
+                       {
+                               int stolen = int(float ((*k)->fleet(i->first, tick - 1)) / totalstealers * j->second);
+                               (*k)->addFleet(j->first, stolen, tick);
+                       }
+               }
+       }
+}
+
+//////////////////////////////////////////////////////////////////////////
+//
+void Fleet::calculateSalvage()
+{
+       for (FleetList::iterator i = m_Fleet.begin(); i != m_Fleet.end(); ++i)
+       {
+
+               map<string, int> res = s_Units[i->first].resources();
+
+               if (i->second.size() > 0)
+                       cerr << endl << i->first << ": ";
+
+               int tick = 0;
+               for (vector<int>::iterator j = i->second.begin(); j != i->second.end(); ++j, ++tick)
+               {
+                       int lostunits = fleet(i->first, tick - 1) - fleet(i->first, tick);
+
+                       if (lostunits <= 0)
+                               continue;
+                       cerr << "(" << tick << ":" << fleet(i->first, tick) << ") ";
+                       for (map<string, int>::iterator k = res.begin(); k != res.end(); ++k)
+                               addResource(k->first, int(lostunits * k->second * 0.25), tick);
+               }
+       }
+}
+
+//////////////////////////////////////////////////////////////////////////
+//
+void Fleet::resetTicks()
+{
+       for (FleetList::iterator i = m_Fleet.begin(); i != m_Fleet.end(); ++i)
+       {
+               if ( i->second.size() < 2)
+                       continue;
+
+               int temp = i->second[0];
+               i->second.clear();
+
+               if (temp > 0)
+                       i->second.push_back(temp);
+       }
+       resetResources();
+}
+
+//////////////////////////////////////////////////////////////////////////
+//
+int Fleet::freePodGuns(int tick) 
+{
+       int guns = 0;
+       for (FleetList::const_iterator i = m_Fleet.begin(); i != m_Fleet.end(); ++i)
+       {
+               if (s_Units[i->first].type() == "Pod")
+               {
+                       guns += freeFleet(i->first, tick) * s_Units[i->first].guns();
+               }
+       }
+       guns -= usedPodGuns(tick);
+       return guns;
+}
+
+//////////////////////////////////////////////////////////////////////////
+//
+int Fleet::usedPodGuns(int tick) const
+{
+       int ticks = m_UsedPodGuns.size();
+
+       if (ticks == 0)
+               return 0;
+
+       if (tick < 0)
+               return m_UsedPodGuns[0];
+
+       --ticks;
+
+       if (ticks < tick)
+               return m_UsedPodGuns[ticks];
+
+       return m_UsedPodGuns[tick];
+
+}
+
+//////////////////////////////////////////////////////////////////////////
+//
+void Fleet::usePodGuns(int tick, int guns)
+{
+       int ticks = m_UsedPodGuns.size();
+
+       for (int i = ticks; i <= tick; ++i)
+       {
+               m_UsedPodGuns.push_back(0);
+       }
+       m_UsedPodGuns[tick] += guns;
+}
+
+//////////////////////////////////////////////////////////////////////////
+//
+std::map<std::string, int*> Fleet::findTargets(std::string targetClass,int& total, int attackerType)
+{
+       map<string, int*> targets;
+
+       for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); ++i)
+       {
+               if (m_Fleet[i->first].size() == 0)
+                       continue;
+
+               if (m_Fleet[i->first].size() == 1 )
+                       m_Fleet[i->first].push_back(m_Fleet[i->first][0]);
+
+               if (m_Fleet[i->first][1] > 0  && ( targetClass == i->second.unitClass() || targetClass == "All"))
+               {
+                       if (i->second.unitClass() == "PDS" && attackerType == 1)
+                               continue;
+                       targets[i->first] = &m_Fleet[i->first][1];
+                       total += m_Fleet[i->first][1];
+               }
+       }
+       return targets;
+}