1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Replaced most of usages of CRandomGenerator with vstd::RNG in library

This commit is contained in:
Ivan Savenko
2024-06-01 15:28:17 +00:00
parent 60a51e98de
commit 63bcf7d83c
125 changed files with 620 additions and 409 deletions

View File

@ -31,6 +31,8 @@
#include "../networkPacks/PacksForClientBattle.h"
#include "../serializer/JsonSerializeFormat.h"
#include <vstd/RNG.h>
VCMI_LIB_NAMESPACE_BEGIN
int CGTownInstance::getSightRadius() const //returns sight distance
@ -379,7 +381,7 @@ bool CGTownInstance::isBonusingBuildingAdded(BuildingID bid) const
return present != bonusingBuildings.end();
}
void CGTownInstance::addTownBonuses(CRandomGenerator & rand)
void CGTownInstance::addTownBonuses(vstd::RNG & rand)
{
for(const auto & kvp : town->buildings)
{
@ -461,7 +463,7 @@ void CGTownInstance::deleteTownBonus(BuildingID bid)
delete freeIt;
}
FactionID CGTownInstance::randomizeFaction(CRandomGenerator & rand)
FactionID CGTownInstance::randomizeFaction(vstd::RNG & rand)
{
if(getOwner().isValidPlayer())
return cb->gameState()->scenarioOps->getIthPlayersSettings(getOwner()).castle;
@ -479,7 +481,7 @@ FactionID CGTownInstance::randomizeFaction(CRandomGenerator & rand)
return *RandomGeneratorUtil::nextItem(potentialPicks, rand);
}
void CGTownInstance::pickRandomObject(CRandomGenerator & rand)
void CGTownInstance::pickRandomObject(vstd::RNG & rand)
{
assert(ID == MapObjectID::TOWN || ID == MapObjectID::RANDOM_TOWN);
if (ID == MapObjectID::RANDOM_TOWN)
@ -495,7 +497,7 @@ void CGTownInstance::pickRandomObject(CRandomGenerator & rand)
updateAppearance();
}
void CGTownInstance::initObj(CRandomGenerator & rand) ///initialize town structures
void CGTownInstance::initObj(vstd::RNG & rand) ///initialize town structures
{
blockVisit = true;
@ -521,7 +523,7 @@ void CGTownInstance::initObj(CRandomGenerator & rand) ///initialize town structu
updateAppearance();
}
void CGTownInstance::newTurn(CRandomGenerator & rand) const
void CGTownInstance::newTurn(vstd::RNG & rand) const
{
if (cb->getDate(Date::DAY_OF_WEEK) == 1) //reset on new week
{