mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 14:41:28 +00:00
Modifications to findzone
This commit is contained in:
parent
a2364023c4
commit
1ef577bc25
@ -2,6 +2,8 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50)
|
||||
-------------------------------------------------------
|
||||
== 8/11/2019 ==
|
||||
Akkadius: Added bulk edit command #npceditmass <column-to-search> <column-search-value> <change-column> <change-value>
|
||||
Akkadius: Modified #findzone to include clickable saylinks to both regular zone (if able) and private gmzone instances
|
||||
Akkadius: Added #findzone expansion <expansion-number> to show zones via expansion
|
||||
|
||||
== 8/6/2019 ==
|
||||
Akkadius: Optimizations to movement updates to eliminate ghosting possibilities in larger zones
|
||||
|
||||
114
zone/command.cpp
114
zone/command.cpp
@ -3720,49 +3720,93 @@ void command_findnpctype(Client *c, const Seperator *sep)
|
||||
|
||||
void command_findzone(Client *c, const Seperator *sep)
|
||||
{
|
||||
if(sep->arg[1][0] == 0) {
|
||||
if (sep->arg[1][0] == 0) {
|
||||
c->Message(Chat::White, "Usage: #findzone [search criteria]");
|
||||
return;
|
||||
}
|
||||
c->Message(Chat::White, "Usage: #findzone expansion [expansion number]");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string query;
|
||||
int id = atoi((const char *)sep->arg[1]);
|
||||
if (id == 0) { // If id evaluates to 0, then search as if user entered a string.
|
||||
auto escName = new char[strlen(sep->arg[1]) * 2 + 1];
|
||||
database.DoEscapeString(escName, sep->arg[1], strlen(sep->arg[1]));
|
||||
std::string query;
|
||||
int id = atoi((const char *) sep->arg[1]);
|
||||
|
||||
query = StringFormat("SELECT zoneidnumber, short_name, long_name FROM zone "
|
||||
"WHERE long_name RLIKE '%s' AND version = 0",
|
||||
escName);
|
||||
safe_delete_array(escName);
|
||||
}
|
||||
else // Otherwise, look for just that zoneidnumber.
|
||||
query = StringFormat("SELECT zoneidnumber, short_name, long_name FROM zone "
|
||||
"WHERE zoneidnumber = %i AND version = 0", id);
|
||||
std::string arg1 = sep->arg[1];
|
||||
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
c->Message (0, "Error querying database.");
|
||||
c->Message (0, query.c_str());
|
||||
return;
|
||||
}
|
||||
if (arg1 == "expansion") {
|
||||
query = fmt::format(
|
||||
"SELECT zoneidnumber, short_name, long_name, version FROM zone WHERE expansion = {}",
|
||||
sep->arg[2]
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
||||
int count = 0;
|
||||
const int maxrows = 20;
|
||||
/**
|
||||
* If id evaluates to 0, then search as if user entered a string
|
||||
*/
|
||||
if (id == 0) {
|
||||
query = fmt::format(
|
||||
"SELECT zoneidnumber, short_name, long_name, version FROM zone WHERE long_name LIKE '%{}%'",
|
||||
EscapeString(sep->arg[1])
|
||||
);
|
||||
}
|
||||
else {
|
||||
query = fmt::format(
|
||||
"SELECT zoneidnumber, short_name, long_name, version FROM zone WHERE zoneidnumber = {}",
|
||||
id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for(auto row = results.begin(); row != results.end(); ++row) {
|
||||
if (++count > maxrows) {
|
||||
c->Message (0, "%i zones shown. Too many results.", maxrows);
|
||||
break;
|
||||
}
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
c->Message(Chat::White, "Error querying database.");
|
||||
c->Message(Chat::White, query.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message (0, " %s: %s, %s", row[0], row[1], row[2]);
|
||||
}
|
||||
int count = 0;
|
||||
const int maxrows = 100;
|
||||
|
||||
if (count <= maxrows)
|
||||
c->Message (0, "Query complete. %i rows shown.", count);
|
||||
else if (count == 0)
|
||||
c->Message (0, "No matches found for %s.", sep->arg[1]);
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
std::string zone_id = row[0];
|
||||
std::string short_name = row[1];
|
||||
std::string long_name = row[2];
|
||||
int version = atoi(row[3]);
|
||||
|
||||
if (++count > maxrows) {
|
||||
c->Message(Chat::White, "%i zones shown. Too many results.", maxrows);
|
||||
break;
|
||||
}
|
||||
|
||||
std::string command_zone = EQEmu::SayLinkEngine::GenerateQuestSaylink("#zone " + short_name, false, "zone");
|
||||
std::string command_gmzone = EQEmu::SayLinkEngine::GenerateQuestSaylink(
|
||||
fmt::format("#gmzone {} {}", short_name, version),
|
||||
false,
|
||||
"gmzone"
|
||||
);
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"[{}] [{}] [{}] Version ({}) [{}]",
|
||||
(version == 0 ? command_zone : "zone"),
|
||||
command_gmzone,
|
||||
short_name,
|
||||
version,
|
||||
long_name
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
|
||||
if (count <= maxrows) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
"Query complete. %i rows shown. %s",
|
||||
count,
|
||||
(arg1 == "expansion" ? "(expansion search)" : ""));
|
||||
}
|
||||
else if (count == 0) {
|
||||
c->Message(Chat::White, "No matches found for %s.", sep->arg[1]);
|
||||
}
|
||||
}
|
||||
|
||||
void command_viewnpctype(Client *c, const Seperator *sep)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user