aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/die.cpp
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2015-05-06 11:00:50 +0200
committerRenaud G <renaud@rolisteam.org>2015-05-06 11:00:50 +0200
commitdba610b6f1a31f8791fbc9baa6cf360bf62c72e9 (patch)
treed0f28b56e34c36fdbc6d28a14d24c96855a44e52 /die.cpp
parent4ce233c2f8397c9792c3668b49e670a9dccdef95 (diff)
downloadOneRoll-dba610b6f1a31f8791fbc9baa6cf360bf62c72e9.tar.gz
OneRoll-dba610b6f1a31f8791fbc9baa6cf360bf62c72e9.zip
prevent crash with die with zero faces
Diffstat (limited to 'die.cpp')
-rw-r--r--die.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/die.cpp b/die.cpp
index 4782705..28be07c 100644
--- a/die.cpp
+++ b/die.cpp
@@ -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);
+ }
}
}