コード例 #1
0
ファイル: Netchan.cs プロジェクト: optimus-code/Q2Sharp
 public static void Netchan_OutOfBand(int net_socket, netadr_t adr, int length, byte[] data)
 {
     SZ.Init(send, send_buf, Defines.MAX_MSGLEN);
     MSG.WriteInt(send, -1);
     SZ.Write(send, data, length);
     NET.SendPacket(net_socket, send.cursize, send.data, adr);
 }
コード例 #2
0
ファイル: Netchan.cs プロジェクト: optimus-code/Q2Sharp
        public static void Transmit(netchan_t chan, int length, byte[] data)
        {
            int send_reliable;
            int w1, w2;

            if (chan.message.overflowed)
            {
                chan.fatal_error = true;
                Com.Printf(NET.AdrToString(chan.remote_address) + ":Outgoing message overflow\\n");
                return;
            }

            send_reliable = Netchan_NeedReliable(chan) ? 1 : 0;
            if (chan.reliable_length == 0 && chan.message.cursize != 0)
            {
                System.Array.Copy(chan.message_buf, 0, chan.reliable_buf, 0, chan.message.cursize);
                chan.reliable_length    = chan.message.cursize;
                chan.message.cursize    = 0;
                chan.reliable_sequence ^= 1;
            }

            SZ.Init(send, send_buf, send_buf.Length);
            w1 = (chan.outgoing_sequence & ~(1 << 31)) | (send_reliable << 31);
            w2 = (chan.incoming_sequence & ~(1 << 31)) | (chan.incoming_reliable_sequence << 31);
            chan.outgoing_sequence++;
            chan.last_sent = (int)Globals.curtime;
            MSG.WriteInt(send, w1);
            MSG.WriteInt(send, w2);
            if (chan.sock == Defines.NS_CLIENT)
            {
                MSG.WriteShort(send, (int)qport.value);
            }
            if (send_reliable != 0)
            {
                SZ.Write(send, chan.reliable_buf, chan.reliable_length);
                chan.last_reliable_sequence = chan.outgoing_sequence;
            }

            if (send.maxsize - send.cursize >= length)
            {
                SZ.Write(send, data, length);
            }
            else
            {
                Com.Printf("Netchan_Transmit: dumped unreliable\\n");
            }
            NET.SendPacket(chan.sock, send.cursize, send.data, chan.remote_address);
            if (showpackets.value != 0)
            {
                if (send_reliable != 0)
                {
                    Com.Printf("send " + send.cursize + " : s=" + (chan.outgoing_sequence - 1) + " reliable=" + chan.reliable_sequence + " ack=" + chan.incoming_sequence + " rack=" + chan.incoming_reliable_sequence + "\\n");
                }
                else
                {
                    Com.Printf("send " + send.cursize + " : s=" + (chan.outgoing_sequence - 1) + " ack=" + chan.incoming_sequence + " rack=" + chan.incoming_reliable_sequence + "\\n");
                }
            }
        }
コード例 #3
0
        public static void WriteString(sizebuf_t sb, String s)
        {
            var x = s;

            if (s == null)
            {
                x = "";
            }
            SZ.Write(sb, Lib.StringToBytes(x));
            WriteByte(sb, 0);
        }
コード例 #4
0
ファイル: Cbuf.cs プロジェクト: optimus-code/Q2Sharp
        public static void AddText(string text)
        {
            int l = text.Length;

            if (Globals.cmd_text.cursize + l >= Globals.cmd_text.maxsize)
            {
                Com.Printf("Cbuf_AddText: overflow\\n");
                return;
            }

            SZ.Write(Globals.cmd_text, Encoding.ASCII.GetBytes(text), l);
        }
コード例 #5
0
ファイル: Cbuf.cs プロジェクト: optimus-code/Q2Sharp
        public static void InsertText(string text)
        {
            int templen = 0;

            templen = Globals.cmd_text.cursize;
            if (templen != 0)
            {
                System.Array.Copy(Globals.cmd_text.data, 0, tmp, 0, templen);
                SZ.Clear(Globals.cmd_text);
            }

            Cbuf.AddText(text);
            if (templen != 0)
            {
                SZ.Write(Globals.cmd_text, tmp, templen);
            }
        }