MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / FiosGetHeightmapListCallback

Function FiosGetHeightmapListCallback

src/fios.cpp:482–520  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

480}
481
482std::tuple<FiosType, std::string> FiosGetHeightmapListCallback(SaveLoadOperation, std::string_view file, std::string_view ext)
483{
484 /* Show heightmap files
485 * .PNG PNG Based heightmap files
486 * .BMP BMP Based heightmap files
487 */
488
489 FiosType type = FIOS_TYPE_INVALID;
490
491#ifdef WITH_PNG
492 if (StrEqualsIgnoreCase(ext, ".png")) type = FIOS_TYPE_PNG;
493#endif /* WITH_PNG */
494
495 if (StrEqualsIgnoreCase(ext, ".bmp")) type = FIOS_TYPE_BMP;
496
497 if (type == FIOS_TYPE_INVALID) return { FIOS_TYPE_INVALID, {} };
498
499 TarFileList::iterator it = _tar_filelist[SCENARIO_DIR].find(file);
500 if (it != _tar_filelist[SCENARIO_DIR].end()) {
501 /* If the file is in a tar and that tar is not in a heightmap
502 * directory we are for sure not supposed to see it.
503 * Examples of this are pngs part of documentation within
504 * collections of NewGRFs or 32 bpp graphics replacement PNGs.
505 */
506 bool match = false;
507 for (Searchpath sp : _valid_searchpaths) {
508 std::string buf = FioGetDirectory(sp, HEIGHTMAP_DIR);
509
510 if (it->second.tar_filename.starts_with(buf)) {
511 match = true;
512 break;
513 }
514 }
515
516 if (!match) return { FIOS_TYPE_INVALID, {} };
517 }
518
519 return { type, GetFileTitle(file, HEIGHTMAP_DIR) };
520}
521
522/**
523 * Get a list of heightmaps.

Callers 1

openttd_mainFunction · 0.85

Calls 5

StrEqualsIgnoreCaseFunction · 0.85
FioGetDirectoryFunction · 0.85
GetFileTitleFunction · 0.85
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected