Found another issue which might lead to wrong autobuy. If a ship has no batts/bots defined it can happen that the autobuy buys nearly 4 billion items š
here the code:
foreach(lstCargo, CARGO_INFO, it) { AUTOBUY_CARTITEM aci; if((*it).iArchID == iNanobotsID) { aci.iArchID = iNanobotsID; aci.iCount = ship->iMaxNanobots - (*it).iCount; aci.wscDescription = L"Nanobots"; lstCart.push_back(aci); bNanobotsFound = true; } else if((*it).iArchID == iShieldBatsID){ aci.iArchID = iShieldBatsID; aci.iCount = ship->iMaxShieldBats - (*it).iCount; aci.wscDescription = L"Shield Batteries"; lstCart.push_back(aci); bShieldBattsFound = true; } }Should be changed to:
foreach (lstCargo, CARGO_INFO, it) { AUTOBUY_CARTITEM aci; if (((*it).iArchID == iNanobotsID) && (ship->iMaxNanobots > 0)) { aci.iArchID = iNanobotsID; aci.iCount = ship->iMaxNanobots - (*it).iCount; aci.wscDescription = L"Nanobots"; lstCart.push_back (aci); bNanobotsFound = true; } else if (((*it).iArchID == iShieldBatsID) && (ship->iMaxShieldBats > 0)) { aci.iArchID = iShieldBatsID; aci.iCount = ship->iMaxShieldBats - (*it).iCount; aci.wscDescription = L"Shield Batteries"; lstCart.push_back (aci); bShieldBattsFound = true; } } if ((!bNanobotsFound) && (ship->iMaxNanobots > 0)) { // no nanos found -> add all AUTOBUY_CARTITEM aci; aci.iArchID = iNanobotsID; aci.iCount = ship->iMaxNanobots; aci.wscDescription = L"Nanobots"; lstCart.push_back (aci); } if ((!bShieldBattsFound) && (ship->iMaxShieldBats > 0)) { // no batts found -> add all AUTOBUY_CARTITEM aci; aci.iArchID = iShieldBatsID; aci.iCount = ship->iMaxShieldBats; aci.wscDescription = L"Shield Batteries"; lstCart.push_back (aci); } }