| 9 | { |
| 10 | |
| 11 | void InitialGameStateExtractor::extractBaseLayouts(GameState &state) const |
| 12 | { |
| 13 | auto &data = this->ufo2p; |
| 14 | for (unsigned i = 0; i < data.baselayouts->count(); i++) |
| 15 | { |
| 16 | UString id = format("%s%d", BaseLayout::getPrefix(), i); |
| 17 | auto layout = mksp<BaseLayout>(); |
| 18 | auto b = data.baselayouts->get(i); |
| 19 | bool foundLift = false; |
| 20 | for (int row = 0; row < 8; row++) |
| 21 | { |
| 22 | for (int col = 0; col < 8; col++) |
| 23 | { |
| 24 | switch (b.module[row][col]) |
| 25 | { |
| 26 | case 0: |
| 27 | // 0 == ground |
| 28 | break; |
| 29 | case 1: |
| 30 | // 1 == corridor |
| 31 | { |
| 32 | layout->baseCorridors.emplace(col, row, col + 1, row + 1); |
| 33 | break; |
| 34 | } |
| 35 | case 2: |
| 36 | { |
| 37 | if (foundLift) |
| 38 | { |
| 39 | LogError("Unexpected repeated lift at position {%d,%d} in base %s", row, |
| 40 | col, id); |
| 41 | } |
| 42 | foundLift = true; |
| 43 | layout->baseLift = {col, row}; |
| 44 | // We see 'corridors' as the base bounds, and the access |
| 45 | // lift should be within that, so mark that as a 'corridor' |
| 46 | // with an access lift built on top |
| 47 | layout->baseCorridors.emplace(col, row, col + 1, row + 1); |
| 48 | break; |
| 49 | } |
| 50 | default: |
| 51 | LogError("Unexpected module id %d at {%d,%d} in base %s", |
| 52 | (int)b.module[row][col], col, row, id); |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | if (!foundLift) |
| 57 | { |
| 58 | LogError("No lift found in base %s", id); |
| 59 | } |
| 60 | Rect<int>::compactRectSet(layout->baseCorridors); |
| 61 | state.base_layouts[id] = layout; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | } // namespace OpenApoc |
no test coverage detected