public ModuleFieldLayout( EcmaModule module, StaticsBlock gcStatics, StaticsBlock nonGcStatics, StaticsBlock threadGcStatics, StaticsBlock threadNonGcStatics, IReadOnlyDictionary <TypeDefinitionHandle, OffsetsForType> typeOffsets) { Module = module; GcStatics = gcStatics; NonGcStatics = nonGcStatics; ThreadGcStatics = threadGcStatics; ThreadNonGcStatics = threadNonGcStatics; TypeOffsets = typeOffsets; _genericTypeToFieldMap = new Dictionary <DefType, FieldAndOffset[]>(); }
public static void LoadMap(int i) { int mapblocksize = Marshal.SizeOf <MapBlock>(); int staticidxblocksize = Marshal.SizeOf <StaidxBlock>(); int staticblocksize = Marshal.SizeOf <StaticsBlock>(); int width = MapBlocksSize[i][0]; int height = MapBlocksSize[i][1]; int maxblockcount = width * height; BlockData[i] = new IndexMap[maxblockcount]; UOFile file = _filesMap[i]; UOFile fileidx = _filesIdxStatics[i]; UOFile staticfile = _filesStatics[i]; ulong staticidxaddress = (ulong)fileidx.StartAddress; ulong endstaticidxaddress = staticidxaddress + (ulong)fileidx.Length; ulong staticaddress = (ulong)staticfile.StartAddress; ulong endstaticaddress = staticaddress + (ulong)staticfile.Length; ulong mapddress = (ulong)file.StartAddress; ulong endmapaddress = mapddress + (ulong)file.Length; ulong uopoffset = 0; int fileNumber = -1; bool isuop = file is UOFileUop; for (int block = 0; block < maxblockcount; block++) { ulong realmapaddress = 0, realstaticaddress = 0; uint realstaticcount = 0; int blocknum = block; if (isuop) { blocknum &= 4095; int shifted = block >> 12; if (fileNumber != shifted) { fileNumber = shifted; if (shifted < file.Entries.Length) { uopoffset = (ulong)file.Entries[shifted].Offset; } } } ulong address = mapddress + uopoffset + (ulong)(blocknum * mapblocksize); if (address < endmapaddress) { realmapaddress = address; } ulong stidxaddress = staticidxaddress + (ulong)(block * staticidxblocksize); StaidxBlock bb = fileidx.ReadStruct <StaidxBlock>(block * staticidxblocksize); if (stidxaddress < endstaticidxaddress && bb.Size > 0 && bb.Position != 0xFFFFFFFF) { ulong address1 = staticaddress + bb.Position; if (address1 < endstaticaddress) { StaticsBlock sss = staticfile.ReadStruct <StaticsBlock>(bb.Position); realstaticaddress = address1; realstaticcount = (uint)(bb.Size / staticblocksize); if (realstaticcount > 1024) { realstaticcount = 1024; } } } BlockData[i][block] = new IndexMap { OriginalMapAddress = realmapaddress, OriginalStaticAddress = realstaticaddress, OriginalStaticCount = realstaticcount, MapAddress = realmapaddress, StaticAddress = realstaticaddress, StaticCount = realstaticcount }; } }
private unsafe void Load() { int size = IO.Resources.Map.MapsDefaultSize[World.MapIndex][0] * IO.Resources.Map.MapsDefaultSize[World.MapIndex][1]; ushort[] buffer = new ushort[size]; int maxBlock = size - 1; for (int bx = 0; bx < IO.Resources.Map.MapBlocksSize[World.MapIndex][0]; bx++) { int mapX = bx * 8; for (int by = 0; by < IO.Resources.Map.MapBlocksSize[World.MapIndex][1]; by++) { IndexMap indexMap = World.Map.GetIndex(bx, by); if (indexMap.MapAddress == 0) { continue; } int mapY = by * 8; MapBlock info = new MapBlock(); MapCells *infoCells = (MapCells *)&info.Cells; MapBlock *mapBlock = (MapBlock *)indexMap.MapAddress; MapCells *cells = (MapCells *)&mapBlock->Cells; int pos = 0; for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { ref MapCells cell = ref cells[pos]; ref MapCells infoCell = ref infoCells[pos]; infoCell.TileID = cell.TileID; infoCell.Z = cell.Z; pos++; } } StaticsBlock *sb = (StaticsBlock *)indexMap.StaticAddress; if (sb != null) { int count = (int)indexMap.StaticCount; for (int c = 0; c < count; c++) { StaticsBlock staticBlock = sb[c]; if (staticBlock.Color > 0 && staticBlock.Color != 0xFFFF && !View.IsNoDrawable(staticBlock.Color)) { pos = staticBlock.Y * 8 + staticBlock.X; ref MapCells cell = ref infoCells[pos]; if (cell.Z <= staticBlock.Z) { cell.TileID = (ushort)(staticBlock.Color + 0x4000); cell.Z = staticBlock.Z; } } } }
private unsafe void CreateMiniMapTexture(bool force = false) { if (_gumpTexture == null || _gumpTexture.IsDisposed) { return; } ushort lastX = World.Player.X; ushort lastY = World.Player.Y; if (_x != lastX || _y != lastY) { _x = lastX; _y = lastY; } else if (!force) { return; } int blockOffsetX = Width >> 2; int blockOffsetY = Height >> 2; int gumpCenterX = Width >> 1; //int gumpCenterY = Height >> 1; //0xFF080808 - pixel32 //0x8421 - pixel16 int minBlockX = ((lastX - blockOffsetX) >> 3) - 1; int minBlockY = ((lastY - blockOffsetY) >> 3) - 1; int maxBlockX = ((lastX + blockOffsetX) >> 3) + 1; int maxBlockY = ((lastY + blockOffsetY) >> 3) + 1; if (minBlockX < 0) { minBlockX = 0; } if (minBlockY < 0) { minBlockY = 0; } int maxBlockIndex = World.Map.BlocksCount; int mapBlockHeight = MapLoader.Instance.MapBlocksSize[World.MapIndex, 1]; int index = _useLargeMap ? 1 : 0; _blankGumpsPixels[index].CopyTo(_blankGumpsPixels[index + 2], 0); uint[] data = _blankGumpsPixels[index + 2]; Point *table = stackalloc Point[2]; table[0].X = 0; table[0].Y = 0; table[1].X = 0; table[1].Y = 1; for (int i = minBlockX; i <= maxBlockX; i++) { int blockIndexOffset = i * mapBlockHeight; for (int j = minBlockY; j <= maxBlockY; j++) { int blockIndex = blockIndexOffset + j; if (blockIndex >= maxBlockIndex) { break; } ref IndexMap indexMap = ref World.Map.GetIndex(i, j); if (indexMap.MapAddress == 0) { break; } MapBlock * mp = (MapBlock *)indexMap.MapAddress; MapCells * cells = (MapCells *)&mp->Cells; StaticsBlock *sb = (StaticsBlock *)indexMap.StaticAddress; uint staticCount = indexMap.StaticCount; Chunk block = World.Map.GetChunk(blockIndex); int realBlockX = i << 3; int realBlockY = j << 3; for (int x = 0; x < 8; x++) { int px = realBlockX + x - lastX + gumpCenterX; for (int y = 0; y < 8; y++) { ref MapCells cell = ref cells[(y << 3) + x]; int color = cell.TileID; bool isLand = true; int z = cell.Z; for (int c = 0; c < staticCount; ++c) { ref StaticsBlock stblock = ref sb[c]; if (stblock.X == x && stblock.Y == y && stblock.Color > 0 && stblock.Color != 0xFFFF && GameObject.CanBeDrawn(stblock.Color)) { if (stblock.Z >= z) { color = stblock.Hue > 0 ? (ushort)(stblock.Hue + 0x4000) : stblock.Color; isLand = stblock.Hue > 0; z = stblock.Z; } } } if (block != null) { GameObject obj = block.Tiles[x, y]; while (obj?.TNext != null) { obj = obj.TNext; } for (; obj != null; obj = obj.TPrevious) { if (obj is Multi) { if (obj.Hue == 0) { color = obj.Graphic; isLand = false; } else { color = obj.Hue + 0x4000; } break; } } } if (!isLand) { color += 0x4000; } int tableSize = 2; if (isLand && color > 0x4000) { color = HuesLoader.Instance.GetColor16(16384, (ushort)(color - 0x4000)); //28672 is an arbitrary position in hues.mul, is the 14 position in the range } else { color = HuesLoader.Instance.GetRadarColorData(color); } int py = realBlockY + y - lastY; int gx = px - py; int gy = px + py; CreatePixels ( data, 0x8000 | color, gx, gy, Width, Height, table, tableSize ); } }