Skip to content

Commit e52350f

Browse files
committed
Merge branch 'main' into font-as-resource
2 parents e5294c9 + 972b535 commit e52350f

File tree

3 files changed

+10
-20
lines changed

3 files changed

+10
-20
lines changed

src/resource/archive/ArchiveManager.cpp

+10-18
Original file line numberDiff line numberDiff line change
@@ -40,40 +40,31 @@ bool ArchiveManager::IsArchiveLoaded() {
4040
return !mArchives.empty();
4141
}
4242

43-
std::shared_ptr<File> ArchiveManager::LoadFile(const std::string& filePath, std::shared_ptr<ResourceInitData> initData) {
43+
std::shared_ptr<File> ArchiveManager::LoadFile(const std::string& filePath) {
4444
if (filePath == "") {
4545
return nullptr;
4646
}
4747

48-
const auto archive = mFileToArchive[CRC64(filePath.c_str())];
49-
if (archive == nullptr) {
50-
return nullptr;
51-
}
52-
53-
return archive->LoadFile(filePath, initData);
48+
return LoadFile(CRC64(filePath.c_str()), initData);
5449
}
5550

56-
std::shared_ptr<File> ArchiveManager::LoadFile(uint64_t hash, std::shared_ptr<ResourceInitData> initData) {
51+
std::shared_ptr<File> ArchiveManager::LoadFile(uint64_t hash) {
5752
const auto archive = mFileToArchive[hash];
5853
if (archive == nullptr) {
5954
return nullptr;
6055
}
6156

62-
return archive->LoadFile(hash, initData);
57+
auto file = archive->LoadFile(hash, initData);
58+
file->Parent = archive;
59+
return file;
6360
}
6461

65-
//TODO remove
6662
std::shared_ptr<File> ArchiveManager::LoadFileRaw(const std::string& filePath) {
6763
if (filePath == "") {
6864
return nullptr;
6965
}
7066

71-
const auto archive = mFileToArchive[CRC64(filePath.c_str())];
72-
if (archive == nullptr) {
73-
return nullptr;
74-
}
75-
76-
return archive->LoadFileRaw(filePath);
67+
return LoadFileRaw(CRC64(filePath.c_str()));
7768
}
7869

7970
std::shared_ptr<File> ArchiveManager::LoadFileRaw(uint64_t hash) {
@@ -82,9 +73,10 @@ std::shared_ptr<File> ArchiveManager::LoadFileRaw(uint64_t hash) {
8273
return nullptr;
8374
}
8475

85-
return archive->LoadFileRaw(hash);
76+
auto file = archive->LoadFileRaw(hash);
77+
file->Parent = archive;
78+
return file;
8679
}
87-
//ENDTODO
8880

8981
bool ArchiveManager::HasFile(const std::string& filePath) {
9082
return HasFile(CRC64(filePath.c_str()));

src/resource/archive/O2rArchive.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ std::shared_ptr<File> O2rArchive::LoadFileRaw(const std::string& filePath) {
5353
SPDLOG_TRACE("Error closing file {} in zip archive {}.", filePath, GetPath());
5454
}
5555

56-
fileToLoad->Parent = dynamic_pointer_cast<Archive>(std::make_shared<O2rArchive>(std::move(*this)));
5756
fileToLoad->IsLoaded = true;
5857

5958
return fileToLoad;

src/resource/archive/OtrArchive.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ std::shared_ptr<File> OtrArchive::LoadFileRaw(const std::string& filePath) {
5050
SPDLOG_ERROR("({}) Failed to close file {} from mpq archive {}", GetLastError(), filePath, GetPath());
5151
}
5252

53-
fileToLoad->Parent = dynamic_pointer_cast<Archive>(std::make_shared<OtrArchive>(std::move(*this)));
5453
fileToLoad->IsLoaded = true;
5554

5655
return fileToLoad;

0 commit comments

Comments
 (0)