SpawnerList::random_id: avoid division by zero in PRNG function

This commit is contained in:
James R 2023-12-06 04:06:00 -08:00
parent 5329afd23c
commit 4931f32bb8

View file

@ -92,7 +92,12 @@ public:
auto it = list_.begin();
std::size_t count = std::distance(it, list_.end());
return std::next(it, P_RandomKey(PR_BATTLEUFO, count - 1u))->id();
if (count > 1u)
{
std::advance(it, P_RandomKey(PR_BATTLEUFO, count - 1u));
}
return it->id();
}
void spawn_ufo() const