0x0046CD31
| 812 | |
| 813 | // 0x0046CD31 |
| 814 | static void setMapPixelsOwnership(PaletteIndex_t* mapPtr, PaletteIndex_t* mapAltPtr, Pos2 pos, Pos2 delta) |
| 815 | { |
| 816 | for (auto rowCountLeft = kMapColumns; rowCountLeft > 0; rowCountLeft--) |
| 817 | { |
| 818 | // Coords shouldn't be at map edge |
| 819 | if (!(pos.x > 0 && pos.y > 0 && pos.x < kMapWidth - kTileSize && pos.y < kMapHeight - kTileSize)) |
| 820 | { |
| 821 | pos += delta; |
| 822 | mapPtr += kRenderedMapWidth + 1; |
| 823 | mapAltPtr += kRenderedMapWidth + 1; |
| 824 | continue; |
| 825 | } |
| 826 | |
| 827 | bool haveTrackOrRoad = false; // ch |
| 828 | PaletteIndex_t colourFlash0{}, colourFlash1{}, colour0{}, colour1{}; |
| 829 | auto tile = TileManager::get(pos); |
| 830 | for (auto& el : tile) |
| 831 | { |
| 832 | switch (el.type()) |
| 833 | { |
| 834 | case ElementType::surface: |
| 835 | { |
| 836 | auto* surfaceEl = el.as<SurfaceElement>(); |
| 837 | if (surfaceEl == nullptr) |
| 838 | { |
| 839 | continue; |
| 840 | } |
| 841 | |
| 842 | uint8_t terrainColour0{}, terrainColour1{}; |
| 843 | if (surfaceEl->water() == 0) |
| 844 | { |
| 845 | const auto* landObj = ObjectManager::get<LandObject>(surfaceEl->terrain()); |
| 846 | const auto* landImage = Gfx::getG1Element(landObj->mapPixelImage); |
| 847 | terrainColour0 = landImage->offset[0]; |
| 848 | terrainColour1 = landImage->offset[1]; |
| 849 | } |
| 850 | else |
| 851 | { |
| 852 | const auto* waterObj = ObjectManager::get<WaterObject>(); |
| 853 | const auto* waterImage = Gfx::getG1Element(waterObj->mapPixelImage); |
| 854 | terrainColour0 = waterImage->offset[0]; |
| 855 | terrainColour1 = waterImage->offset[1]; |
| 856 | } |
| 857 | |
| 858 | colour0 = colourFlash0 = terrainColour0; |
| 859 | if (!haveTrackOrRoad) |
| 860 | { |
| 861 | colour1 = colourFlash1 = terrainColour1; |
| 862 | } |
| 863 | break; |
| 864 | } |
| 865 | |
| 866 | case ElementType::track: |
| 867 | case ElementType::station: |
| 868 | case ElementType::road: |
| 869 | { |
| 870 | if (el.isGhost() || el.isAiAllocated()) |
| 871 | { |
no test coverage detected