private void LoadMapCellsv0(byte[] fileBytes) { int offSet = 0; Width = BitConverter.ToInt16(fileBytes, offSet); offSet += 2; Height = BitConverter.ToInt16(fileBytes, offSet); Cells = new Cell[Width, Height]; //DoorIndex = new Door[Width, Height]; offSet = 52; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) {//total 12 bool validcell = true; if ((BitConverter.ToInt16(fileBytes, offSet) & 0x8000) != 0) { validcell = false; } offSet += 2; if ((BitConverter.ToInt16(fileBytes, offSet) & 0x8000) != 0) { validcell = false; } offSet += 2; if ((BitConverter.ToInt16(fileBytes, offSet) & 0x8000) != 0) { validcell = false; } offSet += 4; //if (fileBytes[offSet] > 0) // DoorIndex[x, y] = AddDoor(fileBytes[offSet], new Point(x, y)); offSet += 3; byte light = fileBytes[offSet++]; //if (light >= 100 && light <= 119) // Cells[x, y].FishingAttribute = (sbyte)(light - 100); if (validcell) { ValidCells.Add(Cells[x, y] = new Cell(new Point(x, y)) { Map = this }); } } } }
private void LoadMapCellsv1(byte[] fileBytes) { int offSet = 21; int w = BitConverter.ToInt16(fileBytes, offSet); offSet += 2; int xor = BitConverter.ToInt16(fileBytes, offSet); offSet += 2; int h = BitConverter.ToInt16(fileBytes, offSet); Width = w ^ xor; Height = h ^ xor; Cells = new Cell[Width, Height]; //DoorIndex = new Door[Width, Height]; offSet = 54; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { bool validcell = true; if (((BitConverter.ToInt32(fileBytes, offSet) ^ 0xAA38AA38) & 0x20000000) != 0) { validcell = false; } offSet += 6; if (((BitConverter.ToInt16(fileBytes, offSet) ^ xor) & 0x8000) != 0) { validcell = false; } offSet += 2; //if (fileBytes[offSet] > 0) // DoorIndex[x, y] = AddDoor(fileBytes[offSet], new Point(x, y)); offSet += 5; byte light = fileBytes[offSet++]; //if (light >= 100 && light <= 119) // Cells[x, y].FishingAttribute = (sbyte)(light - 100); offSet += 1; if (validcell) { ValidCells.Add(Cells[x, y] = new Cell(new Point(x, y)) { Map = this }); } } } }
private void LoadMapCellsV100(byte[] Bytes) { int offset = 4; if ((Bytes[0] != 1) || (Bytes[1] != 0)) { return; //only support version 1 atm } Width = BitConverter.ToInt16(Bytes, offset); offset += 2; Height = BitConverter.ToInt16(Bytes, offset); Cells = new Cell[Width, Height]; //DoorIndex = new Door[Width, Height]; offset = 8; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { bool validcell = true; offset += 2; if ((BitConverter.ToInt32(Bytes, offset) & 0x20000000) != 0) { validcell = false; } offset += 10; if ((BitConverter.ToInt16(Bytes, offset) & 0x8000) != 0) { validcell = false; } offset += 2; //if (Bytes[offset] > 0) // DoorIndex[x, y] = AddDoor(Bytes[offset], new Point(x, y)); offset += 11; byte light = Bytes[offset++]; //if (light >= 100 && light <= 119) // Cells[x, y].FishingAttribute = (sbyte)(light - 100); if (validcell) { ValidCells.Add(Cells[x, y] = new Cell(new Point(x, y)) { Map = this }); } } } }
private void LoadMapCellsv4(byte[] fileBytes) { int offSet = 31; int w = BitConverter.ToInt16(fileBytes, offSet); offSet += 2; int xor = BitConverter.ToInt16(fileBytes, offSet); offSet += 2; int h = BitConverter.ToInt16(fileBytes, offSet); Width = w ^ xor; Height = h ^ xor; Cells = new Cell[Width, Height]; //DoorIndex = new Door[Width, Height]; offSet = 64; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) {//total 12 bool validcell = true; if ((BitConverter.ToInt16(fileBytes, offSet) & 0x8000) != 0) { validcell = false; } offSet += 2; if ((BitConverter.ToInt16(fileBytes, offSet) & 0x8000) != 0) { validcell = false; } offSet += 4; //if (fileBytes[offSet] > 0) // DoorIndex[x, y] = AddDoor(fileBytes[offSet], new Point(x, y)); offSet += 6; if (validcell) { ValidCells.Add(Cells[x, y] = new Cell(new Point(x, y)) { Map = this }); } } } }
public void Load() { string fileName = $"{Config.MapPath}{Info.FileName}.map"; if (!File.Exists(fileName)) { SEnvir.Log($"Map: {fileName} not found."); return; } byte[] fileBytes = File.ReadAllBytes(fileName); Width = fileBytes[23] << 8 | fileBytes[22]; Height = fileBytes[25] << 8 | fileBytes[24]; Cells = new Cell[Width, Height]; int offSet = 28 + Width * Height / 4 * 3; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { byte flag = fileBytes[offSet + (x * Height + y) * 14]; if ((flag & 0x02) != 2 || (flag & 0x01) != 1) { continue; } ValidCells.Add(Cells[x, y] = new Cell(new Point(x, y)) { Map = this }); } } OrderedObjects = new HashSet <MapObject> [Width]; for (int i = 0; i < OrderedObjects.Length; i++) { OrderedObjects[i] = new HashSet <MapObject>(); } }
private void LoadMapCellsv5(byte[] fileBytes) { int offSet = 22; Width = BitConverter.ToInt16(fileBytes, offSet); offSet += 2; Height = BitConverter.ToInt16(fileBytes, offSet); Cells = new Cell[Width, Height]; //DoorIndex = new Door[Width, Height]; offSet = 28 + (3 * ((Width / 2) + (Width % 2)) * (Height / 2)); for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) {//total 14 bool validcell = true; if ((fileBytes[offSet] & 0x01) != 1) { validcell = false; } else if ((fileBytes[offSet] & 0x02) != 2) { validcell = false; } offSet += 13; byte light = fileBytes[offSet++]; //if (light >= 100 && light <= 119) // Cells[x, y].FishingAttribute = (sbyte)(light - 100); if (validcell) { ValidCells.Add(Cells[x, y] = new Cell(new Point(x, y)) { Map = this }); } } } }
private void LoadMapCellsv6(byte[] fileBytes) { int offSet = 16; Width = BitConverter.ToInt16(fileBytes, offSet); offSet += 2; Height = BitConverter.ToInt16(fileBytes, offSet); Cells = new Cell[Width, Height]; //DoorIndex = new Door[Width, Height]; offSet = 40; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) {//total 20 bool validcell = true; if ((fileBytes[offSet] & 0x01) != 1) { validcell = false; } else if ((fileBytes[offSet] & 0x02) != 2) { validcell = false; } offSet += 20; if (validcell) { ValidCells.Add(Cells[x, y] = new Cell(new Point(x, y)) { Map = this }); } } } }
public void Load() { string fileName = Info.FileName; if (fileName.Contains("|")) { fileName = fileName.Split('|')[1]; } fileName = $"{Config.MapPath}{fileName}.map"; if (!File.Exists(fileName)) { SEnvir.Log($"Map: {fileName} not found."); return; } byte[] fileBytes = File.ReadAllBytes(fileName); int offSet = 0; Width = BitConverter.ToInt16(fileBytes, offSet); offSet += 2; Height = BitConverter.ToInt16(fileBytes, offSet); Cells = new Cell[Width, Height]; //DoorIndex = new Door[Width, Height]; offSet = 52; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) {//total 12 bool isWall = (BitConverter.ToInt16(fileBytes, offSet) & 0x8000) != 0; offSet += 2; if ((BitConverter.ToInt16(fileBytes, offSet) & 0x8000) != 0) { isWall = true; } offSet += 2; if ((BitConverter.ToInt16(fileBytes, offSet) & 0x8000) != 0) { isWall = true; } if (!isWall) { ValidCells.Add(Cells[x, y] = new Cell(new Point(x, y)) { Map = this }); } offSet += 4; //if (fileBytes[offSet] > 0) // DoorIndex[x, y] = AddDoor(fileBytes[offSet], new Point(x, y)); offSet += 3; byte light = fileBytes[offSet++]; //if (light >= 100 && light <= 119) // Cells[x, y].FishingAttribute = (sbyte)(light - 100); } } OrderedObjects = new HashSet <MapObject> [Width]; for (int i = 0; i < OrderedObjects.Length; i++) { OrderedObjects[i] = new HashSet <MapObject>(); } }