Beispiel #1
0
 public bool IsInMulti(int px, int py, int pz)
 {
     for (int i = 0; i < this.m_Items.Count; i++)
     {
         Item item = (Item)this.m_Items[i];
         if (item.InWorld && item.IsMulti)
         {
             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) && this.IsInMulti(item, m, px, py, pz))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Beispiel #2
0
        public bool RunUO_IsInside(Item item, Multi m, int px, int py, int pz)
        {
            int num;
            int num2;
            int num3;
            int num4;

            m.GetBounds(out num, out num2, out num3, out num4);
            int num5 = px - item.X;
            int num6 = py - item.Y;

            if (((num5 >= num) && (num5 <= num3)) && ((num6 >= num2) && (num6 <= num4)))
            {
                if ((item.Multi != m) && (num6 < num4))
                {
                    return(true);
                }
                int index = num5 - num;
                int num8  = num6 - num2;
                if (m.RunUO_Inside == null)
                {
                    m.UpdateRadar();
                }
                int num9 = m.RunUO_Inside[num8][index] + item.Z;
                if ((pz == num9) || ((pz + 0x10) > num9))
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #3
0
 public void Register(Item i, int id)
 {
     if ((i.Multi == null) || (i.Multi.MultiID != id))
     {
         Multi multi = new Multi(id);
         i.Multi = multi;
         Map.Invalidate();
         GRadar.Invalidate();
     }
     if (!this.m_Items.Contains(i))
     {
         this.m_Items.Add(i);
         this.m_Items.Sort(MultiComparer.Instance);
         Map.Invalidate();
         GRadar.Invalidate();
     }
 }
Beispiel #4
0
 public static void SetCustomMulti(int serial, int revision, Multi baseMulti, int compressionType, byte[] buffer)
 {
     ArrayList list = (ArrayList) m_Hashtable[serial];
     if (list == null)
     {
         m_Hashtable[serial] = list = new ArrayList();
     }
     CustomMultiEntry entry = new CustomMultiEntry(serial, revision, baseMulti, compressionType, buffer);
     for (int i = 0; i < list.Count; i++)
     {
         CustomMultiEntry entry2 = (CustomMultiEntry) list[i];
         if (entry2.Revision == revision)
         {
             list[i] = entry;
             return;
         }
     }
     list.Add(entry);
     Map.Invalidate();
     GRadar.Invalidate();
 }
Beispiel #5
0
        public bool IsInMulti(Item item, Multi m, int px, int py, int pz)
        {
            int num;
            int num2;
            int num3;
            int num4;

            if ((((item.X >= 0x1400) && (item.X < 0x1800)) && ((item.Y >= 0x900) && (item.Y < 0x1000))) && ((Engine.m_World == 0) || (Engine.m_World == 1)))
            {
                return(true);
            }
            m.GetBounds(out num, out num2, out num3, out num4);
            int num5 = px - item.X;
            int num6 = py - item.Y;

            if (((num5 >= num) && (num5 <= num3)) && ((num6 >= num2) && (num6 <= num4)))
            {
                if ((item.Multi != m) && (num6 < num4))
                {
                    return(true);
                }
                int index = num5 - num;
                int num8  = num6 - num2;
                if (((m != item.Multi) && (index == 0)) && (num6 == num4))
                {
                    return(true);
                }
                if (m.Inside == null)
                {
                    m.UpdateRadar();
                }
                int num9 = m.Inside[num8][index] + item.Z;
                if ((pz == num9) || ((pz + 0x10) > num9))
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #6
0
        public static void SetCustomMulti(int serial, int revision, Multi baseMulti, int compressionType, byte[] buffer)
        {
            ArrayList list = (ArrayList)m_Hashtable[serial];

            if (list == null)
            {
                m_Hashtable[serial] = list = new ArrayList();
            }
            CustomMultiEntry entry = new CustomMultiEntry(serial, revision, baseMulti, compressionType, buffer);

            for (int i = 0; i < list.Count; i++)
            {
                CustomMultiEntry entry2 = (CustomMultiEntry)list[i];
                if (entry2.Revision == revision)
                {
                    list[i] = entry;
                    return;
                }
            }
            list.Add(entry);
            Map.Invalidate();
            GRadar.Invalidate();
        }
Beispiel #7
0
 public bool RunUO_IsInside(Item item, Multi m, int px, int py, int pz)
 {
     int num;
     int num2;
     int num3;
     int num4;
     m.GetBounds(out num, out num2, out num3, out num4);
     int num5 = px - item.X;
     int num6 = py - item.Y;
     if (((num5 >= num) && (num5 <= num3)) && ((num6 >= num2) && (num6 <= num4)))
     {
         if ((item.Multi != m) && (num6 < num4))
         {
             return true;
         }
         int index = num5 - num;
         int num8 = num6 - num2;
         if (m.RunUO_Inside == null)
         {
             m.UpdateRadar();
         }
         int num9 = m.RunUO_Inside[num8][index] + item.Z;
         if ((pz == num9) || ((pz + 0x10) > num9))
         {
             return true;
         }
     }
     return false;
 }
Beispiel #8
0
 public void Register(Item i, int id)
 {
     if ((i.Multi == null) || (i.Multi.MultiID != id))
     {
         Multi multi = new Multi(id);
         i.Multi = multi;
         Map.Invalidate();
         GRadar.Invalidate();
     }
     if (!this.m_Items.Contains(i))
     {
         this.m_Items.Add(i);
         this.m_Items.Sort(MultiComparer.Instance);
         Map.Invalidate();
         GRadar.Invalidate();
     }
 }
Beispiel #9
0
 public bool IsInMulti(Item item, Multi m, int px, int py, int pz)
 {
     int num;
     int num2;
     int num3;
     int num4;
     if ((((item.X >= 0x1400) && (item.X < 0x1800)) && ((item.Y >= 0x900) && (item.Y < 0x1000))) && ((Engine.m_World == 0) || (Engine.m_World == 1)))
     {
         return true;
     }
     m.GetBounds(out num, out num2, out num3, out num4);
     int num5 = px - item.X;
     int num6 = py - item.Y;
     if (((num5 >= num) && (num5 <= num3)) && ((num6 >= num2) && (num6 <= num4)))
     {
         if ((item.Multi != m) && (num6 < num4))
         {
             return true;
         }
         int index = num5 - num;
         int num8 = num6 - num2;
         if (((m != item.Multi) && (index == 0)) && (num6 == num4))
         {
             return true;
         }
         if (m.Inside == null)
         {
             m.UpdateRadar();
         }
         int num9 = m.Inside[num8][index] + item.Z;
         if ((pz == num9) || ((pz + 0x10) > num9))
         {
             return true;
         }
     }
     return false;
 }
Beispiel #10
0
        private static unsafe void Load(int x, int y, int w, int h, int world, Texture tex)
        {
            if (m_Colors == null)
            {
                LoadColors();
            }
            if ((m_StrongReferences == null) || (m_StrongReferences.Length != (w * h)))
            {
                m_StrongReferences = new MapBlock[w * h];
            }
            if ((m_Guarded == null) || (m_Guarded.Length != ((w * h) * 0x40)))
            {
                m_Guarded = new BitArray((w * h) * 0x40);
            }
            else
            {
                m_Guarded.SetAll(false);
            }
            Region[] guardedRegions = Region.GuardedRegions;
            int      num            = x * 8;
            int      num2           = y * 8;
            int      num3           = w * 8;
            int      num4           = h * 8;

            for (int i = 0; i < guardedRegions.Length; i++)
            {
                Region      region = guardedRegions[i];
                RegionWorld world2 = region.World;
                bool        flag   = false;
                switch (world2)
                {
                case RegionWorld.Britannia:
                    flag = (world == 0) || (world == 1);
                    break;

                case RegionWorld.Felucca:
                    flag = world == 0;
                    break;

                case RegionWorld.Trammel:
                    flag = world == 1;
                    break;

                case RegionWorld.Ilshenar:
                    flag = world == 2;
                    break;

                case RegionWorld.Malas:
                    flag = world == 3;
                    break;

                case RegionWorld.Tokuno:
                    flag = world == 4;
                    break;
                }
                if (flag)
                {
                    int num6 = region.X - num;
                    int num7 = region.Y - num2;
                    if (((num6 < num3) && (num7 < num4)) && ((num6 > -region.Width) && (num7 > -region.Height)))
                    {
                        int num8 = num6 + region.Width;
                        int num9 = num7 + region.Height;
                        if (num6 < 0)
                        {
                            num6 = 0;
                        }
                        if (num7 < 0)
                        {
                            num7 = 0;
                        }
                        for (int j = num6; (j < num8) && (j < num3); j++)
                        {
                            for (int k = num7; (k < num9) && (k < num4); k++)
                            {
                                m_Guarded[(k * num3) + j] = true;
                            }
                        }
                    }
                }
            }
            TileMatrix matrix = Map.GetMatrix(world);
            LockData   data   = tex.Lock(LockFlags.WriteOnly);
            int        num12  = data.Pitch >> 1;

            fixed(short *numRef = m_Colors)
            {
                for (int m = 0; m < w; m++)
                {
                    short *numPtr = (short *)(data.pvSrc + ((m << 3) * 2));
                    for (int num14 = 0; num14 < h; num14++)
                    {
                        MapBlock block = matrix.GetBlock(x + m, y + num14);
                        m_StrongReferences[(num14 * w) + m] = block;
                        HuedTile[][][] tileArray  = (block == null) ? matrix.EmptyStaticBlock : block.m_StaticTiles;
                        Tile[]         tileArray2 = (block == null) ? matrix.InvalidLandBlock : block.m_LandTiles;
                        int            index      = 0;
                        for (int num16 = 0; index < 8; num16 += 8)
                        {
                            for (int num17 = 0; num17 < 8; num17++)
                            {
                                int num18 = -255;
                                int num19 = -255;
                                int num20 = 0;
                                int hue   = 0;
                                for (int num24 = 0; num24 < tileArray[num17][index].Length; num24++)
                                {
                                    HuedTile tile = tileArray[num17][index][num24];
                                    int      iD   = tile.ID;
                                    switch (iD)
                                    {
                                    case 0x4001:
                                    case 0x5796:
                                    case 0x61a4:
                                    case 0x6198:
                                    case 0x61bc:
                                    case 0x6199:
                                        break;

                                    default:
                                    {
                                        int z     = tile.Z;
                                        int num23 = z + Map.GetHeight(iD);
                                        if ((num23 > num18) || ((z > num19) && (num23 >= num18)))
                                        {
                                            num18 = num23;
                                            num19 = z;
                                            num20 = iD;
                                            hue   = tile.Hue;
                                        }
                                        break;
                                    }
                                    }
                                }
                                if ((tileArray2[num16 + num17].Z > num18) && (tileArray2[num16 + num17].ID != 2))
                                {
                                    num20 = tileArray2[num16 + num17].ID;
                                    hue   = 0;
                                }
                                int num26 = ((((num14 << 3) + index) * num3) + (m << 3)) + num17;
                                if (m_Guarded[num26] && ((((num26 >= 1) && !m_Guarded[num26 - 1]) || ((num26 >= num3) && !m_Guarded[num26 - num3])) || (((num26 < (m_Guarded.Length - 1)) && !m_Guarded[num26 + 1]) || ((num26 < (m_Guarded.Length - num3)) && !m_Guarded[num26 + num3]))))
                                {
                                    numPtr[num17] = -31776;
                                }
                                else if (hue == 0)
                                {
                                    numPtr[num17] = numRef[num20];
                                }
                                else
                                {
                                    numPtr[num17] = (short)Hues.Load((hue & 0x3fff) | 0x8000).Pixel((ushort)numRef[num20]);
                                }
                            }
                            numPtr += num12;
                            index++;
                        }
                    }
                }
                ArrayList items = Engine.Multis.Items;

                for (int n = 0; n < items.Count; n++)
                {
                    Item item = (Item)items[n];
                    if (item.InWorld && item.Visible)
                    {
                        CustomMultiEntry customMulti = CustomMultiLoader.GetCustomMulti(item.Serial, item.Revision);
                        Multi            multi       = null;
                        if (customMulti != null)
                        {
                            multi = customMulti.Multi;
                        }
                        if (multi == null)
                        {
                            multi = item.Multi;
                        }
                        if (multi != null)
                        {
                            short[][] radar = multi.Radar;
                            if (radar != null)
                            {
                                int num28;
                                int num29;
                                int num30;
                                int num31;
                                multi.GetBounds(out num28, out num29, out num30, out num31);
                                int num32 = 0;
                                for (int num33 = (item.Y - (y << 3)) + num29; num32 < radar.Length; num33++)
                                {
                                    if ((num33 >= 0) && (num33 < (h << 3)))
                                    {
                                        short * numPtr2   = (short *)(data.pvSrc + ((num33 * num12) * 2));
                                        short[] numArray2 = radar[num32];
                                        int     num34     = 0;
                                        for (int num35 = (item.X - (x << 3)) + num28; num34 < numArray2.Length; num35++)
                                        {
                                            if (((num35 >= 0) && (num35 < (w << 3))) && (numArray2[num34] != 0))
                                            {
                                                numPtr2[num35] = numRef[numArray2[num34]];
                                            }
                                            num34++;
                                        }
                                    }
                                    num32++;
                                }
                            }
                        }
                    }
                }
            }

            tex.Unlock();
        }
Beispiel #11
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)));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }