public Multi(int MultiID) { this.m_MultiID = MultiID; ArrayList list = Engine.Multis.Load(MultiID); int count = list.Count; int num2 = 0; this.m_xMin = 0x3e8; this.m_yMin = 0x3e8; this.m_xMax = -1000; this.m_yMax = -1000; while (num2 < count) { MultiItem item = (MultiItem)list[num2]; if (item.X < this.m_xMin) { this.m_xMin = item.X; } if (item.Y < this.m_yMin) { this.m_yMin = item.Y; } if (item.X > this.m_xMax) { this.m_xMax = item.X; } if (item.Y > this.m_yMax) { this.m_yMax = item.Y; } num2++; } this.m_List = list; this.UpdateRadar(); }
private unsafe ArrayList ReadFromDisk(int multiID) { BinaryReader reader = new BinaryReader(Engine.FileManager.OpenMUL(Files.MultiIdx)); reader.BaseStream.Seek((long)(multiID * 12), SeekOrigin.Begin); int num = reader.ReadInt32(); int num2 = reader.ReadInt32(); reader.Close(); if (num == -1) { return(new ArrayList()); } Stream stream = Engine.FileManager.OpenMUL(Files.MultiMul); stream.Seek((long)num, SeekOrigin.Begin); byte[] buffer = new byte[num2]; Engine.NativeRead((FileStream)stream, buffer, 0, buffer.Length); stream.Close(); int num3 = num2 / 12; MultiItem[] c = new MultiItem[num3]; fixed(byte *numRef = buffer) { MultiItem *itemPtr = (MultiItem *)numRef; MultiItem *itemPtr2 = itemPtr + num3; fixed(MultiItem *itemRef = c) { MultiItem *itemPtr3 = itemRef; while (itemPtr < itemPtr2) { itemPtr->ItemID = (short)(itemPtr->ItemID & 0x3fff); itemPtr->ItemID = (short)(itemPtr->ItemID + 0x4000); itemPtr3++; itemPtr++; itemPtr3[0] = itemPtr[0]; } } } return(new ArrayList(c)); }
public bool Remove(int x, int y, int z, int itemID) { if (((x < this.m_xMin) || (y < this.m_yMin)) || ((x > this.m_xMax) || (y > this.m_yMax))) { return(false); } itemID &= 0x3fff; itemID |= 0x4000; bool flag = false; for (int i = 0; i < this.m_List.Count; i++) { MultiItem item = (MultiItem)this.m_List[i]; if (((item.X == x) && (item.Y == y)) && ((item.Z == z) && (item.ItemID == itemID))) { this.m_List.RemoveAt(i--); flag = true; } } return(flag); }
public static void LoadUncompressed(byte[] buffer, ArrayList list) { int num = buffer.Length / 5; int num2 = 0; for (int i = 0; i < num; i++) { int num4 = (buffer[num2++] << 8) | buffer[num2++]; int num5 = (sbyte)buffer[num2++]; int num6 = (sbyte)buffer[num2++]; int num7 = (sbyte)buffer[num2++]; MultiItem item = new MultiItem { Flags = 1, ItemID = (short)num4, X = (short)num5, Y = (short)num6, Z = (short)num7 }; list.Add(item); } }
public void Add(int itemID, int x, int y, int z) { if ((((x >= this.m_xMin) && (y >= this.m_yMin)) && (x <= this.m_xMax)) && (y <= this.m_yMax)) { itemID &= 0x3fff; itemID |= 0x4000; for (int i = 0; i < this.m_List.Count; i++) { MultiItem item = (MultiItem)this.m_List[i]; if (((item.X == x) && (item.Y == y)) && ((item.Z == z) && ((Map.GetHeight(item.ItemID) > 0) == (Map.GetHeight(itemID) > 0)))) { this.m_List.RemoveAt(i--); } } MultiItem item2 = new MultiItem { Flags = 1, ItemID = (short)itemID, X = (short)x, Y = (short)y, Z = (short)z }; this.m_List.Add(item2); } }
private unsafe ArrayList ReadFromDisk(int multiID) { BinaryReader reader = new BinaryReader(Engine.FileManager.OpenMUL(Files.MultiIdx)); reader.BaseStream.Seek((long) (multiID * 12), SeekOrigin.Begin); int num = reader.ReadInt32(); int num2 = reader.ReadInt32(); reader.Close(); if (num == -1) { return new ArrayList(); } Stream stream = Engine.FileManager.OpenMUL(Files.MultiMul); stream.Seek((long) num, SeekOrigin.Begin); byte[] buffer = new byte[num2]; Engine.NativeRead((FileStream) stream, buffer, 0, buffer.Length); stream.Close(); int num3 = num2 / 12; MultiItem[] c = new MultiItem[num3]; fixed (byte* numRef = buffer) { MultiItem* itemPtr = (MultiItem*) numRef; MultiItem* itemPtr2 = itemPtr + num3; fixed (MultiItem* itemRef = c) { MultiItem* itemPtr3 = itemRef; while (itemPtr < itemPtr2) { itemPtr->ItemID = (short) (itemPtr->ItemID & 0x3fff); itemPtr->ItemID = (short) (itemPtr->ItemID + 0x4000); itemPtr3++; itemPtr++; itemPtr3[0] = itemPtr[0]; } } } return new ArrayList(c); }
public static unsafe void LoadDeflated(int xMin, int yMin, int xMax, int yMax, byte[] buffer, ArrayList list) { int num = (yMax - yMin) + 1; fixed (byte* numRef = buffer) { byte* source = numRef; int num2 = *(source++); for (int i = 0; i < num2; i++) { int num4 = (source[0] >> 4) & 15; int num5 = source[0] & 15; int destLength = source[1] | ((source[3] << 4) & 0xf00); int sourceLength = source[2] | ((source[3] << 8) & 0xf00); source += 4; if ((m_InflateBuffer == null) || (m_InflateBuffer.Length < destLength)) { m_InflateBuffer = new byte[destLength]; } fixed (byte* numRef2 = m_InflateBuffer) { MultiItem item; int num8; int num9; int num10; int num11; int num12; byte* dest = numRef2; uncompress(dest, ref destLength, source, sourceLength); source += sourceLength; byte* numPtr3 = dest + destLength; switch (num4) { case 0: goto Label_014A; case 1: num8 = 0; switch (num5) { case 0: goto Label_018C; case 1: case 5: goto Label_0191; case 2: case 6: goto Label_0196; case 3: case 7: goto Label_019C; case 4: case 8: goto Label_01A2; } goto Label_0226; case 2: num9 = 0; switch (num5) { case 0: goto Label_0268; case 1: case 5: goto Label_026D; case 2: case 6: goto Label_0272; case 3: case 7: goto Label_0278; case 4: case 8: goto Label_027E; } goto Label_0284; default: { continue; } } Label_00CA: item = new MultiItem(); item.Flags = 1; item.ItemID = (short) (0x4000 | (((dest[0] << 8) | dest[1]) & 0x3fff)); item.X = (sbyte) dest[2]; item.Y = (sbyte) dest[3]; item.Z = (sbyte) dest[4]; dest += 5; if (item.ItemID != 0x4000) { list.Add(item); } Label_014A: if (dest < numPtr3) { goto Label_00CA; } continue; Label_018C: num8 = 0; goto Label_0226; Label_0191: num8 = 7; goto Label_0226; Label_0196: num8 = 0x1b; goto Label_0226; Label_019C: num8 = 0x2f; goto Label_0226; Label_01A2: num8 = 0x43; Label_0226: while (dest < numPtr3) { MultiItem item2 = new MultiItem { Flags = 1, ItemID = (short) (0x4000 | (((dest[0] << 8) | dest[1]) & 0x3fff)), X = (sbyte) dest[2], Y = (sbyte) dest[3], Z = (sbyte) num8 }; dest += 4; if (item2.ItemID != 0x4000) { list.Add(item2); } } continue; Label_0268: num9 = 0; goto Label_0284; Label_026D: num9 = 7; goto Label_0284; Label_0272: num9 = 0x1b; goto Label_0284; Label_0278: num9 = 0x2f; goto Label_0284; Label_027E: num9 = 0x43; Label_0284: if (num5 <= 0) { num10 = xMin; num11 = yMin; num12 = num + 1; } else if (num5 <= 4) { num10 = xMin + 1; num11 = yMin + 1; num12 = num - 1; } else { num10 = xMin; num11 = yMin; num12 = num; } int num13 = 0; while (dest < numPtr3) { short num14 = (short) (0x4000 | (((dest[0] << 8) | dest[1]) & 0x3fff)); num13++; dest += 2; if (num14 != 0x4000) { MultiItem item3 = new MultiItem { Flags = 1, ItemID = num14, X = (short) (num10 + ((num13 - 1) / num12)), Y = (sbyte) (num11 + ((num13 - 1) % num12)), Z = (sbyte) num9 }; list.Add(item3); } } } } } }
public static void LoadUncompressed(byte[] buffer, ArrayList list) { int num = buffer.Length / 5; int num2 = 0; for (int i = 0; i < num; i++) { int num4 = (buffer[num2++] << 8) | buffer[num2++]; int num5 = (sbyte) buffer[num2++]; int num6 = (sbyte) buffer[num2++]; int num7 = (sbyte) buffer[num2++]; MultiItem item = new MultiItem { Flags = 1, ItemID = (short) num4, X = (short) num5, Y = (short) num6, Z = (short) num7 }; list.Add(item); } }
public void Add(int itemID, int x, int y, int z) { if ((((x >= this.m_xMin) && (y >= this.m_yMin)) && (x <= this.m_xMax)) && (y <= this.m_yMax)) { itemID &= 0x3fff; itemID |= 0x4000; for (int i = 0; i < this.m_List.Count; i++) { MultiItem item = (MultiItem) this.m_List[i]; if (((item.X == x) && (item.Y == y)) && ((item.Z == z) && ((Map.GetHeight(item.ItemID) > 0) == (Map.GetHeight(itemID) > 0)))) { this.m_List.RemoveAt(i--); } } MultiItem item2 = new MultiItem { Flags = 1, ItemID = (short) itemID, X = (short) x, Y = (short) y, Z = (short) z }; this.m_List.Add(item2); } }
private static void MultiTarget(PacketReader pvSrc) { pvSrc.ReadByte(); Engine.m_MultiPreview = true; Engine.m_MultiSerial = pvSrc.ReadInt32(); Engine.TargetHandler = new MultiTargetHandler(Engine.m_MultiSerial); pvSrc.Seek(12, SeekOrigin.Current); Engine.m_MultiID = pvSrc.ReadInt16(); Engine.m_xMultiOffset = pvSrc.ReadInt16(); Engine.m_yMultiOffset = pvSrc.ReadInt16(); Engine.m_zMultiOffset = pvSrc.ReadInt16(); ArrayList list = new ArrayList(Engine.Multis.Load(Engine.m_MultiID)); int count = list.Count; int x = 0x3e8; int y = 0x3e8; int num4 = -1000; int num5 = -1000; for (int i = 0; i < count; i++) { MultiItem item = (MultiItem) list[i]; if (item.X < x) { x = item.X; } if (item.X > num4) { num4 = item.X; } if (item.Y < y) { y = item.Y; } if (item.Y > num5) { num5 = item.Y; } } Engine.m_MultiMinX = x; Engine.m_MultiMinY = y; Engine.m_MultiMaxX = num4; Engine.m_MultiMaxY = num5; ArrayList list2 = new ArrayList(list.Count); for (int j = x; j <= num4; j++) { for (int k = y; k <= num5; k++) { ArrayList list3 = new ArrayList(8); count = list.Count; int index = 0; while (index < count) { MultiItem item2 = (MultiItem) list[index]; if ((item2.X == j) && (item2.Y == k)) { list3.Add(StaticItem.Instantiate(item2.ItemID, (sbyte) item2.Z, item2.Flags)); list.RemoveAt(index); count--; } else { index++; } } list3.Sort(TileSorter.Comparer); count = list3.Count; for (index = 0; index < count; index++) { StaticItem item3 = (StaticItem) list3[index]; MultiItem item4 = new MultiItem { X = (short) j, Y = (short) k, Z = item3.Z, ItemID = (short) ((item3.ID & 0x3fff) | 0x4000), Flags = item3.Serial }; list2.Add(item4); } } } Engine.m_MultiList = list2; }
public void UpdateRadar() { int num = (this.m_xMax - this.m_xMin) + 1; int num2 = (this.m_yMax - this.m_yMin) + 1; if ((num > 0) && (num2 > 0)) { int[][] numArray = new int[num2][]; int[][] numArray2 = new int[num2][]; this.m_Inside = new sbyte[num2][]; this.m_RunUO_Inside = new sbyte[num2][]; this.m_Radar = new short[num2][]; for (int i = 0; i < num2; i++) { this.m_Radar[i] = new short[num]; this.m_Inside[i] = new sbyte[num]; this.m_RunUO_Inside[i] = new sbyte[num]; numArray[i] = new int[num]; numArray2[i] = new int[num]; for (int k = 0; k < num; k++) { numArray[i][k] = -2147483648; } for (int m = 0; m < num; m++) { numArray2[i][m] = -2147483648; } for (int n = 0; n < num; n++) { this.m_Inside[i][n] = 0x7f; } for (int num7 = 0; num7 < num; num7++) { this.m_RunUO_Inside[i][num7] = 0x7f; } } for (int j = 0; j < this.m_List.Count; j++) { MultiItem item = (MultiItem)this.m_List[j]; int index = item.X - this.m_xMin; int num10 = item.Y - this.m_yMin; if (((index >= 0) && (index < num)) && ((num10 >= 0) && (num10 < num2))) { int z = item.Z; int num12 = z + Map.GetHeight(item.ItemID); int num13 = numArray2[num10][index]; int num14 = numArray[num10][index]; int itemID = item.ItemID; if (((num12 > num14) || ((num12 == num14) && (z > num13))) && ((((itemID != 0x4001) && (itemID != 0x5796)) && ((itemID != 0x61a4) && (itemID != 0x6198))) && ((itemID != 0x61bc) && (itemID != 0x6199)))) { this.m_Radar[num10][index] = item.ItemID; numArray2[num10][index] = z; numArray[num10][index] = num12; } if (!Map.GetTileFlags(item.ItemID)[TileFlag.Roof]) { itemID = item.ItemID & 0x3fff; sbyte num16 = (sbyte)item.Z; if (num16 < this.m_Inside[num10][index]) { this.m_Inside[num10][index] = num16; } if ((((itemID < 0xb95) || (itemID > 0xc0e)) && ((itemID < 0xc43) || (itemID > 0xc44))) && (num16 < this.m_RunUO_Inside[num10][index])) { this.m_RunUO_Inside[num10][index] = num16; } } } } } }
public static unsafe void LoadDeflated(int xMin, int yMin, int xMax, int yMax, byte[] buffer, ArrayList list) { int num = (yMax - yMin) + 1; fixed(byte *numRef = buffer) { byte *source = numRef; int num2 = *(source++); for (int i = 0; i < num2; i++) { int num4 = (source[0] >> 4) & 15; int num5 = source[0] & 15; int destLength = source[1] | ((source[3] << 4) & 0xf00); int sourceLength = source[2] | ((source[3] << 8) & 0xf00); source += 4; if ((m_InflateBuffer == null) || (m_InflateBuffer.Length < destLength)) { m_InflateBuffer = new byte[destLength]; } fixed(byte *numRef2 = m_InflateBuffer) { MultiItem item; int num8; int num9; int num10; int num11; int num12; byte * dest = numRef2; uncompress(dest, ref destLength, source, sourceLength); source += sourceLength; byte *numPtr3 = dest + destLength; switch (num4) { case 0: goto Label_014A; case 1: num8 = 0; switch (num5) { case 0: goto Label_018C; case 1: case 5: goto Label_0191; case 2: case 6: goto Label_0196; case 3: case 7: goto Label_019C; case 4: case 8: goto Label_01A2; } goto Label_0226; case 2: num9 = 0; switch (num5) { case 0: goto Label_0268; case 1: case 5: goto Label_026D; case 2: case 6: goto Label_0272; case 3: case 7: goto Label_0278; case 4: case 8: goto Label_027E; } goto Label_0284; default: { continue; } } Label_00CA: item = new MultiItem(); item.Flags = 1; item.ItemID = (short)(0x4000 | (((dest[0] << 8) | dest[1]) & 0x3fff)); item.X = (sbyte)dest[2]; item.Y = (sbyte)dest[3]; item.Z = (sbyte)dest[4]; dest += 5; if (item.ItemID != 0x4000) { list.Add(item); } Label_014A: if (dest < numPtr3) { goto Label_00CA; } continue; Label_018C: num8 = 0; goto Label_0226; Label_0191: num8 = 7; goto Label_0226; Label_0196: num8 = 0x1b; goto Label_0226; Label_019C: num8 = 0x2f; goto Label_0226; Label_01A2: num8 = 0x43; Label_0226: while (dest < numPtr3) { MultiItem item2 = new MultiItem { Flags = 1, ItemID = (short)(0x4000 | (((dest[0] << 8) | dest[1]) & 0x3fff)), X = (sbyte)dest[2], Y = (sbyte)dest[3], Z = (sbyte)num8 }; dest += 4; if (item2.ItemID != 0x4000) { list.Add(item2); } } continue; Label_0268: num9 = 0; goto Label_0284; Label_026D: num9 = 7; goto Label_0284; Label_0272: num9 = 0x1b; goto Label_0284; Label_0278: num9 = 0x2f; goto Label_0284; Label_027E: num9 = 0x43; Label_0284: if (num5 <= 0) { num10 = xMin; num11 = yMin; num12 = num + 1; } else if (num5 <= 4) { num10 = xMin + 1; num11 = yMin + 1; num12 = num - 1; } else { num10 = xMin; num11 = yMin; num12 = num; } int num13 = 0; while (dest < numPtr3) { short num14 = (short)(0x4000 | (((dest[0] << 8) | dest[1]) & 0x3fff)); num13++; dest += 2; if (num14 != 0x4000) { MultiItem item3 = new MultiItem { Flags = 1, ItemID = num14, X = (short)(num10 + ((num13 - 1) / num12)), Y = (sbyte)(num11 + ((num13 - 1) % num12)), Z = (sbyte)num9 }; list.Add(item3); } } } } } }
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))); } } } } } } } }