mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
SpawnerList::random_id: avoid division by zero in PRNG function
This commit is contained in:
parent
5329afd23c
commit
4931f32bb8
1 changed files with 6 additions and 1 deletions
|
|
@ -92,7 +92,12 @@ public:
|
||||||
auto it = list_.begin();
|
auto it = list_.begin();
|
||||||
std::size_t count = std::distance(it, list_.end());
|
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
|
void spawn_ufo() const
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue