public static Packet AnnounceGame(GameDefinition gameDefinition) { var packet = new Packet(); packet.Type = gameDefinition.GameTypeInfo.PacketType; packet.Data.Add(new Signature(SignatureType.Data, gameDefinition.GameId)); packet.Data.Add(new Signature(SignatureType.Data, BinaryCodedDecimal.FromDecimal((byte)gameDefinition.GameTimeMinutes))); packet.Data.Add(new Signature(SignatureType.Data, BinaryCodedDecimal.FromDecimal((byte)gameDefinition.Tags))); packet.Data.Add(new Signature(SignatureType.Data, BinaryCodedDecimal.FromDecimal((byte)gameDefinition.Reloads))); packet.Data.Add(new Signature(SignatureType.Data, BinaryCodedDecimal.FromDecimal((byte)gameDefinition.Shields))); packet.Data.Add(new Signature(SignatureType.Data, BinaryCodedDecimal.FromDecimal((byte)gameDefinition.Mega))); var flags1 = (byte) ((gameDefinition.ExtendedTagging ? 1 : 0) << 7 | (gameDefinition.LimitedReloads ? 1 : 0) << 6 | (gameDefinition.LimitedMega ? 1 : 0) << 5 | (gameDefinition.TeamTags ? 1 : 0) << 4 | (gameDefinition.MedicMode ? 1 : 0) << 3 | (gameDefinition.SlowTags ? 1 : 0) << 2 | (gameDefinition.GameTypeInfo.HuntThePrey ? 1 : 0) << 1 | (gameDefinition.GameTypeInfo.ReverseHuntDirection ? 1 : 0) << 0); var flags2 = (byte) ((gameDefinition.GameTypeInfo.Zones ? 1 : 0) << 7 | (gameDefinition.GameTypeInfo.TeamZones ? 1 : 0) << 6 | (gameDefinition.GameTypeInfo.NeutralizePlayersTaggedInZone ? 1 : 0) << 5 | (gameDefinition.GameTypeInfo.ZonesRevivePlayers ? 1 : 0) << 4 | (gameDefinition.GameTypeInfo.HospitalZones ? 1 : 0) << 3 | (gameDefinition.GameTypeInfo.ZonesTagPlayers ? 1 : 0) << 2 | (gameDefinition.TeamCount & 0x03)); // hard code these here for now switch (gameDefinition.GameType) { case GameType.Respawn: // RESP case GameType.RespawnTwoTeams: // 2TRS case GameType.RespawnThreeTeams: // 3TRS flags1 |= 0x80; flags2 |= 0x30; break; } packet.Data.Add(new Signature(SignatureType.Data, flags1)); packet.Data.Add(new Signature(SignatureType.Data, flags2)); if (gameDefinition.GameTypeInfo.PacketType == PacketType.AnnounceGameSpecial) { packet.Data.AddRange(gameDefinition.GameTypeInfo.Name.GetSignatures(4, true)); } packet.PopulateChecksum(); return packet; }
public void StartServer(GameDefinition gameDefinition) { if (HostingState != HostingStates.Idle) return; _gameDefinition = gameDefinition; _gameDefinition.GameId = new RandomId(); ChangeState(HostingStates.Adding); }