public static unsafe int GetBrightness(Texture tex, int xStart, int yStart, int xStep, int yStep, int count) { LockData data = tex.Lock(LockFlags.ReadOnly); short * pvSrc = (short *)data.pvSrc; int num = data.Pitch >> 1; pvSrc += yStart * num; pvSrc += xStart; num *= yStep; num += xStep; int num2 = 0; for (int i = 0; i < count; i++) { short num4 = pvSrc[0]; num2 += (num4 & 0x1f) * 0x72; num2 += ((num4 >> 5) & 0x1f) * 0x24b; num2 += ((num4 >> 10) & 0x1f) * 0x12b; pvSrc += num; } tex.Unlock(); num2 = num2 << 3; num2 /= count; return(num2 / 0x3e8); }
public static unsafe int GetBrightness(Texture tex, int xStart, int yStart, int xStep, int yStep, int count) { LockData data = tex.Lock(LockFlags.ReadOnly); short* pvSrc = (short*) data.pvSrc; int num = data.Pitch >> 1; pvSrc += yStart * num; pvSrc += xStart; num *= yStep; num += xStep; int num2 = 0; for (int i = 0; i < count; i++) { short num4 = pvSrc[0]; num2 += (num4 & 0x1f) * 0x72; num2 += ((num4 >> 5) & 0x1f) * 0x24b; num2 += ((num4 >> 10) & 0x1f) * 0x12b; pvSrc += num; } tex.Unlock(); num2 = num2 << 3; num2 /= count; return (num2 / 0x3e8); }
protected unsafe Texture Construct(bool isReconstruct) { int num; int num2; if (!this.CoreLookup()) { return(Texture.Empty); } this.CoreGetDimensions(out num, out num2); Texture tex = new Texture(num, num2, true, 0x19, 1, isReconstruct); if (tex.IsEmpty()) { return(Texture.Empty); } LockData data = tex.Lock(LockFlags.WriteOnly); this.CoreProcessImage(data.Width, data.Height, data.Pitch, (ushort *)data.pvSrc, (ushort *)(data.pvSrc + (data.Width * 2)), (ushort *)(data.pvSrc + (data.Height * data.Pitch)), (data.Pitch >> 1) - data.Width, data.Pitch >> 1); tex.Unlock(); this.CoreAssignArgs(tex); this.m_Textures.Add(tex); return(tex); }
protected unsafe Texture Construct(bool isReconstruct) { int num; int num2; if (!this.CoreLookup()) { return Texture.Empty; } this.CoreGetDimensions(out num, out num2); Texture tex = new Texture(num, num2, true, 0x19, 1, isReconstruct); if (tex.IsEmpty()) { return Texture.Empty; } LockData data = tex.Lock(LockFlags.WriteOnly); this.CoreProcessImage(data.Width, data.Height, data.Pitch, (ushort*) data.pvSrc, (ushort*) (data.pvSrc + (data.Width * 2)), (ushort*) (data.pvSrc + (data.Height * data.Pitch)), (data.Pitch >> 1) - data.Width, data.Pitch >> 1); tex.Unlock(); this.CoreAssignArgs(tex); this.m_Textures.Add(tex); return tex; }
unsafe Texture IFontFactory.CreateInstance(string text, IHue hue) { int num; char ch; FontImage image; if ((text == null) || (text.Length <= 0)) { return(Texture.Empty); } int yHeight = 0; int num3 = 0; int width = 0; int height = 1; char[] chArray = text.ToCharArray(); for (num = 0; num < chArray.Length; num++) { ch = chArray[num]; if ((ch >= ' ') && (ch < 'Ā')) { image = this.m_Images[ch - ' ']; num3 += image.xWidth; if (num3 > width) { width = num3; } if (image.yHeight > yHeight) { yHeight = image.yHeight; } } else if (ch == '\n') { num3 = 0; height++; } } height *= yHeight; if ((width <= 0) || (height <= 0)) { return(Texture.Empty); } Texture texture = new Texture(width, height, false); if (texture.IsEmpty()) { return(Texture.Empty); } short[] numArray = new short[this.m_Palette.Length]; fixed(short *numRef = numArray) { fixed(short *numRef2 = this.m_Palette) { hue.CopyPixels((void *)(numRef2 + 1), (void *)(numRef + 1), this.m_Palette.Length - 1); } LockData data = texture.Lock(LockFlags.WriteOnly); short * pvSrc = (short *)data.pvSrc; short * numPtr2 = pvSrc; int num6 = data.Pitch >> 1; int num7 = num6 * yHeight; for (num = 0; num < chArray.Length; num++) { ch = chArray[num]; if ((ch >= ' ') && (ch < 'Ā')) { image = this.m_Images[ch - ' ']; int xWidth = image.xWidth; int num11 = image.yHeight; short *numPtr3 = numPtr2; numPtr3 += (yHeight - num11) * num6; int num8 = num6 - xWidth; int num9 = image.xDelta - xWidth; fixed(byte *numRef3 = image.xyPixels) { byte *numPtr4 = numRef3; int num12 = 0; while (num12 < num11) { int num13 = xWidth >> 2; int num14 = xWidth & 3; while (--num13 >= 0) { numPtr3[0] = numRef[numPtr4[0]]; numPtr3[1] = numRef[numPtr4[1]]; numPtr3[2] = numRef[numPtr4[2]]; numPtr3[3] = numRef[numPtr4[3]]; numPtr3 += 4; numPtr4 += 4; } while (--num14 >= 0) { numPtr3++; numPtr3[0] = numRef[*(numPtr4++)]; } num12++; numPtr3 += num8; numPtr4 += num9; } } numPtr2 += image.xWidth; } else if (ch == '\n') { pvSrc += num7; numPtr2 = pvSrc; } } texture.Unlock(); return(texture); } }
public void Apply(Texture Target) { LockData ld = Target.Lock(LockFlags.ReadWrite); this.Apply(ld); Target.Unlock(); }
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(); }
public unsafe object Create(int realID, IHue hue) { int length; int lookup; int num3; Stream stream; switch (this.ConvertRealID(ref realID)) { case 1: { if (((realID < 0) || (realID >= this.m_Count)) || (realID >= this.m_Index.Length)) { return Frames.Empty; } Entry3D entryd = this.m_Index[realID]; length = entryd.m_Length; lookup = entryd.m_Lookup; num3 = entryd.m_Extra & 0xff; stream = m_Stream; break; } case 2: { if (((realID < 0) || (realID >= this.m_Count2)) || (realID >= this.m_Index2.Length)) { return Frames.Empty; } Entry3D entryd2 = this.m_Index2[realID]; length = entryd2.m_Length; lookup = entryd2.m_Lookup; num3 = entryd2.m_Extra & 0xff; stream = m_Stream2; break; } case 3: { if (((realID < 0) || (realID >= this.m_Count3)) || (realID >= this.m_Index3.Length)) { return Frames.Empty; } Entry3D entryd3 = this.m_Index3[realID]; length = entryd3.m_Length; lookup = entryd3.m_Lookup; num3 = entryd3.m_Extra & 0xff; stream = m_Stream3; break; } default: { if (((realID < 0) || (realID >= this.m_Count4)) || (realID >= this.m_Index4.Length)) { return Frames.Empty; } Entry3D entryd4 = this.m_Index4[realID]; length = entryd4.m_Length; lookup = entryd4.m_Lookup; num3 = entryd4.m_Extra & 0xff; stream = m_Stream4; break; } } if (((lookup < 0) || (length <= 0)) || ((num3 <= 0) || (stream == null))) { return Frames.Empty; } if ((this.m_Data == null) || (length > this.m_Data.Length)) { this.m_Data = new byte[length]; } stream.Seek((long) lookup, SeekOrigin.Begin); stream.Read(this.m_Data, 0, length); fixed (short* numRef = this.m_Palette) { short* numPtr = numRef; fixed (byte* numRef2 = this.m_Data) { if (hue.HueID() == 0) { numPtr = (short*) numRef2; int* numPtr2 = (int*) numPtr; int* numPtr3 = numPtr2 + 0x80; while (numPtr2 < numPtr3) { numPtr2[0] |= -2147450880; int* numPtr1 = numPtr2 + 1; numPtr1[0] |= -2147450880; int* numPtr9 = numPtr2 + 2; numPtr9[0] |= -2147450880; int* numPtr10 = numPtr2 + 3; numPtr10[0] |= -2147450880; numPtr2 += 4; } } else { hue.CopyPixels((void*) numRef2, (void*) numPtr, 0x100); } Frames frames = new Frames { FrameCount = num3, FrameList = new Frame[num3] }; for (int i = 0; i < num3; i++) { int num6 = (numRef2 + 0x204)[i << 2]; byte* numPtr4 = (numRef2 + 0x200) + num6; short* numPtr5 = (short*) numPtr4; int num7 = numPtr5[0]; int num8 = numPtr5[1]; int width = numPtr5[2]; int height = numPtr5[3]; numPtr4 += 8; frames.FrameList[i] = new Frame(); frames.FrameList[i].CenterX = num7; frames.FrameList[i].CenterY = num8; if ((width <= 0) || (height <= 0)) { frames.FrameList[i].Image = Texture.Empty; } else { Texture texture = new Texture(width, height, true); if (texture.IsEmpty()) { frames.FrameList[i].Image = Texture.Empty; } else { int num11 = 0; short* numPtr6 = null; int num12 = num7 - 0x200; int num13 = (num8 + height) - 0x200; LockData data = texture.Lock(LockFlags.WriteOnly); short* pvSrc = (short*) data.pvSrc; int num14 = data.Pitch >> 1; pvSrc += num12; pvSrc += num13 * num14; while ((num11 = *((int*) numPtr4)) != 0x7fff7fff) { numPtr4 += 4; num11 ^= -2145386496; numPtr6 = pvSrc + ((((num11 >> 12) & 0x3ff) * num14) + ((num11 >> 0x16) & 0x3ff)); short* numPtr8 = numPtr6 + (num11 & 0xffc); while (numPtr6 < numPtr8) { numPtr6[0] = numPtr[numPtr4[0]]; numPtr6[1] = numPtr[numPtr4[1]]; numPtr6[2] = numPtr[numPtr4[2]]; numPtr6[3] = numPtr[numPtr4[3]]; numPtr6 += 4; numPtr4 += 4; } switch ((num11 & 3)) { case 1: goto Label_04A6; case 2: break; case 3: numPtr6[2] = numPtr[numPtr4[2]]; break; default: goto Label_04B5; } numPtr6[1] = numPtr[numPtr4[1]]; Label_04A6: numPtr6[0] = numPtr[numPtr4[0]]; Label_04B5: numPtr4 += num11 & 3; } texture.Unlock(); texture.SetPriority(0); frames.FrameList[i].Image = texture; } } } this.m_Frames.Add(frames); return frames; } } }
private static unsafe CursorEntry LoadCursor(int idCursor, int idType) { int num; IHue hue; switch (idType) { case 0: hue = Hues.Default; num = 0x606a + idCursor; break; case 1: hue = Hues.Default; num = 0x6053 + idCursor; break; case 2: hue = Hues.Load(0x896d); num = 0x606a + idCursor; break; default: return(null); } Texture item = hue.GetItem(num); if ((item == null) || item.IsEmpty()) { return(new CursorEntry(0, 0, 0, 0, Texture.Empty)); } if (item.m_Factory != null) { item.m_Factory.Remove(item); item.m_Factory = null; item.m_FactoryArgs = null; } int xOffset = 0; int yOffset = 0; if (idType < 2) { LockData data = item.Lock(LockFlags.ReadWrite); int width = data.Width; int height = data.Height; int num6 = data.Pitch >> 1; short * pvSrc = (short *)data.pvSrc; short * numPtr2 = (short *)(data.pvSrc + (((height - 1) * num6) * 2)); for (int i = 0; i < width; i++) { if ((pvSrc[0] & 0x7fff) == 0x3e0) { xOffset = i; } pvSrc++; pvSrc[0] = 0; numPtr2++; numPtr2[0] = 0; } pvSrc = (short *)data.pvSrc; numPtr2 = (short *)(data.pvSrc + ((width - 1) * 2)); for (int j = 0; j < height; j++) { if ((pvSrc[0] & 0x7fff) == 0x3e0) { yOffset = j; } pvSrc[0] = 0; numPtr2[0] = 0; pvSrc += num6; numPtr2 += num6; } item.Unlock(); } else { CursorEntry entry = m_Cursors[idCursor, 1]; if (entry == null) { entry = m_Cursors[idCursor, 0]; if (entry == null) { entry = m_Cursors[idCursor, 1] = LoadCursor(idCursor, 1); } } xOffset = entry.m_xOffset; yOffset = entry.m_yOffset; LockData data2 = item.Lock(LockFlags.ReadWrite); int num9 = data2.Width; int num10 = data2.Height; int num11 = data2.Pitch >> 1; short * numPtr3 = (short *)data2.pvSrc; short * numPtr4 = (short *)(data2.pvSrc + (((num10 - 1) * num11) * 2)); for (int k = 0; k < num9; k++) { numPtr3++; numPtr3[0] = 0; numPtr4++; numPtr4[0] = 0; } numPtr3 = (short *)data2.pvSrc; numPtr4 = (short *)(data2.pvSrc + ((num9 - 1) * 2)); for (int m = 0; m < num10; m++) { numPtr3[0] = 0; numPtr4[0] = 0; numPtr3 += num11; numPtr4 += num11; } item.Unlock(); } return(new CursorEntry(idCursor, idType, xOffset, yOffset, item)); }
unsafe Texture IFontFactory.CreateInstance(string text, IHue hue) { int num; char ch; FontImage image; if ((text == null) || (text.Length <= 0)) { return Texture.Empty; } int yHeight = 0; int num3 = 0; int width = 0; int height = 1; char[] chArray = text.ToCharArray(); for (num = 0; num < chArray.Length; num++) { ch = chArray[num]; if ((ch >= ' ') && (ch < 'Ā')) { image = this.m_Images[ch - ' ']; num3 += image.xWidth; if (num3 > width) { width = num3; } if (image.yHeight > yHeight) { yHeight = image.yHeight; } } else if (ch == '\n') { num3 = 0; height++; } } height *= yHeight; if ((width <= 0) || (height <= 0)) { return Texture.Empty; } Texture texture = new Texture(width, height, false); if (texture.IsEmpty()) { return Texture.Empty; } short[] numArray = new short[this.m_Palette.Length]; fixed (short* numRef = numArray) { fixed (short* numRef2 = this.m_Palette) { hue.CopyPixels((void*) (numRef2 + 1), (void*) (numRef + 1), this.m_Palette.Length - 1); } LockData data = texture.Lock(LockFlags.WriteOnly); short* pvSrc = (short*) data.pvSrc; short* numPtr2 = pvSrc; int num6 = data.Pitch >> 1; int num7 = num6 * yHeight; for (num = 0; num < chArray.Length; num++) { ch = chArray[num]; if ((ch >= ' ') && (ch < 'Ā')) { image = this.m_Images[ch - ' ']; int xWidth = image.xWidth; int num11 = image.yHeight; short* numPtr3 = numPtr2; numPtr3 += (yHeight - num11) * num6; int num8 = num6 - xWidth; int num9 = image.xDelta - xWidth; fixed (byte* numRef3 = image.xyPixels) { byte* numPtr4 = numRef3; int num12 = 0; while (num12 < num11) { int num13 = xWidth >> 2; int num14 = xWidth & 3; while (--num13 >= 0) { numPtr3[0] = numRef[numPtr4[0]]; numPtr3[1] = numRef[numPtr4[1]]; numPtr3[2] = numRef[numPtr4[2]]; numPtr3[3] = numRef[numPtr4[3]]; numPtr3 += 4; numPtr4 += 4; } while (--num14 >= 0) { numPtr3++; numPtr3[0] = numRef[*(numPtr4++)]; } num12++; numPtr3 += num8; numPtr4 += num9; } } numPtr2 += image.xWidth; } else if (ch == '\n') { pvSrc += num7; numPtr2 = pvSrc; } } texture.Unlock(); return texture; } }
public unsafe object Create(int realID, IHue hue) { int length; int lookup; int num3; Stream stream; switch (this.ConvertRealID(ref realID)) { case 1: { if (((realID < 0) || (realID >= this.m_Count)) || (realID >= this.m_Index.Length)) { return(Frames.Empty); } Entry3D entryd = this.m_Index[realID]; length = entryd.m_Length; lookup = entryd.m_Lookup; num3 = entryd.m_Extra & 0xff; stream = m_Stream; break; } case 2: { if (((realID < 0) || (realID >= this.m_Count2)) || (realID >= this.m_Index2.Length)) { return(Frames.Empty); } Entry3D entryd2 = this.m_Index2[realID]; length = entryd2.m_Length; lookup = entryd2.m_Lookup; num3 = entryd2.m_Extra & 0xff; stream = m_Stream2; break; } case 3: { if (((realID < 0) || (realID >= this.m_Count3)) || (realID >= this.m_Index3.Length)) { return(Frames.Empty); } Entry3D entryd3 = this.m_Index3[realID]; length = entryd3.m_Length; lookup = entryd3.m_Lookup; num3 = entryd3.m_Extra & 0xff; stream = m_Stream3; break; } default: { if (((realID < 0) || (realID >= this.m_Count4)) || (realID >= this.m_Index4.Length)) { return(Frames.Empty); } Entry3D entryd4 = this.m_Index4[realID]; length = entryd4.m_Length; lookup = entryd4.m_Lookup; num3 = entryd4.m_Extra & 0xff; stream = m_Stream4; break; } } if (((lookup < 0) || (length <= 0)) || ((num3 <= 0) || (stream == null))) { return(Frames.Empty); } if ((this.m_Data == null) || (length > this.m_Data.Length)) { this.m_Data = new byte[length]; } stream.Seek((long)lookup, SeekOrigin.Begin); stream.Read(this.m_Data, 0, length); fixed(short *numRef = this.m_Palette) { short *numPtr = numRef; fixed(byte *numRef2 = this.m_Data) { if (hue.HueID() == 0) { numPtr = (short *)numRef2; int *numPtr2 = (int *)numPtr; int *numPtr3 = numPtr2 + 0x80; while (numPtr2 < numPtr3) { numPtr2[0] |= -2147450880; int *numPtr1 = numPtr2 + 1; numPtr1[0] |= -2147450880; int *numPtr9 = numPtr2 + 2; numPtr9[0] |= -2147450880; int *numPtr10 = numPtr2 + 3; numPtr10[0] |= -2147450880; numPtr2 += 4; } } else { hue.CopyPixels((void *)numRef2, (void *)numPtr, 0x100); } Frames frames = new Frames { FrameCount = num3, FrameList = new Frame[num3] }; for (int i = 0; i < num3; i++) { int num6 = (numRef2 + 0x204)[i << 2]; byte * numPtr4 = (numRef2 + 0x200) + num6; short *numPtr5 = (short *)numPtr4; int num7 = numPtr5[0]; int num8 = numPtr5[1]; int width = numPtr5[2]; int height = numPtr5[3]; numPtr4 += 8; frames.FrameList[i] = new Frame(); frames.FrameList[i].CenterX = num7; frames.FrameList[i].CenterY = num8; if ((width <= 0) || (height <= 0)) { frames.FrameList[i].Image = Texture.Empty; } else { Texture texture = new Texture(width, height, true); if (texture.IsEmpty()) { frames.FrameList[i].Image = Texture.Empty; } else { int num11 = 0; short * numPtr6 = null; int num12 = num7 - 0x200; int num13 = (num8 + height) - 0x200; LockData data = texture.Lock(LockFlags.WriteOnly); short * pvSrc = (short *)data.pvSrc; int num14 = data.Pitch >> 1; pvSrc += num12; pvSrc += num13 * num14; while ((num11 = *((int *)numPtr4)) != 0x7fff7fff) { numPtr4 += 4; num11 ^= -2145386496; numPtr6 = pvSrc + ((((num11 >> 12) & 0x3ff) * num14) + ((num11 >> 0x16) & 0x3ff)); short *numPtr8 = numPtr6 + (num11 & 0xffc); while (numPtr6 < numPtr8) { numPtr6[0] = numPtr[numPtr4[0]]; numPtr6[1] = numPtr[numPtr4[1]]; numPtr6[2] = numPtr[numPtr4[2]]; numPtr6[3] = numPtr[numPtr4[3]]; numPtr6 += 4; numPtr4 += 4; } switch ((num11 & 3)) { case 1: goto Label_04A6; case 2: break; case 3: numPtr6[2] = numPtr[numPtr4[2]]; break; default: goto Label_04B5; } numPtr6[1] = numPtr[numPtr4[1]]; Label_04A6: numPtr6[0] = numPtr[numPtr4[0]]; Label_04B5: numPtr4 += num11 & 3; } texture.Unlock(); texture.SetPriority(0); frames.FrameList[i].Image = texture; } } } this.m_Frames.Add(frames); return(frames); } } }
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(); }