Fixed item distribution (signed numbers made the random number

negative, causing incorrect distribution of items).
This commit is contained in:
hiker 2018-08-02 18:03:42 +10:00
parent 0fa25db181
commit b164a35d91
2 changed files with 5 additions and 4 deletions

View File

@ -388,7 +388,7 @@ void PowerupManager::WeightsData::precomputeWeights()
* \param random_number A random number used to 'randomly' select the item
* that was picked.
*/
int PowerupManager::WeightsData::getRandomItem(int rank, int random_number)
int PowerupManager::WeightsData::getRandomItem(int rank, unsigned int random_number)
{
// E.g. for battle mode with only one entry
if(rank>(int)m_summed_weights_for_rank.size())
@ -571,7 +571,7 @@ void PowerupManager::computeWeightsForRace(int num_karts)
*/
PowerupManager::PowerupType PowerupManager::getRandomPowerup(unsigned int pos,
unsigned int *n,
int random_number)
unsigned int random_number)
{
int powerup = m_current_item_weights.getRandomItem(pos-1, random_number);
if(powerup > POWERUP_LAST)

View File

@ -107,7 +107,7 @@ private:
void convertRankToSection(int rank, int *prev, int *next,
float *weight);
void precomputeWeights();
int getRandomItem(int rank, int random_number);
int getRandomItem(int rank, unsigned int random_number);
// --------------------------------------------------------------------
/** Sets the number of karts. */
void setNumKarts(int num_karts) { m_num_karts = num_karts; }
@ -165,7 +165,8 @@ public:
void computeWeightsForRace(int num_karts);
void LoadPowerup (PowerupType type, const XMLNode &node);
PowerupManager::PowerupType
getRandomPowerup(unsigned int pos, unsigned int *n, int random_number);
getRandomPowerup(unsigned int pos, unsigned int *n,
unsigned int random_number);
// ------------------------------------------------------------------------
/** Returns the icon(material) for a powerup. */
Material* getIcon(int type) const {return m_all_icons [type];}