Skip to content

Commit

Permalink
Merge pull request #18638 from hrydgard/more-tex-replacement-details
Browse files Browse the repository at this point in the history
Fix two minor tex replacement issues
  • Loading branch information
unknownbrackets committed Dec 29, 2023
2 parents 46b25d2 + daa9fab commit 80bd328
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion GPU/Common/ReplacedTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void ReplacedTexture::Prepare(VFSBackend *vfs) {
VFSFileReference *fileRef = vfs_->GetFile(desc_.filenames[i].c_str());
if (!fileRef) {
if (i == 0) {
WARN_LOG(G3D, "Texture replacement file '%s' not found", desc_.filenames[i].c_str());
INFO_LOG(G3D, "Texture replacement file '%s' not found", desc_.filenames[i].c_str());
// No file at all. Mark as NOT_FOUND.
SetState(ReplacementState::NOT_FOUND);
return;
Expand Down
13 changes: 12 additions & 1 deletion GPU/Common/TextureReplacer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ bool TextureReplacer::LoadIni() {
// Do what we can do anyway: Scan for textures and build the map.
std::map<ReplacementCacheKey, std::map<int, std::string>> filenameMap;
ScanForHashNamedFiles(dir, filenameMap);

if (filenameMap.empty()) {
WARN_LOG(G3D, "No replacement textures found.");
return false;
}

ComputeAliasMap(filenameMap);
}
}
Expand Down Expand Up @@ -593,7 +599,12 @@ ReplacedTexture *TextureReplacer::FindReplacement(u64 cachekey, u32 hash, int w,
}
desc.logId = desc.filenames[0];
desc.hashfiles = desc.filenames[0]; // The generated filename of the top level is used as the key in the data cache.
hashfiles = desc.filenames[0];
hashfiles.clear();
hashfiles.reserve(desc.filenames[0].size() * (desc.filenames.size() + 1));
for (int level = 0; level < desc.filenames.size(); level++) {
hashfiles += desc.filenames[level];
hashfiles.push_back('|');
}
} else {
desc.logId = hashfiles;
SplitString(hashfiles, '|', desc.filenames);
Expand Down

0 comments on commit 80bd328

Please sign in to comment.