/* Thor Server 2.0 Project - Codenamed "Stockholm" Copyright 2008 - 2009 Joe Hegarty This file is part of The Thor Server 2.0 Project - Codenamed "Stockholm". The Thor Server 2.0 Project - Codenamed "Stockholm" is free software: you can redistribute it and/or modify it under the terms of the Microsoft Public License The Thor Server Project is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Microsoft Public License for more details. You should have received a copy of the Microsoft Public License along with The Thor Server Project. If not, see http://www.opensource.org/licenses/ms-pl.html */ using System; using StockholmLibrary.Net; namespace StockholmLibrary.Game.Packets.Client { //------------------------------------ public class SetFlatInfoPacket : ClientPacketDeserialiser { public int RoomID; public string RoomDescription; public bool SuperUsers; public int MaxGuests; public string Password; //********************************************** public override void Deserialise(ClientPacket packet) { base.Deserialise(packet); string[] lines = packet.ReadWholePacketAsString().Split("\r".ToCharArray()); // Determine the room ID (packet body is different incase SetFlatInfo follows CreateFlat) if (lines[0][0] == '/') { this.RoomID = int.Parse(lines[0].Split('/')[1]); } else { this.RoomID = int.Parse(lines[0].Split('/')[0]); } // Process the key-value pairs foreach (var line in lines) { string[] parts = line.Split("=".ToCharArray(), 2); if (parts[0] == "description") { this.RoomDescription = parts[1]; } else if (parts[0] == "allsuperuser") { this.SuperUsers = (parts[1] == "1"); } else if (parts[0] == "maxvisitors") { this.MaxGuests = int.Parse(parts[1]); } else if (parts[0] == "password") { // SetFlatInfoPacket.Password will hold null when there is either no password or a blank/invalid password if (parts[1].Length > 0 && parts[1] != "null") { this.Password = parts[1]; } } } } } }