eqemu-server/zone/gm_commands/showskills.cpp
Alex King 2a6cf8c8e7
[Strings] Add more number formatters (#2873)
* [Strings] Add more number formatters

# Notes
- Adds `Strings::ToUnsignedInt` for `uint32` support.
- Adds `Strings::ToBigInt` for `int64` support.
- Adds `Strings::ToUnsignedBigInt` for `uint64` support.
- Adds `Strings::ToFloat` for `float` support.
- Replaces all `std::stoi` references with `Strings::ToInt`.
- Replaces all `atoi` references with `Strings::ToInt`.
- Replaces all `std::stoul` references with `Strings::ToUnsignedInt`.
- Replaces all `atoul` references with `Strings::ToUnsignedInt`.
- Replaces all `std::stoll` references with `Strings::ToBigInt`.
- Replaces all `atoll` references with `Strings::ToBigInt`.
- Replaces all `std::stoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `atoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `std::stof` references with `Strings::ToFloat`.

* [Strings] Add more number formatters

- Adds `Strings::ToUnsignedInt` for `uint32` support.
- Adds `Strings::ToBigInt` for `int64` support.
- Adds `Strings::ToUnsignedBigInt` for `uint64` support.
- Adds `Strings::ToFloat` for `float` support.
- Replaces all `std::stoi` references with `Strings::ToInt`.
- Replaces all `atoi` references with `Strings::ToInt`.
- Replaces all `std::stoul` references with `Strings::ToUnsignedInt`.
- Replaces all `atoul` references with `Strings::ToUnsignedInt`.
- Replaces all `std::stoll` references with `Strings::ToBigInt`.
- Replaces all `atoll` references with `Strings::ToBigInt`.
- Replaces all `std::stoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `atoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `std::stof` references with `Strings::ToFloat`.

* Rebase cleanup

* Changes/benchmarks/tests

---------

Co-authored-by: Akkadius <akkadius1@gmail.com>
2023-03-04 17:01:19 -06:00

99 lines
2.4 KiB
C++
Executable File

#include "../client.h"
void command_showskills(Client *c, const Seperator *sep)
{
auto target = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) {
target = c->GetTarget()->CastToClient();
}
uint32 start_skill_id = 0;
if (sep->IsNumber(1)) {
start_skill_id = Strings::ToUnsignedInt(sep->arg[1]);
}
bool show_all = !strcasecmp(sep->arg[2], "all");
uint32 max_skill_id = (start_skill_id + 49);
std::string popup_text = "<table>";
popup_text += "<tr><td>ID</td><td>Name</td><td>Current</td><td>Max</td><td>Raw</td></tr>";
for (
EQ::skills::SkillType skill_id = (EQ::skills::SkillType) start_skill_id;
skill_id <= (EQ::skills::SkillType) max_skill_id;
skill_id = (EQ::skills::SkillType) (skill_id + 1)
) {
if ((EQ::skills::SkillType) skill_id >= EQ::skills::SkillCount) {
max_skill_id = (EQ::skills::SkillCount - 1);
break;
}
if (show_all || (target->CanHaveSkill(skill_id) && target->MaxSkill(skill_id))) {
popup_text += fmt::format(
"<tr><td>{}</td><td>{}</td><td>{}</td><td>{}</td><td>{}</td></tr>",
skill_id,
EQ::skills::GetSkillName(skill_id),
target->GetSkill(skill_id),
target->MaxSkill(skill_id),
target->GetRawSkill(skill_id)
);
}
}
popup_text += "</table>";
std::string popup_title = fmt::format(
"Skills for {} [{} to {}]",
c->GetTargetDescription(target, TargetDescriptionType::UCSelf),
start_skill_id,
max_skill_id
);
c->SendPopupToClient(
popup_title.c_str(),
popup_text.c_str()
);
c->Message(
Chat::White,
fmt::format(
"Viewing skill levels from {} ({}) to {} ({}) for {}.",
EQ::skills::GetSkillName((EQ::skills::SkillType) start_skill_id),
start_skill_id,
EQ::skills::GetSkillName((EQ::skills::SkillType) max_skill_id),
max_skill_id,
c->GetTargetDescription(target)
).c_str()
);
int next_skill_id = (max_skill_id + 1);
if ((EQ::skills::SkillType) next_skill_id < EQ::skills::SkillCount) {
auto next_list_string = fmt::format(
"#showskills {}",
next_skill_id
);
auto next_list_link = Saylink::Silent(next_list_string, next_list_string);
auto next_list_all_string = fmt::format(
"#showskills {} all",
next_skill_id
);
auto next_list_all_link = Saylink::Silent(next_list_all_string, next_list_all_string);
c->Message(
Chat::White,
fmt::format(
"To view the next 50 skill levels, you can use {} or {} to show skills the player cannot normally have.",
next_list_link,
next_list_all_link
).c_str()
);
}
}