fix: probably fix for duplicate bot names when save names active (ref #403)
This commit is contained in:
parent
0d4fcdcf4d
commit
9d8318e584
3 changed files with 15 additions and 0 deletions
|
|
@ -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 ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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...");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue