mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 13:41:31 +00:00
* [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>
64 lines
1.7 KiB
C++
Executable File
64 lines
1.7 KiB
C++
Executable File
#include "../client.h"
|
|
#include "../groups.h"
|
|
#include "../raids.h"
|
|
#include "../raids.h"
|
|
|
|
void command_setaapts(Client *c, const Seperator *sep)
|
|
{
|
|
int arguments = sep->argnum;
|
|
if (arguments <= 1 || !sep->IsNumber(2)) {
|
|
c->Message(Chat::White, "Usage: #setaapts [AA|Group|Raid] [AA Amount]");
|
|
return;
|
|
}
|
|
|
|
Client *target = c;
|
|
if (c->GetTarget() && c->GetTarget()->IsClient()) {
|
|
target = c->GetTarget()->CastToClient();
|
|
}
|
|
|
|
std::string aa_type = Strings::ToLower(sep->arg[1]);
|
|
std::string group_raid_string;
|
|
uint32 aa_points = static_cast<uint32>(std::min(Strings::ToUnsignedBigInt(sep->arg[2]), (uint64) 2000000000));
|
|
bool is_aa = aa_type.find("aa") != std::string::npos;
|
|
bool is_group = aa_type.find("group") != std::string::npos;
|
|
bool is_raid = aa_type.find("raid") != std::string::npos;
|
|
if (!is_aa && !is_group && !is_raid) {
|
|
c->Message(Chat::White, "Usage: #setaapts [AA|Group|Raid] [AA Amount]");
|
|
return;
|
|
}
|
|
|
|
if (is_aa) {
|
|
target->GetPP().aapoints = aa_points;
|
|
target->GetPP().expAA = 0;
|
|
target->SendAlternateAdvancementStats();
|
|
}
|
|
else if (is_group || is_raid) {
|
|
if (is_group) {
|
|
group_raid_string = "Group ";
|
|
target->GetPP().group_leadership_points = aa_points;
|
|
target->GetPP().group_leadership_exp = 0;
|
|
}
|
|
else if (is_raid) {
|
|
group_raid_string = "Raid ";
|
|
target->GetPP().raid_leadership_points = aa_points;
|
|
target->GetPP().raid_leadership_exp = 0;
|
|
}
|
|
target->SendLeadershipEXPUpdate();
|
|
}
|
|
|
|
std::string aa_message = fmt::format(
|
|
"{} now {} {} {}AA Point{}.",
|
|
c->GetTargetDescription(target, TargetDescriptionType::UCYou),
|
|
c == target ? "have" : "has",
|
|
aa_points,
|
|
group_raid_string,
|
|
aa_points != 1 ? "s" : ""
|
|
|
|
);
|
|
c->Message(
|
|
Chat::White,
|
|
aa_message.c_str()
|
|
);
|
|
}
|
|
|