import: a .rsbank lands as a new bank, whole or not at all
Four collisions answered explicitly: ids reminted, names never overwritten, content deduped before the write, bank name auto-suffixed. Degraded ledger refuses before the picker.
This commit is contained in:
@@ -117,6 +117,17 @@ bool BankBook::createBank(const std::string& id, const std::string& displayName)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Runs behind displayNameTaken so the probe and the create/rename check can never
|
||||
// disagree about what "already used" means. exceptId is deliberately "" — no bank can
|
||||
// carry an empty id, so nothing is excluded from the scan.
|
||||
std::string BankBook::uniqueDisplayName(const std::string& seed) const {
|
||||
if (!displayNameTaken(seed, /*exceptId=*/std::string{})) return seed;
|
||||
for (int n = 2;; ++n) {
|
||||
std::string candidate = seed + " " + std::to_string(n);
|
||||
if (!displayNameTaken(candidate, /*exceptId=*/std::string{})) return candidate;
|
||||
}
|
||||
}
|
||||
|
||||
bool BankBook::renameBank(const std::string& id, const std::string& displayName) {
|
||||
if (id == kPoolBankId) return false; // pool is un-renamable
|
||||
Bank* b = bank(id);
|
||||
|
||||
Reference in New Issue
Block a user