示例#1
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);
            }
        }
示例#2
0
        public static void SV_ConSay_f( )
        {
            client_t client;
            Int32    j;
            String   p;
            String   text;

            if (Cmd.Argc() < 2)
            {
                return;
            }
            text = "console: ";
            p    = Cmd.Args();
            if (p[0] == '"')
            {
                p = p.Substring(1, p.Length - 1);
            }

            text += p;
            for (j = 0; j < SV_MAIN.maxclients.value; j++)
            {
                client = SV_INIT.svs.clients[j];
                if (client.state != Defines.cs_spawned)
                {
                    continue;
                }
                SV_SEND.SV_ClientPrintf(client, Defines.PRINT_CHAT, text + "\\n");
            }
        }
示例#3
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();
        }
示例#4
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));
                }
            }
示例#5
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++;
            }
示例#6
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");
        }
示例#7
0
文件: V.cs 项目: optimus-code/Q2Sharp
            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);
            }
示例#8
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");
        }
示例#9
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;
        }
示例#10
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);
        }
示例#11
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");
            }
        }
示例#12
0
        public static void SV_DumpUser_f( )
        {
            if (Cmd.Argc() != 2)
            {
                Com.Printf("Usage: info <userid>\\n");
                return;
            }

            if (!SV_SetPlayer())
            {
                return;
            }
            Com.Printf("userinfo\\n");
            Com.Printf("--------\\n");
            Info.Print(SV_MAIN.sv_client.userinfo);
        }
示例#13
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++;
            }
        }
示例#14
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);
        }
示例#15
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);
        }
示例#16
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);
        }
示例#17
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();
        }
示例#18
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);
        }
示例#19
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++;
            }
        }
示例#20
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");
            }
        }
示例#21
0
        public static void SV_Kick_f( )
        {
            if (!SV_INIT.svs.initialized)
            {
                Com.Printf("No server running.\\n");
                return;
            }

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

            if (!SV_SetPlayer())
            {
                return;
            }
            SV_SEND.SV_BroadcastPrintf(Defines.PRINT_HIGH, SV_MAIN.sv_client.name + " was kicked\\n");
            SV_SEND.SV_ClientPrintf(SV_MAIN.sv_client, Defines.PRINT_HIGH, "You were kicked from the game\\n");
            SV_MAIN.SV_DropClient(SV_MAIN.sv_client);
            SV_MAIN.sv_client.lastmessage = SV_INIT.svs.realtime;
        }
示例#22
0
        /**
         * Handles variable inspection and changing from the console.
         */
        public static bool Command()
        {
            cvar_t v;

            // check variables
            v = Cvar.FindVar(Cmd.Argv(0));

            if (v == null)
            {
                return(false);
            }

            // perform a variable print or set
            if (Cmd.Argc() == 1)
            {
                Com.Printf("\"" + v.name + "\" is \"" + v.@string + "\"\n");

                return(true);
            }

            Cvar.Set(v.name, Cmd.Argv(1));

            return(true);
        }
示例#23
0
 // ClientCommand and ServerCommand parameter access
 public int argc()
 {
     return(Cmd.Argc());
 }
示例#24
0
        public static void SV_ServerRecord_f( )
        {
            String name;

            Byte[]    buf_data = new Byte[32768];
            sizebuf_t buf      = new sizebuf_t();
            Int32     len;
            Int32     i;

            if (Cmd.Argc() != 2)
            {
                Com.Printf("serverrecord <demoname>\\n");
                return;
            }

            if (SV_INIT.svs.demofile != null)
            {
                Com.Printf("Already recording.\\n");
                return;
            }

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

            name = FS.Gamedir() + "/demos/" + Cmd.Argv(1) + ".dm2";
            Com.Printf("recording to " + name + ".\\n");
            FS.CreatePath(name);
            try
            {
                SV_INIT.svs.demofile = new QuakeFile(name, FileAccess.ReadWrite);
            }
            catch (Exception e)
            {
                Com.Printf("ERROR: couldn't open.\\n");
                return;
            }

            SZ.Init(SV_INIT.svs.demo_multicast, SV_INIT.svs.demo_multicast_buf, SV_INIT.svs.demo_multicast_buf.Length);
            SZ.Init(buf, buf_data, buf_data.Length);
            MSG.WriteByte(buf, Defines.svc_serverdata);
            MSG.WriteLong(buf, Defines.PROTOCOL_VERSION);
            MSG.WriteLong(buf, SV_INIT.svs.spawncount);
            MSG.WriteByte(buf, 2);
            MSG.WriteString(buf, Cvar.VariableString("gamedir"));
            MSG.WriteShort(buf, -1);
            MSG.WriteString(buf, SV_INIT.sv.configstrings[Defines.CS_NAME]);
            for (i = 0; i < Defines.MAX_CONFIGSTRINGS; i++)
            {
                if (SV_INIT.sv.configstrings[i].Length == 0)
                {
                    MSG.WriteByte(buf, Defines.svc_configstring);
                    MSG.WriteShort(buf, i);
                    MSG.WriteString(buf, SV_INIT.sv.configstrings[i]);
                }
            }

            Com.DPrintf("signon message length: " + buf.cursize + "\\n");
            len = EndianHandler.SwapInt(buf.cursize);
            try
            {
                SV_INIT.svs.demofile.Write(len);
                SV_INIT.svs.demofile.Write(buf.data, 0, buf.cursize);
            }
            catch (IOException e1)
            {
                e1.PrintStackTrace();
            }
        }
示例#25
0
        /*
         * ==================
         * SV_SetPlayer
         *
         * Sets sv_client and sv_player to the player with idnum Cmd.Argv(1)
         * ==================
         */
        public static bool SV_SetPlayer()
        {
            client_t cl;
            int      i;
            int      idnum;
            string   s;

            if (Cmd.Argc() < 2)
            {
                return(false);
            }

            s = Cmd.Argv(1);

            // numeric values are just slot numbers
            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);
            }

            // check for a name match
            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);
        }
示例#26
0
            public override void Execute( )
            {
                Int32      l, x;
                Int32      line;
                FileStream f;

                Byte[] buffer = new Byte[1024];
                String name;

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

                name = FS.Gamedir() + "/" + Cmd.Argv(1) + ".txt";
                Com.Printf("Dumped console text to " + name + ".\\n");
                FS.CreatePath(name);
                f = Lib.Fopen(name, FileMode.OpenOrCreate, FileAccess.ReadWrite);
                if (f == null)
                {
                    Com.Printf("ERROR: couldn't open.\\n");
                    return;
                }

                for (l = con.current - con.totallines + 1; l <= con.current; l++)
                {
                    line = (l % con.totallines) * con.linewidth;
                    for (x = 0; x < con.linewidth; x++)
                    {
                        if (con.text[line + x] != ' ')
                        {
                            break;
                        }
                    }
                    if (x != con.linewidth)
                    {
                        break;
                    }
                }

                buffer[con.linewidth] = 0;
                for ( ; l <= con.current; l++)
                {
                    line = (l % con.totallines) * con.linewidth;
                    System.Array.Copy(con.text, line, buffer, 0, con.linewidth);
                    for (x = con.linewidth - 1; x >= 0; x--)
                    {
                        if (buffer[x] == ' ')
                        {
                            buffer[x] = 0;
                        }
                        else
                        {
                            break;
                        }
                    }

                    for (x = 0; buffer[x] != 0; x++)
                    {
                        buffer[x] &= 0x7f;
                    }
                    buffer[x] = ( Byte )'\\';
                    try
                    {
                        f.Write(buffer, 0, x + 1);
                    }
                    catch (IOException e)
                    {
                    }
                }

                Lib.Fclose(f);
            }