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

Method AddFile

src/newgrf_config.cpp:513–535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

511};
512
513bool GRFFileScanner::AddFile(const std::string &filename, size_t basepath_length, const std::string &)
514{
515 /* Abort if the user stopped the game during a scan. */
516 if (_exit_game) return false;
517
518 bool added = false;
519 auto c = std::make_unique<GRFConfig>(filename.substr(basepath_length));
520 GRFConfig *grfconfig = c.get();
521 if (FillGRFDetails(*c, false)) {
522 if (std::ranges::none_of(_all_grfs, [&c](const auto &gc) { return c->ident.grfid == gc->ident.grfid && c->ident.md5sum == gc->ident.md5sum; })) {
523 _all_grfs.push_back(std::move(c));
524 added = true;
525 }
526 }
527
528 this->num_scanned++;
529
530 std::string name = grfconfig->GetName();
531 UpdateNewGRFScanStatus(this->num_scanned, std::move(name));
532 VideoDriver::GetInstance()->GameLoopPause();
533
534 return added;
535}
536
537/**
538 * Simple sorter for GRFS

Callers

nothing calls this directly

Calls 7

FillGRFDetailsFunction · 0.85
UpdateNewGRFScanStatusFunction · 0.85
substrMethod · 0.80
push_backMethod · 0.80
GameLoopPauseMethod · 0.80
getMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected