Ejemplo n.º 1
0
        public override void Process(FileParser fileParser)
        {
            Line = fileParser.Lines[fileParser.CurrentLineCount];

            string name = null;

            if (ParamsList != null && ParamsList.Count > 0)
            {
                for (int i = 0; i < ParamsList.Count; i++)
                {
                    if (ParamsList[i] is NameParam nameParam)
                    {
                        name = nameParam.Value;

                        ParamsList.RemoveAt(i);

                        break;
                    }
                }

                if (ParamsList.Count == 0)
                {
                    ParamsList = null;
                }
            }

            Match  splitMatch = GetRegex().Match(Line);
            string result     = Line.Substring(splitMatch.Index, Line.Length - splitMatch.Index);

            ConVarData = NeoDoc.GetEntriesFromString(result, out _).ToArray();
            ConVarName = (name ?? ConVarData[0]).Trim('"');
        }
Ejemplo n.º 2
0
        public override void Process(FileParser fileParser)
        {
            // if param "@local" found
            if (ParamsList != null && ParamsList.Count > 0)
            {
                for (int i = 0; i < ParamsList.Count; i++)
                {
                    if (ParamsList[i] is LocalParam)
                    {
                        Local = true;

                        ParamsList.RemoveAt(i);

                        break;
                    }
                }
            }

            Line = fileParser.Lines[fileParser.CurrentLineCount];

            if (!Local)
            {
                Match match = new Regex(@"^\s*local\s*").Match(Line);

                Local = match.Success;
            }

            if (Local)
            {
                Ignore = true;
            }

            FunctionData = GetRegex().Match(Line).Value.TrimStart('@');
            Name         = FunctionData.Replace("function ", "").Split('(')[0].Trim();
        }
Ejemplo n.º 3
0
        public override DataStructure CheckDataStructureTransformation()
        {
            // check whether it's a hook

            // if param "@hook" found
            if (ParamsList != null && ParamsList.Count > 0)
            {
                for (int i = 0; i < ParamsList.Count; i++)
                {
                    if (ParamsList[i] is HookParam)
                    {
                        ParamsList.RemoveAt(i);

                        if (ParamsList.Count == 0)
                        {
                            ParamsList = null;
                        }

                        return(new Hook
                        {
                            HookName = FunctionData.Replace("function ", "").Split('(')[0].Trim().Replace("GAMEMODE", "GM"),
                            HookData = FunctionData.Replace("GAMEMODE", "GM"),
                            GlobalWrapper = FunctionData.Replace("function ", "").Split(':')[0].Trim().Replace("GAMEMODE", "GM"),
                            Line = Line,
                            ParamsList = ParamsList,
                            Realm = Realm,
                            Ignore = Ignore,
                            FoundLine = FoundLine,
                            FoundPath = FoundPath,
                            IsMain = true
                        });
                    }
                }
            }

            // if "GM" or "GAMEMODE" found
            Regex regex = new Regex(@"\s*function\s*(GAMEMODE|GM)\:\w+\s*\(");

            if (regex.Match(Line).Success)
            {
                return(new Hook
                {
                    HookName = FunctionData.Replace("function ", "").Split('(')[0].Trim().Replace("GAMEMODE", "GM"),
                    HookData = FunctionData.Replace("GAMEMODE", "GM"),
                    Line = Line,
                    ParamsList = ParamsList,
                    Realm = Realm,
                    Ignore = Ignore,
                    FoundLine = FoundLine,
                    FoundPath = FoundPath,
                    IsMain = true
                });
            }

            return(base.CheckDataStructureTransformation());
        }
Ejemplo n.º 4
0
        public override void Process(FileParser fileParser)
        {
            Line = fileParser.Lines[fileParser.CurrentLineCount];

            string name = null;

            if (ParamsList != null && ParamsList.Count > 0)
            {
                for (int i = 0; i < ParamsList.Count; i++)
                {
                    if (ParamsList[i] is NameParam nameParam)
                    {
                        name = nameParam.Value;

                        ParamsList.RemoveAt(i);

                        break;
                    }
                }

                if (ParamsList.Count == 0)
                {
                    ParamsList = null;
                }
            }

            Match splitMatch = GetRegex().Match(Line);

            if (splitMatch.NextMatch().Success)             // there are multiple hooks in this line
            {
                NeoDoc.WriteErrors("Multiple datastructures found", null, fileParser.relPath, fileParser.CurrentLineCount + 1, (int)NeoDoc.ERROR_CODES.MULTIPLE_DS_IN_LINE);
            }

            string result = Line.Substring(splitMatch.Index, Line.Length - splitMatch.Index);

            bool mode = new Regex(@"\s*hook\.Run\s*\(").Match(Line).Success;             // if false, "hook.Call(" is found

            List <string> tmpData = NeoDoc.GetEntriesFromString(result, out _);

            HookName = GlobalWrapper + ":" + (name ?? tmpData[0]).Trim('"');

            HookData = HookName + "(" + string.Join(", ", tmpData.GetRange(mode ? 1 : 2, tmpData.Count - (mode ? 1 : 2)).ToArray()) + ")";             // "hook.Call( string eventName, table gamemodeTable, vararg args )" or "hook.Run( string eventName, vararg args )"
        }