mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-21 06:01:29 +00:00
* First push * Final push. * Consolidate zone commands in to one. * Update command.cpp * Remove debug messages. * Test * Add support for sub command status levels. * Update command.cpp * Update client.cpp * Update database_update_manifest.cpp * Update version.h * Update item.cpp * Update version.h * Update database_update_manifest.cpp * Fix command arguments. * Help message. * Update command.cpp * Do DB injection/deletion * Indent * Update server_locked.cpp * Update set.cpp * Lock aliases * Update command_subsettings_repository.h * Update set.cpp * Fix --------- Co-authored-by: Akkadius <akkadius1@gmail.com>
141 lines
2.2 KiB
C++
141 lines
2.2 KiB
C++
#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) {
|
|
std::string 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(
|
|
"{} | {}",
|
|
summon_links,
|
|
database.CreateItemLink(item_id)
|
|
).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);
|
|
if (!item) {
|
|
continue;
|
|
}
|
|
|
|
std::string 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(
|
|
"{} | {} ({})",
|
|
summon_links,
|
|
database.CreateItemLink(e),
|
|
Strings::Commify(item->ID)
|
|
).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()
|
|
);
|
|
}
|
|
|