aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2017-01-27 23:08:33 +0100
committerRenaud G <renaud@rolisteam.org>2017-01-27 23:08:33 +0100
commit2ebb2016f7ff7d4a86f13e1350c9d4b03b3a47eb (patch)
tree86342fa0df9ade6092efaa7a0363dc70e515b9d5
parentfbd6780d707769aa57e0ba3d9bd6f088e538535b (diff)
downloadOneRoll-2ebb2016f7ff7d4a86f13e1350c9d4b03b3a47eb.tar.gz
OneRoll-2ebb2016f7ff7d4a86f13e1350c9d4b03b3a47eb.zip
-Fix issue with Math priority : 5-5*5+5 is working now.
-rw-r--r--diceparser.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/diceparser.cpp b/diceparser.cpp
index f2e3104..dc18903 100644
--- a/diceparser.cpp
+++ b/diceparser.cpp
@@ -753,11 +753,27 @@ bool DiceParser::readOperator(QString& str,ExecutionNode* previous)
delete node;
return false;
}
- if(node->getPriority()>=nodeExec->getPriority())
+ ExecutionNode* nodeExecOrChild = nodeExec;
+ ExecutionNode* parent = NULL;
+
+ while((nullptr!=nodeExecOrChild) && (node->getPriority()<nodeExecOrChild->getPriority()))
{
- node->setNextNode(nodeExec->getNextNode());
- nodeExec->setNextNode(NULL);
+ parent = nodeExecOrChild;
+ nodeExecOrChild = nodeExecOrChild->getNextNode();
}
+
+ if((nullptr != nodeExecOrChild)&&(nodeExec != nodeExecOrChild))
+ {
+ node->setNextNode(nodeExecOrChild);
+ parent->setNextNode(NULL);
+ }
+ else
+ {
+ node->setNextNode(nodeExecOrChild->getNextNode());
+ nodeExecOrChild->setNextNode(NULL);
+ }
+
+
previous->setNextNode(node);
return true;