/* 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 System.Collections.Generic; using StockholmLibrary.Net; namespace StockholmLibrary.Game.Util { //------------------------------------ public enum EUserProperty : byte { Username = 2, Password = 3, Figure = 4, Sex = 5, Motto = 6, Email = 7, DateOfBirth = 8, CurrentPassword = 13 } //------------------------------------ public class UserPropertyDecoder { private Dictionary _properties; //********************************************** public string this[EUserProperty propertyID] { get { if (_properties.ContainsKey(propertyID)) { return _properties[propertyID]; } else { return null; } } } //********************************************** public UserPropertyDecoder(ClientPacket packet) { _properties = new Dictionary(); while (packet.Buffer.Position < packet.Buffer.Length) { byte propertyID = (byte)packet.ReadArgumentInt(); if (propertyID == 10) { // Protocol exception for the 'receive email from hotel manager' flag, skip 7 bytes byte[] tmp = new byte[7]; packet.Buffer.Read(tmp, 0, tmp.Length); } else { string propertyValue = packet.ReadArgumentString(); if (Enum.IsDefined(typeof(EUserProperty), propertyID)) { _properties.Add((EUserProperty)propertyID, propertyValue); } } } } } }