From c90a1c0c9627d2cb4d5ad105ae7020582c8b2cab Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 3 Apr 2016 18:10:09 -0500 Subject: [PATCH] Add "support" for user string variables in DECORATE - This is "support" in the very most basic sense. You can declare them, but you can't actually do anything with them, since the decorate parser can't handle expressions when it's parsing string arguments. However, they seem to be getting properly initialized and destroyed, which is what this was added to test. If it doesn't look like too much trouble, I might try to turn them into something actually worth something. --- src/thingdef/thingdef_parse.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/thingdef/thingdef_parse.cpp b/src/thingdef/thingdef_parse.cpp index f5359a7d8..bf929128b 100644 --- a/src/thingdef/thingdef_parse.cpp +++ b/src/thingdef/thingdef_parse.cpp @@ -533,12 +533,17 @@ static void ParseUserVariable (FScanner &sc, PSymbolTable *symt, PClassActor *cl // Read the type and make sure it's acceptable. sc.MustGetAnyToken(); - if (sc.TokenType != TK_Int && sc.TokenType != TK_Float) + switch (sc.TokenType) { - sc.ScriptMessage("User variables must be of type 'int' or 'float'"); + case TK_Int: type = TypeSInt32; break; + case TK_Float: type = TypeFloat64; break; + case TK_String: type = TypeString; break; + default: + type = TypeError; + sc.ScriptMessage("User variables must be of type 'int' or 'float' or 'string'"); FScriptPosition::ErrorCounter++; + break; } - type = sc.TokenType == TK_Int ? (PType *)TypeSInt32 : (PType *)TypeFloat64; sc.MustGetToken(TK_Identifier); // For now, restrict user variables to those that begin with "user_" to guarantee