From 210a222b894caa3c8af38ccb6653db0fd8491f6e Mon Sep 17 00:00:00 2001 From: Renaud G Date: Sat, 2 Feb 2019 12:23:30 +0100 Subject: remove warnings --- die.cpp | 2 +- node/dicerollernode.cpp | 82 +++++++++++++++++++++++-------------------------- 2 files changed, 40 insertions(+), 44 deletions(-) diff --git a/die.cpp b/die.cpp index 5ba6137..3d372c8 100644 --- a/die.cpp +++ b/die.cpp @@ -155,7 +155,7 @@ void Die::roll(bool adding) quint64 Die::getFaces() const { - return abs(m_maxValue - m_base) + 1; + return std::abs(m_maxValue - m_base) + 1; } qint64 Die::getLastRolledValue() { diff --git a/node/dicerollernode.cpp b/node/dicerollernode.cpp index 06daf7f..44b9e0a 100644 --- a/node/dicerollernode.cpp +++ b/node/dicerollernode.cpp @@ -1,61 +1,57 @@ #include "dicerollernode.h" #include "die.h" - +#include #include #include -#include #include - - -DiceRollerNode::DiceRollerNode(qint64 max,qint64 min) - : m_max(max),m_diceResult(new DiceResult()),m_min(min),m_operator(Die::PLUS) +DiceRollerNode::DiceRollerNode(qint64 max, qint64 min) + : m_max(max), m_diceResult(new DiceResult()), m_min(min), m_operator(Die::PLUS) { - m_result=m_diceResult; + m_result= m_diceResult; } void DiceRollerNode::run(ExecutionNode* previous) { - m_previousNode = previous; - if(nullptr!=previous) + m_previousNode= previous; + if(nullptr != previous) { - Result* result=previous->getResult(); - if(nullptr!=result) + Result* result= previous->getResult(); + if(nullptr != result) { - m_diceCount = static_cast(result->getResult(Result::SCALAR).toReal()); + m_diceCount= static_cast(result->getResult(Result::SCALAR).toReal()); m_result->setPrevious(result); if(m_diceCount == 0) { - m_errors.insert(NO_DICE_TO_ROLL,QObject::tr("No dice to roll")); + m_errors.insert(NO_DICE_TO_ROLL, QObject::tr("No dice to roll")); } - auto possibleValue = static_cast(abs((m_max-m_min)+1)); - if( possibleValue < m_diceCount && m_unique) + auto possibleValue= static_cast(std::abs((m_max - m_min) + 1)); + if(possibleValue < m_diceCount && m_unique) { - m_errors.insert(TOO_MANY_DICE,QObject::tr("More unique values asked than possible values (D operator)")); + m_errors.insert( + TOO_MANY_DICE, QObject::tr("More unique values asked than possible values (D operator)")); return; } - for(quint64 i=0; i < m_diceCount ; ++i) + for(quint64 i= 0; i < m_diceCount; ++i) { - Die* die = new Die(); + Die* die= new Die(); die->setOp(m_operator); die->setBase(m_min); die->setMaxValue(m_max); die->roll(); if(m_unique) { - const auto& equal = [](const Die* a,const Die* b){ - return a->getValue() == b->getValue(); - }; - while(m_diceResult->contains(die,equal)) + const auto& equal= [](const Die* a, const Die* b) { return a->getValue() == b->getValue(); }; + while(m_diceResult->contains(die, equal)) { die->roll(false); } } m_diceResult->insertResult(die); } - if(nullptr!=m_nextNode) + if(nullptr != m_nextNode) { m_nextNode->run(this); } @@ -65,37 +61,37 @@ void DiceRollerNode::run(ExecutionNode* previous) quint64 DiceRollerNode::getFaces() const { - return abs(m_max-m_min)+1; + return std::abs(m_max - m_min) + 1; } -std::pair DiceRollerNode::getRange() const +std::pair DiceRollerNode::getRange() const { - return std::make_pair(m_min,m_max); + return std::make_pair(m_min, m_max); } QString DiceRollerNode::toString(bool wl) const { - if(wl) - { + if(wl) + { return QString("%1 [label=\"DiceRollerNode faces: %2\"]").arg(m_id).arg(getFaces()); - } - else - { - return m_id; - } + } + else + { + return m_id; + } } qint64 DiceRollerNode::getPriority() const { - qint64 priority=4; -// if(nullptr!=m_nextNode) -// { -// priority = m_nextNode->getPriority(); -// } + qint64 priority= 4; + // if(nullptr!=m_nextNode) + // { + // priority = m_nextNode->getPriority(); + // } return priority; } ExecutionNode* DiceRollerNode::getCopy() const { - DiceRollerNode* node = new DiceRollerNode(m_max,m_min); - if(nullptr!=m_nextNode) + DiceRollerNode* node= new DiceRollerNode(m_max, m_min); + if(nullptr != m_nextNode) { node->setNextNode(m_nextNode->getCopy()); } @@ -107,9 +103,9 @@ Die::ArithmeticOperator DiceRollerNode::getOperator() const return m_operator; } -void DiceRollerNode::setOperator(const Die::ArithmeticOperator &dieOperator) +void DiceRollerNode::setOperator(const Die::ArithmeticOperator& dieOperator) { - m_operator = dieOperator; + m_operator= dieOperator; m_diceResult->setOperator(dieOperator); } @@ -120,5 +116,5 @@ bool DiceRollerNode::getUnique() const void DiceRollerNode::setUnique(bool unique) { - m_unique = unique; + m_unique= unique; } -- cgit v1.2.3-70-g09d2