| 293 | static_assert(sizeof(struct StratHeader) == 4, "Invalid strat_header size"); |
| 294 | |
| 295 | static sp<PaletteImage> loadStrategy(IFile &file) |
| 296 | { |
| 297 | auto img = mksp<PaletteImage>(Vec2<int>{8, 8}); // All strategy map tiles are 8x8 |
| 298 | unsigned int offset = 0; |
| 299 | |
| 300 | struct StratHeader header; |
| 301 | file.read(reinterpret_cast<char *>(&header), sizeof(header)); |
| 302 | PaletteImageLock region(img); |
| 303 | while (file && header.pixel_skip != 0xffff) |
| 304 | { |
| 305 | unsigned int count = header.count; |
| 306 | offset = header.pixel_skip; |
| 307 | while (file && count--) |
| 308 | { |
| 309 | uint8_t idx = 0; |
| 310 | #define STRIDE 640 |
| 311 | unsigned int x = offset % STRIDE; |
| 312 | unsigned int y = offset / STRIDE; |
| 313 | #undef STRIDE |
| 314 | |
| 315 | file.read(reinterpret_cast<char *>(&idx), 1); |
| 316 | |
| 317 | if (x >= 8 || y >= 8) |
| 318 | { |
| 319 | LogInfo("Writing to {%d,%d} in 8x8 stratmap image", x, y); |
| 320 | } |
| 321 | else |
| 322 | { |
| 323 | region.set(Vec2<int>{x, y}, idx); |
| 324 | } |
| 325 | |
| 326 | offset++; |
| 327 | } |
| 328 | file.read(reinterpret_cast<char *>(&header), sizeof(header)); |
| 329 | } |
| 330 | return img; |
| 331 | } |
| 332 | |
| 333 | sp<ImageSet> PCKLoader::loadStrat(Data &data, UString PckFilename, UString TabFilename) |
| 334 | { |