From 60c90259bb5fd233bcb90a16d4dc01caccb0d68b Mon Sep 17 00:00:00 2001 From: Thomas Martin <304581853+boubou666@users.noreply.github.com> Date: Wed, 11 Nov 2026 12:49:41 +0100 Subject: [PATCH] Read each texture once when making a pack The texture dump's parallel runs can each list a texture they all load, so index.tsv holds the same identity two or three times (79 of 2,290 on the 0.6.0 release check). tmb-texture-pack's prepare threads then wrote the same file into the model's folder at once, a rename failed, and the launcher's Enhanced textures stopped with "cannot write to ...". Duplicate rows are now dropped when the index is read. Co-Authored-By: Claude Opus 5.5 --- bozo/tmb_texture_pack.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bozo/tmb_texture_pack.cpp b/bozo/tmb_texture_pack.cpp index efac288..90ddc93 100644 --- a/bozo/tmb_texture_pack.cpp +++ b/bozo/tmb_texture_pack.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #if defined(_WIN32) @@ -720,14 +721,19 @@ int main(int argc, char **argv) // ---- the textures to make: padded colour into the model's folder ---- say("step prepare"); + // One row per identity: the dump's parallel runs can each list a texture they all load, and two threads writing + // the same file into the model's folder would collide. std::vector rows; + std::unordered_set seen; std::string line; std::getline(index, line); // the header while (std::getline(index, line)) + { if (!line.empty() && line.back() == '\r') - line.pop_back(), rows.push_back(line); - else if (!line.empty()) + line.pop_back(); + if (!line.empty() && seen.insert(line.substr(0, line.find('\t'))).second) rows.push_back(line); + } std::vector todo; // identities (re-read when finished: a whole dump does not stay in memory) std::mutex todoMutex; std::atomic next{0}, prepared{0};