give the drug item draw an engine it can take by reference

std::uniform_int_distribution::operator() takes its engine by non-const
reference, and the call passes a freshly constructed std::mt19937 temporary.
MSVC binds it anyway; clang-cl reports

  error: no matching function for call to object of type
  'std::uniform_int_distribution<>'
  note: candidate function not viable: expects an lvalue for 1st argument

Naming the engine is enough. Behaviour is unchanged: the engine is still
seeded from std::random_device and still discarded after the single draw.
This commit is contained in:
Marco Antonio J. Costa
2026-07-23 19:29:55 -03:00
committed by majcosta
parent 3cc3ade169
commit c6a4fdb393
+2 -1
View File
@@ -1817,7 +1817,8 @@ void HandleRisksForSoldierFacilityAssignment( SOLDIERTYPE *pSoldier, UINT8 ubFac
}
else
{
INT16 sItemId = riskDrugItems[std::uniform_int_distribution<>(0, riskDrugItems.size() - 1)(std::mt19937{ std::random_device{}() })];
std::mt19937 engine{ std::random_device{}() };
INT16 sItemId = riskDrugItems[std::uniform_int_distribution<>(0, riskDrugItems.size() - 1)(engine)];
CreateItem(sItemId, Item[sItemId].usPortionSize, &gTempObject);