Print() 공개 정적인 메소드

Con_Printf
public static Print ( string fmt ) : void
fmt string
리턴 void
예제 #1
0
        // Host_Startdemos_f
        private static void Startdemos_f()
        {
            if (Client.cls.state == cactive_t.ca_dedicated)
            {
                if (!Server.sv.active)
                {
                    Cbuf.AddText("map start\n");
                }
                return;
            }

            int c = Cmd.Argc - 1;

            if (c > Client.MAX_DEMOS)
            {
                Con.Print("Max {0} demos in demoloop\n", Client.MAX_DEMOS);
                c = Client.MAX_DEMOS;
            }
            Con.Print("{0} demo(s) in loop\n", c);

            for (int i = 1; i < c + 1; i++)
            {
                Client.cls.demos[i - 1] = Common.Copy(Cmd.Argv(i), Client.MAX_DEMONAME);
            }

            if (!Server.sv.active && Client.cls.demonum != -1 && !Client.cls.demoplayback)
            {
                Client.cls.demonum = 0;
                Client.NextDemo();
            }
            else
            {
                Client.cls.demonum = -1;
            }
        }
예제 #2
0
        // Cmd_Alias_f
        // Creates a new command that executes a command string (possibly ; seperated)
        private static void Alias_f()
        {
            if (_Argc == 1)
            {
                Con.Print("Current alias commands:\n");
                foreach (KeyValuePair <string, string> alias in _Aliases)
                {
                    Con.Print("{0} : {1}\n", alias.Key, alias.Value);
                }
                return;
            }

            string name = _Argv[1];

            if (name.Length >= MAX_ALIAS_NAME)
            {
                Con.Print("Alias name is too long\n");
                return;
            }

            // copy the rest of the command line
            StringBuilder sb = new StringBuilder(1024);

            for (int i = 2; i < _Argc; i++)
            {
                sb.Append(_Argv[i]);
                if (i + 1 < _Argc)
                {
                    sb.Append(" ");
                }
            }
            sb.AppendLine();
            _Aliases[name] = sb.ToString();
        }
예제 #3
0
        /// <summary>
        /// CL_Stop_f
        /// stop recording a demo
        /// </summary>
        private static void Stop_f()
        {
            if (cmd.Source != cmd_source_t.src_command)
            {
                return;
            }

            if (!cls.demorecording)
            {
                Con.Print("Not recording a demo.\n");
                return;
            }

            // write a disconnect message to the demo file
            net.Message.Clear();
            net.Message.WriteByte(protocol.svc_disconnect);
            WriteDemoMessage();

            // finish up
            if (cls.demofile != null)
            {
                cls.demofile.Dispose();
                cls.demofile = null;
            }
            cls.demorecording = false;
            Con.Print("Completed demo\n");
        }
예제 #4
0
        // PR_Profile_f
        private static void Profile_f()
        {
            if (_Functions == null)
            {
                return;
            }

            dfunction_t best;
            int         num = 0;

            do
            {
                int max = 0;
                best = null;
                for (int i = 0; i < _Functions.Length; i++)
                {
                    dfunction_t f = _Functions[i];
                    if (f.profile > max)
                    {
                        max  = f.profile;
                        best = f;
                    }
                }
                if (best != null)
                {
                    if (num < 10)
                    {
                        Con.Print("{0,7} {1}\n", best.profile, GetString(best.s_name));
                    }
                    num++;
                    best.profile = 0;
                }
            } while(best != null);
        }
예제 #5
0
        static void Test5_f()
        {
            Entity p = Client.ViewEntity;

            if (p == null)
            {
                return;
            }

            OpenTK.Vector3 org = p.origin;

            for (int i = 0; i < Server.sv.edicts.Length; i++)
            {
                edict_t ed = Server.sv.edicts[i];

                if (ed.free)
                {
                    continue;
                }

                OpenTK.Vector3 vmin, vmax;
                Mathlib.Copy(ref ed.v.absmax, out vmax);
                Mathlib.Copy(ref ed.v.absmin, out vmin);

                if (org.X >= vmin.X && org.Y >= vmin.Y && org.Z >= vmin.Z &&
                    org.X <= vmax.X && org.Y <= vmax.Y && org.Z <= vmax.Z)
                {
                    Con.Print("{0}\n", i);
                }
            }
        }
예제 #6
0
        /// <summary>
        /// NET_SendUnreliableMessage
        /// returns 0 if the message connot be delivered reliably, but the connection
        ///		is still considered valid
        /// returns 1 if the message was sent properly
        /// returns -1 if the connection died
        /// </summary>
        public static int SendUnreliableMessage(qsocket_t sock, MsgWriter data)
        {
            if (sock == null)
            {
                return(-1);
            }

            if (sock.disconnected)
            {
                Con.Print("NET_SendMessage: disconnected socket\n");
                return(-1);
            }

            SetNetTime();

            int r = _Drivers[sock.driver].SendUnreliableMessage(sock, data);

            if (r == 1 && sock.driver != 0)
            {
                _UnreliableMessagesSent++;
            }

            if (_IsRecording)
            {
                _VcrSendMessage.time    = Host.Time;
                _VcrSendMessage.op      = VcrOp.VCR_OP_SENDMESSAGE;
                _VcrSendMessage.session = 1;// (long)sock; Uze todo: ???????
                _VcrSendMessage.ret     = r;
                byte[] buf = Sys.StructureToBytes(ref _VcrSendMessage);
                Host.VcrWriter.Write(buf);
            }

            return(r);
        }
예제 #7
0
        // Con_Init (void)
        public static void Init()
        {
            _DebugLog = (Common.CheckParm("-condebug") > 0);
            if (_DebugLog)
            {
                string path = Path.Combine(Common.GameDir, LOG_FILE_NAME);
                if (File.Exists(path))
                {
                    File.Delete(path);
                }

                _Log = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read);
            }

            _LineWidth = -1;
            CheckResize();

            Con.Print("Console initialized.\n");

            //
            // register our commands
            //
            if (_NotifyTime == null)
            {
                _NotifyTime = new Cvar("con_notifytime", "3");
            }

            Cmd.Add("toggleconsole", ToggleConsole_f);
            Cmd.Add("messagemode", MessageMode_f);
            Cmd.Add("messagemode2", MessageMode2_f);
            Cmd.Add("clear", Clear_f);

            _IsInitialized = true;
        }
예제 #8
0
        /// <summary>
        /// Host_Error
        /// This shuts down both the client and server
        /// </summary>
        public static void Error(string error, params object[] args)
        {
            _ErrorDepth++;
            try
            {
                if (_ErrorDepth > 1)
                {
                    Sys.Error("Host_Error: recursively entered. " + error, args);
                }

                Scr.EndLoadingPlaque();         // reenable screen updates

                string message = (args.Length > 0 ? String.Format(error, args) : error);
                Con.Print("Host_Error: {0}\n", message);

                if (Server.sv.active)
                {
                    ShutdownServer(false);
                }

                if (Client.cls.state == cactive_t.ca_dedicated)
                {
                    Sys.Error("Host_Error: {0}\n", message);    // dedicated servers exit
                }
                Client.Disconnect();
                Client.cls.demonum = -1;

                throw new EndGameException(); // longjmp (host_abortserver, 1);
            }
            finally
            {
                _ErrorDepth--;
            }
        }
예제 #9
0
 // PrintStats(qsocket_t* s)
 private void PrintStats(qsocket_t s)
 {
     Con.Print("canSend = {0:4}   \n", s.canSend);
     Con.Print("sendSeq = {0:4}   ", s.sendSequence);
     Con.Print("recvSeq = {0:4}   \n", s.receiveSequence);
     Con.Print("\n");
 }
예제 #10
0
 private static void ShowNet(string s)
 {
     if (_ShowNet.Value == 2)
     {
         Con.Print("{0,3}:{1}\n", Net.Reader.Position - 1, s);
     }
 }
예제 #11
0
        // S_SoundList
        private static void SoundList()
        {
            int total = 0;

            for (int i = 0; i < _NumSfx; i++)
            {
                sfx_t      sfx = _KnownSfx[i];
                sfxcache_t sc  = (sfxcache_t)Cache.Check(sfx.cache);
                if (sc == null)
                {
                    continue;
                }

                int size = sc.length * sc.width * (sc.stereo + 1);
                total += size;
                if (sc.loopstart >= 0)
                {
                    Con.Print("L");
                }
                else
                {
                    Con.Print(" ");
                }
                Con.Print("({0:d2}b) {1:g6} : {2}\n", sc.width * 8, size, sfx.name);
            }
            Con.Print("Total resident: {0}\n", total);
        }
예제 #12
0
        /// <summary>
        /// CL_KeepaliveMessage
        /// When the client is taking a long time to load stuff, send keepalive messages
        /// so the server doesn't disconnect.
        /// </summary>
        private static void KeepaliveMessage()
        {
            if (Server.IsActive)
            {
                return; // no need if server is local
            }
            if (cls.demoplayback)
            {
                return;
            }

            // read messages from server, should just be nops
            Net.Message.SaveState(ref _MsgState);

            int ret;

            do
            {
                ret = GetMessage();
                switch (ret)
                {
                default:
                    Host.Error("CL_KeepaliveMessage: CL_GetMessage failed");
                    break;

                case 0:
                    break;      // nothing waiting

                case 1:
                    Host.Error("CL_KeepaliveMessage: received a message");
                    break;

                case 2:
                    if (Net.Reader.ReadByte() != Protocol.svc_nop)
                    {
                        Host.Error("CL_KeepaliveMessage: datagram wasn't a nop");
                    }
                    break;
                }
            } while(ret != 0);

            Net.Message.RestoreState(_MsgState);

            // check time
            float time = (float)Sys.GetFloatTime();

            if (time - _LastMsg < 5)
            {
                return;
            }

            _LastMsg = time;

            // write out a nop
            Con.Print("--> client to server keepalive\n");

            cls.message.WriteByte(Protocol.clc_nop);
            Net.SendMessage(cls.netcon, cls.message);
            cls.message.Clear();
        }
예제 #13
0
        // NET_Port_f
        static void Port_f()
        {
            if (Cmd.Argc != 2)
            {
                Con.Print("\"port\" is \"{0}\"\n", HostPort);
                return;
            }

            int n = Common.atoi(Cmd.Argv(1));

            if (n < 1 || n > 65534)
            {
                Con.Print("Bad value, must be between 1 and 65534\n");
                return;
            }

            _DefHostPort = n;
            HostPort     = n;

            if (_IsListening)
            {
                // force a change to the new port
                Cbuf.AddText("listen 0\n");
                Cbuf.AddText("listen 1\n");
            }
        }
예제 #14
0
 // VID_DescribeModes_f
 static void DescribeModes_f()
 {
     for (int i = 0; i < _Modes.Length; i++)
     {
         Con.Print("{0}:{1}\n", i, GetExtModeDescription(i));
     }
 }
예제 #15
0
        // ED_Count
        //
        // For debugging
        static void EdictCount()
        {
            int active = 0, models = 0, solid = 0, step = 0;

            for (int i = 0; i < Server.sv.num_edicts; i++)
            {
                edict_t ent = Server.EdictNum(i);
                if (ent.free)
                {
                    continue;
                }

                active++;
                if (ent.v.solid != 0)
                {
                    solid++;
                }

                if (ent.v.model != 0)
                {
                    models++;
                }

                if (ent.v.movetype == Movetypes.MOVETYPE_STEP)
                {
                    step++;
                }
            }

            Con.Print("num_edicts:{0}\n", Server.sv.num_edicts);
            Con.Print("active    :{0}\n", active);
            Con.Print("view      :{0}\n", models);
            Con.Print("touch     :{0}\n", solid);
            Con.Print("step      :{0}\n", step);
        }
예제 #16
0
        // void	Cmd_ForwardToServer (void);
        // adds the current command line as a clc_stringcmd to the client message.
        // things like godmode, noclip, etc, are commands directed to the server,
        // so when they are typed in at the console, they will need to be forwarded.
        //
        // Sends the entire command line over to the server
        public static void ForwardToServer()
        {
            if (Client.cls.state != cactive_t.ca_connected)
            {
                Con.Print("Can't \"{0}\", not connected\n", Cmd.Argv(0));
                return;
            }

            if (Client.cls.demoplayback)
            {
                return;         // not really connected
            }
            MsgWriter writer = Client.cls.message;

            writer.WriteByte(Protocol.clc_stringcmd);
            if (!Cmd.Argv(0).Equals("cmd"))
            {
                writer.Print(Cmd.Argv(0) + " ");
            }
            if (Cmd.Argc > 1)
            {
                writer.Print(Cmd.Args);
            }
            else
            {
                writer.Print("\n");
            }
        }
예제 #17
0
        // NET_Stats_f
        private void Stats_f()
        {
            if (cmd.Argc == 1)
            {
                Con.Print("unreliable messages sent   = %i\n", net.UnreliableMessagesSent);
                Con.Print("unreliable messages recv   = %i\n", net.UnreliableMessagesReceived);
                Con.Print("reliable messages sent     = %i\n", net.MessagesSent);
                Con.Print("reliable messages received = %i\n", net.MessagesReceived);
                Con.Print("packetsSent                = %i\n", packetsSent);
                Con.Print("packetsReSent              = %i\n", packetsReSent);
                Con.Print("packetsReceived            = %i\n", packetsReceived);
                Con.Print("receivedDuplicateCount     = %i\n", receivedDuplicateCount);
                Con.Print("shortPacketCount           = %i\n", shortPacketCount);
                Con.Print("droppedDatagrams           = %i\n", droppedDatagrams);
            }
            else if (cmd.Argv(1) == "*")
            {
                foreach (qsocket_t s in net.ActiveSockets)
                {
                    PrintStats(s);
                }

                foreach (qsocket_t s in net.FreeSockets)
                {
                    PrintStats(s);
                }
            }
            else
            {
                qsocket_t sock    = null;
                string    cmdAddr = cmd.Argv(1);

                foreach (qsocket_t s in net.ActiveSockets)
                {
                    if (common.SameText(s.address, cmdAddr))
                    {
                        sock = s;
                        break;
                    }
                }

                if (sock == null)
                {
                    foreach (qsocket_t s in net.FreeSockets)
                    {
                        if (common.SameText(s.address, cmdAddr))
                        {
                            sock = s;
                            break;
                        }
                    }
                }
                if (sock == null)
                {
                    return;
                }
                PrintStats(sock);
            }
        }
예제 #18
0
        // SCR_ScreenShot_f
        private static void ScreenShot_f()
        {
            //
            // find a file name to save it to
            //
            string path = null;
            int    i;

            for (i = 0; i <= 999; i++)
            {
                path = Path.Combine(Common.GameDir, String.Format("quake{0:D3}.tga", i));
                if (Sys.GetFileTime(path) == DateTime.MinValue)
                {
                    break;      // file doesn't exist
                }
            }
            if (i == 100)
            {
                Con.Print("SCR_ScreenShot_f: Couldn't create a file\n");
                return;
            }

            FileStream fs = Sys.FileOpenWrite(path, true);

            if (fs == null)
            {
                Con.Print("SCR_ScreenShot_f: Couldn't create a file\n");
                return;
            }
            using (BinaryWriter writer = new BinaryWriter(fs))
            {
                // Write tga header (18 bytes)
                writer.Write((ushort)0);
                writer.Write((byte)2);   //buffer[2] = 2; uncompressed type
                writer.Write((byte)0);
                writer.Write((uint)0);
                writer.Write((uint)0);
                writer.Write((byte)(glWidth & 0xff));
                writer.Write((byte)(glWidth >> 8));
                writer.Write((byte)(glHeight & 0xff));
                writer.Write((byte)(glHeight >> 8));
                writer.Write((byte)24);   // pixel size
                writer.Write((ushort)0);

                byte[] buffer = new byte[glWidth * glHeight * 3];
                GL.ReadPixels(glX, glY, glWidth, glHeight, PixelFormat.Rgb, PixelType.UnsignedByte, buffer);

                // swap 012 to 102
                int c = glWidth * glHeight * 3;
                for (i = 0; i < c; i += 3)
                {
                    byte temp = buffer[i + 0];
                    buffer[i + 0] = buffer[i + 1];
                    buffer[i + 1] = temp;
                }
                writer.Write(buffer, 0, buffer.Length);
            }
            Con.Print("Wrote {0}\n", Path.GetFileName(path));
        }
예제 #19
0
 /// <summary>
 /// CheckMultiTextureExtensions
 /// </summary>
 static void CheckMultiTextureExtensions()
 {
     if (_glExtensions.Contains("GL_SGIS_multitexture ") && !Common.HasParam("-nomtex"))
     {
         Con.Print("Multitexture extensions found.\n");
         _glMTexable = true;
     }
 }
예제 #20
0
 // Cmd_Echo_f
 // Just prints the rest of the line to the console
 private static void Echo_f()
 {
     for (int i = 1; i < _Argc; i++)
     {
         Con.Print("{0} ", _Argv[i]);
     }
     Con.Print("\n");
 }
예제 #21
0
 // ED_PrintEdicts
 //
 // For debugging, prints all the entities in the current server
 public static void PrintEdicts()
 {
     Con.Print("{0} entities\n", Server.sv.num_edicts);
     for (int i = 0; i < Server.sv.num_edicts; i++)
     {
         PrintNum(i);
     }
 }
예제 #22
0
        // Host_Name_f
        static void Name_f()
        {
            if (Cmd.Argc == 1)
            {
                Con.Print("\"name\" is \"{0}\"\n", Client.Name);
                return;
            }

            string newName;

            if (Cmd.Argc == 2)
            {
                newName = Cmd.Argv(1);
            }
            else
            {
                newName = Cmd.Args;
            }

            if (newName.Length > 16)
            {
                newName = newName.Remove(15);
            }

            if (Cmd.Source == cmd_source_t.src_command)
            {
                if (Client.Name == newName)
                {
                    return;
                }

                Cvar.Set("_cl_name", newName);
                if (Client.Cls.state == ClientActivityState.Connected)
                {
                    Cmd.ForwardToServer();
                }

                return;
            }

            if (!String.IsNullOrEmpty(Host.HostClient.name) && Host.HostClient.name != "unconnected")
            {
                if (Host.HostClient.name != newName)
                {
                    Con.Print("{0} renamed to {1}\n", Host.HostClient.name, newName);
                }
            }

            Host.HostClient.name            = newName;
            Host.HostClient.edict.v.netname = Progs.NewString(newName);

            // send notification to all clients
            MessageWriter msg = Server.sv.reliable_datagram;

            msg.WriteByte(Protocol.svc_updatename);
            msg.WriteByte(Host.ClientNum);
            msg.WriteString(newName);
        }
예제 #23
0
        // Host_Color_f
        static void Color_f()
        {
            if (Cmd.Argc == 1)
            {
                Con.Print("\"color\" is \"{0} {1}\"\n", ((int)Client.Color) >> 4, ((int)Client.Color) & 0x0f);
                Con.Print("color <0-13> [0-13]\n");
                return;
            }

            int top, bottom;

            if (Cmd.Argc == 2)
            {
                top = bottom = Common.atoi(Cmd.Argv(1));
            }
            else
            {
                top    = Common.atoi(Cmd.Argv(1));
                bottom = Common.atoi(Cmd.Argv(2));
            }

            top &= 15;
            if (top > 13)
            {
                top = 13;
            }

            bottom &= 15;
            if (bottom > 13)
            {
                bottom = 13;
            }

            int playercolor = top * 16 + bottom;

            if (Cmd.Source == cmd_source_t.src_command)
            {
                Cvar.Set("_cl_color", playercolor);
                if (Client.Cls.state == ClientActivityState.Connected)
                {
                    Cmd.ForwardToServer();
                }

                return;
            }


            Host.HostClient.colors       = playercolor;
            Host.HostClient.edict.v.team = bottom + 1;

            // send notification to all clients
            MessageWriter msg = Server.sv.reliable_datagram;

            msg.WriteByte(Protocol.svc_updatecolors);
            msg.WriteByte(Host.ClientNum);
            msg.WriteByte(Host.HostClient.colors);
        }
예제 #24
0
        // Host_Name_f
        private static void Name_f()
        {
            if (cmd.Argc == 1)
            {
                Con.Print("\"name\" is \"{0}\"\n", client.Name);
                return;
            }

            string newName;

            if (cmd.Argc == 2)
            {
                newName = cmd.Argv(1);
            }
            else
            {
                newName = cmd.Args;
            }

            if (newName.Length > 16)
            {
                newName = newName.Remove(15);
            }

            if (cmd.Source == cmd_source_t.src_command)
            {
                if (client.Name == newName)
                {
                    return;
                }
                cvar.Set("_cl_name", newName);
                if (client.cls.state == cactive_t.ca_connected)
                {
                    cmd.ForwardToServer();
                }
                return;
            }

            if (!String.IsNullOrEmpty(host.HostClient.name) && host.HostClient.name != "unconnected")
            {
                if (host.HostClient.name != newName)
                {
                    Con.Print("{0} renamed to {1}\n", host.HostClient.name, newName);
                }
            }

            host.HostClient.name            = newName;
            host.HostClient.edict.v.netname = progs.NewString(newName);

            // send notification to all clients
            MsgWriter msg = server.sv.reliable_datagram;

            msg.WriteByte(protocol.svc_updatename);
            msg.WriteByte(host.ClientNum);
            msg.WriteString(newName);
        }
예제 #25
0
        /// <summary>
        /// PR_RunError
        /// Aborts the currently executing function
        /// </summary>
        public static void RunError(string fmt, params object[] args)
        {
            PrintStatement(ref _Statements[_xStatement]);
            StackTrace();
            Con.Print(fmt, args);

            _Depth = 0;         // dump the stack so host_error can shutdown functions

            host.Error("Program error");
        }
예제 #26
0
        // Host_Begin_f
        private static void Begin_f()
        {
            if (Cmd.Source == cmd_source_t.src_command)
            {
                Con.Print("begin is not valid from the console\n");
                return;
            }

            Host.HostClient.spawned = true;
        }
예제 #27
0
        /// <summary>
        /// ED_PrintEdict_f
        /// For debugging, prints a single edict
        /// </summary>
        static void PrintEdict_f()
        {
            int i = Common.atoi(Cmd.Argv(1));

            if (i >= Server.sv.num_edicts)
            {
                Con.Print("Bad edict number\n");
                return;
            }
            Progs.PrintNum(i);
        }
예제 #28
0
        /// <summary>
        /// ED_PrintEdict_f
        /// For debugging, prints a single edict
        /// </summary>
        private static void PrintEdict_f()
        {
            int i = common.atoi(cmd.Argv(1));

            if (i >= server.sv.num_edicts)
            {
                Con.Print("Bad edict number\n");
                return;
            }
            progs.PrintNum(i);
        }
예제 #29
0
        private static void PrintFrameName(model_t m, int frame)
        {
            aliashdr_t hdr = Mod.GetExtraData(m);

            if (hdr == null)
            {
                return;
            }

            Con.Print("frame {0}: {1}\n", frame, hdr.frames[frame].name);
        }
예제 #30
0
 static void PrintSlistTrailer()
 {
     if (HostCacheCount != 0)
     {
         Con.Print("== end list ==\n\n");
     }
     else
     {
         Con.Print("No Quake servers found.\n\n");
     }
 }