Skip to content

Commit

Permalink
"Gnomish Shrink Ray" fix with roll
Browse files Browse the repository at this point in the history
The author assumed that the roll variable would be assigned with a
random value, and then this value would be compared with 3. However, the
priority of the comparison operation is higher than of the assignment
operation (see the table "Operation priorities in C/C++", so the random
number will be compared with 3 first, and then the result of the
comparison (0 or 1) will be written to the roll variable.

Close cmangos/mangos-classic#258

(based on cmangos/mangos-wotlk@c7c1fc302)

Signed-off-by: Xfurry <xfurry.cmangos@outlook.com>
  • Loading branch information
catterpiler74 authored and xfurry committed Jan 3, 2018
1 parent 9e107e6 commit ba2a737
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/game/Spells/SpellEffects.cpp
Expand Up @@ -891,8 +891,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect)
{
if (unitTarget && m_CastItem)
{
uint32 roll = urand(0, 99);
// These rates are hella random; someone feel free to correct them
if (uint32 roll = urand(0, 99) < 3) // Whole party will grow
if (roll < 3) // Whole party will grow
m_caster->CastSpell(m_caster, 13004, TRIGGERED_OLD_TRIGGERED);
else if (roll < 6) // Whole party will shrink
m_caster->CastSpell(m_caster, 13010, TRIGGERED_OLD_TRIGGERED);
Expand Down

0 comments on commit ba2a737

Please sign in to comment.