X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=bs%2Ffleet.cpp;h=00fb66b7e7005e1d590644d139f6624d4804c63d;hb=b6d8203669c6a6016458e72fd240527845449475;hp=cb15df528c6bce726a0f7dd52db026f7d57f5a31;hpb=5940cfda3be2c7b4ecbd64c814948b29139177c0;p=hbs.git diff --git a/bs/fleet.cpp b/bs/fleet.cpp index cb15df5..00fb66b 100644 --- a/bs/fleet.cpp +++ b/bs/fleet.cpp @@ -29,6 +29,7 @@ Fleet::Fleet() m_iETA = 0; m_sRace = "Cathaar"; } + Fleet::~Fleet(){ } @@ -81,7 +82,8 @@ int Fleet::numberOfShips() const for (map >::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; @@ -174,3 +176,26 @@ unsigned Fleet::score(int tick = 0) const return tot_score; } +////////////////////////////////////////////////////////////////////////// +// +void Fleet::setFleet(string unittype, int number) +{ + if (m_Fleet[unittype].size() == 0) + { + m_Fleet[unittype].push_back(number); + return; + } + m_Fleet[unittype][0] = number; +} + +////////////////////////////////////////////////////////////////////////// +// +int Fleet::fleet(string unittype, int tick = 0) +{ + if (m_Fleet[unittype].size() == 0) + return 0; + + return m_Fleet[unittype][tick]; +} + +