mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +02:00
ASD/ARC: Fix Error by One in gasCan Vector (#472)
* ASD/ARC: Fix Error by One in gasCan Vector * Add size check for the gasCan vector as part of ARC * Remove unused Vectors for ARC
This commit is contained in:
@@ -129,21 +129,10 @@ namespace ItemIdCache
|
|||||||
{
|
{
|
||||||
// cache these values on load so that we don't need to search for them every time something happens
|
// cache these values on load so that we don't need to search for them every time something happens
|
||||||
std::vector<UINT16> gasCans;
|
std::vector<UINT16> gasCans;
|
||||||
std::vector<UINT16> firstAidKits;
|
|
||||||
std::vector<UINT16> medKits;
|
|
||||||
std::vector<UINT16> toolKits;
|
|
||||||
std::vector<UINT16> ammo[10]; // coolness
|
|
||||||
|
|
||||||
void Clear()
|
void Clear()
|
||||||
{
|
{
|
||||||
gasCans.clear();
|
gasCans.clear();
|
||||||
firstAidKits.clear();
|
|
||||||
medKits.clear();
|
|
||||||
toolKits.clear();
|
|
||||||
for (int i = 0; i < 10; ++i)
|
|
||||||
{
|
|
||||||
ammo[i].clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4418,23 +4407,6 @@ void SetupInfo()
|
|||||||
for (UINT16 i = 0; i < MAXITEMS; ++i)
|
for (UINT16 i = 0; i < MAXITEMS; ++i)
|
||||||
{
|
{
|
||||||
if (ItemIsGascan(i)) ItemIdCache::gasCans.push_back(i);
|
if (ItemIsGascan(i)) ItemIdCache::gasCans.push_back(i);
|
||||||
else if (ItemIsFirstAidKit(i)) ItemIdCache::firstAidKits.push_back(i);
|
|
||||||
else if (ItemIsMedicalKit(i)) ItemIdCache::medKits.push_back(i);
|
|
||||||
else if (ItemIsToolkit(i)) ItemIdCache::toolKits.push_back(i);
|
|
||||||
else if (Item[i].usItemClass & IC_AMMO)
|
|
||||||
{
|
|
||||||
if (Magazine[Item[i].ubClassIndex].ubMagType == AMMO_BOX)
|
|
||||||
{
|
|
||||||
if ((gGameOptions.fGunNut || !ItemIsOnlyInTonsOfGuns(i))
|
|
||||||
&& (gGameOptions.ubGameStyle == STYLE_SCIFI || !ItemIsOnlyInScifi(i)))
|
|
||||||
{
|
|
||||||
// coolness runs from 1-10, so apply offset
|
|
||||||
const UINT8 coolness = min(max(1, Item[i].ubCoolness), 10);
|
|
||||||
ItemIdCache::ammo[coolness-1].push_back(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4772,8 +4744,10 @@ void ApplyAdditionalASDEffects()
|
|||||||
{
|
{
|
||||||
case MissionHelpers::DISRUPT_ASD_STEAL_FUEL:
|
case MissionHelpers::DISRUPT_ASD_STEAL_FUEL:
|
||||||
{
|
{
|
||||||
// spawn a gas can
|
// only spawn a gas can if at least one gas can is known by the game (ItemIsGascan)
|
||||||
CreateItemAtAirport(ItemIdCache::gasCans.at(ItemIdCache::gasCans.size()), 75 + Random(26));
|
if (ItemIdCache::gasCans.size() > 0)
|
||||||
|
// The gas can is spawned like a Bobby Ray delivery (you need to open the crate)
|
||||||
|
CreateItemAtAirport(ItemIdCache::gasCans.at(ItemIdCache::gasCans.size() -1), 75 + Random(26));
|
||||||
|
|
||||||
// say it came from the ASD's reserves
|
// say it came from the ASD's reserves
|
||||||
AddStrategicAIResources(ASD_FUEL, -(gGameExternalOptions.gASDResource_Fuel_Jeep + Random(gGameExternalOptions.gASDResource_Fuel_Jeep)));
|
AddStrategicAIResources(ASD_FUEL, -(gGameExternalOptions.gASDResource_Fuel_Jeep + Random(gGameExternalOptions.gASDResource_Fuel_Jeep)));
|
||||||
|
|||||||
Reference in New Issue
Block a user