mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-10 19:10:25 +00:00
[Bug Fix] Fix Bot Creation Issue (#4235)
# Notes - Creating bots was failing because were checking for `false` on `Database::CheckUsedName()` in `BotDatabase::QueryNameAvailability`. - `Database::CheckUsedName()` is now `Database::IsNameUsed()` and checks for both bots and character name usages. - We were checking for `false` which was always happening when there were no entries for the supplied name, meaning we were never allowed to create a bot.
This commit is contained in:
+20
-3
@@ -74,6 +74,7 @@
|
||||
#include "repositories/zone_repository.h"
|
||||
#include "zone_store.h"
|
||||
#include "repositories/merchantlist_temp_repository.h"
|
||||
#include "repositories/bot_data_repository.h"
|
||||
|
||||
extern Client client;
|
||||
|
||||
@@ -915,15 +916,31 @@ bool Database::UpdateName(const std::string& old_name, const std::string& new_na
|
||||
return CharacterDataRepository::UpdateOne(*this, e);
|
||||
}
|
||||
|
||||
bool Database::CheckUsedName(const std::string& name)
|
||||
bool Database::IsNameUsed(const std::string& name)
|
||||
{
|
||||
return !CharacterDataRepository::GetWhere(
|
||||
if (RuleB(Bots, Enabled)) {
|
||||
const auto& bot_data = BotDataRepository::GetWhere(
|
||||
*this,
|
||||
fmt::format(
|
||||
"`name` = '{}'",
|
||||
Strings::Escape(name)
|
||||
)
|
||||
);
|
||||
|
||||
if (!bot_data.empty()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
const auto& character_data = CharacterDataRepository::GetWhere(
|
||||
*this,
|
||||
fmt::format(
|
||||
"`name` = '{}'",
|
||||
Strings::Escape(name)
|
||||
)
|
||||
).empty();
|
||||
);
|
||||
|
||||
return !character_data.empty();
|
||||
}
|
||||
|
||||
uint32 Database::GetServerType()
|
||||
|
||||
Reference in New Issue
Block a user