private void SendUserCmds() { var last = new UserCmd(); using (var stream = Bitstream.Create()) { var move = new CCLCMsg_Move(); move.num_backup_commands = (uint)backup.Count; foreach (var cmd in backup) { WriteUserCmd(cmd, last, stream); last = cmd; } move.num_new_commands = (uint)next.Count; foreach (var cmd in next) { WriteUserCmd(cmd, last, stream); last = cmd; } backup.Clear(); backup.AddRange(next); next.Clear(); move.data = stream.ToBytes(); var tick = new CNETMsg_Tick(); tick.tick = client.ServerTick; connection.SendUnreliably( Connection.ConvertProtoToMessage <CCLCMsg_Move>((uint)CLC_Messages.clc_Move, move), Connection.ConvertProtoToMessage <CNETMsg_Tick>((uint)NET_Messages.net_Tick, tick)); } }
public void RespondHandshake() { using (var stream = Bitstream.Create()) { stream.WriteChar(C2S_CONNECT); stream.WriteUInt32(SOURCE_VERSION); stream.WriteUInt32(STEAM_VERSION); stream.WriteUInt32(server_challenge); stream.WriteUInt32(client_challenge); stream.Write(Encoding.UTF8.GetBytes(client.CVars["name"])); stream.WriteByte(0); stream.Write(Encoding.UTF8.GetBytes(details.Secret.ToString())); stream.WriteByte(0); // num players stream.WriteByte(1); // cvars stream.WriteByte((byte)CLC_Messages.clc_SplitPlayerConnect); var split = new CCLCMsg_SplitPlayerConnect(); split.convars = client.ExposeCVars(); Serializer.SerializeWithLengthPrefix(stream, split, PrefixStyle.Base128); connection.EnqueueOutOfBand(stream.ToBytes()); } }
public void RequestHandshake() { connection.Open(); using (var stream = Bitstream.Create()) { stream.WriteChar(C2S_REQUEST); stream.WriteUInt32(client_challenge); foreach (char c in "0000000000") { stream.WriteChar(c); } stream.WriteByte(0); connection.EnqueueOutOfBand(stream.ToBytes()); } }
public void RespondHandshake() { using (var stream = Bitstream.Create()) { stream.WriteChar(C2S_CONNECT); stream.WriteUInt32(SOURCE_VERSION); stream.WriteUInt32(STEAM_VERSION); stream.WriteUInt32(server_challenge); stream.WriteUInt32(client_challenge); stream.Write(Encoding.UTF8.GetBytes(client.CVars["name"])); stream.WriteByte(0); stream.Write(Encoding.UTF8.GetBytes(details.Secret.ToString())); stream.WriteByte(0); // num players stream.WriteByte(1); // cvars stream.WriteByte((byte)CLC_Messages.clc_SplitPlayerConnect); var split = new CCLCMsg_SplitPlayerConnect(); split.convars = client.ExposeCVars(); Serializer.SerializeWithLengthPrefix(stream, split, PrefixStyle.Base128); // auth ticket byte[] bytes = new byte[details.Ticket.Length]; details.Ticket.CopyTo(bytes, 0); bool carry = false; for (int i = 0; i < bytes.Length; ++i) { byte d = (byte) (((bytes[i] * 2) % 256) + (carry ? 1 : 0)); carry = bytes[i] > 127; bytes[i] = d; } stream.Write(bytes); connection.EnqueueOutOfBand(stream.ToBytes()); } }