mirror of
https://github.com/1dot13/source.git
synced 2026-07-29 13:52:17 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user