* Load a particular NewGRF. * @param config The configuration of the to be loaded NewGRF. * @param stage The loading stage of the NewGRF. * @param subdir The sub directory to find the NewGRF in. * @param temporary The NewGRF/sprite file is to be loaded temporarily and should be closed immediately, * contrary to loading the SpriteFile and having it cached by the
| 1389 | * contrary to loading the SpriteFile and having it cached by the SpriteCache. |
| 1390 | */ |
| 1391 | void LoadNewGRFFile(GRFConfig &config, GrfLoadingStage stage, Subdirectory subdir, bool temporary) |
| 1392 | { |
| 1393 | const std::string &filename = config.filename; |
| 1394 | |
| 1395 | /* A .grf file is activated only if it was active when the game was |
| 1396 | * started. If a game is loaded, only its active .grfs will be |
| 1397 | * reactivated, unless "loadallgraphics on" is used. A .grf file is |
| 1398 | * considered active if its action 8 has been processed, i.e. its |
| 1399 | * action 8 hasn't been skipped using an action 7. |
| 1400 | * |
| 1401 | * During activation, only actions 0, 1, 2, 3, 4, 5, 7, 8, 9, 0A and 0B are |
| 1402 | * carried out. All others are ignored, because they only need to be |
| 1403 | * processed once at initialization. */ |
| 1404 | if (stage != GLS_FILESCAN && stage != GLS_SAFETYSCAN && stage != GLS_LABELSCAN) { |
| 1405 | _cur_gps.grffile = GetFileByFilename(filename); |
| 1406 | if (_cur_gps.grffile == nullptr) UserError("File '{}' lost in cache.\n", filename); |
| 1407 | if (stage == GLS_RESERVE && config.status != GCS_INITIALISED) return; |
| 1408 | if (stage == GLS_ACTIVATION && !config.flags.Test(GRFConfigFlag::Reserved)) return; |
| 1409 | } |
| 1410 | |
| 1411 | bool needs_palette_remap = config.palette & GRFP_USE_MASK; |
| 1412 | if (temporary) { |
| 1413 | SpriteFile temporarySpriteFile(filename, subdir, needs_palette_remap); |
| 1414 | LoadNewGRFFileFromFile(config, stage, temporarySpriteFile); |
| 1415 | } else { |
| 1416 | LoadNewGRFFileFromFile(config, stage, OpenCachedSpriteFile(filename, subdir, needs_palette_remap)); |
| 1417 | } |
| 1418 | } |
| 1419 | |
| 1420 | /** |
| 1421 | * Relocates the old shore sprites at new positions. |
no test coverage detected