mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
Added bulk edit command #npceditmass <column-to-search> <column-search-value> <change-column> <change-value>
This commit is contained in:
parent
e9cb8781bf
commit
1c6a76246f
@ -1,5 +1,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>
|
||||
|
||||
== 8/6/2019 ==
|
||||
Akkadius: Optimizations to movement updates to eliminate ghosting possibilities in larger zones
|
||||
|
||||
|
||||
@ -27,6 +27,8 @@
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef va_copy
|
||||
@ -119,19 +121,27 @@ std::vector<std::string> SplitString(const std::string &str, char delim) {
|
||||
while(std::getline(ss, item, delim)) {
|
||||
ret.push_back(item);
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static std::string implode(char *sep, std::vector<std::string> src)
|
||||
std::string implode(std::string glue, std::vector<std::string> src)
|
||||
{
|
||||
std::ostringstream output;
|
||||
if (src.empty()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::ostringstream output;
|
||||
std::vector<std::string>::iterator src_iter;
|
||||
|
||||
for (src_iter = src.begin(); src_iter != src.end(); src_iter++)
|
||||
output << *src_iter << sep;
|
||||
for (src_iter = src.begin(); src_iter != src.end(); src_iter++) {
|
||||
output << *src_iter << glue;
|
||||
}
|
||||
|
||||
return output.str();
|
||||
std::string final_output = output.str();
|
||||
final_output.resize (output.str().size () - glue.size());
|
||||
|
||||
return final_output;
|
||||
}
|
||||
|
||||
std::string EscapeString(const std::string &s) {
|
||||
|
||||
@ -30,7 +30,7 @@ const std::string ucfirst(std::string s);
|
||||
std::vector<std::string> split(std::string str_to_split, char delimiter);
|
||||
const std::string StringFormat(const char* format, ...);
|
||||
const std::string vStringFormat(const char* format, va_list args);
|
||||
static std::string implode(char *sep, std::vector<std::string> src);
|
||||
std::string implode(std::string glue, std::vector<std::string> src);
|
||||
std::vector<std::string> SplitString(const std::string &s, char delim);
|
||||
std::string EscapeString(const char *src, size_t sz);
|
||||
std::string EscapeString(const std::string &s);
|
||||
|
||||
@ -7337,6 +7337,15 @@ void command_npceditmass(Client *c, const Seperator *sep)
|
||||
zone->GetInstanceVersion()
|
||||
);
|
||||
|
||||
std::string status = "(Searching)";
|
||||
|
||||
if (strcasecmp(sep->arg[5], "apply") == 0) {
|
||||
status = "(Applying)";
|
||||
}
|
||||
|
||||
std::vector <std::string> npc_ids;
|
||||
|
||||
int found_count = 0;
|
||||
results = database.QueryDatabase(query);
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
|
||||
@ -7352,16 +7361,60 @@ void command_npceditmass(Client *c, const Seperator *sep)
|
||||
c->Message(
|
||||
15,
|
||||
fmt::format(
|
||||
"NPC ({0}) [{1}] ({2}) [{3}] Current ({4}) [{5}] New [{6}]",
|
||||
"NPC ({0}) [{1}] ({2}) [{3}] Current ({4}) [{5}] New [{6}] {7}",
|
||||
npc_id,
|
||||
npc_name,
|
||||
search_column,
|
||||
search_column_value,
|
||||
change_column,
|
||||
change_column_current_value,
|
||||
change_value
|
||||
change_value,
|
||||
status
|
||||
).c_str()
|
||||
);
|
||||
|
||||
npc_ids.push_back(npc_id);
|
||||
|
||||
found_count++;
|
||||
}
|
||||
|
||||
std::string saylink = fmt::format(
|
||||
"#npceditmass {} {} {} {} apply",
|
||||
search_column,
|
||||
search_value,
|
||||
change_column,
|
||||
change_value
|
||||
);
|
||||
|
||||
if (strcasecmp(sep->arg[5], "apply") == 0) {
|
||||
std::string npc_ids_string = implode(",", npc_ids);
|
||||
if (npc_ids_string.empty()) {
|
||||
c->Message(Chat::Red, "Error: Ran into an unknown error compiling NPC IDs");
|
||||
return;
|
||||
}
|
||||
|
||||
database.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE `npc_types` SET {} = {} WHERE id IN ({})",
|
||||
change_column,
|
||||
change_value,
|
||||
npc_ids_string
|
||||
)
|
||||
);
|
||||
|
||||
c->Message(Chat::Yellow, "Changes applied to (%i) NPC's", found_count);
|
||||
zone->Repop();
|
||||
}
|
||||
else {
|
||||
c->Message(Chat::Yellow, "Found (%i) NPC's that match this search...", found_count);
|
||||
|
||||
if (found_count > 0) {
|
||||
c->Message(
|
||||
Chat::Yellow, "To apply these changes, click <%s> or type [%s]",
|
||||
EQEmu::SayLinkEngine::GenerateQuestSaylink(saylink, false, "Apply").c_str(),
|
||||
saylink.c_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -12232,7 +12285,7 @@ void command_scale(Client *c, const Seperator *sep)
|
||||
|
||||
c->Message(Chat::Yellow, "Found (%i) NPC's that match this search...", found_count);
|
||||
c->Message(
|
||||
15, "To apply these changes, click <%s> or type %s",
|
||||
Chat::Yellow, "To apply these changes, click <%s> or type %s",
|
||||
EQEmu::SayLinkEngine::GenerateQuestSaylink(saylink, false, "Apply").c_str(),
|
||||
saylink.c_str()
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user