[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
+19 -51
View File
@@ -70,10 +70,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "client.h"
#include "../common/repositories/account_repository.h"
#ifdef BOTS
#include "bot.h"
#endif
extern QueryServ* QServ;
extern Zone* zone;
@@ -1536,11 +1533,11 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
LFG = false;
}
#ifdef BOTS
database.botdb.LoadOwnerOptions(this);
// TODO: mod below function for loading spawned botgroups
Bot::LoadAndSpawnAllZonedBots(this);
#endif
if (RuleB(Bots, Enabled)) {
database.botdb.LoadOwnerOptions(this);
// TODO: mod below function for loading spawned botgroups
Bot::LoadAndSpawnAllZonedBots(this);
}
m_inv.SetGMInventory((bool)m_pp.gm); // set to current gm state for calc
CalcBonuses();
@@ -3998,13 +3995,14 @@ void Client::Handle_OP_BuffRemoveRequest(const EQApplicationPacket *app)
{
m = entity_list.GetMobID(brrs->EntityID);
}
#ifdef BOTS
else {
Mob* bot_test = entity_list.GetMob(brrs->EntityID);
if (bot_test && bot_test->IsBot() && bot_test->GetOwner() == this)
m = bot_test;
if (RuleB(Bots, Enabled)) {
Mob *bot_test = entity_list.GetMob(brrs->EntityID);
if (bot_test && bot_test->IsBot() && bot_test->GetOwner() == this) {
m = bot_test;
}
}
}
#endif
if (!m)
return;
@@ -4037,15 +4035,10 @@ void Client::Handle_OP_Bug(const EQApplicationPacket *app)
void Client::Handle_OP_Camp(const EQApplicationPacket *app)
{
#ifdef BOTS
// This block is necessary to clean up any bot objects owned by a Client
Bot::BotOrderCampAll(this);
// Evidently, this is bad under certain conditions and causes crashes...
// Group and Raid code really needs to be overhauled to account for non-client types (mercs and bots)
//auto group = GetGroup();
//if (group && group->GroupCount() < 2)
// group->DisbandGroup();
#endif
if (RuleB(Bots, Enabled)) {
Bot::BotOrderCampAll(this);
}
if (IsLFP())
worldserver.StopLFP(CharacterID());
@@ -6797,9 +6790,8 @@ void Client::Handle_OP_GroupDisband(const EQApplicationPacket *app)
if (!group)
return;
#ifdef BOTS
// this block is necessary to allow more control over controlling how bots are zoned or camped.
if (Bot::GroupHasBot(group)) {
if (RuleB(Bots, Enabled) && Bot::GroupHasBot(group)) {
if (group->IsLeader(this)) {
if ((GetTarget() == 0 || GetTarget() == this) || (group->GroupCount() < 3)) {
Bot::ProcessBotGroupDisband(this, std::string());
@@ -6820,9 +6812,10 @@ void Client::Handle_OP_GroupDisband(const EQApplicationPacket *app)
}
group = GetGroup();
if (!group) //We must recheck this here.. incase the final bot disbanded the party..otherwise we crash
if (!group) {
return;
#endif
}
Mob* memberToDisband = GetTarget();
if (!memberToDisband)
@@ -7012,11 +7005,9 @@ void Client::Handle_OP_GroupInvite2(const EQApplicationPacket *app)
}
}
}
#ifdef BOTS
else if (Invitee->IsBot()) {
Bot::ProcessBotGroupInvite(this, std::string(Invitee->GetName()));
}
#endif
}
else
{
@@ -7725,13 +7716,6 @@ void Client::Handle_OP_GuildInvite(const EQApplicationPacket *app)
return;
}
}
#ifdef BOTS
else if (invitee->IsBot()) {
// The guild system is too tightly coupled with the character_data table so we have to avoid using much of the system
Bot::ProcessGuildInvite(this, invitee->CastToBot());
return;
}
#endif
}
}
@@ -8098,10 +8082,6 @@ void Client::Handle_OP_GuildRemove(const EQApplicationPacket *app)
else if (!worldserver.Connected())
Message(Chat::Red, "Error: World server disconnected");
else {
#ifdef BOTS
if (Bot::ProcessGuildRemoval(this, gc->othername))
return;
#endif
uint32 char_id;
Client* client = entity_list.GetClientByName(gc->othername);
@@ -8454,9 +8434,7 @@ void Client::Handle_OP_InspectRequest(const EQApplicationPacket *app)
else { ProcessInspectRequest(tmp->CastToClient(), this); }
}
#ifdef BOTS
if (tmp != 0 && tmp->IsBot()) { Bot::ProcessBotInspectionRequest(tmp->CastToBot(), this); }
#endif
return;
}
@@ -11199,10 +11177,8 @@ void Client::Handle_OP_PopupResponse(const EQApplicationPacket *app)
if (t) {
if (t->IsNPC()) {
parse->EventNPC(EVENT_POPUP_RESPONSE, t->CastToNPC(), this, export_string, 0);
#ifdef BOTS
} else if (t->IsBot()) {
parse->EventBot(EVENT_POPUP_RESPONSE, t->CastToBot(), this, export_string, 0);
#endif
}
}
}
@@ -13984,9 +13960,7 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app)
}
if (GetGM() || RuleB(Spells, AlwaysSendTargetsBuffs) || nt == this || inspect_buffs || (nt->IsClient() && !nt->CastToClient()->GetPVP()) ||
(nt->IsPet() && nt->GetOwner() && nt->GetOwner()->IsClient() && !nt->GetOwner()->CastToClient()->GetPVP()) ||
#ifdef BOTS
(nt->IsBot() && nt->GetOwner() && nt->GetOwner()->IsClient() && !nt->GetOwner()->CastToClient()->GetPVP()) || // TODO: bot pets
#endif
(nt->IsMerc() && nt->GetOwner() && nt->GetOwner()->IsClient() && !nt->GetOwner()->CastToClient()->GetPVP()))
{
nt->SendBuffsToClient(this);
@@ -14421,11 +14395,9 @@ void Client::Handle_OP_TradeAcceptClick(const EQApplicationPacket *app)
FinishTrade(with->CastToNPC());
}
}
#ifdef BOTS
// TODO: Log Bot trades
else if (with->IsBot())
with->CastToBot()->FinishTrade(this, Bot::BotTradeClientNormal);
#endif
trade->Reset();
}
@@ -14677,11 +14649,7 @@ void Client::Handle_OP_TradeRequest(const EQApplicationPacket *app)
if (tradee && tradee->IsClient()) {
tradee->CastToClient()->QueuePacket(app);
}
#ifndef BOTS
else if (tradee && tradee->IsNPC()) {
#else
else if (tradee && (tradee->IsNPC() || tradee->IsBot())) {
#endif
if (!tradee->IsEngaged()) {
trade->Start(msg->to_mob_id);
EQApplicationPacket *outapp = new EQApplicationPacket(OP_TradeRequestAck, sizeof(TradeRequest_Struct));