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

@ -25,6 +25,8 @@
#include "../networkPacks/PacksForClient.h"
#include "../serializer/JsonSerializeFormat.h"
#include <vstd/RNG.h>
VCMI_LIB_NAMESPACE_BEGIN
//TODO: remove constructor
@ -164,12 +166,12 @@ void CGObjectInstance::setType(MapObjectID newID, MapObjectSubID newSubID)
cb->gameState()->map->addBlockVisTiles(this);
}
void CGObjectInstance::pickRandomObject(CRandomGenerator & rand)
void CGObjectInstance::pickRandomObject(vstd::RNG & rand)
{
// no-op
}
void CGObjectInstance::initObj(CRandomGenerator & rand)
void CGObjectInstance::initObj(vstd::RNG & rand)
{
// no-op
}
@ -232,7 +234,7 @@ std::string CGObjectInstance::getObjectName() const
return VLC->objtypeh->getObjectName(ID, subID);
}
std::optional<AudioPath> CGObjectInstance::getAmbientSound() const
std::optional<AudioPath> CGObjectInstance::getAmbientSound(vstd::RNG & rng) const
{
const auto & sounds = VLC->objtypeh->getObjectSounds(ID, subID).ambient;
if(!sounds.empty())
@ -241,20 +243,20 @@ std::optional<AudioPath> CGObjectInstance::getAmbientSound() const
return std::nullopt;
}
std::optional<AudioPath> CGObjectInstance::getVisitSound() const
std::optional<AudioPath> CGObjectInstance::getVisitSound(vstd::RNG & rng) const
{
const auto & sounds = VLC->objtypeh->getObjectSounds(ID, subID).visit;
if(!sounds.empty())
return *RandomGeneratorUtil::nextItem(sounds, CRandomGenerator::getDefault());
return *RandomGeneratorUtil::nextItem(sounds, rng);
return std::nullopt;
}
std::optional<AudioPath> CGObjectInstance::getRemovalSound() const
std::optional<AudioPath> CGObjectInstance::getRemovalSound(vstd::RNG & rng) const
{
const auto & sounds = VLC->objtypeh->getObjectSounds(ID, subID).removal;
if(!sounds.empty())
return *RandomGeneratorUtil::nextItem(sounds, CRandomGenerator::getDefault());
return *RandomGeneratorUtil::nextItem(sounds, rng);
return std::nullopt;
}