* Load an old fashioned GRF file to replace already loaded sprites. * @param filename The name of the file to open. * @param index_tbl The offsets of each of the sprites. * @param needs_palette_remap Whether the colours in the GRF file need a palette remap. * @return The number of loaded sprites. */
| 80 | * @return The number of loaded sprites. |
| 81 | */ |
| 82 | static void LoadGrfFileIndexed(const std::string &filename, std::span<const std::pair<SpriteID, SpriteID>> index_tbl, bool needs_palette_remap) |
| 83 | { |
| 84 | uint sprite_id = 0; |
| 85 | |
| 86 | SpriteFile &file = OpenCachedSpriteFile(filename, BASESET_DIR, needs_palette_remap); |
| 87 | |
| 88 | Debug(sprite, 2, "Reading indexed grf-file '{}'", filename); |
| 89 | |
| 90 | uint8_t container_ver = file.GetContainerVersion(); |
| 91 | if (container_ver == 0) UserError("Base grf '{}' is corrupt", filename); |
| 92 | ReadGRFSpriteOffsets(file); |
| 93 | if (container_ver >= 2) { |
| 94 | /* Read compression. */ |
| 95 | uint8_t compression = file.ReadByte(); |
| 96 | if (compression != 0) UserError("Unsupported compression format"); |
| 97 | } |
| 98 | |
| 99 | for (const auto &pair : index_tbl) { |
| 100 | for (SpriteID load_index = pair.first; load_index <= pair.second; ++load_index) { |
| 101 | [[maybe_unused]] bool b = LoadNextSprite(load_index, file, sprite_id); |
| 102 | assert(b); |
| 103 | sprite_id++; |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Checks whether the MD5 checksums of the files are correct. |
no test coverage detected