Пример #1
0
            public override void Execute( )
            {
                Int32 c;
                Int32 flags;

                c = Cmd.Argc();
                if (c != 3 && c != 4)
                {
                    Com.Printf("usage: set <variable> <value> [u / s]\\n");
                    return;
                }

                if (c == 4)
                {
                    if (Cmd.Argv(3).Equals("u"))
                    {
                        flags = CVAR_USERINFO;
                    }
                    else if (Cmd.Argv(3).Equals("s"))
                    {
                        flags = CVAR_SERVERINFO;
                    }
                    else
                    {
                        Com.Printf("flags can only be 'u' or 's'\\n");
                        return;
                    }

                    Cvar.FullSet(Cmd.Argv(1), Cmd.Argv(2), flags);
                }
                else
                {
                    Cvar.Set(Cmd.Argv(1), Cmd.Argv(2));
                }
            }
Пример #2
0
        public static void SVC_RemoteCommand( )
        {
            Int32  i;
            String remaining;

            i = Rcon_Validate();
            var msg = Lib.CtoJava(Globals.net_message.data, 4, 1024);

            if (i == 0)
            {
                Com.Printf("Bad rcon from " + NET.AdrToString(Globals.net_from) + ":\\n" + msg + "\\n");
            }
            else
            {
                Com.Printf("Rcon from " + NET.AdrToString(Globals.net_from) + ":\\n" + msg + "\\n");
            }
            Com.BeginRedirect(Defines.RD_PACKET, SV_SEND.sv_outputbuf, Defines.SV_OUTPUTBUF_LENGTH, new AnonymousRD_Flusher());
            if (0 == Rcon_Validate())
            {
                Com.Printf("Bad rcon_password.\\n");
            }
            else
            {
                remaining = "";
                for (i = 2; i < Cmd.Argc(); i++)
                {
                    remaining += Cmd.Argv(i);
                    remaining += " ";
                }

                Cmd.ExecuteString(remaining);
            }

            Com.EndRedirect();
        }
Пример #3
0
        public static void SVC_Info( )
        {
            String string_renamed;
            Int32  i, count;
            Int32  version;

            if (SV_MAIN.maxclients.value == 1)
            {
                return;
            }
            version = Lib.Atoi(Cmd.Argv(1));
            if (version != Defines.PROTOCOL_VERSION)
            {
                string_renamed = SV_MAIN.hostname.string_renamed + ": wrong version\\n";
            }
            else
            {
                count = 0;
                for (i = 0; i < SV_MAIN.maxclients.value; i++)
                {
                    if (SV_INIT.svs.clients[i].state >= Defines.cs_connected)
                    {
                        count++;
                    }
                }
                string_renamed = SV_MAIN.hostname.string_renamed + " " + SV_INIT.sv.name + " " + count + "/" + ( Int32 )SV_MAIN.maxclients.value + "\\n";
            }

            Netchan.OutOfBandPrint(Defines.NS_SERVER, Globals.net_from, "info\\n" + string_renamed);
        }
Пример #4
0
            public override void Execute( )
            {
                String filename;

                if (Cmd.Argc() != 2)
                {
                    Com.Printf("Usage: download <filename>\\n");
                    return;
                }

                filename = Cmd.Argv(1);
                if (filename.IndexOf("..") != -1)
                {
                    Com.Printf("Refusing to download a path with ..\\n");
                    return;
                }

                if (FS.LoadFile(filename) != null)
                {
                    Com.Printf("File already exists.\\n");
                    return;
                }

                Globals.cls.downloadname = filename;
                Com.Printf("Downloading " + Globals.cls.downloadname + "\\n");
                Globals.cls.downloadtempname  = Com.StripExtension(Globals.cls.downloadname);
                Globals.cls.downloadtempname += ".tmp";
                MSG.WriteByte(Globals.cls.netchan.message, Defines.clc_stringcmd);
                MSG.WriteString(Globals.cls.netchan.message, "download " + Globals.cls.downloadname);
                Globals.cls.downloadnumber++;
            }
Пример #5
0
        /**
         * SVC_Info, responds with short info for broadcast scans The second parameter should
         * be the current protocol version number.
         */
        public static void SVC_Info()
        {
            string @string;
            int    i, count;
            int    version;

            if (SV_MAIN.maxclients.value == 1)
            {
                return;                 // ignore in single player
            }
            version = Lib.atoi(Cmd.Argv(1));

            if (version != Defines.PROTOCOL_VERSION)
            {
                @string = SV_MAIN.hostname.@string + ": wrong version\n";
            }
            else
            {
                count = 0;

                for (i = 0; i < SV_MAIN.maxclients.value; i++)
                {
                    if (SV_INIT.svs.clients[i].state >= Defines.cs_connected)
                    {
                        count++;
                    }
                }

                @string = SV_MAIN.hostname.@string + " " + SV_INIT.sv.name + " " + count + "/" + (int)SV_MAIN.maxclients.value + "\n";
            }

            Netchan.OutOfBandPrint(Defines.NS_SERVER, Globals.net_from, "info\n" + @string);
        }
Пример #6
0
        public static void Link_f( )
        {
            if (Cmd.Argc() != 3)
            {
                Com.Printf("USAGE: link <from> <to>\\n");
                return;
            }

            foreach (var entry in fs_links.ToArray())
            {
                if (entry.from.Equals(Cmd.Argv(1)))
                {
                    if (Cmd.Argv(2).Length < 1)
                    {
                        fs_links.Remove(entry);
                        return;
                    }

                    entry.to = new String(Cmd.Argv(2));
                    return;
                }
            }

            if (Cmd.Argv(2).Length > 0)
            {
                var entry = new filelink_t();
                entry.from       = new String(Cmd.Argv(1));
                entry.fromlength = entry.from.Length;
                entry.to         = new String(Cmd.Argv(2));
                fs_links.AddLast(entry);
            }
        }
Пример #7
0
        public static void SV_Nextserver_f( )
        {
            if (Lib.Atoi(Cmd.Argv(1)) != SV_INIT.svs.spawncount)
            {
                Com.DPrintf("Nextserver() from wrong level, from " + SV_MAIN.sv_client.name + "\\n");
                return;
            }

            Com.DPrintf("Nextserver() from " + SV_MAIN.sv_client.name + "\\n");
            SV_Nextserver();
        }
Пример #8
0
        public static void SV_Savegame_f( )
        {
            String dir;

            if (SV_INIT.sv.state != Defines.ss_game)
            {
                Com.Printf("You must be in a game to save.\\n");
                return;
            }

            if (Cmd.Argc() != 2)
            {
                Com.Printf("USAGE: savegame <directory>\\n");
                return;
            }

            if (Cvar.VariableValue("deathmatch") != 0)
            {
                Com.Printf("Can't savegame in a deathmatch\\n");
                return;
            }

            if (0 == Lib.Strcmp(Cmd.Argv(1), "current"))
            {
                Com.Printf("Can't save to 'current'\\n");
                return;
            }

            if (SV_MAIN.maxclients.value == 1 && SV_INIT.svs.clients[0].edict.client.ps.stats[Defines.STAT_HEALTH] <= 0)
            {
                Com.Printf("\\nCan't savegame while dead!\\n");
                return;
            }

            dir = Cmd.Argv(1);
            if ((dir.IndexOf("..") > -1) || (dir.IndexOf("/") > -1) || (dir.IndexOf("\\\\") > -1))
            {
                Com.Printf("Bad savedir.\\n");
            }

            Com.Printf("Saving game...\\n");
            SV_WriteLevelFile();
            try
            {
                SV_WriteServerFile(false);
            }
            catch (Exception e)
            {
                Com.Printf("IOError in SV_WriteServerFile: " + e);
            }

            SV_CopySaveGame("current", dir);
            Com.Printf("Done.\\n");
        }
Пример #9
0
            public override void Execute( )
            {
                if (Cmd.Argc() != 2)
                {
                    gun_model = null;
                    return;
                }

                var name = "models/" + Cmd.Argv(1) + "/tris.md2";

                gun_model = re.RegisterModel(name);
            }
Пример #10
0
        /**
         * A connectionless packet has four leading 0xff characters to distinguish
         * it from a game channel. Clients that are in the game can still send
         * connectionless packets. It is used also by rcon commands.
         */
        public static void SV_ConnectionlessPacket()
        {
            string s;
            string c;

            MSG.BeginReading(Globals.net_message);
            MSG.ReadLong(Globals.net_message);             // skip the -1 marker

            s = MSG.ReadStringLine(Globals.net_message);

            Cmd.TokenizeString(s.ToCharArray(), false);

            c = Cmd.Argv(0);

            //for debugging purposes
            //Com.Printf("Packet " + NET.AdrToString(Netchan.net_from) + " : " + c + "\n");
            //Com.Printf(Lib.hexDump(net_message.data, 64, false) + "\n");

            if (0 == Lib.strcmp(c, "ping"))
            {
                SV_MAIN.SVC_Ping();
            }
            else if (0 == Lib.strcmp(c, "ack"))
            {
                SV_MAIN.SVC_Ack();
            }
            else if (0 == Lib.strcmp(c, "status"))
            {
                SV_MAIN.SVC_Status();
            }
            else if (0 == Lib.strcmp(c, "info"))
            {
                SV_MAIN.SVC_Info();
            }
            else if (0 == Lib.strcmp(c, "getchallenge"))
            {
                SV_MAIN.SVC_GetChallenge();
            }
            else if (0 == Lib.strcmp(c, "connect"))
            {
                SV_MAIN.SVC_DirectConnect();
            }
            else if (0 == Lib.strcmp(c, "rcon"))
            {
                SV_MAIN.SVC_RemoteCommand();
            }
            else
            {
                Com.Printf("bad connectionless packet from " + NET.AdrToString(Globals.net_from) + "\n");
                Com.Printf("[" + s + "]\n");
                Com.Printf("" + Lib.hexDump(Globals.net_message.data, 128, false));
            }
        }
Пример #11
0
 public static Int32 Rcon_Validate( )
 {
     if (0 == SV_MAIN.rcon_password.string_renamed.Length)
     {
         return(0);
     }
     if (0 != Lib.Strcmp(Cmd.Argv(1), SV_MAIN.rcon_password.string_renamed))
     {
         return(0);
     }
     return(1);
 }
Пример #12
0
        public static void SV_BeginDownload_f( )
        {
            String name;
            var    offset = 0;

            name = Cmd.Argv(1);
            if (Cmd.Argc() > 2)
            {
                offset = Lib.Atoi(Cmd.Argv(2));
            }
            if (name.IndexOf("..") != -1 || SV_MAIN.allow_download.value == 0 || name[0] == '.' || name[0] == '/' || (name.StartsWith("players/") && 0 == SV_MAIN.allow_download_players.value) || (name.StartsWith("models/") && 0 == SV_MAIN.allow_download_models.value) || (name.StartsWith("sound/") && 0 == SV_MAIN.allow_download_sounds.value) || (name.StartsWith("maps/") && 0 == SV_MAIN.allow_download_maps.value) || name.IndexOf('/') == -1)
            {
                MSG.WriteByte(SV_MAIN.sv_client.netchan.message, Defines.svc_download);
                MSG.WriteShort(SV_MAIN.sv_client.netchan.message, -1);
                MSG.WriteByte(SV_MAIN.sv_client.netchan.message, 0);
                return;
            }

            if (SV_MAIN.sv_client.download != null)
            {
                FS.FreeFile(SV_MAIN.sv_client.download);
            }
            SV_MAIN.sv_client.download = FS.LoadFile(name);
            if (SV_MAIN.sv_client.download == null)
            {
                return;
            }

            SV_MAIN.sv_client.downloadsize  = SV_MAIN.sv_client.download.Length;
            SV_MAIN.sv_client.downloadcount = offset;
            if (offset > SV_MAIN.sv_client.downloadsize)
            {
                SV_MAIN.sv_client.downloadcount = SV_MAIN.sv_client.downloadsize;
            }
            if (SV_MAIN.sv_client.download == null || (name.StartsWith("maps/") && FS.file_from_pak != 0))
            {
                Com.DPrintf("Couldn't download " + name + " to " + SV_MAIN.sv_client.name + "\\n");
                if (SV_MAIN.sv_client.download != null)
                {
                    FS.FreeFile(SV_MAIN.sv_client.download);
                    SV_MAIN.sv_client.download = null;
                }

                MSG.WriteByte(SV_MAIN.sv_client.netchan.message, Defines.svc_download);
                MSG.WriteShort(SV_MAIN.sv_client.netchan.message, -1);
                MSG.WriteByte(SV_MAIN.sv_client.netchan.message, 0);
                return;
            }

            SV_NextDownload_f();
            Com.DPrintf("Downloading " + name + " to " + SV_MAIN.sv_client.name + "\\n");
        }
Пример #13
0
        static void KeyUp(kbutton_t b)
        {
            int    k;
            string c;
            int    uptime;

            c = Cmd.Argv(1);
            if (c.Length > 0)
            {
                k = Lib.Atoi(c);
            }
            else
            {
                b.down[0] = b.down[1] = 0;
                b.state   = 4;
                return;
            }

            if (b.down[0] == k)
            {
                b.down[0] = 0;
            }
            else if (b.down[1] == k)
            {
                b.down[1] = 0;
            }
            else
            {
                return;
            }
            if (b.down[0] != 0 || b.down[1] != 0)
            {
                return;
            }
            if ((b.state & 1) == 0)
            {
                return;
            }
            c      = Cmd.Argv(2);
            uptime = Lib.Atoi(c);
            if (uptime != 0)
            {
                b.msec += uptime - b.downtime;
            }
            else
            {
                b.msec += 10;
            }
            b.state &= ~1;
            b.state |= 4;
        }
Пример #14
0
        /*
         * ===============================================================================
         *
         * OPERATOR CONSOLE ONLY COMMANDS
         *
         * These commands can only be entered from stdin or by a remote operator datagram
         * ===============================================================================
         */

        /*
         * ====================
         * SV_SetMaster_f
         *
         * Specify a list of master servers
         * ====================
         */
        public static void SV_SetMaster_f()
        {
            int i, slot;

            // only dedicated servers send heartbeats
            if (Globals.dedicated.value == 0)
            {
                Com.Printf("Only dedicated servers use masters.\n");

                return;
            }

            // make sure the server is listed public
            Cvar.Set("public", "1");

            for (i = 1; i < Defines.MAX_MASTERS; i++)
            {
                SV_MAIN.master_adr[i] = new();
            }

            slot = 1;             // slot 0 will always contain the id master

            for (i = 1; i < Cmd.Argc(); i++)
            {
                if (slot == Defines.MAX_MASTERS)
                {
                    break;
                }

                if (!NET.StringToAdr(Cmd.Argv(i), SV_MAIN.master_adr[i]))
                {
                    Com.Printf("Bad address: " + Cmd.Argv(i) + "\n");

                    continue;
                }

                if (SV_MAIN.master_adr[slot].port == 0)
                {
                    SV_MAIN.master_adr[slot].port = Defines.PORT_MASTER;
                }

                Com.Printf("Master server at " + NET.AdrToString(SV_MAIN.master_adr[slot]) + "\n");
                Com.Printf("Sending a ping.\n");

                Netchan.OutOfBandPrint(Defines.NS_SERVER, SV_MAIN.master_adr[slot], "ping");

                slot++;
            }

            SV_INIT.svs.last_heartbeat = -9999999;
        }
Пример #15
0
        public static void SV_Begin_f( )
        {
            Com.DPrintf("Begin() from " + SV_MAIN.sv_client.name + "\\n");
            if (Lib.Atoi(Cmd.Argv(1)) != SV_INIT.svs.spawncount)
            {
                Com.Printf("SV_Begin_f from different level\\n");
                SV_New_f();
                return;
            }

            SV_MAIN.sv_client.state = Defines.cs_spawned;
            PlayerClient.ClientBegin(SV_USER.sv_player);
            Cbuf.InsertFromDefer();
        }
Пример #16
0
        public static Boolean SV_SetPlayer( )
        {
            client_t cl;
            Int32    i;
            Int32    idnum;
            String   s;

            if (Cmd.Argc() < 2)
            {
                return(false);
            }
            s = Cmd.Argv(1);
            if (s[0] >= '0' && s[0] <= '9')
            {
                idnum = Lib.Atoi(Cmd.Argv(1));
                if (idnum < 0 || idnum >= SV_MAIN.maxclients.value)
                {
                    Com.Printf("Bad client slot: " + idnum + "\\n");
                    return(false);
                }

                SV_MAIN.sv_client = SV_INIT.svs.clients[idnum];
                SV_USER.sv_player = SV_MAIN.sv_client.edict;
                if (0 == SV_MAIN.sv_client.state)
                {
                    Com.Printf("Client " + idnum + " is not active\\n");
                    return(false);
                }

                return(true);
            }

            for (i = 0; i < SV_MAIN.maxclients.value; i++)
            {
                cl = SV_INIT.svs.clients[i];
                if (0 == cl.state)
                {
                    continue;
                }
                if (0 == Lib.Strcmp(cl.name, s))
                {
                    SV_MAIN.sv_client = cl;
                    SV_USER.sv_player = SV_MAIN.sv_client.edict;
                    return(true);
                }
            }

            Com.Printf("Userid " + s + " is not on the server\\n");
            return(false);
        }
Пример #17
0
        /**
         * Checks if the rcon password is corect.
         */
        public static int Rcon_Validate()
        {
            if (0 == [email protected])
            {
                return(0);
            }

            if (0 != Lib.strcmp(Cmd.Argv(1), SV_MAIN.rcon_password.@string))
            {
                return(0);
            }

            return(1);
        }
Пример #18
0
        public static void SV_GameMap_f( )
        {
            if (Cmd.Argc() != 2)
            {
                Com.Printf("USAGE: gamemap <map>\\n");
                return;
            }

            Com.DPrintf("SV_GameMap(" + Cmd.Argv(1) + ")\\n");
            FS.CreatePath(FS.Gamedir() + "/save/current/");
            var map = Cmd.Argv(1);

            if (map[0] == '*')
            {
                SV_WipeSavegame("current");
            }
            else
            {
                if (SV_INIT.sv.state == Defines.ss_game)
                {
                    client_t  cl;
                    Boolean[] savedInuse = new Boolean[( Int32 )SV_MAIN.maxclients.value];
                    for (var i = 0; i < SV_MAIN.maxclients.value; i++)
                    {
                        cl             = SV_INIT.svs.clients[i];
                        savedInuse[i]  = cl.edict.inuse;
                        cl.edict.inuse = false;
                    }

                    SV_WriteLevelFile();
                    for (var i = 0; i < SV_MAIN.maxclients.value; i++)
                    {
                        cl             = SV_INIT.svs.clients[i];
                        cl.edict.inuse = savedInuse[i];
                    }

                    savedInuse = null;
                }
            }

            SV_INIT.SV_Map(false, Cmd.Argv(1), false);
            SV_INIT.svs.mapcmd = Cmd.Argv(1);
            if (0 == Globals.dedicated.value)
            {
                SV_WriteServerFile(true);
                SV_CopySaveGame("current", "save0");
            }
        }
Пример #19
0
        void Play( )
        {
            var    i = 1;
            String name;

            while (i < Cmd.Argc())
            {
                name = new String(Cmd.Argv(i));
                if (name.IndexOf('.') == -1)
                {
                    name += ".wav";
                }
                RegisterSound(name);
                StartLocalSound(name);
                i++;
            }
        }
Пример #20
0
        public static void SV_Baselines_f( )
        {
            Int32          start;
            entity_state_t nullstate;
            entity_state_t base_renamed;

            Com.DPrintf("Baselines() from " + SV_MAIN.sv_client.name + "\\n");
            if (SV_MAIN.sv_client.state != Defines.cs_connected)
            {
                Com.Printf("baselines not valid -- already spawned\\n");
                return;
            }

            if (Lib.Atoi(Cmd.Argv(1)) != SV_INIT.svs.spawncount)
            {
                Com.Printf("SV_Baselines_f from different level\\n");
                SV_New_f();
                return;
            }

            start     = Lib.Atoi(Cmd.Argv(2));
            nullstate = new entity_state_t(null);
            while (SV_MAIN.sv_client.netchan.message.cursize < Defines.MAX_MSGLEN / 2 && start < Defines.MAX_EDICTS)
            {
                base_renamed = SV_INIT.sv.baselines[start];
                if (base_renamed.modelindex != 0 || base_renamed.sound != 0 || base_renamed.effects != 0)
                {
                    MSG.WriteByte(SV_MAIN.sv_client.netchan.message, Defines.svc_spawnbaseline);
                    MSG.WriteDeltaEntity(nullstate, base_renamed, SV_MAIN.sv_client.netchan.message, true, true);
                }

                start++;
            }

            if (start == Defines.MAX_EDICTS)
            {
                MSG.WriteByte(SV_MAIN.sv_client.netchan.message, Defines.svc_stufftext);
                MSG.WriteString(SV_MAIN.sv_client.netchan.message, "precache " + SV_INIT.svs.spawncount + "\\n");
            }
            else
            {
                MSG.WriteByte(SV_MAIN.sv_client.netchan.message, Defines.svc_stufftext);
                MSG.WriteString(SV_MAIN.sv_client.netchan.message, "cmd baselines " + SV_INIT.svs.spawncount + " " + start + "\\n");
            }
        }
Пример #21
0
        public static void SV_ConnectionlessPacket( )
        {
            String s;
            String c;

            MSG.BeginReading(Globals.net_message);
            MSG.ReadLong(Globals.net_message);
            s = MSG.ReadStringLine(Globals.net_message);
            Cmd.TokenizeString(s.ToCharArray(), false);
            c = Cmd.Argv(0);
            if (0 == Lib.Strcmp(c, "ping"))
            {
                SVC_Ping();
            }
            else if (0 == Lib.Strcmp(c, "ack"))
            {
                SVC_Ack();
            }
            else if (0 == Lib.Strcmp(c, "status"))
            {
                SVC_Status();
            }
            else if (0 == Lib.Strcmp(c, "info"))
            {
                SVC_Info();
            }
            else if (0 == Lib.Strcmp(c, "getchallenge"))
            {
                SVC_GetChallenge();
            }
            else if (0 == Lib.Strcmp(c, "connect"))
            {
                SVC_DirectConnect();
            }
            else if (0 == Lib.Strcmp(c, "rcon"))
            {
                SVC_RemoteCommand();
            }
            else
            {
                Com.Printf("bad connectionless packet from " + NET.AdrToString(Globals.net_from) + "\\n");
                Com.Printf("[" + s + "]\\n");
                Com.Printf("" + Lib.HexDump(Globals.net_message.data, 128, false));
            }
        }
Пример #22
0
        static void Key_Unbind_f()
        {
            if (Cmd.Argc() != 2)
            {
                Com.Printf("unbind <key> : remove commands from a key\\n");
                return;
            }

            int b = Key.StringToKeynum(Cmd.Argv(1));

            if (b == -1)
            {
                Com.Printf("\\\"" + Cmd.Argv(1) + "\\\" isn't a valid key\\n");
                return;
            }

            Key.SetBinding(b, null);
        }
Пример #23
0
        public static Boolean Command( )
        {
            cvar_t v;

            v = Cvar.FindVar(Cmd.Argv(0));
            if (v == null)
            {
                return(false);
            }
            if (Cmd.Argc() == 1)
            {
                Com.Printf("\\\"" + v.name + "\\\" is \\\"" + v.string_renamed + "\\\"\\n");
                return(true);
            }

            Cvar.Set(v.name, Cmd.Argv(1));
            return(true);
        }
Пример #24
0
        static void Key_Bind_f()
        {
            int c = Cmd.Argc();

            if (c < 2)
            {
                Com.Printf("bind <key> [command] : attach a command to a key\\n");
                return;
            }

            int b = StringToKeynum(Cmd.Argv(1));

            if (b == -1)
            {
                Com.Printf("\\\"" + Cmd.Argv(1) + "\\\" isn't a valid key\\n");
                return;
            }

            if (c == 2)
            {
                if (Globals.keybindings[b] != null)
                {
                    Com.Printf("\\\"" + Cmd.Argv(1) + "\\\" = \\\"" + Globals.keybindings[b] + "\\\"\\n");
                }
                else
                {
                    Com.Printf("\\\"" + Cmd.Argv(1) + "\\\" is not bound\\n");
                }
                return;
            }

            string cmd = "";

            for (int i = 2; i < c; i++)
            {
                cmd += Cmd.Argv(i);
                if (i != (c - 1))
                {
                    cmd += " ";
                }
            }

            SetBinding(b, cmd);
        }
Пример #25
0
        /**
         * A client issued an rcon command. Shift down the remaining args Redirect
         * all printfs fromt hte server to the client.
         */
        public static void SVC_RemoteCommand()
        {
            int    i;
            string remaining;

            i = SV_MAIN.Rcon_Validate();

            var msg = Lib.CtoJava(Globals.net_message.data, 4, 1024);

            if (i == 0)
            {
                Com.Printf("Bad rcon from " + NET.AdrToString(Globals.net_from) + ":\n" + msg + "\n");
            }
            else
            {
                Com.Printf("Rcon from " + NET.AdrToString(Globals.net_from) + ":\n" + msg + "\n");
            }

            Com.BeginRedirect(
                Defines.RD_PACKET,
                SV_SEND.sv_outputbuf,
                Defines.SV_OUTPUTBUF_LENGTH,
                (target, buffer) => { SV_SEND.SV_FlushRedirect(target, Lib.stringToBytes(buffer.ToString())); }
                );

            if (0 == SV_MAIN.Rcon_Validate())
            {
                Com.Printf("Bad rcon_password.\n");
            }
            else
            {
                remaining = "";

                for (i = 2; i < Cmd.Argc(); i++)
                {
                    remaining += Cmd.Argv(i);
                    remaining += " ";
                }

                Cmd.ExecuteString(remaining);
            }

            Com.EndRedirect();
        }
Пример #26
0
        static void KeyDown(kbutton_t b)
        {
            int    k;
            string c;

            c = Cmd.Argv(1);
            if (c.Length > 0)
            {
                k = Lib.Atoi(c);
            }
            else
            {
                k = -1;
            }
            if (k == b.down[0] || k == b.down[1])
            {
                return;
            }
            if (b.down[0] == 0)
            {
                b.down[0] = k;
            }
            else if (b.down[1] == 0)
            {
                b.down[1] = k;
            }
            else
            {
                Com.Printf("Three keys down for a button!\\n");
                return;
            }

            if ((b.state & 1) != 0)
            {
                return;
            }
            c          = Cmd.Argv(2);
            b.downtime = Lib.Atoi(c);
            if (b.downtime == 0)
            {
                b.downtime = Globals.sys_frame_time - 100;
            }
            b.state |= 3;
        }
Пример #27
0
        void Play()
        {
            int    i;
            string name;
            sfx_t  sfx;

            i = 1;
            while (i < Cmd.Argc())
            {
                name = new string (Cmd.Argv(i));
                if (name.IndexOf('.') == -1)
                {
                    name += ".wav";
                }
                sfx = RegisterSound(name);
                StartSound(null, Globals.cl.playernum + 1, 0, sfx, 1F, 1F, 0F);
                i++;
            }
        }
Пример #28
0
        public static void SV_Loadgame_f( )
        {
            if (Cmd.Argc() != 2)
            {
                Com.Printf("USAGE: loadgame <directory>\\n");
                return;
            }

            Com.Printf("Loading game...\\n");
            var dir = Cmd.Argv(1);

            if ((dir.IndexOf("..") > -1) || (dir.IndexOf("/") > -1) || (dir.IndexOf("\\\\") > -1))
            {
                Com.Printf("Bad savedir.\\n");
            }

            var       name = FS.Gamedir() + "/save/" + Cmd.Argv(1) + "/server.ssv";
            QuakeFile f;

            try
            {
                f = new QuakeFile(name, FileAccess.Read);
            }
            catch (FileNotFoundException e)
            {
                Com.Printf("No such savegame: " + name + "\\n");
                return;
            }

            try
            {
                f.Dispose();
            }
            catch (IOException e1)
            {
                e1.PrintStackTrace();
            }

            SV_CopySaveGame(Cmd.Argv(1), "current");
            SV_ReadServerFile();
            SV_INIT.sv.state = Defines.ss_dead;
            SV_INIT.SV_Map(false, SV_INIT.svs.mapcmd, true);
        }
Пример #29
0
        public static void Dir_f( )
        {
            String path     = null;
            String findname = null;
            var    wildcard = "*.*";

            String[] dirnames;
            if (Cmd.Argc() != 1)
            {
                wildcard = Cmd.Argv(1);
            }

            while ((path = NextPath(path)) != null)
            {
                var tmp = findname;
                findname = path + '/' + wildcard;
                if (tmp != null)
                {
                    tmp.Replace("\\\\\\\\", "/");
                }
                Com.Printf("Directory of " + findname + '\\');
                Com.Printf("----\\n");
                dirnames = ListFiles(findname, 0, 0);
                if (dirnames != null)
                {
                    var index = 0;
                    for (var i = 0; i < dirnames.Length; i++)
                    {
                        if ((index = dirnames[i].LastIndexOf('/')) > 0)
                        {
                            Com.Printf(dirnames[i].Substring(index + 1, dirnames[i].Length) + '\\');
                        }
                        else
                        {
                            Com.Printf(dirnames[i] + '\\');
                        }
                    }
                }

                Com.Printf("\\n");
            }
        }
Пример #30
0
        public static void SV_Configstrings_f( )
        {
            Int32 start;

            Com.DPrintf("Configstrings() from " + SV_MAIN.sv_client.name + "\\n");
            if (SV_MAIN.sv_client.state != Defines.cs_connected)
            {
                Com.Printf("configstrings not valid -- already spawned\\n");
                return;
            }

            if (Lib.Atoi(Cmd.Argv(1)) != SV_INIT.svs.spawncount)
            {
                Com.Printf("SV_Configstrings_f from different level\\n");
                SV_New_f();
                return;
            }

            start = Lib.Atoi(Cmd.Argv(2));
            while (SV_MAIN.sv_client.netchan.message.cursize < Defines.MAX_MSGLEN / 2 && start < Defines.MAX_CONFIGSTRINGS)
            {
                if (SV_INIT.sv.configstrings[start] != null && SV_INIT.sv.configstrings[start].Length != 0)
                {
                    MSG.WriteByte(SV_MAIN.sv_client.netchan.message, Defines.svc_configstring);
                    MSG.WriteShort(SV_MAIN.sv_client.netchan.message, start);
                    MSG.WriteString(SV_MAIN.sv_client.netchan.message, SV_INIT.sv.configstrings[start]);
                }

                start++;
            }

            if (start == Defines.MAX_CONFIGSTRINGS)
            {
                MSG.WriteByte(SV_MAIN.sv_client.netchan.message, Defines.svc_stufftext);
                MSG.WriteString(SV_MAIN.sv_client.netchan.message, "cmd baselines " + SV_INIT.svs.spawncount + " 0\\n");
            }
            else
            {
                MSG.WriteByte(SV_MAIN.sv_client.netchan.message, Defines.svc_stufftext);
                MSG.WriteString(SV_MAIN.sv_client.netchan.message, "cmd configstrings " + SV_INIT.svs.spawncount + " " + start + "\\n");
            }
        }