mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-11 11:48:37 +00:00
[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>
This commit is contained in:
+6
-6
@@ -453,7 +453,7 @@ bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app)
|
||||
|
||||
is_player_zoning = (login_info->zoning == 1);
|
||||
|
||||
uint32 id = std::stoi(name);
|
||||
uint32 id = Strings::ToInt(name);
|
||||
if (id == 0) {
|
||||
LogWarning("Receiving Login Info Packet from Client | account_id is 0 - disconnecting");
|
||||
return false;
|
||||
@@ -808,7 +808,7 @@ bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) {
|
||||
if (!strcasecmp(row[1], char_name)) {
|
||||
if (RuleB(World, EnableReturnHomeButton)) {
|
||||
int now = time(nullptr);
|
||||
if ((now - atoi(row[3])) >= RuleI(World, MinOfflineTimeToReturnHome)) {
|
||||
if ((now - Strings::ToInt(row[3])) >= RuleI(World, MinOfflineTimeToReturnHome)) {
|
||||
home_enabled = true;
|
||||
break;
|
||||
}
|
||||
@@ -834,7 +834,7 @@ bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) {
|
||||
if (!strcasecmp(row[1], char_name)) {
|
||||
if (
|
||||
RuleB(World, EnableTutorialButton) &&
|
||||
std::stoi(row[2]) <= RuleI(World, MaxLevelForTutorial)
|
||||
Strings::ToInt(row[2]) <= RuleI(World, MaxLevelForTutorial)
|
||||
) {
|
||||
tutorial_enabled = true;
|
||||
break;
|
||||
@@ -1258,7 +1258,7 @@ bool Client::ChecksumVerificationCRCEQGame(uint64 checksum)
|
||||
std::string checksumvar;
|
||||
uint64_t checksumint;
|
||||
if (database.GetVariable("crc_eqgame", checksumvar)) {
|
||||
checksumint = atoll(checksumvar.c_str());
|
||||
checksumint = Strings::ToBigInt(checksumvar.c_str());
|
||||
}
|
||||
else {
|
||||
LogChecksumVerification("variable not set in variables table.");
|
||||
@@ -1281,7 +1281,7 @@ bool Client::ChecksumVerificationCRCSkillCaps(uint64 checksum)
|
||||
std::string checksumvar;
|
||||
uint64_t checksumint;
|
||||
if (database.GetVariable("crc_skillcaps", checksumvar)) {
|
||||
checksumint = atoll(checksumvar.c_str());
|
||||
checksumint = Strings::ToBigInt(checksumvar.c_str());
|
||||
}
|
||||
else {
|
||||
LogChecksumVerification("[checksum_crc2_skillcaps] variable not set in variables table.");
|
||||
@@ -1304,7 +1304,7 @@ bool Client::ChecksumVerificationCRCBaseData(uint64 checksum)
|
||||
std::string checksumvar;
|
||||
uint64_t checksumint;
|
||||
if (database.GetVariable("crc_basedata", checksumvar)) {
|
||||
checksumint = atoll(checksumvar.c_str());
|
||||
checksumint = Strings::ToBigInt(checksumvar.c_str());
|
||||
}
|
||||
else {
|
||||
LogChecksumVerification("variable not set in variables table.");
|
||||
|
||||
Reference in New Issue
Block a user