mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-22 22:34:33 +01:00
Improve FileIndex (#17773)
This commit is contained in:
@@ -73,7 +73,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
std::tuple<bool, TrackRepositoryItem> Create(int32_t, const std::string& path) const override
|
||||
std::optional<TrackRepositoryItem> Create(int32_t, const std::string& path) const override
|
||||
{
|
||||
auto td6 = TrackDesignImport(path.c_str());
|
||||
if (td6 != nullptr)
|
||||
@@ -88,14 +88,14 @@ public:
|
||||
{
|
||||
item.Flags |= TRIF_READ_ONLY;
|
||||
}
|
||||
return std::make_tuple(true, item);
|
||||
return item;
|
||||
}
|
||||
|
||||
return std::make_tuple(true, TrackRepositoryItem());
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
protected:
|
||||
void Serialise(DataSerialiser& ds, TrackRepositoryItem& item) const override
|
||||
void Serialise(DataSerialiser& ds, const TrackRepositoryItem& item) const override
|
||||
{
|
||||
ds << item.Name;
|
||||
ds << item.Path;
|
||||
@@ -266,10 +266,9 @@ public:
|
||||
if (File::Copy(path, newPath, false))
|
||||
{
|
||||
auto language = LocalisationService_GetCurrentLanguage();
|
||||
auto td = _fileIndex.Create(language, newPath);
|
||||
if (std::get<0>(td))
|
||||
if (auto td = _fileIndex.Create(language, newPath); td.has_value())
|
||||
{
|
||||
_items.push_back(std::move(std::get<1>(td)));
|
||||
_items.push_back(std::move(td.value()));
|
||||
SortItems();
|
||||
result = path;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user