mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 09:31:30 +00:00
34 lines
919 B
C++
34 lines
919 B
C++
#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");
|
|
}
|