mirror of
https://github.com/EQEmu/Server.git
synced 2026-09-05 03:06:38 +00:00
[Commands] Consolidate #findX commands to a singular #find Command (#3452)
* Push up example for Kingly * Update aa.cpp * Update find.cpp * Bulk push. * Update aa.cpp * Cleanup * Repository method. * Static aliasing * Aliases * Fix alias error. * Update zone.cpp * Update command.cpp * Update find.cpp --------- Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
#include "../../client.h"
|
||||
|
||||
void FindAA(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (sep->IsNumber(2)) {
|
||||
const auto aa_id = Strings::ToInt(sep->arg[2]);
|
||||
const auto& aa_name = zone->GetAAName(aa_id);
|
||||
if (!aa_name.empty()) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"AA {} | {}",
|
||||
Strings::Commify(aa_id),
|
||||
aa_name
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"AA ID {} was not found.",
|
||||
Strings::Commify(aa_id)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& search_criteria = Strings::ToLower(sep->argplus[2]);
|
||||
|
||||
auto found_count = 0;
|
||||
|
||||
std::map<int, std::string> ordered_aas;
|
||||
|
||||
for (const auto &a: zone->aa_abilities) {
|
||||
ordered_aas[a.second.get()->first->id] = a.second.get()->name;
|
||||
}
|
||||
|
||||
for (const auto &a: ordered_aas) {
|
||||
const auto& aa_name = zone->GetAAName(a.first);
|
||||
if (!aa_name.empty()) {
|
||||
const auto& aa_name_lower = Strings::ToLower(aa_name);
|
||||
if (!Strings::Contains(aa_name_lower, search_criteria)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"AA {} | {}",
|
||||
Strings::Commify(a.first),
|
||||
aa_name
|
||||
).c_str()
|
||||
);
|
||||
|
||||
found_count++;
|
||||
|
||||
if (found_count == 50) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (found_count == 50) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"50 AAs were found matching '{}', max reached.",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} AA{} found matching '{}'.",
|
||||
found_count,
|
||||
found_count != 1 ? "s" : "",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
#include "../../client.h"
|
||||
#include "../../common/repositories/character_data_repository.h"
|
||||
|
||||
void FindCharacter(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (sep->IsNumber(2)) {
|
||||
const auto character_id = Strings::ToUnsignedInt(sep->arg[2]);
|
||||
|
||||
const auto& e = CharacterDataRepository::FindOne(content_db, character_id);
|
||||
if (!e.id) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Character ID {} does not exist or is invalid.",
|
||||
Strings::Commify(character_id)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Character ID {} | {}",
|
||||
Strings::Commify(character_id),
|
||||
e.name
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const auto search_criteria = Strings::ToLower(sep->argplus[2]);
|
||||
|
||||
const auto& l = CharacterDataRepository::GetWhere(
|
||||
content_db,
|
||||
fmt::format(
|
||||
"LOWER(`name`) LIKE '%%{}%%' ORDER BY `id` ASC LIMIT 50",
|
||||
search_criteria
|
||||
)
|
||||
);
|
||||
|
||||
if (l.empty()) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"No characters found matching '{}'.",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
|
||||
auto found_count = 0;
|
||||
|
||||
for (const auto& e : l) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Character ID {} | {}",
|
||||
Strings::Commify(e.id),
|
||||
e.name
|
||||
).c_str()
|
||||
);
|
||||
|
||||
found_count++;
|
||||
|
||||
if (found_count == 50) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found_count == 50) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"50 Characters found matching '{}', max reached.",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} Character{} found matching '{}'.",
|
||||
found_count,
|
||||
found_count != 1 ? "s" : "",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
#include "../../client.h"
|
||||
|
||||
void FindClass(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (sep->IsNumber(2)) {
|
||||
const auto class_id = Strings::ToInt(sep->arg[2]);
|
||||
if (EQ::ValueWithin(class_id, WARRIOR, BERSERKER)) {
|
||||
const std::string& class_name = GetClassIDName(class_id);
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Class {} | {}{}",
|
||||
class_id,
|
||||
class_name,
|
||||
(
|
||||
c->IsPlayerClass(class_id) ?
|
||||
fmt::format(
|
||||
" ({})",
|
||||
Strings::Commify(GetPlayerClassBit(class_id))
|
||||
) :
|
||||
""
|
||||
)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Class ID {} was not found.",
|
||||
class_id
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& search_criteria = Strings::ToLower(sep->argplus[2]);
|
||||
|
||||
auto found_count = 0;
|
||||
|
||||
for (uint16 class_id = WARRIOR; class_id <= MERCENARY_MASTER; class_id++) {
|
||||
const std::string& class_name = GetClassIDName(class_id);
|
||||
const auto& class_name_lower = Strings::ToLower(class_name);
|
||||
if (!Strings::Contains(class_name_lower, search_criteria)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Class {} | {}{}",
|
||||
class_id,
|
||||
class_name,
|
||||
(
|
||||
c->IsPlayerClass(class_id) ?
|
||||
fmt::format(
|
||||
" | ({})",
|
||||
Strings::Commify(GetPlayerClassBit(class_id))
|
||||
) :
|
||||
""
|
||||
)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
found_count++;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} Class{} found matching '{}'.",
|
||||
found_count,
|
||||
found_count != 1 ? "es" : "",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
#include "../../client.h"
|
||||
|
||||
void FindCurrency(Client *c, const Seperator *sep)
|
||||
{
|
||||
const auto can_summon_items = c->Admin() >= GetCommandStatus(c, "summonitem");
|
||||
|
||||
if (sep->IsNumber(2)) {
|
||||
const auto item_id = Strings::ToUnsignedInt(sep->arg[2]);
|
||||
const auto currency_id = zone->GetCurrencyID(item_id);
|
||||
|
||||
if (!currency_id) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"There is no currency with an item ID of {}.",
|
||||
Strings::Commify(item_id)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const auto item_data = database.GetItem(item_id);
|
||||
if (!item_data) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Item ID {} does not exist.",
|
||||
Strings::Commify(item_id)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Currency {} | {}{}",
|
||||
currency_id,
|
||||
database.CreateItemLink(item_id),
|
||||
(
|
||||
can_summon_items ?
|
||||
fmt::format(
|
||||
" | {}",
|
||||
Saylink::Silent(
|
||||
fmt::format(
|
||||
"#summonitem {} {}",
|
||||
item_id,
|
||||
item_data->StackSize
|
||||
),
|
||||
"Summon"
|
||||
)
|
||||
) :
|
||||
""
|
||||
)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& search_criteria = Strings::ToLower(sep->argplus[2]);
|
||||
|
||||
auto found_count = 0;
|
||||
|
||||
for (const auto& e : zone->AlternateCurrencies) {
|
||||
const auto item_data = database.GetItem(e.item_id);
|
||||
if (!item_data) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto& item_name = Strings::ToLower(item_data->Name);
|
||||
|
||||
if (!Strings::Contains(item_name, search_criteria)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Currency {} | {}{}",
|
||||
e.id,
|
||||
database.CreateItemLink(e.item_id),
|
||||
(
|
||||
can_summon_items ?
|
||||
fmt::format(
|
||||
" | {}",
|
||||
Saylink::Silent(
|
||||
fmt::format(
|
||||
"#summonitem {} {}",
|
||||
e.item_id,
|
||||
item_data->StackSize
|
||||
),
|
||||
"Summon"
|
||||
)
|
||||
) :
|
||||
""
|
||||
)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
found_count++;
|
||||
|
||||
if (found_count == 50) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found_count == 50) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"50 Currencies found matching '{}', max reached.",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} Currenc{} found matching '{}'.",
|
||||
found_count,
|
||||
found_count != 1 ? "ies" : "y",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
#include "../../client.h"
|
||||
|
||||
void FindDeity(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (sep->IsNumber(2)) {
|
||||
const auto deity_id = static_cast<EQ::deity::DeityType>(Strings::ToInt(sep->arg[2]));
|
||||
const auto& deity_name = EQ::deity::GetDeityName(deity_id);
|
||||
if (!deity_name.empty()) {
|
||||
const auto deity_bit = EQ::deity::GetDeityBitmask(deity_id);
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Deity {} | {} ({})",
|
||||
deity_id,
|
||||
deity_name,
|
||||
Strings::Commify(deity_bit)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Deity ID {} was not found.",
|
||||
deity_id
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& search_criteria = Strings::ToLower(sep->argplus[2]);
|
||||
|
||||
auto found_count = 0;
|
||||
|
||||
for (const auto& d : EQ::deity::GetDeityMap()) {
|
||||
const auto& deity_name_lower = Strings::ToLower(d.second);
|
||||
if (!Strings::Contains(deity_name_lower, search_criteria)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto deity_bit = EQ::deity::GetDeityBitmask(d.first);
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Deity {} | {} ({})",
|
||||
d.first,
|
||||
d.second,
|
||||
Strings::Commify(deity_bit)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
found_count++;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} Deit{} found matching '{}'.",
|
||||
found_count,
|
||||
found_count != 1 ? "ies" : "y",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
#include "../../client.h"
|
||||
|
||||
void FindFaction(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (sep->IsNumber(2)) {
|
||||
const auto faction_id = Strings::ToInt(sep->arg[2]);
|
||||
const auto& faction_name = content_db.GetFactionName(faction_id);
|
||||
if (!faction_name.empty()) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Faction {} | {}",
|
||||
Strings::Commify(faction_id),
|
||||
faction_name
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Faction ID {} was not found.",
|
||||
Strings::Commify(faction_id)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& search_criteria = Strings::ToLower(sep->argplus[2]);
|
||||
auto found_count = 0;
|
||||
const auto max_faction_id = content_db.GetMaxFaction();
|
||||
|
||||
for (uint32 faction_id = 0; faction_id < max_faction_id; faction_id++) {
|
||||
const auto& faction_name = content_db.GetFactionName(faction_id);
|
||||
const auto& faction_name_lower = Strings::ToLower(faction_name);
|
||||
if (faction_name.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Strings::Contains(faction_name_lower, search_criteria)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Faction {} | {}",
|
||||
Strings::Commify(faction_id),
|
||||
faction_name
|
||||
).c_str()
|
||||
);
|
||||
|
||||
found_count++;
|
||||
|
||||
if (found_count == 50) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found_count == 50) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"50 Factions found matching '{}', max reached.",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} Faction{} found matching '{}'.",
|
||||
found_count,
|
||||
found_count != 1 ? "s" : "",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
#include "../../client.h"
|
||||
#include "../../common/repositories/items_repository.h"
|
||||
|
||||
void FindItem(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (sep->IsNumber(2)) {
|
||||
const auto item_id = Strings::ToUnsignedInt(sep->arg[2]);
|
||||
const auto* item = database.GetItem(item_id);
|
||||
if (item) {
|
||||
auto summon_links = Saylink::Silent(
|
||||
fmt::format(
|
||||
"#si {}",
|
||||
item_id
|
||||
),
|
||||
"X"
|
||||
);
|
||||
|
||||
if (item->Stackable && item->StackSize > 1) {
|
||||
summon_links += fmt::format(
|
||||
" | {}",
|
||||
Saylink::Silent(
|
||||
fmt::format(
|
||||
"#si {} {}",
|
||||
item_id,
|
||||
item->StackSize
|
||||
),
|
||||
std::to_string(item->StackSize)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} | {}",
|
||||
database.CreateItemLink(item_id),
|
||||
summon_links
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Item ID {} not found",
|
||||
item_id
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& search_criteria = Strings::ToLower(sep->argplus[2]);
|
||||
|
||||
const auto& l = ItemsRepository::GetItemIDsBySearchCriteria(content_db, search_criteria, 50);
|
||||
|
||||
if (l.empty()) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"No items were found matching '{}'.",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
auto found_count = 0;
|
||||
|
||||
for (const auto& e : l) {
|
||||
const auto *item = database.GetItem(e);
|
||||
auto summon_links = Saylink::Silent(
|
||||
fmt::format(
|
||||
"#si {}",
|
||||
e
|
||||
),
|
||||
"X"
|
||||
);
|
||||
|
||||
if (item->Stackable && item->StackSize > 1) {
|
||||
summon_links += fmt::format(
|
||||
" | {}",
|
||||
Saylink::Silent(
|
||||
fmt::format(
|
||||
"#si {} {}",
|
||||
e,
|
||||
item->StackSize
|
||||
),
|
||||
std::to_string(item->StackSize)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} | {}",
|
||||
database.CreateItemLink(e),
|
||||
summon_links
|
||||
).c_str()
|
||||
);
|
||||
|
||||
found_count++;
|
||||
|
||||
if (found_count == 50) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found_count == 50) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"50 Items found matching '{}', max reached.",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} Item{} found matching '{}'.",
|
||||
found_count,
|
||||
found_count != 1 ? "s" :"",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
#include "../../client.h"
|
||||
#include "../../common/languages.h"
|
||||
|
||||
void FindLanguage(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (sep->IsNumber(2)) {
|
||||
const auto language_id = Strings::ToInt(sep->arg[2]);
|
||||
if (EQ::ValueWithin(language_id, LANG_COMMON_TONGUE, LANG_UNKNOWN)) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Language {} | {}",
|
||||
language_id,
|
||||
EQ::constants::GetLanguageName(language_id)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Language ID {} was not found.",
|
||||
language_id
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& search_criteria = Strings::ToLower(sep->argplus[2]);
|
||||
|
||||
auto found_count = 0;
|
||||
|
||||
for (const auto& l : EQ::constants::GetLanguageMap()) {
|
||||
const auto& language_name_lower = Strings::ToLower(l.second);
|
||||
if (!Strings::Contains(language_name_lower, search_criteria)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Language {} | {}",
|
||||
l.first,
|
||||
l.second
|
||||
).c_str()
|
||||
);
|
||||
|
||||
found_count++;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} Language{} found matching '{}'.",
|
||||
found_count,
|
||||
found_count != 1 ? "s" : "",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
#include "../../client.h"
|
||||
|
||||
void FindNPCType(Client *c, const Seperator *sep)
|
||||
{
|
||||
std::string query = "SELECT `id`, `name` FROM npc_types WHERE ";
|
||||
const std::string& search_criteria = sep->argplus[2];
|
||||
if (sep->IsNumber(2)) {
|
||||
const auto npc_id = Strings::ToUnsignedInt(sep->arg[2]);
|
||||
|
||||
query += fmt::format(
|
||||
"id = {}",
|
||||
npc_id
|
||||
);
|
||||
} else {
|
||||
query += fmt::format(
|
||||
"`name` LIKE '%%{}%%'",
|
||||
Strings::Escape(search_criteria)
|
||||
);
|
||||
}
|
||||
|
||||
query += " ORDER BY `id` ASC LIMIT 50";
|
||||
|
||||
auto results = content_db.QueryDatabase(query);
|
||||
if (!results.Success() || !results.RowCount()) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"No NPCs matching '{}' were found.",
|
||||
search_criteria
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const auto can_spawn_npcs = c->Admin() >= GetCommandStatus(c, "#npctypespawn");
|
||||
|
||||
auto found_count = 0;
|
||||
|
||||
for (auto row : results) {
|
||||
auto found_number = (found_count + 1);
|
||||
if (found_count == 50) {
|
||||
break;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"NPC {} | {}{}",
|
||||
Strings::Commify(row[0]),
|
||||
row[1],
|
||||
(
|
||||
can_spawn_npcs ?
|
||||
fmt::format(
|
||||
" | {}",
|
||||
Saylink::Silent(
|
||||
fmt::format(
|
||||
"#npctypespawn {}",
|
||||
row[0]
|
||||
),
|
||||
"Spawn"
|
||||
)
|
||||
) :
|
||||
""
|
||||
)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
found_count++;
|
||||
}
|
||||
|
||||
if (found_count == 50) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"50 NPCs found matching '{}', max reached.",
|
||||
search_criteria
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} NPC{} found matching '{}'.",
|
||||
found_count,
|
||||
found_count != 1 ? "s" : "",
|
||||
search_criteria
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
#include "../../client.h"
|
||||
|
||||
void FindRace(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (sep->IsNumber(2)) {
|
||||
const auto race_id = static_cast<uint16>(Strings::ToUnsignedInt(sep->arg[2]));
|
||||
const std::string& race_name = GetRaceIDName(race_id);
|
||||
if (EQ::ValueWithin(race_id, RACE_HUMAN_1, RACE_PEGASUS_732)) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Race {} | {}{}",
|
||||
race_id,
|
||||
race_name,
|
||||
(
|
||||
c->IsPlayerRace(race_id) ?
|
||||
fmt::format(
|
||||
" ({})",
|
||||
Strings::Commify(GetPlayerRaceBit(race_id))
|
||||
) :
|
||||
""
|
||||
)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Race ID {} was not found.",
|
||||
race_id
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& search_criteria = Strings::ToLower(sep->argplus[2]);
|
||||
|
||||
auto found_count = 0;
|
||||
|
||||
for (uint16 race_id = RACE_HUMAN_1; race_id <= RACE_PEGASUS_732; race_id++) {
|
||||
std::string race_name = GetRaceIDName(race_id);
|
||||
auto race_name_lower = Strings::ToLower(race_name);
|
||||
if (!Strings::Contains(race_name_lower, search_criteria)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Race {} | {}{}",
|
||||
race_id,
|
||||
race_name,
|
||||
(
|
||||
c->IsPlayerRace(race_id) ?
|
||||
fmt::format(
|
||||
" ({})",
|
||||
Strings::Commify(GetPlayerRaceBit(race_id))
|
||||
) :
|
||||
""
|
||||
)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
found_count++;
|
||||
|
||||
if (found_count == 50) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found_count == 50) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"50 Races found matching '{}', max reached.",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} Race{} found matching '{}'.",
|
||||
found_count,
|
||||
found_count != 1 ? "s" : "",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
#include "../../client.h"
|
||||
#include "../../command.h"
|
||||
#include "../../common/repositories/tradeskill_recipe_repository.h"
|
||||
|
||||
void FindRecipe(Client *c, const Seperator *sep)
|
||||
{
|
||||
const auto can_view_recipes = c->Admin() >= GetCommandStatus(c, "viewrecipe");
|
||||
|
||||
if (sep->IsNumber(2)) {
|
||||
const auto recipe_id = static_cast<uint16>(Strings::ToUnsignedInt(sep->arg[2]));
|
||||
|
||||
const auto& l = TradeskillRecipeRepository::GetWhere(
|
||||
database,
|
||||
fmt::format("id = {}", recipe_id)
|
||||
);
|
||||
|
||||
if (l.empty() || !l[0].id) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Recipe ID {} could not be found.",
|
||||
Strings::Commify(recipe_id)
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Recipe {} | {}{}",
|
||||
Strings::Commify(recipe_id),
|
||||
l[0].name,
|
||||
(
|
||||
can_view_recipes ?
|
||||
fmt::format(
|
||||
" | {}",
|
||||
Saylink::Silent(
|
||||
fmt::format(
|
||||
"#viewrecipe {}",
|
||||
l[0].id
|
||||
),
|
||||
"View"
|
||||
)
|
||||
) :
|
||||
""
|
||||
)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& search_criteria = Strings::ToLower(sep->argplus[2]);
|
||||
|
||||
auto found_count = 0;
|
||||
|
||||
const auto& l = TradeskillRecipeRepository::GetWhere(
|
||||
database,
|
||||
fmt::format(
|
||||
"LOWER(`name`) LIKE '%%{}%%' ORDER BY `id` ASC",
|
||||
search_criteria
|
||||
)
|
||||
);
|
||||
|
||||
if (l.empty() || !l[0].id) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"No recipes were found matching '{}'.",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto& e : l) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Recipe {} | {}{}",
|
||||
Strings::Commify(e.id),
|
||||
e.name,
|
||||
(
|
||||
can_view_recipes ?
|
||||
fmt::format(
|
||||
" | {}",
|
||||
Saylink::Silent(
|
||||
fmt::format(
|
||||
"#viewrecipe {}",
|
||||
e.id
|
||||
),
|
||||
"View"
|
||||
)
|
||||
) :
|
||||
""
|
||||
)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
if (found_count == 50) {
|
||||
break;
|
||||
}
|
||||
|
||||
found_count++;
|
||||
}
|
||||
|
||||
if (found_count == 50) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"50 Recipes found matching '{}', max reached.",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} Recipe{} found matching '{}'.",
|
||||
found_count,
|
||||
found_count != 1 ? "s" : "",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
#include "../../client.h"
|
||||
|
||||
void FindSkill(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (sep->IsNumber(2)) {
|
||||
const auto skill_id = Strings::ToInt(sep->arg[2]);
|
||||
if (EQ::ValueWithin(skill_id, EQ::skills::Skill1HBlunt, EQ::skills::SkillCount)) {
|
||||
for (const auto& s : EQ::skills::GetSkillTypeMap()) {
|
||||
if (skill_id == s.first) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Skill {} | {}",
|
||||
s.first,
|
||||
s.second
|
||||
).c_str()
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Skill ID {} was not found.",
|
||||
skill_id
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& search_criteria = Strings::ToLower(sep->argplus[2]);
|
||||
|
||||
auto found_count = 0;
|
||||
|
||||
for (const auto& s : EQ::skills::GetSkillTypeMap()) {
|
||||
const auto& skill_name_lower = Strings::ToLower(s.second);
|
||||
if (!Strings::Contains(skill_name_lower, sep->argplus[2])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Skill {} | {}",
|
||||
s.first,
|
||||
s.second
|
||||
).c_str()
|
||||
);
|
||||
|
||||
found_count++;
|
||||
|
||||
if (found_count == 50) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found_count == 50) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"50 Skills were found matching '{}', max reached.",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} Skill{} found matching '{}'.",
|
||||
found_count,
|
||||
found_count != 1 ? "s" : "",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
#include "../../client.h"
|
||||
|
||||
void FindSpell(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (SPDAT_RECORDS <= 0) {
|
||||
c->Message(Chat::White, "Spells not loaded.");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto can_cast_spells = c->Admin() >= GetCommandStatus(c, "castspell");
|
||||
|
||||
if (sep->IsNumber(2)) {
|
||||
const auto spell_id = Strings::ToUnsignedInt(sep->arg[2]);
|
||||
if (!IsValidSpell(spell_id)) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Spell ID {} was not found.",
|
||||
Strings::Commify(spell_id)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Spell {} | {}",
|
||||
Strings::Commify(spell_id),
|
||||
spells[spell_id].name
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& search_criteria = Strings::ToLower(sep->argplus[2]);
|
||||
|
||||
auto found_count = 0;
|
||||
|
||||
for (uint32 spell_id = 0; spell_id < SPDAT_RECORDS; spell_id++) {
|
||||
if (IsValidSpell(spell_id)) {
|
||||
const auto& current_spell = spells[spell_id];
|
||||
|
||||
const std::string& spell_name = current_spell.name;
|
||||
const auto& spell_name_lower = Strings::ToLower(spell_name);
|
||||
if (!Strings::Contains(spell_name_lower, search_criteria)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Spell {} | {}{}",
|
||||
Strings::Commify(spell_id),
|
||||
spell_name,
|
||||
(
|
||||
can_cast_spells ?
|
||||
fmt::format(
|
||||
" | {}",
|
||||
Saylink::Silent(
|
||||
fmt::format(
|
||||
"#castspell {}",
|
||||
spell_id
|
||||
),
|
||||
"Cast"
|
||||
)
|
||||
) :
|
||||
""
|
||||
)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
found_count++;
|
||||
|
||||
if (found_count == 50) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (found_count == 50) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"50 Spells found matching '{}', max reached.",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} Spell{} found matching '{}'.",
|
||||
found_count,
|
||||
found_count != 1 ? "s" : "",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
#include "../../client.h"
|
||||
|
||||
void FindTask(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (!RuleB(TaskSystem, EnableTaskSystem)) {
|
||||
c->Message(Chat::White, "This command cannot be used while the Task system is disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto can_assign_tasks = c->Admin() >= GetCommandStatus(c, "task");
|
||||
|
||||
if (sep->IsNumber(2)) {
|
||||
const auto task_id = Strings::ToUnsignedInt(sep->arg[2]);
|
||||
const auto& task_name = task_manager->GetTaskName(task_id);
|
||||
|
||||
if (task_name.empty()) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Task ID {} was not found.",
|
||||
Strings::Commify(task_id)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Task {} | {}",
|
||||
Strings::Commify(task_id),
|
||||
task_name
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& search_criteria = Strings::ToLower(sep->argplus[2]);
|
||||
|
||||
auto found_count = 0;
|
||||
|
||||
for (const auto& t : task_manager->GetTaskData()) {
|
||||
const auto& task_name = t.second.title;
|
||||
const auto& task_name_lower = Strings::ToLower(task_name);
|
||||
if (!Strings::Contains(task_name_lower, search_criteria)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Task {} | {}{}",
|
||||
Strings::Commify(t.first),
|
||||
task_name,
|
||||
(
|
||||
can_assign_tasks ?
|
||||
fmt::format(
|
||||
" | {}{}",
|
||||
Saylink::Silent(
|
||||
fmt::format(
|
||||
"#task assign {}",
|
||||
t.first
|
||||
),
|
||||
"Assign"
|
||||
),
|
||||
Saylink::Silent(
|
||||
fmt::format(
|
||||
"#task uncomplete {}",
|
||||
t.first
|
||||
),
|
||||
"Uncomplete"
|
||||
)
|
||||
) :
|
||||
""
|
||||
)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
found_count++;
|
||||
|
||||
if (found_count == 50) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found_count == 50) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"50 Tasks were found matching '{}', max reached.",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} Task{} found matching '{}'.",
|
||||
found_count,
|
||||
found_count != 1 ? "s" : "",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
#include "../../client.h"
|
||||
#include "../../common/content/world_content_service.h"
|
||||
|
||||
void FindZone(Client *c, const Seperator *sep)
|
||||
{
|
||||
std::string query = "SELECT zoneidnumber, short_name, long_name, version FROM zone WHERE ";
|
||||
|
||||
const auto is_expansion_search = !strcasecmp(sep->arg[2], "expansion");
|
||||
const auto is_id_search = Strings::IsNumber(sep->arg[2]);
|
||||
const auto is_short_name_search = !is_expansion_search && !is_id_search;
|
||||
|
||||
std::string search_string;
|
||||
std::string search_type;
|
||||
|
||||
if (is_expansion_search) {
|
||||
query += fmt::format(
|
||||
"expansion = {}",
|
||||
Strings::ToInt(sep->arg[3])
|
||||
);
|
||||
|
||||
search_string = Expansion::ExpansionName[Strings::ToInt(sep->arg[3])];
|
||||
search_type = "Expansion";
|
||||
} else if (is_id_search) {
|
||||
query += fmt::format(
|
||||
"zoneidnumber = {}",
|
||||
Strings::ToUnsignedInt(sep->arg[2])
|
||||
);
|
||||
|
||||
search_string = sep->arg[2];
|
||||
search_type = "Expansion";
|
||||
} else if (is_short_name_search) {
|
||||
query += fmt::format(
|
||||
"LOWER(`long_name`) LIKE '%%{}%%' OR LOWER(`short_name`) LIKE '%%{}%%'",
|
||||
Strings::Escape(Strings::ToLower(sep->argplus[2])),
|
||||
Strings::Escape(Strings::ToLower(sep->argplus[2]))
|
||||
);
|
||||
|
||||
search_string = sep->argplus[2];
|
||||
search_type = "Expansion";
|
||||
}
|
||||
|
||||
query += " ORDER BY `zoneidnumber` ASC LIMIT 50";
|
||||
|
||||
auto results = content_db.QueryDatabase(query);
|
||||
if (!results.Success() || !results.RowCount()) {
|
||||
c->Message(Chat::White, "No zones were found matching your search criteria.");
|
||||
c->Message(Chat::White, query.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
auto found_count = 0;
|
||||
|
||||
for (auto row : results) {
|
||||
const auto zone_id = Strings::ToUnsignedInt(row[0]);
|
||||
const std::string& short_name = row[1];
|
||||
const std::string& long_name = row[2];
|
||||
const auto version = Strings::ToInt(row[3]);
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{}{} {} ({}) (ID {}){}",
|
||||
(
|
||||
version == 0 ?
|
||||
fmt::format(
|
||||
"{} | ",
|
||||
Saylink::Silent(
|
||||
fmt::format(
|
||||
"#zone {}",
|
||||
short_name
|
||||
),
|
||||
"Zone"
|
||||
)
|
||||
) :
|
||||
""
|
||||
),
|
||||
fmt::format(
|
||||
"{} |",
|
||||
Saylink::Silent(
|
||||
fmt::format(
|
||||
"#gmzone {} {}",
|
||||
short_name,
|
||||
version
|
||||
),
|
||||
"GM Zone"
|
||||
)
|
||||
),
|
||||
long_name,
|
||||
short_name,
|
||||
zone_id,
|
||||
(
|
||||
version != 0 ?
|
||||
fmt::format(
|
||||
" (Version {})",
|
||||
version
|
||||
) :
|
||||
""
|
||||
)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
found_count++;
|
||||
|
||||
if (found_count == 50) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found_count == 50) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"50 Zones found matching '{}' of '{}'.",
|
||||
search_type,
|
||||
search_string
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} Zone{} found matching '{}' of '{}'.",
|
||||
found_count,
|
||||
found_count != 1 ? "s" : "",
|
||||
search_type,
|
||||
search_string
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user