예제 #1
0
        public static int NET_SendUnreliableMessage(qsocket_t sock, common.sizebuf_t data)
        {
            int r;

            if (sock == null)
            {
                return(-1);
            }

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

            SetNetTime();
            r = net_drivers[sock.driver].delegate_SendUnreliableMessage(sock, data);
            if (r == 1 && sock.driver != 0)
            {
                unreliableMessagesSent++;
            }

            return(r);
        }
예제 #2
0
        /*
        ==============
        CL_SendMove
        ==============
        */
        static void CL_SendMove(usercmd_t cmd)
        {
            int		i;
            int		bits;
            common.sizebuf_t	buf = new common.sizebuf_t();
            byte[]	data = new byte[128];

            buf.maxsize = 128;
            buf.cursize = 0;
            buf.data = data;

            cl.cmd = cmd;

            //
            // send the movement message
            //
            common.MSG_WriteByte (buf, net.clc_move);

            common.MSG_WriteFloat(buf, cl.mtime[0]);	// so server can get ping times

            for (i=0 ; i<3 ; i++)
                common.MSG_WriteAngle(buf, cl.viewangles[i]);

            common.MSG_WriteShort(buf, (int)cmd.forwardmove);
            common.MSG_WriteShort(buf, (int)cmd.sidemove);
            common.MSG_WriteShort(buf, (int)cmd.upmove);

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

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

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

            common.MSG_WriteByte(buf, bits);

            common.MSG_WriteByte(buf, in_impulse);
            in_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.NET_SendUnreliableMessage (cls.netcon, buf) == -1)
            {
                console.Con_Printf ("CL_SendMove: lost server connection\n");
                CL_Disconnect ();
            }
        }
예제 #3
0
        /*
         * ==============
         * CL_SendMove
         * ==============
         */
        static void CL_SendMove(usercmd_t cmd)
        {
            int i;
            int bits;

            common.sizebuf_t buf = new common.sizebuf_t();
            byte[]  data         = new byte[128];

            buf.maxsize = 128;
            buf.cursize = 0;
            buf.data    = data;

            cl.cmd = cmd;

            //
            // send the movement message
            //
            common.MSG_WriteByte(buf, net.clc_move);

            common.MSG_WriteFloat(buf, cl.mtime[0]);    // so server can get ping times

            for (i = 0; i < 3; i++)
            {
                common.MSG_WriteAngle(buf, cl.viewangles[i]);
            }

            common.MSG_WriteShort(buf, (int)cmd.forwardmove);
            common.MSG_WriteShort(buf, (int)cmd.sidemove);
            common.MSG_WriteShort(buf, (int)cmd.upmove);

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

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

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

            common.MSG_WriteByte(buf, bits);

            common.MSG_WriteByte(buf, in_impulse);
            in_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.NET_SendUnreliableMessage(cls.netcon, buf) == -1)
            {
                console.Con_Printf("CL_SendMove: lost server connection\n");
                CL_Disconnect();
            }
        }
예제 #4
0
        public static int NET_SendToAll(common.sizebuf_t data, int blocktime)
        {
            double start;
            int    i;
            int    count = 0;

            bool[] state1 = new bool[quakedef.MAX_SCOREBOARD];
            bool[] state2 = new bool[quakedef.MAX_SCOREBOARD];

            for (i = 0; i < server.svs.maxclients; i++)
            {
                host.host_client = server.svs.clients[i];
                if (host.host_client.netconnection == null)
                {
                    continue;
                }
                if (host.host_client.active)
                {
                    if (host.host_client.netconnection.driver == 0)
                    {
                        NET_SendMessage(host.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;
                }
            }

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

                    if (!state2[i])
                    {
                        if (NET_CanSendMessage(host.host_client.netconnection))
                        {
                            state2[i] = true;
                        }
                        else
                        {
                            NET_GetMessage(host.host_client.netconnection);
                        }
                        count++;
                        continue;
                    }
                }
                if ((sys_linux.Sys_FloatTime() - start) > blocktime)
                {
                    break;
                }
            }
            return(count);
        }