File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- // Copyright (C) 2005 - 2025 Settlers Freaks (sf-team at siedler25.org)
1+ // Copyright (C) 2005 - 2026 Settlers Freaks (sf-team at siedler25.org)
22//
33// SPDX-License-Identifier: GPL-2.0-or-later
44
@@ -29,20 +29,16 @@ inline bool random(unsigned total = 2u, unsigned chance = 1u)
2929}
3030
3131template <typename ContainerT>
32- inline unsigned randomIndex (const ContainerT& container)
32+ unsigned randomIndex (const ContainerT& container)
3333{
3434 RTTR_Assert (!container.empty ());
35- return randomValue ( 0u , static_cast < unsigned >( container.size ()) - 1u );
35+ return helpers::getRandomIndex ( getRandomGenerator (), container.size ());
3636}
3737
3838template <typename ContainerT>
39- inline auto randomElement (const ContainerT& container)
39+ auto randomElement (const ContainerT& container)
4040{
41- RTTR_Assert (!container.empty ());
42- auto it = container.begin ();
43- if (container.size () > 1u )
44- std::advance (it, randomIndex (container));
45- return *it;
41+ return helpers::getRandomElement (getRandomGenerator (), container);
4642}
4743
4844} // namespace AI
You can’t perform that action at this time.
0 commit comments