]> ruin.nu Git - hbs.git/blobdiff - bs/fleet.cpp
added the possibility to add new fleets..
[hbs.git] / bs / fleet.cpp
index 7361fe2122b486a4b32b11f7d69e44a3d27a857e..ee22ae7a2759f58b97e35a98b8dffc8dfd4e8728 100644 (file)
@@ -82,7 +82,8 @@ int Fleet::numberOfShips() const
 
        for (map<string, vector<int> >::const_iterator i = m_Fleet.begin(); i != m_Fleet.end(); ++i)
        {
-               total += i->second[0];
+               if (i->second.size() != 0)
+                       total += i->second[0];
        }
 
        return total;
@@ -169,7 +170,9 @@ unsigned Fleet::score(int tick = 0) const
 
        for (FleetList::const_iterator i = m_Fleet.begin(); i != m_Fleet.end(); ++i)
        {
-               tot_score += i->second[tick] * s_Units[i->first].totRes() / 10;
+                 if (i->second.size() >= tick)
+                               break;
+                       tot_score += i->second[tick] * s_Units[i->first].totRes() / 10;
        }
 
        return tot_score;