Пример #1
0
        // CL_SendMove
        public static void SendMove(ref usercmd_t cmd)
        {
            cl.cmd = cmd; // cl.cmd = *cmd - struct copying!!!

            MsgWriter msg = new MsgWriter(128);

            //
            // send the movement message
            //
            msg.WriteByte(Protocol.clc_move);

            msg.WriteFloat((float)cl.mtime[0]);	// so server can get ping times

            msg.WriteAngle(cl.viewangles.X);
            msg.WriteAngle(cl.viewangles.Y);
            msg.WriteAngle(cl.viewangles.Z);

            msg.WriteShort((short)cmd.forwardmove);
            msg.WriteShort((short)cmd.sidemove);
            msg.WriteShort((short)cmd.upmove);

            //
            // send button bits
            //
            int bits = 0;

            if ((ClientInput.AttackBtn.state & 3) != 0)
                bits |= 1;
            ClientInput.AttackBtn.state &= ~2;

            if ((ClientInput.JumpBtn.state & 3) != 0)
                bits |= 2;
            ClientInput.JumpBtn.state &= ~2;

            msg.WriteByte(bits);

            msg.WriteByte(ClientInput.Impulse);
            ClientInput.Impulse = 0;

            //
            // deliver the message
            //
            if (cls.demoplayback)
                return;

            //
            // allways dump the first two message, because it may contain leftover inputs
            // from the last level
            //
            if (++cl.movemessages <= 2)
                return;

            if (Net.SendUnreliableMessage(cls.netcon, msg) == -1)
            {
                Con.Print("CL_SendMove: lost server connection\n");
                Disconnect();
            }
        }
Пример #2
0
        /// <summary>
        /// Create an instance of <see cref="TraceManager"/> giving the <see cref="LogWriter"/>.
        /// </summary>
        /// <param name="logWriter">The <see cref="LogWriter"/> that is used to write trace messages.</param>
        /// <param name="instrumentationProvider">The <see cref="ITracerInstrumentationProvider"/> used to determine if instrumentation should be enabled</param>
        public TraceManager(MsgWriter logWriter, ITracerInstrumentationProvider instrumentationProvider)
        {
            if (logWriter == null)
            {
                throw new ArgumentNullException("logWriter");
            }

            this.logWriter = logWriter;
            this.instrumentationProvider = instrumentationProvider;
        }
Пример #3
0
 /// <summary>
 /// Create an instance of <see cref="TraceManager"/> giving the <see cref="LogWriter"/>.
 /// </summary>
 /// <param name="logWriter">The <see cref="LogWriter"/> that is used to write trace messages.</param>
 public TraceManager(MsgWriter logWriter)
     : this(logWriter, new NullTracerInstrumentationProvider())
 {
 }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Tracer"/> class with the given logical operation name and activity id.
 /// </summary>
 /// <remarks>
 /// The activity id will override a previous activity id
 /// </remarks>
 /// <param name="operation">The operation for the <see cref="Tracer"/></param>
 /// <param name="activityId">The activity id</param>
 /// <param name="writer">The <see cref="MsgWriter"/> that is used to write trace messages</param>
 /// <param name="instrumentationConfiguration">configuration source that is used to determine instrumentation should be enabled</param>
 public Tracer(string operation, Guid activityId, MsgWriter writer, IConfigurationSource instrumentationConfiguration)
     : this(operation, activityId, writer, GetTracerInstrumentationProvider(instrumentationConfiguration))
 {
 }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Tracer"/> class with the given logical operation name and activity id.
        /// </summary>
        /// <remarks>
        /// This is meant to be used internally
        /// </remarks>
        /// <param name="operation">The operation for the <see cref="Tracer"/></param>
        /// <param name="activityId">The activity id</param>
        /// <param name="writer">The <see cref="MsgWriter"/> that is used to write trace messages</param>
        /// <param name="instrumentationProvider">Instrumentation provider to use for firing logical instrumentation events from Tracer.</param>
        /// <exception cref="ArgumentNullException"></exception>
        internal Tracer(string operation, Guid activityId, MsgWriter writer, ITracerInstrumentationProvider instrumentationProvider)
        {
            this.instrumentationProvider = instrumentationProvider;

            if (CheckTracingAvailable())
            {
                if (writer == null) throw new ArgumentNullException("writer", Resources.ExceptionWriterShouldNotBeNull);

                this.previousActivityId = GetActivityId();
                SetActivityId(activityId);

                this.writer = writer;

                Initialize(operation);
            }
        }
Пример #6
0
        // CL_SendMove
        public static void SendMove(ref usercmd_t cmd)
        {
            cl.cmd = cmd; // cl.cmd = *cmd - struct copying!!!

            MsgWriter msg = new MsgWriter(128);

            //
            // send the movement message
            //
            msg.WriteByte(protocol.clc_move);

            msg.WriteFloat((float)cl.mtime[0]);         // so server can get ping times

            msg.WriteAngle(cl.viewangles.X);
            msg.WriteAngle(cl.viewangles.Y);
            msg.WriteAngle(cl.viewangles.Z);

            msg.WriteShort((short)cmd.forwardmove);
            msg.WriteShort((short)cmd.sidemove);
            msg.WriteShort((short)cmd.upmove);

            //
            // send button bits
            //
            int bits = 0;

            if ((client_input.AttackBtn.state & 3) != 0)
            {
                bits |= 1;
            }
            client_input.AttackBtn.state &= ~2;

            if ((client_input.JumpBtn.state & 3) != 0)
            {
                bits |= 2;
            }
            client_input.JumpBtn.state &= ~2;

            msg.WriteByte(bits);

            msg.WriteByte(client_input.Impulse);
            client_input.Impulse = 0;

            //
            // deliver the message
            //
            if (cls.demoplayback)
            {
                return;
            }

            //
            // allways dump the first two message, because it may contain leftover inputs
            // from the last level
            //
            if (++cl.movemessages <= 2)
            {
                return;
            }

            if (net.SendUnreliableMessage(cls.netcon, msg) == -1)
            {
                Con.Print("CL_SendMove: lost server connection\n");
                Disconnect();
            }
        }
Пример #7
0
        public int SendMessage(qsocket_t sock, MsgWriter data)
        {
            if (sock.driverdata == null)
                return -1;

            qsocket_t sock2 = (qsocket_t)sock.driverdata;

            if ((sock2.receiveMessageLength + data.Length + 4) > Net.NET_MAXMESSAGE)
                Sys.Error("Loop_SendMessage: overflow\n");

            // message type
            int offset = sock2.receiveMessageLength;
            sock2.receiveMessage[offset++] = 1;

            // length
            sock2.receiveMessage[offset++] = (byte)(data.Length & 0xff);
            sock2.receiveMessage[offset++] = (byte)(data.Length >> 8);

            // align
            offset++;

            // message
            Buffer.BlockCopy(data.Data, 0, sock2.receiveMessage, offset, data.Length);
            sock2.receiveMessageLength = IntAlign(sock2.receiveMessageLength + data.Length + 4);

            sock.canSend = false;
            return 1;
        }
Пример #8
0
        /// <summary>
        /// NET_SendToAll
        /// This is a reliable *blocking* send to all attached clients.
        /// </summary>
        public static int SendToAll(MsgWriter data, int blocktime)
        {
            bool[] state1 = new bool[QDef.MAX_SCOREBOARD];
            bool[] state2 = new bool[QDef.MAX_SCOREBOARD];

            int count = 0;
            for (int i = 0; i < Server.svs.maxclients; i++)
            {
                Host.HostClient = Server.svs.clients[i];
                if (Host.HostClient.netconnection == null)
                    continue;

                if (Host.HostClient.active)
                {
                    if (Host.HostClient.netconnection.driver == 0)
                    {
                        SendMessage(Host.HostClient.netconnection, data);
                        state1[i] = true;
                        state2[i] = true;
                        continue;
                    }
                    count++;
                    state1[i] = false;
                    state2[i] = false;
                }
                else
                {
                    state1[i] = true;
                    state2[i] = true;
                }
            }

            double start = Sys.GetFloatTime();
            while (count > 0)
            {
                count = 0;
                for (int i = 0; i < Server.svs.maxclients; i++)
                {
                    Host.HostClient = Server.svs.clients[i];
                    if (!state1[i])
                    {
                        if (CanSendMessage(Host.HostClient.netconnection))
                        {
                            state1[i] = true;
                            SendMessage(Host.HostClient.netconnection, data);
                        }
                        else
                        {
                            GetMessage(Host.HostClient.netconnection);
                        }
                        count++;
                        continue;
                    }

                    if (!state2[i])
                    {
                        if (CanSendMessage(Host.HostClient.netconnection))
                        {
                            state2[i] = true;
                        }
                        else
                        {
                            GetMessage(Host.HostClient.netconnection);
                        }
                        count++;
                        continue;
                    }
                }
                if ((Sys.GetFloatTime() - start) > blocktime)
                    break;
            }
            return count;
        }
Пример #9
0
    public static int NET_SendToAll(MsgWriter data, int blocktime)
    {
        bool[] state1 = new bool[q_shared.MAX_SCOREBOARD];
        bool[] state2 = new bool[q_shared.MAX_SCOREBOARD];

        int count = 0;

        for (int i = 0; i < svs.maxclients; i++)
        {
            host_client = svs.clients[i];
            if (host_client.netconnection == null)
            {
                continue;
            }

            if (host_client.active)
            {
                if (host_client.netconnection.driver == 0)
                {
                    NET_SendMessage(host_client.netconnection, data);
                    state1[i] = true;
                    state2[i] = true;
                    continue;
                }
                count++;
                state1[i] = false;
                state2[i] = false;
            }
            else
            {
                state1[i] = true;
                state2[i] = true;
            }
        }

        double start = Sys_FloatTime();

        while (count > 0)
        {
            count = 0;
            for (int i = 0; i < svs.maxclients; i++)
            {
                host_client = svs.clients[i];
                if (!state1[i])
                {
                    if (NET_CanSendMessage(host_client.netconnection))
                    {
                        state1[i] = true;
                        NET_SendMessage(host_client.netconnection, data);
                    }
                    else
                    {
                        NET_GetMessage(host_client.netconnection);
                    }
                    count++;
                    continue;
                }

                if (!state2[i])
                {
                    if (NET_CanSendMessage(host_client.netconnection))
                    {
                        state2[i] = true;
                    }
                    else
                    {
                        NET_GetMessage(host_client.netconnection);
                    }
                    count++;
                    continue;
                }
            }
            if ((Sys_FloatTime() - start) > blocktime)
            {
                break;
            }
        }
        return(count);
    }
Пример #10
0
    public static void Host_ShutdownServer(bool crash)
    {
        if (!sv.active)
        {
            return;
        }

        sv.active = false;

        // stop all client sounds immediately
        if (cls.state == cactive_t.ca_connected)
        {
            CL_Disconnect();
        }

        // flush any pending messages - like the score!!!
        double start = Sys_FloatTime();
        int    count;

        do
        {
            count = 0;
            for (int i = 0; i < svs.maxclients; i++)
            {
                host_client = svs.clients[i];
                if (host_client.active && !host_client.message.IsEmpty)
                {
                    if (NET_CanSendMessage(host_client.netconnection))
                    {
                        NET_SendMessage(host_client.netconnection, host_client.message);
                        host_client.message.Clear();
                    }
                    else
                    {
                        NET_GetMessage(host_client.netconnection);
                        count++;
                    }
                }
            }
            if ((Sys_FloatTime() - start) > 3.0)
            {
                break;
            }
        }while (count > 0);

        // make sure all the clients know we're disconnecting
        MsgWriter writer = new MsgWriter(4);

        writer.MSG_WriteByte(q_shared.svc_disconnect);
        count = NET_SendToAll(writer, 5);
        if (count != 0)
        {
            Con_Printf("Host_ShutdownServer: NET_SendToAll failed for {0} clients\n", count);
        }

        for (int i = 0; i < svs.maxclients; i++)
        {
            host_client = svs.clients[i];
            if (host_client.active)
            {
                SV_DropClient(crash);
            }
        }

        //
        // clear structures
        //
        sv.Clear();
        for (int i = 0; i < svs.clients.Length; i++)
        {
            svs.clients[i].Clear();
        }
    }
Пример #11
0
 public int SendUnreliableMessage(qsocket_t sock, MsgWriter data)
 {
     throw new NotImplementedException();
 }
Пример #12
0
        /// <summary>
        /// NET_SendToAll
        /// This is a reliable *blocking* send to all attached clients.
        /// </summary>
        public static int SendToAll(MsgWriter data, int blocktime)
        {
            bool[] state1 = new bool[QDef.MAX_SCOREBOARD];
            bool[] state2 = new bool[QDef.MAX_SCOREBOARD];

            int count = 0;

            for (int i = 0; i < Server.svs.maxclients; i++)
            {
                Host.HostClient = Server.svs.clients[i];
                if (Host.HostClient.netconnection == null)
                {
                    continue;
                }

                if (Host.HostClient.active)
                {
                    if (Host.HostClient.netconnection.driver == 0)
                    {
                        SendMessage(Host.HostClient.netconnection, data);
                        state1[i] = true;
                        state2[i] = true;
                        continue;
                    }
                    count++;
                    state1[i] = false;
                    state2[i] = false;
                }
                else
                {
                    state1[i] = true;
                    state2[i] = true;
                }
            }

            double start = Sys.GetFloatTime();

            while (count > 0)
            {
                count = 0;
                for (int i = 0; i < Server.svs.maxclients; i++)
                {
                    Host.HostClient = Server.svs.clients[i];
                    if (!state1[i])
                    {
                        if (CanSendMessage(Host.HostClient.netconnection))
                        {
                            state1[i] = true;
                            SendMessage(Host.HostClient.netconnection, data);
                        }
                        else
                        {
                            GetMessage(Host.HostClient.netconnection);
                        }
                        count++;
                        continue;
                    }

                    if (!state2[i])
                    {
                        if (CanSendMessage(Host.HostClient.netconnection))
                        {
                            state2[i] = true;
                        }
                        else
                        {
                            GetMessage(Host.HostClient.netconnection);
                        }
                        count++;
                        continue;
                    }
                }
                if ((Sys.GetFloatTime() - start) > blocktime)
                {
                    break;
                }
            }
            return(count);
        }
Пример #13
0
 public client_static_t()
 {
     this.demos = new string[Client.MAX_DEMOS];
     this.message = new MsgWriter(1024); // like in Client_Init()
 }
Пример #14
0
        // vcrSendMessage
        // NET_Init (void)
        public static void Init()
        {
            for (int i2 = 0; i2 < _HostCache.Length; i2++)
            {
                _HostCache[i2] = new hostcache_t();
            }

            if (_Drivers == null)
            {
                if (Common.HasParam("-playback"))
                {
                    _Drivers = new INetDriver[]
                    {
                        new NetVcr()
                    };
                }
                else
                {
                    _Drivers = new INetDriver[]
                    {
                        new NetLoop(),
                        NetDatagram.Instance
                    };
                }
            }

            if (_LanDrivers == null)
            {
                _LanDrivers = new INetLanDriver[]
                {
                    NetTcpIp.Instance
                };
            }

            if (Common.HasParam("-record"))
            {
                _IsRecording = true;
            }

            int i = Common.CheckParm("-port");

            if (i == 0)
            {
                i = Common.CheckParm("-udpport");
            }
            if (i == 0)
            {
                i = Common.CheckParm("-ipxport");
            }

            if (i > 0)
            {
                if (i < Common.Argc - 1)
                {
                    _DefHostPort = Common.atoi(Common.Argv(i + 1));
                }
                else
                {
                    Sys.Error("Net.Init: you must specify a number after -port!");
                }
            }
            HostPort = _DefHostPort;

            if (Common.HasParam("-listen") || Client.cls.state == cactive_t.ca_dedicated)
            {
                _IsListening = true;
            }
            int numsockets = Server.svs.maxclientslimit;

            if (Client.cls.state != cactive_t.ca_dedicated)
            {
                numsockets++;
            }

            _FreeSockets   = new List <qsocket_t>(numsockets);
            _ActiveSockets = new List <qsocket_t>(numsockets);

            for (i = 0; i < numsockets; i++)
            {
                _FreeSockets.Add(new qsocket_t());
            }

            SetNetTime();

            // allocate space for network message buffer
            Message = new MsgWriter(NET_MAXMESSAGE);   // SZ_Alloc (&net_message, NET_MAXMESSAGE);
            Reader  = new MsgReader(Net.Message);

            if (_MessageTimeout == null)
            {
                _MessageTimeout = new Cvar("net_messagetimeout", "300");
                _HostName       = new Cvar("hostname", "UNNAMED");
            }

            Cmd.Add("slist", Slist_f);
            Cmd.Add("listen", Listen_f);
            Cmd.Add("maxplayers", MaxPlayers_f);
            Cmd.Add("port", Port_f);

            // initialize all the drivers
            _DriverLevel = 0;
            foreach (INetDriver driver in _Drivers)
            {
                driver.Init();
                if (driver.IsInitialized && _IsListening)
                {
                    driver.Listen(true);
                }
                _DriverLevel++;
            }

            //if (*my_ipx_address)
            //    Con_DPrintf("IPX address %s\n", my_ipx_address);
            if (!String.IsNullOrEmpty(_MyTcpIpAddress))
            {
                Con.DPrint("TCP/IP address {0}\n", _MyTcpIpAddress);
            }
        }
Пример #15
0
        /// <summary>
        /// Host_Spawn_f
        /// </summary>
        private static void Spawn_f()
        {
            if (cmd.Source == cmd_source_t.src_command)
            {
                Con.Print("spawn is not valid from the console\n");
                return;
            }

            if (host.HostClient.spawned)
            {
                Con.Print("Spawn not valid -- allready spawned\n");
                return;
            }

            edict_t ent;

            // run the entrance script
            if (server.sv.loadgame)
            {
                // loaded games are fully inited allready
                // if this is the last client to be connected, unpause
                server.sv.paused = false;
            }
            else
            {
                // set up the edict
                ent = host.HostClient.edict;

                ent.Clear(); //memset(&ent.v, 0, progs.entityfields * 4);
                ent.v.colormap = server.NumForEdict(ent);
                ent.v.team     = (host.HostClient.colors & 15) + 1;
                ent.v.netname  = progs.NewString(host.HostClient.name);

                // copy spawn parms out of the client_t
                progs.GlobalStruct.SetParams(host.HostClient.spawn_parms);

                // call the spawn function

                progs.GlobalStruct.time = (float)server.sv.time;
                progs.GlobalStruct.self = server.EdictToProg(server.Player);
                progs.Execute(progs.GlobalStruct.ClientConnect);

                if ((sys.GetFloatTime() - host.HostClient.netconnection.connecttime) <= server.sv.time)
                {
                    Con.DPrint("{0} entered the game\n", host.HostClient.name);
                }

                progs.Execute(progs.GlobalStruct.PutClientInServer);
            }

            // send all current names, colors, and frag counts
            MsgWriter msg = host.HostClient.message;

            msg.Clear();

            // send time of update
            msg.WriteByte(protocol.svc_time);
            msg.WriteFloat((float)server.sv.time);

            for (int i = 0; i < server.svs.maxclients; i++)
            {
                client_t client = server.svs.clients[i];
                msg.WriteByte(protocol.svc_updatename);
                msg.WriteByte(i);
                msg.WriteString(client.name);
                msg.WriteByte(protocol.svc_updatefrags);
                msg.WriteByte(i);
                msg.WriteShort(client.old_frags);
                msg.WriteByte(protocol.svc_updatecolors);
                msg.WriteByte(i);
                msg.WriteByte(client.colors);
            }

            // send all current light styles
            for (int i = 0; i < QDef.MAX_LIGHTSTYLES; i++)
            {
                msg.WriteByte(protocol.svc_lightstyle);
                msg.WriteByte((char)i);
                msg.WriteString(server.sv.lightstyles[i]);
            }

            //
            // send some stats
            //
            msg.WriteByte(protocol.svc_updatestat);
            msg.WriteByte(QStats.STAT_TOTALSECRETS);
            msg.WriteLong((int)progs.GlobalStruct.total_secrets);

            msg.WriteByte(protocol.svc_updatestat);
            msg.WriteByte(QStats.STAT_TOTALMONSTERS);
            msg.WriteLong((int)progs.GlobalStruct.total_monsters);

            msg.WriteByte(protocol.svc_updatestat);
            msg.WriteByte(QStats.STAT_SECRETS);
            msg.WriteLong((int)progs.GlobalStruct.found_secrets);

            msg.WriteByte(protocol.svc_updatestat);
            msg.WriteByte(QStats.STAT_MONSTERS);
            msg.WriteLong((int)progs.GlobalStruct.killed_monsters);

            //
            // send a fixangle
            // Never send a roll angle, because savegames can catch the server
            // in a state where it is expecting the client to correct the angle
            // and it won't happen if the game was just loaded, so you wind up
            // with a permanent head tilt
            ent = server.EdictNum(1 + host.ClientNum);
            msg.WriteByte(protocol.svc_setangle);
            msg.WriteAngle(ent.v.angles.x);
            msg.WriteAngle(ent.v.angles.y);
            msg.WriteAngle(0);

            server.WriteClientDataToMessage(server.Player, host.HostClient.message);

            msg.WriteByte(protocol.svc_signonnum);
            msg.WriteByte(3);
            host.HostClient.sendsignon = true;
        }
Пример #16
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;
        }
Пример #17
0
        public Vector3 wishdir; // intended motion calced from cmd

        #endregion Fields

        #region Constructors

        public client_t()
        {
            this.ping_times = new float[Server.NUM_PING_TIMES];
            this.spawn_parms = new float[Server.NUM_SPAWN_PARMS];
            this.message = new MsgWriter(QDef.MAX_MSGLEN);
        }
Пример #18
0
    public static void SV_WriteEntitiesToClient(edict_t clent, MsgWriter msg)
    {
        // find the client's PVS
        Vector3 org = ToVector(ref clent.v.origin) + ToVector(ref clent.v.view_ofs);

        byte[] pvs = SV_FatPVS(ref org);

        // send over all entities (except the client) that touch the pvs
        for (int e = 1; e < sv.num_edicts; e++)
        {
            edict_t ent = sv.edicts[e];
            // ignore if not touching a PV leaf
            if (ent != clent)   // clent is ALLWAYS sent
            {
                // ignore ents without visible models
                string mname = GetString(ent.v.model);
                if (String.IsNullOrEmpty(mname))
                {
                    continue;
                }

                int i;
                for (i = 0; i < ent.num_leafs; i++)
                {
                    if ((pvs[ent.leafnums[i] >> 3] & (1 << (ent.leafnums[i] & 7))) != 0)
                    {
                        break;
                    }
                }

                if (i == ent.num_leafs)
                {
                    continue;           // not visible
                }
            }

            if (msg.Capacity - msg.Length < 16)
            {
                Con_Printf("packet overflow\n");
                return;
            }

            // send an update
            int bits = 0;
            v3f miss;
            Mathlib.VectorSubtract(ref ent.v.origin, ref ent.baseline.origin, out miss);
            if (miss.x < -0.1f || miss.x > 0.1f)
            {
                bits |= q_shared.U_ORIGIN1;
            }
            if (miss.y < -0.1f || miss.y > 0.1f)
            {
                bits |= q_shared.U_ORIGIN2;
            }
            if (miss.z < -0.1f || miss.z > 0.1f)
            {
                bits |= q_shared.U_ORIGIN3;
            }

            if (ent.v.angles.x != ent.baseline.angles.x)
            {
                bits |= q_shared.U_ANGLE1;
            }

            if (ent.v.angles.y != ent.baseline.angles.y)
            {
                bits |= q_shared.U_ANGLE2;
            }

            if (ent.v.angles.z != ent.baseline.angles.z)
            {
                bits |= q_shared.U_ANGLE3;
            }

            if (ent.v.movetype == q_shared.MOVETYPE_STEP)
            {
                bits |= q_shared.U_NOLERP;      // don't mess up the step animation
            }
            if (ent.baseline.colormap != ent.v.colormap)
            {
                bits |= q_shared.U_COLORMAP;
            }

            if (ent.baseline.skin != ent.v.skin)
            {
                bits |= q_shared.U_SKIN;
            }

            if (ent.baseline.frame != ent.v.frame)
            {
                bits |= q_shared.U_FRAME;
            }

            if (ent.baseline.effects != ent.v.effects)
            {
                bits |= q_shared.U_EFFECTS;
            }

            if (ent.baseline.modelindex != ent.v.modelindex)
            {
                bits |= q_shared.U_MODEL;
            }

            if (e >= 256)
            {
                bits |= q_shared.U_LONGENTITY;
            }

            if (bits >= 256)
            {
                bits |= q_shared.U_MOREBITS;
            }

            //
            // write the message
            //
            msg.MSG_WriteByte(bits | q_shared.U_SIGNAL);

            if ((bits & q_shared.U_MOREBITS) != 0)
            {
                msg.MSG_WriteByte(bits >> 8);
            }
            if ((bits & q_shared.U_LONGENTITY) != 0)
            {
                msg.MSG_WriteShort(e);
            }
            else
            {
                msg.MSG_WriteByte(e);
            }

            if ((bits & q_shared.U_MODEL) != 0)
            {
                msg.MSG_WriteByte((int)ent.v.modelindex);
            }
            if ((bits & q_shared.U_FRAME) != 0)
            {
                msg.MSG_WriteByte((int)ent.v.frame);
            }
            if ((bits & q_shared.U_COLORMAP) != 0)
            {
                msg.MSG_WriteByte((int)ent.v.colormap);
            }
            if ((bits & q_shared.U_SKIN) != 0)
            {
                msg.MSG_WriteByte((int)ent.v.skin);
            }
            if ((bits & q_shared.U_EFFECTS) != 0)
            {
                msg.MSG_WriteByte((int)ent.v.effects);
            }
            if ((bits & q_shared.U_ORIGIN1) != 0)
            {
                msg.MSG_WriteCoord(ent.v.origin.x);
            }
            if ((bits & q_shared.U_ANGLE1) != 0)
            {
                msg.MSG_WriteAngle(ent.v.angles.x);
            }
            if ((bits & q_shared.U_ORIGIN2) != 0)
            {
                msg.MSG_WriteCoord(ent.v.origin.y);
            }
            if ((bits & q_shared.U_ANGLE2) != 0)
            {
                msg.MSG_WriteAngle(ent.v.angles.y);
            }
            if ((bits & q_shared.U_ORIGIN3) != 0)
            {
                msg.MSG_WriteCoord(ent.v.origin.z);
            }
            if ((bits & q_shared.U_ANGLE3) != 0)
            {
                msg.MSG_WriteAngle(ent.v.angles.z);
            }
        }
    }
Пример #19
0
        public int SendMessage(qsocket_t sock, MsgWriter data)
        {
            if (Host.Time != _Next.time || _Next.op != VcrOp.VCR_OP_SENDMESSAGE || _Next.session != SocketToSession(sock))
                Sys.Error("VCR missmatch");

            int ret = Host.VcrReader.ReadInt32();

            ReadNext();

            return ret;
        }
Пример #20
0
        // NET_Init (void)
        public static void Init()
        {
            for (int i2 = 0; i2 < _HostCache.Length; i2++)
                _HostCache[i2] = new hostcache_t();

            if (_Drivers == null)
            {
                if(Common.HasParam("-playback"))
                {
                    _Drivers = new INetDriver[]
                    {
                        new NetVcr()
                    };
                }
                else
                {
                    _Drivers = new INetDriver[]
                    {
                        new NetLoop(),
                        NetDatagram.Instance
                    };
                }
            }

            if (_LanDrivers == null)
            {
                _LanDrivers = new INetLanDriver[]
                {
                    NetTcpIp.Instance
                };
            }

            if (Common.HasParam("-record"))
                _IsRecording = true;

            int i = Common.CheckParm("-port");
            if (i == 0)
                i = Common.CheckParm("-udpport");
            if (i == 0)
                i = Common.CheckParm("-ipxport");

            if (i > 0)
            {
                if (i < Common.Argc - 1)
                    _DefHostPort = Common.atoi(Common.Argv(i + 1));
                else
                    Sys.Error("Net.Init: you must specify a number after -port!");
            }
            HostPort = _DefHostPort;

            if (Common.HasParam("-listen") || Client.cls.state == cactive_t.ca_dedicated)
                _IsListening = true;
            int numsockets = Server.svs.maxclientslimit;
            if (Client.cls.state != cactive_t.ca_dedicated)
                numsockets++;

            _FreeSockets = new List<qsocket_t>(numsockets);
            _ActiveSockets = new List<qsocket_t>(numsockets);

            for (i = 0; i < numsockets; i++)
                _FreeSockets.Add(new qsocket_t());

            SetNetTime();

            // allocate space for network message buffer
            Message = new MsgWriter(NET_MAXMESSAGE); // SZ_Alloc (&net_message, NET_MAXMESSAGE);
            Reader = new MsgReader(Net.Message);

            if (_MessageTimeout == null)
            {
                _MessageTimeout = new Cvar("net_messagetimeout", "300");
                _HostName = new Cvar("hostname", "UNNAMED");
            }

            Cmd.Add("slist", Slist_f);
            Cmd.Add("listen", Listen_f);
            Cmd.Add("maxplayers", MaxPlayers_f);
            Cmd.Add("port", Port_f);

            // initialize all the drivers
            _DriverLevel = 0;
            foreach (INetDriver driver in _Drivers)
            {
                driver.Init();
                if (driver.IsInitialized && _IsListening)
                {
                    driver.Listen(true);
                }
                _DriverLevel++;
            }

            //if (*my_ipx_address)
            //    Con_DPrintf("IPX address %s\n", my_ipx_address);
            if (!String.IsNullOrEmpty(_MyTcpIpAddress))
                Con.DPrint("TCP/IP address {0}\n", _MyTcpIpAddress);
        }
Пример #21
0
    public static void SV_SendServerinfo(client_t client)
    {
        MsgWriter writer = client.message;

        writer.MSG_WriteByte(q_shared.svc_print);
        writer.MSG_WriteString(String.Format("{0}\nVERSION {1,4:F2} SERVER ({2} CRC)", (char)2, q_shared.VERSION, pr_crc));

        writer.MSG_WriteByte(q_shared.svc_serverinfo);
        writer.MSG_WriteLong(q_shared.PROTOCOL_VERSION);
        writer.MSG_WriteByte(svs.maxclients);

        if (!(coop.value != 0) && deathmatch.value != 0)
        {
            writer.MSG_WriteByte(q_shared.GAME_DEATHMATCH);
        }
        else
        {
            writer.MSG_WriteByte(q_shared.GAME_COOP);
        }

        string message = GetString(sv.edicts[0].v.message);

        writer.MSG_WriteString(message);

        for (int i = 1; i < sv.model_precache.Length; i++)
        {
            string tmp = sv.model_precache[i];
            if (String.IsNullOrEmpty(tmp))
            {
                break;
            }
            writer.MSG_WriteString(tmp);
        }
        writer.MSG_WriteByte(0);

        for (int i = 1; i < sv.sound_precache.Length; i++)
        {
            string tmp = sv.sound_precache[i];
            if (tmp == null)
            {
                break;
            }
            writer.MSG_WriteString(tmp);
        }
        writer.MSG_WriteByte(0);

        // send music
        writer.MSG_WriteByte(q_shared.svc_cdtrack);
        writer.MSG_WriteByte((int)sv.edicts[0].v.sounds);
        writer.MSG_WriteByte((int)sv.edicts[0].v.sounds);

        // set view
        writer.MSG_WriteByte(q_shared.svc_setview);
        writer.MSG_WriteShort(NUM_FOR_EDICT(client.edict));

        writer.MSG_WriteByte(q_shared.svc_signonnum);
        writer.MSG_WriteByte(1);

        client.sendsignon = true;
        client.spawned    = false;      // need prespawn, spawn, etc
    }
Пример #22
0
 public int SendUnreliableMessage(qsocket_t sock, MsgWriter data)
 {
     throw new NotImplementedException();
 }
Пример #23
0
    public static void SV_WriteClientdataToMessage(edict_t ent, MsgWriter msg)
    {
        //
        // send a damage message
        //
        if (ent.v.dmg_take != 0 || ent.v.dmg_save != 0)
        {
            edict_t other = PROG_TO_EDICT(ent.v.dmg_inflictor);
            msg.MSG_WriteByte(q_shared.svc_damage);
            msg.MSG_WriteByte((int)ent.v.dmg_save);
            msg.MSG_WriteByte((int)ent.v.dmg_take);
            msg.MSG_WriteCoord(other.v.origin.x + 0.5f * (other.v.mins.x + other.v.maxs.x));
            msg.MSG_WriteCoord(other.v.origin.y + 0.5f * (other.v.mins.y + other.v.maxs.y));
            msg.MSG_WriteCoord(other.v.origin.z + 0.5f * (other.v.mins.z + other.v.maxs.z));

            ent.v.dmg_take = 0;
            ent.v.dmg_save = 0;
        }

        //
        // send the current viewpos offset from the view entity
        //
        SV_SetIdealPitch();             // how much to look up / down ideally

        // a fixangle might get lost in a dropped packet.  Oh well.
        if (ent.v.fixangle != 0)
        {
            msg.MSG_WriteByte(q_shared.svc_setangle);
            msg.MSG_WriteAngle(ent.v.angles.x);
            msg.MSG_WriteAngle(ent.v.angles.y);
            msg.MSG_WriteAngle(ent.v.angles.z);
            ent.v.fixangle = 0;
        }

        int bits = 0;

        if (ent.v.view_ofs.z != q_shared.DEFAULT_VIEWHEIGHT)
        {
            bits |= q_shared.SU_VIEWHEIGHT;
        }

        if (ent.v.idealpitch != 0)
        {
            bits |= q_shared.SU_IDEALPITCH;
        }

        // stuff the sigil bits into the high bits of items for sbar, or else
        // mix in items2
        float val = GetEdictFieldFloat(ent, "items2", 0);
        int   items;

        if (val != 0)
        {
            items = (int)ent.v.items | ((int)val << 23);
        }
        else
        {
            items = (int)ent.v.items | ((int)pr_global_struct.serverflags << 28);
        }

        bits |= q_shared.SU_ITEMS;

        if (((int)ent.v.flags & q_shared.FL_ONGROUND) != 0)
        {
            bits |= q_shared.SU_ONGROUND;
        }

        if (ent.v.waterlevel >= 2)
        {
            bits |= q_shared.SU_INWATER;
        }

        if (ent.v.punchangle.x != 0)
        {
            bits |= q_shared.SU_PUNCH1;
        }
        if (ent.v.punchangle.y != 0)
        {
            bits |= q_shared.SU_PUNCH2;
        }
        if (ent.v.punchangle.z != 0)
        {
            bits |= q_shared.SU_PUNCH3;
        }

        if (ent.v.velocity.x != 0)
        {
            bits |= q_shared.SU_VELOCITY1;
        }
        if (ent.v.velocity.y != 0)
        {
            bits |= q_shared.SU_VELOCITY2;
        }
        if (ent.v.velocity.z != 0)
        {
            bits |= q_shared.SU_VELOCITY3;
        }

        if (ent.v.weaponframe != 0)
        {
            bits |= q_shared.SU_WEAPONFRAME;
        }

        if (ent.v.armorvalue != 0)
        {
            bits |= q_shared.SU_ARMOR;
        }

        //	if (ent.v.weapon)
        bits |= q_shared.SU_WEAPON;

        // send the data

        msg.MSG_WriteByte(q_shared.svc_clientdata);
        msg.MSG_WriteShort(bits);

        if ((bits & q_shared.SU_VIEWHEIGHT) != 0)
        {
            msg.MSG_WriteChar((int)ent.v.view_ofs.z);
        }

        if ((bits & q_shared.SU_IDEALPITCH) != 0)
        {
            msg.MSG_WriteChar((int)ent.v.idealpitch);
        }

        if ((bits & q_shared.SU_PUNCH1) != 0)
        {
            msg.MSG_WriteChar((int)ent.v.punchangle.x);
        }
        if ((bits & q_shared.SU_VELOCITY1) != 0)
        {
            msg.MSG_WriteChar((int)(ent.v.velocity.x / 16));
        }

        if ((bits & q_shared.SU_PUNCH2) != 0)
        {
            msg.MSG_WriteChar((int)ent.v.punchangle.y);
        }
        if ((bits & q_shared.SU_VELOCITY2) != 0)
        {
            msg.MSG_WriteChar((int)(ent.v.velocity.y / 16));
        }

        if ((bits & q_shared.SU_PUNCH3) != 0)
        {
            msg.MSG_WriteChar((int)ent.v.punchangle.z);
        }
        if ((bits & q_shared.SU_VELOCITY3) != 0)
        {
            msg.MSG_WriteChar((int)(ent.v.velocity.z / 16));
        }

        // always sent
        msg.MSG_WriteLong(items);

        if ((bits & q_shared.SU_WEAPONFRAME) != 0)
        {
            msg.MSG_WriteByte((int)ent.v.weaponframe);
        }
        if ((bits & q_shared.SU_ARMOR) != 0)
        {
            msg.MSG_WriteByte((int)ent.v.armorvalue);
        }
        if ((bits & q_shared.SU_WEAPON) != 0)
        {
            msg.MSG_WriteByte(SV_ModelIndex(GetString(ent.v.weaponmodel)));
        }

        msg.MSG_WriteShort((int)ent.v.health);
        msg.MSG_WriteByte((int)ent.v.currentammo);
        msg.MSG_WriteByte((int)ent.v.ammo_shells);
        msg.MSG_WriteByte((int)ent.v.ammo_nails);
        msg.MSG_WriteByte((int)ent.v.ammo_rockets);
        msg.MSG_WriteByte((int)ent.v.ammo_cells);

        if (_GameKind == GameKind.StandardQuake)
        {
            msg.MSG_WriteByte((int)ent.v.weapon);
        }
        else
        {
            for (int i = 0; i < 32; i++)
            {
                if ((((int)ent.v.weapon) & (1 << i)) != 0)
                {
                    msg.MSG_WriteByte(i);
                    break;
                }
            }
        }
    }
Пример #24
0
 public override void WriteMessage(string message)
 {
     Console.WriteLine($"经过CompressedDecorate加持...");
     MsgWriter.WriteMessage(message);
 }
Пример #25
0
    public static void NET_Init()
    {
        for (int i2 = 0; i2 < hostcache.Length; i2++)
        {
            hostcache[i2] = new hostcache_t();
        }

        if (net_drivers == null)
        {
            if (HasParam("-playback"))
            {
                net_drivers = new INetDriver[]
                {
                    new NetVcr()
                };
            }
            else
            {
                net_drivers = new INetDriver[]
                {
                    new NetLoop(),
                    NetDatagram.Instance
                };
            }
        }

        if (net_landrivers == null)
        {
            net_landrivers = new INetLanDriver[]
            {
                NetTcpIp.Instance
            };
        }

        if (HasParam("-record"))
        {
            recording = true;
        }

        int i = COM_CheckParm("-port");

        if (i == 0)
        {
            i = COM_CheckParm("-udpport");
        }
        if (i == 0)
        {
            i = COM_CheckParm("-ipxport");
        }

        if (i > 0)
        {
            if (i < com_argv.Length - 1)
            {
                DEFAULTnet_hostport = atoi(Argv(i + 1));
            }
            else
            {
                Sys_Error("Net.Init: you must specify a number after -port!");
            }
        }
        net_hostport = DEFAULTnet_hostport;

        if (HasParam("-listen") || cls.state == cactive_t.ca_dedicated)
        {
            listening = true;
        }
        int numsockets = svs.maxclientslimit;

        if (cls.state != cactive_t.ca_dedicated)
        {
            numsockets++;
        }

        net_freeSockets   = new List <qsocket_t>(numsockets);
        net_activeSockets = new List <qsocket_t>(numsockets);

        for (i = 0; i < numsockets; i++)
        {
            net_freeSockets.Add(new qsocket_t());
        }

        SetNetTime();

        // allocate space for network message buffer
        Message = new MsgWriter(q_shared.NET_MAXMESSAGE); // SZ_Alloc (&net_message, NET_MAXMESSAGE);
        Reader  = new MsgReader(Message);

        net_messagetimeout = new cvar_t("net_messagetimeout", "300");
        hostname           = new cvar_t("hostname", "UNNAMED");

        Cmd_AddCommand("slist", NET_Slist_f);
        Cmd_AddCommand("listen", NET_Listen_f);
        Cmd_AddCommand("maxplayers", MaxPlayers_f);
        Cmd_AddCommand("port", NET_Port_f);

        // initialize all the drivers
        net_driverlevel = 0;
        foreach (INetDriver driver in net_drivers)
        {
            driver.Init();
            if (driver.IsInitialized && listening)
            {
                driver.Datagram_Listen(true);
            }
            net_driverlevel++;
        }

        //if (*my_ipx_address)
        //    Con_DPrintf("IPX address %s\n", my_ipx_address);
        if (!String.IsNullOrEmpty(my_tcpip_address))
        {
            Con_DPrintf("TCP/IP address {0}\n", my_tcpip_address);
        }
    }
Пример #26
0
 public override void WriteMessage(string message)
 {
     Console.WriteLine($"经过DigitallySignedDecorate加持...");
     MsgWriter.WriteMessage(message);
 }
Пример #27
0
        /// <summary>
        /// Host_ShutdownServer
        /// This only happens at the end of a game, not between levels
        /// </summary>
        public static void ShutdownServer(bool crash)
        {
            if (!Server.IsActive)
            {
                return;
            }

            Server.sv.active = false;

            // stop all client sounds immediately
            if (Client.cls.state == cactive_t.ca_connected)
            {
                Client.Disconnect();
            }

            // flush any pending messages - like the score!!!
            double start = Sys.GetFloatTime();
            int    count;

            do
            {
                count = 0;
                for (int i = 0; i < Server.svs.maxclients; i++)
                {
                    HostClient = Server.svs.clients[i];
                    if (HostClient.active && !HostClient.message.IsEmpty)
                    {
                        if (Net.CanSendMessage(HostClient.netconnection))
                        {
                            Net.SendMessage(HostClient.netconnection, HostClient.message);
                            HostClient.message.Clear();
                        }
                        else
                        {
                            Net.GetMessage(HostClient.netconnection);
                            count++;
                        }
                    }
                }
                if ((Sys.GetFloatTime() - start) > 3.0)
                {
                    break;
                }
            }while (count > 0);

            // make sure all the clients know we're disconnecting
            MsgWriter writer = new MsgWriter(4);

            writer.WriteByte(Protocol.svc_disconnect);
            count = Net.SendToAll(writer, 5);
            if (count != 0)
            {
                Con.Print("Host_ShutdownServer: NET_SendToAll failed for {0} clients\n", count);
            }

            for (int i = 0; i < Server.svs.maxclients; i++)
            {
                HostClient = Server.svs.clients[i];
                if (HostClient.active)
                {
                    Server.DropClient(crash);
                }
            }

            //
            // clear structures
            //
            Server.sv.Clear();
            for (int i = 0; i < Server.svs.clients.Length; i++)
            {
                Server.svs.clients[i].Clear();
            }
        }
Пример #28
0
        /// <summary>
        /// SV_SendServerinfo
        /// Sends the first message from the server to a connected client.
        /// This will be sent on the initial connection and upon each server load.
        /// </summary>
        static void SendServerInfo(client_t client)
        {
            MsgWriter writer = client.message;

            writer.WriteByte(Protocol.svc_print);
            writer.WriteString(String.Format("{0}\nVERSION {1,4:F2} SERVER ({2} CRC)", (char)2, QDef.VERSION, Progs.Crc));

            writer.WriteByte(Protocol.svc_serverinfo);
            writer.WriteLong(Protocol.PROTOCOL_VERSION);
            writer.WriteByte(svs.maxclients);

            if (!Host.IsCoop && Host.Deathmatch != 0)
            {
                writer.WriteByte(Protocol.GAME_DEATHMATCH);
            }
            else
            {
                writer.WriteByte(Protocol.GAME_COOP);
            }

            string message = Progs.GetString(sv.edicts[0].v.message);

            writer.WriteString(message);

            for (int i = 1; i < sv.model_precache.Length; i++)
            {
                string tmp = sv.model_precache[i];
                if (String.IsNullOrEmpty(tmp))
                {
                    break;
                }
                writer.WriteString(tmp);
            }
            writer.WriteByte(0);

            for (int i = 1; i < sv.sound_precache.Length; i++)
            {
                string tmp = sv.sound_precache[i];
                if (tmp == null)
                {
                    break;
                }
                writer.WriteString(tmp);
            }
            writer.WriteByte(0);

            // send music
            writer.WriteByte(Protocol.svc_cdtrack);
            writer.WriteByte((int)sv.edicts[0].v.sounds);
            writer.WriteByte((int)sv.edicts[0].v.sounds);

            // set view
            writer.WriteByte(Protocol.svc_setview);
            writer.WriteShort(NumForEdict(client.edict));

            writer.WriteByte(Protocol.svc_signonnum);
            writer.WriteByte(1);

            client.sendsignon = true;
            client.spawned    = false;          // need prespawn, spawn, etc
        }
Пример #29
0
        public int SendUnreliableMessage(qsocket_t sock, MsgWriter data)
        {
            if (sock.driverdata == null)
                return -1;

            qsocket_t sock2 = (qsocket_t)sock.driverdata;

            if ((sock2.receiveMessageLength + data.Length + sizeof(byte) + sizeof(short)) > Net.NET_MAXMESSAGE)
                return 0;

            int offset = sock2.receiveMessageLength;

            // message type
            sock2.receiveMessage[offset++] = 2;

            // length
            sock2.receiveMessage[offset++] = (byte)(data.Length & 0xff);
            sock2.receiveMessage[offset++] = (byte)(data.Length >> 8);

            // align
            offset++;

            // message
            Buffer.BlockCopy(data.Data, 0, sock2.receiveMessage, offset, data.Length);
            sock2.receiveMessageLength = IntAlign(sock2.receiveMessageLength + data.Length + 4);

            return 1;
        }
Пример #30
0
 public client_t()
 {
     this.ping_times  = new float[Server.NUM_PING_TIMES];
     this.spawn_parms = new float[Server.NUM_SPAWN_PARMS];
     this.message     = new MsgWriter(QDef.MAX_MSGLEN);
 }
Пример #31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Tracer"/> class with the given logical operation name and activity id.
 /// </summary>
 /// <remarks>
 /// The activity id will override a previous activity id
 /// </remarks>
 /// <param name="operation">The operation for the <see cref="Tracer"/></param>
 /// <param name="activityId">The activity id</param>
 /// <param name="writer">The <see cref="MsgWriter"/> that is used to write trace messages</param>
 /// <param name="serviceLocator"><see cref="IServiceLocator"/> used to retrieve the instrumentation provider for this tracer.</param>
 public Tracer(string operation, Guid activityId, MsgWriter writer, IServiceLocator serviceLocator)
     : this(operation, activityId, writer, GetTracerInstrumentationProvider(serviceLocator))
 {
 }
Пример #32
0
        public MsgWriter message; // sizebuf_t	message;		// writing buffer to send to server

        public client_static_t()
        {
            this.demos   = new string[Client.MAX_DEMOS];
            this.message = new MsgWriter(1024);   // like in Client_Init()
        }
Пример #33
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Tracer"/> class with the given logical operation name and activity id.
        /// </summary>
        /// <remarks>
        /// This is meant to be used internally
        /// </remarks>
        /// <param name="operation">The operation for the <see cref="Tracer"/></param>
        /// <param name="writer">The <see cref="MsgWriter"/> that is used to write trace messages</param>
        /// <param name="instrumentationProvider">Instrumentation provider to use for firing logical instrumentation events from Tracer.</param>
        /// <exception cref="ArgumentNullException"></exception>
        internal Tracer(string operation, MsgWriter writer, ITracerInstrumentationProvider instrumentationProvider)
        {
            this.instrumentationProvider = instrumentationProvider;

            if (CheckTracingAvailable())
            {
                if (writer == null) throw new ArgumentNullException("writer", Resources.ExceptionWriterShouldNotBeNull);

                if (GetActivityId().Equals(Guid.Empty))
                {
                    this.previousActivityId = Guid.Empty;
                    SetActivityId(Guid.NewGuid());
                }
                else
                {
                    this.previousActivityId = null;
                }

                this.writer = writer;

                Initialize(operation);
            }
        }
Пример #34
0
 /// <summary>
 /// Creates a <see cref="MsgCallHandler"/> with default settings that writes
 /// to the given <see cref="LogWriter"/>.
 /// </summary>
 /// <remarks>See the <see cref="LogCallHandlerDefaults"/> class for the default values.</remarks>
 /// <param name="logWriter"><see cref="LogWriter"/> to write logs to.</param>
 public MsgCallHandler(MsgWriter logWriter)
 {
     this.logWriter = logWriter;
 }
Пример #35
0
 /// <summary>
 /// Creates a new <see cref="MsgCallHandler"/> that writes to the specified <see cref="LogWriter"/>
 /// using the given logging settings.
 /// </summary>
 /// <param name="logWriter"><see cref="LogWriter"/> to write log entries to.</param>
 /// <param name="eventId">EventId to include in log entries.</param>
 /// <param name="logBeforeCall">Should the handler log information before calling the target?</param>
 /// <param name="logAfterCall">Should the handler log information after calling the target?</param>
 /// <param name="beforeMessage">Message to include in a before-call log entry.</param>
 /// <param name="afterMessage">Message to include in an after-call log entry.</param>
 /// <param name="includeParameters">Should the parameter values be included in the log entry?</param>
 /// <param name="includeCallStack">Should the current call stack be included in the log entry?</param>
 /// <param name="includeCallTime">Should the time to execute the target be included in the log entry?</param>
 /// <param name="priority">Priority of the log entry.</param>
 public MsgCallHandler(MsgWriter logWriter, int eventId,
                       bool logBeforeCall,
                       bool logAfterCall, string beforeMessage, string afterMessage,
                       bool includeParameters, bool includeCallStack,
                       bool includeCallTime, int priority)
 {
     this.logWriter = logWriter;
     this.eventId = eventId;
     this.logBeforeCall = logBeforeCall;
     this.logAfterCall = logAfterCall;
     this.beforeMessage = beforeMessage;
     this.afterMessage = afterMessage;
     this.includeParameters = includeParameters;
     this.includeCallStack = includeCallStack;
     this.includeCallTime = includeCallTime;
     this.priority = priority;
 }
Пример #36
0
 /// <summary>
 /// Creates a new <see cref="MsgCallHandler"/> that writes to the specified <see cref="LogWriter"/>
 /// using the given logging settings.
 /// </summary>
 /// <param name="logWriter"><see cref="LogWriter"/> to write log entries to.</param>
 /// <param name="eventId">EventId to include in log entries.</param>
 /// <param name="logBeforeCall">Should the handler log information before calling the target?</param>
 /// <param name="logAfterCall">Should the handler log information after calling the target?</param>
 /// <param name="beforeMessage">Message to include in a before-call log entry.</param>
 /// <param name="afterMessage">Message to include in an after-call log entry.</param>
 /// <param name="includeParameters">Should the parameter values be included in the log entry?</param>
 /// <param name="includeCallStack">Should the current call stack be included in the log entry?</param>
 /// <param name="includeCallTime">Should the time to execute the target be included in the log entry?</param>
 /// <param name="priority">Priority of the log entry.</param>
 /// <param name="order">Order in which the handler will be executed.</param>
 public MsgCallHandler(MsgWriter logWriter, int eventId,
                       bool logBeforeCall,
                       bool logAfterCall, string beforeMessage, string afterMessage,
                       bool includeParameters, bool includeCallStack,
                       bool includeCallTime, int priority,
                       int order)
     : this(logWriter, eventId, logBeforeCall, logAfterCall, beforeMessage, afterMessage, includeParameters, includeCallStack, includeCallTime, priority)
 {
     this.order = order;
 }
Пример #37
0
 public server_t()
 {
     this.model_precache = new string[QDef.MAX_MODELS];
     this.models = new model_t[QDef.MAX_MODELS];
     this.sound_precache = new string[QDef.MAX_SOUNDS];
     this.lightstyles = new string[QDef.MAX_LIGHTSTYLES];
     this.datagram = new MsgWriter(QDef.MAX_DATAGRAM);
     this.reliable_datagram = new MsgWriter(QDef.MAX_DATAGRAM);
     this.signon = new MsgWriter(8192);
 }
Пример #38
0
        /// <summary>
        /// Host_ShutdownServer
        /// This only happens at the end of a game, not between levels
        /// </summary>
        public static void ShutdownServer(bool crash)
        {
            if (!Server.IsActive)
                return;

            Server.sv.active = false;

            // stop all client sounds immediately
            if (Client.cls.state == cactive_t.ca_connected)
                Client.Disconnect();

            // flush any pending messages - like the score!!!
            double start = Sys.GetFloatTime();
            int count;
            do
            {
                count = 0;
                for (int i = 0; i < Server.svs.maxclients; i++)
                {
                    HostClient = Server.svs.clients[i];
                    if (HostClient.active && !HostClient.message.IsEmpty)
                    {
                        if (Net.CanSendMessage(HostClient.netconnection))
                        {
                            Net.SendMessage(HostClient.netconnection, HostClient.message);
                            HostClient.message.Clear();
                        }
                        else
                        {
                            Net.GetMessage(HostClient.netconnection);
                            count++;
                        }
                    }
                }
                if ((Sys.GetFloatTime() - start) > 3.0)
                    break;
            }
            while (count > 0);

            // make sure all the clients know we're disconnecting
            MsgWriter writer = new MsgWriter(4);
            writer.WriteByte(Protocol.svc_disconnect);
            count = Net.SendToAll(writer, 5);
            if (count != 0)
                Con.Print("Host_ShutdownServer: NET_SendToAll failed for {0} clients\n", count);

            for (int i = 0; i < Server.svs.maxclients; i++)
            {
                HostClient = Server.svs.clients[i];
                if (HostClient.active)
                    Server.DropClient(crash);
            }

            //
            // clear structures
            //
            Server.sv.Clear();
            for (int i = 0; i < Server.svs.clients.Length; i++)
                Server.svs.clients[i].Clear();
        }