mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-18 19:41:30 +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 ==
|
== 8/11/2019 ==
|
||||||
Akkadius: Added bulk edit command #npceditmass <column-to-search> <column-search-value> <change-column> <change-value>
|
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 ==
|
== 8/6/2019 ==
|
||||||
Akkadius: Optimizations to movement updates to eliminate ghosting possibilities in larger zones
|
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)
|
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]");
|
c->Message(Chat::White, "Usage: #findzone [search criteria]");
|
||||||
return;
|
c->Message(Chat::White, "Usage: #findzone expansion [expansion number]");
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::string query;
|
std::string query;
|
||||||
int id = atoi((const char *)sep->arg[1]);
|
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]));
|
|
||||||
|
|
||||||
query = StringFormat("SELECT zoneidnumber, short_name, long_name FROM zone "
|
std::string arg1 = sep->arg[1];
|
||||||
"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);
|
|
||||||
|
|
||||||
auto results = database.QueryDatabase(query);
|
if (arg1 == "expansion") {
|
||||||
if (!results.Success()) {
|
query = fmt::format(
|
||||||
c->Message (0, "Error querying database.");
|
"SELECT zoneidnumber, short_name, long_name, version FROM zone WHERE expansion = {}",
|
||||||
c->Message (0, query.c_str());
|
sep->arg[2]
|
||||||
return;
|
);
|
||||||
}
|
}
|
||||||
|
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) {
|
auto results = database.QueryDatabase(query);
|
||||||
if (++count > maxrows) {
|
if (!results.Success()) {
|
||||||
c->Message (0, "%i zones shown. Too many results.", maxrows);
|
c->Message(Chat::White, "Error querying database.");
|
||||||
break;
|
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)
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
c->Message (0, "Query complete. %i rows shown.", count);
|
std::string zone_id = row[0];
|
||||||
else if (count == 0)
|
std::string short_name = row[1];
|
||||||
c->Message (0, "No matches found for %s.", sep->arg[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)
|
void command_viewnpctype(Client *c, const Seperator *sep)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user