X-Git-Url: https://ruin.nu/git/?p=hbs.git;a=blobdiff_plain;f=bs%2Fplanet.cpp;h=e0cf514e0c45d7b6054afbaae1c3b3ebc99342a9;hp=4fa69786a009e426ae8dd666724965d3aa89465c;hb=236fcf8db0fa64f8acd0a1eb81aa3ce5f2bfb3e8;hpb=4cf2f4e52869627146dfc5a0c0d4fe0942777a09 diff --git a/bs/planet.cpp b/bs/planet.cpp index 4fa6978..e0cf514 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -17,6 +17,8 @@ #include "planet.h" +using namespace std; + Planet::Planet() { m_sRace = "Planet"; @@ -42,22 +44,35 @@ void Planet::setPlanetScore(unsigned i) ////////////////////////////////////////////////////////////////////////// // -int roids(std::string type, int tick = 0) const +int Planet::roids(std::string type, int tick = 0) const { - ticks = m_Roids[type].size(); + // const... I would like [] as for const types: int ticks = m_Roids[type].size(); + + vectorconst* roids; + for (RoidList::const_iterator i = m_Roids.begin(); i != m_Roids.end(); ++i) + { + if (i->first == type) + { + roids = &i->second; + break; + } + } + + int ticks = roids->size(); + if( ticks == 0) return 0; if (ticks < tick) - return m_Roids[type][ticks]; - return m_Roids[type][tick]; + return roids->at(ticks); + return roids->at(tick); } ////////////////////////////////////////////////////////////////////////// // -void setRoids(std::string type, int number) +void Planet::setRoids(std::string type, int number) { if (m_Roids[type].size() == 0) - m_Roids.push_back(number); + m_Roids[type].push_back(number); m_Roids[type][0] = number; }