Skip to content

Commit 2da88e0

Browse files
committed
Added safety for grabbing a number string in a node that goes above 64
1 parent 7120b14 commit 2da88e0

File tree

11 files changed

+92
-80
lines changed

11 files changed

+92
-80
lines changed

Runtime/Scripts/Interactivity/Playback/Context/Export/InteractivityExportContext.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ public override void AfterSceneExport(GLTFSceneExporter exporter, GLTFRoot gltfR
3636
foreach (var transform in exporter.RootTransforms)
3737
{
3838
t = transform;
39+
40+
if (t.TryGetComponent(out wrapper))
41+
break;
42+
3943
while (t.parent != null)
4044
{
4145
if (t.parent.TryGetComponent(out wrapper))

Runtime/Scripts/Interactivity/Playback/Data/Helpers/Constants.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,15 @@ public static class ConstStrings
121121
A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P
122122
};
123123

124-
public static readonly string[] Numbers = new string[]
124+
public static string GetNumberString(int i)
125+
{
126+
if (i > 0 && i < _numbers.Length)
127+
return _numbers[i];
128+
129+
return i.ToString();
130+
}
131+
132+
private static readonly string[] _numbers = new string[]
125133
{
126134
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15",
127135
"16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31",

Runtime/Scripts/Interactivity/Playback/Nodes/Variable/SetMultiple.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected override void Execute(string socket, ValidationResult validationResult
2525
{
2626
index = _variableIndices[i];
2727

28-
if (!TryEvaluateValue(ConstStrings.Numbers[index], out IProperty value))
28+
if (!TryEvaluateValue(ConstStrings.GetNumberString(i), out IProperty value))
2929
continue;
3030

3131
variable = engine.graph.variables[index];

Tests/Runtime/Interactivity/Nodes/Common/NodeTestHelpers.cs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -269,67 +269,67 @@ private static void GenerateGraphByExpectedValueType(Dictionary<string, IPropert
269269
var f2Val = ((Property<float2>)expected.Value).value;
270270
for (int i = 0; i < 2; i++)
271271
{
272-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[i], f2Val[i], subGraph);
272+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(i), f2Val[i], subGraph);
273273
}
274274
break;
275275
case Property<float3>:
276276
node = CreateExtractNode(g, "math/extract3", opNode, out value, out node, expected);
277277
var f3Val = ((Property<float3>)expected.Value).value;
278278
for (int i = 0; i < 3; i++)
279279
{
280-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[i], f3Val[i], subGraph);
280+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(i), f3Val[i], subGraph);
281281
}
282282
break;
283283
case Property<float4>:
284284
node = CreateExtractNode(g, "math/extract4", opNode, out value, out node, expected);
285285
var f4Val = ((Property<float4>)expected.Value).value;
286286
for (int i = 0; i < 4; i++)
287287
{
288-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[i], f4Val[i], subGraph);
288+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(i), f4Val[i], subGraph);
289289
}
290290
break;
291291
case Property<float2x2>:
292292
node = CreateExtractNode(g, "math/extract2x2", opNode, out value, out node, expected);
293293
var f2x2Val = ((Property<float2x2>)expected.Value).value;
294-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[0], f2x2Val.c0.x, subGraph);
295-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[1], f2x2Val.c0.y, subGraph);
296-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[2], f2x2Val.c1.x, subGraph);
297-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[3], f2x2Val.c1.y, subGraph);
294+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(0), f2x2Val.c0.x, subGraph);
295+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(1), f2x2Val.c0.y, subGraph);
296+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(2), f2x2Val.c1.x, subGraph);
297+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(3), f2x2Val.c1.y, subGraph);
298298
break;
299299

300300
case Property<float3x3>:
301301
node = CreateExtractNode(g, "math/extract3x3", opNode, out value, out node, expected);
302302
var f3x3Val = ((Property<float3x3>)expected.Value).value;
303-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[0], f3x3Val.c0.x, subGraph);
304-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[1], f3x3Val.c0.y, subGraph);
305-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[2], f3x3Val.c0.z, subGraph);
306-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[3], f3x3Val.c1.x, subGraph);
307-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[4], f3x3Val.c1.y, subGraph);
308-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[5], f3x3Val.c1.z, subGraph);
309-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[6], f3x3Val.c2.x, subGraph);
310-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[7], f3x3Val.c2.y, subGraph);
311-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[8], f3x3Val.c2.z, subGraph);
303+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(0), f3x3Val.c0.x, subGraph);
304+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(1), f3x3Val.c0.y, subGraph);
305+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(2), f3x3Val.c0.z, subGraph);
306+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(3), f3x3Val.c1.x, subGraph);
307+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(4), f3x3Val.c1.y, subGraph);
308+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(5), f3x3Val.c1.z, subGraph);
309+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(6), f3x3Val.c2.x, subGraph);
310+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(7), f3x3Val.c2.y, subGraph);
311+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(8), f3x3Val.c2.z, subGraph);
312312
break;
313313

314314
case Property<float4x4>:
315315
node = CreateExtractNode(g, "math/extract4x4", opNode, out value, out node, expected);
316316
var f4x4Val = ((Property<float4x4>)expected.Value).value;
317-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[0], f4x4Val.c0.x, subGraph);
318-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[1], f4x4Val.c0.y, subGraph);
319-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[2], f4x4Val.c0.z, subGraph);
320-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[3], f4x4Val.c0.w, subGraph);
321-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[4], f4x4Val.c1.x, subGraph);
322-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[5], f4x4Val.c1.y, subGraph);
323-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[6], f4x4Val.c1.z, subGraph);
324-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[7], f4x4Val.c1.w, subGraph);
325-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[8], f4x4Val.c2.x, subGraph);
326-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[9], f4x4Val.c2.y, subGraph);
327-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[10], f4x4Val.c2.z, subGraph);
328-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[11], f4x4Val.c2.w, subGraph);
329-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[12], f4x4Val.c3.x, subGraph);
330-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[13], f4x4Val.c3.y, subGraph);
331-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[14], f4x4Val.c3.z, subGraph);
332-
CreateSingleValueTestSubGraph(g, node, ConstStrings.Numbers[15], f4x4Val.c3.w, subGraph);
317+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(0), f4x4Val.c0.x, subGraph);
318+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(1), f4x4Val.c0.y, subGraph);
319+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(2), f4x4Val.c0.z, subGraph);
320+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(3), f4x4Val.c0.w, subGraph);
321+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(4), f4x4Val.c1.x, subGraph);
322+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(5), f4x4Val.c1.y, subGraph);
323+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(6), f4x4Val.c1.z, subGraph);
324+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(7), f4x4Val.c1.w, subGraph);
325+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(8), f4x4Val.c2.x, subGraph);
326+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(9), f4x4Val.c2.y, subGraph);
327+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(10), f4x4Val.c2.z, subGraph);
328+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(11), f4x4Val.c2.w, subGraph);
329+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(12), f4x4Val.c3.x, subGraph);
330+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(13), f4x4Val.c3.y, subGraph);
331+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(14), f4x4Val.c3.z, subGraph);
332+
CreateSingleValueTestSubGraph(g, node, ConstStrings.GetNumberString(15), f4x4Val.c3.w, subGraph);
333333
break;
334334

335335
}

Tests/Runtime/Interactivity/Nodes/Event/EventNodeTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ private static Graph CreateEventReceiveWithValuesTestGraph()
169169

170170
fail.AddConfiguration(ConstStrings.EVENT, FAIL_EVENT_INDEX);
171171

172-
sequence.AddFlow(branch, ConstStrings.Numbers[i]);
172+
sequence.AddFlow(branch, ConstStrings.GetNumberString(i));
173173
}
174174

175-
sequence.AddFlow(complete, ConstStrings.Numbers[values.Count]);
175+
sequence.AddFlow(complete, ConstStrings.GetNumberString(values.Count));
176176

177177
complete.AddConfiguration(ConstStrings.EVENT, COMPLETED_EVENT_INDEX);
178178

@@ -252,10 +252,10 @@ private static Graph CreateEventReceiveWithNoSendCheckOutputValuesTestGraph()
252252

253253
fail.AddConfiguration(ConstStrings.EVENT, FAIL_EVENT_INDEX);
254254

255-
sequence.AddFlow(branch, ConstStrings.Numbers[i]);
255+
sequence.AddFlow(branch, ConstStrings.GetNumberString(i));
256256
}
257257

258-
sequence.AddFlow(complete, ConstStrings.Numbers[values.Count]);
258+
sequence.AddFlow(complete, ConstStrings.GetNumberString(values.Count));
259259

260260
complete.AddConfiguration(ConstStrings.EVENT, COMPLETED_EVENT_INDEX);
261261

Tests/Runtime/Interactivity/Nodes/Flow/FlowNodesTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ private static Graph CreateFlowSequenceGraph(int numOutFlows)
210210
branch.AddFlow(complete, ConstStrings.TRUE);
211211
}
212212

213-
sequenceNode.AddFlow(branch, ConstStrings.Numbers[i]);
213+
sequenceNode.AddFlow(branch, ConstStrings.GetNumberString(i));
214214
}
215215

216216
return g;
@@ -320,7 +320,7 @@ private static Graph CreateSwitchGraph()
320320
for (int i = 0; i < outputFlowOrder.Length; i++)
321321
{
322322
var subGraphEntry = CreateSwitchFlowSubGraph(g, outputFlowOrder[i], 1 << i, flowIndexVariableIndex, bitmaskVariableIndex);
323-
switchNode.AddFlow(subGraphEntry, ConstStrings.Numbers[i]);
323+
switchNode.AddFlow(subGraphEntry, ConstStrings.GetNumberString(i));
324324

325325
expected |= 1 << i;
326326
}

Tests/Runtime/Interactivity/Nodes/Flow/MultiGateTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private static Graph GenerateMultiGateTestGraph(int outputs)
5656
for (int i = 0; i < outputs - 1; i++)
5757
{
5858
var subGraphEntry = CreateMultiGateFlowSubGraph(g, 1 << i, flowIndexVariableIndex, bitmaskVariableIndex);
59-
multiGate.AddFlow(subGraphEntry, ConstStrings.Numbers[i]);
59+
multiGate.AddFlow(subGraphEntry, ConstStrings.GetNumberString(i));
6060

6161
expected |= 1 << i;
6262
}
@@ -72,7 +72,7 @@ private static Graph GenerateMultiGateTestGraph(int outputs)
7272
eq.AddConnectedValue(ConstStrings.A, bitmaskGet);
7373
eq.AddValue(ConstStrings.B, expected);
7474

75-
multiGate.AddFlow(branch, ConstStrings.Numbers[outputs - 1]);
75+
multiGate.AddFlow(branch, ConstStrings.GetNumberString(outputs - 1));
7676

7777
var fail = g.CreateNode("event/send");
7878
var completed = g.CreateNode("event/send");
@@ -139,7 +139,7 @@ private static Graph GenerateMultiGateLoopTestGraph(int outputs, int iterations)
139139
for (int i = 0; i < outputs; i++)
140140
{
141141
Node outFlowCounter = CreateVariableIncrementSubgraph(g, outFlowActivationsVariable);
142-
multiGate.AddFlow(outFlowCounter, ConstStrings.Numbers[i]);
142+
multiGate.AddFlow(outFlowCounter, ConstStrings.GetNumberString(i));
143143

144144
var lastIndexBranch = g.CreateNode("flow/branch");
145145
var lastIndexEq = g.CreateNode("math/eq");
@@ -227,7 +227,7 @@ private static Graph GenerateMultiGateResetTestGraph(int outputs, int resetItera
227227
for (int i = 0; i < outputs; i++)
228228
{
229229
Node outFlowCounter = CreateVariableIncrementSubgraph(g, outFlowActivationsVariable);
230-
multiGate.AddFlow(outFlowCounter, ConstStrings.Numbers[i]);
230+
multiGate.AddFlow(outFlowCounter, ConstStrings.GetNumberString(i));
231231
}
232232

233233
var completeBranch = g.CreateNode("flow/branch");

Tests/Runtime/Interactivity/Nodes/Flow/ThrottleTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@ private static Graph GenerateThrottleResetTestGraph(float duration, float resetT
274274
startDelay.AddFlow(setDelay);
275275
setDelay.AddFlow(sequence, ConstStrings.DONE);
276276

277-
sequence.AddFlow(throttle, ConstStrings.Numbers[0], ConstStrings.RESET);
278-
sequence.AddFlow(branch, ConstStrings.Numbers[1]);
277+
sequence.AddFlow(throttle, ConstStrings.GetNumberString(0), ConstStrings.RESET);
278+
sequence.AddFlow(branch, ConstStrings.GetNumberString(1));
279279

280280
branch.AddConnectedValue(ConstStrings.CONDITION, isNaN);
281281
isNaN.AddConnectedValue(ConstStrings.A, throttle, ConstStrings.LAST_REMAINING_TIME);

Tests/Runtime/Interactivity/Nodes/Flow/WaitAllTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ private static Graph GenerateWaitAllTestGraph(int inputs)
3030
for (int i = 0; i < inputs; i++)
3131
{
3232
starts[i] = g.CreateNode("event/onStart");
33-
starts[i].AddFlow(waitAll, ConstStrings.OUT, ConstStrings.Numbers[i]);
33+
starts[i].AddFlow(waitAll, ConstStrings.OUT, ConstStrings.GetNumberString(i));
3434
}
3535

3636
var completed = g.CreateNode("event/send");
@@ -91,14 +91,14 @@ private static Graph GenerateWaitAllResetTestGraph()
9191

9292
branch2.AddFlow(inputs2Log, ConstStrings.FALSE);
9393

94-
sequence.AddFlow(waitAll, ConstStrings.Numbers[0], ConstStrings.Numbers[0]);
95-
sequence.AddFlow(waitAll, ConstStrings.Numbers[1], ConstStrings.Numbers[1]);
96-
sequence.AddFlow(waitAll, ConstStrings.Numbers[2], ConstStrings.Numbers[2]);
97-
sequence.AddFlow(branch1, ConstStrings.Numbers[3]);
98-
sequence.AddFlow(waitAll, ConstStrings.Numbers[4], ConstStrings.RESET);
99-
sequence.AddFlow(waitAll, ConstStrings.Numbers[5], ConstStrings.Numbers[3]);
100-
sequence.AddFlow(waitAll, ConstStrings.Numbers[6], ConstStrings.Numbers[4]);
101-
sequence.AddFlow(branch2, ConstStrings.Numbers[7]);
94+
sequence.AddFlow(waitAll, ConstStrings.GetNumberString(0), ConstStrings.GetNumberString(0));
95+
sequence.AddFlow(waitAll, ConstStrings.GetNumberString(1), ConstStrings.GetNumberString(1));
96+
sequence.AddFlow(waitAll, ConstStrings.GetNumberString(2), ConstStrings.GetNumberString(2));
97+
sequence.AddFlow(branch1, ConstStrings.GetNumberString(3));
98+
sequence.AddFlow(waitAll, ConstStrings.GetNumberString(4), ConstStrings.RESET);
99+
sequence.AddFlow(waitAll, ConstStrings.GetNumberString(5), ConstStrings.GetNumberString(3));
100+
sequence.AddFlow(waitAll, ConstStrings.GetNumberString(6), ConstStrings.GetNumberString(4));
101+
sequence.AddFlow(branch2, ConstStrings.GetNumberString(7));
102102

103103
var completed = g.CreateNode("event/send");
104104
completed.AddConfiguration(ConstStrings.EVENT, COMPLETED_EVENT_INDEX);

0 commit comments

Comments
 (0)