mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 18:52:22 +00:00
Update command handler to use actual real arguments
This commit is contained in:
@@ -38,10 +38,6 @@ namespace EQEmuCommand {
|
||||
void DisplayDebug(argh::parser &cmd)
|
||||
{
|
||||
if (cmd[{"-d", "--debug"}]) {
|
||||
std::cout << "Positional args:\n";
|
||||
for (auto &pos_arg : cmd)
|
||||
std::cout << '\t' << pos_arg << std::endl;
|
||||
|
||||
std::cout << "Positional args:\n";
|
||||
for (auto &pos_arg : cmd.pos_args())
|
||||
std::cout << '\t' << pos_arg << std::endl;
|
||||
@@ -73,16 +69,18 @@ namespace EQEmuCommand {
|
||||
{
|
||||
bool arguments_filled = true;
|
||||
|
||||
int index = 2;
|
||||
for (auto &arg : arguments) {
|
||||
if (cmd(arg).str().empty()) {
|
||||
if (cmd(arg).str().empty() && cmd(index).str().empty()) {
|
||||
arguments_filled = false;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
if (!arguments_filled || argc == 2) {
|
||||
std::string arguments_string;
|
||||
for (auto &arg : arguments) {
|
||||
arguments_string += " " + arg + "=*\n";
|
||||
arguments_string += " " + arg;
|
||||
}
|
||||
|
||||
std::string options_string;
|
||||
@@ -90,8 +88,12 @@ namespace EQEmuCommand {
|
||||
options_string += " " + opt + "\n";
|
||||
}
|
||||
|
||||
std::stringstream str;
|
||||
str << termcolor::yellow << "\nCommand" << termcolor::reset << "\n\n";
|
||||
|
||||
std::cout << fmt::format(
|
||||
"Command\n\n{0} \n\nArgs\n{1}\nOptions\n{2}",
|
||||
"{0}{1}{2}\n\nOptions\n{3}",
|
||||
str.str(),
|
||||
argv[1],
|
||||
arguments_string,
|
||||
options_string
|
||||
|
||||
@@ -293,6 +293,37 @@ bool Database::SetAccountStatus(const char* name, int16 status) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param account_name
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
bool Database::SetAccountStatus(const std::string& account_name, int16 status)
|
||||
{
|
||||
LogInfo("Account [{}] is attempting to be set to status [{}]", account_name, status);
|
||||
|
||||
std::string query = fmt::format(
|
||||
SQL(
|
||||
UPDATE account SET status = {} WHERE name = '{}'
|
||||
),
|
||||
status,
|
||||
account_name
|
||||
);
|
||||
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (results.RowsAffected() == 0) {
|
||||
LogWarning("Account [{}] does not exist!", account_name);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* This initially creates the character during character create */
|
||||
bool Database::ReserveName(uint32 account_id, char* name) {
|
||||
std::string query = StringFormat("SELECT `account_id`, `name` FROM `character_data` WHERE `name` = '%s'", name);
|
||||
|
||||
@@ -179,6 +179,7 @@ public:
|
||||
bool DeleteAccount(const char *name, const char* loginserver);
|
||||
bool GetLiveChar(uint32 account_id, char* cname);
|
||||
bool SetAccountStatus(const char* name, int16 status);
|
||||
bool SetAccountStatus(const std::string& account_name, int16 status);
|
||||
bool SetLocalPassword(uint32 accid, const char* password);
|
||||
bool UpdateLiveChar(char* charname, uint32 account_id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user