From 9c5815dae064ee674a48253629de69114b0606b0 Mon Sep 17 00:00:00 2001 From: codereader Date: Sun, 4 Sep 2022 19:55:42 +0200 Subject: [PATCH] #6092: Parse the first few action members --- radiantcore/fx/FxAction.cpp | 21 ++++++++++++++++++++- test/Fx.cpp | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/radiantcore/fx/FxAction.cpp b/radiantcore/fx/FxAction.cpp index 1dc82a6862..1f087d8a4f 100644 --- a/radiantcore/fx/FxAction.cpp +++ b/radiantcore/fx/FxAction.cpp @@ -1,5 +1,8 @@ #include "FxAction.h" +#include "parser/DefTokeniser.h" +#include "string/case_conv.h" + namespace fx { @@ -20,7 +23,23 @@ bool FxAction::getIgnoreMaster() void FxAction::parseFromTokens(parser::DefTokeniser& tokeniser) { - + while (tokeniser.hasMoreTokens()) + { + auto token = tokeniser.nextToken(); + string::to_lower(token); + + // Hit a closing brace and we're done with this action + if (token == "}") return; + + if (token == "ignoremaster") + { + _ignoreMaster = true; + } + else if (token == "delay") + { + _delayInSeconds = string::convert(tokeniser.nextToken()); + } + } } diff --git a/test/Fx.cpp b/test/Fx.cpp index 6852e17576..629f3b6b73 100644 --- a/test/Fx.cpp +++ b/test/Fx.cpp @@ -44,7 +44,7 @@ TEST_F(FxTest, ParseActionDelay) { EXPECT_EQ(getFxByName("fx/sparks")->getAction(0)->getDelay(), 0); EXPECT_EQ(getFxByName("fx/sparks")->getAction(1)->getDelay(), 2); - EXPECT_EQ(getFxByName("fx/sparks")->getAction(2)->getDelay(), 1.5); + EXPECT_EQ(getFxByName("fx/sparks")->getAction(2)->getDelay(), 1.5f); } TEST_F(FxTest, ParseActionIgnoreMaster)