mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-28 00:57:15 +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();
|
auto bot_character_level = c->GetBotRequiredLevel();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
bot_character_level >= 0 &&
|
bot_character_level >= 0 &&
|
||||||
c->GetLevel() < bot_character_level &&
|
c->GetLevel() < bot_character_level &&
|
||||||
@@ -1011,6 +1012,7 @@ void bot_command_spawn(Client *c, const Seperator *sep)
|
|||||||
!c->GetGM()
|
!c->GetGM()
|
||||||
) {
|
) {
|
||||||
std::string message;
|
std::string message;
|
||||||
|
|
||||||
if (bot_spawn_limit) {
|
if (bot_spawn_limit) {
|
||||||
message = fmt::format(
|
message = fmt::format(
|
||||||
"You cannot have more than {} spawned bot{}.",
|
"You cannot have more than {} spawned bot{}.",
|
||||||
@@ -1034,6 +1036,7 @@ void bot_command_spawn(Client *c, const Seperator *sep)
|
|||||||
|
|
||||||
uint32 bot_id = 0;
|
uint32 bot_id = 0;
|
||||||
uint8 bot_class = Class::None;
|
uint8 bot_class = Class::None;
|
||||||
|
|
||||||
if (!database.botdb.LoadBotID(bot_name, bot_id, bot_class)) {
|
if (!database.botdb.LoadBotID(bot_name, bot_id, bot_class)) {
|
||||||
c->Message(
|
c->Message(
|
||||||
Chat::White,
|
Chat::White,
|
||||||
@@ -1074,6 +1077,7 @@ void bot_command_spawn(Client *c, const Seperator *sep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto bot_character_level_class = c->GetBotRequiredLevel(bot_class);
|
auto bot_character_level_class = c->GetBotRequiredLevel(bot_class);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
bot_character_level_class >= 0 &&
|
bot_character_level_class >= 0 &&
|
||||||
c->GetLevel() < bot_character_level_class &&
|
c->GetLevel() < bot_character_level_class &&
|
||||||
@@ -1113,6 +1117,7 @@ void bot_command_spawn(Client *c, const Seperator *sep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto my_bot = Bot::LoadBot(bot_id);
|
auto my_bot = Bot::LoadBot(bot_id);
|
||||||
|
|
||||||
if (!my_bot) {
|
if (!my_bot) {
|
||||||
c->Message(
|
c->Message(
|
||||||
Chat::White,
|
Chat::White,
|
||||||
@@ -1134,6 +1139,7 @@ void bot_command_spawn(Client *c, const Seperator *sep)
|
|||||||
bot_id
|
bot_id
|
||||||
).c_str()
|
).c_str()
|
||||||
);
|
);
|
||||||
|
|
||||||
safe_delete(my_bot);
|
safe_delete(my_bot);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,8 +88,22 @@ int Client::GetBotSpawnLimit(uint8 class_id)
|
|||||||
);
|
);
|
||||||
|
|
||||||
auto bucket_value = GetBucket(bucket_name);
|
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)) {
|
if (!bucket_value.empty() && Strings::IsNumber(bucket_value)) {
|
||||||
bot_spawn_limit = Strings::ToInt(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;
|
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
|
auto results = database.QueryDatabase(query); // use 'database' for non-bot table calls
|
||||||
|
|
||||||
if (!results.Success() || !results.RowCount()) {
|
if (!results.Success() || !results.RowCount()) {
|
||||||
return bot_spawn_limit;
|
return bot_spawn_limit;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user