[Cleanup] Remove bot-based saylink method (#3852)

# Notes
- With the new saylink functionality, bots no longer need their own saylink method.
This commit is contained in:
Alex King 2024-01-07 00:48:37 -05:00 committed by GitHub
parent c0769a9c29
commit 1227f35382
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 108 deletions

View File

@ -8138,28 +8138,6 @@ bool Bot::DyeArmor(int16 slot_id, uint32 rgb, bool all_flag, bool save_flag)
return true;
}
std::string Bot::CreateSayLink(Client* c, const char* message, const char* name)
{
// TODO: review
int saylink_size = strlen(message);
char* escaped_string = new char[saylink_size * 2];
database.DoEscapeString(escaped_string, message, saylink_size);
uint32 saylink_id = database.LoadSaylinkID(escaped_string);
safe_delete_array(escaped_string);
EQ::SayLinkEngine linker;
linker.SetLinkType(EQ::saylink::SayLinkItemData);
linker.SetProxyItemID(SAYLINK_ITEM_ID);
linker.SetProxyAugment1ID(saylink_id);
linker.SetProxyText(name);
auto saylink = linker.GenerateLink();
return saylink;
}
void Bot::Signal(int signal_id)
{
if (parse->BotHasQuestSub(EVENT_SIGNAL)) {

View File

@ -659,8 +659,6 @@ public:
void SetBotEnforceSpellSetting(bool enforcespellsettings, bool save = false);
bool GetBotEnforceSpellSetting() const { return m_enforce_spell_settings; }
std::string CreateSayLink(Client* botOwner, const char* message, const char* name);
// Class Destructors
~Bot() override;

View File

@ -4003,8 +4003,6 @@ void bot_command_item_use(Client* c, const Seperator* sep)
}
}
std::string text_link;
EQ::SayLinkEngine linker;
linker.SetLinkType(EQ::saylink::SayLinkItemInst);
@ -4050,15 +4048,6 @@ void bot_command_item_use(Client* c, const Seperator* sep)
continue;
}
text_link = bot_iter->CreateSayLink(
c,
fmt::format(
"^inventorygive byname {}",
bot_iter->GetCleanName()
).c_str(),
bot_iter->GetCleanName()
);
for (const auto& slot_iter : equipable_slot_list) {
// needs more failure criteria - this should cover the bulk for now
if (slot_iter == EQ::invslot::slotSecondary && item_data->Damage && !bot_iter->CanThisClassDualWield()) {
@ -4074,7 +4063,13 @@ void bot_command_item_use(Client* c, const Seperator* sep)
Chat::Say,
fmt::format(
"{} says, 'I can use that for my {} instead of my {}! Would you like to {} my {}?'",
text_link,
Saylink::Silent(
fmt::format(
"^inventorygive byname {}",
bot_iter->GetCleanName()
),
bot_iter->GetCleanName()
),
EQ::invslot::GetInvPossessionsSlotName(slot_iter),
linker.GenerateLink(),
Saylink::Silent(
@ -4096,7 +4091,13 @@ void bot_command_item_use(Client* c, const Seperator* sep)
Chat::Say,
fmt::format(
"{} says, 'I can use that for my {}! Would you like to {} it to me?'",
text_link,
Saylink::Silent(
fmt::format(
"^inventorygive byname {}",
bot_iter->GetCleanName()
),
bot_iter->GetCleanName()
),
EQ::invslot::GetInvPossessionsSlotName(slot_iter),
Saylink::Silent(
fmt::format(
@ -9542,10 +9543,6 @@ uint32 helper_bot_create(Client *bot_owner, std::string bot_name, uint8 bot_clas
if (!Bot::IsValidRaceClassCombo(bot_race, bot_class)) {
const std::string bot_race_name = GetRaceIDName(bot_race);
const std::string bot_class_name = GetClassIDName(bot_class);
const auto view_saylink = Saylink::Silent(
fmt::format("^viewcombos {}", bot_race),
"view"
);
bot_owner->Message(
Chat::White,
@ -9553,7 +9550,10 @@ uint32 helper_bot_create(Client *bot_owner, std::string bot_name, uint8 bot_clas
"{} {} is an invalid race-class combination, would you like to {} proper combinations for {}?",
bot_race_name,
bot_class_name,
view_saylink,
Saylink::Silent(
fmt::format("^viewcombos {}", bot_race),
"view"
),
bot_race_name
).c_str()
);
@ -9871,9 +9871,6 @@ void helper_command_depart_list(Client* bot_owner, Bot* druid_bot, Bot* wizard_b
return;
}
std::string msg;
std::string text_link;
auto destination_count = 0;
auto destination_number = 1;
for (auto list_iter : *local_list) {
@ -9891,24 +9888,19 @@ void helper_command_depart_list(Client* bot_owner, Bot* druid_bot, Bot* wizard_b
continue;
}
msg = fmt::format(
"^circle {}{}",
spells[local_entry->spell_id].teleport_zone,
single_flag ? " single" : ""
);
text_link = druid_bot->CreateSayLink(
bot_owner,
msg.c_str(),
"Goto"
);
druid_bot->OwnerMessage(
fmt::format(
"Destination {} | {} | {}",
destination_number,
local_entry->long_name,
text_link
Saylink::Silent(
fmt::format(
"^circle {}{}",
spells[local_entry->spell_id].teleport_zone,
single_flag ? " single" : ""
),
"Goto"
)
)
);
@ -9926,24 +9918,19 @@ void helper_command_depart_list(Client* bot_owner, Bot* druid_bot, Bot* wizard_b
continue;
}
msg = fmt::format(
"^portal {}{}",
spells[local_entry->spell_id].teleport_zone,
single_flag ? " single" : ""
);
text_link = wizard_bot->CreateSayLink(
bot_owner,
msg.c_str(),
"Goto"
);
wizard_bot->OwnerMessage(
fmt::format(
"Destination {} | {} | {}",
destination_number,
local_entry->long_name,
text_link
Saylink::Silent(
fmt::format(
"^portal {}{}",
spells[local_entry->spell_id].teleport_zone,
single_flag ? " single" : ""
),
"Goto"
)
)
);

View File

@ -4321,39 +4321,6 @@ bool ZoneDatabase::DeleteCharacterCorpse(uint32 db_id) {
return false;
}
uint32 ZoneDatabase::LoadSaylinkID(const char* saylink_text, bool auto_insert)
{
if (!saylink_text || saylink_text[0] == '\0')
return 0;
std::string query = StringFormat("SELECT `id` FROM `saylink` WHERE `phrase` = '%s' LIMIT 1", saylink_text);
auto results = QueryDatabase(query);
if (!results.Success())
return 0;
if (!results.RowCount()) {
if (auto_insert)
return SaveSaylinkID(saylink_text);
else
return 0;
}
auto& row = results.begin();
return Strings::ToInt(row[0]);
}
uint32 ZoneDatabase::SaveSaylinkID(const char* saylink_text)
{
if (!saylink_text || saylink_text[0] == '\0')
return 0;
std::string query = StringFormat("INSERT INTO `saylink` (`phrase`) VALUES ('%s')", saylink_text);
auto results = QueryDatabase(query);
if (!results.Success())
return 0;
return results.LastInsertedID();
}
double ZoneDatabase::GetAAEXPModifier(uint32 character_id, uint32 zone_id, int16 instance_version) const {
const std::string query = fmt::format(
SQL(

View File

@ -648,10 +648,6 @@ public:
void LoadAltCurrencyValues(uint32 char_id, std::map<uint32, uint32> &currency);
void UpdateAltCurrencyValue(uint32 char_id, uint32 currency_id, uint32 value);
/* Saylinks */
uint32 LoadSaylinkID(const char* saylink_text, bool auto_insert = true);
uint32 SaveSaylinkID(const char* saylink_text);
/*
* Misc stuff.
* PLEASE DO NOT ADD TO THIS COLLECTION OF CRAP UNLESS YOUR METHOD