[Bots] Cleanup and remove preprocessors. (#2757)

* [Bots] Cleanup and remove preprocessors.

- Removes every `#ifdef BOTS` we have and locks bots behind `Bots:AllowBots` rule.
- Bot updates are now done by default similar to regular database updates.
- Modify `CMakeLists.txt`, `.drone.yml`, and `BUILD.md` to match the removal of `EQEMU_ENABLE_BOTS`.

* Cleanup

- Add SQL for enabling bots for servers with bots.
- Add message that tells players/operators bots are disabled.

* Suggested changes.

* Bot injection stuff

* Change SQL to bot SQL.

* Tweaks

* Remove `is_bot`

* Update version.h

* Update main.cpp

* Update database.cpp

* Fix name availability crash

* Remove bots from update script

Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
Alex King
2023-01-20 13:35:33 -05:00
committed by GitHub
parent 1f0b2a8991
commit 3335cacac1
91 changed files with 263 additions and 1150 deletions
+33 -49
View File
@@ -50,9 +50,7 @@ extern volatile bool RunLoops;
#include "petitions.h"
#include "command.h"
#include "water_map.h"
#ifdef BOTS
#include "bot_command.h"
#endif
#include "string_ids.h"
#include "guild_mgr.h"
@@ -369,7 +367,6 @@ Client::Client(EQStreamInterface *ieqs) : Mob(
SetDisplayMobInfoWindow(true);
SetDevToolsEnabled(true);
#ifdef BOTS
bot_owner_options[booDeathMarquee] = false;
bot_owner_options[booStatsUpdate] = false;
bot_owner_options[booSpawnMessageSay] = false;
@@ -382,7 +379,6 @@ Client::Client(EQStreamInterface *ieqs) : Mob(
SetBotPulling(false);
SetBotPrecombat(false);
#endif
AI_Init();
}
@@ -390,9 +386,10 @@ Client::Client(EQStreamInterface *ieqs) : Mob(
Client::~Client() {
mMovementManager->RemoveClient(this);
#ifdef BOTS
Bot::ProcessBotOwnerRefDelete(this);
#endif
if (RuleB(Bots, Enabled)) {
Bot::ProcessBotOwnerRefDelete(this);
}
if(IsInAGuild())
guild_mgr.SendGuildMemberUpdateToWorld(GetName(), GuildID(), 0, time(nullptr));
@@ -1148,30 +1145,32 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s
break;
}
#ifdef BOTS
if (message[0] == BOT_COMMAND_CHAR) {
if (bot_command_dispatch(this, message) == -2) {
if (parse->PlayerHasQuestSub(EVENT_BOT_COMMAND)) {
int i = parse->EventPlayer(EVENT_BOT_COMMAND, this, message, 0);
if (i == 0 && !RuleB(Chat, SuppressCommandErrors)) {
Message(Chat::Red, "Bot command '%s' not recognized.", message);
}
}
else if (parse->PlayerHasQuestSub(EVENT_SAY)) {
int i = parse->EventPlayer(EVENT_SAY, this, message, 0);
if (i == 0 && !RuleB(Chat, SuppressCommandErrors)) {
Message(Chat::Red, "Bot command '%s' not recognized.", message);
}
}
else {
if (!RuleB(Chat, SuppressCommandErrors)) {
Message(Chat::Red, "Bot command '%s' not recognized.", message);
if (RuleB(Bots, Enabled)) {
if (bot_command_dispatch(this, message) == -2) {
if (parse->PlayerHasQuestSub(EVENT_BOT_COMMAND)) {
int i = parse->EventPlayer(EVENT_BOT_COMMAND, this, message, 0);
if (i == 0 && !RuleB(Chat, SuppressCommandErrors)) {
Message(Chat::Red, "Bot command '%s' not recognized.", message);
}
}
else if (parse->PlayerHasQuestSub(EVENT_SAY)) {
int i = parse->EventPlayer(EVENT_SAY, this, message, 0);
if (i == 0 && !RuleB(Chat, SuppressCommandErrors)) {
Message(Chat::Red, "Bot command '%s' not recognized.", message);
}
}
else {
if (!RuleB(Chat, SuppressCommandErrors)) {
Message(Chat::Red, "Bot command '%s' not recognized.", message);
}
}
}
} else {
Message(Chat::Red, "Bots are disabled on this server.");
}
break;
}
#endif
if (EQ::ProfanityManager::IsCensorshipActive()) {
EQ::ProfanityManager::RedactMessage(message);
@@ -1223,20 +1222,15 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s
}
}
#ifdef BOTS
else if (GetTarget() && GetTarget()->IsBot() && !IsInvisible(GetTarget())) {
if (DistanceNoZ(m_Position, GetTarget()->GetPosition()) <= RuleI(Range, Say)) {
if (GetTarget()->IsEngaged()) {
parse->EventBot(EVENT_AGGRO_SAY, GetTarget()->CastToBot(), this, message, language);
} else {
parse->EventBot(EVENT_SAY, GetTarget()->CastToBot(), this, message, language);
else if (GetTarget() && GetTarget()->IsBot() && !IsInvisible(GetTarget())) {
if (DistanceNoZ(m_Position, GetTarget()->GetPosition()) <= RuleI(Range, Say)) {
if (GetTarget()->IsEngaged()) {
parse->EventBot(EVENT_AGGRO_SAY, GetTarget()->CastToBot(), this, message, language);
} else {
parse->EventBot(EVENT_SAY, GetTarget()->CastToBot(), this, message, language);
}
}
}
}
#endif
break;
}
case ChatChannel_UCSRelay:
@@ -7618,13 +7612,9 @@ void Client::GarbleMessage(char *message, uint8 variance)
int delimiter_count = 0;
// Don't garble # commands
if (message[0] == COMMAND_CHAR)
if (message[0] == COMMAND_CHAR || message[0] == BOT_COMMAND_CHAR) {
return;
#ifdef BOTS
if (message[0] == BOT_COMMAND_CHAR)
return;
#endif
}
for (size_t i = 0; i < strlen(message); i++) {
// Client expects hex values inside of a text link body
@@ -11612,14 +11602,12 @@ std::vector<Mob*> Client::GetApplySpellList(
l.push_back(m->GetPet());
}
#ifdef BOTS
if (allow_bots) {
const auto& sbl = entity_list.GetBotListByCharacterID(m->CharacterID());
for (const auto& b : sbl) {
l.push_back(b);
}
}
#endif
}
}
}
@@ -11635,14 +11623,12 @@ std::vector<Mob*> Client::GetApplySpellList(
l.push_back(m->GetPet());
}
#ifdef BOTS
if (allow_bots) {
const auto& sbl = entity_list.GetBotListByCharacterID(m->CastToClient()->CharacterID());
for (const auto& b : sbl) {
l.push_back(b);
}
}
#endif
}
}
}
@@ -11653,14 +11639,12 @@ std::vector<Mob*> Client::GetApplySpellList(
l.push_back(GetPet());
}
#ifdef BOTS
if (allow_bots) {
const auto& sbl = entity_list.GetBotListByCharacterID(CharacterID());
for (const auto& b : sbl) {
l.push_back(b);
}
}
#endif
}
return l;