mirror of
https://github.com/1dot13/source.git
synced 2026-07-29 13:52:17 +02:00
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:
committed by
majcosta
parent
3cc3ade169
commit
c6a4fdb393
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user