Beispiel #1
0
        /**
         * SV_RemoveIP_f.
         */
        private static void SVCmd_RemoveIP_f()
        {
            ipfilter_t f = new();
            int        i, j;

            if (GameBase.gi.argc() < 3)
            {
                GameBase.gi.cprintf(null, Defines.PRINT_HIGH, "Usage:  sv removeip <ip-mask>\n");

                return;
            }

            if (!GameSVCmds.StringToFilter(GameBase.gi.argv(2), f))
            {
                return;
            }

            for (i = 0; i < GameSVCmds.numipfilters; i++)
            {
                if (GameSVCmds.ipfilters[i].mask == f.mask && GameSVCmds.ipfilters[i].compare == f.compare)
                {
                    for (j = i + 1; j < GameSVCmds.numipfilters; j++)
                    {
                        GameSVCmds.ipfilters[j - 1] = GameSVCmds.ipfilters[j];
                    }

                    GameSVCmds.numipfilters--;
                    GameBase.gi.cprintf(null, Defines.PRINT_HIGH, "Removed.\n");

                    return;
                }
            }

            GameBase.gi.cprintf(null, Defines.PRINT_HIGH, "Didn't find " + GameBase.gi.argv(2) + ".\n");
        }
Beispiel #2
0
        /**
         * ServerCommand
         *
         * ServerCommand will be called when an "sv" command is issued. The game can
         * issue gi.argc() / gi.argv() commands to get the rest of the parameters
         */
        public static void ServerCommand()
        {
            string cmd;

            cmd = GameBase.gi.argv(1);

            if (Lib.Q_stricmp(cmd, "test") == 0)
            {
                GameSVCmds.Svcmd_Test_f();
            }
            else if (Lib.Q_stricmp(cmd, "addip") == 0)
            {
                GameSVCmds.SVCmd_AddIP_f();
            }
            else if (Lib.Q_stricmp(cmd, "removeip") == 0)
            {
                GameSVCmds.SVCmd_RemoveIP_f();
            }
            else if (Lib.Q_stricmp(cmd, "listip") == 0)
            {
                GameSVCmds.SVCmd_ListIP_f();
            }
            else if (Lib.Q_stricmp(cmd, "writeip") == 0)
            {
                GameSVCmds.SVCmd_WriteIP_f();
            }
            else
            {
                GameBase.gi.cprintf(null, Defines.PRINT_HIGH, "Unknown server command \"" + cmd + "\"\n");
            }
        }
Beispiel #3
0
        /**
         * SV_AddIP_f.
         */
        private static void SVCmd_AddIP_f()
        {
            int i;

            if (GameBase.gi.argc() < 3)
            {
                GameBase.gi.cprintf(null, Defines.PRINT_HIGH, "Usage:  addip <ip-mask>\n");

                return;
            }

            for (i = 0; i < GameSVCmds.numipfilters; i++)
            {
                if ((uint)GameSVCmds.ipfilters[i].compare == 0xffffffff)
                {
                    break;                     // free spot
                }
            }

            if (i == GameSVCmds.numipfilters)
            {
                if (GameSVCmds.numipfilters == GameSVCmds.MAX_IPFILTERS)
                {
                    GameBase.gi.cprintf(null, Defines.PRINT_HIGH, "IP filter list is full\n");

                    return;
                }

                GameSVCmds.numipfilters++;
            }

            if (!GameSVCmds.StringToFilter(GameBase.gi.argv(2), GameSVCmds.ipfilters[i]))
            {
                GameSVCmds.ipfilters[i].compare = unchecked ((int)0xffffffff);
            }
        }