public static Int32 FillFrom(this MessageWriter writer, Network network, Socket socket, ref EndPoint ep) { writer.Clear(); var result = network.LanDriver.Read(socket, writer._Buffer, writer._Buffer.Length, ref ep); if (result >= 0) { writer._Count = result; } return(result); }
public static void Serialize(MessageWriter writer, bool clear, int gameCode) { if (clear) { writer.Clear(SendOption.Reliable); } writer.StartMessage(MessageFlags.HostGame); writer.Write(gameCode); writer.EndMessage(); }
private void WriteWaitForHostMessage(MessageWriter message, bool clear, ClientPlayer player) { if (clear) { message.Clear(SendOption.Reliable); } message.StartMessage((byte)RequestFlag.WaitForHost); message.Write(Code); message.Write(player.Client.Id); message.EndMessage(); }
public static void Serialize(MessageWriter writer, bool clear, int gameCode, int playerId) { if (clear) { writer.Clear(SendOption.Reliable); } writer.StartMessage(MessageFlags.WaitForHost); writer.Write(gameCode); writer.Write(playerId); writer.EndMessage(); }
public static void Serialize(MessageWriter writer, bool clear, IPEndPoint ipEndPoint) { if (clear) { writer.Clear(SendOption.Reliable); } writer.StartMessage(MessageFlags.Redirect); writer.Write(ipEndPoint.Address.GetAddressBytes()); writer.Write((ushort)ipEndPoint.Port); writer.EndMessage(); }
public static void Serialize(MessageWriter writer, bool clear, int gameCode, int playerId, bool isBan) { if (clear) { writer.Clear(SendOption.Reliable); } writer.StartMessage(MessageFlags.KickPlayer); writer.Write(gameCode); writer.WritePacked(playerId); writer.Write(isBan); writer.EndMessage(); }
private void WriteAlterGameMessage(MessageWriter message, bool clear) { if (clear) { message.Clear(SendOption.Reliable); } message.StartMessage((byte)RequestFlag.AlterGame); message.Write(Code); message.Write((byte)AlterGameTags.ChangePrivacy); message.Write(IsPublic); message.EndMessage(); }
private void WriteKickPlayerMessage(MessageWriter message, bool clear, int playerId, bool isBan) { if (clear) { message.Clear(SendOption.Reliable); } message.StartMessage((byte)RequestFlag.KickPlayer); message.Write(Code); message.WritePacked(playerId); message.Write(isBan); message.EndMessage(); }
private void BroadcastJoinMessage(MessageWriter message, bool clear, ClientPlayer player) { if (clear) { message.Clear(SendOption.Reliable); } message.StartMessage((byte)RequestFlag.JoinGame); message.Write(Code); message.Write(player.Client.Id); message.Write(HostId); message.EndMessage(); SendToAllExcept(message, player); }
private void WriteRemovePlayerMessage(MessageWriter message, bool clear, int playerId, DisconnectReason reason) { // Only a subset of DisconnectReason shows an unique message. // ExitGame, Banned and Kicked. if (clear) { message.Clear(SendOption.Reliable); } message.StartMessage((byte)RequestFlag.RemovePlayer); message.Write(Code); message.Write(playerId); message.Write(HostId); message.Write((byte)reason); message.EndMessage(); }
public static void Serialize(MessageWriter writer, bool clear, int gameCode, int playerId, int hostId, DisconnectReason reason) { // Only a subset of DisconnectReason shows an unique message. // ExitGame, Banned and Kicked. if (clear) { writer.Clear(SendOption.Reliable); } writer.StartMessage(MessageFlags.RemovePlayer); writer.Write(gameCode); writer.Write(playerId); writer.Write(hostId); writer.Write((byte)reason); writer.EndMessage(); }
public static void Serialize(MessageWriter writer, bool clear, int gameCode, int playerId, int hostId, int[] otherPlayerIds) { if (clear) { writer.Clear(SendOption.Reliable); } writer.StartMessage(MessageFlags.JoinedGame); writer.Write(gameCode); writer.Write(playerId); writer.Write(hostId); writer.WritePacked(otherPlayerIds.Length); foreach (var id in otherPlayerIds) { writer.WritePacked(id); } writer.EndMessage(); }
public void Clear() { active = false; spawned = false; dropasap = false; privileged = false; sendsignon = false; last_message = 0; netconnection = null; cmd.Clear(); wishdir = Vector3.Zero; message.Clear(); edict = null; name = null; colors = 0; Array.Clear(ping_times, 0, ping_times.Length); num_pings = 0; Array.Clear(spawn_parms, 0, spawn_parms.Length); old_frags = 0; }
private void WriteJoinedGameMessage(MessageWriter message, bool clear, ClientPlayer player) { if (clear) { message.Clear(SendOption.Reliable); } message.StartMessage((byte)RequestFlag.JoinedGame); message.Write(Code); message.Write(player.Client.Id); message.Write(HostId); message.WritePacked(_players.Count - 1); foreach (var(_, p) in _players.Where(x => x.Value != player)) { message.WritePacked(p.Client.Id); } message.EndMessage(); }
public static void SerializeError(MessageWriter writer, bool clear, DisconnectReason reason, string message = null) { if (clear) { writer.Clear(SendOption.Reliable); } writer.StartMessage(MessageFlags.JoinGame); writer.Write((int)reason); if (reason == DisconnectReason.Custom) { if (message == null) { throw new ArgumentNullException(nameof(message)); } writer.Write(message); } writer.EndMessage(); }
public void Clear() { active = false; paused = false; loadgame = false; time = 0; lastcheck = 0; lastchecktime = 0; name = null; modelname = null; worldmodel = null; Array.Clear(model_precache, 0, model_precache.Length); Array.Clear(models, 0, models.Length); Array.Clear(sound_precache, 0, sound_precache.Length); Array.Clear(lightstyles, 0, lightstyles.Length); num_edicts = 0; max_edicts = 0; edicts = null; state = 0; datagram.Clear(); reliable_datagram.Clear(); signon.Clear(); }
/// <summary> /// Host_Spawn_f /// </summary> 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 MessageWriter 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; }