private bool LoadFromOtbVer3(BinaryNode node, FileReader reader) { PropertyReader props = null; while (node != null) { props = reader.GetPropertyReader(node); ItemType item = new ItemType(); byte itemGroup = (byte)node.Type; switch ((OtbItemGroup)itemGroup) { case OtbItemGroup.NONE: item.Group = ItemGroup.None; break; case OtbItemGroup.GROUND: item.Group = ItemGroup.Ground; break; case OtbItemGroup.SPLASH: item.Group = ItemGroup.Splash; break; case OtbItemGroup.FLUID: item.Group = ItemGroup.FluidContainer; break; case OtbItemGroup.CONTAINER: item.Group = ItemGroup.Container; break; case OtbItemGroup.DEPRECATED: item.Group = ItemGroup.Deprecated; break; default: Messages.AddWarning("Unknown item group declaration"); break; } OtbItemFlags flags = (OtbItemFlags)props.ReadUInt32(); item.BlockObject = ((flags & OtbItemFlags.BLOCK_SOLID) == OtbItemFlags.BLOCK_SOLID); item.BlockProjectile = ((flags & OtbItemFlags.BLOCK_PROJECTILE) == OtbItemFlags.BLOCK_PROJECTILE); item.BlockPathFind = ((flags & OtbItemFlags.BLOCK_PATHFIND) == OtbItemFlags.BLOCK_PATHFIND); item.IsPickupable = ((flags & OtbItemFlags.PICKUPABLE) == OtbItemFlags.PICKUPABLE); item.IsMoveable = ((flags & OtbItemFlags.MOVEABLE) == OtbItemFlags.MOVEABLE); item.IsStackable = ((flags & OtbItemFlags.STACKABLE) == OtbItemFlags.STACKABLE); item.FloorChangeDown = ((flags & OtbItemFlags.FLOORCHANGEDOWN) == OtbItemFlags.FLOORCHANGEDOWN); item.FloorChangeNorth = ((flags & OtbItemFlags.FLOORCHANGENORTH) == OtbItemFlags.FLOORCHANGENORTH); item.FloorChangeEast = ((flags & OtbItemFlags.FLOORCHANGEEAST) == OtbItemFlags.FLOORCHANGEEAST); item.FloorChangeSouth = ((flags & OtbItemFlags.FLOORCHANGESOUTH) == OtbItemFlags.FLOORCHANGESOUTH); item.FloorChangeWest = ((flags & OtbItemFlags.FLOORCHANGEWEST) == OtbItemFlags.FLOORCHANGEWEST); item.alwaysOnBottom = ((flags & OtbItemFlags.ALWAYSONTOP) == OtbItemFlags.ALWAYSONTOP); item.IsVertical = ((flags & OtbItemFlags.VERTICAL) == OtbItemFlags.VERTICAL); item.IsHorizontal = ((flags & OtbItemFlags.HORIZONTAL) == OtbItemFlags.HORIZONTAL); item.IsHangable = ((flags & OtbItemFlags.HANGABLE) == OtbItemFlags.HANGABLE); item.IsRotatable = ((flags & OtbItemFlags.ROTABLE) == OtbItemFlags.ROTABLE); item.IsReadable = ((flags & OtbItemFlags.READABLE) == OtbItemFlags.READABLE); item.HasUseWith = ((flags & OtbItemFlags.USEABLE) == OtbItemFlags.USEABLE); item.HasHeight = ((flags & OtbItemFlags.HAS_HEIGHT) == OtbItemFlags.HAS_HEIGHT); item.LookThrough = ((flags & OtbItemFlags.LOOKTHROUGH) == OtbItemFlags.LOOKTHROUGH); item.AllowDistRead = ((flags & OtbItemFlags.ALLOWDISTREAD) == OtbItemFlags.ALLOWDISTREAD); item.IsAnimation = ((flags & OtbItemFlags.ANIMATION) == OtbItemFlags.ANIMATION); item.WalkStack = ((flags & OtbItemFlags.WALKSTACK) == OtbItemFlags.WALKSTACK); while (props.PeekChar() != -1) { byte attribute = props.ReadByte(); UInt16 datalen = props.ReadUInt16(); switch ((OtbItemAttr)attribute) { case OtbItemAttr.ITEM_ATTR_SERVERID: if (datalen != sizeof(UInt16)) { throw new Exception("Unexpected data length of server id block (Should be 2 bytes)"); } item.Id = props.ReadUInt16(); break; case OtbItemAttr.ITEM_ATTR_CLIENTID: if (datalen != sizeof(UInt16)) { throw new Exception("Unexpected data length of client id block (Should be 2 bytes)"); } item.SpriteId = props.ReadUInt16(); break; case OtbItemAttr.ITEM_ATTR_WAREID: if (datalen != sizeof(UInt16)) { throw new Exception("Unexpected data length of ware id block (Should be 2 bytes)"); } item.WareId = props.ReadUInt16(); break; case OtbItemAttr.ITEM_ATTR_SPEED: if (datalen != sizeof(UInt16)) { throw new Exception("Unexpected data length of speed block (Should be 2 bytes)"); } item.GroundSpeed = props.ReadUInt16(); break; case OtbItemAttr.ITEM_ATTR_NAME: item.Name = new string(props.ReadChars(datalen)); break; case OtbItemAttr.ITEM_ATTR_SPRITEHASH: if (datalen != 16) { throw new Exception("Unexpected data length of sprite hash (Should be 16 bytes)"); } item.SpriteHash = props.ReadBytes(16); break; case OtbItemAttr.ITEM_ATTR_MINIMAPCOLOR: if (datalen != 2) { throw new Exception("Unexpected data length of minimap color (Should be 2 bytes)"); } item.MinimapColor = props.ReadUInt16(); break; case OtbItemAttr.ITEM_ATTR_07: //read/write-able if (datalen != 2) { throw new Exception("Unexpected data length of attr 07 (Should be 2 bytes)"); } item.MaxReadWriteChars = props.ReadUInt16(); break; case OtbItemAttr.ITEM_ATTR_08: //readable if (datalen != 2) { throw new Exception("Unexpected data length of attr 08 (Should be 2 bytes)"); } item.MaxReadChars = props.ReadUInt16(); break; case OtbItemAttr.ITEM_ATTR_LIGHT2: if (datalen != sizeof(UInt16) * 2) { throw new Exception("Unexpected data length of item light (2) block"); } item.LightLevel = props.ReadUInt16(); item.LightColor = props.ReadUInt16(); break; case OtbItemAttr.ITEM_ATTR_TOPORDER: if (datalen != sizeof(byte)) { throw new Exception("Unexpected data length of item toporder block (Should be 1 byte)"); } item.AlwaysOnTopOrder = props.ReadByte(); break; default: //skip unknown attributes props.ReadBytes(datalen); break; } } if (MaxId < item.Id) { MaxId = item.Id; } items[item.Id] = item; clientItems[item.SpriteId] = item; node = node.Next; } return(true); }