Address a round of feedback

This commit is contained in:
Henrik Rydgård 2023-03-11 21:46:01 +01:00
parent f32d0c2d69
commit d95cd73c2c
3 changed files with 12 additions and 5 deletions

View file

@ -88,18 +88,24 @@ private:
bool ReplacedTexture::IsReady(double budget) {
_assert_(vfs_ != nullptr);
double now = time_now_d();
switch (State()) {
case ReplacementState::ACTIVE:
case ReplacementState::NOT_FOUND:
if (threadWaitable_) {
if (!threadWaitable_->WaitFor(budget)) {
lastUsed_ = now;
return false;
}
// Successfully waited! Can get rid of it.
threadWaitable_->WaitAndRelease();
threadWaitable_ = nullptr;
if (levelData_) {
levelData_->lastUsed = now;
}
}
lastUsed_ = time_now_d();
lastUsed_ = now;
return true;
case ReplacementState::UNINITIALIZED:
// _dbg_assert_(false);
@ -112,7 +118,7 @@ bool ReplacedTexture::IsReady(double budget) {
break;
}
lastUsed_ = time_now_d();
lastUsed_ = now;
// Let's not even start a new texture if we're already behind.
if (budget < 0.0)

View file

@ -1514,7 +1514,7 @@ ReplacedTexture *TextureCacheCommon::FindReplacement(TexCacheEntry *entry, int &
return nullptr;
}
if ((entry->status & TexCacheEntry::STATUS_VIDEO) && replacer_.AllowVideo()) {
if ((entry->status & TexCacheEntry::STATUS_VIDEO) && !replacer_.AllowVideo()) {
return nullptr;
}

View file

@ -216,8 +216,6 @@ bool TextureReplacer::LoadIniValues(IniFile &ini, bool isOverride) {
bool filenameWarning = false;
if (ini.HasSection("hashes")) {
aliases_.clear();
auto hashes = ini.GetOrCreateSection("hashes")->ToMap();
// Format: hashname = filename.png
bool checkFilenames = g_Config.bSaveNewTextures && !g_Config.bIgnoreTextureFilenames && !vfsIsZip_;
@ -693,6 +691,9 @@ void TextureReplacer::NotifyTextureDecoded(const ReplacedTextureDecodeInfo &repl
#endif
if (slash != hashfile.npos) {
// Does this ever happen?
// Answer: An alias could be used to save a texture in a subfolder of newTextureDir_
// (i.e. if you had the hash and purged out your pngs to redump them), although I guess this usage is probably uncommon. - unknown
// Create any directory structure as needed.
task->saveDirectory = newTextureDir_ / hashfile.substr(0, slash);
task->createSaveDirectory = true;