mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 22:58:34 +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:
+14
-14
@@ -379,14 +379,14 @@ static void ProcessSetMessageStatus(std::string SetMessageCommand) {
|
||||
|
||||
if (NumEnd == std::string::npos) {
|
||||
|
||||
MessageNumber = atoi(SetMessageCommand.substr(NumStart).c_str());
|
||||
MessageNumber = Strings::ToInt(SetMessageCommand.substr(NumStart).c_str());
|
||||
|
||||
database.SetMessageStatus(MessageNumber, Status);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
MessageNumber = atoi(SetMessageCommand.substr(NumStart, NumEnd - NumStart).c_str());
|
||||
MessageNumber = Strings::ToInt(SetMessageCommand.substr(NumStart, NumEnd - NumStart).c_str());
|
||||
|
||||
database.SetMessageStatus(MessageNumber, Status);
|
||||
|
||||
@@ -876,7 +876,7 @@ void Clientlist::ProcessOPMailCommand(Client *c, std::string command_string, boo
|
||||
break;
|
||||
|
||||
case CommandGetBody:
|
||||
database.SendBody(c, atoi(parameters.c_str()));
|
||||
database.SendBody(c, Strings::ToInt(parameters.c_str()));
|
||||
break;
|
||||
|
||||
case CommandMailTo:
|
||||
@@ -891,7 +891,7 @@ void Clientlist::ProcessOPMailCommand(Client *c, std::string command_string, boo
|
||||
case CommandSelectMailBox:
|
||||
{
|
||||
std::string::size_type NumStart = parameters.find_first_of("0123456789");
|
||||
c->ChangeMailBox(atoi(parameters.substr(NumStart).c_str()));
|
||||
c->ChangeMailBox(Strings::ToInt(parameters.substr(NumStart).c_str()));
|
||||
break;
|
||||
}
|
||||
case CommandSetMailForwarding:
|
||||
@@ -1253,7 +1253,7 @@ void Client::ProcessChannelList(std::string Input) {
|
||||
std::string ChannelName = Input;
|
||||
|
||||
if (isdigit(ChannelName[0]))
|
||||
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
||||
ChannelName = ChannelSlotName(Strings::ToInt(ChannelName.c_str()));
|
||||
|
||||
ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName);
|
||||
|
||||
@@ -1414,7 +1414,7 @@ void Client::SendChannelMessageByNumber(std::string Message) {
|
||||
if (MessageStart == std::string::npos)
|
||||
return;
|
||||
|
||||
int ChannelNumber = atoi(Message.substr(0, MessageStart).c_str());
|
||||
int ChannelNumber = Strings::ToInt(Message.substr(0, MessageStart).c_str());
|
||||
|
||||
if ((ChannelNumber < 1) || (ChannelNumber > MAX_JOINED_CHANNELS)) {
|
||||
|
||||
@@ -1657,7 +1657,7 @@ void Client::SetChannelPassword(std::string ChannelPassword) {
|
||||
std::string ChannelName = ChannelPassword.substr(ChannelStart);
|
||||
|
||||
if ((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
||||
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
||||
ChannelName = ChannelSlotName(Strings::ToInt(ChannelName.c_str()));
|
||||
|
||||
std::string Message;
|
||||
|
||||
@@ -1722,7 +1722,7 @@ void Client::SetChannelOwner(std::string CommandString) {
|
||||
std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
|
||||
|
||||
if ((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
||||
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
||||
ChannelName = ChannelSlotName(Strings::ToInt(ChannelName.c_str()));
|
||||
|
||||
LogInfo("Set owner of channel [[{}]] to [[{}]]", ChannelName.c_str(), NewOwner.c_str());
|
||||
|
||||
@@ -1768,7 +1768,7 @@ void Client::OPList(std::string CommandString) {
|
||||
std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
|
||||
|
||||
if ((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
||||
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
||||
ChannelName = ChannelSlotName(Strings::ToInt(ChannelName.c_str()));
|
||||
|
||||
ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName);
|
||||
|
||||
@@ -1811,7 +1811,7 @@ void Client::ChannelInvite(std::string CommandString) {
|
||||
std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
|
||||
|
||||
if ((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
||||
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
||||
ChannelName = ChannelSlotName(Strings::ToInt(ChannelName.c_str()));
|
||||
|
||||
LogInfo("[[{}]] invites [[{}]] to channel [[{}]]", GetName().c_str(), Invitee.c_str(), ChannelName.c_str());
|
||||
|
||||
@@ -1881,7 +1881,7 @@ void Client::ChannelModerate(std::string CommandString) {
|
||||
std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
|
||||
|
||||
if ((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
||||
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
||||
ChannelName = ChannelSlotName(Strings::ToInt(ChannelName.c_str()));
|
||||
|
||||
ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName);
|
||||
|
||||
@@ -1939,7 +1939,7 @@ void Client::ChannelGrantModerator(std::string CommandString) {
|
||||
std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
|
||||
|
||||
if ((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
||||
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
||||
ChannelName = ChannelSlotName(Strings::ToInt(ChannelName.c_str()));
|
||||
|
||||
LogInfo("[[{}]] gives [[{}]] moderator rights to channel [[{}]]", GetName().c_str(), Moderator.c_str(), ChannelName.c_str());
|
||||
|
||||
@@ -2020,7 +2020,7 @@ void Client::ChannelGrantVoice(std::string CommandString) {
|
||||
std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
|
||||
|
||||
if ((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
||||
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
||||
ChannelName = ChannelSlotName(Strings::ToInt(ChannelName.c_str()));
|
||||
|
||||
LogInfo("[[{}]] gives [[{}]] voice to channel [[{}]]", GetName().c_str(), Voicee.c_str(), ChannelName.c_str());
|
||||
|
||||
@@ -2108,7 +2108,7 @@ void Client::ChannelKick(std::string CommandString) {
|
||||
std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
|
||||
|
||||
if ((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
||||
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
||||
ChannelName = ChannelSlotName(Strings::ToInt(ChannelName.c_str()));
|
||||
|
||||
LogInfo("[[{}]] kicks [[{}]] from channel [[{}]]", GetName().c_str(), Kickee.c_str(), ChannelName.c_str());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user