Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Commands] Cleanup #resetaa and #resetaa_timer #3047

Merged
merged 1 commit into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 4 additions & 5 deletions zone/gm_commands/resetaa.cpp
Expand Up @@ -7,15 +7,14 @@ void command_resetaa(Client *c, const Seperator *sep)
return;
}

auto target = c->GetTarget()->CastToClient();
target->ResetAA();
auto t = c->GetTarget()->CastToClient();
t->ResetAA();

c->Message(
Chat::White,
fmt::format(
"Successfully reset all Alternate Advancements for {}.",
c->GetTargetDescription(target)
c->GetTargetDescription(t)
).c_str()
);
}

25 changes: 13 additions & 12 deletions zone/gm_commands/resetaa_timer.cpp
Expand Up @@ -2,43 +2,44 @@

void command_resetaa_timer(Client *c, const Seperator *sep)
{
int arguments = sep->argnum;
const auto arguments = sep->argnum;
if (!arguments) {
c->Message(Chat::White, "Usage: #resetaa_timer all - Reset all Alternate Advancement timers");
c->Message(Chat::White, "Usage: #resetaa_timer [Timer ID] - Reset Alternate Advancement timer by ID");
return;
}

auto target = c;
auto t = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) {
target = c->GetTarget()->CastToClient();
t = c->GetTarget()->CastToClient();
}

bool is_all = !strcasecmp(sep->arg[1], "all");
const bool is_all = !strcasecmp(sep->arg[1], "all");

if (is_all) {
c->Message(
Chat::White,
fmt::format(
"Reset all Alternate Advancement timers for {}.",
c->GetTargetDescription(target)
c->GetTargetDescription(t)
).c_str()
);
target->ResetAlternateAdvancementTimers();

t->ResetAlternateAdvancementTimers();

return;
}
} else if (sep->IsNumber(1)) {
const auto timer_id = Strings::ToInt(sep->arg[1]);

if (sep->IsNumber(1)) {
int timer_id = Strings::ToInt(sep->arg[1]);
c->Message(
Chat::White,
fmt::format(
"Reset Alternate Advancement timer {} for {}.",
timer_id,
c->GetTargetDescription(target)
c->GetTargetDescription(t)
).c_str()
);
target->ResetAlternateAdvancementTimer(timer_id);

t->ResetAlternateAdvancementTimer(timer_id);
}
}