Skip to content

Commit

Permalink
Fix zero division in enchantment magnitude calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Capostrophic committed Apr 14, 2019
1 parent 5b8fc5a commit 2c473d8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/openmw/mwworld/inventorystore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,8 @@ void MWWorld::InventoryStore::updateMagicEffects(const Ptr& actor)
{
int delta = effect.mMagnMax - effect.mMagnMin;
// Roll some dice, one for each effect
params[i].mRandom = Misc::Rng::rollDice(delta + 1) / static_cast<float>(delta);
if (delta)
params[i].mRandom = Misc::Rng::rollDice(delta + 1) / static_cast<float>(delta);
// Try resisting each effect
params[i].mMultiplier = MWMechanics::getEffectMultiplier(effect.mEffectID, actor, actor);
++i;
Expand Down

2 comments on commit 2c473d8

@JordyMoos
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not this fix need to be applied here as well?

random[i] = Misc::Rng::rollDice(delta + 1) / static_cast<float>(delta);

@Capostrophic
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, delta is never zero there.

Please sign in to comment.