This commit is contained in:
mark 2010-12-06 06:45:45 +00:00
parent 34d969712e
commit d444b9ba5c
70 changed files with 569 additions and 495 deletions

View file

@ -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];
}
}

View file

@ -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;
}
}
}
}
}

View file

@ -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<Item> items = new List<Item>();
@ -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<Tile> GetTilesAt( Point2D p, bool items, bool land, bool statics )
{
List<Tile> list = new List<Tile>();
@ -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;
}
*/
/// <summary>
/// Gets the highest surface that is lower than <paramref name="p"/>.
@ -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;
}*/

View file

@ -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];
}
}

View file

@ -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;
}

View file

@ -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 )

View file

@ -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;
}
}

View file

@ -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;
}

View file

@ -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
{

View file

@ -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];

View file

@ -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;
}
}
}

View file

@ -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();

View file

@ -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 )
{