mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-27 12:01:29 +00:00
[CLI] Add mercs:enable and mercs:disable commands (#3416)
* [CLI] Add `mercs:enable` and `mercs:disable` commands * Update descriptions
This commit is contained in:
parent
cf49b2fe49
commit
a663c822e8
@ -2447,6 +2447,9 @@ void Database::SourceSqlFromUrl(std::string url)
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (res->status == 404) {
|
||||
LogError("Error retrieving URL [{}]", url);
|
||||
}
|
||||
}
|
||||
else {
|
||||
LogError("Error retrieving URL [{}]", url);
|
||||
|
||||
7067
utils/sql/merc_tables_bootstrap.sql
Normal file
7067
utils/sql/merc_tables_bootstrap.sql
Normal file
File diff suppressed because it is too large
Load Diff
33
world/cli/mercs_disable.cpp
Normal file
33
world/cli/mercs_disable.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include "../worlddb.h"
|
||||
#include "../../common/database_schema.h"
|
||||
|
||||
void WorldserverCLI::MercsDisable(int argc, char **argv, argh::parser &cmd, std::string &description)
|
||||
{
|
||||
description = "Disables mercenaries";
|
||||
|
||||
if (cmd[{"-h", "--help"}]) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string input;
|
||||
std::cout << "Warning! This will drop all merc tables, are you sure? [y/n]";
|
||||
std::getline(std::cin, input);
|
||||
|
||||
if (Strings::ToLower(input) != "y") {
|
||||
LogInfo("Aborting");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string sql = "SET FOREIGN_KEY_CHECKS = 0;";
|
||||
for (auto &t: DatabaseSchema::GetMercTables()) {
|
||||
sql += fmt::format("DROP TABLE IF EXISTS {};", t);
|
||||
LogInfo("Dropping table [{}]", t);
|
||||
}
|
||||
|
||||
sql += "SET FOREIGN_KEY_CHECKS = 1;";
|
||||
|
||||
database.QueryDatabaseMulti(sql);
|
||||
LogInfo("Setting rule Mercs:AllowMercs to false");
|
||||
RuleManager::Instance()->SetRule("Mercs:AllowMercs", "false", &database, true, true);
|
||||
LogInfo("Disabled mercs and dropped tables");
|
||||
}
|
||||
27
world/cli/mercs_enable.cpp
Normal file
27
world/cli/mercs_enable.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include "../worlddb.h"
|
||||
#include "../../common/database_schema.h"
|
||||
|
||||
void WorldserverCLI::MercsEnable(int argc, char **argv, argh::parser &cmd, std::string &description)
|
||||
{
|
||||
description = "Enables mercenaries";
|
||||
|
||||
if (cmd[{"-h", "--help"}]) {
|
||||
return;
|
||||
}
|
||||
|
||||
// bootstrap merc tables if they don't exist
|
||||
if (!database.DoesTableExist("merc_types")) {
|
||||
LogInfo("Bootstrapping merc tables");
|
||||
database.SourceSqlFromUrl(
|
||||
"https://raw.githubusercontent.com/EQEmu/Server/master/utils/sql/merc_tables_bootstrap.sql"
|
||||
);
|
||||
}
|
||||
else {
|
||||
LogInfo("Merc tables already exist, skipping bootstrap");
|
||||
}
|
||||
|
||||
LogInfo("Enabling mercs");
|
||||
LogInfo("Setting rule Mercs:AllowMercs to true");
|
||||
RuleManager::Instance()->SetRule("Mercs:AllowMercs", "true", &database, true, true);
|
||||
LogInfo("Mercs enabled");
|
||||
}
|
||||
@ -22,6 +22,8 @@ void WorldserverCLI::CommandHandler(int argc, char **argv)
|
||||
*/
|
||||
function_map["bots:enable"] = &WorldserverCLI::BotsEnable;
|
||||
function_map["bots:disable"] = &WorldserverCLI::BotsDisable;
|
||||
function_map["mercs:enable"] = &WorldserverCLI::MercsEnable;
|
||||
function_map["mercs:disable"] = &WorldserverCLI::MercsDisable;
|
||||
function_map["world:version"] = &WorldserverCLI::Version;
|
||||
function_map["character:copy-character"] = &WorldserverCLI::CopyCharacter;
|
||||
function_map["database:version"] = &WorldserverCLI::DatabaseVersion;
|
||||
@ -41,6 +43,8 @@ void WorldserverCLI::CommandHandler(int argc, char **argv)
|
||||
|
||||
#include "cli/bots_enable.cpp"
|
||||
#include "cli/bots_disable.cpp"
|
||||
#include "cli/mercs_enable.cpp"
|
||||
#include "cli/mercs_disable.cpp"
|
||||
#include "cli/database_concurrency.cpp"
|
||||
#include "cli/copy_character.cpp"
|
||||
#include "cli/database_dump.cpp"
|
||||
|
||||
@ -9,6 +9,8 @@ public:
|
||||
static void CommandHandler(int argc, char **argv);
|
||||
static void BotsEnable(int argc, char **argv, argh::parser &cmd, std::string &description);
|
||||
static void BotsDisable(int argc, char **argv, argh::parser &cmd, std::string &description);
|
||||
static void MercsEnable(int argc, char **argv, argh::parser &cmd, std::string &description);
|
||||
static void MercsDisable(int argc, char **argv, argh::parser &cmd, std::string &description);
|
||||
static void Version(int argc, char **argv, argh::parser &cmd, std::string &description);
|
||||
static void CopyCharacter(int argc, char **argv, argh::parser &cmd, std::string &description);
|
||||
static void DatabaseVersion(int argc, char **argv, argh::parser &cmd, std::string &description);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user