]> ruin.nu Git - hbs.git/blobdiff - bs/planet.cpp
Fixed a bug in the shipstealing code..
[hbs.git] / bs / planet.cpp
index f57d20877ed5455f262c495271204c4daa1f6795..4133277d62d7cc080abfee462df05db499a9756e 100644 (file)
@@ -23,6 +23,7 @@ using namespace std;
 Planet::Planet()
 {
        m_sRace = "Planet";
+       m_iStays = -1;
 }
 
 Planet::~Planet(){
@@ -148,10 +149,10 @@ void Planet::runBattle(std::vector<Fleet*> friendly, std::vector<Fleet*> hostile
        int skipped = 0;
 
        for (vector<Fleet*>::iterator i = friendly.begin(); i != friendly.end(); ++i)
-               (*i)->resetResources();
+               (*i)->resetTicks();
 
        for (vector<Fleet*>::iterator i = hostile.begin(); i != hostile.end(); ++i)
-               (*i)->resetResources();
+               (*i)->resetTicks();
 
        for(int tick = 1; skipped < 20; ++tick)
        {
@@ -196,9 +197,11 @@ void Planet::runBattle(std::vector<Fleet*> friendly, std::vector<Fleet*> hostile
                //allFriends.printFleet();
 
                allFriends.distributeLossesGains(friends, tick);
+               allFriends.distributeStolenShips(stealfriendly, friends, tick);
 
                allHostiles.distributeLossesGains(hostiles, tick);
                allHostiles.distributeCappedRoids(hostiles, tick);
+               allHostiles.distributeStolenShips(stealhostile, hostiles, tick);
 
                calculateScoreLoss(friends, tick);
 
@@ -206,6 +209,9 @@ void Planet::runBattle(std::vector<Fleet*> friendly, std::vector<Fleet*> hostile
                        setRoids(i->first, roids(i->first, 1), tick);*/
        }
 
+       for (vector<Fleet*>::iterator i = friendly.begin(); i != friendly.end(); ++i)
+               (*i)->calculateSalvage();
+
        for (RoidList::iterator i = m_Roids.begin(); i != m_Roids.end(); ++i)
        {
                for (vector<int>::iterator j = i->second.begin(); j != i->second.end(); ++j)
@@ -225,6 +231,7 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map<std::string,
        map<string, int> pods;
 
 
+       //FIXME: Need to change this and allow multiple shiptypes with the same initiative.
        map<int, string> unitsinit; // order units after their ininitiative
        for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); ++i)
                unitsinit[i->second.initiative()] = i->first;
@@ -247,6 +254,9 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map<std::string,
                {
                        hostiletemp->takeShoot(unittype, friendly->freeFleet(unittype, 1), stealfriendly[unittype]);
                        friendlytemp->takeShoot(unittype, hostile->freeFleet(unittype, 1), stealhostile[unittype]);
+
+                       friendlytemp->calculateLostStealships(unittype, stealfriendly[unittype], 1);
+                       hostiletemp->calculateLostStealships(unittype, stealhostile[unittype], 1);
                }
                else
                {
@@ -257,6 +267,7 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map<std::string,
 
                if (s_Units[unittype].type() == "Pod")
                {
+                       //FIXME: Prolly need to recode the whole capping section for r7, due to multiple pods thingy
                        cerr << "Capping is: " << capping(tick) << endl;
        
                        if (capping(tick) > 0)
@@ -340,6 +351,8 @@ void Planet::setCapping(float capping, int tick = 0)
 
        if (capping <= 0.15 && capping >= 0)
                m_Capping[tick] = capping;
-       else
+       else if (capping >= 0.15)
                m_Capping[tick] = 0.15;
+       else
+               m_Capping[tick] = 0;
 }