[Strings] Refactor Strings Usage (#2305)

* Initial commit checkpoint

* More functions converted

* Commify

* More functions

* Fin

* Sort declarations

* Split functions between files

* Bots

* Update strings.h

* Split

* Revert find replaces

* Repository template

* Money

* Misc function

* Update CMakeLists.txt

* Saylink

* Update strings.cpp

* Swap Strings::Saylink for Saylink::Create since saylink is coupled to zone database

* API casings
This commit is contained in:
Chris Miles
2022-07-14 02:10:52 -05:00
committed by GitHub
parent 44c85a0dd7
commit dfd8f84cac
573 changed files with 5197 additions and 5137 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
#include "../common/extprofile.h"
#include "../common/rulesys.h"
#include "../common/misc_functions.h"
#include "../common/string_util.h"
#include "../common/strings.h"
#include "../common/random.h"
#include "adventure.h"
#include "adventure_manager.h"
+1 -1
View File
@@ -1,6 +1,6 @@
#include "../common/global_define.h"
#include "../common/misc_functions.h"
#include "../common/string_util.h"
#include "../common/strings.h"
#include "../common/servertalk.h"
#include "../common/rulesys.h"
#include "../common/random.h"
+2 -2
View File
@@ -31,7 +31,7 @@
#include "../common/languages.h"
#include "../common/skills.h"
#include "../common/extprofile.h"
#include "../common/string_util.h"
#include "../common/strings.h"
#include "../common/emu_versions.h"
#include "../common/random.h"
#include "../common/shareddb.h"
@@ -768,7 +768,7 @@ bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) {
}
if (eqs->ClientVersion() == EQ::versions::ClientVersion::Titanium) {
character_limit = Titanium::constants::CHARACTER_CREATION_LIMIT;
character_limit = Titanium::constants::CHARACTER_CREATION_LIMIT;
}
auto query = fmt::format(
+1 -1
View File
@@ -25,7 +25,7 @@
#include "zoneserver.h"
#include "world_config.h"
#include "../common/guilds.h"
#include "../common/string_util.h"
#include "../common/strings.h"
extern uint32 numplayers;
extern LoginServerList loginserverlist;
+1 -1
View File
@@ -22,7 +22,7 @@
#include "zonelist.h"
#include "client.h"
#include "worlddb.h"
#include "../common/string_util.h"
#include "../common/strings.h"
#include "../common/guilds.h"
#include "../common/races.h"
#include "../common/classes.h"
+17 -17
View File
@@ -27,7 +27,7 @@
#include "worlddb.h"
#include "zonelist.h"
#include "zoneserver.h"
#include "../common/string_util.h"
#include "../common/strings.h"
#include "../common/md5.h"
#include "eqemu_api_world_data_service.h"
#include "world_store.h"
@@ -164,7 +164,7 @@ void ConsoleWho(
if (strcasecmp(arg.c_str(), "gm") == 0) {
whom.gmlookup = 1;
}
else if (StringIsNumber(arg)) {
else if (Strings::IsNumber(arg)) {
if (whom.lvllow == 0xFFFF) {
whom.lvllow = atoi(arg.c_str());
whom.lvlhigh = whom.lvllow;
@@ -200,7 +200,7 @@ void ConsoleUptime(
return;
}
if (StringIsNumber(args[0]) && atoi(args[0].c_str()) > 0) {
if (Strings::IsNumber(args[0]) && atoi(args[0].c_str()) > 0) {
auto pack = new ServerPacket(ServerOP_Uptime, sizeof(ServerUptime_Struct));
ServerUptime_Struct *sus = (ServerUptime_Struct *) pack->pBuffer;
snprintf(sus->adminname, sizeof(sus->adminname), "*%s", connection->UserName().c_str());
@@ -285,7 +285,7 @@ void ConsoleEmote(
0,
AccountStatus::Player,
atoi(args[1].c_str()),
JoinString(join_args, " ").c_str()
Strings::Join(join_args, " ").c_str()
);
}
else {
@@ -296,7 +296,7 @@ void ConsoleEmote(
0,
AccountStatus::Player,
atoi(args[1].c_str()),
JoinString(join_args, " ").c_str()
Strings::Join(join_args, " ").c_str()
);
}
else {
@@ -305,7 +305,7 @@ void ConsoleEmote(
0,
AccountStatus::Player,
atoi(args[1].c_str()),
JoinString(join_args, " ").c_str()
Strings::Join(join_args, " ").c_str()
);
}
}
@@ -361,7 +361,7 @@ void ConsoleTell(
auto join_args = args;
join_args.erase(join_args.begin(), join_args.begin() + 1);
zoneserver_list.SendChannelMessage(tmpname, to.c_str(), 7, 0, JoinString(join_args, " ").c_str());
zoneserver_list.SendChannelMessage(tmpname, to.c_str(), 7, 0, Strings::Join(join_args, " ").c_str());
}
/**
@@ -382,7 +382,7 @@ void ConsoleBroadcast(
char tmpname[64];
tmpname[0] = '*';
strcpy(&tmpname[1], connection->UserName().c_str());
zoneserver_list.SendChannelMessage(tmpname, 0, 6, 0, JoinString(args, " ").c_str());
zoneserver_list.SendChannelMessage(tmpname, 0, 6, 0, Strings::Join(args, " ").c_str());
}
/**
@@ -403,7 +403,7 @@ void ConsoleGMSay(
char tmpname[64];
tmpname[0] = '*';
strcpy(&tmpname[1], connection->UserName().c_str());
zoneserver_list.SendChannelMessage(tmpname, 0, 11, 0, JoinString(args, " ").c_str());
zoneserver_list.SendChannelMessage(tmpname, 0, 11, 0, Strings::Join(args, " ").c_str());
}
/**
@@ -422,7 +422,7 @@ void ConsoleGuildSay(
}
auto from = args[0];
auto guild_id = StringIsNumber(args[1]) ? std::stoul(args[1]) : 0;
auto guild_id = Strings::IsNumber(args[1]) ? std::stoul(args[1]) : 0;
if (!guild_id) {
return;
}
@@ -433,7 +433,7 @@ void ConsoleGuildSay(
auto message = fmt::format(
"{} tells the guild, '{}'",
from,
JoinString(join_args, " ")
Strings::Join(join_args, " ")
);
zoneserver_list.SendEmoteMessage(0, guild_id, AccountStatus::Player, Chat::Guild, message.c_str());
@@ -457,7 +457,7 @@ void ConsoleOOC(
char tmpname[64];
tmpname[0] = '*';
strcpy(&tmpname[1], connection->UserName().c_str());
zoneserver_list.SendChannelMessage(tmpname, 0, 5, 0, JoinString(args, " ").c_str());
zoneserver_list.SendChannelMessage(tmpname, 0, 5, 0, Strings::Join(args, " ").c_str());
}
/**
@@ -478,7 +478,7 @@ void ConsoleAuction(
char tmpname[64];
tmpname[0] = '*';
strcpy(&tmpname[1], connection->UserName().c_str());
zoneserver_list.SendChannelMessage(tmpname, 0, 4, 0, JoinString(args, " ").c_str());
zoneserver_list.SendChannelMessage(tmpname, 0, 4, 0, Strings::Join(args, " ").c_str());
}
/**
@@ -584,7 +584,7 @@ void ConsoleZoneShutdown(
ServerZoneStateChange_struct *s = (ServerZoneStateChange_struct *) pack->pBuffer;
pack->opcode = ServerOP_ZoneShutdown;
strcpy(s->adminname, tmpname);
if (StringIsNumber(args[0])) {
if (Strings::IsNumber(args[0])) {
s->ZoneServerID = atoi(args[0].c_str());
}
else {
@@ -628,7 +628,7 @@ void ConsoleZoneBootup(
return;
}
if (args[1].length() == 0 || !StringIsNumber(args[0])) {
if (args[1].length() == 0 || !Strings::IsNumber(args[0])) {
connection->SendLine("Usage: zonebootup ZoneServerID# zoneshortname");
}
else {
@@ -754,7 +754,7 @@ void ConsoleFlag(
return;
}
if (args[1].length() == 0 || !StringIsNumber(args[0])) {
if (args[1].length() == 0 || !Strings::IsNumber(args[0])) {
connection->SendLine("Usage: flag [status] [accountname]");
}
else {
@@ -828,7 +828,7 @@ void ConsoleWorldShutdown(
{
if (args.size() == 2) {
int32 time, interval;
if (StringIsNumber(args[0]) && StringIsNumber(args[1]) && ((time = atoi(args[0].c_str())) > 0) &&
if (Strings::IsNumber(args[0]) && Strings::IsNumber(args[1]) && ((time = atoi(args[0].c_str())) > 0) &&
((interval = atoi(args[1].c_str())) > 0)) {
zoneserver_list.WorldShutDown(time, interval);
}
+1 -1
View File
@@ -38,7 +38,7 @@
#include "../common/opcodemgr.h"
#include "../common/rulesys.h"
#include "../common/ruletypes.h"
#include "../common/string_util.h"
#include "../common/strings.h"
#include "world_config.h"
#include "zoneserver.h"
#include "zonelist.h"
+1 -1
View File
@@ -20,7 +20,7 @@
#include "worlddb.h"
#include "launcher_link.h"
#include "launcher_list.h"
#include "../common/string_util.h"
#include "../common/strings.h"
#include "world_store.h"
#include <cstdlib>
#include <cstring>
+1 -1
View File
@@ -25,7 +25,7 @@
#include "../common/races.h"
#include "../common/classes.h"
#include "../common/misc.h"
#include "../common/string_util.h"
#include "../common/strings.h"
#include "zoneserver.h"
#include "zonelist.h"
#include "clientlist.h"
+1 -1
View File
@@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "../common/md5.h"
#include "../common/packet_dump.h"
#include "../common/servertalk.h"
#include "../common/string_util.h"
#include "../common/strings.h"
#include "../common/misc_functions.h"
#include "worlddb.h"
#include "eql_config.h"
+1 -1
View File
@@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "../common/misc_functions.h"
#include "../common/eq_packet_structs.h"
#include "../common/packet_dump.h"
#include "../common/string_util.h"
#include "../common/strings.h"
#include "../common/eqemu_logsys.h"
#include "login_server.h"
#include "login_server_list.h"
+3 -3
View File
@@ -28,7 +28,7 @@
#include <stdlib.h>
#include <signal.h>
#include "../common/string_util.h"
#include "../common/strings.h"
#include "../common/eqemu_logsys.h"
#include "../common/queue.h"
#include "../common/timer.h"
@@ -248,10 +248,10 @@ static void GMSayHookCallBackProcessWorld(uint16 log_category, std::string messa
}
// Replace Occurrences of % or MessageStatus will crash
find_replace(message, std::string("%"), std::string("."));
Strings::FindReplace(message, std::string("%"), std::string("."));
if (message.find('\n') != std::string::npos) {
auto message_split = SplitString(message, '\n');
auto message_split = Strings::Split(message, '\n');
for (size_t iter = 0; iter < message_split.size(); ++iter) {
zoneserver_list.SendEmoteMessage(
+1 -1
View File
@@ -1029,7 +1029,7 @@ void SharedTaskManager::InvitePlayerByPlayerName(SharedTask *s, const std::strin
{
auto character = CharacterDataRepository::GetWhere(
*m_database,
fmt::format("`name` = '{}' LIMIT 1", EscapeString(player_name))
fmt::format("`name` = '{}' LIMIT 1", Strings::Escape(player_name))
);
auto character_id = !character.empty() ? character.front().id : 0;
+1 -1
View File
@@ -34,7 +34,7 @@ uint32 WorldStore::GetZoneID(const char *in_zone_name)
return 0;
}
std::string zone_name = str_tolower(in_zone_name);
std::string zone_name = Strings::ToLower(in_zone_name);
return GetZoneID(zone_name);
}
+1 -1
View File
@@ -17,7 +17,7 @@
*/
#include "worlddb.h"
#include "../common/string_util.h"
#include "../common/strings.h"
#include "../common/eq_packet_structs.h"
#include "../common/inventory_profile.h"
#include "../common/rulesys.h"
+2 -2
View File
@@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "world_config.h"
#include "../common/misc_functions.h"
#include "../common/servertalk.h"
#include "../common/string_util.h"
#include "../common/strings.h"
#include "../common/random.h"
#include "../common/json/json.h"
#include "../common/event_sub.h"
@@ -50,7 +50,7 @@ ZSList::~ZSList() {
void ZSList::ShowUpTime(WorldTCPConnection* con, const char* adminname) {
uint32 ms = Timer::GetCurrentTime();
std::string time_string = ConvertMillisecondsToTime(ms);
std::string time_string = Strings::MillisecondsToTime(ms);
con->SendEmoteMessage(
adminname,
0,
+2 -2
View File
@@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "../common/guilds.h"
#include "../common/packet_dump.h"
#include "../common/misc.h"
#include "../common/string_util.h"
#include "../common/strings.h"
#include "cliententry.h"
#include "wguild_mgr.h"
#include "lfplist.h"
@@ -1343,7 +1343,7 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) {
zoneserver_list.SendPacket(pack);
content_service.SetExpansionContext()->ReloadContentFlags();
break;
}
}
case ServerOP_ReloadLogs: {
zoneserver_list.SendPacket(pack);
LogSys.LoadLogDatabaseSettings();