| 331 | } |
| 332 | |
| 333 | sp<ImageSet> PCKLoader::loadStrat(Data &data, UString PckFilename, UString TabFilename) |
| 334 | { |
| 335 | auto imageSet = mksp<ImageSet>(); |
| 336 | auto tabFile = data.fs.open(TabFilename); |
| 337 | if (!tabFile) |
| 338 | { |
| 339 | LogWarning("Failed to open tab \"%s\"", TabFilename); |
| 340 | return nullptr; |
| 341 | } |
| 342 | auto pckFile = data.fs.open(PckFilename); |
| 343 | if (!pckFile) |
| 344 | { |
| 345 | LogWarning("Failed to open tab \"%s\"", TabFilename); |
| 346 | return nullptr; |
| 347 | } |
| 348 | |
| 349 | uint32_t offset = 0; |
| 350 | unsigned idx = 0; |
| 351 | while (tabFile.read(reinterpret_cast<char *>(&offset), sizeof(offset))) |
| 352 | { |
| 353 | pckFile.seekg(offset, std::ios::beg); |
| 354 | if (!pckFile) |
| 355 | { |
| 356 | LogError("Failed to seek to offset %u", offset); |
| 357 | return nullptr; |
| 358 | } |
| 359 | auto img = loadStrategy(pckFile); |
| 360 | if (!img) |
| 361 | { |
| 362 | LogError("Failed to load image"); |
| 363 | return nullptr; |
| 364 | } |
| 365 | if (img->size != Vec2<unsigned int>{8, 8}) |
| 366 | { |
| 367 | LogError("Invalid size of {%d,%d} in stratmap image", img->size.x, img->size.y); |
| 368 | return nullptr; |
| 369 | } |
| 370 | imageSet->images.push_back(img); |
| 371 | img->owningSet = imageSet; |
| 372 | img->calculateBounds(); |
| 373 | img->indexInSet = idx++; |
| 374 | } |
| 375 | |
| 376 | imageSet->maxSize = {8, 8}; |
| 377 | |
| 378 | LogInfo("Loaded %u images", static_cast<unsigned>(imageSet->images.size())); |
| 379 | |
| 380 | return imageSet; |
| 381 | } |
| 382 | |
| 383 | struct ShadowHeader |
| 384 | { |
nothing calls this directly
no test coverage detected