Fix nested branches not being triggered.
This commit is contained in:
+24
-18
@@ -281,7 +281,7 @@ struct bmsCommandTree
|
|||||||
|
|
||||||
newNode->conditionValue = randomStack[currentNode->branchHeight];
|
newNode->conditionValue = randomStack[currentNode->branchHeight];
|
||||||
newNode->parent = currentNode;
|
newNode->parent = currentNode;
|
||||||
newNode->branchHeight = currentNode->branchHeight + 1;
|
newNode->branchHeight = currentNode->branchHeight;
|
||||||
newNode->conditionType = bmsNodeS::CT_CONDITIONALCHAIN;
|
newNode->conditionType = bmsNodeS::CT_CONDITIONALCHAIN;
|
||||||
|
|
||||||
currentNode->branches.push_back(newNode);
|
currentNode->branches.push_back(newNode);
|
||||||
@@ -294,7 +294,7 @@ struct bmsCommandTree
|
|||||||
|
|
||||||
newNode->conditionValue = randomStack[currentNode->branchHeight];
|
newNode->conditionValue = randomStack[currentNode->branchHeight];
|
||||||
newNode->parent = Chain;
|
newNode->parent = Chain;
|
||||||
newNode->branchHeight = currentNode->branchHeight + 1;
|
newNode->branchHeight = Chain->branchHeight + 1;
|
||||||
newNode->conditionTriggerValue = value;
|
newNode->conditionTriggerValue = value;
|
||||||
newNode->conditionType = bmsNodeS::CT_IF;
|
newNode->conditionType = bmsNodeS::CT_IF;
|
||||||
Chain->branches.push_back(newNode);
|
Chain->branches.push_back(newNode);
|
||||||
@@ -306,9 +306,9 @@ struct bmsCommandTree
|
|||||||
{
|
{
|
||||||
bmsNodeS *newNode = new bmsNodeS;
|
bmsNodeS *newNode = new bmsNodeS;
|
||||||
|
|
||||||
newNode->conditionValue = randomStack[currentNode->branchHeight];
|
newNode->conditionValue = randomStack[Chain->branchHeight];
|
||||||
newNode->parent = Chain;
|
newNode->parent = Chain;
|
||||||
newNode->branchHeight = currentNode->branchHeight + 1;
|
newNode->branchHeight = Chain->branchHeight + 1;
|
||||||
newNode->conditionTriggerValue = value;
|
newNode->conditionTriggerValue = value;
|
||||||
newNode->conditionType = bmsNodeS::CT_ELSEIF;
|
newNode->conditionType = bmsNodeS::CT_ELSEIF;
|
||||||
Chain->branches.push_back(newNode);
|
Chain->branches.push_back(newNode);
|
||||||
@@ -320,9 +320,9 @@ struct bmsCommandTree
|
|||||||
{
|
{
|
||||||
bmsNodeS *newNode = new bmsNodeS;
|
bmsNodeS *newNode = new bmsNodeS;
|
||||||
|
|
||||||
newNode->conditionValue = randomStack[currentNode->branchHeight];
|
newNode->conditionValue = randomStack[Chain->branchHeight];
|
||||||
newNode->parent = Chain;
|
newNode->parent = Chain;
|
||||||
newNode->branchHeight = currentNode->branchHeight + 1;
|
newNode->branchHeight = Chain->branchHeight + 1;
|
||||||
newNode->conditionType = bmsNodeS::CT_ELSE;
|
newNode->conditionType = bmsNodeS::CT_ELSE;
|
||||||
Chain->branches.push_back(newNode);
|
Chain->branches.push_back(newNode);
|
||||||
|
|
||||||
@@ -353,24 +353,31 @@ struct bmsCommandTree
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool evaluateNode(bmsNodeS* node, BMSHeaders &headersOut, vector<RString> &linesOut)
|
bool triggerBranches(bmsNodeS* node, BMSHeaders &headersOut, vector<RString> &linesOut)
|
||||||
{
|
{
|
||||||
switch (node->conditionType)
|
|
||||||
{
|
|
||||||
case bmsNodeS::CT_CONDITIONALCHAIN:
|
|
||||||
FOREACH(bmsNodeS*, node->branches, b)
|
FOREACH(bmsNodeS*, node->branches, b)
|
||||||
if (evaluateNode(*b, headersOut, linesOut))
|
if (evaluateNode(*b, headersOut, linesOut))
|
||||||
{
|
{
|
||||||
node->Triggered = true;
|
node->Triggered = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool evaluateNode(bmsNodeS* node, BMSHeaders &headersOut, vector<RString> &linesOut)
|
||||||
|
{
|
||||||
|
switch (node->conditionType)
|
||||||
|
{
|
||||||
|
case bmsNodeS::CT_CONDITIONALCHAIN:
|
||||||
|
triggerBranches(node, headersOut, linesOut);
|
||||||
|
break;
|
||||||
case bmsNodeS::CT_IF:
|
case bmsNodeS::CT_IF:
|
||||||
case bmsNodeS::CT_ELSEIF: // Their differences are solved at node creation time.
|
case bmsNodeS::CT_ELSEIF: // Their differences are solved at node creation time.
|
||||||
if (node->parent->conditionValue == node->conditionTriggerValue)
|
if (node->parent->conditionValue == node->conditionTriggerValue)
|
||||||
{
|
{
|
||||||
appendNodeElements(node, headersOut, linesOut);
|
appendNodeElements(node, headersOut, linesOut);
|
||||||
|
triggerBranches(node, headersOut, linesOut);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -378,16 +385,13 @@ struct bmsCommandTree
|
|||||||
if (!node->parent->Triggered) // we're the only branch left, so okay, evaluate.
|
if (!node->parent->Triggered) // we're the only branch left, so okay, evaluate.
|
||||||
{
|
{
|
||||||
appendNodeElements(node, headersOut, linesOut);
|
appendNodeElements(node, headersOut, linesOut);
|
||||||
|
triggerBranches(node, headersOut, linesOut);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case bmsNodeS::CT_NULL:
|
case bmsNodeS::CT_NULL:
|
||||||
appendNodeElements(node, headersOut, linesOut);
|
appendNodeElements(node, headersOut, linesOut);
|
||||||
FOREACH(bmsNodeS*, node->branches, b)
|
triggerBranches(node, headersOut, linesOut);
|
||||||
{
|
|
||||||
evaluateNode(*b, headersOut, linesOut);
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -427,8 +431,10 @@ struct bmsCommandTree
|
|||||||
{
|
{
|
||||||
if (randomStack.size() < currentNode->branchHeight + 1)
|
if (randomStack.size() < currentNode->branchHeight + 1)
|
||||||
{
|
{
|
||||||
LOG->UserLog("Song file", path, "Line %d: Missing #RANDOM. Warning: processing as part of parent branch!", line);
|
LOG->UserLog("Song file", path, "Line %d: Missing #RANDOM. Warning: Branch will be considered false!", line);
|
||||||
return;
|
|
||||||
|
while (randomStack.size() < currentNode->branchHeight + 1)
|
||||||
|
randomStack.push_back(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bmsNodeS *chain = addConditionalChain();
|
bmsNodeS *chain = addConditionalChain();
|
||||||
|
|||||||
Reference in New Issue
Block a user