mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-10 12:02:31 +00:00
[Bug Fix] Find Zone - Expansion Settings (#4692)
* Bug Fix Find Zone - Expansion Settings #fz expansion 30 Would crash your zone since the expansions don't go up that high. This Adds a check for range out of bounds and provides an exception to expansion 99 since those are test/dev zones. * Update zone.cpp * Update zone.cpp * Update zone.cpp --------- Co-authored-by: Kinglykrab <kinglykrab@gmail.com>
This commit is contained in:
parent
55155ff800
commit
8315240b17
@ -1,35 +1,51 @@
|
|||||||
#include "../../client.h"
|
#include "../../client.h"
|
||||||
#include "../../common/content/world_content_service.h"
|
#include "../../common/content/world_content_service.h"
|
||||||
|
|
||||||
void FindZone(Client *c, const Seperator *sep)
|
void FindZone(Client* c, const Seperator* sep)
|
||||||
{
|
{
|
||||||
std::string query = "SELECT zoneidnumber, short_name, long_name, version FROM zone WHERE ";
|
std::string where_filter = std::string();
|
||||||
|
|
||||||
const auto is_expansion_search = !strcasecmp(sep->arg[2], "expansion");
|
const bool is_expansion_search = !strcasecmp(sep->arg[2], "expansion");
|
||||||
const auto is_id_search = Strings::IsNumber(sep->arg[2]);
|
const bool is_id_search = Strings::IsNumber(sep->arg[2]);
|
||||||
const auto is_short_name_search = !is_expansion_search && !is_id_search;
|
const bool is_short_name_search = !is_expansion_search && !is_id_search;
|
||||||
|
|
||||||
std::string search_string;
|
std::string search_string;
|
||||||
std::string search_type;
|
std::string search_type;
|
||||||
|
|
||||||
if (is_expansion_search) {
|
if (is_expansion_search) {
|
||||||
query += fmt::format(
|
int expansion_id = Strings::ToInt(sep->arg[3]);
|
||||||
"expansion = {}",
|
|
||||||
Strings::ToInt(sep->arg[3])
|
|
||||||
);
|
|
||||||
|
|
||||||
search_string = Expansion::ExpansionName[Strings::ToInt(sep->arg[3])];
|
if (
|
||||||
search_type = "expansion";
|
!EQ::ValueWithin(expansion_id, Expansion::Classic, Expansion::MaxId - 1) &&
|
||||||
|
expansion_id != Expansion::EXPANSION_FILTER_MAX
|
||||||
|
) {
|
||||||
|
c->Message(
|
||||||
|
Chat::White,
|
||||||
|
fmt::format(
|
||||||
|
"Invalid expansion ID: {}. Please enter a value between 0 and {}, or 99.",
|
||||||
|
expansion_id,
|
||||||
|
Expansion::MaxId - 1
|
||||||
|
).c_str()
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
where_filter = fmt::format("expansion = {}", expansion_id);
|
||||||
|
|
||||||
|
if (expansion_id == Expansion::EXPANSION_FILTER_MAX) {
|
||||||
|
search_string = "Test Zones";
|
||||||
|
} else {
|
||||||
|
search_string = Expansion::ExpansionName[expansion_id];
|
||||||
|
}
|
||||||
|
|
||||||
|
search_type = "expansion";
|
||||||
} else if (is_id_search) {
|
} else if (is_id_search) {
|
||||||
query += fmt::format(
|
where_filter = fmt::format("zoneidnumber = {}", Strings::ToUnsignedInt(sep->arg[2]));
|
||||||
"zoneidnumber = {}",
|
|
||||||
Strings::ToUnsignedInt(sep->arg[2])
|
|
||||||
);
|
|
||||||
|
|
||||||
search_string = sep->arg[2];
|
search_string = sep->arg[2];
|
||||||
search_type = "ID";
|
search_type = "ID";
|
||||||
} else if (is_short_name_search) {
|
} else if (is_short_name_search) {
|
||||||
query += fmt::format(
|
where_filter = fmt::format(
|
||||||
"LOWER(`long_name`) LIKE '%%{}%%' OR LOWER(`short_name`) LIKE '%%{}%%'",
|
"LOWER(`long_name`) LIKE '%%{}%%' OR LOWER(`short_name`) LIKE '%%{}%%'",
|
||||||
Strings::Escape(Strings::ToLower(sep->argplus[2])),
|
Strings::Escape(Strings::ToLower(sep->argplus[2])),
|
||||||
Strings::Escape(Strings::ToLower(sep->argplus[2]))
|
Strings::Escape(Strings::ToLower(sep->argplus[2]))
|
||||||
@ -39,35 +55,30 @@ void FindZone(Client *c, const Seperator *sep)
|
|||||||
search_type = "name";
|
search_type = "name";
|
||||||
}
|
}
|
||||||
|
|
||||||
query += " ORDER BY `zoneidnumber` ASC LIMIT 50";
|
where_filter += " ORDER BY `zoneidnumber` ASC LIMIT 50";
|
||||||
|
|
||||||
auto results = content_db.QueryDatabase(query);
|
const auto& l = ZoneRepository::GetWhere(content_db, where_filter);
|
||||||
if (!results.Success() || !results.RowCount()) {
|
|
||||||
|
if (l.empty()) {
|
||||||
c->Message(Chat::White, "No zones were found matching your search criteria.");
|
c->Message(Chat::White, "No zones were found matching your search criteria.");
|
||||||
c->Message(Chat::White, query.c_str());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto found_count = 0;
|
uint32 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]);
|
|
||||||
|
|
||||||
|
for (const auto& e : l) {
|
||||||
c->Message(
|
c->Message(
|
||||||
Chat::White,
|
Chat::White,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"{}{} {} ({}) (ID {}){}",
|
"{}{} {} ({}) (ID {}){}",
|
||||||
(
|
(
|
||||||
version == 0 ?
|
e.version == 0 ?
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"{} | ",
|
"{} | ",
|
||||||
Saylink::Silent(
|
Saylink::Silent(
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"#zone {}",
|
"#zone {}",
|
||||||
short_name
|
e.short_name
|
||||||
),
|
),
|
||||||
"Zone"
|
"Zone"
|
||||||
)
|
)
|
||||||
@ -79,20 +90,20 @@ void FindZone(Client *c, const Seperator *sep)
|
|||||||
Saylink::Silent(
|
Saylink::Silent(
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"#gmzone {} {}",
|
"#gmzone {} {}",
|
||||||
short_name,
|
e.short_name,
|
||||||
version
|
e.version
|
||||||
),
|
),
|
||||||
"GM Zone"
|
"GM Zone"
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
long_name,
|
e.long_name,
|
||||||
short_name,
|
e.short_name,
|
||||||
zone_id,
|
e.zoneidnumber,
|
||||||
(
|
(
|
||||||
version != 0 ?
|
e.version != 0 ?
|
||||||
fmt::format(
|
fmt::format(
|
||||||
" (Version {})",
|
" (Version {})",
|
||||||
version
|
e.version
|
||||||
) :
|
) :
|
||||||
""
|
""
|
||||||
)
|
)
|
||||||
@ -110,7 +121,7 @@ void FindZone(Client *c, const Seperator *sep)
|
|||||||
c->Message(
|
c->Message(
|
||||||
Chat::White,
|
Chat::White,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"50 Zones found matching '{}' of '{}'.",
|
"50 Zones found matching '{}' of '{}', max reached.",
|
||||||
search_type,
|
search_type,
|
||||||
search_string
|
search_string
|
||||||
).c_str()
|
).c_str()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user