mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-18 08:18:27 +00:00
Merge branch 'master' of https://github.com/EQEmu/Server into io_work
This commit is contained in:
@@ -182,6 +182,7 @@ int command_init(void)
|
||||
command_add("crashtest", "- Crash the zoneserver", 255, command_crashtest) ||
|
||||
command_add("cvs", "- Summary of client versions currently online.", 200, command_cvs) ||
|
||||
command_add("damage", "[amount] - Damage your target", 100, command_damage) ||
|
||||
command_add("databuckets", "View|Delete [key] [limit]- View data buckets, limit 50 default or Delete databucket by key", 80, command_databuckets) ||
|
||||
command_add("date", "[yyyy] [mm] [dd] [HH] [MM] - Set EQ time", 90, command_date) ||
|
||||
command_add("dbspawn2", "[spawngroup] [respawn] [variance] - Spawn an NPC from a predefined row in the spawn2 table", 100, command_dbspawn2) ||
|
||||
command_add("delacct", "[accountname] - Delete an account", 150, command_delacct) ||
|
||||
@@ -12637,6 +12638,85 @@ void command_scale(Client *c, const Seperator *sep)
|
||||
}
|
||||
}
|
||||
|
||||
void command_databuckets(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (sep->arg[1][0] == 0) {
|
||||
c->Message(Chat::Yellow, "Usage: #databuckets view (partial key)|(limit) OR #databuckets delete (key)");
|
||||
return;
|
||||
}
|
||||
if (strcasecmp(sep->arg[1], "view") == 0) {
|
||||
|
||||
std::string key_filter;
|
||||
uint8 limit = 50;
|
||||
for (int i = 2; i < 4; i++) {
|
||||
if (sep->arg[i][0] == '\0')
|
||||
break;
|
||||
if (strcasecmp(sep->arg[i], "limit") == 0) {
|
||||
limit = (uint8)atoi(sep->arg[i + 1]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (sep->arg[2]) {
|
||||
key_filter = str_tolower(sep->arg[2]);
|
||||
}
|
||||
std::string query = "SELECT `id`, `key`, `value`, `expires` FROM data_buckets";
|
||||
if (!key_filter.empty()) query += StringFormat(" WHERE `key` LIKE '%%%s%%'", key_filter.c_str());
|
||||
query += StringFormat(" LIMIT %u", limit);
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
return;
|
||||
if (results.RowCount() == 0) {
|
||||
c->Message(Chat::Yellow, "No data_buckets found");
|
||||
return;
|
||||
}
|
||||
int _ctr = 0;
|
||||
// put in window for easier readability in case want command line for something else
|
||||
std::string window_title = "Data Buckets";
|
||||
std::string window_text =
|
||||
"<table>"
|
||||
"<tr>"
|
||||
"<td>ID</td>"
|
||||
"<td>Expires</td>"
|
||||
"<td>Key</td>"
|
||||
"<td>Value</td>"
|
||||
"</tr>";
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
auto id = static_cast<uint32>(atoi(row[0]));
|
||||
std::string key = row[1];
|
||||
std::string value = row[2];
|
||||
std::string expires = row[3];
|
||||
window_text.append(StringFormat(
|
||||
"<tr>"
|
||||
"<td>%u</td>"
|
||||
"<td>%s</td>"
|
||||
"<td>%s</td>"
|
||||
"<td>%s</td>"
|
||||
"</tr>",
|
||||
id,
|
||||
expires.c_str(),
|
||||
key.c_str(),
|
||||
value.c_str()
|
||||
));
|
||||
_ctr++;
|
||||
std::string del_saylink = StringFormat("#databuckets delete %s", key.c_str());
|
||||
c->Message(Chat::White, "%s : %s",
|
||||
EQEmu::SayLinkEngine::GenerateQuestSaylink(del_saylink, false, "Delete").c_str(), key.c_str(), " Value: ", value.c_str());
|
||||
}
|
||||
window_text.append("</table>");
|
||||
c->SendPopupToClient(window_title.c_str(), window_text.c_str());
|
||||
std::string response = _ctr > 0 ? StringFormat("Found %i matching data buckets", _ctr).c_str() : "No Databuckets found.";
|
||||
c->Message(Chat::Yellow, response.c_str());
|
||||
}
|
||||
else if (strcasecmp(sep->arg[1], "delete") == 0)
|
||||
{
|
||||
if (DataBucket::DeleteData(sep->argplus[2]))
|
||||
c->Message(Chat::Yellow, "data bucket %s deleted.", sep->argplus[2]);
|
||||
else
|
||||
c->Message(Chat::Red, "An error occurred deleting data bucket %s", sep->argplus[2]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void command_who(Client *c, const Seperator *sep)
|
||||
{
|
||||
std::string query =
|
||||
|
||||
Reference in New Issue
Block a user