mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 07:18:37 +00:00
Add zero check for bot spawn limits
If the spawn limit rule is set to 0 and spawn limit is set by bucket, if no class buckets are set, it defaults to the rule of 0 and renders the player unable to spawn bots. This adds a check where if the rule and class bucket are 0, it will check for the spawn limit bucket
This commit is contained in:
@@ -983,6 +983,7 @@ void bot_command_spawn(Client *c, const Seperator *sep)
|
||||
}
|
||||
|
||||
auto bot_character_level = c->GetBotRequiredLevel();
|
||||
|
||||
if (
|
||||
bot_character_level >= 0 &&
|
||||
c->GetLevel() < bot_character_level &&
|
||||
@@ -1009,8 +1010,9 @@ void bot_command_spawn(Client *c, const Seperator *sep)
|
||||
bot_spawn_limit >= 0 &&
|
||||
spawned_bot_count >= bot_spawn_limit &&
|
||||
!c->GetGM()
|
||||
) {
|
||||
) {
|
||||
std::string message;
|
||||
|
||||
if (bot_spawn_limit) {
|
||||
message = fmt::format(
|
||||
"You cannot have more than {} spawned bot{}.",
|
||||
@@ -1034,6 +1036,7 @@ void bot_command_spawn(Client *c, const Seperator *sep)
|
||||
|
||||
uint32 bot_id = 0;
|
||||
uint8 bot_class = Class::None;
|
||||
|
||||
if (!database.botdb.LoadBotID(bot_name, bot_id, bot_class)) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
@@ -1052,7 +1055,7 @@ void bot_command_spawn(Client *c, const Seperator *sep)
|
||||
bot_spawn_limit_class >= 0 &&
|
||||
spawned_bot_count_class >= bot_spawn_limit_class &&
|
||||
!c->GetGM()
|
||||
) {
|
||||
) {
|
||||
std::string message;
|
||||
|
||||
if (bot_spawn_limit_class) {
|
||||
@@ -1074,11 +1077,12 @@ void bot_command_spawn(Client *c, const Seperator *sep)
|
||||
}
|
||||
|
||||
auto bot_character_level_class = c->GetBotRequiredLevel(bot_class);
|
||||
|
||||
if (
|
||||
bot_character_level_class >= 0 &&
|
||||
c->GetLevel() < bot_character_level_class &&
|
||||
!c->GetGM()
|
||||
) {
|
||||
) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
@@ -1113,6 +1117,7 @@ void bot_command_spawn(Client *c, const Seperator *sep)
|
||||
}
|
||||
|
||||
auto my_bot = Bot::LoadBot(bot_id);
|
||||
|
||||
if (!my_bot) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
@@ -1134,6 +1139,7 @@ void bot_command_spawn(Client *c, const Seperator *sep)
|
||||
bot_id
|
||||
).c_str()
|
||||
);
|
||||
|
||||
safe_delete(my_bot);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -88,8 +88,22 @@ int Client::GetBotSpawnLimit(uint8 class_id)
|
||||
);
|
||||
|
||||
auto bucket_value = GetBucket(bucket_name);
|
||||
|
||||
if (class_id && !bot_spawn_limit && bucket_value.empty()) {
|
||||
const auto new_bucket_name = "bot_spawn_limit";
|
||||
|
||||
bucket_value = GetBucket(new_bucket_name);
|
||||
|
||||
if (!bucket_value.empty() && Strings::IsNumber(bucket_value)) {
|
||||
bot_spawn_limit = Strings::ToInt(bucket_value);
|
||||
|
||||
return bot_spawn_limit;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bucket_value.empty() && Strings::IsNumber(bucket_value)) {
|
||||
bot_spawn_limit = Strings::ToInt(bucket_value);
|
||||
|
||||
return bot_spawn_limit;
|
||||
}
|
||||
|
||||
@@ -101,6 +115,7 @@ int Client::GetBotSpawnLimit(uint8 class_id)
|
||||
);
|
||||
|
||||
auto results = database.QueryDatabase(query); // use 'database' for non-bot table calls
|
||||
|
||||
if (!results.Success() || !results.RowCount()) {
|
||||
return bot_spawn_limit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user