From 1227f35382cb07b3f5e77e0de775f09b2dfe56f9 Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Sun, 7 Jan 2024 00:48:37 -0500 Subject: [PATCH] [Cleanup] Remove bot-based saylink method (#3852) # Notes - With the new saylink functionality, bots no longer need their own saylink method. --- zone/bot.cpp | 22 ------------ zone/bot.h | 2 -- zone/bot_command.cpp | 81 +++++++++++++++++++------------------------- zone/zonedb.cpp | 33 ------------------ zone/zonedb.h | 4 --- 5 files changed, 34 insertions(+), 108 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index 0328b01e9..8cb7760b7 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -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)) { diff --git a/zone/bot.h b/zone/bot.h index 38637f022..b4a3cdc72 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -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; diff --git a/zone/bot_command.cpp b/zone/bot_command.cpp index c08927d16..eaf6d0e54 100644 --- a/zone/bot_command.cpp +++ b/zone/bot_command.cpp @@ -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" + ) ) ); diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 62f5e9e56..9d5d96019 100755 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -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( diff --git a/zone/zonedb.h b/zone/zonedb.h index f436dd17c..b5c794f4c 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -648,10 +648,6 @@ public: void LoadAltCurrencyValues(uint32 char_id, std::map ¤cy); 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