From d444b9ba5c2d78fbd31488ff129634afdfec71d6 Mon Sep 17 00:00:00 2001 From: mark Date: Mon, 6 Dec 2010 06:45:45 +0000 Subject: [PATCH] --- Scripts/Commands/Decorate.cs | 2 +- Scripts/Commands/DecorateMag.cs | 2 +- Scripts/Commands/GenCategorization.cs | 2 +- Scripts/Commands/Statics.cs | 58 +++-- Scripts/Engines/BulkOrders/SmallBulkEntry.cs | 2 +- Scripts/Engines/Craft/Core/CraftItem.cs | 4 +- Scripts/Engines/Craft/DefBlacksmithy.cs | 4 +- Scripts/Engines/Craft/DefInscription.cs | 10 +- Scripts/Engines/Harvest/Core/HarvestSystem.cs | 2 +- Scripts/Engines/Harvest/Fishing.cs | 2 +- Scripts/Engines/Pathing/Movement.cs | 51 ++--- .../Engines/Plants/MiscItems/GreenThorns.cs | 2 +- Scripts/Engines/Plants/PlantBowl.cs | 2 +- Scripts/Engines/Plants/PlantType.cs | 2 +- .../Quests/Collector/Items/ImageType.cs | 2 +- Scripts/Gumps/ViewHousesGump.cs | 2 +- Scripts/Items/Addons/BaseAddon.cs | 6 +- Scripts/Items/Construction/Doors/BaseDoor.cs | 2 +- Scripts/Items/Deeds/HolidayTreeDeed.cs | 8 +- Scripts/Items/Food/CookableFood.cs | 4 +- Scripts/Items/Misc/Firebomb.cs | 2 +- Scripts/Items/Misc/InteriorDecorator.cs | 6 +- Scripts/Items/Misc/Static.cs | 11 +- Scripts/Items/Resources/Blacksmithing/Ore.cs | 2 +- .../Fishing/Misc/SpecialFishingNet.cs | 2 +- .../Explosion Potions/BaseExplosionPotion.cs | 2 +- .../Items/Special/Veteran Rewards/Banner.cs | 2 +- .../Veteran Rewards/DecorativeShield.cs | 2 +- .../Veteran Rewards/HangingSkeleton.cs | 2 +- Scripts/Misc/DoorGenerator.cs | 14 +- Scripts/Misc/VendorGenerator.cs | 36 ++-- Scripts/Mobiles/Vendors/GenericBuy.cs | 2 +- Scripts/Multis/BaseHouse.cs | 8 +- Scripts/Multis/Boats/BaseBoat.cs | 12 +- Scripts/Multis/Boats/BaseBoatDeed.cs | 2 +- Scripts/Multis/Boats/BaseDockedBoat.cs | 2 +- Scripts/Multis/Boats/LargeBoat.cs | 12 +- Scripts/Multis/Boats/LargeDragonBoat.cs | 12 +- Scripts/Multis/Boats/MediumBoat.cs | 12 +- Scripts/Multis/Boats/MediumDragonBoat.cs | 12 +- Scripts/Multis/Boats/SmallBoat.cs | 12 +- Scripts/Multis/Boats/SmallDragonBoat.cs | 12 +- Scripts/Multis/Boats/Strandedness.cs | 12 +- Scripts/Multis/Camps/BaseCamp.cs | 12 +- Scripts/Multis/Camps/BrigandCamp.cs | 2 +- Scripts/Multis/Camps/LizardmenCamp.cs | 2 +- Scripts/Multis/Camps/OrcCamp.cs | 2 +- Scripts/Multis/Camps/RatCamp.cs | 2 +- Scripts/Multis/Deeds.cs | 2 +- Scripts/Multis/HouseFoundation.cs | 32 +-- Scripts/Multis/HousePlacement.cs | 40 ++-- Scripts/Multis/Houses.cs | 6 +- Scripts/Multis/PreviewHouse.cs | 4 +- Scripts/Regions/BaseRegion.cs | 16 +- Scripts/Regions/Spawning/SpawnDefinition.cs | 2 +- Scripts/Spells/Base/SpellHelper.cs | 2 +- Scripts/Spells/Spellweaving/ArcaneCircle.cs | 9 +- Server/Item.cs | 62 ++++-- Server/Items/BaseMulti.cs | 18 +- Server/Map.cs | 62 +++--- Server/MultiData.cs | 83 ++++---- Server/Network/PacketHandlers.cs | 10 +- Server/Network/Packets.cs | 72 +++---- Server/Targeting/LandTarget.cs | 2 +- Server/Targeting/StaticTarget.cs | 2 +- Server/TileData.cs | 14 ++ Server/TileList.cs | 22 +- Server/TileMatrix.cs | 199 +++++++++++------- Server/TileMatrixPatch.cs | 10 +- Server/Utility.cs | 15 +- 70 files changed, 569 insertions(+), 495 deletions(-) diff --git a/Scripts/Commands/Decorate.cs b/Scripts/Commands/Decorate.cs index 3a58d8317..eab3722e5 100644 --- a/Scripts/Commands/Decorate.cs +++ b/Scripts/Commands/Decorate.cs @@ -901,7 +901,7 @@ namespace Server.Commands m_DeleteQueue.Enqueue( item ); } } - else if ( (TileData.ItemTable[itemID & 0x3FFF].Flags & TileFlag.LightSource) != 0 ) + else if ( (TileData.ItemTable[itemID & TileData.MaxItemValue].Flags & TileFlag.LightSource) != 0 ) { eable = map.GetItemsInRange( new Point3D( x, y, z ), 0 ); diff --git a/Scripts/Commands/DecorateMag.cs b/Scripts/Commands/DecorateMag.cs index 10a05aaa2..904b92d4b 100644 --- a/Scripts/Commands/DecorateMag.cs +++ b/Scripts/Commands/DecorateMag.cs @@ -898,7 +898,7 @@ namespace Server.Commands m_DeleteQueue.Enqueue( item ); } } - else if ( (TileData.ItemTable[itemID & 0x3FFF].Flags & TileFlag.LightSource) != 0 ) + else if ( (TileData.ItemTable[itemID & TileData.MaxItemValue].Flags & TileFlag.LightSource) != 0 ) { eable = map.GetItemsInRange( new Point3D( x, y, z ), 0 ); diff --git a/Scripts/Commands/GenCategorization.cs b/Scripts/Commands/GenCategorization.cs index 043ace68d..027aef164 100644 --- a/Scripts/Commands/GenCategorization.cs +++ b/Scripts/Commands/GenCategorization.cs @@ -108,7 +108,7 @@ namespace Server.Commands if ( item is BaseAddon && ((BaseAddon)item).Components.Count == 1 ) itemID = ((AddonComponent)(((BaseAddon)item).Components[0])).ItemID; - if ( itemID >= 0x4000 ) + if ( itemID > TileData.MaxItemValue ) itemID = 1; xml.WriteAttributeString( "gfx", XmlConvert.ToString( itemID ) ); diff --git a/Scripts/Commands/Statics.cs b/Scripts/Commands/Statics.cs index 2fa16e3d3..0e16cd20f 100644 --- a/Scripts/Commands/Statics.cs +++ b/Scripts/Commands/Statics.cs @@ -210,13 +210,7 @@ namespace Server if ( xOffset < 0 || xOffset >= 8 || yOffset < 0 || yOffset >= 8 ) continue; - StaticTile newTile = new StaticTile(); - - newTile.m_ID = (short)(item.ItemID & 0x3FFF); - newTile.m_X = (byte)xOffset; - newTile.m_Y = (byte)yOffset; - newTile.m_Z = (sbyte)item.Z; - newTile.m_Hue = (short)item.Hue; + StaticTile newTile = new StaticTile( (ushort)item.ItemID, (byte)xOffset, (byte)yOffset, (sbyte)item.Z, (short)item.Hue ); newTiles[newTileCount++] = newTile; @@ -241,22 +235,22 @@ namespace Server { StaticTile toWrite = oldTiles[i]; - mulWriter.Write( (short) toWrite.m_ID ); - mulWriter.Write( (byte) toWrite.m_X ); - mulWriter.Write( (byte) toWrite.m_Y ); - mulWriter.Write( (sbyte) toWrite.m_Z ); - mulWriter.Write( (short) toWrite.m_Hue ); + mulWriter.Write( (ushort) toWrite.ID ); + mulWriter.Write( (byte) toWrite.X ); + mulWriter.Write( (byte) toWrite.Y ); + mulWriter.Write( (sbyte) toWrite.Z ); + mulWriter.Write( (short) toWrite.Hue ); } for ( int i = 0; i < newTileCount; ++i ) { StaticTile toWrite = newTiles[i]; - mulWriter.Write( (short) toWrite.m_ID ); - mulWriter.Write( (byte) toWrite.m_X ); - mulWriter.Write( (byte) toWrite.m_Y ); - mulWriter.Write( (sbyte) toWrite.m_Z ); - mulWriter.Write( (short) toWrite.m_Hue ); + mulWriter.Write( (ushort) toWrite.ID ); + mulWriter.Write( (byte) toWrite.X ); + mulWriter.Write( (byte) toWrite.Y ); + mulWriter.Write( (sbyte) toWrite.Z ); + mulWriter.Write( (short) toWrite.Hue ); } mulWriter.Flush(); @@ -381,8 +375,8 @@ namespace Server { StaticTile oldTile = oldTiles[i]; - int px = baseX + oldTile.m_X; - int py = baseY + oldTile.m_Y; + int px = baseX + oldTile.X; + int py = baseY + oldTile.Y; if ( px < 0 || px >= xTileWidth || py < 0 || py >= yTileHeight ) { @@ -392,11 +386,11 @@ namespace Server { ++totalUnfrozen; - Item item = new Static( oldTile.m_ID & 0x3FFF ); + Item item = new Static( oldTile.ID ); - item.Hue = oldTile.m_Hue; + item.Hue = oldTile.Hue; - item.MoveToWorld( new Point3D( px + xTileStart, py + yTileStart, oldTile.m_Z ), map ); + item.MoveToWorld( new Point3D( px + xTileStart, py + yTileStart, oldTile.Z ), map ); } } @@ -416,11 +410,11 @@ namespace Server { StaticTile toWrite = newTiles[i]; - mulWriter.Write( (short) toWrite.m_ID ); - mulWriter.Write( (byte) toWrite.m_X ); - mulWriter.Write( (byte) toWrite.m_Y ); - mulWriter.Write( (sbyte) toWrite.m_Z ); - mulWriter.Write( (short) toWrite.m_Hue ); + mulWriter.Write( (ushort) toWrite.ID ); + mulWriter.Write( (byte) toWrite.X ); + mulWriter.Write( (byte) toWrite.Y ); + mulWriter.Write( (sbyte) toWrite.Z ); + mulWriter.Write( (short) toWrite.Hue ); } mulWriter.Flush(); @@ -533,11 +527,9 @@ namespace Server for ( int i = 0; i < count; ++i ) { - staTiles[i].m_ID = (short)(m_Buffer[index++] | (m_Buffer[index++] << 8)); - staTiles[i].m_X = m_Buffer[index++]; - staTiles[i].m_Y = m_Buffer[index++]; - staTiles[i].m_Z = (sbyte)m_Buffer[index++]; - staTiles[i].m_Hue = (short)(m_Buffer[index++] | (m_Buffer[index++] << 8)); + staTiles[i].Set((ushort)(m_Buffer[index++] | (m_Buffer[index++] << 8)), + (byte)m_Buffer[index++], (byte)m_Buffer[index++], (sbyte)m_Buffer[index++], + (short)(m_Buffer[index++] | (m_Buffer[index++] << 8))); } } } @@ -558,7 +550,7 @@ namespace Server { m_X = p.X; m_Y = p.Y; - m_List = new List(); + m_List = new List(); } } diff --git a/Scripts/Engines/BulkOrders/SmallBulkEntry.cs b/Scripts/Engines/BulkOrders/SmallBulkEntry.cs index d0da3707f..d7eb8b22e 100644 --- a/Scripts/Engines/BulkOrders/SmallBulkEntry.cs +++ b/Scripts/Engines/BulkOrders/SmallBulkEntry.cs @@ -95,7 +95,7 @@ namespace Server.Engines.BulkOrders int graphic = Utility.ToInt32( split[split.Length - 1] ); if ( type != null && graphic > 0 ) - list.Add( new SmallBulkEntry( type, 1020000 + graphic, graphic ) ); + list.Add( new SmallBulkEntry( type, graphic < 0x4000 ? 1020000 + graphic : 1078872 + graphic, graphic ) ); } } catch diff --git a/Scripts/Engines/Craft/Core/CraftItem.cs b/Scripts/Engines/Craft/Core/CraftItem.cs index acc38f500..6bc4f48a0 100644 --- a/Scripts/Engines/Craft/Core/CraftItem.cs +++ b/Scripts/Engines/Craft/Core/CraftItem.cs @@ -420,12 +420,12 @@ namespace Server.Engines.Craft int vx = from.X + x; int vy = from.Y + y; - Tile[] tiles = map.Tiles.GetStaticTiles( vx, vy, true ); + StaticTile[] tiles = map.Tiles.GetStaticTiles( vx, vy, true ); for ( int i = 0; i < tiles.Length; ++i ) { int z = tiles[i].Z; - int id = tiles[i].ID & 0x3FFF; + int id = tiles[i].ID; if ( (z + 16) > from.Z && (from.Z + 16) > z && Find( id, itemIDs ) ) return true; diff --git a/Scripts/Engines/Craft/DefBlacksmithy.cs b/Scripts/Engines/Craft/DefBlacksmithy.cs index 9ca1bd07c..604dee139 100644 --- a/Scripts/Engines/Craft/DefBlacksmithy.cs +++ b/Scripts/Engines/Craft/DefBlacksmithy.cs @@ -92,11 +92,11 @@ namespace Server.Engines.Craft { for ( int y = -range; (!anvil || !forge) && y <= range; ++y ) { - Tile[] tiles = map.Tiles.GetStaticTiles( from.X+x, from.Y+y, true ); + StaticTile[] tiles = map.Tiles.GetStaticTiles( from.X+x, from.Y+y, true ); for ( int i = 0; (!anvil || !forge) && i < tiles.Length; ++i ) { - int id = tiles[i].ID & 0x3FFF; + int id = tiles[i].ID; bool isAnvil = ( id == 4015 || id == 4016 || id == 0x2DD5 || id == 0x2DD6 ); bool isForge = ( id == 4017 || (id >= 6522 && id <= 6569) || id == 0x2DD8 ); diff --git a/Scripts/Engines/Craft/DefInscription.cs b/Scripts/Engines/Craft/DefInscription.cs index 3952e0d64..074a35db5 100644 --- a/Scripts/Engines/Craft/DefInscription.cs +++ b/Scripts/Engines/Craft/DefInscription.cs @@ -159,10 +159,14 @@ namespace Server.Engines.Craft private void AddNecroSpell( int spell, int mana, double minSkill, Type type, params Type[] regs ) { - int index = AddCraft( type, 1061677, 1060509 + spell, minSkill, minSkill + 1.0, regs[0], 1020000 + CraftItem.ItemIDOf( regs[0] ), 1, 501627 ); //Yes, on OSI it's only 1.0 skill diff'. Don't blame me, blame OSI. + int id = CraftItem.ItemIDOf( regs[0] ); - for ( int i = 1; i < regs.Length; ++i ) - AddRes( index, regs[i], 1020000 + CraftItem.ItemIDOf( regs[i] ), 1, 501627 ); + int index = AddCraft( type, 1061677, 1060509 + spell, minSkill, minSkill + 1.0, regs[0], id < 0x4000 ? 1020000 + id : 1078872 + id, 501627 ); //Yes, on OSI it's only 1.0 skill diff'. Don't blame me, blame OSI. + + for ( int i = 1; i < regs.Length; ++i ) { + id = CraftItem.ItemIDOf( regs[i] ); + AddRes( index, regs[i], id < 0x4000 ? 1020000 + id : 1078872 + id, 1, 501627 ); + } AddRes( index, typeof( BlankScroll ), 1044377, 1, 1044378 ); diff --git a/Scripts/Engines/Harvest/Core/HarvestSystem.cs b/Scripts/Engines/Harvest/Core/HarvestSystem.cs index 87e2bca0e..cc3e148c8 100644 --- a/Scripts/Engines/Harvest/Core/HarvestSystem.cs +++ b/Scripts/Engines/Harvest/Core/HarvestSystem.cs @@ -467,7 +467,7 @@ namespace Server.Engines.Harvest { LandTarget obj = (LandTarget)toHarvest; - tileID = obj.TileID & 0x3FFF; + tileID = obj.TileID; map = from.Map; loc = obj.Location; } diff --git a/Scripts/Engines/Harvest/Fishing.cs b/Scripts/Engines/Harvest/Fishing.cs index 8a8da738d..19d26b3ae 100644 --- a/Scripts/Engines/Harvest/Fishing.cs +++ b/Scripts/Engines/Harvest/Fishing.cs @@ -387,7 +387,7 @@ namespace Server.Engines.Harvest int tx = m.X - 10 + Utility.Random( 21 ); int ty = m.Y - 10 + Utility.Random( 21 ); - Tile t = map.Tiles.GetLandTile( tx, ty ); + LandTile t = map.Tiles.GetLandTile( tx, ty ); if ( t.Z == -5 && ( (t.ID >= 0xA8 && t.ID <= 0xAB) || (t.ID >= 0x136 && t.ID <= 0x137) ) && !Spells.SpellHelper.CheckMulti( new Point3D( tx, ty, -5 ), map ) ) { diff --git a/Scripts/Engines/Pathing/Movement.cs b/Scripts/Engines/Pathing/Movement.cs index 6d28731d6..e9a775dd8 100644 --- a/Scripts/Engines/Pathing/Movement.cs +++ b/Scripts/Engines/Pathing/Movement.cs @@ -2,6 +2,7 @@ using System; using System.Collections; using System.Collections.Generic; using Server; +using Server.Items; using Server.Mobiles; namespace Server.Movement @@ -30,12 +31,12 @@ namespace Server.Movement { } - private bool IsOk( bool ignoreDoors, bool ignoreSpellFields, int ourZ, int ourTop, Tile[] tiles, List items ) + private bool IsOk( bool ignoreDoors, bool ignoreSpellFields, int ourZ, int ourTop, StaticTile[] tiles, List items ) { for ( int i = 0; i < tiles.Length; ++i ) { - Tile check = tiles[i]; - ItemData itemData = TileData.ItemTable[check.ID & 0x3FFF]; + StaticTile check = tiles[i]; + ItemData itemData = TileData.ItemTable[check.ID & TileData.MaxItemValue]; if ( (itemData.Flags & ImpassableSurface) != 0 ) // Impassable || Surface { @@ -50,7 +51,7 @@ namespace Server.Movement for ( int i = 0; i < items.Count; ++i ) { Item item = items[i]; - int itemID = item.ItemID & 0x3FFF; + int itemID = item.ItemID & TileData.MaxItemValue; ItemData itemData = TileData.ItemTable[itemID]; TileFlag flags = itemData.Flags; @@ -85,15 +86,15 @@ namespace Server.Movement { newZ = 0; - Tile[] tiles = map.Tiles.GetStaticTiles( x, y, true ); - Tile landTile = map.Tiles.GetLandTile( x, y ); + StaticTile[] tiles = map.Tiles.GetStaticTiles( x, y, true ); + LandTile landTile = map.Tiles.GetLandTile( x, y ); - bool landBlocks = (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Impassable) != 0; + bool landBlocks = (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Impassable) != 0; bool considerLand = !landTile.Ignored; - if ( landBlocks && canSwim && (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Wet) != 0 ) //Impassable, Can Swim, and Is water. Don't block it. + if ( landBlocks && canSwim && (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Wet) != 0 ) //Impassable, Can Swim, and Is water. Don't block it. landBlocks = false; - else if ( cantWalk && (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Wet) == 0 ) //Can't walk and it's not water + else if ( cantWalk && (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Wet) == 0 ) //Can't walk and it's not water landBlocks = true; int landZ = 0, landCenter = 0, landTop = 0; @@ -111,8 +112,8 @@ namespace Server.Movement #region Tiles for ( int i = 0; i < tiles.Length; ++i ) { - Tile tile = tiles[i]; - ItemData itemData = TileData.ItemTable[tile.ID & 0x3FFF]; + StaticTile tile = tiles[i]; + ItemData itemData = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; TileFlag flags = itemData.Flags; if ( (flags & ImpassableSurface) == TileFlag.Surface || (canSwim && (flags & TileFlag.Wet) != 0) ) // Surface && !Impassable @@ -319,13 +320,13 @@ namespace Server.Movement if ( (item.ItemData.Flags & reqFlags) == 0 ) continue; - if ( sector == sectorStart && item.AtWorldPoint( xStart, yStart ) && item.ItemID < 0x4000 ) + if ( sector == sectorStart && item.AtWorldPoint( xStart, yStart ) && item.ItemID <= TileData.MaxItemValue ) itemsStart.Add( item ); - else if ( sector == sectorForward && item.AtWorldPoint( xForward, yForward ) && item.ItemID < 0x4000 ) + else if ( sector == sectorForward && item.AtWorldPoint( xForward, yForward ) && item.ItemID <= TileData.MaxItemValue ) itemsForward.Add( item ); - else if ( sector == sectorLeft && item.AtWorldPoint( xLeft, yLeft ) && item.ItemID < 0x4000 ) + else if ( sector == sectorLeft && item.AtWorldPoint( xLeft, yLeft ) && item.ItemID <= TileData.MaxItemValue ) itemsLeft.Add( item ); - else if ( sector == sectorRight && item.AtWorldPoint( xRight, yRight ) && item.ItemID < 0x4000 ) + else if ( sector == sectorRight && item.AtWorldPoint( xRight, yRight ) && item.ItemID <= TileData.MaxItemValue ) itemsRight.Add( item ); } } @@ -350,9 +351,9 @@ namespace Server.Movement if ( (item.ItemData.Flags & reqFlags) == 0 ) continue; - if ( item.AtWorldPoint( xStart, yStart ) && item.ItemID < 0x4000 ) + if ( item.AtWorldPoint( xStart, yStart ) && item.ItemID <= TileData.MaxItemValue ) itemsStart.Add( item ); - else if ( item.AtWorldPoint( xForward, yForward ) && item.ItemID < 0x4000 ) + else if ( item.AtWorldPoint( xForward, yForward ) && item.ItemID <= TileData.MaxItemValue ) itemsForward.Add( item ); } } @@ -368,7 +369,7 @@ namespace Server.Movement if ( (item.ItemData.Flags & reqFlags) == 0 ) continue; - if ( item.AtWorldPoint( xForward, yForward ) && item.ItemID < 0x4000 ) + if ( item.AtWorldPoint( xForward, yForward ) && item.ItemID <= TileData.MaxItemValue ) itemsForward.Add( item ); } @@ -426,13 +427,13 @@ namespace Server.Movement { int xCheck = loc.X, yCheck = loc.Y; - Tile landTile = map.Tiles.GetLandTile( xCheck, yCheck ); + LandTile landTile = map.Tiles.GetLandTile( xCheck, yCheck ); int landZ = 0, landCenter = 0, landTop = 0; - bool landBlocks = (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Impassable) != 0; + bool landBlocks = (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Impassable) != 0; - if ( landBlocks && m.CanSwim && (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Wet) != 0 ) + if ( landBlocks && m.CanSwim && (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Wet) != 0 ) landBlocks = false; - else if ( m.CantWalk && (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Wet) == 0 ) + else if ( m.CantWalk && (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Wet) == 0 ) landBlocks = true; map.GetAverageZ( xCheck, yCheck, ref landZ, ref landCenter, ref landTop ); @@ -453,12 +454,12 @@ namespace Server.Movement isSet = true; } - Tile[] staticTiles = map.Tiles.GetStaticTiles( xCheck, yCheck, true ); + StaticTile[] staticTiles = map.Tiles.GetStaticTiles( xCheck, yCheck, true ); for ( int i = 0; i < staticTiles.Length; ++i ) { - Tile tile = staticTiles[i]; - ItemData id = TileData.ItemTable[tile.ID & 0x3FFF]; + StaticTile tile = staticTiles[i]; + ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; int calcTop = (tile.Z + id.CalcHeight); diff --git a/Scripts/Engines/Plants/MiscItems/GreenThorns.cs b/Scripts/Engines/Plants/MiscItems/GreenThorns.cs index 151eafd11..0fc7a4a95 100644 --- a/Scripts/Engines/Plants/MiscItems/GreenThorns.cs +++ b/Scripts/Engines/Plants/MiscItems/GreenThorns.cs @@ -270,7 +270,7 @@ namespace Server.Items if ( !from.Map.CanSpawnMobile( land.Location ) ) return null; - int tileID = land.TileID & 0x3FFF; + int tileID = land.TileID; foreach ( TilesAndEffect taep in m_Table ) { diff --git a/Scripts/Engines/Plants/PlantBowl.cs b/Scripts/Engines/Plants/PlantBowl.cs index efab1cdf7..d886318e2 100644 --- a/Scripts/Engines/Plants/PlantBowl.cs +++ b/Scripts/Engines/Plants/PlantBowl.cs @@ -137,7 +137,7 @@ namespace Server.Engines.Plants else if ( obj is StaticTarget ) tileID = (((StaticTarget)obj).ItemID & 0x3FFF) | 0x4000; else if ( obj is LandTarget ) - tileID = ((LandTarget)obj).TileID & 0x3FFF; + tileID = ((LandTarget)obj).TileID; else return false; diff --git a/Scripts/Engines/Plants/PlantType.cs b/Scripts/Engines/Plants/PlantType.cs index a691cf519..62febda49 100644 --- a/Scripts/Engines/Plants/PlantType.cs +++ b/Scripts/Engines/Plants/PlantType.cs @@ -285,7 +285,7 @@ namespace Server.Engines.Plants public int OffsetX { get { return m_OffsetX; } } public int OffsetY { get { return m_OffsetY; } } public PlantType PlantType { get { return m_PlantType; } } - public int Name { get { return 1020000 + m_ItemID; } } + public int Name { get { return m_ItemID < 0x4000 ? 1020000 + m_ItemID : 1078872 + m_ItemID; } } public bool ContainsPlant { get { return m_ContainsPlant; } } public bool Flowery { get { return m_Flowery; } } public bool Crossable { get { return m_Crossable; } } diff --git a/Scripts/Engines/Quests/Collector/Items/ImageType.cs b/Scripts/Engines/Quests/Collector/Items/ImageType.cs index 71d381350..5160c6f52 100644 --- a/Scripts/Engines/Quests/Collector/Items/ImageType.cs +++ b/Scripts/Engines/Quests/Collector/Items/ImageType.cs @@ -92,7 +92,7 @@ namespace Server.Engines.Quests.Collector public int Figurine { get { return m_Figurine; } } public Type Type { get { return m_Type; } } - public int Name { get { return 1020000 + m_Figurine; } } + public int Name { get { return m_Figurine < 0x4000 ? 1020000 + m_Figurine : 1078872 + m_Figurine; } } public int X { get { return m_X; } } public int Y { get { return m_Y; } } diff --git a/Scripts/Gumps/ViewHousesGump.cs b/Scripts/Gumps/ViewHousesGump.cs index 3f41c6b22..b1b38eb0f 100644 --- a/Scripts/Gumps/ViewHousesGump.cs +++ b/Scripts/Gumps/ViewHousesGump.cs @@ -246,7 +246,7 @@ namespace Server.Gumps public object FindHouseName( BaseHouse house ) { - int multiID = house.ItemID & 0x3FFF; + int multiID = house.ItemID; HousePlacementEntry[] entries; entries = HousePlacementEntry.ClassicHouses; diff --git a/Scripts/Items/Addons/BaseAddon.cs b/Scripts/Items/Addons/BaseAddon.cs index 9449d24d1..75d40890b 100644 --- a/Scripts/Items/Addons/BaseAddon.cs +++ b/Scripts/Items/Addons/BaseAddon.cs @@ -172,12 +172,12 @@ namespace Server.Items if ( map == null ) return false; - Tile[] tiles = map.Tiles.GetStaticTiles( x, y, true ); + StaticTile[] tiles = map.Tiles.GetStaticTiles( x, y, true ); for ( int i = 0; i < tiles.Length; ++i ) { - Tile t = tiles[i]; - ItemData id = TileData.ItemTable[t.ID & 0x3FFF]; + StaticTile t = tiles[i]; + ItemData id = TileData.ItemTable[t.ID & TileData.MaxItemValue]; if ( (id.Flags & TileFlag.Wall) != 0 && (z + 16) > t.Z && (t.Z + t.Height) > z ) return true; diff --git a/Scripts/Items/Construction/Doors/BaseDoor.cs b/Scripts/Items/Construction/Doors/BaseDoor.cs index 6864084e9..6d0b7fb37 100644 --- a/Scripts/Items/Construction/Doors/BaseDoor.cs +++ b/Scripts/Items/Construction/Doors/BaseDoor.cs @@ -288,7 +288,7 @@ namespace Server.Items { Item item = items[i]; - if ( item.ItemID < 0x4000 && item.AtWorldPoint( x, y ) && !(item is BaseDoor) ) + if ( !(item is BaseMulti) && item.AtWorldPoint( x, y ) && !(item is BaseDoor) ) { ItemData id = item.ItemData; bool surface = id.Surface; diff --git a/Scripts/Items/Deeds/HolidayTreeDeed.cs b/Scripts/Items/Deeds/HolidayTreeDeed.cs index 4606da02c..6104a75a4 100644 --- a/Scripts/Items/Deeds/HolidayTreeDeed.cs +++ b/Scripts/Items/Deeds/HolidayTreeDeed.cs @@ -94,10 +94,10 @@ namespace Server.Items Point3D loc = new Point3D( p ); if ( p is StaticTarget ) - loc.Z -= TileData.ItemTable[((StaticTarget)p).ItemID & 0x3FFF].CalcHeight; /* NOTE: OSI does not properly normalize Z positioning here. - * A side affect is that you can only place on floors (due to the CanFit call). - * That functionality may be desired. And so, it's included in this script. - */ + loc.Z -= TileData.ItemTable[((StaticTarget)p).ItemID].CalcHeight; /* NOTE: OSI does not properly normalize Z positioning here. + * A side affect is that you can only place on floors (due to the CanFit call). + * That functionality may be desired. And so, it's included in this script. + */ if ( ValidatePlacement( from, loc ) ) EndPlace( from, (HolidayTreeType) state, loc ); diff --git a/Scripts/Items/Food/CookableFood.cs b/Scripts/Items/Food/CookableFood.cs index 245fd9a46..bc7669c15 100644 --- a/Scripts/Items/Food/CookableFood.cs +++ b/Scripts/Items/Food/CookableFood.cs @@ -75,9 +75,9 @@ namespace Server.Items int itemID; if ( targeted is Item ) - itemID = ((Item)targeted).ItemID & 0x3FFF; + itemID = ((Item)targeted).ItemID; else if ( targeted is StaticTarget ) - itemID = ((StaticTarget)targeted).ItemID & 0x3FFF; + itemID = ((StaticTarget)targeted).ItemID; else return false; diff --git a/Scripts/Items/Misc/Firebomb.cs b/Scripts/Items/Misc/Firebomb.cs index ef7b9a34c..dc2a2bae6 100644 --- a/Scripts/Items/Misc/Firebomb.cs +++ b/Scripts/Items/Misc/Firebomb.cs @@ -164,7 +164,7 @@ namespace Server.Items else to = new Entity( Serial.Zero, new Point3D( p ), Map ); - Effects.SendMovingEffect( from, to, ItemID & 0x3FFF, 7, 0, false, false, Hue, 0 ); + Effects.SendMovingEffect( from, to, ItemID, 7, 0, false, false, Hue, 0 ); Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), new TimerStateCallback( FirebombReposition_OnTick ), new object[]{ p, Map } ); Internalize(); diff --git a/Scripts/Items/Misc/InteriorDecorator.cs b/Scripts/Items/Misc/InteriorDecorator.cs index 46ca7676b..86bb8c028 100644 --- a/Scripts/Items/Misc/InteriorDecorator.cs +++ b/Scripts/Items/Misc/InteriorDecorator.cs @@ -243,14 +243,14 @@ namespace Server.Items if ( map == null ) return int.MinValue; - Tile[] tiles = map.Tiles.GetStaticTiles( item.X, item.Y, true ); + StaticTile[] tiles = map.Tiles.GetStaticTiles( item.X, item.Y, true ); int z = int.MinValue; for ( int i = 0; i < tiles.Length; ++i ) { - Tile tile = tiles[i]; - ItemData id = TileData.ItemTable[tile.ID & 0x3FFF]; + StaticTile tile = tiles[i]; + ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; int top = tile.Z; // Confirmed : no height checks here diff --git a/Scripts/Items/Misc/Static.cs b/Scripts/Items/Misc/Static.cs index e283af4a0..09fceb626 100644 --- a/Scripts/Items/Misc/Static.cs +++ b/Scripts/Items/Misc/Static.cs @@ -5,11 +5,10 @@ namespace Server.Items { public class Static : Item { - public Static() //Dupe-tastic! - : base( 0x80 ) - { - Movable = false; - } + public Static() : base( 0x80 ) + { + Movable = false; + } [Constructable] public Static( int itemID ) : base( itemID ) @@ -58,7 +57,7 @@ namespace Server.Items public override int LabelNumber{ get{ return m_LabelNumber; } } [Constructable] - public LocalizedStatic( int itemID ) : this( itemID, 1020000 + itemID ) + public LocalizedStatic( int itemID ) : this( itemID, itemID < 0x4000 ? 1020000 + itemID : 1078872 + itemID ) { } diff --git a/Scripts/Items/Resources/Blacksmithing/Ore.cs b/Scripts/Items/Resources/Blacksmithing/Ore.cs index 0bca1adc6..e7d9c197e 100644 --- a/Scripts/Items/Resources/Blacksmithing/Ore.cs +++ b/Scripts/Items/Resources/Blacksmithing/Ore.cs @@ -175,7 +175,7 @@ namespace Server.Items if ( obj is Item ) itemID = ((Item)obj).ItemID; else if ( obj is StaticTarget ) - itemID = ((StaticTarget)obj).ItemID & 0x3FFF; + itemID = ((StaticTarget)obj).ItemID; return ( itemID == 4017 || (itemID >= 6522 && itemID <= 6569) ); } diff --git a/Scripts/Items/Skill Items/Fishing/Misc/SpecialFishingNet.cs b/Scripts/Items/Skill Items/Fishing/Misc/SpecialFishingNet.cs index 75d729d39..12416e958 100644 --- a/Scripts/Items/Skill Items/Fishing/Misc/SpecialFishingNet.cs +++ b/Scripts/Items/Skill Items/Fishing/Misc/SpecialFishingNet.cs @@ -218,7 +218,7 @@ namespace Server.Items int tx = p.X - 2 + Utility.Random( 5 ); int ty = p.Y - 2 + Utility.Random( 5 ); - Tile t = map.Tiles.GetLandTile( tx, ty ); + LandTile t = map.Tiles.GetLandTile( tx, ty ); if ( t.Z == p.Z && ( (t.ID >= 0xA8 && t.ID <= 0xAB) || (t.ID >= 0x136 && t.ID <= 0x137) ) && !Spells.SpellHelper.CheckMulti( new Point3D( tx, ty, p.Z ), map ) ) { diff --git a/Scripts/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs b/Scripts/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs index 16ef3c6f4..66191ca50 100644 --- a/Scripts/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs +++ b/Scripts/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs @@ -210,7 +210,7 @@ namespace Server.Items to = (Mobile)p; } - Effects.SendMovingEffect( from, to, m_Potion.ItemID & 0x3FFF, 7, 0, false, false, m_Potion.Hue, 0 ); + Effects.SendMovingEffect( from, to, m_Potion.ItemID, 7, 0, false, false, m_Potion.Hue, 0 ); if( m_Potion.Amount > 1 ) { diff --git a/Scripts/Items/Special/Veteran Rewards/Banner.cs b/Scripts/Items/Special/Veteran Rewards/Banner.cs index 54a0b2158..03f471bc0 100644 --- a/Scripts/Items/Special/Veteran Rewards/Banner.cs +++ b/Scripts/Items/Special/Veteran Rewards/Banner.cs @@ -273,7 +273,7 @@ namespace Server.Items return; Point3D p3d = new Point3D( p ); - ItemData id = TileData.ItemTable[ m_ItemID & 0x3FFF ]; + ItemData id = TileData.ItemTable[ m_ItemID & TileData.MaxItemValue ]; if ( map.CanFit( p3d, id.Height ) ) { diff --git a/Scripts/Items/Special/Veteran Rewards/DecorativeShield.cs b/Scripts/Items/Special/Veteran Rewards/DecorativeShield.cs index 49471f7f6..be4fecc0a 100644 --- a/Scripts/Items/Special/Veteran Rewards/DecorativeShield.cs +++ b/Scripts/Items/Special/Veteran Rewards/DecorativeShield.cs @@ -288,7 +288,7 @@ namespace Server.Items return; Point3D p3d = new Point3D( p ); - ItemData id = TileData.ItemTable[ m_ItemID & 0x3FFF ]; + ItemData id = TileData.ItemTable[ m_ItemID & TileData.MaxItemValue ]; if ( map.CanFit( p3d, id.Height ) ) { diff --git a/Scripts/Items/Special/Veteran Rewards/HangingSkeleton.cs b/Scripts/Items/Special/Veteran Rewards/HangingSkeleton.cs index b6aa199f8..77d181ce0 100644 --- a/Scripts/Items/Special/Veteran Rewards/HangingSkeleton.cs +++ b/Scripts/Items/Special/Veteran Rewards/HangingSkeleton.cs @@ -277,7 +277,7 @@ namespace Server.Items return; Point3D p3d = new Point3D( p ); - ItemData id = TileData.ItemTable[ m_ItemID & 0x3FFF ]; + ItemData id = TileData.ItemTable[ m_ItemID & TileData.MaxItemValue ]; if ( map.CanFit( p3d, id.Height ) ) { diff --git a/Scripts/Misc/DoorGenerator.cs b/Scripts/Misc/DoorGenerator.cs index a9ebc9e67..e3b8952b1 100644 --- a/Scripts/Misc/DoorGenerator.cs +++ b/Scripts/Misc/DoorGenerator.cs @@ -392,8 +392,6 @@ namespace Server public static bool IsFrame( int id, int[] list ) { - id &= 0x3FFF; - if ( id > list[list.Length - 1] ) return false; @@ -432,11 +430,11 @@ namespace Server public static bool IsEastFrame( int x, int y, int z ) { - Tile[] tiles = m_Map.Tiles.GetStaticTiles( x, y ); + StaticTile[] tiles = m_Map.Tiles.GetStaticTiles( x, y ); for ( int i = 0; i < tiles.Length; ++i ) { - Tile tile = tiles[i]; + StaticTile tile = tiles[i]; if ( tile.Z == z && IsEastFrame( tile.ID ) ) return true; @@ -447,11 +445,11 @@ namespace Server public static bool IsSouthFrame( int x, int y, int z ) { - Tile[] tiles = m_Map.Tiles.GetStaticTiles( x, y ); + StaticTile[] tiles = m_Map.Tiles.GetStaticTiles( x, y ); for ( int i = 0; i < tiles.Length; ++i ) { - Tile tile = tiles[i]; + StaticTile tile = tiles[i]; if ( tile.Z == z && IsSouthFrame( tile.ID ) ) return true; @@ -497,11 +495,11 @@ namespace Server int vx = rx + region.X; int vy = ry + region.Y; - Tile[] tiles = m_Map.Tiles.GetStaticTiles( vx, vy ); + StaticTile[] tiles = m_Map.Tiles.GetStaticTiles( vx, vy ); for ( int i = 0; i < tiles.Length; ++i ) { - Tile tile = tiles[i]; + StaticTile tile = tiles[i]; int id = tile.ID; int z = tile.Z; diff --git a/Scripts/Misc/VendorGenerator.cs b/Scripts/Misc/VendorGenerator.cs index 6f6a3a3c0..1ecf6f1d7 100644 --- a/Scripts/Misc/VendorGenerator.cs +++ b/Scripts/Misc/VendorGenerator.cs @@ -49,7 +49,7 @@ namespace Server private static bool GetFloorZ( Map map, int x, int y, out int z ) { - Tile lt = map.Tiles.GetLandTile( x, y ); + LandTile lt = map.Tiles.GetLandTile( x, y ); if ( IsFloor( lt.ID ) && map.CanFit( x, y, lt.Z, 16, false, false ) ) { @@ -57,12 +57,12 @@ namespace Server return true; } - Tile[] tiles = map.Tiles.GetStaticTiles( x, y ); + StaticTile[] tiles = map.Tiles.GetStaticTiles( x, y ); for ( int i = 0; i < tiles.Length; ++i ) { - Tile t = tiles[i]; - ItemData id = TileData.ItemTable[t.ID & 0x3FFF]; + StaticTile t = tiles[i]; + ItemData id = TileData.ItemTable[t.ID & TileData.MaxItemValue]; if ( IsStaticFloor( t.ID ) && map.CanFit( x, y, t.Z + (id.Surface ? id.CalcHeight : 0), 16, false, false ) ) { @@ -77,17 +77,17 @@ namespace Server private static bool IsFloor( Map map, int x, int y, bool canFit ) { - Tile lt = map.Tiles.GetLandTile( x, y ); + LandTile lt = map.Tiles.GetLandTile( x, y ); if ( IsFloor( lt.ID ) && (canFit||CanFit( map, x, y, lt.Z )) ) return true; - Tile[] tiles = map.Tiles.GetStaticTiles( x, y ); + StaticTile[] tiles = map.Tiles.GetStaticTiles( x, y ); for ( int i = 0; i < tiles.Length; ++i ) { - Tile t = tiles[i]; - ItemData id = TileData.ItemTable[t.ID & 0x3FFF]; + StaticTile t = tiles[i]; + ItemData id = TileData.ItemTable[t.ID & TileData.MaxItemValue]; if ( IsStaticFloor( t.ID ) && (canFit||CanFit( map, x, y, t.Z + (id.Surface ? id.CalcHeight : 0) )) ) return true; @@ -98,23 +98,19 @@ namespace Server private static bool IsFloor( int itemID ) { - itemID &= 0x3FFF; + itemID &= TileData.MaxLandValue; return ( itemID >= 0x406 && itemID <= 0x51A ); } private static bool IsStaticFloor( int itemID ) { - itemID &= 0x3FFF; - return ( itemID >= 0x495 && itemID <= 0x514 ) || ( itemID >= 0x519 && itemID <= 0x53A ); } private static bool IsDisplayCase( int itemID ) { - itemID &= 0x3FFF; - return ( itemID >= 0xB00 && itemID <= 0xB02 ) || ( itemID >= 0xB06 && itemID <= 0xB0A ) || ( itemID >= 0xB0D && itemID <= 0xB17 ); @@ -261,7 +257,7 @@ namespace Server private static void CheckFloor( Map map, int x, int y ) { - Tile[] tiles = map.Tiles.GetStaticTiles( x, y ); + StaticTile[] tiles = map.Tiles.GetStaticTiles( x, y ); for ( int i = 0; i < tiles.Length; ++i ) { @@ -371,7 +367,7 @@ namespace Server private static ShopFlags ProcessDisplayedItem( int itemID ) { - itemID &= 0x3FFF; + itemID &= TileData.MaxItemValue; ShopFlags res = ShopFlags.None; @@ -411,7 +407,7 @@ namespace Server return res; } - private static void ProcessDisplayCase( Map map, Tile[] tiles, int x, int y ) + private static void ProcessDisplayCase( Map map, StaticTile[] tiles, int x, int y ) { ShopFlags flags = ShopFlags.None; @@ -460,18 +456,18 @@ namespace Server { bool hasSurface = false; - Tile lt = map.Tiles.GetLandTile( x, y ); + LandTile lt = map.Tiles.GetLandTile( x, y ); int lowZ = 0, avgZ = 0, topZ = 0; map.GetAverageZ( x, y, ref lowZ, ref avgZ, ref topZ ); - TileFlag landFlags = TileData.LandTable[lt.ID & 0x3FFF].Flags; + TileFlag landFlags = TileData.LandTable[lt.ID & TileData.MaxLandValue].Flags; if ( (landFlags & TileFlag.Impassable) != 0 && topZ > z && (z + 16) > lowZ ) return false; else if ( (landFlags & TileFlag.Impassable) == 0 && z == avgZ && !lt.Ignored ) hasSurface = true; - Tile[] staticTiles = map.Tiles.GetStaticTiles( x, y ); + StaticTile[] staticTiles = map.Tiles.GetStaticTiles( x, y ); bool surface, impassable; @@ -480,7 +476,7 @@ namespace Server if ( IsDisplayCase( staticTiles[i].ID ) ) continue; - ItemData id = TileData.ItemTable[staticTiles[i].ID & 0x3FFF]; + ItemData id = TileData.ItemTable[staticTiles[i].ID & TileData.MaxItemValue]; surface = id.Surface; impassable = id.Impassable; diff --git a/Scripts/Mobiles/Vendors/GenericBuy.cs b/Scripts/Mobiles/Vendors/GenericBuy.cs index eea30f2fe..d46a3384f 100644 --- a/Scripts/Mobiles/Vendors/GenericBuy.cs +++ b/Scripts/Mobiles/Vendors/GenericBuy.cs @@ -256,7 +256,7 @@ namespace Server.Mobiles m_Args = args; if ( name == null ) - m_Name = (1020000 + (itemID & 0x3FFF)).ToString(); + m_Name = itemID < 0x4000 ? (1020000 + itemID).ToString() : (1078872 + itemID).ToString(); else m_Name = name; } diff --git a/Scripts/Multis/BaseHouse.cs b/Scripts/Multis/BaseHouse.cs index 64e065961..2eed1440f 100644 --- a/Scripts/Multis/BaseHouse.cs +++ b/Scripts/Multis/BaseHouse.cs @@ -1052,12 +1052,12 @@ namespace Server.Multis if ( this is HouseFoundation && y < (mcl.Height-1) && p.Z >= this.Z ) return true; - Tile[] tiles = mcl.Tiles[x][y]; + StaticTile[] tiles = mcl.Tiles[x][y]; for ( int j = 0; j < tiles.Length; ++j ) { - Tile tile = tiles[j]; - int id = tile.ID & 0x3FFF; + StaticTile tile = tiles[j]; + int id = tile.ID & TileData.MaxItemValue; ItemData data = TileData.ItemTable[id]; // Slanted roofs do not count; they overhang blocking south and east sides of the multi @@ -1095,7 +1095,7 @@ namespace Server.Multis private static List m_AllHouses = new List(); - public BaseHouse( int multiID, Mobile owner, int MaxLockDown, int MaxSecure ) : base( multiID | 0x4000 ) + public BaseHouse( int multiID, Mobile owner, int MaxLockDown, int MaxSecure ) : base( multiID ) { m_AllHouses.Add( this ); diff --git a/Scripts/Multis/Boats/BaseBoat.cs b/Scripts/Multis/Boats/BaseBoat.cs index 2b8920b4d..f6090ed88 100644 --- a/Scripts/Multis/Boats/BaseBoat.cs +++ b/Scripts/Multis/Boats/BaseBoat.cs @@ -149,7 +149,7 @@ namespace Server.Multis public static List Boats{ get{ return m_Instances; } } - public BaseBoat() : base( 0x4000 ) + public BaseBoat() : base( 0x0 ) { m_DecayTime = DateTime.Now + BoatDecayDelay; @@ -1184,8 +1184,8 @@ namespace Server.Multis if ( newComponents.Tiles[x][y].Length == 0 || Contains( tx, ty ) ) continue; - Tile landTile = map.Tiles.GetLandTile( tx, ty ); - Tile[] tiles = map.Tiles.GetStaticTiles( tx, ty, true ); + LandTile landTile = map.Tiles.GetLandTile( tx, ty ); + StaticTile[] tiles = map.Tiles.GetStaticTiles( tx, ty, true ); bool hasWater = false; @@ -1203,8 +1203,8 @@ namespace Server.Multis for ( int i = 0; i < tiles.Length; ++i ) { - Tile tile = tiles[i]; - bool isWater = ( tile.ID >= 0x5796 && tile.ID <= 0x57B2 ); + StaticTile tile = tiles[i]; + bool isWater = ( tile.ID >= 0x1796 && tile.ID <= 0x17B2 ); if ( tile.Z == p.Z && isWater ) hasWater = true; @@ -1221,7 +1221,7 @@ namespace Server.Multis foreach ( Item item in eable ) { - if ( item.ItemID >= 0x4000 || item.Z < p.Z || !item.Visible ) + if ( item is BaseMulti || item.Z < p.Z || !item.Visible ) continue; int x = item.X - p.X + newComponents.Min.X; diff --git a/Scripts/Multis/Boats/BaseBoatDeed.cs b/Scripts/Multis/Boats/BaseBoatDeed.cs index f55932a5a..3bd45c14c 100644 --- a/Scripts/Multis/Boats/BaseBoatDeed.cs +++ b/Scripts/Multis/Boats/BaseBoatDeed.cs @@ -25,7 +25,7 @@ namespace Server.Multis if ( !Core.AOS ) LootType = LootType.Newbied; - m_MultiID = id & 0x3FFF; + m_MultiID = id; m_Offset = offset; } diff --git a/Scripts/Multis/Boats/BaseDockedBoat.cs b/Scripts/Multis/Boats/BaseDockedBoat.cs index 2eea84597..577c027d4 100644 --- a/Scripts/Multis/Boats/BaseDockedBoat.cs +++ b/Scripts/Multis/Boats/BaseDockedBoat.cs @@ -26,7 +26,7 @@ namespace Server.Multis Weight = 1.0; LootType = LootType.Blessed; - m_MultiID = id & 0x3FFF; + m_MultiID = id; m_Offset = offset; m_ShipName = boat.ShipName; diff --git a/Scripts/Multis/Boats/LargeBoat.cs b/Scripts/Multis/Boats/LargeBoat.cs index 0308a57ec..601de7480 100644 --- a/Scripts/Multis/Boats/LargeBoat.cs +++ b/Scripts/Multis/Boats/LargeBoat.cs @@ -6,10 +6,10 @@ namespace Server.Multis { public class LargeBoat : BaseBoat { - public override int NorthID{ get{ return 0x4010; } } - public override int EastID{ get{ return 0x4011; } } - public override int SouthID{ get{ return 0x4012; } } - public override int WestID{ get{ return 0x4013; } } + public override int NorthID{ get{ return 0x10; } } + public override int EastID{ get{ return 0x11; } } + public override int SouthID{ get{ return 0x12; } } + public override int WestID{ get{ return 0x13; } } public override int HoldDistance{ get{ return 5; } } public override int TillerManDistance{ get{ return -5; } } @@ -51,7 +51,7 @@ namespace Server.Multis public override BaseBoat Boat{ get{ return new LargeBoat(); } } [Constructable] - public LargeBoatDeed() : base( 0x4010, new Point3D( 0, -1, 0 ) ) + public LargeBoatDeed() : base( 0x10, new Point3D( 0, -1, 0 ) ) { } @@ -78,7 +78,7 @@ namespace Server.Multis { public override BaseBoat Boat{ get{ return new LargeBoat(); } } - public LargeDockedBoat( BaseBoat boat ) : base( 0x4010, new Point3D( 0, -1, 0 ), boat ) + public LargeDockedBoat( BaseBoat boat ) : base( 0x10, new Point3D( 0, -1, 0 ), boat ) { } diff --git a/Scripts/Multis/Boats/LargeDragonBoat.cs b/Scripts/Multis/Boats/LargeDragonBoat.cs index 6c08f579e..6acba8139 100644 --- a/Scripts/Multis/Boats/LargeDragonBoat.cs +++ b/Scripts/Multis/Boats/LargeDragonBoat.cs @@ -6,10 +6,10 @@ namespace Server.Multis { public class LargeDragonBoat : BaseBoat { - public override int NorthID{ get{ return 0x4014; } } - public override int EastID{ get{ return 0x4015; } } - public override int SouthID{ get{ return 0x4016; } } - public override int WestID{ get{ return 0x4017; } } + public override int NorthID{ get{ return 0x14; } } + public override int EastID{ get{ return 0x15; } } + public override int SouthID{ get{ return 0x16; } } + public override int WestID{ get{ return 0x17; } } public override int HoldDistance{ get{ return 5; } } public override int TillerManDistance{ get{ return -5; } } @@ -51,7 +51,7 @@ namespace Server.Multis public override BaseBoat Boat{ get{ return new LargeDragonBoat(); } } [Constructable] - public LargeDragonBoatDeed() : base( 0x4014, new Point3D( 0, -1, 0 ) ) + public LargeDragonBoatDeed() : base( 0x14, new Point3D( 0, -1, 0 ) ) { } @@ -78,7 +78,7 @@ namespace Server.Multis { public override BaseBoat Boat{ get{ return new LargeDragonBoat(); } } - public LargeDockedDragonBoat( BaseBoat boat ) : base( 0x4014, new Point3D( 0, -1, 0 ), boat ) + public LargeDockedDragonBoat( BaseBoat boat ) : base( 0x14, new Point3D( 0, -1, 0 ), boat ) { } diff --git a/Scripts/Multis/Boats/MediumBoat.cs b/Scripts/Multis/Boats/MediumBoat.cs index 124cbd4f4..d747753be 100644 --- a/Scripts/Multis/Boats/MediumBoat.cs +++ b/Scripts/Multis/Boats/MediumBoat.cs @@ -6,10 +6,10 @@ namespace Server.Multis { public class MediumBoat : BaseBoat { - public override int NorthID{ get{ return 0x4008; } } - public override int EastID{ get{ return 0x4009; } } - public override int SouthID{ get{ return 0x400A; } } - public override int WestID{ get{ return 0x400B; } } + public override int NorthID{ get{ return 0x8; } } + public override int EastID{ get{ return 0x9; } } + public override int SouthID{ get{ return 0xA; } } + public override int WestID{ get{ return 0xB; } } public override int HoldDistance{ get{ return 4; } } public override int TillerManDistance{ get{ return -5; } } @@ -51,7 +51,7 @@ namespace Server.Multis public override BaseBoat Boat{ get{ return new MediumBoat(); } } [Constructable] - public MediumBoatDeed() : base( 0x4008, Point3D.Zero ) + public MediumBoatDeed() : base( 0x8, Point3D.Zero ) { } @@ -78,7 +78,7 @@ namespace Server.Multis { public override BaseBoat Boat{ get{ return new MediumBoat(); } } - public MediumDockedBoat( BaseBoat boat ) : base( 0x4008, Point3D.Zero, boat ) + public MediumDockedBoat( BaseBoat boat ) : base( 0x8, Point3D.Zero, boat ) { } diff --git a/Scripts/Multis/Boats/MediumDragonBoat.cs b/Scripts/Multis/Boats/MediumDragonBoat.cs index 5b624e370..2cb7e68bd 100644 --- a/Scripts/Multis/Boats/MediumDragonBoat.cs +++ b/Scripts/Multis/Boats/MediumDragonBoat.cs @@ -6,10 +6,10 @@ namespace Server.Multis { public class MediumDragonBoat : BaseBoat { - public override int NorthID{ get{ return 0x400C; } } - public override int EastID{ get{ return 0x400D; } } - public override int SouthID{ get{ return 0x400E; } } - public override int WestID{ get{ return 0x400F; } } + public override int NorthID{ get{ return 0xC; } } + public override int EastID{ get{ return 0xD; } } + public override int SouthID{ get{ return 0xE; } } + public override int WestID{ get{ return 0xF; } } public override int HoldDistance{ get{ return 4; } } public override int TillerManDistance{ get{ return -5; } } @@ -51,7 +51,7 @@ namespace Server.Multis public override BaseBoat Boat{ get{ return new MediumDragonBoat(); } } [Constructable] - public MediumDragonBoatDeed() : base( 0x400C, Point3D.Zero ) + public MediumDragonBoatDeed() : base( 0xC, Point3D.Zero ) { } @@ -78,7 +78,7 @@ namespace Server.Multis { public override BaseBoat Boat{ get{ return new MediumDragonBoat(); } } - public MediumDockedDragonBoat( BaseBoat boat ) : base( 0x400C, Point3D.Zero, boat ) + public MediumDockedDragonBoat( BaseBoat boat ) : base( 0xC, Point3D.Zero, boat ) { } diff --git a/Scripts/Multis/Boats/SmallBoat.cs b/Scripts/Multis/Boats/SmallBoat.cs index 87463b765..cdd2f1a58 100644 --- a/Scripts/Multis/Boats/SmallBoat.cs +++ b/Scripts/Multis/Boats/SmallBoat.cs @@ -6,10 +6,10 @@ namespace Server.Multis { public class SmallBoat : BaseBoat { - public override int NorthID{ get{ return 0x4000; } } - public override int EastID{ get{ return 0x4001; } } - public override int SouthID{ get{ return 0x4002; } } - public override int WestID{ get{ return 0x4003; } } + public override int NorthID{ get{ return 0x0; } } + public override int EastID{ get{ return 0x1; } } + public override int SouthID{ get{ return 0x2; } } + public override int WestID{ get{ return 0x3; } } public override int HoldDistance{ get{ return 4; } } public override int TillerManDistance{ get{ return -4; } } @@ -51,7 +51,7 @@ namespace Server.Multis public override BaseBoat Boat{ get{ return new SmallBoat(); } } [Constructable] - public SmallBoatDeed() : base( 0x4000, Point3D.Zero ) + public SmallBoatDeed() : base( 0x0, Point3D.Zero ) { } @@ -78,7 +78,7 @@ namespace Server.Multis { public override BaseBoat Boat{ get{ return new SmallBoat(); } } - public SmallDockedBoat( BaseBoat boat ) : base( 0x4000, Point3D.Zero, boat ) + public SmallDockedBoat( BaseBoat boat ) : base( 0x0, Point3D.Zero, boat ) { } diff --git a/Scripts/Multis/Boats/SmallDragonBoat.cs b/Scripts/Multis/Boats/SmallDragonBoat.cs index eb2d377ff..58d06af72 100644 --- a/Scripts/Multis/Boats/SmallDragonBoat.cs +++ b/Scripts/Multis/Boats/SmallDragonBoat.cs @@ -6,10 +6,10 @@ namespace Server.Multis { public class SmallDragonBoat : BaseBoat { - public override int NorthID{ get{ return 0x4004; } } - public override int EastID{ get{ return 0x4005; } } - public override int SouthID{ get{ return 0x4006; } } - public override int WestID{ get{ return 0x4007; } } + public override int NorthID{ get{ return 0x4; } } + public override int EastID{ get{ return 0x5; } } + public override int SouthID{ get{ return 0x6; } } + public override int WestID{ get{ return 0x7; } } public override int HoldDistance{ get{ return 4; } } public override int TillerManDistance{ get{ return -4; } } @@ -51,7 +51,7 @@ namespace Server.Multis public override BaseBoat Boat{ get{ return new SmallDragonBoat(); } } [Constructable] - public SmallDragonBoatDeed() : base( 0x4004, Point3D.Zero ) + public SmallDragonBoatDeed() : base( 0x4, Point3D.Zero ) { } @@ -78,7 +78,7 @@ namespace Server.Multis { public override BaseBoat Boat{ get{ return new SmallDragonBoat(); } } - public SmallDockedDragonBoat( BaseBoat boat ) : base( 0x4004, Point3D.Zero, boat ) + public SmallDockedDragonBoat( BaseBoat boat ) : base( 0x4, Point3D.Zero, boat ) { } diff --git a/Scripts/Multis/Boats/Strandedness.cs b/Scripts/Multis/Boats/Strandedness.cs index 2efc1e21a..dc160cb2b 100644 --- a/Scripts/Multis/Boats/Strandedness.cs +++ b/Scripts/Multis/Boats/Strandedness.cs @@ -103,13 +103,15 @@ namespace Server.Misc object surface = map.GetTopSurface( from.Location ); - if ( surface is Tile ) - { - int id = ((Tile)surface).ID; + if ( surface is LandTile ) { + int id = ((LandTile)surface).ID; return (id >= 168 && id <= 171) - || (id >= 310 && id <= 311) - || (id >= 0x5796 && id <= 0x57B2); + || (id >= 310 && id <= 311); + } else if ( surface is StaticTile ) { + int id = ((StaticTile)surface).ID; + + return (id >= 0x1796 && id <= 0x17B2); } return false; diff --git a/Scripts/Multis/Camps/BaseCamp.cs b/Scripts/Multis/Camps/BaseCamp.cs index 11980ed03..60afb0a42 100644 --- a/Scripts/Multis/Camps/BaseCamp.cs +++ b/Scripts/Multis/Camps/BaseCamp.cs @@ -30,7 +30,7 @@ namespace Server.Multis } } - public BaseCamp( int multiID ) : base( multiID | 0x4000 ) + public BaseCamp( int multiID ) : base( multiID ) { m_Items = new List(); m_Mobiles = new List(); @@ -40,16 +40,6 @@ namespace Server.Multis Timer.DelayCall( TimeSpan.Zero, new TimerCallback( CheckAddComponents ) ); } - public BaseCamp( int multiID, int mode ) : base( multiID | 0x4000*mode ) - { - m_Items = new List(); - m_Mobiles = new List(); - m_DecayDelay = TimeSpan.FromMinutes(30.0); - RefreshDecay(true); - - Timer.DelayCall( TimeSpan.Zero, new TimerCallback( CheckAddComponents ) ); - } - public void CheckAddComponents() { if ( Deleted ) diff --git a/Scripts/Multis/Camps/BrigandCamp.cs b/Scripts/Multis/Camps/BrigandCamp.cs index 1f49bba21..cdcebff69 100644 --- a/Scripts/Multis/Camps/BrigandCamp.cs +++ b/Scripts/Multis/Camps/BrigandCamp.cs @@ -12,7 +12,7 @@ namespace Server.Multis private Mobile m_Prisoner; [Constructable] - public BrigandCamp() : base( 0x10ee, 0 ) // dummy garbage at center + public BrigandCamp() : base( 0x10EE ) // dummy garbage at center { } diff --git a/Scripts/Multis/Camps/LizardmenCamp.cs b/Scripts/Multis/Camps/LizardmenCamp.cs index df09aa158..7c04f2174 100644 --- a/Scripts/Multis/Camps/LizardmenCamp.cs +++ b/Scripts/Multis/Camps/LizardmenCamp.cs @@ -11,7 +11,7 @@ namespace Server.Multis private Mobile m_Prisoner; [Constructable] - public LizardmenCamp() : base( 0x10ee , 0 ) // dummy garbage at center + public LizardmenCamp() : base( 0x10EE ) // dummy garbage at center { } diff --git a/Scripts/Multis/Camps/OrcCamp.cs b/Scripts/Multis/Camps/OrcCamp.cs index a89f07f3e..c4f7380ba 100644 --- a/Scripts/Multis/Camps/OrcCamp.cs +++ b/Scripts/Multis/Camps/OrcCamp.cs @@ -11,7 +11,7 @@ namespace Server.Multis private Mobile m_Prisoner; [Constructable] - public OrcCamp() : base( 0x10ee, 0 ) // dummy garbage at center + public OrcCamp() : base( 0x10EE ) // dummy garbage at center { } diff --git a/Scripts/Multis/Camps/RatCamp.cs b/Scripts/Multis/Camps/RatCamp.cs index 26407ad1f..92fcf3bf0 100644 --- a/Scripts/Multis/Camps/RatCamp.cs +++ b/Scripts/Multis/Camps/RatCamp.cs @@ -11,7 +11,7 @@ namespace Server.Multis private Mobile m_Prisoner; [Constructable] - public RatCamp() : base( 0x10ee, 0 ) // dummy garbage at center + public RatCamp() : base( 0x10EE ) // dummy garbage at center { } diff --git a/Scripts/Multis/Deeds.cs b/Scripts/Multis/Deeds.cs index d53ba774b..1b17cae4a 100644 --- a/Scripts/Multis/Deeds.cs +++ b/Scripts/Multis/Deeds.cs @@ -75,7 +75,7 @@ namespace Server.Multis.Deeds Weight = 1.0; LootType = LootType.Newbied; - m_MultiID = id & 0x3FFF; + m_MultiID = id; m_Offset = offset; } diff --git a/Scripts/Multis/HouseFoundation.cs b/Scripts/Multis/HouseFoundation.cs index 83e8e4f91..b48f4374a 100644 --- a/Scripts/Multis/HouseFoundation.cs +++ b/Scripts/Multis/HouseFoundation.cs @@ -553,11 +553,11 @@ namespace Server.Multis if( x >= 0 && x < mcl.Width && y >= 0 && y < mcl.Height ) { - Tile[] tiles = mcl.Tiles[x][y]; + StaticTile[] tiles = mcl.Tiles[x][y]; for( int i = 0; i < tiles.Length; ++i ) { - Tile tile = tiles[i]; + StaticTile tile = tiles[i]; if( tile.Z == 7 && tile.Height == 20 ) return true; @@ -1061,11 +1061,11 @@ namespace Server.Multis public static bool ValidPiece( int itemID, bool roof ) { - itemID &= 0x3FFF; + itemID &= TileData.MaxItemValue; - if ( !roof && ( TileData.ItemTable[itemID & 0x3FFF].Flags & TileFlag.Roof ) != 0 ) + if ( !roof && ( TileData.ItemTable[itemID].Flags & TileFlag.Roof ) != 0 ) return false; - else if ( roof && ( TileData.ItemTable[itemID & 0x3FFF].Flags & TileFlag.Roof ) == 0 ) + else if ( roof && ( TileData.ItemTable[itemID].Flags & TileFlag.Roof ) == 0 ) return false; return Verification.IsItemValid( itemID ); @@ -1141,11 +1141,11 @@ namespace Server.Multis if( IsStairBlock( id ) ) { - Tile[] tiles = mcl.Tiles[ax][ay]; + StaticTile[] tiles = mcl.Tiles[ax][ay]; for( int i = 0; i < tiles.Length; ++i ) { - Tile tile = tiles[i]; + StaticTile tile = tiles[i]; if( tile.Z == (z + 5) ) { @@ -1220,12 +1220,12 @@ namespace Server.Multis if( ax >= 1 && ax < mcl.Width && ay >= 1 && ay < mcl.Height - 1 ) { - Tile[] tiles = mcl.Tiles[ax][ay]; + StaticTile[] tiles = mcl.Tiles[ax][ay]; bool hasBaseFloor = false; for( int j = 0; !hasBaseFloor && j < tiles.Length; ++j ) - hasBaseFloor = (tiles[j].Z == 7 && (tiles[j].ID & 0x3FFF) != 1); + hasBaseFloor = (tiles[j].Z == 7 && tiles[j].ID != 1); if( !hasBaseFloor ) mcl.Add( 0x31F4, x, y, 7 ); @@ -1284,12 +1284,12 @@ namespace Server.Multis // If needed, replace removed component with a dirt tile if( ax >= 1 && ax < mcl.Width && ay >= 1 && ay < mcl.Height - 1 ) { - Tile[] tiles = mcl.Tiles[ax][ay]; + StaticTile[] tiles = mcl.Tiles[ax][ay]; bool hasBaseFloor = false; for( int i = 0; !hasBaseFloor && i < tiles.Length; ++i ) - hasBaseFloor = (tiles[i].Z == 7 && (tiles[i].ID & 0x3FFF) != 1); + hasBaseFloor = (tiles[i].Z == 7 && tiles[i].ID != 1); if( !hasBaseFloor ) { @@ -1641,7 +1641,7 @@ namespace Server.Multis { MultiTileEntry mte = list[i]; - if( mte.m_OffsetX == x && mte.m_OffsetY == y && GetZLevel( mte.m_OffsetZ, context.Foundation ) == context.Level && (TileData.ItemTable[mte.m_ItemID & 0x3FFF].Flags & TileFlag.Roof) != 0 ) + if( mte.m_OffsetX == x && mte.m_OffsetY == y && GetZLevel( mte.m_OffsetZ, context.Foundation ) == context.Level && (TileData.ItemTable[mte.m_ItemID & TileData.MaxItemValue].Flags & TileFlag.Roof) != 0 ) mcl.Remove( mte.m_ItemID, x, y, mte.m_OffsetZ ); } @@ -1669,7 +1669,7 @@ namespace Server.Multis DesignState design = context.Foundation.DesignState; MultiComponentList mcl = design.Components; - if( (TileData.ItemTable[itemID & 0x3FFF].Flags & TileFlag.Roof) == 0 ) + if( (TileData.ItemTable[itemID & TileData.MaxItemValue].Flags & TileFlag.Roof) == 0 ) { design.SendDetailedInfoTo( state ); return; @@ -1748,7 +1748,7 @@ namespace Server.Multis for( int i = 0; i < length; ++i ) { - m_Fixtures[i].m_ItemID = reader.ReadShort(); + m_Fixtures[i].m_ItemID = reader.ReadUShort(); m_Fixtures[i].m_OffsetX = reader.ReadShort(); m_Fixtures[i].m_OffsetY = reader.ReadShort(); m_Fixtures[i].m_OffsetZ = reader.ReadShort(); @@ -1774,7 +1774,7 @@ namespace Server.Multis { MultiTileEntry ent = m_Fixtures[i]; - writer.Write( (short)ent.m_ItemID ); + writer.Write( (ushort)ent.m_ItemID ); writer.Write( (short)ent.m_OffsetX ); writer.Write( (short)ent.m_OffsetY ); writer.Write( (short)ent.m_OffsetZ ); @@ -2229,7 +2229,7 @@ namespace Server.Multis int x = mte.m_OffsetX - xMin; int y = mte.m_OffsetY - yMin; int z = mte.m_OffsetZ; - bool floor = (TileData.ItemTable[mte.m_ItemID & 0x3FFF].Height <= 0); + bool floor = (TileData.ItemTable[mte.m_ItemID & TileData.MaxItemValue].Height <= 0); int plane, size; switch( z ) diff --git a/Scripts/Multis/HousePlacement.cs b/Scripts/Multis/HousePlacement.cs index 1140f965b..0b62c9ce3 100644 --- a/Scripts/Multis/HousePlacement.cs +++ b/Scripts/Multis/HousePlacement.cs @@ -97,7 +97,7 @@ namespace Server.Multis int tileX = start.X + x; int tileY = start.Y + y; - Tile[] addTiles = mcl.Tiles[x][y]; + StaticTile[] addTiles = mcl.Tiles[x][y]; if ( addTiles.Length == 0 ) continue; // There are no tiles here, continue checking somewhere else @@ -117,10 +117,10 @@ namespace Server.Multis return HousePlacementResult.BadRegion; } - Tile landTile = map.Tiles.GetLandTile( tileX, tileY ); - int landID = landTile.ID & 0x3FFF; + LandTile landTile = map.Tiles.GetLandTile( tileX, tileY ); + int landID = landTile.ID & TileData.MaxLandValue; - Tile[] oldTiles = map.Tiles.GetStaticTiles( tileX, tileY, true ); + StaticTile[] oldTiles = map.Tiles.GetStaticTiles( tileX, tileY, true ); Sector sector = map.GetSector( tileX, tileY ); @@ -152,12 +152,12 @@ namespace Server.Multis for ( int i = 0; i < addTiles.Length; ++i ) { - Tile addTile = addTiles[i]; + StaticTile addTile = addTiles[i]; - if ( addTile.ID == 0x4001 ) // Nodraw + if ( addTile.ID == 0x1 ) // Nodraw continue; - TileFlag addTileFlags = TileData.ItemTable[addTile.ID & 0x3FFF].Flags; + TileFlag addTileFlags = TileData.ItemTable[addTile.ID & TileData.MaxItemValue].Flags; bool isFoundation = ( addTile.Z == 0 && (addTileFlags & TileFlag.Wall) != 0 ); bool hasSurface = false; @@ -174,13 +174,13 @@ namespace Server.Multis if ( addTileTop > landStartZ && landAvgZ > addTileZ ) return HousePlacementResult.BadLand; // Broke rule #2 - if ( isFoundation && ((TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Impassable) == 0) && landAvgZ == center.Z ) + if ( isFoundation && ((TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Impassable) == 0) && landAvgZ == center.Z ) hasSurface = true; for ( int j = 0; j < oldTiles.Length; ++j ) { - Tile oldTile = oldTiles[j]; - ItemData id = TileData.ItemTable[oldTile.ID & 0x3FFF]; + StaticTile oldTile = oldTiles[j]; + ItemData id = TileData.ItemTable[oldTile.ID & TileData.MaxItemValue]; if ( (id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0)) && addTileTop > oldTile.Z && (oldTile.Z + id.CalcHeight) > addTileZ ) return HousePlacementResult.BadStatic; // Broke rule #2 @@ -251,14 +251,14 @@ namespace Server.Multis if ( vx >= 0 && vx < mcl.Width && vy >= 0 && vy < mcl.Height ) { - Tile[] breakTiles = mcl.Tiles[vx][vy]; + StaticTile[] breakTiles = mcl.Tiles[vx][vy]; bool shouldBreak = false; for ( int i = 0; !shouldBreak && i < breakTiles.Length; ++i ) { - Tile breakTile = breakTiles[i]; + StaticTile breakTile = breakTiles[i]; - if ( breakTile.Height == 0 && breakTile.Z <= 8 && TileData.ItemTable[breakTile.ID & 0x3FFF].Surface ) + if ( breakTile.Height == 0 && breakTile.Z <= 8 && TileData.ItemTable[breakTile.ID & TileData.MaxItemValue].Surface ) shouldBreak = true; } @@ -280,8 +280,8 @@ namespace Server.Multis { Point2D borderPoint = borders[i]; - Tile landTile = map.Tiles.GetLandTile( borderPoint.X, borderPoint.Y ); - int landID = landTile.ID & 0x3FFF; + LandTile landTile = map.Tiles.GetLandTile( borderPoint.X, borderPoint.Y ); + int landID = landTile.ID & TileData.MaxLandValue; if ( (TileData.LandTable[landID].Flags & TileFlag.Impassable) != 0 ) return HousePlacementResult.BadLand; @@ -292,12 +292,12 @@ namespace Server.Multis return HousePlacementResult.BadLand; // Broke rule #5 } - Tile[] tiles = map.Tiles.GetStaticTiles( borderPoint.X, borderPoint.Y, true ); + StaticTile[] tiles = map.Tiles.GetStaticTiles( borderPoint.X, borderPoint.Y, true ); for ( int j = 0; j < tiles.Length; ++j ) { - Tile tile = tiles[j]; - ItemData id = TileData.ItemTable[tile.ID & 0x3FFF]; + StaticTile tile = tiles[j]; + ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; if ( id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0 && (tile.Z + id.CalcHeight) > (center.Z + 2)) ) return HousePlacementResult.BadStatic; // Broke rule #1 @@ -353,11 +353,11 @@ namespace Server.Multis IPooledEnumerable eable = map.GetMultiTilesAt( yardPoint.X, yardPoint.Y ); - foreach ( Tile[] tile in eable ) + foreach ( StaticTile[] tile in eable ) { for ( int j = 0; j < tile.Length; ++j ) { - if ( (TileData.ItemTable[tile[j].ID & 0x3FFF].Flags & (TileFlag.Impassable | TileFlag.Surface)) != 0 ) + if ( (TileData.ItemTable[tile[j].ID & TileData.MaxItemValue].Flags & (TileFlag.Impassable | TileFlag.Surface)) != 0 ) { eable.Free(); return HousePlacementResult.BadStatic; // Broke rule #3 diff --git a/Scripts/Multis/Houses.cs b/Scripts/Multis/Houses.cs index 9968e8f14..68fbac883 100644 --- a/Scripts/Multis/Houses.cs +++ b/Scripts/Multis/Houses.cs @@ -32,7 +32,7 @@ namespace Server.Multis public override HouseDeed GetDeed() { - switch ( ItemID ^ 0x4000 ) + switch ( ItemID ) { case 0x64: return new StonePlasterHouseDeed(); case 0x66: return new FieldStoneHouseDeed(); @@ -128,7 +128,7 @@ namespace Server.Multis public override HouseDeed GetDeed() { - switch( ItemID ^ 0x4000 ) + switch( ItemID ) { case 0x76: return new TwoStoryWoodPlasterHouseDeed(); case 0x78: @@ -554,7 +554,7 @@ namespace Server.Multis public override HouseDeed GetDeed() { - switch ( ItemID ^ 0x4000 ) + switch ( ItemID ) { case 0xA0: return new StoneWorkshopDeed(); case 0xA2: diff --git a/Scripts/Multis/PreviewHouse.cs b/Scripts/Multis/PreviewHouse.cs index d4956b656..528779361 100644 --- a/Scripts/Multis/PreviewHouse.cs +++ b/Scripts/Multis/PreviewHouse.cs @@ -11,7 +11,7 @@ namespace Server.Multis private List m_Components; private Timer m_Timer; - public PreviewHouse( int multiID ) : base( multiID | 0x4000 ) + public PreviewHouse( int multiID ) : base( multiID ) { m_Components = new List(); @@ -123,7 +123,7 @@ namespace Server.Multis } } - Delete(); + Timer.DelayCall( TimeSpan.Zero, new TimerCallback( this.Delete ) ); } private class DecayTimer : Timer diff --git a/Scripts/Regions/BaseRegion.cs b/Scripts/Regions/BaseRegion.cs index 6d4935bad..9545a659d 100644 --- a/Scripts/Regions/BaseRegion.cs +++ b/Scripts/Regions/BaseRegion.cs @@ -269,12 +269,12 @@ namespace Server.Regions if ( x < 0 || y < 0 || x >= map.Width || y >= map.Height ) continue; - Tile lt = map.Tiles.GetLandTile( x, y ); + LandTile lt = map.Tiles.GetLandTile( x, y ); int ltLowZ = 0, ltAvgZ = 0, ltTopZ = 0; map.GetAverageZ( x, y, ref ltLowZ, ref ltAvgZ, ref ltTopZ ); - TileFlag ltFlags = TileData.LandTable[lt.ID & 0x3FFF].Flags; + TileFlag ltFlags = TileData.LandTable[lt.ID & TileData.MaxLandValue].Flags; bool ltImpassable = ( (ltFlags & TileFlag.Impassable) != 0 ); if ( !lt.Ignored && ltAvgZ >= minZ && ltAvgZ < maxZ ) @@ -285,12 +285,12 @@ namespace Server.Regions else if ( land && !ltImpassable ) m_SpawnBuffer1.Add( ltAvgZ ); - Tile[] staticTiles = map.Tiles.GetStaticTiles( x, y, true ); + StaticTile[] staticTiles = map.Tiles.GetStaticTiles( x, y, true ); for ( int j = 0; j < staticTiles.Length; j++ ) { - Tile tile = staticTiles[j]; - ItemData id = TileData.ItemTable[tile.ID & 0x3FFF]; + StaticTile tile = staticTiles[j]; + ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; int tileZ = tile.Z + id.CalcHeight; if ( tileZ >= minZ && tileZ < maxZ ) @@ -309,7 +309,7 @@ namespace Server.Regions { Item item = sector.Items[j]; - if ( item.ItemID < 0x4000 && item.AtWorldPoint( x, y ) ) + if ( item.ItemID <= TileData.MaxItemValue && item.AtWorldPoint( x, y ) ) { m_SpawnBuffer2.Add( item ); @@ -411,8 +411,8 @@ namespace Server.Regions for ( int j = 0; j < staticTiles.Length; j++ ) { - Tile tile = staticTiles[j]; - ItemData id = TileData.ItemTable[tile.ID & 0x3FFF]; + StaticTile tile = staticTiles[j]; + ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; if ( ( id.Surface || id.Impassable ) && tile.Z + id.CalcHeight > z && tile.Z < top ) { diff --git a/Scripts/Regions/Spawning/SpawnDefinition.cs b/Scripts/Regions/Spawning/SpawnDefinition.cs index 3f6573f51..973ee34c9 100644 --- a/Scripts/Regions/Spawning/SpawnDefinition.cs +++ b/Scripts/Regions/Spawning/SpawnDefinition.cs @@ -270,7 +270,7 @@ namespace Server.Regions protected override void Init() { - m_Height = TileData.ItemTable[m_ItemID & 0x3FFF].Height; + m_Height = TileData.ItemTable[m_ItemID & TileData.MaxItemValue].Height; } protected override Item CreateItem() diff --git a/Scripts/Spells/Base/SpellHelper.cs b/Scripts/Spells/Base/SpellHelper.cs index 200cf97be..aa2174775 100644 --- a/Scripts/Spells/Base/SpellHelper.cs +++ b/Scripts/Spells/Base/SpellHelper.cs @@ -195,7 +195,7 @@ namespace Server.Spells int z = t.Z; if( (t.Flags & TileFlag.Surface) == 0 ) - z -= TileData.ItemTable[t.ItemID & 0x3FFF].CalcHeight; + z -= TileData.ItemTable[t.ItemID & TileData.MaxItemValue].CalcHeight; p = new Point3D( t.X, t.Y, z ); } diff --git a/Scripts/Spells/Spellweaving/ArcaneCircle.cs b/Scripts/Spells/Spellweaving/ArcaneCircle.cs index c0695234c..9b61e1934 100644 --- a/Scripts/Spells/Spellweaving/ArcaneCircle.cs +++ b/Scripts/Spells/Spellweaving/ArcaneCircle.cs @@ -66,19 +66,18 @@ namespace Server.Spells.Spellweaving private static bool IsValidLocation( Point3D location, Map map ) { - Tile lt = map.Tiles.GetLandTile( location.X, location.Y ); // Land Tiles + LandTile lt = map.Tiles.GetLandTile( location.X, location.Y ); // Land Tiles if( IsValidTile( lt.ID ) && lt.Z == location.Z ) return true; - Tile[] tiles = map.Tiles.GetStaticTiles( location.X, location.Y ); // Static Tiles + StaticTile[] tiles = map.Tiles.GetStaticTiles( location.X, location.Y ); // Static Tiles for( int i = 0; i < tiles.Length; ++i ) { - Tile t = tiles[i]; - ItemData id = TileData.ItemTable[t.ID & 0x3FFF]; + StaticTile t = tiles[i]; - int tand = t.ID & 0x3FFF; + int tand = t.ID; if( t.Z != location.Z ) continue; diff --git a/Server/Item.cs b/Server/Item.cs index 39c3d4112..7633a36dc 100644 --- a/Server/Item.cs +++ b/Server/Item.cs @@ -603,6 +603,7 @@ namespace Server #region Packet caches private Packet m_WorldPacket; private Packet m_WorldPacketSA; + private Packet m_WorldPacketHS; private Packet m_RemovePacket; private Packet m_OPLPacket; @@ -1747,10 +1748,33 @@ namespace Server } } + public Packet WorldPacketHS + { + get + { + // This needs to be invalidated when any of the following changes: + // - ItemID + // - Amount + // - Location + // - Hue + // - Packet Flags + // - Direction + + if ( m_WorldPacketHS == null ) + { + m_WorldPacketHS = new WorldItemHS( this ); + m_WorldPacketHS.SetStatic(); + } + + return m_WorldPacketHS; + } + } + public void ReleaseWorldPackets() { Packet.Release( ref m_WorldPacket ); Packet.Release( ref m_WorldPacketSA ); + Packet.Release( ref m_WorldPacketHS ); } [CommandProperty( AccessLevel.GameMaster )] @@ -2675,7 +2699,12 @@ namespace Server } protected virtual Packet GetWorldPacketFor( NetState state ) { - return this.WorldPacket; + if ( state.HighSeas ) + return this.WorldPacketHS; + else if ( state.StygianAbyss ) + return this.WorldPacketSA; + else + return this.WorldPacket; } public virtual bool IsVirtualItem{ get{ return false; } } @@ -2706,7 +2735,10 @@ namespace Server { get { - return 1020000 + (m_ItemID & 0x3FFF); + if ( m_ItemID < 0x4000 ) + return 1020000 + m_ItemID; + else + return 1078872 + m_ItemID; } } @@ -2732,7 +2764,7 @@ namespace Server { get { - if ( m_ItemID < 0 || m_ItemID >= 0x4000 ) + if ( m_ItemID < 0 || m_ItemID > TileData.MaxItemValue || this is BaseMulti ) return 0; int weight = TileData.ItemTable[m_ItemID].Weight; @@ -2791,7 +2823,7 @@ namespace Server { get { - return ( m_ItemID & 0x3FFF ); + return m_ItemID; } } @@ -3859,8 +3891,8 @@ namespace Server int maxZ = from.Z + 16; - Tile landTile = map.Tiles.GetLandTile( x, y ); - TileFlag landFlags = TileData.LandTable[landTile.ID & 0x3FFF].Flags; + LandTile landTile = map.Tiles.GetLandTile( x, y ); + TileFlag landFlags = TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags; int landZ = 0, landAvg = 0, landTop = 0; map.GetAverageZ( x, y, ref landZ, ref landAvg, ref landTop ); @@ -3871,12 +3903,12 @@ namespace Server z = landAvg; } - Tile[] tiles = map.Tiles.GetStaticTiles( x, y, true ); + StaticTile[] tiles = map.Tiles.GetStaticTiles( x, y, true ); for ( int i = 0; i < tiles.Length; ++i ) { - Tile tile = tiles[i]; - ItemData id = TileData.ItemTable[tile.ID & 0x3FFF]; + StaticTile tile = tiles[i]; + ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; if ( !id.Surface ) continue; @@ -3895,7 +3927,7 @@ namespace Server foreach ( Item item in eable ) { - if ( item.ItemID >= 0x4000 ) + if ( item is BaseMulti ) continue; items.Add( item ); @@ -3927,8 +3959,8 @@ namespace Server for ( int i = 0; i < tiles.Length; ++i ) { - Tile tile = tiles[i]; - ItemData id = TileData.ItemTable[tile.ID & 0x3FFF]; + StaticTile tile = tiles[i]; + ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; int checkZ = tile.Z; int checkTop = checkZ + id.CalcHeight; @@ -4021,8 +4053,8 @@ namespace Server for ( int i = 0; i < tiles.Length; ++i ) { - Tile tile = tiles[i]; - ItemData id = TileData.ItemTable[tile.ID & 0x3FFF]; + StaticTile tile = tiles[i]; + ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; int checkZ = tile.Z; int checkTop = checkZ + id.CalcHeight; @@ -4323,7 +4355,7 @@ namespace Server { get { - return TileData.ItemTable[m_ItemID & 0x3FFF]; + return TileData.ItemTable[m_ItemID & TileData.MaxItemValue]; } } diff --git a/Server/Items/BaseMulti.cs b/Server/Items/BaseMulti.cs index 809e25795..650796f77 100644 --- a/Server/Items/BaseMulti.cs +++ b/Server/Items/BaseMulti.cs @@ -75,8 +75,14 @@ namespace Server.Items { MultiComponentList mcl = this.Components; - if ( mcl.List.Length > 0 ) - return 1020000 + (mcl.List[0].m_ItemID & 0x3FFF); + if ( mcl.List.Length > 0 ) { + int id = mcl.List[0].m_ItemID; + + if ( id < 0x4000 ) + return 1020000 + id; + else + return 1078872 + id; + } return base.LabelNumber; } @@ -149,7 +155,7 @@ namespace Server.Items { base.Serialize( writer ); - writer.Write( (int) 0 ); // version + writer.Write( (int) 1 ); // version } public override void Deserialize( GenericReader reader ) @@ -157,6 +163,12 @@ namespace Server.Items base.Deserialize( reader ); int version = reader.ReadInt(); + + if ( version == 0 ) { + if ( ItemID >= 0x4000 ) { + ItemID -= 0x4000; + } + } } } } \ No newline at end of file diff --git a/Server/Map.cs b/Server/Map.cs index a8938daa6..a1451ff5b 100644 --- a/Server/Map.cs +++ b/Server/Map.cs @@ -360,24 +360,24 @@ namespace Server bool hasSurface = false; - Tile lt = Tiles.GetLandTile( x, y ); + LandTile lt = Tiles.GetLandTile( x, y ); int lowZ = 0, avgZ = 0, topZ = 0; GetAverageZ( x, y, ref lowZ, ref avgZ, ref topZ ); - TileFlag landFlags = TileData.LandTable[lt.ID & 0x3FFF].Flags; + TileFlag landFlags = TileData.LandTable[lt.ID & TileData.MaxLandValue].Flags; if ( ( landFlags & TileFlag.Impassable ) != 0 && avgZ > z && ( z + height ) > lowZ ) return false; else if ( ( landFlags & TileFlag.Impassable ) == 0 && z == avgZ && !lt.Ignored ) hasSurface = true; - Tile[] staticTiles = Tiles.GetStaticTiles( x, y, true ); + StaticTile[] staticTiles = Tiles.GetStaticTiles( x, y, true ); bool surface, impassable; for ( int i = 0; i < staticTiles.Length; ++i ) { - ItemData id = TileData.ItemTable[staticTiles[i].ID & 0x3FFF]; + ItemData id = TileData.ItemTable[staticTiles[i].ID & TileData.MaxItemValue]; surface = id.Surface; impassable = id.Impassable; @@ -395,7 +395,7 @@ namespace Server { Item item = items[i]; - if ( item.ItemID < 0x4000 && item.AtWorldPoint( x, y ) ) + if ( !(item is BaseMulti) && item.AtWorldPoint( x, y ) ) { ItemData id = item.ItemData; surface = id.Surface; @@ -457,12 +457,12 @@ namespace Server public void FixColumn( int x, int y ) { - Tile landTile = Tiles.GetLandTile( x, y ); + LandTile landTile = Tiles.GetLandTile( x, y ); int landZ = 0, landAvg = 0, landTop = 0; GetAverageZ( x, y, ref landZ, ref landAvg, ref landTop ); - Tile[] tiles = Tiles.GetStaticTiles( x, y, true ); + StaticTile[] tiles = Tiles.GetStaticTiles( x, y, true ); List items = new List(); @@ -470,7 +470,7 @@ namespace Server foreach ( Item item in eable ) { - if ( item.ItemID < 0x4000 ) + if ( !(item is BaseMulti) ) { items.Add( item ); @@ -501,8 +501,8 @@ namespace Server for ( int j = 0; j < tiles.Length; ++j ) { - Tile tile = tiles[j]; - ItemData id = TileData.ItemTable[tile.ID & 0x3FFF]; + StaticTile tile = tiles[j]; + ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; int checkZ = tile.Z; int checkTop = checkZ + id.CalcHeight; @@ -537,6 +537,7 @@ namespace Server } } + /* This could be probably be re-implemented if necessary (perhaps via an ITile interface?). public List GetTilesAt( Point2D p, bool items, bool land, bool statics ) { List list = new List(); @@ -556,11 +557,12 @@ namespace Server foreach ( Item item in sector.Items ) if ( item.AtWorldPoint( p.m_X, p.m_Y ) ) - list.Add( new Tile( (short) ( ( item.ItemID & 0x3FFF ) + 0x4000 ), (sbyte) item.Z ) ); + list.Add( new StaticTile( (ushort)item.ItemID, (sbyte) item.Z ) ); } return list; } + */ /// /// Gets the highest surface that is lower than . @@ -576,7 +578,7 @@ namespace Server int surfaceZ = int.MinValue; - Tile lt = Tiles.GetLandTile( p.X, p.Y ); + LandTile lt = Tiles.GetLandTile( p.X, p.Y ); if ( !lt.Ignored ) { @@ -593,12 +595,12 @@ namespace Server } - Tile[] staticTiles = Tiles.GetStaticTiles( p.X, p.Y, true ); + StaticTile[] staticTiles = Tiles.GetStaticTiles( p.X, p.Y, true ); for ( int i = 0; i < staticTiles.Length; i++ ) { - Tile tile = staticTiles[i]; - ItemData id = TileData.ItemTable[tile.ID & 0x3FFF]; + StaticTile tile = staticTiles[i]; + ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; if ( id.Surface || ( id.Flags & TileFlag.Wet ) != 0 ) { @@ -622,7 +624,7 @@ namespace Server { Item item = sector.Items[i]; - if ( item.ItemID < 0x4000 && item.AtWorldPoint( p.X, p.Y ) && !item.Movable ) + if ( !(item is BaseMulti) && item.AtWorldPoint( p.X, p.Y ) && !item.Movable ) { ItemData id = item.ItemData; @@ -1385,12 +1387,12 @@ namespace Server if ( xOffset >= 0 && xOffset < list.Width && yOffset >= 0 && yOffset < list.Height ) { - Tile[] tiles = list.Tiles[xOffset][yOffset]; + StaticTile[] tiles = list.Tiles[xOffset][yOffset]; if ( tiles.Length > 0 ) { // TODO: How to avoid this copy? - Tile[] copy = new Tile[tiles.Length]; + StaticTile[] copy = new StaticTile[tiles.Length]; for ( int i = 0; i < copy.Length; ++i ) { @@ -1779,7 +1781,7 @@ namespace Server else if( o is StaticTarget ) { StaticTarget st = (StaticTarget)o; - ItemData id = TileData.ItemTable[st.ItemID & 0x3FFF]; + ItemData id = TileData.ItemTable[st.ItemID & TileData.MaxItemValue]; p = new Point3D( st.X, st.Y, st.Z - id.CalcHeight + (id.Height / 2) + 1 ); } @@ -1894,7 +1896,7 @@ namespace Server { Point3D point = path[i]; - Tile landTile = Tiles.GetLandTile( point.X, point.Y ); + LandTile landTile = Tiles.GetLandTile( point.X, point.Y ); int landZ = 0, landAvg = 0, landTop = 0; GetAverageZ( point.m_X, point.m_Y, ref landZ, ref landAvg, ref landTop ); @@ -1902,12 +1904,12 @@ namespace Server return false; /* --Do land tiles need to be checked? There is never land between two people, always statics.-- - Tile landTile = Tiles.GetLandTile( point.X, point.Y ); - if ( landTile.Z-1 >= point.Z && landTile.Z+1 <= point.Z && (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Impassable) != 0 ) + LandTile landTile = Tiles.GetLandTile( point.X, point.Y ); + if ( landTile.Z-1 >= point.Z && landTile.Z+1 <= point.Z && (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Impassable) != 0 ) return false; */ - Tile[] statics = Tiles.GetStaticTiles( point.m_X, point.m_Y, true ); + StaticTile[] statics = Tiles.GetStaticTiles( point.m_X, point.m_Y, true ); bool contains = false; int ltID = landTile.ID; @@ -1936,9 +1938,9 @@ namespace Server for( int j = 0; j < statics.Length; ++j ) { - Tile t = statics[j]; + StaticTile t = statics[j]; - ItemData id = TileData.ItemTable[t.ID & 0x3FFF]; + ItemData id = TileData.ItemTable[t.ID & TileData.MaxItemValue]; flags = id.Flags; height = id.CalcHeight; @@ -1954,7 +1956,7 @@ namespace Server /*if ( t.Z <= point.Z && t.Z+height >= point.Z && (flags&TileFlag.Window)==0 && (flags&TileFlag.NoShoot)!=0 && ( (flags&TileFlag.Wall)!=0 || (flags&TileFlag.Roof)!=0 || (((flags&TileFlag.Surface)!=0 && zd != 0)) ) )*/ /*{ - //Console.WriteLine( "LoS: Blocked by Static \"{0}\" Z:{1} T:{3} P:{2} F:x{4:X}", TileData.ItemTable[t.ID&0x3FFF].Name, t.Z, point, t.Z+height, flags ); + //Console.WriteLine( "LoS: Blocked by Static \"{0}\" Z:{1} T:{3} P:{2} F:x{4:X}", TileData.ItemTable[t.ID&TileData.MaxItemValue].Name, t.Z, point, t.Z+height, flags ); //Console.WriteLine( "if ( {0} && {1} && {2} && ( {3} || {4} || {5} || ({6} && {7} && {8}) ) )", t.Z <= point.Z, t.Z+height >= point.Z, (flags&TileFlag.Window)==0, (flags&TileFlag.Impassable)!=0, (flags&TileFlag.Wall)!=0, (flags&TileFlag.Roof)!=0, (flags&TileFlag.Surface)!=0, t.Z != dest.Z, zd != 0 ) ; return false; }*/ @@ -1970,7 +1972,7 @@ namespace Server if( !i.Visible ) continue; - if( i.ItemID >= 0x4000 ) + if( i is BaseMulti || i.ItemID > TileData.MaxItemValue ) continue; ItemData id = i.ItemData; @@ -2010,11 +2012,11 @@ namespace Server /*if ( (flags & (TileFlag.Impassable | TileFlag.Surface | TileFlag.Roof)) != 0 ) - //flags = TileData.ItemTable[i.ItemID&0x3FFF].Flags; + //flags = TileData.ItemTable[i.ItemID&TileData.MaxItemValue].Flags; //if ( (flags&TileFlag.Window)==0 && (flags&TileFlag.NoShoot)!=0 && ( (flags&TileFlag.Wall)!=0 || (flags&TileFlag.Roof)!=0 || (((flags&TileFlag.Surface)!=0 && zd != 0)) ) ) { - //height = TileData.ItemTable[i.ItemID&0x3FFF].Height; - //Console.WriteLine( "LoS: Blocked by ITEM \"{0}\" P:{1} T:{2} F:x{3:X}", TileData.ItemTable[i.ItemID&0x3FFF].Name, i.Location, i.Location.Z+height, flags ); + //height = TileData.ItemTable[i.ItemID&TileData.MaxItemValue].Height; + //Console.WriteLine( "LoS: Blocked by ITEM \"{0}\" P:{1} T:{2} F:x{3:X}", TileData.ItemTable[i.ItemID&TileData.MaxItemValue].Name, i.Location, i.Location.Z+height, flags ); area.Free(); return false; }*/ diff --git a/Server/MultiData.cs b/Server/MultiData.cs index 901ffe379..909d29383 100644 --- a/Server/MultiData.cs +++ b/Server/MultiData.cs @@ -35,8 +35,6 @@ namespace Server { MultiComponentList mcl; - multiID &= 0x3FFF; - if ( multiID >= 0 && multiID < m_Components.Length ) { mcl = m_Components[multiID]; @@ -132,11 +130,11 @@ namespace Server public struct MultiTileEntry { - public short m_ItemID; + public ushort m_ItemID; public short m_OffsetX, m_OffsetY, m_OffsetZ; public int m_Flags; - public MultiTileEntry( short itemID, short xOffset, short yOffset, short zOffset, int flags ) + public MultiTileEntry( ushort itemID, short xOffset, short yOffset, short zOffset, int flags ) { m_ItemID = itemID; m_OffsetX = xOffset; @@ -157,7 +155,7 @@ namespace Server private Point2D m_Min, m_Max, m_Center; private int m_Width, m_Height; - private Tile[][][] m_Tiles; + private StaticTile[][][] m_Tiles; private MultiTileEntry[] m_List; public static readonly MultiComponentList Empty = new MultiComponentList(); @@ -170,29 +168,26 @@ namespace Server public int Width{ get{ return m_Width; } } public int Height{ get{ return m_Height; } } - public Tile[][][] Tiles{ get{ return m_Tiles; } } + public StaticTile[][][] Tiles{ get{ return m_Tiles; } } public MultiTileEntry[] List{ get{ return m_List; } } public void Add( int itemID, int x, int y, int z ) { - itemID &= 0x3FFF; - itemID |= 0x4000; - int vx = x + m_Center.m_X; int vy = y + m_Center.m_Y; if ( vx >= 0 && vx < m_Width && vy >= 0 && vy < m_Height ) { - Tile[] oldTiles = m_Tiles[vx][vy]; + StaticTile[] oldTiles = m_Tiles[vx][vy]; for ( int i = oldTiles.Length - 1; i >= 0; --i ) { - ItemData data = TileData.ItemTable[itemID & 0x3FFF]; + ItemData data = TileData.ItemTable[itemID & TileData.MaxItemValue]; if ( oldTiles[i].Z == z && (oldTiles[i].Height > 0 == data.Height > 0 ) ) { bool newIsRoof = ( data.Flags & TileFlag.Roof) != 0; - bool oldIsRoof = (TileData.ItemTable[oldTiles[i].ID & 0x3FFF].Flags & TileFlag.Roof ) != 0; + bool oldIsRoof = (TileData.ItemTable[oldTiles[i].ID & TileData.MaxItemValue].Flags & TileFlag.Roof ) != 0; if ( newIsRoof == oldIsRoof ) Remove( oldTiles[i].ID, x, y, z ); @@ -201,12 +196,12 @@ namespace Server oldTiles = m_Tiles[vx][vy]; - Tile[] newTiles = new Tile[oldTiles.Length + 1]; + StaticTile[] newTiles = new StaticTile[oldTiles.Length + 1]; for ( int i = 0; i < oldTiles.Length; ++i ) newTiles[i] = oldTiles[i]; - newTiles[oldTiles.Length] = new Tile( (short)itemID, (sbyte)z ); + newTiles[oldTiles.Length] = new StaticTile( (ushort)itemID, (sbyte)z ); m_Tiles[vx][vy] = newTiles; @@ -216,7 +211,7 @@ namespace Server for ( int i = 0; i < oldList.Length; ++i ) newList[i] = oldList[i]; - newList[oldList.Length] = new MultiTileEntry( (short)itemID, (short)x, (short)y, (short)z, 1 ); + newList[oldList.Length] = new MultiTileEntry( (ushort)itemID, (short)x, (short)y, (short)z, 1 ); m_List = newList; @@ -241,15 +236,15 @@ namespace Server if ( vx >= 0 && vx < m_Width && vy >= 0 && vy < m_Height ) { - Tile[] oldTiles = m_Tiles[vx][vy]; + StaticTile[] oldTiles = m_Tiles[vx][vy]; for ( int i = 0; i < oldTiles.Length; ++i ) { - Tile tile = oldTiles[i]; + StaticTile tile = oldTiles[i]; if ( tile.Z == z && tile.Height >= minHeight ) { - Tile[] newTiles = new Tile[oldTiles.Length - 1]; + StaticTile[] newTiles = new StaticTile[oldTiles.Length - 1]; for ( int j = 0; j < i; ++j ) newTiles[j] = oldTiles[j]; @@ -269,7 +264,7 @@ namespace Server { MultiTileEntry tile = oldList[i]; - if ( tile.m_OffsetX == (short)x && tile.m_OffsetY == (short)y && tile.m_OffsetZ == (short)z && TileData.ItemTable[tile.m_ItemID & 0x3FFF].Height >= minHeight ) + if ( tile.m_OffsetX == (short)x && tile.m_OffsetY == (short)y && tile.m_OffsetZ == (short)z && TileData.ItemTable[tile.m_ItemID & TileData.MaxItemValue].Height >= minHeight ) { MultiTileEntry[] newList = new MultiTileEntry[oldList.Length - 1]; @@ -294,15 +289,15 @@ namespace Server if ( vx >= 0 && vx < m_Width && vy >= 0 && vy < m_Height ) { - Tile[] oldTiles = m_Tiles[vx][vy]; + StaticTile[] oldTiles = m_Tiles[vx][vy]; for ( int i = 0; i < oldTiles.Length; ++i ) { - Tile tile = oldTiles[i]; + StaticTile tile = oldTiles[i]; - if ( (tile.ID & 0x3FFF) == (itemID & 0x3FFF) && tile.Z == z ) + if ( tile.ID == itemID && tile.Z == z ) { - Tile[] newTiles = new Tile[oldTiles.Length - 1]; + StaticTile[] newTiles = new StaticTile[oldTiles.Length - 1]; for ( int j = 0; j < i; ++j ) newTiles[j] = oldTiles[j]; @@ -322,7 +317,7 @@ namespace Server { MultiTileEntry tile = oldList[i]; - if ( (tile.m_ItemID & 0x3FFF) == (short)(itemID & 0x3FFF) && tile.m_OffsetX == (short)x && tile.m_OffsetY == (short)y && tile.m_OffsetZ == (short)z ) + if ( tile.m_ItemID == itemID && tile.m_OffsetX == (short)x && tile.m_OffsetY == (short)y && tile.m_OffsetZ == (short)z ) { MultiTileEntry[] newList = new MultiTileEntry[oldList.Length - 1]; @@ -343,22 +338,22 @@ namespace Server public void Resize( int newWidth, int newHeight ) { int oldWidth = m_Width, oldHeight = m_Height; - Tile[][][] oldTiles = m_Tiles; + StaticTile[][][] oldTiles = m_Tiles; int totalLength = 0; - Tile[][][] newTiles = new Tile[newWidth][][]; + StaticTile[][][] newTiles = new StaticTile[newWidth][][]; for ( int x = 0; x < newWidth; ++x ) { - newTiles[x] = new Tile[newHeight][]; + newTiles[x] = new StaticTile[newHeight][]; for ( int y = 0; y < newHeight; ++y ) { if ( x < oldWidth && y < oldHeight ) newTiles[x][y] = oldTiles[x][y]; else - newTiles[x][y] = new Tile[0]; + newTiles[x][y] = new StaticTile[0]; totalLength += newTiles[x][y].Length; } @@ -378,11 +373,11 @@ namespace Server { for ( int y = 0; y < newHeight; ++y ) { - Tile[] tiles = newTiles[x][y]; + StaticTile[] tiles = newTiles[x][y]; for ( int i = 0; i < tiles.Length; ++i ) { - Tile tile = tiles[i]; + StaticTile tile = tiles[i]; int vx = x - m_Center.X; int vy = y - m_Center.Y; @@ -399,7 +394,7 @@ namespace Server if ( vy > m_Max.m_Y ) m_Max.m_Y = vy; - m_List[index++] = new MultiTileEntry( (short)tile.ID, (short)vx, (short)vy, (short)tile.Z, 1 ); + m_List[index++] = new MultiTileEntry( (ushort)tile.ID, (short)vx, (short)vy, (short)tile.Z, 1 ); } } } @@ -415,15 +410,15 @@ namespace Server m_Width = toCopy.m_Width; m_Height = toCopy.m_Height; - m_Tiles = new Tile[m_Width][][]; + m_Tiles = new StaticTile[m_Width][][]; for ( int x = 0; x < m_Width; ++x ) { - m_Tiles[x] = new Tile[m_Height][]; + m_Tiles[x] = new StaticTile[m_Height][]; for ( int y = 0; y < m_Height; ++y ) { - m_Tiles[x][y] = new Tile[toCopy.m_Tiles[x][y].Length]; + m_Tiles[x][y] = new StaticTile[toCopy.m_Tiles[x][y].Length]; for ( int i = 0; i < m_Tiles[x][y].Length; ++i ) m_Tiles[x][y][i] = toCopy.m_Tiles[x][y][i]; @@ -453,7 +448,7 @@ namespace Server { MultiTileEntry ent = m_List[i]; - writer.Write( (short) ent.m_ItemID ); + writer.Write( (ushort) ent.m_ItemID ); writer.Write( (short) ent.m_OffsetX ); writer.Write( (short) ent.m_OffsetY ); writer.Write( (short) ent.m_OffsetZ ); @@ -481,7 +476,7 @@ namespace Server for ( int i = 0; i < length; ++i ) { - allTiles[i].m_ItemID = reader.ReadShort(); + allTiles[i].m_ItemID = reader.ReadUShort(); allTiles[i].m_OffsetX = reader.ReadShort(); allTiles[i].m_OffsetY = reader.ReadShort(); allTiles[i].m_OffsetZ = reader.ReadShort(); @@ -489,12 +484,12 @@ namespace Server } TileList[][] tiles = new TileList[m_Width][]; - m_Tiles = new Tile[m_Width][][]; + m_Tiles = new StaticTile[m_Width][][]; for ( int x = 0; x < m_Width; ++x ) { tiles[x] = new TileList[m_Height]; - m_Tiles[x] = new Tile[m_Height][]; + m_Tiles[x] = new StaticTile[m_Height][]; for ( int y = 0; y < m_Height; ++y ) tiles[x][y] = new TileList(); @@ -507,7 +502,7 @@ namespace Server int xOffset = allTiles[i].m_OffsetX + m_Center.m_X; int yOffset = allTiles[i].m_OffsetY + m_Center.m_Y; - tiles[xOffset][yOffset].Add( (short)((allTiles[i].m_ItemID & 0x3FFF) | 0x4000), (sbyte)allTiles[i].m_OffsetZ ); + tiles[xOffset][yOffset].Add( (ushort)allTiles[i].m_ItemID, (sbyte)allTiles[i].m_OffsetZ ); } } @@ -526,7 +521,7 @@ namespace Server for ( int i = 0; i < count; ++i ) { - allTiles[i].m_ItemID = reader.ReadInt16(); + allTiles[i].m_ItemID = reader.ReadUInt16(); allTiles[i].m_OffsetX = reader.ReadInt16(); allTiles[i].m_OffsetY = reader.ReadInt16(); allTiles[i].m_OffsetZ = reader.ReadInt16(); @@ -558,12 +553,12 @@ namespace Server m_Height = (m_Max.m_Y - m_Min.m_Y) + 1; TileList[][] tiles = new TileList[m_Width][]; - m_Tiles = new Tile[m_Width][][]; + m_Tiles = new StaticTile[m_Width][][]; for ( int x = 0; x < m_Width; ++x ) { tiles[x] = new TileList[m_Height]; - m_Tiles[x] = new Tile[m_Height][]; + m_Tiles[x] = new StaticTile[m_Height][]; for ( int y = 0; y < m_Height; ++y ) tiles[x][y] = new TileList(); @@ -576,7 +571,7 @@ namespace Server int xOffset = allTiles[i].m_OffsetX + m_Center.m_X; int yOffset = allTiles[i].m_OffsetY + m_Center.m_Y; - tiles[xOffset][yOffset].Add( (short)((allTiles[i].m_ItemID & 0x3FFF) | 0x4000), (sbyte)allTiles[i].m_OffsetZ ); + tiles[xOffset][yOffset].Add( (ushort)allTiles[i].m_ItemID, (sbyte)allTiles[i].m_OffsetZ ); } } @@ -587,7 +582,7 @@ namespace Server private MultiComponentList() { - m_Tiles = new Tile[0][][]; + m_Tiles = new StaticTile[0][][]; m_List = new MultiTileEntry[0]; } } diff --git a/Server/Network/PacketHandlers.cs b/Server/Network/PacketHandlers.cs index 7b5b48705..0db6d67b7 100644 --- a/Server/Network/PacketHandlers.cs +++ b/Server/Network/PacketHandlers.cs @@ -1056,7 +1056,7 @@ namespace Server.Network int flags = pvSrc.ReadByte(); Serial serial = pvSrc.ReadInt32(); int x = pvSrc.ReadInt16(), y = pvSrc.ReadInt16(), z = pvSrc.ReadInt16(); - int graphic = pvSrc.ReadInt16(); + int graphic = pvSrc.ReadUInt16(); if ( targetID == unchecked( (int) 0xDEADBEEF ) ) return; @@ -1100,13 +1100,17 @@ namespace Server.Network } else { - Tile[] tiles = map.Tiles.GetStaticTiles( x, y, !t.DisallowMultis ); + StaticTile[] tiles = map.Tiles.GetStaticTiles( x, y, !t.DisallowMultis ); bool valid = false; + ItemData id = TileData.ItemTable[graphic&TileData.MaxItemValue]; + if ( id.Surface ) + z -= id.Height; + for ( int i = 0; !valid && i < tiles.Length; ++i ) { - if ( tiles[i].Z == z && (tiles[i].ID & 0x3FFF) == (graphic & 0x3FFF) ) + if ( tiles[i].Z == z && tiles[i].ID == graphic ) valid = true; } diff --git a/Server/Network/Packets.cs b/Server/Network/Packets.cs index 2fc8b9bd0..6b8c1322f 100644 --- a/Server/Network/Packets.cs +++ b/Server/Network/Packets.cs @@ -265,7 +265,7 @@ namespace Server.Network BuyItemState bis = (BuyItemState)list[i]; m_Stream.Write( (int)bis.MySerial ); - m_Stream.Write( (ushort)(bis.ItemID & 0x3FFF) ); + m_Stream.Write( (ushort)bis.ItemID ); m_Stream.Write( (byte)0 );//itemid offset m_Stream.Write( (ushort)bis.Amount ); m_Stream.Write( (short)(i+1) );//x @@ -293,7 +293,7 @@ namespace Server.Network BuyItemState bis = (BuyItemState)list[i]; m_Stream.Write( (int)bis.MySerial ); - m_Stream.Write( (ushort)(bis.ItemID & 0x3FFF) ); + m_Stream.Write( (ushort)bis.ItemID ); m_Stream.Write( (byte)0 );//itemid offset m_Stream.Write( (ushort)bis.Amount ); m_Stream.Write( (short)(i+1) );//x @@ -366,7 +366,7 @@ namespace Server.Network foreach ( SellItemState state in table.Values ) { m_Stream.Write( (int) state.Item.Serial ); - m_Stream.Write( (ushort) (state.Item.ItemID & 0x3FFF) ); + m_Stream.Write( (ushort) state.Item.ItemID ); m_Stream.Write( (ushort) state.Item.Hue ); m_Stream.Write( (ushort) state.Item.Amount ); m_Stream.Write( (ushort) state.Price ); @@ -769,7 +769,7 @@ namespace Server.Network { ItemListEntry e = entries[i]; - m_Stream.Write( (short) (e.ItemID & 0x3FFF) ); + m_Stream.Write( (ushort) e.ItemID ); m_Stream.Write( (short) e.Hue ); string name = e.Name; @@ -1021,7 +1021,7 @@ namespace Server.Network // +1 - Flags uint serial = (uint)item.Serial.Value; - int itemID = item.ItemID; + int itemID = item.ItemID & 0x3FFF; int amount = item.Amount; Point3D loc = item.Location; int x = loc.m_X; @@ -1040,7 +1040,11 @@ namespace Server.Network } m_Stream.Write( (uint) serial ); - m_Stream.Write( (short) (itemID & 0x7FFF) ); + + if ( item is BaseMulti ) + m_Stream.Write( (short) (itemID | 0x4000) ); + else + m_Stream.Write( (short) itemID ); if ( amount != 0 ) { @@ -1135,12 +1139,12 @@ namespace Server.Network itemID &= 0x3FFF; } else { m_Stream.Write( (byte) 0x00 ); - itemID &= 0x7FFF; + itemID &= 0xFFFF; } m_Stream.Write( (int) item.Serial ); - m_Stream.Write( (short) itemID ); + m_Stream.Write( (ushort) itemID ); m_Stream.Write( (byte) item.Direction ); @@ -1701,13 +1705,8 @@ namespace Server.Network parentSerial = Serial.Zero; } - ushort cid = (ushort) item.ItemID; - - if ( cid > 0x3FFF ) - cid = 0x9D7; - m_Stream.Write( (int) item.Serial ); - m_Stream.Write( (short) cid ); + m_Stream.Write( (ushort) item.ItemID ); m_Stream.Write( (byte) 0 ); // signed, itemID offset m_Stream.Write( (ushort) item.Amount ); m_Stream.Write( (short) item.X ); @@ -1733,13 +1732,8 @@ namespace Server.Network parentSerial = Serial.Zero; } - ushort cid = (ushort) item.ItemID; - - if ( cid > 0x3FFF ) - cid = 0x9D7; - m_Stream.Write( (int) item.Serial ); - m_Stream.Write( (short) cid ); + m_Stream.Write( (ushort) item.ItemID ); m_Stream.Write( (byte) 0 ); // signed, itemID offset m_Stream.Write( (ushort) item.Amount ); m_Stream.Write( (short) item.X ); @@ -1773,13 +1767,8 @@ namespace Server.Network { Point3D loc = child.Location; - ushort cid = (ushort) child.ItemID; - - if ( cid > 0x3FFF ) - cid = 0x9D7; - m_Stream.Write( (int) child.Serial ); - m_Stream.Write( (ushort) cid ); + m_Stream.Write( (ushort) child.ItemID ); m_Stream.Write( (byte) 0 ); // signed, itemID offset m_Stream.Write( (ushort) child.Amount ); m_Stream.Write( (short) loc.m_X ); @@ -1819,13 +1808,8 @@ namespace Server.Network { Point3D loc = child.Location; - ushort cid = (ushort) child.ItemID; - - if ( cid > 0x3FFF ) - cid = 0x9D7; - m_Stream.Write( (int) child.Serial ); - m_Stream.Write( (ushort) cid ); + m_Stream.Write( (ushort) child.ItemID ); m_Stream.Write( (byte) 0 ); // signed, itemID offset m_Stream.Write( (ushort) child.Amount ); m_Stream.Write( (short) loc.m_X ); @@ -3185,14 +3169,14 @@ namespace Server.Network if ( beheld.SolidHueOverride >= 0 ) hue = beheld.SolidHueOverride; - int itemID = item.ItemID & 0x3FFF; + int itemID = item.ItemID & 0x7FFF; bool writeHue = ( hue != 0 ); if ( writeHue ) itemID |= 0x8000; m_Stream.Write( (int) item.Serial ); - m_Stream.Write( (short) itemID ); + m_Stream.Write( (ushort) itemID ); m_Stream.Write( (byte) layer ); if ( writeHue ) @@ -3210,7 +3194,7 @@ namespace Server.Network if( beheld.SolidHueOverride >= 0 ) hue = beheld.SolidHueOverride; - int itemID = beheld.HairItemID & 0x3FFF; + int itemID = beheld.HairItemID & 0x7FFF; bool writeHue = (hue != 0); @@ -3218,7 +3202,7 @@ namespace Server.Network itemID |= 0x8000; m_Stream.Write( (int)HairInfo.FakeSerial( beheld ) ); - m_Stream.Write( (short)itemID ); + m_Stream.Write( (ushort)itemID ); m_Stream.Write( (byte)Layer.Hair ); if( writeHue ) @@ -3236,7 +3220,7 @@ namespace Server.Network if( beheld.SolidHueOverride >= 0 ) hue = beheld.SolidHueOverride; - int itemID = beheld.FacialHairItemID & 0x3FFF; + int itemID = beheld.FacialHairItemID & 0x7FFF; bool writeHue = (hue != 0); @@ -3244,7 +3228,7 @@ namespace Server.Network itemID |= 0x8000; m_Stream.Write( (int)FacialHairInfo.FakeSerial( beheld ) ); - m_Stream.Write( (short)itemID ); + m_Stream.Write( (ushort)itemID ); m_Stream.Write( (byte)Layer.FacialHair ); if( writeHue ) @@ -3309,14 +3293,14 @@ namespace Server.Network if ( beheld.SolidHueOverride >= 0 ) hue = beheld.SolidHueOverride; - int itemID = item.ItemID & 0x3FFF; + int itemID = item.ItemID & 0x7FFF; bool writeHue = ( hue != 0 ); if ( writeHue ) itemID |= 0x8000; m_Stream.Write( (int) item.Serial ); - m_Stream.Write( (short) itemID ); + m_Stream.Write( (ushort) itemID ); m_Stream.Write( (byte) layer ); if ( writeHue ) @@ -3334,7 +3318,7 @@ namespace Server.Network if( beheld.SolidHueOverride >= 0 ) hue = beheld.SolidHueOverride; - int itemID = beheld.HairItemID & 0x3FFF; + int itemID = beheld.HairItemID & 0x7FFF; bool writeHue = (hue != 0); @@ -3342,7 +3326,7 @@ namespace Server.Network itemID |= 0x8000; m_Stream.Write( (int)HairInfo.FakeSerial( beheld ) ); - m_Stream.Write( (short)itemID ); + m_Stream.Write( (ushort)itemID ); m_Stream.Write( (byte)Layer.Hair ); if( writeHue ) @@ -3360,7 +3344,7 @@ namespace Server.Network if( beheld.SolidHueOverride >= 0 ) hue = beheld.SolidHueOverride; - int itemID = beheld.FacialHairItemID & 0x3FFF; + int itemID = beheld.FacialHairItemID & 0x7FFF; bool writeHue = (hue != 0); @@ -3368,7 +3352,7 @@ namespace Server.Network itemID |= 0x8000; m_Stream.Write( (int)FacialHairInfo.FakeSerial( beheld ) ); - m_Stream.Write( (short)itemID ); + m_Stream.Write( (ushort)itemID ); m_Stream.Write( (byte)Layer.FacialHair ); if( writeHue ) diff --git a/Server/Targeting/LandTarget.cs b/Server/Targeting/LandTarget.cs index a4bfc76c3..6902c5c11 100644 --- a/Server/Targeting/LandTarget.cs +++ b/Server/Targeting/LandTarget.cs @@ -34,7 +34,7 @@ namespace Server.Targeting if ( map != null ) { m_Location.Z = map.GetAverageZ( m_Location.X, m_Location.Y ); - m_TileID = map.Tiles.GetLandTile( m_Location.X, m_Location.Y ).ID & 0x3FFF; + m_TileID = map.Tiles.GetLandTile( m_Location.X, m_Location.Y ).ID & TileData.MaxLandValue; } } diff --git a/Server/Targeting/StaticTarget.cs b/Server/Targeting/StaticTarget.cs index b2d5db789..9b0413b11 100644 --- a/Server/Targeting/StaticTarget.cs +++ b/Server/Targeting/StaticTarget.cs @@ -30,7 +30,7 @@ namespace Server.Targeting public StaticTarget( Point3D location, int itemID ) { m_Location = location; - m_ItemID = itemID & 0x3FFF; + m_ItemID = itemID & TileData.MaxItemValue; m_Location.Z += TileData.ItemTable[m_ItemID].CalcHeight; } diff --git a/Server/TileData.cs b/Server/TileData.cs index f7d2c37e1..49770594b 100644 --- a/Server/TileData.cs +++ b/Server/TileData.cs @@ -218,6 +218,17 @@ namespace Server } } + private static int m_MaxLandValue; + private static int m_MaxItemValue; + + public static int MaxLandValue { + get { return m_MaxLandValue; } + } + + public static int MaxItemValue { + get { return m_MaxItemValue; } + } + private static byte[] m_StringBuffer = new byte[20]; private static string ReadNameString( BinaryReader bin ) @@ -344,6 +355,9 @@ namespace Server } } } + + m_MaxLandValue = m_LandData.Length - 1; + m_MaxItemValue = m_ItemData.Length - 1; } else { diff --git a/Server/TileList.cs b/Server/TileList.cs index 55580e54a..df1599185 100644 --- a/Server/TileList.cs +++ b/Server/TileList.cs @@ -24,12 +24,12 @@ namespace Server { public class TileList { - private Tile[] m_Tiles; + private StaticTile[] m_Tiles; private int m_Count; public TileList() { - m_Tiles = new Tile[8]; + m_Tiles = new StaticTile[8]; m_Count = 0; } @@ -41,12 +41,12 @@ namespace Server } } - public void AddRange( Tile[] tiles ) + public void AddRange( StaticTile[] tiles ) { if ( (m_Count + tiles.Length) > m_Tiles.Length ) { - Tile[] old = m_Tiles; - m_Tiles = new Tile[(m_Count + tiles.Length) * 2]; + StaticTile[] old = m_Tiles; + m_Tiles = new StaticTile[(m_Count + tiles.Length) * 2]; for ( int i = 0; i < old.Length; ++i ) m_Tiles[i] = old[i]; @@ -56,12 +56,12 @@ namespace Server m_Tiles[m_Count++] = tiles[i]; } - public void Add( short id, sbyte z ) + public void Add( ushort id, sbyte z ) { if ( (m_Count + 1) > m_Tiles.Length ) { - Tile[] old = m_Tiles; - m_Tiles = new Tile[old.Length * 2]; + StaticTile[] old = m_Tiles; + m_Tiles = new StaticTile[old.Length * 2]; for ( int i = 0; i < old.Length; ++i ) m_Tiles[i] = old[i]; @@ -72,14 +72,14 @@ namespace Server ++m_Count; } - private static Tile[] m_EmptyTiles = new Tile[0]; + private static StaticTile[] m_EmptyTiles = new StaticTile[0]; - public Tile[] ToArray() + public StaticTile[] ToArray() { if ( m_Count == 0 ) return m_EmptyTiles; - Tile[] tiles = new Tile[m_Count]; + StaticTile[] tiles = new StaticTile[m_Count]; for ( int i = 0; i < m_Count; ++i ) tiles[i] = m_Tiles[i]; diff --git a/Server/TileMatrix.cs b/Server/TileMatrix.cs index 0e81c17df..76a70e936 100644 --- a/Server/TileMatrix.cs +++ b/Server/TileMatrix.cs @@ -27,11 +27,11 @@ namespace Server { public class TileMatrix { - private Tile[][][][][] m_StaticTiles; - private Tile[][][] m_LandTiles; + private StaticTile[][][][][] m_StaticTiles; + private LandTile[][][] m_LandTiles; - private Tile[] m_InvalidLandBlock; - private Tile[][][] m_EmptyStaticBlock; + private LandTile[] m_InvalidLandBlock; + private StaticTile[][][] m_EmptyStaticBlock; private FileStream m_Map; @@ -173,27 +173,27 @@ namespace Server m_Statics = new FileStream( staticsPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite ); } - m_EmptyStaticBlock = new Tile[8][][]; + m_EmptyStaticBlock = new StaticTile[8][][]; for ( int i = 0; i < 8; ++i ) { - m_EmptyStaticBlock[i] = new Tile[8][]; + m_EmptyStaticBlock[i] = new StaticTile[8][]; for ( int j = 0; j < 8; ++j ) - m_EmptyStaticBlock[i][j] = new Tile[0]; + m_EmptyStaticBlock[i][j] = new StaticTile[0]; } - m_InvalidLandBlock = new Tile[196]; + m_InvalidLandBlock = new LandTile[196]; - m_LandTiles = new Tile[m_BlockWidth][][]; - m_StaticTiles = new Tile[m_BlockWidth][][][][]; + m_LandTiles = new LandTile[m_BlockWidth][][]; + m_StaticTiles = new StaticTile[m_BlockWidth][][][][]; m_StaticPatches = new int[m_BlockWidth][]; m_LandPatches = new int[m_BlockWidth][]; m_Patch = new TileMatrixPatch( this, mapID ); } - public Tile[][][] EmptyStaticBlock + public StaticTile[][][] EmptyStaticBlock { get { @@ -201,13 +201,13 @@ namespace Server } } - public void SetStaticBlock( int x, int y, Tile[][][] value ) + public void SetStaticBlock( int x, int y, StaticTile[][][] value ) { if ( x < 0 || y < 0 || x >= m_BlockWidth || y >= m_BlockHeight ) return; if ( m_StaticTiles[x] == null ) - m_StaticTiles[x] = new Tile[m_BlockHeight][][][]; + m_StaticTiles[x] = new StaticTile[m_BlockHeight][][][]; m_StaticTiles[x][y] = value; @@ -217,15 +217,15 @@ namespace Server m_StaticPatches[x][y >> 5] |= 1 << (y & 0x1F); } - public Tile[][][] GetStaticBlock( int x, int y ) + public StaticTile[][][] GetStaticBlock( int x, int y ) { if ( x < 0 || y < 0 || x >= m_BlockWidth || y >= m_BlockHeight || m_Statics == null || m_Index == null ) return m_EmptyStaticBlock; if ( m_StaticTiles[x] == null ) - m_StaticTiles[x] = new Tile[m_BlockHeight][][][]; + m_StaticTiles[x] = new StaticTile[m_BlockHeight][][][]; - Tile[][][] tiles = m_StaticTiles[x][y]; + StaticTile[][][] tiles = m_StaticTiles[x][y]; if ( tiles == null ) { @@ -235,7 +235,7 @@ namespace Server if ( x >= 0 && x < shared.m_BlockWidth && y >= 0 && y < shared.m_BlockHeight ) { - Tile[][][][] theirTiles = shared.m_StaticTiles[x]; + StaticTile[][][][] theirTiles = shared.m_StaticTiles[x]; if ( theirTiles != null ) tiles = theirTiles[y]; @@ -259,18 +259,18 @@ namespace Server return tiles; } - public Tile[] GetStaticTiles( int x, int y ) + public StaticTile[] GetStaticTiles( int x, int y ) { - Tile[][][] tiles = GetStaticBlock( x >> 3, y >> 3 ); + StaticTile[][][] tiles = GetStaticBlock( x >> 3, y >> 3 ); return tiles[x & 0x7][y & 0x7]; } private static TileList m_TilesList = new TileList(); - public Tile[] GetStaticTiles( int x, int y, bool multis ) + public StaticTile[] GetStaticTiles( int x, int y, bool multis ) { - Tile[][][] tiles = GetStaticBlock( x >> 3, y >> 3 ); + StaticTile[][][] tiles = GetStaticBlock( x >> 3, y >> 3 ); if ( multis ) { @@ -281,7 +281,7 @@ namespace Server bool any = false; - foreach ( Tile[] multiTiles in eable ) + foreach ( StaticTile[] multiTiles in eable ) { if ( !any ) any = true; @@ -304,13 +304,13 @@ namespace Server } } - public void SetLandBlock( int x, int y, Tile[] value ) + public void SetLandBlock( int x, int y, LandTile[] value ) { if ( x < 0 || y < 0 || x >= m_BlockWidth || y >= m_BlockHeight ) return; if ( m_LandTiles[x] == null ) - m_LandTiles[x] = new Tile[m_BlockHeight][]; + m_LandTiles[x] = new LandTile[m_BlockHeight][]; m_LandTiles[x][y] = value; @@ -320,15 +320,15 @@ namespace Server m_LandPatches[x][y >> 5] |= 1 << (y & 0x1F); } - public Tile[] GetLandBlock( int x, int y ) + public LandTile[] GetLandBlock( int x, int y ) { if ( x < 0 || y < 0 || x >= m_BlockWidth || y >= m_BlockHeight || m_Map == null ) return m_InvalidLandBlock; if ( m_LandTiles[x] == null ) - m_LandTiles[x] = new Tile[m_BlockHeight][]; + m_LandTiles[x] = new LandTile[m_BlockHeight][]; - Tile[] tiles = m_LandTiles[x][y]; + LandTile[] tiles = m_LandTiles[x][y]; if ( tiles == null ) { @@ -338,7 +338,7 @@ namespace Server if ( x >= 0 && x < shared.m_BlockWidth && y >= 0 && y < shared.m_BlockHeight ) { - Tile[][] theirTiles = shared.m_LandTiles[x]; + LandTile[][] theirTiles = shared.m_LandTiles[x]; if ( theirTiles != null ) tiles = theirTiles[y]; @@ -362,9 +362,9 @@ namespace Server return tiles; } - public Tile GetLandTile( int x, int y ) + public LandTile GetLandTile( int x, int y ) { - Tile[] tiles = GetLandBlock( x >> 3, y >> 3 ); + LandTile[] tiles = GetLandBlock( x >> 3, y >> 3 ); return tiles[((y & 0x7) << 3) + (x & 0x7)]; } @@ -373,7 +373,7 @@ namespace Server private static StaticTile[] m_TileBuffer = new StaticTile[128]; - private unsafe Tile[][][] ReadStaticBlock( int x, int y ) + private unsafe StaticTile[][][] ReadStaticBlock( int x, int y ) { try { @@ -423,15 +423,15 @@ namespace Server while ( pCur < pEnd ) { - lists[pCur->m_X & 0x7][pCur->m_Y & 0x7].Add( (short)((pCur->m_ID & 0x3FFF) + 0x4000), pCur->m_Z ); + lists[pCur->m_X & 0x7][pCur->m_Y & 0x7].Add( pCur->m_ID, pCur->m_Z ); pCur = pCur + 1; } - Tile[][][] tiles = new Tile[8][][]; + StaticTile[][][] tiles = new StaticTile[8][][]; for ( int i = 0; i < 8; ++i ) { - tiles[i] = new Tile[8][]; + tiles[i] = new StaticTile[8][]; for ( int j = 0; j < 8; ++j ) tiles[i][j] = lists[i][j].ToArray(); @@ -462,15 +462,15 @@ namespace Server throw new Exception(); } - private unsafe Tile[] ReadLandBlock( int x, int y ) + private unsafe LandTile[] ReadLandBlock( int x, int y ) { try { m_Map.Seek( ((x * m_BlockHeight) + y) * 196 + 4, SeekOrigin.Begin ); - Tile[] tiles = new Tile[64]; + LandTile[] tiles = new LandTile[64]; - fixed ( Tile *pTiles = tiles ) + fixed ( LandTile *pTiles = tiles ) { #if !MONO NativeReader.Read( m_Map.SafeFileHandle.DangerousGetHandle(), pTiles, 192 ); @@ -507,65 +507,34 @@ namespace Server } [System.Runtime.InteropServices.StructLayout( System.Runtime.InteropServices.LayoutKind.Sequential, Pack=1 )] - public struct StaticTile - { - public short m_ID; - public byte m_X; - public byte m_Y; - public sbyte m_Z; - public short m_Hue; - } - - [System.Runtime.InteropServices.StructLayout( System.Runtime.InteropServices.LayoutKind.Sequential, Pack=1 )] - public struct Tile + public struct LandTile { internal short m_ID; internal sbyte m_Z; public int ID { - get - { - return m_ID; - } + get { return m_ID; } } public int Z { - get - { - return m_Z; - } - set - { - m_Z = (sbyte)value; - } + get { return m_Z; } + set { m_Z = (sbyte)value; } } public int Height { - get - { - if ( m_ID < 0x4000 ) - { - return 0; - } - else - { - return TileData.ItemTable[m_ID & 0x3FFF].Height; - } - } + get { return 0; } + } public bool Ignored { - get - { - return ( m_ID == 2 || m_ID == 0x1DB || ( m_ID >= 0x1AE && m_ID <= 0x1B5 ) ); - } + get { return ( m_ID == 2 || m_ID == 0x1DB || ( m_ID >= 0x1AE && m_ID <= 0x1B5 ) ); } } - public Tile( short id, sbyte z ) + public LandTile( short id, sbyte z ) { m_ID = id; m_Z = z; @@ -577,4 +546,82 @@ namespace Server m_Z = z; } } + + [System.Runtime.InteropServices.StructLayout( System.Runtime.InteropServices.LayoutKind.Sequential, Pack=1 )] + public struct StaticTile + { + internal ushort m_ID; + internal byte m_X; + internal byte m_Y; + internal sbyte m_Z; + internal short m_Hue; + + public int ID + { + get { return m_ID; } + } + + public int X + { + get { return m_X; } + set { m_X = (byte)value; } + } + + public int Y + { + get { return m_Y; } + set { m_Y = (byte)value; } + } + + public int Z + { + get { return m_Z; } + set { m_Z = (sbyte)value; } + } + + public int Hue + { + get { return m_Hue; } + set { m_Hue = (short)value; } + } + + public int Height + { + get { return TileData.ItemTable[m_ID & TileData.MaxItemValue].Height; } + } + + public StaticTile( ushort id, sbyte z ) + { + m_ID = id; + m_Z = z; + + m_X = 0; + m_Y = 0; + m_Hue = 0; + } + + public StaticTile( ushort id, byte x, byte y, sbyte z, short hue ) + { + m_ID = id; + m_X = x; + m_Y = y; + m_Z = z; + m_Hue = hue; + } + + public void Set( ushort id, sbyte z ) + { + m_ID = id; + m_Z = z; + } + + public void Set( ushort id, byte x, byte y, sbyte z, short hue ) + { + m_ID = id; + m_X = x; + m_Y = y; + m_Z = z; + m_Hue = hue; + } + } } diff --git a/Server/TileMatrixPatch.cs b/Server/TileMatrixPatch.cs index 84e44e6b0..7f4e3e050 100644 --- a/Server/TileMatrixPatch.cs +++ b/Server/TileMatrixPatch.cs @@ -95,9 +95,9 @@ namespace Server fsData.Seek( 4, SeekOrigin.Current ); - Tile[] tiles = new Tile[64]; + LandTile[] tiles = new LandTile[64]; - fixed ( Tile *pTiles = tiles ) + fixed ( LandTile *pTiles = tiles ) { #if !MONO NativeReader.Read( fsData.SafeFileHandle.DangerousGetHandle(), pTiles, 192 ); @@ -177,15 +177,15 @@ namespace Server while ( pCur < pEnd ) { - lists[pCur->m_X & 0x7][pCur->m_Y & 0x7].Add( (short)((pCur->m_ID & 0x3FFF) + 0x4000), pCur->m_Z ); + lists[pCur->m_X & 0x7][pCur->m_Y & 0x7].Add( (ushort)pCur->m_ID, pCur->m_Z ); pCur = pCur + 1; } - Tile[][][] tiles = new Tile[8][][]; + StaticTile[][][] tiles = new StaticTile[8][][]; for ( int x = 0; x < 8; ++x ) { - tiles[x] = new Tile[8][]; + tiles[x] = new StaticTile[8][]; for ( int y = 0; y < 8; ++y ) tiles[x][y] = lists[x][y].ToArray(); diff --git a/Server/Utility.cs b/Server/Utility.cs index 1744d61c3..8c580887d 100644 --- a/Server/Utility.cs +++ b/Server/Utility.cs @@ -684,16 +684,18 @@ namespace Server } } - public static bool CanMobileFit( int z, Tile[] tiles ) + /* Should probably be rewritten to use an ITile interface + + public static bool CanMobileFit( int z, StaticTile[] tiles ) { int checkHeight = 15; int checkZ = z; for ( int i = 0; i < tiles.Length; ++i ) { - Tile tile = tiles[i]; + StaticTile tile = tiles[i]; - if ( ((checkZ + checkHeight) > tile.Z && checkZ < (tile.Z + tile.Height))/* || (tile.Z < (checkZ + checkHeight) && (tile.Z + tile.Height) > checkZ)*/ ) + if ( ((checkZ + checkHeight) > tile.Z && checkZ < (tile.Z + tile.Height))*//* || (tile.Z < (checkZ + checkHeight) && (tile.Z + tile.Height) > checkZ)*//* ) { return false; } @@ -706,16 +708,16 @@ namespace Server return true; } - public static bool IsInContact( Tile check, Tile[] tiles ) + public static bool IsInContact( StaticTile check, StaticTile[] tiles ) { int checkHeight = check.Height; int checkZ = check.Z; for ( int i = 0; i < tiles.Length; ++i ) { - Tile tile = tiles[i]; + StaticTile tile = tiles[i]; - if ( ((checkZ + checkHeight) > tile.Z && checkZ < (tile.Z + tile.Height))/* || (tile.Z < (checkZ + checkHeight) && (tile.Z + tile.Height) > checkZ)*/ ) + if ( ((checkZ + checkHeight) > tile.Z && checkZ < (tile.Z + tile.Height))*//* || (tile.Z < (checkZ + checkHeight) && (tile.Z + tile.Height) > checkZ)*//* ) { return true; } @@ -727,6 +729,7 @@ namespace Server return false; } + */ public static object GetArrayCap( Array array, int index ) {