From 17034a6e47b9b36c7def7b49842491f80c73465e Mon Sep 17 00:00:00 2001 From: Kinglykrab <89047260+Kinglykrab@users.noreply.github.com> Date: Sat, 4 Jun 2022 13:59:46 -0400 Subject: [PATCH] [Commands] Cleanup #spawneditmass Command. (#2229) * [Commands] Cleanup #spawneditmass Command. - Cleanup messages and logic. - Split command into its own file. * Save querying database if they're not using the only supported option. * Condense to one message. --- zone/command.cpp | 133 +------------------------- zone/gm_commands/spawneditmass.cpp | 148 +++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+), 131 deletions(-) create mode 100644 zone/gm_commands/spawneditmass.cpp diff --git a/zone/command.cpp b/zone/command.cpp index 01ab70256..b8914e593 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -299,7 +299,7 @@ int command_init(void) command_add("showzonepoints", "Show zone points for current zone", AccountStatus::Guide, command_showzonepoints) || command_add("shutdown", "Shut this zone process down", AccountStatus::GMLeadAdmin, command_shutdown) || command_add("spawn", "[name] [race] [level] [material] [hp] [gender] [class] [priweapon] [secweapon] [merchantid] - Spawn an NPC", AccountStatus::Steward, command_spawn) || - command_add("spawneditmass", "Mass editing spawn command", AccountStatus::GMLeadAdmin, command_spawneditmass) || + command_add("spawneditmass", "[Search Criteria] [Edit Option] [Edit Value] [Apply] Mass editing spawn command (Apply is optional, 0 = False, 1 = True, default is False)", AccountStatus::GMLeadAdmin, command_spawneditmass) || command_add("spawnfix", "Find targeted NPC in database based on its X/Y/heading and update the database to make it spawn at your current location/heading.", AccountStatus::GMAreas, command_spawnfix) || command_add("spawnstatus", "[All|Disabled|Enabled|Spawn ID] - Show respawn timer status", AccountStatus::GMAdmin, command_spawnstatus) || command_add("spellinfo", "[spellid] - Get detailed info about a spell", AccountStatus::Steward, command_spellinfo) || @@ -651,136 +651,6 @@ void command_help(Client *c, const Seperator *sep) ); } -void command_spawneditmass(Client *c, const Seperator *sep) -{ - std::string query = fmt::format( - SQL( - SELECT - npc_types.id, - npc_types.name, - spawn2.respawntime, - spawn2.id - FROM - npc_types - JOIN spawnentry ON spawnentry.npcID = npc_types.id - JOIN spawn2 ON spawn2.spawngroupID = spawnentry.spawngroupID - WHERE - spawn2.zone = '{0}' and spawn2.version = {1} - GROUP BY npc_types.id - ), - zone->GetShortName(), - zone->GetInstanceVersion() - ); - - std::string status = "(Searching)"; - - if (strcasecmp(sep->arg[4], "apply") == 0) { - status = "(Applying)"; - } - - std::string search_value; - std::string edit_option; - std::string edit_value; - std::string apply_set; - - if (sep->arg[1]) { - search_value = sep->arg[1]; - } - - if (sep->arg[2]) { - edit_option = sep->arg[2]; - } - - if (sep->arg[3]) { - edit_value = sep->arg[3]; - } - - if (sep->arg[4]) { - apply_set = sep->arg[4]; - } - - if (!edit_option.empty() && edit_value.empty()) { - c->Message(Chat::Yellow, "Please specify an edit option value | #npceditmass