1 /// Old Isodi tilemap loading code, for compatibility. 2 module isodi.tilemap_legacy; 3 4 import std.conv; 5 import std.algorithm; 6 import std.exception; 7 8 import rcdata.bin; 9 10 import isodi.tilemap; 11 import isodi.exception; 12 13 14 @safe: 15 16 17 18 19 /// Magic bytes 20 private immutable int leet = 0x150D1; 21 22 private struct EntryCell { 23 24 ulong cellID; 25 float height; 26 float depth; 27 28 } 29 30 private struct Entry { 31 32 // Each entry starts with its starting position 33 int x; 34 int y; 35 int layer; 36 37 // Then followed by a list of cells (expanding towards positive X) 38 // Cell under index 0 will be placed under the same position as the entry 39 EntryCell[] cells; 40 41 } 42 43 void parseVersion0(T)(T bin, ref LoadTilemap loader) @trusted { 44 45 // Load declarations 46 loader.onDeclarations(bin.read!(string[]), 1000); 47 48 // Load entries 49 // rcdata.bin could get support for reading as ranges probably 50 auto size = bin.read!ulong; 51 52 foreach (index; 0..size) { 53 54 auto entry = bin.read!Entry; 55 loader.onEntry(entry.x, entry.y, entry.layer); 56 57 // Load each cell 58 foreach (cell; entry.cells) { 59 60 loader.onBlock(cell.cellID, to!int(cell.height * 1000), to!int(cell.depth * 1000)); 61 62 } 63 64 } 65 66 }