mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 18:51: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)
|
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 ==
|
== 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
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,8 @@
|
|||||||
#else
|
#else
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef va_copy
|
#ifndef va_copy
|
||||||
@ -123,15 +125,23 @@ std::vector<std::string> SplitString(const std::string &str, char delim) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string implode(char *sep, std::vector<std::string> src)
|
std::string implode(std::string glue, std::vector<std::string> src)
|
||||||
{
|
{
|
||||||
|
if (src.empty()) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
std::ostringstream output;
|
std::ostringstream output;
|
||||||
std::vector<std::string>::iterator src_iter;
|
std::vector<std::string>::iterator src_iter;
|
||||||
|
|
||||||
for (src_iter = src.begin(); src_iter != src.end(); src_iter++)
|
for (src_iter = src.begin(); src_iter != src.end(); src_iter++) {
|
||||||
output << *src_iter << sep;
|
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) {
|
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);
|
std::vector<std::string> split(std::string str_to_split, char delimiter);
|
||||||
const std::string StringFormat(const char* format, ...);
|
const std::string StringFormat(const char* format, ...);
|
||||||
const std::string vStringFormat(const char* format, va_list args);
|
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::vector<std::string> SplitString(const std::string &s, char delim);
|
||||||
std::string EscapeString(const char *src, size_t sz);
|
std::string EscapeString(const char *src, size_t sz);
|
||||||
std::string EscapeString(const std::string &s);
|
std::string EscapeString(const std::string &s);
|
||||||
|
|||||||
@ -7337,6 +7337,15 @@ void command_npceditmass(Client *c, const Seperator *sep)
|
|||||||
zone->GetInstanceVersion()
|
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);
|
results = database.QueryDatabase(query);
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
|
||||||
@ -7352,16 +7361,60 @@ void command_npceditmass(Client *c, const Seperator *sep)
|
|||||||
c->Message(
|
c->Message(
|
||||||
15,
|
15,
|
||||||
fmt::format(
|
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_id,
|
||||||
npc_name,
|
npc_name,
|
||||||
search_column,
|
search_column,
|
||||||
search_column_value,
|
search_column_value,
|
||||||
change_column,
|
change_column,
|
||||||
change_column_current_value,
|
change_column_current_value,
|
||||||
change_value
|
change_value,
|
||||||
|
status
|
||||||
).c_str()
|
).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(Chat::Yellow, "Found (%i) NPC's that match this search...", found_count);
|
||||||
c->Message(
|
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(),
|
EQEmu::SayLinkEngine::GenerateQuestSaylink(saylink, false, "Apply").c_str(),
|
||||||
saylink.c_str()
|
saylink.c_str()
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user