| 42 | } |
| 43 | |
| 44 | void DS1::loadLayerStreams(Streams::StreamReader &sr) { |
| 45 | static const std::vector dirLookup = {0x00, 0x01, 0x02, 0x01, 0x02, 0x03, 0x03, 0x05, 0x05, 0x06, |
| 46 | 0x06, 0x07, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, |
| 47 | 0x0F, 0x10, 0x11, 0x12, 0x14}; |
| 48 | |
| 49 | for (const auto layerStreamTypes = getLayerStreamTypes(); const auto &layerStreamType : layerStreamTypes) { |
| 50 | for (auto y = 0; y < height; y++) { |
| 51 | for (auto x = 0; x < width; x++) { |
| 52 | const auto prop1 = sr.readUInt8(); |
| 53 | const auto prop2 = sr.readUInt8(); |
| 54 | const auto prop3 = sr.readUInt8(); |
| 55 | const auto prop4 = sr.readUInt8(); |
| 56 | |
| 57 | switch (layerStreamType) { |
| 58 | case LayerStreamType::Wall1: |
| 59 | case LayerStreamType::Wall2: |
| 60 | case LayerStreamType::Wall3: |
| 61 | case LayerStreamType::Wall4: { |
| 62 | const auto wallIndex = static_cast<int>(layerStreamType) - static_cast<int>(LayerStreamType::Wall1); |
| 63 | layers.wall[wallIndex][x + y * width].decode(prop1, prop2, prop3, prop4); |
| 64 | } |
| 65 | break; |
| 66 | case LayerStreamType::Orientation1: |
| 67 | case LayerStreamType::Orientation2: |
| 68 | case LayerStreamType::Orientation3: |
| 69 | case LayerStreamType::Orientation4: { |
| 70 | constexpr uint32_t wallTypeBitmask = 0x000000FF; |
| 71 | const auto wallIndex = static_cast<int>(layerStreamType) - static_cast<int>(LayerStreamType::Orientation1); |
| 72 | auto c = prop1; |
| 73 | if (version < 7 && c < dirLookup.size()) |
| 74 | c = dirLookup[c]; |
| 75 | auto &tile = layers.wall[wallIndex][x + y * width]; |
| 76 | tile.type = static_cast<TileType>(c); |
| 77 | // Zero field |
| 78 | } |
| 79 | break; |
| 80 | case LayerStreamType::Floor1: |
| 81 | case LayerStreamType::Floor2: { |
| 82 | const auto floorIndex = static_cast<int>(layerStreamType) - static_cast<int>(LayerStreamType::Floor1); |
| 83 | layers.floor[floorIndex][x + y * width].decode(prop1, prop2, prop3, prop4); |
| 84 | } |
| 85 | break; |
| 86 | case LayerStreamType::Shadow: |
| 87 | layers.shadow[0][x + y * width].decode(prop1, prop2, prop3, prop4); |
| 88 | break; |
| 89 | case LayerStreamType::Substitution: |
| 90 | layers.substitution[0][x + y * width].decode(prop1, prop2, prop3, prop4); |
| 91 | break; |
| 92 | } |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | std::vector<LayerStreamType> DS1::getLayerStreamTypes() const { |
| 99 | if (version < 4) { |