protected override void GenerateServerInfo(Packer packer, int token) { var playersCount = 0; var clientsCount = 0; for (var i = 0; i < MaxClients; i++) { if (Clients[i].State == ServerClientState.Empty) { continue; } if (GameContext.IsClientPlayer(i)) { playersCount++; } clientsCount++; } if (token != -1) { packer.Reset(); packer.AddRaw(MasterServerPackets.Info); packer.AddInt(token); } packer.AddString(GameContext.GameVersion, 32); packer.AddString(Config["SvName"], 64); packer.AddString(Config["SvHostname"], 128); packer.AddString(CurrentMap.MapName, 32); packer.AddString(GameContext.GameController.GameType, 16); var flag = string.IsNullOrEmpty(Config["Password"]) ? 0 : ServerInfoFlagPassword; packer.AddInt(flag); packer.AddInt(Config["SvSkillLevel"]); packer.AddInt(playersCount); packer.AddInt(Config["SvPlayerSlots"]); packer.AddInt(clientsCount); packer.AddInt(MaxClients); if (token != -1) { for (var i = 0; i < MaxClients; i++) { if (Clients[i].State != ServerClientState.Empty) { packer.AddString(ClientName(i), BaseServerClient.MaxNameLength); packer.AddString(ClientClan(i), BaseServerClient.MaxClanLength); packer.AddInt(ClientCountry(i)); packer.AddInt(GameContext.GameController.Score(i)); packer.AddInt(GameContext.IsClientPlayer(i) ? 0 : 1); // flag spectator=1, bot=2 (player=0) } } } }
private static void SendGetInfo() { var packer = new Packer(); packer.Reset(); packer.AddRaw(MasterServerPackets.GetInfo); packer.AddInt(RNG.Int()); var packet = new Chunk(); packet.EndPoint = new IPEndPoint(IPAddress.Broadcast, 8303); packet.ClientId = -1; packet.Flags = SendFlags.Connless; packet.DataSize = packer.Size(); packet.Data = packer.Data(); _networkClient.Send(packet); }