| 6 | |
| 7 | namespace Abyss::MapEngine { |
| 8 | MapEngine::MapEngine(const int width, const int height, std::vector<DataTypes::DT1> dt1s, std::vector<DataTypes::DS1> ds1s) |
| 9 | : _width(width), _height(height), _dt1s(std::move(dt1s)), _ds1s(std::move(ds1s)) { |
| 10 | |
| 11 | std::vector<std::future<void>> futures; |
| 12 | |
| 13 | futures.reserve(_ds1s.size()); |
| 14 | |
| 15 | for (auto &ds1 : _ds1s) |
| 16 | futures.emplace_back(std::async(std::launch::async, [&ds1, this]() { ds1.bindTileReferences(_dt1s); })); |
| 17 | |
| 18 | for (auto &future : futures) |
| 19 | future.wait(); |
| 20 | |
| 21 | auto maxFloors = 0; |
| 22 | auto maxWalls = 0; |
| 23 | auto maxShadows = 0; |
| 24 | auto maxSubstitutions = 0; |
| 25 | |
| 26 | for (const auto &ds1 : _ds1s) { |
| 27 | maxFloors = std::max(maxFloors, static_cast<int>(ds1.layers.floor.size())); |
| 28 | maxWalls = std::max(maxWalls, static_cast<int>(ds1.layers.wall.size())); |
| 29 | maxShadows = std::max(maxShadows, static_cast<int>(ds1.layers.shadow.size())); |
| 30 | maxSubstitutions = std::max(maxSubstitutions, static_cast<int>(ds1.layers.substitution.size())); |
| 31 | } |
| 32 | |
| 33 | _layers.floor.resize(maxFloors); |
| 34 | _layers.wall.resize(maxWalls); |
| 35 | _layers.shadow.resize(maxShadows); |
| 36 | _layers.substitution.resize(maxSubstitutions); |
| 37 | |
| 38 | const int cellCount = _width * _height; |
| 39 | for (auto &layer : _layers.floor) |
| 40 | layer.resize(cellCount); |
| 41 | for (auto &layer : _layers.wall) |
| 42 | layer.resize(cellCount); |
| 43 | for (auto &layer : _layers.shadow) |
| 44 | layer.resize(cellCount); |
| 45 | for (auto &layer : _layers.substitution) |
| 46 | layer.resize(cellCount); |
| 47 | } |
| 48 | |
| 49 | void MapEngine::stampDs1(const uint32_t ds1Index, const int originX, const int originY) { |
| 50 | const auto &ds1 = _ds1s[ds1Index]; |
nothing calls this directly
no test coverage detected