1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-12-01 23:12:49 +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

@@ -26,6 +26,8 @@
#include "WaterProxy.h"
#include "TownPlacer.h"
#include <vstd/RNG.h>
VCMI_LIB_NAMESPACE_BEGIN
std::pair<Zone::Lock, Zone::Lock> ConnectionsPlacer::lockZones(std::shared_ptr<Zone> otherZone)

View File

@@ -22,6 +22,8 @@
#include "WaterAdopter.h"
#include "../TileInfo.h"
#include <vstd/RNG.h>
VCMI_LIB_NAMESPACE_BEGIN
void MinePlacer::process()

View File

@@ -25,6 +25,8 @@
#include "../Functions.h"
#include "../RmgObject.h"
#include <vstd/RNG.h>
VCMI_LIB_NAMESPACE_BEGIN
void ObjectDistributor::process()

View File

@@ -29,6 +29,8 @@
#include "../Functions.h"
#include "../RmgObject.h"
#include <vstd/RNG.h>
VCMI_LIB_NAMESPACE_BEGIN
void ObjectManager::process()

View File

@@ -19,7 +19,6 @@
#include "RiverPlacer.h"
#include "../RmgMap.h"
#include "../CMapGenerator.h"
#include "../../CRandomGenerator.h"
#include "../Functions.h"
#include "../../mapping/CMapEditManager.h"
#include "../../mapping/CMap.h"

View File

@@ -17,7 +17,9 @@
#include "../../VCMI_Lib.h"
#include "../../mapObjectConstructors/AObjectTypeHandler.h"
#include "../../mapObjectConstructors/CObjectClassesHandler.h"
#include "../../mapObjects/MapObjects.h"
#include "../../mapObjects/MapObjects.h"
#include <vstd/RNG.h>
VCMI_LIB_NAMESPACE_BEGIN

View File

@@ -15,8 +15,6 @@
VCMI_LIB_NAMESPACE_BEGIN
class CRandomGenerator;
class PrisonHeroPlacer : public Modificator
{
public:

View File

@@ -17,7 +17,9 @@
#include "../../VCMI_Lib.h"
#include "../../mapObjectConstructors/AObjectTypeHandler.h"
#include "../../mapObjectConstructors/CObjectClassesHandler.h"
#include "../../mapObjects/MapObjects.h"
#include "../../mapObjects/MapObjects.h"
#include <vstd/RNG.h>
VCMI_LIB_NAMESPACE_BEGIN
@@ -95,7 +97,7 @@ void QuestArtifactPlacer::findZonesForQuestArts()
logGlobal->trace("Number of nearby zones suitable for quest artifacts: %d", questArtZones.size());
}
void QuestArtifactPlacer::placeQuestArtifacts(CRandomGenerator & rand)
void QuestArtifactPlacer::placeQuestArtifacts(vstd::RNG & rand)
{
for (const auto & artifactToPlace : questArtifactsToPlace)
{

View File

@@ -15,8 +15,6 @@
VCMI_LIB_NAMESPACE_BEGIN
class CRandomGenerator;
class QuestArtifactPlacer : public Modificator
{
public:
@@ -33,7 +31,7 @@ public:
void rememberPotentialArtifactToReplace(CGObjectInstance* obj);
CGObjectInstance * drawObjectToReplace();
std::vector<CGObjectInstance*> getPossibleArtifactsToReplace() const;
void placeQuestArtifacts(CRandomGenerator & rand);
void placeQuestArtifacts(vstd::RNG & rand);
void dropReplacedArtifact(CGObjectInstance* obj);
size_t getMaxQuestArtifactCount() const;
@@ -50,4 +48,4 @@ protected:
std::vector<ArtifactID> questArtifacts;
};
VCMI_LIB_NAMESPACE_END
VCMI_LIB_NAMESPACE_END

View File

@@ -27,6 +27,8 @@
#include "WaterProxy.h"
#include "RoadPlacer.h"
#include <vstd/RNG.h>
VCMI_LIB_NAMESPACE_BEGIN
const int RIVER_DELTA_ID = 143;

View File

@@ -19,7 +19,6 @@
#include "../CMapGenerator.h"
#include "../Functions.h"
#include "../../TerrainHandler.h"
#include "../../CRandomGenerator.h"
#include "../lib/mapping/CMapEditManager.h"
#include "../TileInfo.h"
#include "../threadpool/MapProxy.h"

View File

@@ -18,7 +18,6 @@
#include "../CMapGenerator.h"
#include "../Functions.h"
#include "../../TerrainHandler.h"
#include "../../CRandomGenerator.h"
#include "../../mapping/CMapEditManager.h"
#include "../../VCMI_Lib.h"
#include "../TileInfo.h"

View File

@@ -22,6 +22,8 @@
#include "../../TerrainHandler.h"
#include "../../CTownHandler.h"
#include <vstd/RNG.h>
VCMI_LIB_NAMESPACE_BEGIN
void TerrainPainter::process()

View File

@@ -27,6 +27,8 @@
#include "WaterAdopter.h"
#include "../TileInfo.h"
#include <vstd/RNG.h>
VCMI_LIB_NAMESPACE_BEGIN
void TownPlacer::process()

View File

@@ -33,6 +33,8 @@
#include "../../mapping/CMap.h"
#include "../../mapping/CMapEditManager.h"
#include <vstd/RNG.h>
VCMI_LIB_NAMESPACE_BEGIN
ObjectInfo::ObjectInfo():
@@ -649,7 +651,7 @@ std::vector<ObjectInfo*> TreasurePlacer::prepareTreasurePile(const CTreasureInfo
if (currentValue >= minValue)
{
// 50% chance to end right here
if (zone.getRand().nextInt() & 1)
if (zone.getRand().nextInt(0, 1) == 1)
break;
}
}

View File

@@ -18,7 +18,6 @@ class CGObjectInstance;
class ObjectManager;
class RmgMap;
class CMapGenerator;
class CRandomGenerator;
struct ObjectInfo
{

View File

@@ -23,6 +23,8 @@
#include "ConnectionsPlacer.h"
#include "../TileInfo.h"
#include <vstd/RNG.h>
VCMI_LIB_NAMESPACE_BEGIN
void WaterAdopter::process()

View File

@@ -30,6 +30,8 @@
#include "WaterAdopter.h"
#include "../RmgArea.h"
#include <vstd/RNG.h>
VCMI_LIB_NAMESPACE_BEGIN
void WaterProxy::process()