Replacement: Fix mip level loading. Fix bug if LoadIni gets rerun for some reason.

This commit is contained in:
Henrik Rydgård 2023-03-10 23:58:15 +01:00
parent 3dc2463b55
commit 8e3428438e
2 changed files with 9 additions and 1 deletions

View file

@ -2829,8 +2829,9 @@ bool TextureCacheCommon::PrepareBuildTexture(BuildTexturePlan &plan, TexCacheEnt
if (plan.replaceValid) {
// We're replacing, so we won't scale.
plan.scaleFactor = 1;
// We're ignoring how many levels were specified - instead we just load all available from the replacer.
plan.levelsToLoad = plan.replaced->NumLevels();
plan.levelsToCreate = std::min(plan.levelsToLoad, plan.levelsToCreate);
plan.levelsToCreate = plan.levelsToLoad; // Or more, if we wanted to generate.
plan.badMipSizes = false;
// But, we still need to create the texture at a larger size.
plan.replaced->GetSize(0, &plan.createW, &plan.createH);

View file

@ -191,6 +191,13 @@ bool TextureReplacer::LoadIni() {
}
vfs_ = dir;
// If we have stuff loaded from before, need to update the vfs pointers to avoid
// crash on exit. The actual problem is that we tend to call LoadIni a little too much...
for (auto &repl : cache_) {
repl.second->vfs_ = vfs_;
}
INFO_LOG(G3D, "Texture pack activated from '%s'", basePath_.c_str());
// The ini doesn't have to exist for the texture directory or zip to be valid.