Example #1
0
 public static StaticItem Instantiate(short itemID, short realID, sbyte z, int serial)
 {
     if (m_InstancePool.Count > 0)
     {
         StaticItem item = (StaticItem)m_InstancePool.Dequeue();
         item.m_RealID        = (short)((realID & 0x3fff) | 0x4000);
         item.m_ID            = itemID;
         item.m_ID            = (short)(item.m_ID & 0x3fff);
         item.m_ID            = (short)(item.m_ID + 0x4000);
         item.m_Z             = z;
         item.m_Hue           = Hues.Default;
         item.m_Height        = Map.GetHeight(item.m_ID);
         item.m_SortInfluence = 0;
         item.Serial          = serial;
         item.m_LastImage     = null;
         item.m_LastImageHue  = null;
         item.m_LastImageID   = 0;
         item.m_vAlpha        = 0;
         item.m_bAlpha        = false;
         item.m_bDraw         = false;
         item.m_bInit         = false;
         return(item);
     }
     return(new StaticItem(itemID, z, serial));
 }
Example #2
0
 public static StaticItem Instantiate(HuedTile tile, int influence, int serial)
 {
     if (m_InstancePool.Count > 0)
     {
         StaticItem item = (StaticItem)m_InstancePool.Dequeue();
         item.m_RealID        = (short)((tile.ID & 0x3fff) | 0x4000);
         item.m_ID            = (short)tile.ID;
         item.m_ID            = (short)(item.m_ID & 0x3fff);
         item.m_ID            = (short)(item.m_ID + 0x4000);
         item.m_Z             = (sbyte)tile.Z;
         item.m_Hue           = Hues.GetItemHue(item.m_ID, tile.Hue);
         item.m_Height        = Map.GetHeight(item.m_ID);
         item.m_SortInfluence = influence;
         item.Serial          = serial;
         item.m_LastImage     = null;
         item.m_LastImageHue  = null;
         item.m_LastImageID   = 0;
         item.m_vAlpha        = 0;
         item.m_bAlpha        = false;
         item.m_bDraw         = false;
         item.m_bInit         = false;
         return(item);
     }
     return(new StaticItem(tile, influence, serial));
 }
Example #3
0
 public static unsafe StaticItem Instantiate(byte *pSrc, int sortInfluence, int serial)
 {
     if (m_InstancePool.Count > 0)
     {
         StaticItem item = (StaticItem)m_InstancePool.Dequeue();
         item.m_RealID        = (short)((*(((short *)pSrc)) & 0x3fff) | 0x4000);
         item.m_ID            = *((short *)pSrc);
         item.m_ID            = (short)(item.m_ID & 0x3fff);
         item.m_ID            = (short)(item.m_ID + 0x4000);
         item.m_Z             = *((sbyte *)(pSrc + 4));
         item.m_Hue           = Hues.GetItemHue(item.m_ID, *((ushort *)(pSrc + 5)));
         item.m_Height        = Map.GetHeight(item.m_ID);
         item.m_SortInfluence = sortInfluence;
         item.Serial          = serial;
         item.m_LastImage     = null;
         item.m_LastImageHue  = null;
         item.m_LastImageID   = 0;
         item.m_vAlpha        = 0;
         item.m_bAlpha        = false;
         item.m_bDraw         = false;
         item.m_bInit         = false;
         return(item);
     }
     return(new StaticItem(pSrc, sortInfluence, serial));
 }
Example #4
0
 public void GetStats(object obj, out int z, out int treshold, out int type, out int tiebreaker)
 {
     if (obj is MobileCell)
     {
         MobileCell cell = (MobileCell)obj;
         z        = cell.Z;
         treshold = 2;
         type     = 3;
         if (cell.m_Mobile.Player)
         {
             tiebreaker = 0x40000000;
         }
         else
         {
             tiebreaker = cell.Serial;
         }
     }
     else if (obj is LandTile)
     {
         LandTile tile = (LandTile)obj;
         z          = tile.SortZ;
         treshold   = 0;
         type       = 0;
         tiebreaker = 0;
     }
     else if (obj is DynamicItem)
     {
         int         num;
         DynamicItem item = (DynamicItem)obj;
         z = item.Z;
         if (Map.m_ItemFlags[item.ID & 0x3fff][TileFlag.Background])
         {
             num = 0;
         }
         else
         {
             num = 1;
         }
         treshold   = (item.Height == 0) ? num : (num + 1);
         type       = ((item.ID & 0x3fff) == 0x2006) ? 4 : 2;
         tiebreaker = item.Serial;
     }
     else if (obj is StaticItem)
     {
         int        num2;
         StaticItem item2 = (StaticItem)obj;
         z = item2.Z;
         if (Map.m_ItemFlags[item2.ID & 0x3fff][TileFlag.Background])
         {
             num2 = 0;
         }
         else
         {
             num2 = 1;
         }
         treshold   = (item2.Height == 0) ? num2 : (num2 + 1);
         type       = 1;
         tiebreaker = item2.m_SortInfluence;
     }
     else
     {
         z          = 0;
         treshold   = 0;
         type       = 0;
         tiebreaker = 0;
     }
 }
Example #5
0
        public int OldCompare(object x, object y)
        {
            bool  flag5;
            bool  flag6;
            ICell cell     = (ICell)x;
            ICell cell2    = (ICell)y;
            Type  cellType = cell.CellType;
            Type  type2    = cell2.CellType;
            bool  flag     = cellType == tLandTile;
            bool  flag2    = type2 == tLandTile;
            bool  flag3    = !flag && ((cellType == tDynamicItem) || (cellType == tStaticItem));
            bool  flag4    = !flag2 && ((type2 == tDynamicItem) || (type2 == tStaticItem));

            if (flag3)
            {
                this.item1 = (IItem)cell;
                if (cellType == tStaticItem)
                {
                    StaticItem item = (StaticItem)cell;
                    this.c1ItemID        = item.m_ID;
                    this.c1SortZ         = item.m_Z;
                    this.c1Height        = item.m_Height;
                    this.c1SortInfluence = item.m_SortInfluence;
                }
                else
                {
                    DynamicItem item2 = (DynamicItem)cell;
                    this.c1ItemID = item2.m_ID;
                    this.c1SortZ  = item2.m_Z;
                    this.c1Height = item2.m_Height;
                }
                this.c1Flags = Map.m_ItemFlags[this.c1ItemID & 0x3fff].Value;
                flag5        = (this.c1ItemID & 0x3fff) == 0x2006;
                if ((this.c1Flags & 0x400) != 0)
                {
                    this.c1Height /= 2;
                }
            }
            else
            {
                this.c1SortZ  = cell.SortZ;
                this.c1Height = cell.Height;
                flag5         = false;
            }
            if (flag4)
            {
                this.item2 = (IItem)cell2;
                if (type2 == tStaticItem)
                {
                    StaticItem item3 = (StaticItem)cell2;
                    this.c2ItemID        = item3.m_ID;
                    this.c2SortZ         = item3.m_Z;
                    this.c2Height        = item3.m_Height;
                    this.c2SortInfluence = item3.m_SortInfluence;
                }
                else
                {
                    DynamicItem item4 = (DynamicItem)cell2;
                    this.c2ItemID = item4.m_ID;
                    this.c2SortZ  = item4.m_Z;
                    this.c2Height = item4.m_Height;
                }
                this.c2Flags = Map.m_ItemFlags[this.c2ItemID & 0x3fff].Value;
                flag6        = (this.c2ItemID & 0x3fff) == 0x2006;
                if ((this.c2Flags & 0x400) != 0)
                {
                    this.c2Height /= 2;
                }
            }
            else
            {
                this.c2SortZ  = cell2.SortZ;
                this.c2Height = cell2.Height;
                flag6         = false;
            }
            if (flag5 && !flag6)
            {
                return(1);
            }
            if (!flag5 && flag6)
            {
                return(-1);
            }
            if (!flag5 || !flag6)
            {
                if ((flag3 && (this.c1ItemID != 0x4001)) && (((this.c1Flags & 0x10000000) != 0) && (this.c1SortZ > this.c2SortZ)))
                {
                    return(1);
                }
                if ((flag4 && (this.c2ItemID != 0x4001)) && (((this.c2Flags & 0x10000000) != 0) && (this.c2SortZ > this.c1SortZ)))
                {
                    return(-1);
                }
                if ((flag3 && (this.c1ItemID != 0x4001)) && ((this.c1Flags & 0x20000) != 0))
                {
                    return(1);
                }
                if ((flag4 && (this.c2ItemID != 0x4001)) && ((this.c2Flags & 0x20000) != 0))
                {
                    return(-1);
                }
                if ((!flag && flag2) && ((this.c1SortZ + this.c1Height) >= (this.c2SortZ + this.c2Height)))
                {
                    return(1);
                }
                if ((flag && !flag2) && ((this.c2SortZ + this.c2Height) <= (this.c1SortZ + this.c1Height)))
                {
                    return(-1);
                }
                if ((this.c1SortZ + this.c1Height) > (this.c2SortZ + this.c2Height))
                {
                    return(1);
                }
                if ((this.c1SortZ + this.c1Height) < (this.c2SortZ + this.c2Height))
                {
                    return(-1);
                }
                if (this.c1SortZ > this.c2SortZ)
                {
                    return(1);
                }
                if (this.c1SortZ < this.c2SortZ)
                {
                    return(-1);
                }
                if (flag3 && flag4)
                {
                    bool flag7 = (this.c1Flags & 1) != 0;
                    bool flag8 = (this.c2Flags & 1) != 0;
                }
                if (flag && !flag2)
                {
                    return(-1);
                }
                if (!flag && flag2)
                {
                    return(1);
                }
                bool flag9  = (!flag3 && !flag) && (cellType == tMobileCell);
                bool flag10 = (!flag4 && !flag2) && (cellType == tMobileCell);
                if (!flag9 && flag10)
                {
                    return(-1);
                }
                if (flag9 && !flag10)
                {
                    return(1);
                }
                if (flag9 && flag10)
                {
                    Mobile mobile  = ((MobileCell)cell).m_Mobile;
                    Mobile mobile2 = ((MobileCell)cell2).m_Mobile;
                    if ((mobile != null) && (mobile2 != null))
                    {
                        bool player = mobile.Player;
                        bool flag12 = mobile2.Player;
                        if (player && !flag12)
                        {
                            return(1);
                        }
                        if (flag12 && !player)
                        {
                            return(-1);
                        }
                    }
                    return(0);
                }
                if ((cellType == tDynamicItem) && (type2 == tStaticItem))
                {
                    return(1);
                }
                if ((cellType == tStaticItem) && (type2 == tDynamicItem))
                {
                    return(-1);
                }
                if ((cellType == tStaticItem) && (type2 == tStaticItem))
                {
                    if (this.c2SortInfluence < this.c1SortInfluence)
                    {
                        return(-1);
                    }
                    if (this.c2SortInfluence > this.c1SortInfluence)
                    {
                        return(1);
                    }
                    return(0);
                }
                if ((cellType == tDynamicItem) && (type2 == tDynamicItem))
                {
                    Item item5 = ((DynamicItem)cell).m_Item;
                    Item item6 = ((DynamicItem)cell2).m_Item;
                    if (item5.Serial < item6.Serial)
                    {
                        return(-1);
                    }
                    if (item5.Serial > item6.Serial)
                    {
                        return(1);
                    }
                    return(0);
                }
            }
            return(0);
        }
Example #6
0
        public void Update(MapPackage map)
        {
            int count = this.m_Items.Count;

            if (count != 0)
            {
                int length = map.cells.GetLength(0);
                int num3   = map.cells.GetLength(1);
                int cellX  = map.CellX;
                int cellY  = map.CellY;
                int num6   = cellX + length;
                int num7   = cellY + num3;
                for (int i = 0; i < count; i++)
                {
                    Item item = (Item)this.m_Items[i];
                    if (item.InWorld && item.Visible)
                    {
                        CustomMultiEntry customMulti = CustomMultiLoader.GetCustomMulti(item.Serial, item.Revision);
                        Multi            m           = null;
                        if (customMulti != null)
                        {
                            m = customMulti.Multi;
                        }
                        if (m == null)
                        {
                            m = item.Multi;
                        }
                        if (m != null)
                        {
                            int num9;
                            int num10;
                            int num11;
                            int num12;
                            m.GetBounds(out num9, out num10, out num11, out num12);
                            num9  += item.X;
                            num10 += item.Y;
                            num11 += item.X;
                            num12 += item.Y;
                            if ((((num9 < num6) && (num11 >= cellX)) && (num10 < num7)) && (num12 >= cellY))
                            {
                                ArrayList list   = m.List;
                                int       num13  = list.Count;
                                bool      flag   = false;
                                Mobile    player = World.Player;
                                if (player != null)
                                {
                                    flag = this.IsInMulti(item, m, player.X, player.Y, player.Z);
                                }
                                int num14 = -2147483648 | i;
                                for (int j = 0; j < num13; j++)
                                {
                                    MultiItem item2 = (MultiItem)list[j];
                                    if ((item2.Flags == 0) && (j != 0))
                                    {
                                        continue;
                                    }
                                    int num16 = item.X + item2.X;
                                    int num17 = item.Y + item2.Y;
                                    num16 -= cellX;
                                    num17 -= cellY;
                                    if ((((num16 < 0) || (num16 >= length)) || (num17 < 0)) || (num17 >= num3))
                                    {
                                        continue;
                                    }
                                    bool flag2  = true;
                                    int  itemID = item2.ItemID;
                                    if (flag || (this.m_Level == 0))
                                    {
                                        goto Label_03C6;
                                    }
                                    int num19 = 7;
                                    if (customMulti == null)
                                    {
                                        switch ((m.MultiID & 0x3fff))
                                        {
                                        case 0x7a:
                                        case 0x7c:
                                        case 0x7e:
                                        case 0x98:
                                        case 0x9c:
                                            goto Label_0270;

                                        case 150:
                                        case 0xa2:
                                            goto Label_0266;

                                        case 0x9a:
                                            goto Label_0275;

                                        case 0x9e:
                                            num19 = 5;
                                            break;
                                        }
                                    }
                                    goto Label_027A;
Label_0266:
                                    num19 = 4;
                                    goto Label_027A;
Label_0270:
                                    num19 = 6;
                                    goto Label_027A;
Label_0275:
                                    num19 = 8;
Label_027A:
                                    if (Map.m_ItemFlags[itemID & 0x3fff][TileFlag.Bridge] || Map.m_ItemFlags[itemID & 0x3fff][TileFlag.Surface])
                                    {
                                        flag2 = item2.Z < (num19 + (this.m_Level * 20));
                                    }
                                    else
                                    {
                                        flag2 = item2.Z < (num19 + ((this.m_Level - 1) * 20));
                                        if ((item2.Z >= (num19 + ((this.m_Level - 1) * 20))) && (item2.Z <= ((num19 + ((this.m_Level - 1) * 20)) + 2)))
                                        {
                                            if (m_RouteMap == null)
                                            {
                                                m_RouteMap = new int[0x4000];
                                                for (int k = 0; k < m_RouteTable.GetLength(0); k++)
                                                {
                                                    m_RouteMap[m_RouteTable[k, 0]] = m_RouteTable[k, 1];
                                                }
                                            }
                                            int num21 = m_RouteMap[itemID & 0x3fff];
                                            if (num21 != 0)
                                            {
                                                itemID = num21;
                                                flag2  = true;
                                            }
                                        }
                                    }
                                    if (!flag2 && ((((itemID == 0x4001) || (itemID == 0x5796)) || ((itemID == 0x61a4) || (itemID == 0x6198))) || ((itemID == 0x61bc) || (itemID == 0x6199))))
                                    {
                                        flag2 = true;
                                    }
Label_03C6:
                                    if (flag2)
                                    {
                                        map.cells[num16, num17].Add(StaticItem.Instantiate((short)itemID, item2.ItemID, (sbyte)(item.Z + item2.Z), num14 | (j << 0x10)));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Example #7
0
        public static bool CheckMovement(int xStart, int yStart, int zStart, int dir, out int zNew)
        {
            int    num8;
            int    num9;
            Mobile player = World.Player;

            if (player == null)
            {
                zNew = 0;
                return(false);
            }
            int x = xStart;
            int y = yStart;

            Offset(dir, ref x, ref y);
            MapPackage cache = Map.GetCache();
            int        num3  = x - cache.CellX;
            int        num4  = y - cache.CellY;

            if (!Map.IsValid(num3, num4))
            {
                zNew = 0;
                return(false);
            }
            LandTile  tile  = cache.landTiles[num3, num4];
            ArrayList tiles = cache.cells[num3, num4];

            try
            {
                if (((player.Notoriety == Notoriety.Murderer) && tile.m_Guarded) && (!cache.landTiles[xStart - cache.CellX, yStart - cache.CellY].m_Guarded && ((Control.ModifierKeys & (Keys.Control | Keys.Shift)) != (Keys.Control | Keys.Shift))))
                {
                    zNew = 0;
                    return(false);
                }
            }
            catch
            {
            }
            bool flag  = Map.GetLandFlags(tile.m_ID)[TileFlag.Impassable];
            bool flag2 = ((tile.m_ID != 2) && (tile.m_ID != 0x1db)) && ((tile.m_ID < 430) || (tile.m_ID > 0x1b5));
            int  z     = 0;
            int  avg   = 0;
            int  top   = 0;

            Map.GetAverageZ(x, y, ref z, ref avg, ref top);
            GetStartZ(xStart, yStart, zStart, out num8, out num9);
            zNew = num8;
            bool flag3       = false;
            int  num10       = num9 + 2;
            int  num11       = num8 + 0x10;
            bool ignoreDoors = player.Ghost || (player.Body == 0x3db);
            bool ignoreMobs  = (ignoreDoors || (player.StamCur == player.StamMax)) || (Engine.m_World != 0);

            if (Engine.m_Stealth)
            {
                ignoreMobs = false;
            }
            for (int i = 0; i < tiles.Count; i++)
            {
                ICell cell = (ICell)tiles[i];
                if (cell is StaticItem)
                {
                    StaticItem item  = (StaticItem)cell;
                    TileFlags  flags = Map.m_ItemFlags[item.m_RealID & 0x3fff];
                    if (flags[TileFlag.Surface] && !flags[TileFlag.Impassable])
                    {
                        int num13  = item.m_Z;
                        int num14  = num13;
                        int ourZ   = num13 + item.CalcHeight;
                        int num16  = ourZ + 0x10;
                        int ourTop = num11;
                        if (flag3)
                        {
                            int num18 = Math.Abs((int)(ourZ - player.Z)) - Math.Abs((int)(zNew - player.Z));
                            if ((num18 > 0) || ((num18 == 0) && (ourZ > zNew)))
                            {
                                continue;
                            }
                        }
                        if ((ourZ + 0x10) > ourTop)
                        {
                            ourTop = ourZ + 0x10;
                        }
                        if (!flags[TileFlag.Bridge])
                        {
                            num14 += item.Height;
                        }
                        if (num10 >= num14)
                        {
                            int num19 = num13;
                            if (item.Height >= 2)
                            {
                                num19 += 2;
                            }
                            else
                            {
                                num19 += item.Height;
                            }
                            if (((!flag2 || (num19 >= avg)) || ((avg <= ourZ) || (ourTop <= z))) && IsOk(ignoreMobs, ignoreDoors, ourZ, ourTop, tiles))
                            {
                                zNew  = ourZ;
                                flag3 = true;
                            }
                        }
                    }
                }
                else if (cell is DynamicItem)
                {
                    Item      item2  = ((DynamicItem)cell).m_Item;
                    TileFlags flags2 = Map.m_ItemFlags[item2.ID & 0x3fff];
                    if (flags2[TileFlag.Surface] && !flags2[TileFlag.Impassable])
                    {
                        int num20  = item2.Z;
                        int num21  = num20;
                        int num22  = num20;
                        int height = Map.GetHeight((item2.ID & 0x3fff) + 0x4000);
                        if (flags2[TileFlag.Bridge])
                        {
                            num22 += height / 2;
                        }
                        else
                        {
                            num22 += height;
                        }
                        if (flag3)
                        {
                            int num24 = Math.Abs((int)(num22 - player.Z)) - Math.Abs((int)(zNew - player.Z));
                            if ((num24 > 0) || ((num24 == 0) && (num22 > zNew)))
                            {
                                continue;
                            }
                        }
                        int num25 = num22 + 0x10;
                        int num26 = num11;
                        if ((num22 + 0x10) > num26)
                        {
                            num26 = num22 + 0x10;
                        }
                        if (!flags2[TileFlag.Bridge])
                        {
                            num21 += height;
                        }
                        if (num10 >= num21)
                        {
                            int num27 = num20;
                            if (height >= 2)
                            {
                                num27 += 2;
                            }
                            else
                            {
                                num27 += height;
                            }
                            if (((!flag2 || (num27 >= avg)) || ((avg <= num22) || (num26 <= z))) && IsOk(ignoreMobs, ignoreDoors, num22, num26, tiles))
                            {
                                zNew  = num22;
                                flag3 = true;
                            }
                        }
                    }
                }
            }
            if ((flag2 && !flag) && (num10 >= z))
            {
                int num28 = avg;
                int num29 = num28 + 0x10;
                int num30 = num11;
                if ((num28 + 0x10) > num30)
                {
                    num30 = num28 + 0x10;
                }
                bool flag6 = true;
                if (flag3)
                {
                    int num31 = Math.Abs((int)(num28 - player.Z)) - Math.Abs((int)(zNew - player.Z));
                    if ((num31 > 0) || ((num31 == 0) && (num28 > zNew)))
                    {
                        flag6 = false;
                    }
                }
                if (flag6 && IsOk(ignoreMobs, ignoreDoors, num28, num30, tiles))
                {
                    zNew  = num28;
                    flag3 = true;
                }
            }
            return(flag3);
        }
Example #8
0
 private static bool IsOk(bool ignoreMobs, bool ignoreDoors, int ourZ, int ourTop, ArrayList tiles)
 {
     for (int i = 0; i < tiles.Count; i++)
     {
         ICell cell = (ICell)tiles[i];
         if (cell is StaticItem)
         {
             StaticItem item  = (StaticItem)cell;
             TileFlags  flags = Map.m_ItemFlags[item.m_RealID & 0x3fff];
             if (flags[TileFlag.Surface | TileFlag.Impassable])
             {
                 int z    = item.m_Z;
                 int num3 = z + item.CalcHeight;
                 if ((num3 > ourZ) && (ourTop > z))
                 {
                     return(false);
                 }
             }
         }
         else if (cell is DynamicItem)
         {
             Item      item2  = ((DynamicItem)cell).m_Item;
             TileFlags flags2 = Map.m_ItemFlags[item2.ID & 0x3fff];
             if (flags2[TileFlag.Surface | TileFlag.Impassable] && !item2.IsDoor)
             {
                 int num4 = item2.Z;
                 int num5 = num4;
                 if (flags2[TileFlag.Bridge])
                 {
                     num5 += Map.GetHeight((item2.ID & 0x3fff) + 0x4000) / 2;
                 }
                 else
                 {
                     num5 += Map.GetHeight((item2.ID & 0x3fff) + 0x4000);
                 }
                 if ((num5 > ourZ) && (ourTop > num4))
                 {
                     if ((!item2.Flags[ItemFlag.CanMove] && (Map.GetWeight(item2.ID) >= 0xff)) || (((Control.ModifierKeys & Keys.Shift) == Keys.None) || ((m_LastLiftBlocker + TimeSpan.FromSeconds(0.6)) >= DateTime.Now)))
                     {
                         return(false);
                     }
                     m_LastLiftBlocker = DateTime.Now;
                     Network.Send(new PPickupItem(item2, item2.Amount));
                     Network.Send(new PDropItem(item2.Serial, -1, -1, 0, World.Serial));
                 }
             }
         }
         else if (!ignoreMobs && (cell is MobileCell))
         {
             Mobile mobile = ((MobileCell)cell).m_Mobile;
             if (!mobile.Ghost && !mobile.Bonded)
             {
                 int num6 = mobile.Z;
                 int num7 = num6 + 0x10;
                 if ((num7 > ourZ) && (ourTop > num6))
                 {
                     return(false);
                 }
             }
         }
     }
     return(true);
 }
Example #9
0
        private static void GetStartZ(int xStart, int yStart, int zStart, out int zLow, out int zTop)
        {
            MapPackage cache = Map.GetCache();
            int        x     = xStart - cache.CellX;
            int        y     = yStart - cache.CellY;

            if (!Map.IsValid(x, y))
            {
                zLow = zStart;
                zTop = zStart;
            }
            else
            {
                int       num12;
                LandTile  tile  = cache.landTiles[x, y];
                ArrayList list  = cache.cells[x, y];
                bool      flag  = Map.GetLandFlags(tile.m_ID)[TileFlag.Impassable];
                bool      flag2 = ((tile.m_ID != 2) && (tile.m_ID != 0x1db)) && ((tile.m_ID < 430) || (tile.m_ID > 0x1b5));
                int       z     = 0;
                int       avg   = 0;
                int       top   = 0;
                Map.GetAverageZ(xStart, yStart, ref z, ref avg, ref top);
                zTop = num12 = 0;
                int  num6  = zLow = num12;
                bool flag3 = false;
                if (((flag2 && !flag) && (zStart >= avg)) && (!flag3 || (avg >= num6)))
                {
                    zLow = z;
                    num6 = avg;
                    if (!flag3 || (top > zTop))
                    {
                        zTop = top;
                    }
                    flag3 = true;
                }
                for (int i = 0; i < list.Count; i++)
                {
                    ICell cell = (ICell)list[i];
                    if (cell is StaticItem)
                    {
                        StaticItem item  = (StaticItem)cell;
                        TileFlags  flags = Map.m_ItemFlags[item.m_RealID & 0x3fff];
                        int        num8  = item.m_Z + item.CalcHeight;
                        if ((flags[TileFlag.Surface] && (zStart >= num8)) && (!flag3 || (num8 >= num6)))
                        {
                            num6 = num8;
                            int num9 = item.m_Z + item.m_Height;
                            if (!flag3 || (num9 > zTop))
                            {
                                zTop = num9;
                            }
                            zLow  = item.m_Z;
                            flag3 = true;
                        }
                    }
                    else if (cell is DynamicItem)
                    {
                        Item      item2  = ((DynamicItem)cell).m_Item;
                        TileFlags flags2 = Map.m_ItemFlags[item2.ID & 0x3fff];
                        int       num10  = item2.Z;
                        if (flags2[TileFlag.Bridge])
                        {
                            num10 += Map.GetHeight((item2.ID & 0x3fff) + 0x4000) / 2;
                        }
                        else
                        {
                            num10 += Map.GetHeight((item2.ID & 0x3fff) + 0x4000);
                        }
                        if ((flags2[TileFlag.Surface] && (zStart >= num10)) && (!flag3 || (num10 >= num6)))
                        {
                            num6 = num10;
                            int num11 = item2.Z + Map.GetHeight((item2.ID & 0x3fff) + 0x4000);
                            if (!flag3 || (num11 > zTop))
                            {
                                zTop = num11;
                            }
                            zLow  = item2.Z;
                            flag3 = true;
                        }
                    }
                }
                if (!flag3)
                {
                    zLow = zTop = zStart;
                }
                else if (zStart > zTop)
                {
                    zTop = zStart;
                }
            }
        }