fix: probably fix for duplicate bot names when save names active (ref #403)

This commit is contained in:
jeefo 2023-02-01 21:19:17 +03:00
commit 9d8318e584
No known key found for this signature in database
GPG key ID: D85B0637366787C3
3 changed files with 15 additions and 0 deletions

View file

@ -111,6 +111,9 @@ public:
// remove bot name from used list // remove bot name from used list
void clearUsedName (Bot *bot); void clearUsedName (Bot *bot);
// set the bot names as used
void setBotNameUsed(const int index, StringRef name);
// initialize weapon info // initialize weapon info
void initWeapons (); void initWeapons ();

View file

@ -711,6 +711,15 @@ void BotConfig::clearUsedName (Bot *bot) {
} }
} }
void BotConfig::setBotNameUsed(const int index, StringRef name) {
for (auto &bn : m_botNames) {
if (bn.name == name) {
bn.usedBy = index;
break;
}
}
}
void BotConfig::initWeapons () { void BotConfig::initWeapons () {
m_weapons.clear (); m_weapons.clear ();

View file

@ -236,6 +236,9 @@ BotCreateResult BotManager::create (StringRef name, int difficulty, int personal
if (botName != nullptr) { if (botName != nullptr) {
botName->usedBy = index; // save by who name is used botName->usedBy = index; // save by who name is used
} }
else {
conf.setBotNameUsed(index, resultName);
}
m_bots.push (cr::move (object)); m_bots.push (cr::move (object));
ctrl.msg ("Connecting Bot..."); ctrl.msg ("Connecting Bot...");