Bugfix: "Merc Random Stats Feature" (by Jenilee)

- Fixed crash on initializing armor when starting a new game

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6679 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Wanne
2013-12-03 21:14:58 +00:00
parent 689cbbc5ab
commit b7ee1b8979
+6 -2
View File
@@ -486,6 +486,10 @@ INVTYPE* GearGetRandomArmor(std::vector<INVTYPE*>* pointer, INT8 min_coolness =
if (pointer == NULL)
return NULL;
//safety net for low LBE counts (including 1.13 vanilla!)
if (pointer->size() < 20)
return pointer->at(Random(pointer->size()));
std::vector<INVTYPE*> candidates;
for (std::vector<INVTYPE*>::iterator it = pointer->begin(); it != pointer->end(); it++)
@@ -516,9 +520,9 @@ INVTYPE* GearGetRandomArmor(std::vector<INVTYPE*>* pointer, INT8 min_coolness =
}
if (candidates.size() < 1)
return GearGetRandomArmor(pointer, -1, 1); //get some random, basic armor instead.
return NULL;
return candidates[Random(candidates.size())];
return candidates[ Random( candidates.size() ) ];
}
//generate a random weapon of requested type, class and BR coolness