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};