mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Fix initialization of gold pile from random resource with fixed amount
This commit is contained in:
parent
f2d870e651
commit
c68f2da977
@ -263,6 +263,9 @@ void CGResource::pickRandomObject(CRandomGenerator & rand)
|
||||
ID = Obj::RESOURCE;
|
||||
subID = rand.nextInt(EGameResID::WOOD, EGameResID::GOLD);
|
||||
setType(ID, subID);
|
||||
|
||||
if (subID == EGameResID::GOLD && amount != CGResource::RANDOM_AMOUNT)
|
||||
amount *= CGResource::GOLD_AMOUNT_MULTIPLIER;
|
||||
}
|
||||
}
|
||||
|
||||
@ -275,7 +278,7 @@ void CGResource::initObj(CRandomGenerator & rand)
|
||||
switch(resourceID().toEnum())
|
||||
{
|
||||
case EGameResID::GOLD:
|
||||
amount = rand.nextInt(5, 10) * 100;
|
||||
amount = rand.nextInt(5, 10) * CGResource::GOLD_AMOUNT_MULTIPLIER;
|
||||
break;
|
||||
case EGameResID::WOOD: case EGameResID::ORE:
|
||||
amount = rand.nextInt(6, 10);
|
||||
|
@ -122,8 +122,9 @@ class DLL_LINKAGE CGResource : public CArmedInstance
|
||||
public:
|
||||
using CArmedInstance::CArmedInstance;
|
||||
|
||||
static constexpr ui32 RANDOM_AMOUNT = 0;
|
||||
ui32 amount = RANDOM_AMOUNT; //0 if random
|
||||
static constexpr uint32_t RANDOM_AMOUNT = 0;
|
||||
static constexpr uint32_t GOLD_AMOUNT_MULTIPLIER = 100;
|
||||
uint32_t amount = RANDOM_AMOUNT; //0 if random
|
||||
|
||||
MetaString message;
|
||||
|
||||
|
@ -1315,7 +1315,7 @@ CGObjectInstance * CMapLoaderH3M::readResource(const int3 & mapPosition, std::sh
|
||||
if(GameResID(objectTemplate->subid) == GameResID(EGameResID::GOLD))
|
||||
{
|
||||
// Gold is multiplied by 100.
|
||||
object->amount *= 100;
|
||||
object->amount *= CGResource::GOLD_AMOUNT_MULTIPLIER;
|
||||
}
|
||||
reader->skipZero(4);
|
||||
return object;
|
||||
|
Loading…
Reference in New Issue
Block a user