1
0

Changed type of FastRandom in monster drop calculation. (#3920)

* Fixed type of FastRandom in monster drop calculation.

* Distribute dropped items into stacks.

* Moved while loop outside if statement.
This commit is contained in:
Lane Kolbly 2017-08-18 05:23:08 -05:00 committed by Tiger Wang
parent 5e81024f89
commit 8f1ddfa6c3

View File

@ -5,6 +5,7 @@
#include "../Root.h"
#include "../Server.h"
#include "../ClientHandle.h"
#include "../Items/ItemHandler.h"
#include "../World.h"
#include "../EffectID.h"
#include "../Entities/Player.h"
@ -1093,7 +1094,13 @@ std::unique_ptr<cMonster> cMonster::NewMonsterFromType(eMonsterType a_MobType)
void cMonster::AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth)
{
auto Count = GetRandomProvider().RandInt<char>(static_cast<char>(a_Min), static_cast<char>(a_Max));
auto Count = GetRandomProvider().RandInt<unsigned int>(a_Min, a_Max);
auto MaxStackSize = static_cast<unsigned char>(ItemHandler(a_Item)->GetMaxStackSize());
while (Count > MaxStackSize)
{
a_Drops.emplace_back(a_Item, MaxStackSize, a_ItemHealth);
Count -= MaxStackSize;
}
if (Count > 0)
{
a_Drops.emplace_back(a_Item, Count, a_ItemHealth);