diff options
| author | 2015-05-06 11:00:50 +0200 | |
|---|---|---|
| committer | 2015-05-06 11:00:50 +0200 | |
| commit | dba610b6f1a31f8791fbc9baa6cf360bf62c72e9 (patch) | |
| tree | d0f28b56e34c36fdbc6d28a14d24c96855a44e52 /die.cpp | |
| parent | 4ce233c2f8397c9792c3668b49e670a9dccdef95 (diff) | |
| download | OneRoll-dba610b6f1a31f8791fbc9baa6cf360bf62c72e9.tar.gz OneRoll-dba610b6f1a31f8791fbc9baa6cf360bf62c72e9.zip | |
prevent crash with die with zero faces
Diffstat (limited to 'die.cpp')
| -rw-r--r-- | die.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -95,15 +95,17 @@ void Die::replaceLastValue(qint64 value) void Die::roll(bool adding) { - quint64 value=(qrand()%m_faces)+1; - - if((adding)||(m_rollResult.isEmpty())) - { - insertRollValue(value); - } - else + if(m_faces!=0) { - replaceLastValue(value); + quint64 value=(qrand()%m_faces)+1; + if((adding)||(m_rollResult.isEmpty())) + { + insertRollValue(value); + } + else + { + replaceLastValue(value); + } } } |