예제 #1
0
        /**
         * Cmd_ExecuteString
         *
         * A complete command line has been parsed, so try to execute it
         * FIXME: lookupnoadd the token to speed search?
         */
        public static void ExecuteString(string text)
        {
            cmd_function_t cmd;
            cmdalias_t     a;

            Cmd.TokenizeString(text.ToCharArray(), true);

            // execute the command line
            if (Cmd.Argc() == 0)
            {
                return;                 // no tokens
            }
            // check functions
            for (cmd = Cmd.cmd_functions; cmd != null; cmd = cmd.next)
            {
                if (Cmd.cmd_argv[0].Equals(cmd.name, StringComparison.OrdinalIgnoreCase))
                {
                    if (null == cmd.function)
                    {
                        // forward to server command
                        Cmd.ExecuteString("cmd " + text);
                    }
                    else
                    {
                        cmd.function();
                    }

                    return;
                }
            }

            // check alias
            for (a = Globals.cmd_alias; a != null; a = a.next)
            {
                if (Cmd.cmd_argv[0].Equals(a.name, StringComparison.OrdinalIgnoreCase))
                {
                    if (++Globals.alias_count == Cmd.ALIAS_LOOP_COUNT)
                    {
                        Com.Printf("ALIAS_LOOP_COUNT\n");

                        return;
                    }

                    Cbuf.InsertText(a.value);

                    return;
                }
            }

            // check cvars
            if (Cvar.Command())
            {
                return;
            }

            // send it as a server command if we are connected
            Cmd.ForwardToServer();
        }
예제 #2
0
파일: Cmd.cs 프로젝트: optimus-code/Q2Sharp
        public static void ExecuteString(String text)
        {
            cmd_function_t cmd;
            cmdalias_t     a;

            TokenizeString(text.ToCharArray(), true);
            if (Argc() == 0)
            {
                return;
            }
            for (cmd = cmd_functions; cmd != null; cmd = cmd.next)
            {
                if (cmd_argv[0].EqualsIgnoreCase(cmd.name))
                {
                    if (null == cmd.function)
                    {
                        Cmd.ExecuteString("cmd " + text);
                    }
                    else
                    {
                        cmd.function.Execute();
                    }

                    return;
                }
            }

            for (a = Globals.cmd_alias; a != null; a = a.next)
            {
                if (cmd_argv[0].EqualsIgnoreCase(a.name))
                {
                    if (++Globals.alias_count == ALIAS_LOOP_COUNT)
                    {
                        Com.Printf("ALIAS_LOOP_COUNT\\n");
                        return;
                    }

                    Cbuf.InsertText(a.value);
                    return;
                }
            }

            if (Cvar.Command())
            {
                return;
            }
            Cmd.ForwardToServer();
        }