Merge pull request #4039 from ab9rf/tailor-4038

tailor: reshuffled logic
develop
Myk 2023-11-17 16:42:39 -08:00 committed by GitHub
commit b078036ac6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 10 deletions

@ -58,6 +58,7 @@ Template for new versions:
## Fixes ## Fixes
## Misc Improvements ## Misc Improvements
- `tailor`: corrected a corner case that resulted in existing stock being ignored in some circumstances
## Documentation ## Documentation

@ -307,17 +307,9 @@ public:
if (wearing.count(ty) == 0) if (wearing.count(ty) == 0)
{ {
if (available[std::make_pair(ty, usize)] > 0) if (ordered.count(ty) == 0)
{ {
available[std::make_pair(ty, usize)] -= 1; DEBUG(cycle).print ("tailor: %s (size %d) worn by %s (size %d) needs replacement\n",
DEBUG(cycle).print("tailor: allocating a %s (size %d) to %s\n",
ENUM_KEY_STR(item_type, ty).c_str(), usize,
DF2CONSOLE(Translation::TranslateName(&u->name, false)).c_str());
wearing.insert(ty);
}
else if (ordered.count(ty) == 0)
{
DEBUG(cycle).print ("tailor: %s (size %d) worn by %s (size %d) needs replacement, but none available\n",
DF2CONSOLE(description).c_str(), isize, DF2CONSOLE(description).c_str(), isize,
DF2CONSOLE(Translation::TranslateName(&u->name, false)).c_str(), usize); DF2CONSOLE(Translation::TranslateName(&u->name, false)).c_str(), usize);
needed[std::make_pair(ty, usize)] += 1; needed[std::make_pair(ty, usize)] += 1;
@ -369,6 +361,9 @@ public:
int size = a.first.second; int size = a.first.second;
int count = a.second; int count = a.second;
// decrease "need" by "available"
count -= available[std::make_pair(ty, size)];
if (count <= 0) if (count <= 0)
continue; continue;