FIXME: move to centralized data code
| 115 | |
| 116 | // FIXME: move to centralized data code |
| 117 | bool CMultiMap::LoadFacet(CGumpMap *gump, CGUIExternalTexture *mapObject, int facet) |
| 118 | { |
| 119 | if (facet < 0 || facet > 5) |
| 120 | { |
| 121 | Warning(Data, "Invalid facet index: %i", facet); |
| 122 | return false; |
| 123 | } |
| 124 | |
| 125 | auto &file = g_FileManager.m_FacetMul[facet]; |
| 126 | file.ResetPtr(); |
| 127 | if (file.Size == 0u) |
| 128 | { |
| 129 | Warning(Data, "Facet %i is not loaded!", facet); |
| 130 | return false; |
| 131 | } |
| 132 | |
| 133 | const int _mapWidth = file.ReadInt16LE(); |
| 134 | (void)_mapWidth; |
| 135 | int mapHeight = file.ReadInt16LE(); |
| 136 | int startX = gump->StartX; |
| 137 | int endX = gump->EndX; |
| 138 | int startY = gump->StartY; |
| 139 | int endY = gump->EndY; |
| 140 | int width = endX - startX; |
| 141 | int height = endY - startY; |
| 142 | std::vector<uint16_t> map(width * height); |
| 143 | for (int y = 0; y < mapHeight; y++) |
| 144 | { |
| 145 | int x = 0; |
| 146 | int colorCount = file.ReadInt32LE() / 3; |
| 147 | for (int i = 0; i < colorCount; i++) |
| 148 | { |
| 149 | int size = file.ReadUInt8(); |
| 150 | uint16_t color = 0x8000 | file.ReadInt16LE(); |
| 151 | for (int j = 0; j < size; j++) |
| 152 | { |
| 153 | if ((x >= startX && x < endX) && (y >= startY && y < endY)) |
| 154 | { |
| 155 | map[((y - startY) * width) + (x - startX)] = color; |
| 156 | } |
| 157 | x++; |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 | assert(mapObject->m_Sprite != nullptr); |
| 162 | mapObject->m_Sprite->LoadSprite16(gump->Width, gump->Height, map.data()); |
| 163 | //mapObject->m_Sprite->Width = gump->Width; |
| 164 | //mapObject->m_Sprite->Height = gump->Height; |
| 165 | return true; |
| 166 | } |
no test coverage detected