X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=bs%2Ffleet.cpp;h=7070dae6d2a719c3162c5d2113237fa4a84b4383;hb=bb4169deef42f91b6afa4c4561f9339fba040f01;hp=8ca9c7e2c4c366d91a73b507f89bdfb1c1d3fd16;hpb=a61c6ecdc3dd55f06e06cc1a295b1b4fc2830314;p=hbs.git diff --git a/bs/fleet.cpp b/bs/fleet.cpp index 8ca9c7e..7070dae 100644 --- a/bs/fleet.cpp +++ b/bs/fleet.cpp @@ -465,7 +465,7 @@ void Fleet::takeEMP(std::string unittype, int number) for (map::iterator j = targets.begin(); j != targets.end(); ++j) { - int maxguns = (*j->second)/total * guns; + float maxguns = float((*j->second))/total * guns; cerr << "Now shooting at target: " << j->first << endl; double k = maxguns; @@ -529,8 +529,13 @@ void Fleet::addResource(std::string type, int number, int tick = 0) { int ticks = m_Resources[type].size(); + int latest = 0; + + if (ticks > 0) + latest = m_Resources[type][ticks - 1]; + for (int i = ticks; i <= tick; ++i) - m_Resources[type].push_back(number); + m_Resources[type].push_back(latest); m_Resources[type][tick] += number; } @@ -630,7 +635,7 @@ void Fleet::distributeCappedRoids(std::vector fleets, int tick = 0) int lost = 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; - (*j)->setResource(res, (*j)->resource(res, tick - 1) + lost, tick); + (*j)->addResource(res, lost, tick); } } }