mirror of
https://github.com/EQEmu/Server.git
synced 2026-09-05 07:16:37 +00:00
[Cleanup] Cleanup Bucket Comparison Code (#4374)
* [Cleanup] Cleanup Bucket Comparison-based Code * Final
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "find/bug_category.cpp"
|
||||
#include "find/character.cpp"
|
||||
#include "find/class.cpp"
|
||||
#include "find/comparison_type.cpp"
|
||||
#include "find/currency.cpp"
|
||||
#include "find/deity.cpp"
|
||||
#include "find/emote.cpp"
|
||||
@@ -35,6 +36,7 @@ void command_find(Client *c, const Seperator *sep)
|
||||
Cmd{.cmd = "bug_category", .u = "bug_category [Search Criteria]", .fn = FindBugCategory, .a = {"#findbugcategory"}},
|
||||
Cmd{.cmd = "character", .u = "character [Search Criteria]", .fn = FindCharacter, .a = {"#findcharacter"}},
|
||||
Cmd{.cmd = "class", .u = "class [Search Criteria]", .fn = FindClass, .a = {"#findclass"}},
|
||||
Cmd{.cmd = "comparison_type", .u = "comparison_type [Search Criteria]", .fn = FindComparisonType, .a = {"#findcomparisontype"}},
|
||||
Cmd{.cmd = "currency", .u = "currency [Search Criteria]", .fn = FindCurrency, .a = {"#findcurrency"}},
|
||||
Cmd{.cmd = "deity", .u = "deity [Search Criteria]", .fn = FindDeity, .a = {"#finddeity"}},
|
||||
Cmd{.cmd = "emote", .u = "emote [Search Criteria]", .fn = FindEmote, .a = {"#findemote"}},
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
#include "../../client.h"
|
||||
|
||||
void FindComparisonType(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (sep->IsNumber(2)) {
|
||||
const uint8 type = static_cast<uint8>(Strings::ToUnsignedInt(sep->arg[2]));
|
||||
const std::string& type_name = ComparisonType::GetName(type);
|
||||
if (Strings::EqualFold(type_name, "UNKNOWN COMPARISON TYPE")) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Comparison Type {} does not exist.",
|
||||
type
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Comparison Type {} | {}",
|
||||
type,
|
||||
type_name
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string& search_criteria = Strings::ToLower(sep->argplus[2]);
|
||||
|
||||
uint32 found_count = 0;
|
||||
|
||||
for (const auto& e : comparison_types) {
|
||||
const std::string& type_name_lower = Strings::ToLower(e.second);
|
||||
if (!Strings::Contains(type_name_lower, search_criteria)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Comparison Type {} | {}",
|
||||
e.first,
|
||||
e.second
|
||||
).c_str()
|
||||
);
|
||||
|
||||
found_count++;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} Comparison Type{} found matching '{}'.",
|
||||
found_count,
|
||||
found_count != 1 ? "s" : "",
|
||||
sep->argplus[2]
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user