mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 22:01:30 +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>
49 lines
1.2 KiB
C++
49 lines
1.2 KiB
C++
#include "../client.h"
|
|
|
|
void command_level(Client *c, const Seperator *sep)
|
|
{
|
|
int arguments = sep->argnum;
|
|
if (!arguments || !sep->IsNumber(1)) {
|
|
c->Message(Chat::White, "Usage: #level [Level]");
|
|
return;
|
|
}
|
|
|
|
auto target = c->GetTarget();
|
|
if (!target) {
|
|
c->Message(Chat::White, "You must have a target to use this command.");
|
|
return;
|
|
}
|
|
|
|
auto level = static_cast<uint8>(Strings::ToUnsignedInt(sep->arg[1]));
|
|
auto max_level = static_cast<uint8>(RuleI(Character, MaxLevel));
|
|
|
|
if (c->Admin() < RuleI(GM, MinStatusToLevelTarget)) {
|
|
c->Message(Chat::White, "Your status is not high enough to change another person's level.");
|
|
return;
|
|
}
|
|
|
|
if (
|
|
level > max_level &&
|
|
c->Admin() < commandLevelAboveCap
|
|
) {
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"Level {} is above the Maximum Level of {} and your status is not high enough to go beyond the cap.",
|
|
level,
|
|
max_level
|
|
).c_str()
|
|
);
|
|
return;
|
|
}
|
|
|
|
target->SetLevel(level, true);
|
|
if (target->IsClient()) {
|
|
target->CastToClient()->SendLevelAppearance();
|
|
|
|
if (RuleB(Bots, Enabled) && RuleB(Bots, BotLevelsWithOwner)) {
|
|
Bot::LevelBotWithClient(target->CastToClient(), level, true);
|
|
}
|
|
}
|
|
}
|