/** * Load an old fashioned GRF file to replace already loaded sprites. * @param filename The name of the file to open. * @param index_tlb The offsets of each of the sprites. * @param file_index The Fio offset to load the file in. * @return The number of loaded sprites. */ static void LoadGrfFileIndexed(const char *filename, const SpriteID *index_tbl, int file_index) { uint start; uint sprite_id = 0; FioOpenFile(file_index, filename, BASESET_DIR); DEBUG(sprite, 2, "Reading indexed grf-file '%s'", filename); byte container_ver = GetGRFContainerVersion(); if (container_ver == 0) usererror("Base grf '%s' is corrupt", filename); ReadGRFSpriteOffsets(container_ver); if (container_ver >= 2) { /* Read compression. */ byte compression = FioReadByte(); if (compression != 0) usererror("Unsupported compression format"); } while ((start = *index_tbl++) != END) { uint end = *index_tbl++; do { bool b = LoadNextSprite(start, file_index, sprite_id, container_ver); assert(b); sprite_id++; } while (++start <= end); } }
/** * Load an old fashioned GRF file. * @param filename The name of the file to open. * @param load_index The offset of the first sprite. * @param file_index The Fio offset to load the file in. * @return The number of loaded sprites. */ static uint LoadGrfFile(const char *filename, uint load_index, int file_index) { uint load_index_org = load_index; uint sprite_id = 0; FioOpenFile(file_index, filename, BASESET_DIR); DEBUG(sprite, 2, "Reading grf-file '%s'", filename); byte container_ver = GetGRFContainerVersion(); if (container_ver == 0) usererror("Base grf '%s' is corrupt", filename); ReadGRFSpriteOffsets(container_ver); if (container_ver >= 2) { /* Read compression. */ byte compression = FioReadByte(); if (compression != 0) usererror("Unsupported compression format"); } while (LoadNextSprite(load_index, file_index, sprite_id, container_ver)) { load_index++; sprite_id++; if (load_index >= MAX_SPRITES) { usererror("Too many sprites. Recompile with higher MAX_SPRITES value or remove some custom GRF files."); } } DEBUG(sprite, 2, "Currently %i sprites are loaded", load_index); return load_index - load_index_org; }
/** * Load an old fashioned GRF file to replace already loaded sprites. * @param filename The name of the file to open. * @param index_tlb The offsets of each of the sprites. * @param file_index The Fio offset to load the file in. * @return The number of loaded sprites. */ static void LoadGrfFileIndexed(const char *filename, const SpriteID *index_tbl, int file_index) { uint start; uint sprite_id = 0; FioOpenFile(file_index, filename, BASESET_DIR); DEBUG(sprite, 2, "Reading indexed grf-file '%s'", filename); while ((start = *index_tbl++) != END) { uint end = *index_tbl++; do { bool b = LoadNextSprite(start, file_index, sprite_id); assert(b); sprite_id++; } while (++start <= end); } }
/** * Load an old fashioned GRF file. * @param filename The name of the file to open. * @param load_index The offset of the first sprite. * @param file_index The Fio offset to load the file in. * @return The number of loaded sprites. */ static uint LoadGrfFile(const char *filename, uint load_index, int file_index) { uint load_index_org = load_index; uint sprite_id = 0; FioOpenFile(file_index, filename, BASESET_DIR); DEBUG(sprite, 2, "Reading grf-file '%s'", filename); while (LoadNextSprite(load_index, file_index, sprite_id)) { load_index++; sprite_id++; if (load_index >= MAX_SPRITES) { usererror("Too many sprites. Recompile with higher MAX_SPRITES value or remove some custom GRF files."); } } DEBUG(sprite, 2, "Currently %i sprites are loaded", load_index); return load_index - load_index_org; }