From 5957b4f9bca5fe110815cf96fbf46b886b871795 Mon Sep 17 00:00:00 2001
From: charles <128108973+OldFoolAgain@users.noreply.github.com>
Date: Wed, 30 Aug 2023 11:00:11 -0400
Subject: [PATCH 1/3] strutil replacement
---
make/VS2017/uox3.vcxproj | 3 +-
make/VS2017/uox3.vcxproj.filters | 7 +-
make/VS2022/uox3.vcxproj | 5 +-
make/VS2022/uox3.vcxproj.filters | 9 +-
make/XCode/uox3.xcodeproj/project.pbxproj | 26 +-
make/cmake/CMakeLists.txt | 2 +
source/CGump.cpp | 10 +-
source/CJSMapping.cpp | 36 +-
source/CPacketReceive.cpp | 27 +-
source/CPacketSend.cpp | 113 ++--
source/CResponse.cpp | 76 +--
source/Dictionary.cpp | 11 +-
source/JSEncapsulate.cpp | 8 +-
source/SEFunctions.cpp | 50 +-
source/StringUtility.cpp | 198 +------
source/StringUtility.hpp | 90 ----
source/UOXJSMethods.cpp | 131 ++---
source/UOXJSPropertyFuncs.cpp | 126 ++---
source/ai.cpp | 3 +-
source/archive.cpp | 7 +-
source/boats.cpp | 13 +-
source/books.cpp | 28 +-
source/cAccountClass.cpp | 142 ++---
source/cBaseObject.cpp | 132 ++---
source/cChar.cpp | 251 ++++-----
source/cConsole.cpp | 60 +--
source/cGuild.cpp | 62 +--
source/cHTMLSystem.cpp | 58 ++-
source/cItem.cpp | 228 +++++----
source/cMultiObj.cpp | 46 +-
source/cPlayerAction.cpp | 49 +-
source/cRaces.cpp | 33 +-
source/cScript.cpp | 18 +-
source/cServerData.cpp | 106 ++--
source/cServerDefinitions.cpp | 19 +-
source/cSocket.cpp | 36 +-
source/cSpawnRegion.cpp | 32 +-
source/cWeather.cpp | 16 +-
source/cmdtable.cpp | 73 +--
source/commands.cpp | 15 +-
source/effect.cpp | 46 +-
source/fileio.cpp | 101 ++--
source/funcdecl.h | 3 +-
source/gumps.cpp | 338 ++++++------
source/house.cpp | 43 +-
source/items.cpp | 211 ++++----
source/jail.cpp | 9 +-
source/magic.cpp | 54 +-
source/mapstuff.cpp | 23 +-
source/movement.cpp | 52 +-
source/msgboard.cpp | 45 +-
source/network.cpp | 37 +-
source/npcs.cpp | 169 +++---
source/pcmanage.cpp | 30 +-
source/regions.cpp | 38 +-
source/scriptc.cpp | 13 +-
source/skills.cpp | 69 +--
source/sound.cpp | 5 +-
source/speech.cpp | 21 +-
source/ssection.cpp | 27 +-
source/targeting.cpp | 37 +-
source/townregion.cpp | 200 ++++----
source/typedefs.h | 4 +-
source/uox3.cpp | 27 +-
source/utility/strutil.hpp | 598 ++++++++++++++++++++++
source/wholist.cpp | 50 +-
source/worldmain.cpp | 4 +-
67 files changed, 2516 insertions(+), 2093 deletions(-)
create mode 100644 source/utility/strutil.hpp
diff --git a/make/VS2017/uox3.vcxproj b/make/VS2017/uox3.vcxproj
index b712ba8ea..eee0072e3 100644
--- a/make/VS2017/uox3.vcxproj
+++ b/make/VS2017/uox3.vcxproj
@@ -1442,6 +1442,7 @@
+
@@ -1468,4 +1469,4 @@
-
\ No newline at end of file
+
diff --git a/make/VS2017/uox3.vcxproj.filters b/make/VS2017/uox3.vcxproj.filters
index b5955147c..866ab0671 100644
--- a/make/VS2017/uox3.vcxproj.filters
+++ b/make/VS2017/uox3.vcxproj.filters
@@ -555,7 +555,10 @@
Header Files\Utility
-
+
+ Header Files\Utility
+
+
Header Files\UOData
@@ -581,4 +584,4 @@
Resource Files
-
\ No newline at end of file
+
diff --git a/make/VS2022/uox3.vcxproj b/make/VS2022/uox3.vcxproj
index 1978d7850..e3ca192b0 100644
--- a/make/VS2022/uox3.vcxproj
+++ b/make/VS2022/uox3.vcxproj
@@ -278,7 +278,8 @@
-
+
+
@@ -303,4 +304,4 @@
-
\ No newline at end of file
+
diff --git a/make/VS2022/uox3.vcxproj.filters b/make/VS2022/uox3.vcxproj.filters
index e23a44689..e30f8963b 100644
--- a/make/VS2022/uox3.vcxproj.filters
+++ b/make/VS2022/uox3.vcxproj.filters
@@ -1,4 +1,4 @@
-
+
@@ -555,7 +555,10 @@
Header Files\Utility
-
+
+ Header Files\Utility
+
+
Header Files\UOData
@@ -581,4 +584,4 @@
Resource Files
-
\ No newline at end of file
+
diff --git a/make/XCode/uox3.xcodeproj/project.pbxproj b/make/XCode/uox3.xcodeproj/project.pbxproj
index 56b55edc8..c9ad8b840 100644
--- a/make/XCode/uox3.xcodeproj/project.pbxproj
+++ b/make/XCode/uox3.xcodeproj/project.pbxproj
@@ -128,6 +128,7 @@
56C9E3DB2A9C9035004D9F38 /* uox3.vcxproj */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = uox3.vcxproj; path = ../VS2017/uox3.vcxproj; sourceTree = ""; };
56C9E3DC2A9C9035004D9F38 /* uox3.vcxproj.filters */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = uox3.vcxproj.filters; path = ../VS2017/uox3.vcxproj.filters; sourceTree = ""; };
56C9E3DD2A9C9035004D9F38 /* uox3.sln */ = {isa = PBXFileReference; lastKnownFileType = text; name = uox3.sln; path = ../VS2017/uox3.sln; sourceTree = ""; };
+ 56D6EEC32A9F7707005355FA /* strutil.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = strutil.hpp; sourceTree = ""; };
648153C929466EF400784170 /* libjscript.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libjscript.a; sourceTree = BUILT_PRODUCTS_DIR; };
64A9006A293E3DA3009B54DA /* uox3 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = uox3; sourceTree = BUILT_PRODUCTS_DIR; };
64A90075293E3DD4009B54DA /* ai.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ai.cpp; sourceTree = ""; };
@@ -342,6 +343,14 @@
name = vs2017;
sourceTree = "";
};
+ 56D6EEC22A9F76DD005355FA /* utility */ = {
+ isa = PBXGroup;
+ children = (
+ 56D6EEC32A9F7707005355FA /* strutil.hpp */,
+ );
+ path = utility;
+ sourceTree = "";
+ };
64A90061293E3DA3009B54DA = {
isa = PBXGroup;
children = (
@@ -363,13 +372,14 @@
64A90074293E3DD4009B54DA /* source */ = {
isa = PBXGroup;
children = (
+ 56D6EEC22A9F76DD005355FA /* utility */,
64E2F795293FCE7500546A08 /* Script */,
64E2F790293FCE3800546A08 /* Base Objects */,
64E2F791293FCE4800546A08 /* Subsystem */,
64E2F792293FCE5900546A08 /* Other */,
64E2F793293FCE6200546A08 /* JS Engine */,
64E2F794293FCE6C00546A08 /* Network */,
- 64E2F797293FCE8C00546A08 /* Utility */,
+ 64E2F797293FCE8C00546A08 /* OldUtility */,
64E2F796293FCE8400546A08 /* UOData */,
64A90089293E3DD4009B54DA /* Changelog.txt */,
64A90103293E3DD4009B54DA /* uox3.cpp */,
@@ -586,7 +596,7 @@
name = UOData;
sourceTree = "";
};
- 64E2F797293FCE8C00546A08 /* Utility */ = {
+ 64E2F797293FCE8C00546A08 /* OldUtility */ = {
isa = PBXGroup;
children = (
64A900BD293E3DD4009B54DA /* EventTimer.cpp */,
@@ -596,7 +606,7 @@
64A900FB293E3DD4009B54DA /* TimeUtility.cpp */,
64A900FC293E3DD4009B54DA /* TimeUtility.hpp */,
);
- name = Utility;
+ name = OldUtility;
sourceTree = "";
};
/* End PBXGroup section */
@@ -891,7 +901,10 @@
../../source,
../../spidermonkey,
);
- WARNING_CFLAGS = "-Wno-shift-negative-value";
+ WARNING_CFLAGS = (
+ "-Wno-shift-negative-value",
+ "-Wno-format-security",
+ );
};
name = Debug;
};
@@ -911,7 +924,10 @@
../../source,
../../spidermonkey,
);
- WARNING_CFLAGS = "-Wno-shift-negative-value";
+ WARNING_CFLAGS = (
+ "-Wno-shift-negative-value",
+ "-Wno-format-security",
+ );
};
name = Release;
};
diff --git a/make/cmake/CMakeLists.txt b/make/cmake/CMakeLists.txt
index 34ae0cbc1..bb4aa0d29 100644
--- a/make/cmake/CMakeLists.txt
+++ b/make/cmake/CMakeLists.txt
@@ -166,6 +166,7 @@ add_executable(uox3
../../source/TimeUtility.hpp
../../source/EventTimer.cpp
../../source/EventTimer.hpp
+ ../../source/utility/strutil.hpp
# UOData group
../../source/mapclasses.h
../../source/mapstuff.cpp
@@ -211,6 +212,7 @@ else()
-funsigned-char
-Wno-shift-negative-value
-Wno-deprecated-declarations
+ -Wno-format-security
)
if (APPLE)
# We always use the system zlib , as it is most likely better optimized
diff --git a/source/CGump.cpp b/source/CGump.cpp
index 65c323966..99844741b 100644
--- a/source/CGump.cpp
+++ b/source/CGump.cpp
@@ -112,7 +112,7 @@ void CGump::SetSerial( UI32 newSerial )
//o------------------------------------------------------------------------------------------------o
void CGump::AddBackground( UI16 x, UI16 y, UI16 gumpId, UI16 width, UI16 height )
{
- TagList.push_back( oldstrutil::format( "resizepic %u %u %u %u %u", x, y, gumpId, width, height ));
+ TagList.push_back( util::format( "resizepic %u %u %u %u %u", x, y, gumpId, width, height ));
}
//o------------------------------------------------------------------------------------------------o
@@ -122,7 +122,7 @@ void CGump::AddBackground( UI16 x, UI16 y, UI16 gumpId, UI16 width, UI16 height
//o------------------------------------------------------------------------------------------------o
void CGump::AddGump( UI16 x, UI16 y, UI16 gumpId )
{
- TagList.push_back( oldstrutil::format( "gumppic %u %u %u", x, y, gumpId ));
+ TagList.push_back( util::format( "gumppic %u %u %u", x, y, gumpId ));
}
//o------------------------------------------------------------------------------------------------o
@@ -132,7 +132,7 @@ void CGump::AddGump( UI16 x, UI16 y, UI16 gumpId )
//o------------------------------------------------------------------------------------------------o
void CGump::AddButton( UI16 x, UI16 y, UI16 imageUp, UI16 imageDown, UI16 behaviour, UI16 page, UI32 uniqueId )
{
- TagList.push_back( oldstrutil::format( "button %u %u %u %u %u %u %u", x, y, imageUp, imageDown, behaviour, page, uniqueId ));
+ TagList.push_back( util::format( "button %u %u %u %u %u %u %u", x, y, imageUp, imageDown, behaviour, page, uniqueId ));
}
//o------------------------------------------------------------------------------------------------o
@@ -145,7 +145,7 @@ void CGump::AddText( UI16 x, UI16 y, UI16 hue, std::string text )
UI32 textId = static_cast( TextList.size() );
TextList.push_back( text );
- TagList.push_back( oldstrutil::format( "text %u %u %u %u", x, y, hue, textId ));
+ TagList.push_back( util::format( "text %u %u %u %u", x, y, hue, textId ));
}
//o------------------------------------------------------------------------------------------------o
@@ -155,7 +155,7 @@ void CGump::AddText( UI16 x, UI16 y, UI16 hue, std::string text )
//o------------------------------------------------------------------------------------------------o
UI16 CGump::StartPage( void )
{
- TagList.push_back( oldstrutil::format( "page %u", PageCount ));
+ TagList.push_back( util::format( "page %u", PageCount ));
++PageCount;
return PageCount - 1;
diff --git a/source/CJSMapping.cpp b/source/CJSMapping.cpp
index 6bb4a63eb..4109ee9c4 100644
--- a/source/CJSMapping.cpp
+++ b/source/CJSMapping.cpp
@@ -4,6 +4,8 @@
#include "scriptc.h"
#include "ssection.h"
#include "StringUtility.hpp"
+#include "utility/strutil.hpp"
+
#include
using namespace std::string_literals;
@@ -100,7 +102,7 @@ void CJSMapping::Reload( UI16 scriptId )
{
if( scriptId != 0xFFFF )
{
- Console.Print( oldstrutil::format( "CMD: Attempting Reload of JavaScript (ScriptId %u)\n", scriptId ));
+ Console.Print( util::format( "CMD: Attempting Reload of JavaScript (ScriptId %u)\n", scriptId ));
for( size_t i = SCPT_NORMAL; i < SCPT_COUNT; ++i )
{
if( mapSection[i]->IsInMap( scriptId ))
@@ -109,11 +111,11 @@ void CJSMapping::Reload( UI16 scriptId )
return;
}
}
- Console.Warning( oldstrutil::format( "Unable to locate specified JavaScript in the map (ScriptId %u)", scriptId ));
+ Console.Warning( util::format( "Unable to locate specified JavaScript in the map (ScriptId %u)", scriptId ));
}
else
{
- Console.Print( oldstrutil::format( "CMD: Loading JSE Scripts... \n" ));
+ Console.Print( util::format( "CMD: Loading JSE Scripts... \n" ));
Cleanup();
ResetDefaults();
envokeById->Parse();
@@ -129,7 +131,7 @@ void CJSMapping::Reload( UI16 scriptId )
//o------------------------------------------------------------------------------------------------o
void CJSMapping::Reload( SCRIPTTYPE sectionId )
{
- Console.Print( oldstrutil::format( "CMD: Attempting Reload of JavaScript (SectionId %u)\n", static_cast( sectionId )));
+ Console.Print( util::format( "CMD: Attempting Reload of JavaScript (SectionId %u)\n", static_cast( sectionId )));
if( mapSection[sectionId] != nullptr )
{
delete mapSection[sectionId];
@@ -153,7 +155,7 @@ void CJSMapping::Parse( SCRIPTTYPE toParse )
std::string scpFileName = cwmWorldState->ServerData()->Directory( CSDDP_SCRIPTS ) + "jse_fileassociations.scp";
if( !FileExists( scpFileName ))
{
- Console.Error( oldstrutil::format( "Failed to open %s", scpFileName.c_str() ));
+ Console.Error( util::format( "Failed to open %s", scpFileName.c_str() ));
return;
}
@@ -345,7 +347,7 @@ auto CJSMappingSection::Parse( Script *fileAssocData ) -> void
if( !FileExists( fullPath ))
{
- Console.Error( oldstrutil::format( "SE mapping of %i to %s failed, file does not exist!", scriptId, data.c_str() ));
+ Console.Error( util::format( "SE mapping of %i to %s failed, file does not exist!", scriptId, data.c_str() ));
}
else
{
@@ -361,22 +363,22 @@ auto CJSMappingSection::Parse( Script *fileAssocData ) -> void
}
catch( std::runtime_error &e )
{
- Console.Error( oldstrutil::format( "Compiling %s caused a construction failure (Details: %s)", fullPath.c_str(), e.what() ));
+ Console.Error( util::format( "Compiling %s caused a construction failure (Details: %s)", fullPath.c_str(), e.what() ));
}
}
}
Console.Print( " o Loaded " );
Console.TurnYellow();
- Console.Print( oldstrutil::format( "%4u ", i ));
+ Console.Print( util::format( "%4u ", i ));
Console.TurnNormal();
Console.Print( "scripts from section " );
Console.TurnYellow();
- Console.Print( oldstrutil::format( "%s\n", ScriptNames[scriptType].c_str() ));
+ Console.Print( util::format( "%s\n", ScriptNames[scriptType].c_str() ));
Console.TurnNormal();
}
else
{
- Console.Warning( oldstrutil::format( "No JS file mappings found in section %s", ScriptNames[scriptType].c_str() ));
+ Console.Warning( util::format( "No JS file mappings found in section %s", ScriptNames[scriptType].c_str() ));
}
}
@@ -391,7 +393,7 @@ auto CJSMappingSection::Reload( UI16 toLoad ) -> void
auto scpFileName = cwmWorldState->ServerData()->Directory( CSDDP_SCRIPTS ) + "jse_fileassociations.scp"s;
if( !FileExists( scpFileName ))
{
- Console.Error( oldstrutil::format( "Failed to open %s", scpFileName.c_str() ));
+ Console.Error( util::format( "Failed to open %s", scpFileName.c_str() ));
return;
}
@@ -420,7 +422,7 @@ auto CJSMappingSection::Reload( UI16 toLoad ) -> void
if( !FileExists( fullPath ))
{
- Console.Error( oldstrutil::format( "SE mapping of %i to %s failed, file does not exist!", scriptId, data.c_str() ));
+ Console.Error( util::format( "SE mapping of %i to %s failed, file does not exist!", scriptId, data.c_str() ));
}
else
{
@@ -447,22 +449,22 @@ auto CJSMappingSection::Reload( UI16 toLoad ) -> void
{
scriptIdMap[scriptId] = toAdd;
scriptJSMap[toAdd->Object()] = scriptId;
- Console.Print( oldstrutil::format( "Reload of JavaScript (ScriptId %u) Successful\n", toLoad ));
+ Console.Print( util::format( "Reload of JavaScript (ScriptId %u) Successful\n", toLoad ));
}
}
catch( std::runtime_error &e )
{
- Console.Error( oldstrutil::format( "Compiling %s caused a construction failure (Details: %s)", fullPath.c_str(), e.what() ));
+ Console.Error( util::format( "Compiling %s caused a construction failure (Details: %s)", fullPath.c_str(), e.what() ));
}
}
return;
}
}
- Console.Warning( oldstrutil::format( "Unable to locate the specified JavaScript in the file (ScriptId %u)", toLoad ));
+ Console.Warning( util::format( "Unable to locate the specified JavaScript in the file (ScriptId %u)", toLoad ));
}
else
{
- Console.Warning( oldstrutil::format( "No JS file mappings found in section %s", ScriptNames[scriptType].c_str() ));
+ Console.Warning( util::format( "No JS file mappings found in section %s", ScriptNames[scriptType].c_str() ));
}
}
}
@@ -660,7 +662,7 @@ auto CEnvoke::Parse() -> void
}
else
{
- Console.Error( oldstrutil::format( "(ENVOKE) Item %s refers to scriptId %u which does not exist.", tag.c_str(), scriptId ));
+ Console.Error( util::format( "(ENVOKE) Item %s refers to scriptId %u which does not exist.", tag.c_str(), scriptId ));
}
}
}
diff --git a/source/CPacketReceive.cpp b/source/CPacketReceive.cpp
index 945511bd1..cb5b9c1a1 100644
--- a/source/CPacketReceive.cpp
+++ b/source/CPacketReceive.cpp
@@ -17,6 +17,7 @@
#include "cGuild.h"
#include "CResponse.h"
#include "StringUtility.hpp"
+#include "utility/strutil.hpp"
#include "cRaces.h"
#include
#include "IP4Address.hpp"
@@ -347,7 +348,7 @@ bool CPIFirstLogin::Handle( void )
if( tSock->AcctNo() != AB_INVALID_ID )
{
actbTemp->dwLastIP = CalcSerial( tSock->ClientIP4(), tSock->ClientIP3(), tSock->ClientIP2(), tSock->ClientIP1() );
- auto temp = oldstrutil::format( "Client [%i.%i.%i.%i] connected using Account '%s'.", tSock->ClientIP4(), tSock->ClientIP3(), tSock->ClientIP2(), tSock->ClientIP1(), username.c_str() );
+ auto temp = util::format( "Client [%i.%i.%i.%i] connected using Account '%s'.", tSock->ClientIP4(), tSock->ClientIP3(), tSock->ClientIP2(), tSock->ClientIP1(), username.c_str() );
Console.Log( temp , "server.log" );
messageLoop << temp;
@@ -718,9 +719,9 @@ void CPINewClientVersion::Receive( void )
clientPrototype = tSock->GetDWord( 17 );
tSock->ClientVersion( majorVersion, minorVersion, clientRevision, clientPrototype );
- std::string verString = oldstrutil::number( majorVersion ) + std::string( "." ) +
- oldstrutil::number( minorVersion ) + std::string( ". ") + oldstrutil::number( clientRevision ) +
- std::string( "." ) + oldstrutil::number( clientPrototype );
+ std::string verString = util::ntos( majorVersion ) + std::string( "." ) +
+ util::ntos( minorVersion ) + std::string( ". ") + util::ntos( clientRevision ) +
+ std::string( "." ) + util::ntos( clientPrototype );
Console << verString << myendl;
// Set client-version based on information received so far. We need this to be able to send the correct info during login
@@ -1329,7 +1330,7 @@ auto CPITips::Handle() -> bool
for( tag = tips->First(); !tips->AtEnd(); tag = tips->Next() )
{
- if( !tag.empty() && oldstrutil::upper( tag ) == "TIP" )
+ if( !tag.empty() && util::upper( tag ) == "TIP" )
{
--x;
}
@@ -1344,7 +1345,7 @@ auto CPITips::Handle() -> bool
}
data = tips->GrabData();
- sect = "TIP " + oldstrutil::trim( oldstrutil::removeTrailing( data, "//" ));
+ sect = "TIP " + util::trim( util::strip( data, "//" ));
tips = FileLookup->FindEntry( sect, misc_def );
if( tips )
{
@@ -2467,7 +2468,7 @@ bool CPITalkRequest::HandleCommon( void )
tempPage->Reason( Text() );
tempPage->WhoPaging( ourChar->GetSerial() );
- auto temp = oldstrutil::format( "GM Page from %s [%x %x %x %x]: %s", ourChar->GetName().c_str(), a1, a2, a3, a4, tempPage->Reason().c_str() );
+ auto temp = util::format( "GM Page from %s [%x %x %x %x]: %s", ourChar->GetName().c_str(), a1, a2, a3, a4, tempPage->Reason().c_str() );
bool x = false;
{
for( auto &tmpSock : Network->connClients )
@@ -2506,7 +2507,7 @@ bool CPITalkRequest::HandleCommon( void )
tempPageCns = CounselorQueue->Current();
tempPageCns->Reason( Text() );
tempPageCns->WhoPaging( ourChar->GetSerial() );
- auto temp = oldstrutil::format( "Counselor Page from %s [%x %x %x %x]: %s", ourChar->GetName().c_str(), a1, a2, a3, a4, tempPageCns->Reason().c_str() );
+ auto temp = util::format( "Counselor Page from %s [%x %x %x %x]: %s", ourChar->GetName().c_str(), a1, a2, a3, a4, tempPageCns->Reason().c_str() );
bool x = false;
{
for( auto &tmpSock : Network->connClients )
@@ -3025,7 +3026,7 @@ void CPICreateCharacter::Create3DCharacter( void )
{
if( ValidateObject( tSock->CurrcharObj() ))
{
- Console.Error( oldstrutil::format( "CreateCharacter packet 0x8D detected for socket with pre-existing character (%i) attached. Disconnecting socket as safeguard against corruption!", tSock->CurrcharObj()->GetSerial() ));
+ Console.Error( util::format( "CreateCharacter packet 0x8D detected for socket with pre-existing character (%i) attached. Disconnecting socket as safeguard against corruption!", tSock->CurrcharObj()->GetSerial() ));
Network->Disconnect( tSock );
return;
}
@@ -3124,7 +3125,7 @@ void CPICreateCharacter::Create2DCharacter( void )
{
if( ValidateObject( tSock->CurrcharObj() ))
{
- Console.Error( oldstrutil::format( "CreateCharacter packet 0x00 or 0xF8 detected for socket with pre-existing character (%i) attached. Disconnecting socket as safeguard against corruption!", tSock->CurrcharObj()->GetSerial() ));
+ Console.Error( util::format( "CreateCharacter packet 0x00 or 0xF8 detected for socket with pre-existing character (%i) attached. Disconnecting socket as safeguard against corruption!", tSock->CurrcharObj()->GetSerial() ));
Network->Disconnect( tSock );
return;
}
@@ -3975,7 +3976,7 @@ void CPISubcommands::Receive( void )
case 0x0C: { subPacket = new CPIClosedStatusGump( tSock ); } break; // Closed Status Gump
case 0x0F: skipOver = true; break; // Unknown, Sent once at Login
case 0x24: skipOver = true; break;
- default: Console.Print( oldstrutil::format( "Packet 0xBF: Unhandled Subcommand: 0x%X\n", subCmd )); skipOver = true; break;
+ default: Console.Print( util::format( "Packet 0xBF: Unhandled Subcommand: 0x%X\n", subCmd )); skipOver = true; break;
case 0x06: { subPacket = new CPIPartyCommand( tSock ); } break;
case 0x07: { subPacket = new CPITrackingArrow( tSock ); } break; // Click on Quest/Tracking Arrow
case 0x0B: { subPacket = new CPIClientLanguage( tSock ); } break; // Client language. 3 bytes. "ENU" for english
@@ -4705,7 +4706,7 @@ bool CPIPopupMenuSelect::Handle( void )
}
else
{
- Console.Warning( oldstrutil::format( "Character 0x%X has no backpack!", targChar->GetSerial() ));
+ Console.Warning( util::format( "Character 0x%X has no backpack!", targChar->GetSerial() ));
}
}
}
@@ -5087,7 +5088,7 @@ bool CPIPopupMenuSelect::Handle( void )
}
break;
default:
- Console.Print( oldstrutil::format( "Popup Menu Selection Called, Player: 0x%X Selection: 0x%X\n", tSock->GetDWord( 5 ), tSock->GetWord( 9 )));
+ Console.Print( util::format( "Popup Menu Selection Called, Player: 0x%X Selection: 0x%X\n", tSock->GetDWord( 5 ), tSock->GetWord( 9 )));
break;
}
diff --git a/source/CPacketSend.cpp b/source/CPacketSend.cpp
index 5756b38da..388a79eb1 100644
--- a/source/CPacketSend.cpp
+++ b/source/CPacketSend.cpp
@@ -18,6 +18,7 @@
#include
#include
#include "osunique.hpp"
+#include "utility/strutil.hpp"
#if defined(_WIN32)
#include
#endif
@@ -1945,7 +1946,7 @@ void CPOpenGump::Question( std::string toAdd )
#if defined( UOX_DEBUG_MODE )
if( toAdd.length() >= 255 )
{
- Console.Error( oldstrutil::format( "CPOpenGump::Question toAdd.length() is too long (%i)", toAdd.length() ));
+ Console.Error( util::format( "CPOpenGump::Question toAdd.length() is too long (%i)", toAdd.length() ));
}
#endif
pStream.WriteByte( 9, static_cast( toAdd.length() + 1 ));
@@ -1958,7 +1959,7 @@ void CPOpenGump::AddResponse( UI16 modelNum, UI16 colour, std::string responseTe
#if defined( UOX_DEBUG_MODE )
if( responseText.length() >= 255 )
{
- Console.Error( oldstrutil::format( "CPOpenGump::AddResponse responseText is too long (%i)", responseText.length() ));
+ Console.Error( util::format( "CPOpenGump::AddResponse responseText is too long (%i)", responseText.length() ));
}
#endif
UI16 toAdd = static_cast( 5 + responseText.length() );
@@ -4740,10 +4741,10 @@ void CPOpenBuyWindow::AddItem( CItem *toAdd, CTownRegion *tReg, UI16 &baseOffset
itemname.reserve( MAX_NAME );
UI08 sLen = 0;
std::string temp = toAdd->GetName();
- temp = oldstrutil::simplify(temp);
+ temp = util::simplify(temp);
if( temp.substr( 0, 1 ) == "#" )
{
- itemname = oldstrutil::number( 1020000 + toAdd->GetId() );
+ itemname = util::ntos( 1020000 + toAdd->GetId() );
sLen = static_cast( itemname.size() + 1 );
}
else
@@ -7184,24 +7185,24 @@ void CPToolTip::CopyItemData( CItem& cItem, size_t &totalStringLen, bool addAmou
GetTileName( cItem, temp );
if( cItem.GetAmount() > 1 && addAmount )
{
- tempEntry.ourText = oldstrutil::format( " \t%s : %i\t ", temp.c_str(), cItem.GetAmount() );
+ tempEntry.ourText = util::format( " \t%s : %i\t ", temp.c_str(), cItem.GetAmount() );
}
else
{
- tempEntry.ourText = oldstrutil::format( " \t%s\t ", temp.c_str() );
+ tempEntry.ourText = util::format( " \t%s\t ", temp.c_str() );
}
}
else
{
if( cItem.GetAmount() > 1 && !cItem.IsCorpse() && addAmount && cItem.GetType() != IT_SPAWNCONT && cItem.GetType() != IT_LOCKEDSPAWNCONT && cItem.GetType() != IT_UNLOCKABLESPAWNCONT )
{
- tempEntry.ourText = oldstrutil::format( " \t%s : %i\t ", cItemName.c_str(), cItem.GetAmount() );
+ tempEntry.ourText = util::format( " \t%s : %i\t ", cItemName.c_str(), cItem.GetAmount() );
}
else
{
if( cwmWorldState->ServerData()->RankSystemStatus() && cItem.GetRank() == 10 )
{
- tempEntry.ourText = oldstrutil::format(" \t%s %s\t ", cItemName.c_str(), Dictionary->GetEntry( 9140, tSock->Language() ).c_str() ); // %s of exceptional quality
+ tempEntry.ourText = util::format(" \t%s %s\t ", cItemName.c_str(), Dictionary->GetEntry( 9140, tSock->Language() ).c_str() ); // %s of exceptional quality
}
else
{
@@ -7229,11 +7230,11 @@ void CPToolTip::CopyItemData( CItem& cItem, size_t &totalStringLen, bool addAmou
}
}
- tempEntry.ourText = oldstrutil::format( " \t%s\t ", iFlagColor.c_str(), cItemName.c_str() );
+ tempEntry.ourText = util::format( " \t%s\t ", iFlagColor.c_str(), cItemName.c_str() );
}
else
{
- tempEntry.ourText = oldstrutil::format( " \t%s\t ", cItemName.c_str() );
+ tempEntry.ourText = util::format( " \t%s\t ", cItemName.c_str() );
}
}
}
@@ -7250,8 +7251,8 @@ void CPToolTip::CopyItemData( CItem& cItem, size_t &totalStringLen, bool addAmou
if( ValidateObject( cItemCreator ))
{
tempEntry.stringNum = 1042971; // ~1_NOTHING~
- tempEntry.ourText = oldstrutil::format( "%s by %s", cwmWorldState->skill[cItem.GetMadeWith()-1].madeWord.c_str(), cItemCreator->GetName().c_str() ); // tailored/tinkered/forged by %s
- //tempEntry.ourText = oldstrutil::format( "%s %s", Dictionary->GetEntry( 9141, tSock->Language() ).c_str(), cItemCreator->GetName().c_str() ); // Crafted by %s
+ tempEntry.ourText = util::format( "%s by %s", cwmWorldState->skill[cItem.GetMadeWith()-1].madeWord.c_str(), cItemCreator->GetName().c_str() ); // tailored/tinkered/forged by %s
+ //tempEntry.ourText = util::format( "%s %s", Dictionary->GetEntry( 9141, tSock->Language() ).c_str(), cItemCreator->GetName().c_str() ); // Crafted by %s
FinalizeData( tempEntry, totalStringLen );
}
}
@@ -7277,20 +7278,20 @@ void CPToolTip::CopyItemData( CItem& cItem, size_t &totalStringLen, bool addAmou
if( !itemTownRegion->IsGuarded() && !itemTownRegion->IsSafeZone() )
{
tempEntry.stringNum = 1042971; // ~1_NOTHING~
- tempEntry.ourText = oldstrutil::format( "%s", Dictionary->GetEntry( 9051, tSock->Language() ).c_str() ); // [Guarded]
+ tempEntry.ourText = util::format( "%s", Dictionary->GetEntry( 9051, tSock->Language() ).c_str() ); // [Guarded]
FinalizeData( tempEntry, totalStringLen );
}
}
if( cItem.IsNewbie() )
{
tempEntry.stringNum = 1042971; // ~1_NOTHING~
- tempEntry.ourText = oldstrutil::format( "%s", Dictionary->GetEntry( 9055, tSock->Language() ).c_str() ); // [Blessed]
+ tempEntry.ourText = util::format( "%s", Dictionary->GetEntry( 9055, tSock->Language() ).c_str() ); // [Blessed]
FinalizeData( tempEntry, totalStringLen );
}
if( cItem.GetType() == IT_LOCKEDDOOR )
{
tempEntry.stringNum = 1042971; // ~1_NOTHING~
- tempEntry.ourText = oldstrutil::format( "%s", Dictionary->GetEntry( 9050, tSock->Language() ).c_str() ); // [Locked]
+ tempEntry.ourText = util::format( "%s", Dictionary->GetEntry( 9050, tSock->Language() ).c_str() ); // [Locked]
FinalizeData( tempEntry, totalStringLen );
}
@@ -7355,28 +7356,28 @@ void CPToolTip::CopyItemData( CItem& cItem, size_t &totalStringLen, bool addAmou
if( cItem.GetType() == IT_LOCKEDCONTAINER )
{
tempEntry.stringNum = 1042971; // ~1_NOTHING~
- tempEntry.ourText = oldstrutil::format( "%s", Dictionary->GetEntry( 9050 ).c_str(), tSock->Language() ); // [Locked]
+ tempEntry.ourText = util::format( "%s", Dictionary->GetEntry( 9050 ).c_str(), tSock->Language() ); // [Locked]
FinalizeData( tempEntry, totalStringLen );
}
tempEntry.stringNum = 1050044; // ~1_COUNT~ items, ~2_WEIGHT~ stones
- //tempEntry.ourText = oldstrutil::format( "%u\t%i", cItem.GetContainsList()->Num(), ( cItem.GetWeight() / 100 ));
- tempEntry.ourText = oldstrutil::format( "%u\t%i", GetTotalItemCount( &cItem ), ( cItem.GetWeight() / 100 ));
+ //tempEntry.ourText = util::format( "%u\t%i", cItem.GetContainsList()->Num(), ( cItem.GetWeight() / 100 ));
+ tempEntry.ourText = util::format( "%u\t%i", GetTotalItemCount( &cItem ), ( cItem.GetWeight() / 100 ));
FinalizeData( tempEntry, totalStringLen );
if(( cItem.GetWeightMax() / 100 ) >= 1 )
{
tempEntry.stringNum = 1072226; // Capacity: ~1_COUNT~ items, ~2_WEIGHT~ stones
- tempEntry.ourText = oldstrutil::format( "%u\t%i", cItem.GetMaxItems(), ( cItem.GetWeightMax() / 100 ));
+ tempEntry.ourText = util::format( "%u\t%i", cItem.GetMaxItems(), ( cItem.GetWeightMax() / 100 ));
//tempEntry.stringNum = 1060658;
- //tempEntry.ourText = oldstrutil::format( "Capacity\t%i Stones", ( cItem.GetWeightMax() / 100 ));
+ //tempEntry.ourText = util::format( "Capacity\t%i Stones", ( cItem.GetWeightMax() / 100 ));
FinalizeData( tempEntry, totalStringLen );
}
}
else if( cItem.GetType() == IT_LOCKEDSPAWNCONT )
{
tempEntry.stringNum = 1050045; // ~1_PREFIX~~2_NAME~~3_SUFFIX~
- tempEntry.ourText = oldstrutil::format( " \t%s\t ", Dictionary->GetEntry( 9050 ).c_str(), tSock->Language() ); // [Locked]
+ tempEntry.ourText = util::format( " \t%s\t ", Dictionary->GetEntry( 9050 ).c_str(), tSock->Language() ); // [Locked]
FinalizeData( tempEntry, totalStringLen );
}
else if( cItem.GetType() == IT_HOUSESIGN )
@@ -7395,7 +7396,7 @@ void CPToolTip::CopyItemData( CItem& cItem, size_t &totalStringLen, bool addAmou
else if( !cItem.IsCorpse() && cItem.GetType() != IT_POTION && cItem.GetSectionId() != "potionkeg" && cItem.GetName2() != "#" && cItem.GetName2() != "" )
{
tempEntry.stringNum = 1050045; // ~1_PREFIX~~2_NAME~~3_SUFFIX~
- tempEntry.ourText = oldstrutil::format( " \t%s\t ", Dictionary->GetEntry( 9402 ).c_str(), tSock->Language() ); // [Unidentified]
+ tempEntry.ourText = util::format( " \t%s\t ", Dictionary->GetEntry( 9402 ).c_str(), tSock->Language() ); // [Unidentified]
FinalizeData( tempEntry, totalStringLen );
}
else if( cItem.GetType() == IT_RECALLRUNE && cItem.GetTempVar( CITV_MOREX ) != 0 && cItem.GetTempVar( CITV_MOREY ) != 0 )
@@ -7443,18 +7444,18 @@ void CPToolTip::CopyItemData( CItem& cItem, size_t &totalStringLen, bool addAmou
if( cItem.GetType() == IT_ITEMSPAWNER || cItem.GetType() == IT_NPCSPAWNER )
{
- tempEntry.ourText = oldstrutil::number(( cItem.GetWeight() / 100 ));
+ tempEntry.ourText = util::ntos(( cItem.GetWeight() / 100 ));
}
else
{
CItem *cItemCont = static_cast( cItem.GetCont() );
if( ValidateObject( cItemCont ) && cItemCont->GetLayer() == IL_SELLCONTAINER )
{
- tempEntry.ourText = oldstrutil::number(( cItem.GetWeight() / 100 ));
+ tempEntry.ourText = util::ntos(( cItem.GetWeight() / 100 ));
}
else
{
- tempEntry.ourText = oldstrutil::number(( cItem.GetWeight() / 100 ) * cItem.GetAmount() );
+ tempEntry.ourText = util::ntos(( cItem.GetWeight() / 100 ) * cItem.GetAmount() );
}
}
FinalizeData( tempEntry, totalStringLen );
@@ -7462,7 +7463,7 @@ void CPToolTip::CopyItemData( CItem& cItem, size_t &totalStringLen, bool addAmou
if( cItem.GetType() == IT_MAGICWAND && cItem.GetTempVar( CITV_MOREZ ))
{
tempEntry.stringNum = 1060584; // uses remaining: ~1_val~
- tempEntry.ourText = oldstrutil::number( cItem.GetTempVar( CITV_MOREZ ));
+ tempEntry.ourText = util::ntos( cItem.GetTempVar( CITV_MOREZ ));
FinalizeData( tempEntry, totalStringLen );
}
@@ -7478,68 +7479,68 @@ void CPToolTip::CopyItemData( CItem& cItem, size_t &totalStringLen, bool addAmou
if( cItem.GetWeatherDamage( PHYSICAL ))
{
tempEntry.stringNum = 1060403; // physical damage ~1_val~%
- tempEntry.ourText = oldstrutil::number( 100 );
+ tempEntry.ourText = util::ntos( 100 );
FinalizeData( tempEntry, totalStringLen );
}
else if( cItem.GetWeatherDamage( LIGHT ))
{
tempEntry.stringNum = 1042971; // ~1_NOTHING~
- tempEntry.ourText = oldstrutil::format( "light damage: 100%" );
+ tempEntry.ourText = util::format( "light damage: 100%" );
FinalizeData( tempEntry, totalStringLen );
}
else if( cItem.GetWeatherDamage( RAIN ))
{
tempEntry.stringNum = 1042971; // ~1_NOTHING~
- tempEntry.ourText = oldstrutil::format( "rain damage: 100%" );
+ tempEntry.ourText = util::format( "rain damage: 100%" );
FinalizeData( tempEntry, totalStringLen );
}
else if( cItem.GetWeatherDamage( COLD ))
{
tempEntry.stringNum = 1060403; // cold damage ~1_val~%
- tempEntry.ourText = oldstrutil::number( 100 );
+ tempEntry.ourText = util::ntos( 100 );
FinalizeData( tempEntry, totalStringLen );
}
else if( cItem.GetWeatherDamage( HEAT ))
{
tempEntry.stringNum = 1042971; // ~1_NOTHING~
- tempEntry.ourText = oldstrutil::format( "fire damage: 100%" );
+ tempEntry.ourText = util::format( "fire damage: 100%" );
FinalizeData( tempEntry, totalStringLen );
}
else if( cItem.GetWeatherDamage( LIGHTNING ))
{
tempEntry.stringNum = 1060407; // energy damage ~1_val~%
- tempEntry.ourText = oldstrutil::number( 100 );
+ tempEntry.ourText = util::ntos( 100 );
FinalizeData( tempEntry, totalStringLen );
}
else if( cItem.GetWeatherDamage( POISON ))
{
tempEntry.stringNum = 1060406; // energy damage ~1_val~%
- tempEntry.ourText = oldstrutil::number( 100 );
+ tempEntry.ourText = util::ntos( 100 );
FinalizeData( tempEntry, totalStringLen );
}
else if( cItem.GetWeatherDamage( SNOW ))
{
tempEntry.stringNum = 1042971; // ~1_NOTHING~
- tempEntry.ourText = oldstrutil::format( "snow damage: 100%" );
+ tempEntry.ourText = util::format( "snow damage: 100%" );
FinalizeData( tempEntry, totalStringLen );
}
else if( cItem.GetWeatherDamage( STORM ))
{
tempEntry.stringNum = 1042971; // ~1_NOTHING~
- tempEntry.ourText = oldstrutil::format( "storm damage: 100%" );
+ tempEntry.ourText = util::format( "storm damage: 100%" );
FinalizeData( tempEntry, totalStringLen );
}
}
tempEntry.stringNum = 1061168; // weapon damage ~1_val~ - ~2_val~
- tempEntry.ourText = oldstrutil::format( "%i\t%i", cItem.GetLoDamage(), cItem.GetHiDamage() );
+ tempEntry.ourText = util::format( "%i\t%i", cItem.GetLoDamage(), cItem.GetHiDamage() );
FinalizeData( tempEntry, totalStringLen );
}
if( cItem.GetSpeed() > 0 )
{
tempEntry.stringNum = 1061167; // weapon speed ~1_val~
- tempEntry.ourText = oldstrutil::number( cItem.GetSpeed() );
+ tempEntry.ourText = util::ntos( cItem.GetSpeed() );
FinalizeData( tempEntry, totalStringLen );
}
@@ -7584,35 +7585,35 @@ void CPToolTip::CopyItemData( CItem& cItem, size_t &totalStringLen, bool addAmou
if( cItem.GetResist( PHYSICAL ) > 0 )
{
tempEntry.stringNum = 1060448; // physical resist ~1_val~%
- tempEntry.ourText = oldstrutil::number( cItem.GetResist( PHYSICAL ));
+ tempEntry.ourText = util::ntos( cItem.GetResist( PHYSICAL ));
FinalizeData( tempEntry, totalStringLen );
}
if( cItem.GetResist( HEAT ) > 0 )
{
tempEntry.stringNum = 1060447; // fire resist ~1_val~%
- tempEntry.ourText = oldstrutil::number( cItem.GetResist( HEAT ));
+ tempEntry.ourText = util::ntos( cItem.GetResist( HEAT ));
FinalizeData( tempEntry, totalStringLen );
}
if( cItem.GetResist( COLD ) > 0 )
{
tempEntry.stringNum = 1060445; // cold resist ~1_val~%
- tempEntry.ourText = oldstrutil::number( cItem.GetResist( COLD ));
+ tempEntry.ourText = util::ntos( cItem.GetResist( COLD ));
FinalizeData( tempEntry, totalStringLen );
}
if( cItem.GetResist( POISON ) > 0 )
{
tempEntry.stringNum = 1060449; // poison resist ~1_val~%
- tempEntry.ourText = oldstrutil::number( cItem.GetResist( POISON ));
+ tempEntry.ourText = util::ntos( cItem.GetResist( POISON ));
FinalizeData( tempEntry, totalStringLen );
}
if( cItem.GetResist( LIGHTNING ) > 0 )
{
tempEntry.stringNum = 1060446; // energy/electrical resist ~1_val~%
- tempEntry.ourText = oldstrutil::number( cItem.GetResist( LIGHTNING ));
+ tempEntry.ourText = util::ntos( cItem.GetResist( LIGHTNING ));
FinalizeData( tempEntry, totalStringLen );
}
}
@@ -7621,7 +7622,7 @@ void CPToolTip::CopyItemData( CItem& cItem, size_t &totalStringLen, bool addAmou
if( cItem.GetResist( PHYSICAL ) > 0 )
{
tempEntry.stringNum = 1042971; // ~1_NOTHING~
- tempEntry.ourText = oldstrutil::format( "Armor Rating: %s", oldstrutil::number( cItem.GetResist( PHYSICAL )).c_str() );
+ tempEntry.ourText = util::format( "Armor Rating: %s", util::ntos( cItem.GetResist( PHYSICAL )).c_str() );
FinalizeData( tempEntry, totalStringLen );
}
}
@@ -7629,33 +7630,33 @@ void CPToolTip::CopyItemData( CItem& cItem, size_t &totalStringLen, bool addAmou
if( cItem.GetMaxHP() > 1 )
{
tempEntry.stringNum = 1060639; // durability ~1_val~ / ~2_val~
- tempEntry.ourText = oldstrutil::format( "%i\t%i", cItem.GetHP(), cItem.GetMaxHP() );
+ tempEntry.ourText = util::format( "%i\t%i", cItem.GetHP(), cItem.GetMaxHP() );
FinalizeData( tempEntry, totalStringLen );
}
if( cItem.GetStrength2() > 0 )
{
tempEntry.stringNum = 1060485; // strength bonus ~1_val~
- tempEntry.ourText = oldstrutil::number( cItem.GetStrength2() );
+ tempEntry.ourText = util::ntos( cItem.GetStrength2() );
FinalizeData( tempEntry, totalStringLen );
}
if( cItem.GetDexterity2() > 0 )
{
tempEntry.stringNum = 1060409; // dexterity bonus ~1_val~
- tempEntry.ourText = oldstrutil::number( cItem.GetDexterity2() );
+ tempEntry.ourText = util::ntos( cItem.GetDexterity2() );
FinalizeData( tempEntry, totalStringLen );
}
if( cItem.GetIntelligence2() > 0 )
{
tempEntry.stringNum = 1060432; // intelligence bonus ~1_val~
- tempEntry.ourText = oldstrutil::number( cItem.GetIntelligence2() );
+ tempEntry.ourText = util::ntos( cItem.GetIntelligence2() );
FinalizeData( tempEntry, totalStringLen );
}
if( cItem.GetStrength() > 1 )
{
tempEntry.stringNum = 1061170; // strength requirement ~1_val~
- tempEntry.ourText = oldstrutil::number( cItem.GetStrength() );
+ tempEntry.ourText = util::ntos( cItem.GetStrength() );
FinalizeData( tempEntry, totalStringLen );
}
}
@@ -7681,7 +7682,7 @@ void CPToolTip::CopyItemData( CItem& cItem, size_t &totalStringLen, bool addAmou
{
// First the price
tempEntry.stringNum = 1043304; // Price: ~1_COST~
- tempEntry.ourText = oldstrutil::number( cItem.GetVendorPrice() );
+ tempEntry.ourText = util::ntos( cItem.GetVendorPrice() );
FinalizeData( tempEntry, totalStringLen );
}
else
@@ -7719,7 +7720,7 @@ void CPToolTip::CopyCharData( CChar& mChar, size_t &totalStringLen )
if( cwmWorldState->creatures[mChar.GetId()].IsHuman() && !mChar.IsIncognito() && !mChar.IsDisguised() )
{
GetFameTitle( &mChar, fameTitle );
- fameTitle = oldstrutil::trim( fameTitle );
+ fameTitle = util::trim( fameTitle );
}
}
@@ -7727,7 +7728,7 @@ void CPToolTip::CopyCharData( CChar& mChar, size_t &totalStringLen )
tempEntry.stringNum = 1050045; // ~1_PREFIX~~2_NAME~~3_SUFFIX~
std::string mCharName = GetNpcDictName( &mChar, tSock, NRS_TOOLTIP );
std::string convertedString = oldstrutil::stringToWstringToString( mCharName );
- tempEntry.ourText = oldstrutil::format( "%s \t%s\t ", fameTitle.c_str(), convertedString.c_str() );
+ tempEntry.ourText = util::format( "%s \t%s\t ", fameTitle.c_str(), convertedString.c_str() );
FinalizeData( tempEntry, totalStringLen );
@@ -7743,11 +7744,11 @@ void CPToolTip::CopyCharData( CChar& mChar, size_t &totalStringLen )
auto guildTitle = mChar.GetGuildTitle();
if( guildTitle != "" )
{
- tempEntry.ourText = oldstrutil::format( "%s, %s", guildTitle.c_str(), myGuild->Name().c_str() );
+ tempEntry.ourText = util::format( "%s, %s", guildTitle.c_str(), myGuild->Name().c_str() );
}
else
{
- tempEntry.ourText = oldstrutil::format( "%s", myGuild->Name().c_str() );
+ tempEntry.ourText = util::format( "%s", myGuild->Name().c_str() );
}
FinalizeData( tempEntry, totalStringLen );
}
@@ -7761,7 +7762,7 @@ void CPToolTip::CopyCharData( CChar& mChar, size_t &totalStringLen )
{
tempEntry.stringNum = 1042971; // ~1_NOTHING~
auto raceName = Races->Name( mChar.GetRace() );
- tempEntry.ourText = oldstrutil::format( "%s", ( "("s + raceName + ")"s ).c_str() );
+ tempEntry.ourText = util::format( "%s", ( "("s + raceName + ")"s ).c_str() );
FinalizeData( tempEntry, totalStringLen );
}
}
@@ -7773,7 +7774,7 @@ void CPToolTip::CopyCharData( CChar& mChar, size_t &totalStringLen )
if( !charTownRegion->IsGuarded() && !charTownRegion->IsSafeZone() )
{
tempEntry.stringNum = 1042971; // ~1_NOTHING~
- tempEntry.ourText = oldstrutil::format( "%s", Dictionary->GetEntry( 9051, tSock->Language() ).c_str() ); // [Guarded]
+ tempEntry.ourText = util::format( "%s", Dictionary->GetEntry( 9051, tSock->Language() ).c_str() ); // [Guarded]
FinalizeData( tempEntry, totalStringLen );
}
}
@@ -7785,7 +7786,7 @@ void CPToolTip::CopyCharData( CChar& mChar, size_t &totalStringLen )
std::string mCharTitle = GetNpcDictTitle( &mChar, tSock );
convertedString = oldstrutil::stringToWstringToString( mCharTitle );
- tempEntry.ourText = oldstrutil::format( "%s", convertedString.c_str() );
+ tempEntry.ourText = util::format( "%s", convertedString.c_str() );
FinalizeData( tempEntry, totalStringLen );
}
diff --git a/source/CResponse.cpp b/source/CResponse.cpp
index e1486a83e..df37e513a 100644
--- a/source/CResponse.cpp
+++ b/source/CResponse.cpp
@@ -37,6 +37,8 @@
#include "cGuild.h"
#include "skills.h"
#include "StringUtility.hpp"
+#include "utility/strutil.hpp"
+
#include
#include
@@ -206,51 +208,51 @@ bool WhichResponse( CSocket *mSock, CChar *mChar, std::string text, CChar *tChar
case TW_QUESTDEST: tResp = new CEscortResponse( true ); break;
case TW_TRAIN: tResp = new CTrainingResponse( trigWord, tChar ); break;
case TW_FOLLOW: [[fallthrough]];
- case TW_FOLLOW2: tResp = new CPetMultiResponse( oldstrutil::upper( text ), false, TARGET_FOLLOW, 1310, false, true ); break;
+ case TW_FOLLOW2: tResp = new CPetMultiResponse( util::upper( text ), false, TARGET_FOLLOW, 1310, false, true ); break;
case TW_COME: [[fallthrough]];
- case TW_FOLLOWME: tResp = new CPetComeResponse( false, oldstrutil::upper( text )); break;
+ case TW_FOLLOWME: tResp = new CPetComeResponse( false, util::upper( text )); break;
case TW_ALLFOLLOWME: [[fallthrough]];
- case TW_ALLCOME: tResp = new CPetComeResponse( true, oldstrutil::upper( text )); break;
- case TW_ALLFOLLOW: tResp = new CPetMultiResponse( oldstrutil::upper( text ), false, TARGET_FOLLOW, 1310, true, true ); break;
+ case TW_ALLCOME: tResp = new CPetComeResponse( true, util::upper( text )); break;
+ case TW_ALLFOLLOW: tResp = new CPetMultiResponse( util::upper( text ), false, TARGET_FOLLOW, 1310, true, true ); break;
case TW_KILL: [[fallthrough]];
- case TW_ATTACK: tResp = new CPetAttackResponse( false, oldstrutil::upper( text )); break;
+ case TW_ATTACK: tResp = new CPetAttackResponse( false, util::upper( text )); break;
case TW_ALLKILL: [[fallthrough]];
case TW_ALLATTACK:
/*{
- tResp = new CPetAttackResponse( true, oldstrutil::upper( text ));
+ tResp = new CPetAttackResponse( true, util::upper( text ));
tResp->Handle( mSock, mChar );
delete tResp;
tResp = nullptr;
goto endResponseCheck;
}*/
- tResp = new CPetAttackResponse( true, oldstrutil::upper( text ));
+ tResp = new CPetAttackResponse( true, util::upper( text ));
break;
case TW_FETCH:
case TW_GET:
- case TW_BRING: tResp = new CPetMultiResponse( oldstrutil::upper( text ), false, TARGET_GUARD, 1316, false, true ); break;
- case TW_FRIEND: tResp = new CPetMultiResponse( oldstrutil::upper( text ), true, TARGET_FRIEND, 1620, false, true ); break;
- case TW_GUARD: tResp = new CPetMultiResponse( oldstrutil::upper( text ), false, TARGET_GUARD, 1104, false, true ); break;
+ case TW_BRING: tResp = new CPetMultiResponse( util::upper( text ), false, TARGET_GUARD, 1316, false, true ); break;
+ case TW_FRIEND: tResp = new CPetMultiResponse( util::upper( text ), true, TARGET_FRIEND, 1620, false, true ); break;
+ case TW_GUARD: tResp = new CPetMultiResponse( util::upper( text ), false, TARGET_GUARD, 1104, false, true ); break;
case TW_ALLGUARD: [[fallthrough]];
- case TW_ALLGUARDME: tResp = new CPetGuardResponse( true, oldstrutil::upper( text )); break;
+ case TW_ALLGUARDME: tResp = new CPetGuardResponse( true, util::upper( text )); break;
case TW_STOP: [[fallthrough]];
- case TW_STAY: tResp = new CPetStayResponse( false, oldstrutil::upper( text )); break;
+ case TW_STAY: tResp = new CPetStayResponse( false, util::upper( text )); break;
case TW_ALLSTOP: [[fallthrough]];
- case TW_ALLSTAY: tResp = new CPetStayResponse( true, oldstrutil::upper( text )); break;
- case TW_TRANSFER: tResp = new CPetMultiResponse( oldstrutil::upper( text ), true, TARGET_TRANSFER, 1323, false, false ); break;
- case TW_RELEASE: tResp = new CPetReleaseResponse( oldstrutil::upper( text )); break;
- case TW_VENDORBUY: tResp = new CVendorBuyResponse( true, oldstrutil::upper( text )); break;
- case TW_BUY: tResp = new CVendorBuyResponse( false, oldstrutil::upper( text )); break;
- case TW_VENDORSELL: tResp = new CVendorSellResponse( true, oldstrutil::upper( text )); break;
- case TW_SELL: tResp = new CVendorSellResponse( false, oldstrutil::upper( text )); break;
- case TW_VENDORVIEW: tResp = new CVendorViewResponse( true, oldstrutil::upper( text )); break;
- case TW_VIEW: tResp = new CVendorViewResponse( false, oldstrutil::upper( text )); break;
- case TW_VENDORGOLD: tResp = new CVendorGoldResponse( true, oldstrutil::upper( text )); break;
+ case TW_ALLSTAY: tResp = new CPetStayResponse( true, util::upper( text )); break;
+ case TW_TRANSFER: tResp = new CPetMultiResponse( util::upper( text ), true, TARGET_TRANSFER, 1323, false, false ); break;
+ case TW_RELEASE: tResp = new CPetReleaseResponse( util::upper( text )); break;
+ case TW_VENDORBUY: tResp = new CVendorBuyResponse( true, util::upper( text )); break;
+ case TW_BUY: tResp = new CVendorBuyResponse( false, util::upper( text )); break;
+ case TW_VENDORSELL: tResp = new CVendorSellResponse( true, util::upper( text )); break;
+ case TW_SELL: tResp = new CVendorSellResponse( false, util::upper( text )); break;
+ case TW_VENDORVIEW: tResp = new CVendorViewResponse( true, util::upper( text )); break;
+ case TW_VIEW: tResp = new CVendorViewResponse( false, util::upper( text )); break;
+ case TW_VENDORGOLD: tResp = new CVendorGoldResponse( true, util::upper( text )); break;
case TW_COLLECT: [[fallthrough]];
- case TW_GOLD: tResp = new CVendorGoldResponse( false, oldstrutil::upper( text )); break;
- case TW_VENDORSTATUS: tResp = new CVendorStatusResponse( true, oldstrutil::upper( text )); break;
- case TW_STATUS: tResp = new CVendorStatusResponse( false, oldstrutil::upper( text )); break;
- case TW_VENDORDISMISS: tResp = new CVendorDismissResponse( true, oldstrutil::upper( text )); break;
- case TW_DISMISS: tResp = new CVendorDismissResponse( false, oldstrutil::upper( text )); break;
+ case TW_GOLD: tResp = new CVendorGoldResponse( false, util::upper( text )); break;
+ case TW_VENDORSTATUS: tResp = new CVendorStatusResponse( true, util::upper( text )); break;
+ case TW_STATUS: tResp = new CVendorStatusResponse( false, util::upper( text )); break;
+ case TW_VENDORDISMISS: tResp = new CVendorDismissResponse( true, util::upper( text )); break;
+ case TW_DISMISS: tResp = new CVendorDismissResponse( false, util::upper( text )); break;
case TW_HOUSEBAN: tResp = new CHouseMultiResponse( TARGET_HOUSEBAN, 585 ); break;
case TW_HOUSEEJECT: tResp = new CHouseMultiResponse( TARGET_HOUSEEJECT, 587 ); break;
case TW_HOUSELOCKDOWN: tResp = new CHouseMultiResponse( TARGET_HOUSELOCKDOWN, 589 ); break;
@@ -324,7 +326,7 @@ bool WhichResponse( CSocket *mSock, CChar *mChar, std::string text, CChar *tChar
break;
}
#if defined( UOX_DEBUG_MODE )
- Console.Print( oldstrutil::format( "Unhandled trigger [%s] sent by the client 0x%X\n", text.c_str(), trigWord ));
+ Console.Print( util::format( "Unhandled trigger [%s] sent by the client 0x%X\n", text.c_str(), trigWord ));
#endif
break;
}
@@ -600,7 +602,7 @@ void CTrainingResponse::Handle( CSocket *mSock, CChar *mChar )
{
if( nearbyNpc->GetBaseSkill( j ) > 10 )
{
- temp2 = oldstrutil::lower( cwmWorldState->skill[j].name );
+ temp2 = util::lower( cwmWorldState->skill[j].name );
if( !skillsToTrainIn )
{
temp2[0] = std::toupper( temp2[0] ); // If it's the first skill, capitalize it, and add a space in front.
@@ -644,7 +646,7 @@ void CTrainingResponse::Handle( CSocket *mSock, CChar *mChar )
}
if( nearbyNpc->GetBaseSkill( static_cast( skill )) > 10 )
{
- temp = oldstrutil::format( maxsize, Dictionary->GetEntry( 1304 ), oldstrutil::lower( cwmWorldState->skill[skill].name ).c_str() ); // Thou wishest to learn of %s?
+ temp = oldstrutil::format( maxsize, Dictionary->GetEntry( 1304 ), util::lower( cwmWorldState->skill[skill].name ).c_str() ); // Thou wishest to learn of %s?
if( mChar->GetBaseSkill( static_cast( skill )) >= 250 )
{
temp += Dictionary->GetEntry( 1305 ); // I can teach thee no more than thou already knowest!
@@ -750,7 +752,7 @@ bool CPetMultiResponse::Handle( CSocket *mSock, CChar *mChar, CChar *petNpc )
npcName = Dictionary->GetEntry( 3000 + petNpc->GetId() );
}
- if( FindString( ourText, oldstrutil::upper( npcName )))
+ if( FindString( ourText, util::upper( npcName )))
{
if( Npcs->CanControlPet( mChar, petNpc, isRestricted, checkDifficulty ))
{
@@ -779,7 +781,7 @@ CPetReleaseResponse::CPetReleaseResponse( const std::string &text ) : CBasePetRe
bool CPetReleaseResponse::Handle( CSocket *mSock, CChar *mChar, CChar *petNpc )
{
std::string npcName = GetNpcDictName( petNpc, mSock, NRS_SYSTEM );
- if( FindString( ourText, oldstrutil::upper( npcName )))
+ if( FindString( ourText, util::upper( npcName )))
{
if( Npcs->CanControlPet( mChar, petNpc, true, false ))
{
@@ -811,7 +813,7 @@ CPetGuardResponse::CPetGuardResponse( bool allVal, const std::string &text ) : C
bool CPetGuardResponse::Handle( CSocket *mSock, CChar *mChar, CChar *petNpc )
{
std::string npcName = GetNpcDictName( petNpc, mSock, NRS_SYSTEM );
- if( saidAll || FindString( ourText, oldstrutil::upper( npcName )))
+ if( saidAll || FindString( ourText, util::upper( npcName )))
{
if( Npcs->CanControlPet( mChar, petNpc, false, true ))
{
@@ -840,7 +842,7 @@ CPetAttackResponse::CPetAttackResponse( bool allVal, const std::string &text ) :
bool CPetAttackResponse::Handle( CSocket *mSock, CChar *mChar, CChar *petNpc )
{
std::string npcName = GetNpcDictName( petNpc, mSock, NRS_SYSTEM );
- if( saidAll || FindString( ourText, oldstrutil::upper( npcName )))
+ if( saidAll || FindString( ourText, util::upper( npcName )))
{
if( Npcs->CanControlPet( mChar, petNpc, false, true ))
{
@@ -869,7 +871,7 @@ CPetComeResponse::CPetComeResponse( bool allVal, const std::string &text ) : CPe
bool CPetComeResponse::Handle( CSocket *mSock, CChar *mChar, CChar *petNpc )
{
std::string npcName = GetNpcDictName( petNpc, mSock, NRS_SYSTEM );
- if( saidAll || FindString( ourText, oldstrutil::upper( npcName )))
+ if( saidAll || FindString( ourText, util::upper( npcName )))
{
if( Npcs->CanControlPet( mChar, petNpc, false, true ))
{
@@ -895,7 +897,7 @@ CPetStayResponse::CPetStayResponse( bool allVal, const std::string &text ) : CPe
bool CPetStayResponse::Handle( CSocket *mSock, CChar *mChar, CChar *petNpc )
{
std::string npcName = GetNpcDictName( petNpc, mSock, NRS_SYSTEM );
- if( saidAll || FindString( ourText, oldstrutil::upper( npcName )))
+ if( saidAll || FindString( ourText, util::upper( npcName )))
{
if( Npcs->CanControlPet( mChar, petNpc, false, true ))
{
@@ -940,7 +942,7 @@ void CBaseVendorResponse::Handle( CSocket *mSock, CChar *mChar )
continue;
std::string npcName = GetNpcDictName( nearbyNpc, mSock, NRS_SYSTEM );
- if( saidVendor || FindString( ourText, oldstrutil::upper( npcName )))
+ if( saidVendor || FindString( ourText, util::upper( npcName )))
{
if( !Handle( mSock, mChar, nearbyNpc ))
break;
diff --git a/source/Dictionary.cpp b/source/Dictionary.cpp
index 5b05310b8..ae4d19772 100644
--- a/source/Dictionary.cpp
+++ b/source/Dictionary.cpp
@@ -8,6 +8,7 @@
#include "scriptc.h"
#include "ssection.h"
#include "StringUtility.hpp"
+#include "utility/strutil.hpp"
#include
#include
@@ -169,8 +170,8 @@ auto CDictionary::ParseFile( const std::string &dictionaryfile ) -> bool
{
input_buffer[input.gcount()] = 0;
auto line = std::string( input_buffer );
- line = oldstrutil::removeTrailing( line, "//" );
- line = oldstrutil::trim( line );
+ line = util::strip( line, "//" );
+ line = util::trim( line );
if( !line.empty() )
{
switch( static_cast( state ))
@@ -180,8 +181,8 @@ auto CDictionary::ParseFile( const std::string &dictionaryfile ) -> bool
if(( line[0] == '[' ) && ( *( line.rbegin() ) == ']' ))
{
// it is a section header!
- line = oldstrutil::upper( oldstrutil::simplify( line.substr( 1, line.size() - 2 )));
- auto [key, value] = oldstrutil::split( line, " " );
+ line = util::upper( util::simplify( line.substr( 1, line.size() - 2 )));
+ auto [key, value] = util::split( line, " " );
if(( key == "DICTIONARY" ) && ( value == "CLIENTMSG" ))
{
// This is a good section start!
@@ -204,7 +205,7 @@ auto CDictionary::ParseFile( const std::string &dictionaryfile ) -> bool
{
if( line != "}" )
{
- auto [key, value] = oldstrutil::split( line, "=" );
+ auto [key, value] = util::split( line, "=" );
try
{
auto number = std::stoi( key, nullptr, 0 );
diff --git a/source/JSEncapsulate.cpp b/source/JSEncapsulate.cpp
index 1bf09313c..c0749a327 100644
--- a/source/JSEncapsulate.cpp
+++ b/source/JSEncapsulate.cpp
@@ -1,6 +1,8 @@
#include "JSEncapsulate.h"
#include
#include "StringUtility.hpp"
+#include "utility/strutil.hpp"
+
#include "jsobj.h"
#include "jsutil.h"
@@ -240,7 +242,7 @@ void JSEncapsulate::Parse( JSEncapsObjectType typeConvert )
case JSOT_BOOL: boolVal = ( JSVAL_TO_BOOLEAN(( *vp )) == JS_TRUE ); break;
case JSOT_STRING:
svalue = JS_GetStringBytes( JS_ValueToString( cx, *vp ));
- boolVal = ( oldstrutil::upper( svalue ) == "TRUE" );
+ boolVal = ( util::upper( svalue ) == "TRUE" );
break;
default:
case JSOT_COUNT:
@@ -252,11 +254,11 @@ void JSEncapsulate::Parse( JSEncapsObjectType typeConvert )
{
case JSOT_INT:
ivalue = JSVAL_TO_INT(( *vp ));
- stringVal = oldstrutil::number( ivalue );
+ stringVal = util::ntos( ivalue );
break;
case JSOT_DOUBLE:
JS_ValueToNumber( cx, ( *vp ), &fvalue );
- stringVal = oldstrutil::number( fvalue );
+ stringVal = std::to_string( fvalue );
break;
case JSOT_BOOL:
bvalue = ( JSVAL_TO_BOOLEAN(( *vp )) == JS_TRUE );
diff --git a/source/SEFunctions.cpp b/source/SEFunctions.cpp
index 384d1632f..0d308f725 100644
--- a/source/SEFunctions.cpp
+++ b/source/SEFunctions.cpp
@@ -35,7 +35,7 @@
#include "PartySystem.h"
#include "cSpawnRegion.h"
#include "CPacketSend.h"
-
+#include "utility/strutil.hpp"
void LoadTeleportLocations( void );
@@ -71,7 +71,7 @@ ObjectType FindObjTypeFromString( std::string strToFind )
{
InitStringToObjType();
}
- std::map::const_iterator toFind = stringToObjType.find( oldstrutil::upper( strToFind ));
+ std::map::const_iterator toFind = stringToObjType.find( util::upper( strToFind ));
if( toFind != stringToObjType.end() )
{
return toFind->second;
@@ -173,7 +173,7 @@ JSBool SE_BroadcastMessage( JSContext *cx, [[maybe_unused]] JSObject *obj, uintN
std::string trgMessage = JS_GetStringBytes( JS_ValueToString( cx, argv[0] ));
if( trgMessage.empty() || trgMessage.length() == 0 )
{
- ScriptError( cx, oldstrutil::format( "BroadcastMessage: Invalid string (%s)", trgMessage.c_str() ).c_str() );
+ ScriptError( cx, util::format( "BroadcastMessage: Invalid string (%s)", trgMessage.c_str() ).c_str() );
return JS_FALSE;
}
SysBroadcast( trgMessage );
@@ -196,7 +196,7 @@ JSBool SE_CalcItemFromSer( JSContext *cx, [[maybe_unused]] JSObject *obj, uintN
if( argc == 1 )
{
std::string str = JS_GetStringBytes( JS_ValueToString( cx, argv[0] ));
- targSerial = oldstrutil::value( str );
+ targSerial = util::ston( str );
}
else
{
@@ -491,7 +491,7 @@ JSBool SE_MakeItem( JSContext *cx, [[maybe_unused]] JSObject *obj, uintN argc, j
CreateEntry_st *toFind = Skills->FindItem( itemMenu );
if( toFind == nullptr )
{
- ScriptError( cx, oldstrutil::format( "MakeItem: Invalid make item (%i)", itemMenu ).c_str() );
+ ScriptError( cx, util::format( "MakeItem: Invalid make item (%i)", itemMenu ).c_str() );
return JS_FALSE;
}
UI16 resourceColour = 0;
@@ -690,7 +690,7 @@ JSBool SE_RegisterSkill( JSContext *cx, [[maybe_unused]] JSObject *obj, uintN ar
Console.MoveTo( 15 );
Console.Print( "Registering skill number " );
Console.TurnYellow();
- Console.Print( oldstrutil::format( "%i", skillNumber ));
+ Console.Print( util::format( "%i", skillNumber ));
if( !isEnabled )
{
Console.TurnRed();
@@ -737,7 +737,7 @@ JSBool SE_RegisterPacket( JSContext *cx, [[maybe_unused]] JSObject *obj, uintN a
if( scriptId != 0xFFFF )
{
#if defined( UOX_DEBUG_MODE )
- Console.Print( oldstrutil::format( "Registering packet number 0x%X, subcommand 0x%x\n", packet, subCmd ));
+ Console.Print( util::format( "Registering packet number 0x%X, subcommand 0x%x\n", packet, subCmd ));
#endif
Network->RegisterPacket( packet, subCmd, scriptId );
}
@@ -2267,7 +2267,7 @@ JSBool SE_NumToString( JSContext *cx, [[maybe_unused]] JSObject *obj, uintN argc
}
SI32 num = JSVAL_TO_INT( argv[0] );
- auto str = oldstrutil::number( num );
+ auto str = util::ntos( num );
*rval = STRING_TO_JSVAL( JS_NewStringCopyZ( cx, str.c_str() ));
return JS_TRUE;
}
@@ -2287,7 +2287,7 @@ JSBool SE_NumToHexString( JSContext *cx, [[maybe_unused]] JSObject *obj, uintN a
}
SI32 num = JSVAL_TO_INT( argv[0] );
- auto str = oldstrutil::number( num, 16 );
+ auto str = util::ntos( num, 16 );
*rval = STRING_TO_JSVAL( JS_NewStringCopyZ( cx, str.c_str() ));
return JS_TRUE;
@@ -2385,7 +2385,7 @@ JSBool SE_AreaCharacterFunction( JSContext *cx, [[maybe_unused]] JSObject *obj,
}
catch( const std::out_of_range &e )
{
- ScriptError( cx, oldstrutil::format( "Critical error encountered in AreaObjFunc!", e.what() ).c_str() );
+ ScriptError( cx, util::format( "Critical error encountered in AreaObjFunc!", e.what() ).c_str() );
}
*rval = INT_TO_JSVAL( retCounter );
@@ -2816,7 +2816,7 @@ JSBool SE_WorldBrightLevel( [[maybe_unused]] JSContext *cx, [[maybe_unused]] JSO
{
if( argc > 1 )
{
- ScriptError( cx, oldstrutil::format( "WorldBrightLevel: Unknown Count of Arguments: %d", argc ).c_str() );
+ ScriptError( cx, util::format( "WorldBrightLevel: Unknown Count of Arguments: %d", argc ).c_str() );
return JS_FALSE;
}
else if( argc == 1 )
@@ -2838,7 +2838,7 @@ JSBool SE_WorldDarkLevel( [[maybe_unused]] JSContext *cx, [[maybe_unused]] JSObj
{
if( argc > 1 )
{
- ScriptError( cx, oldstrutil::format( "WorldDarkLevel: Unknown Count of Arguments: %d", argc ).c_str() );
+ ScriptError( cx, util::format( "WorldDarkLevel: Unknown Count of Arguments: %d", argc ).c_str() );
return JS_FALSE;
}
else if( argc == 1 )
@@ -2860,7 +2860,7 @@ JSBool SE_WorldDungeonLevel( [[maybe_unused]] JSContext *cx, [[maybe_unused]] JS
{
if( argc > 1 )
{
- ScriptError( cx, oldstrutil::format( "WorldDungeonLevel: Unknown Count of Arguments: %d", argc ).c_str() );
+ ScriptError( cx, util::format( "WorldDungeonLevel: Unknown Count of Arguments: %d", argc ).c_str() );
return JS_FALSE;
}
else if( argc == 1 )
@@ -2881,7 +2881,7 @@ JSBool SE_GetSpawnRegionFacetStatus( [[maybe_unused]] JSContext *cx, [[maybe_unu
{
if( argc > 1 )
{
- ScriptError( cx, oldstrutil::format( "GetSpawnRegionFacetStatus: Unknown Count of Arguments: %d", argc ).c_str() );
+ ScriptError( cx, util::format( "GetSpawnRegionFacetStatus: Unknown Count of Arguments: %d", argc ).c_str() );
return JS_FALSE;
}
else if( argc == 1 )
@@ -2909,7 +2909,7 @@ JSBool SE_SetSpawnRegionFacetStatus( [[maybe_unused]] JSContext *cx, [[maybe_unu
{
if( argc > 2 )
{
- ScriptError( cx, oldstrutil::format( "SetSpawnRegionFacetStatus: Unknown Count of Arguments: %d", argc ).c_str() );
+ ScriptError( cx, util::format( "SetSpawnRegionFacetStatus: Unknown Count of Arguments: %d", argc ).c_str() );
return JS_FALSE;
}
else if( argc == 1 )
@@ -2975,7 +2975,7 @@ JSBool SE_ReloadJSFile( JSContext *cx, [[maybe_unused]] JSObject *obj, uintN arg
UI16 scriptId = static_cast( JSVAL_TO_INT( argv[0] ));
if( scriptId == JSMapping->GetScriptId( JS_GetGlobalObject( cx )))
{
- ScriptError( cx, oldstrutil::format( "ReloadJSFile: JS Script attempted to reload itself, crash avoided (ScriptID %u)", scriptId ).c_str() );
+ ScriptError( cx, util::format( "ReloadJSFile: JS Script attempted to reload itself, crash avoided (ScriptID %u)", scriptId ).c_str() );
return JS_FALSE;
}
@@ -2994,12 +2994,12 @@ JSBool SE_ResourceArea( JSContext *cx, [[maybe_unused]] JSObject *obj, uintN arg
{
if( argc != 0 )
{
- ScriptError( cx, oldstrutil::format( "ResourceArea: Invalid Count of Arguments: %d", argc ).c_str() );
+ ScriptError( cx, util::format( "ResourceArea: Invalid Count of Arguments: %d", argc ).c_str() );
return JS_FALSE;
}
auto resType = std::string( JS_GetStringBytes( JS_ValueToString( cx, argv[0] )));
- resType = oldstrutil::upper( oldstrutil::trim( oldstrutil::removeTrailing( resType, "//" )));
+ resType = util::upper( util::trim( util::strip( resType, "//" )));
*rval = INT_TO_JSVAL( cwmWorldState->ServerData()->ResourceAreaSize() );
@@ -3016,11 +3016,11 @@ JSBool SE_ResourceAmount( JSContext *cx, [[maybe_unused]] JSObject *obj, uintN a
{
if( argc > 2 || argc == 0 )
{
- ScriptError( cx, oldstrutil::format( "ResourceAmount: Invalid Count of Arguments: %d", argc ).c_str() );
+ ScriptError( cx, util::format( "ResourceAmount: Invalid Count of Arguments: %d", argc ).c_str() );
return JS_FALSE;
}
auto resType = std::string( JS_GetStringBytes( JS_ValueToString( cx, argv[0] )));
- resType = oldstrutil::upper( oldstrutil::trim( oldstrutil::removeTrailing( resType, "//" )));
+ resType = util::upper( util::trim( util::strip( resType, "//" )));
if( argc == 2 )
{
@@ -3065,12 +3065,12 @@ JSBool SE_ResourceTime( JSContext *cx, [[maybe_unused]] JSObject *obj, uintN arg
{
if( argc > 2 || argc == 0 )
{
- ScriptError( cx, oldstrutil::format( "ResourceTime: Invalid Count of Arguments: %d", argc ).c_str() );
+ ScriptError( cx, util::format( "ResourceTime: Invalid Count of Arguments: %d", argc ).c_str() );
return JS_FALSE;
}
auto resType = std::string( JS_GetStringBytes( JS_ValueToString( cx, argv[0] )));
- resType = oldstrutil::upper( oldstrutil::trim( oldstrutil::removeTrailing( resType, "//" )));
+ resType = util::upper( util::trim( util::strip( resType, "//" )));
if( argc == 2 )
{
UI16 newVal = static_cast( JSVAL_TO_INT( argv[1] ));
@@ -3408,7 +3408,7 @@ JSBool SE_Moon( [[maybe_unused]] JSContext *cx, [[maybe_unused]] JSObject *obj,
{
if( argc > 2 || argc == 0 )
{
- ScriptError( cx, oldstrutil::format( "Moon: Invalid Count of Arguments: %d", argc ).c_str() );
+ ScriptError( cx, util::format( "Moon: Invalid Count of Arguments: %d", argc ).c_str() );
return JS_FALSE;
}
@@ -3862,7 +3862,7 @@ JSBool SE_EraStringToNum( JSContext *cx, [[maybe_unused]] JSObject *obj, uintN a
return JS_FALSE;
}
- std::string eraString = oldstrutil::upper( JS_GetStringBytes( JS_ValueToString( cx, argv[0] )));
+ std::string eraString = util::upper( JS_GetStringBytes( JS_ValueToString( cx, argv[0] )));
if( !eraString.empty() )
{
UI08 eraNum = static_cast( cwmWorldState->ServerData()->EraStringToEnum( eraString, false, false ));
@@ -3900,7 +3900,7 @@ JSBool SE_GetServerSetting( JSContext *cx, [[maybe_unused]] JSObject *obj, uintN
}
JSString *tString;
- std::string settingName = oldstrutil::upper( JS_GetStringBytes( JS_ValueToString( cx, argv[0] )));
+ std::string settingName = util::upper( JS_GetStringBytes( JS_ValueToString( cx, argv[0] )));
if( !settingName.empty() )
{
auto settingId = cwmWorldState->ServerData()->LookupINIValue( settingName );
diff --git a/source/StringUtility.cpp b/source/StringUtility.cpp
index 6adb6c46c..135d9ccf2 100644
--- a/source/StringUtility.cpp
+++ b/source/StringUtility.cpp
@@ -14,152 +14,13 @@
#include
#include
#include
+#include "utility/strutil.hpp"
using namespace std::string_literals;
namespace oldstrutil
{
- //=====================================================================
- // Lowercase the string
- std::string lower( const std::string &value )
- {
- auto rValue = value;
- std::transform( rValue.begin(), rValue.end(), rValue.begin(),
- []( unsigned char c ){ return std::tolower( c ); } );
- return rValue;
- }
- //=====================================================================
- // Uppercase the string
- std::string upper( const std::string &value )
- {
- auto rValue = value;
- std::transform( rValue.begin(), rValue.end(), rValue.begin(),
- []( unsigned char c ){ return std::toupper( c ); } );
- return rValue;
- }
- //=====================================================================
- // Remove leading whitespace
- std::string ltrim( const std::string &value )
- {
- auto count = 0;
- for( auto it = value.begin(); it != value.end(); it++ )
- {
- if( !isspace( *it ))
- {
- return value.substr( count );
- }
- else
- {
- count++;
- }
- }
-
- return std::string();
- }
-
- //=====================================================================
- // Remove trailing whitespace
- std::string rtrim( const std::string &value )
- {
- auto count = 0;
- for( auto it = value.rbegin(); it != value.rend(); it++ )
- {
- if( !isspace( *it ))
- {
- return value.substr( 0, value.size() - count );
- }
- else
- {
- count++;
- }
- }
-
- return std::string();
- }
-
- //=====================================================================
- // Remove leading/trailing whitespace
- std::string trim( const std::string &value )
- {
- return rtrim( ltrim( value ));
- }
-
- //=====================================================================
- // Remove leading/trailing whitepace, and reduce all other whitespace to one " "
- std::string simplify( const std::string &value )
- {
- auto tvalue = trim( value );
- auto rValue = ""s;
- auto toggle = false;
- for( auto &c : tvalue )
- {
- if( isspace( c ))
- {
- if( !toggle )
- {
- rValue = rValue + c;
- toggle = true;
- }
- }
- else
- {
- toggle = false;
- rValue = rValue + c;
- }
- }
- return rValue;
- }
-
- //=====================================================================
- // Removing everything after a delimiter. Normally "//" for comments
- std::string removeTrailing( const std::string& value, const std::string& delim )
- {
- auto loc = value.find( delim );
- if( loc == std::string::npos )
- {
- return value;
- }
- return value.substr( 0, loc );
- }
-
- //=====================================================================
- // Return the values between two delimitors.
- std::string contents( const std::string &value, const std::string& startdelim, const std::string &enddelim, std::string::size_type location )
- {
- auto loc = value.find_first_of( startdelim, location );
- if( loc == std::string::npos )
- {
- return std::string();
- }
- auto start_search = loc + startdelim.size();
- if( start_search >= value.size() )
- {
- return std::string();
- }
- auto end = value.find_first_of( enddelim, start_search );
- if( end == std::string::npos )
- {
- return std::string();
- }
- return value.substr( start_search, end - start_search );
- }
-
- //=====================================================================
- // Split a string based on a separator
- std::tuple split( const std::string &value, const std::string &sep )
- {
- auto loc = value.find( sep );
- auto next = loc + sep.size();
- if(( loc == std::string::npos ) || ( next >= value.size() ))
- {
- return std::make_tuple( trim( value ), ""s );
- }
- else
- {
- return std::make_tuple( trim( value.substr( 0, loc )), trim( value.substr( next )));
- }
- }
//+++++++++++++++++++++++++++++++++++++
std::string format( std::size_t maxsize, const std::string fmtstring, ... )
@@ -192,13 +53,6 @@ namespace oldstrutil
return temp;
}
- //+++++++++++++++++++++++++++++++++++++
- std::string format( const std::string fmtstring, ... )
- {
- std::va_list argptr;
- va_start( argptr, fmtstring );
- return oldstrutil::format( fmtstring, argptr );
- }
//++++++++++++++++++++++++++++++++++++++
std::string format( const std::string fmtstring, va_list& list )
@@ -277,7 +131,7 @@ namespace oldstrutil
{
return sec[sectionindex];
}
- throw std::runtime_error( oldstrutil::format( "Section index %ul exceeded size %ul from sections %s", sectionindex, sec.size(), value.c_str() ));
+ throw std::runtime_error( util::format( "Section index %ul exceeded size %ul from sections %s", sectionindex, sec.size(), value.c_str() ));
}
//+++++++++++++++++++++++++++++++++++++++++
@@ -361,7 +215,7 @@ namespace oldstrutil
{
std::string value = "\\";
std::string::size_type index = 0;
- auto data = trim( base );
+ auto data = util::trim( base );
while(( index = data.find( value, index )) != std::string::npos )
{
data = data.replace( index, 1, "/" );
@@ -387,52 +241,6 @@ namespace oldstrutil
return data;
}
- std::string number( char n, int base )
- {
- std::stringstream conversion;
- auto value = static_cast( n );
-
- switch( base )
- {
- case 10:
- conversion << std::dec << value;
- break;
- case 16:
- conversion << std::hex << value << std::dec;
- break;
- case 8:
- conversion << std::oct << value << std::dec;
- break;
- default:
- conversion << std::dec << value;
- break;
- }
-
- return conversion.str();
- }
- std::string number( unsigned char n, int base )
- {
- std::stringstream conversion;
- auto value = static_cast( n );
-
- switch( base )
- {
- case 10:
- conversion << std::dec << value;
- break;
- case 16:
- conversion << std::hex << value << std::dec;
- break;
- case 8:
- conversion << std::oct << value << std::dec;
- break;
- default:
- conversion << std::dec << value;
- break;
- }
-
- return conversion.str();
- }
#if defined( _MSC_VER )
#pragma warning(push)
diff --git a/source/StringUtility.hpp b/source/StringUtility.hpp
index 2be725277..bedec005e 100644
--- a/source/StringUtility.hpp
+++ b/source/StringUtility.hpp
@@ -17,34 +17,9 @@
namespace oldstrutil
{
- // Uppercase the string
- std::string lower( const std::string &value );
- // Lowercase the string
- std::string upper( const std::string &value );
-
- // Remove leading whitespace
- std::string ltrim( const std::string &value );
- // Remove trailing whitespace
- std::string rtrim( const std::string &value );
- // Remove leading/trailing whitespace
- std::string trim( const std::string &value );
- // Remove leading/trailing whitepace, and reduce all other whitespace to one " "
- std::string simplify( const std::string &value );
-
- // Removing everything after a delimiter. Normally "//" for comments
- std::string removeTrailing( const std::string& value, const std::string& delim = "//" );
-
- // Return the values between two delimitors.
- std::string contents( const std::string &value, const std::string& startdelim, const std::string &enddelim, std::string::size_type location = 0 );
-
- // Split a string based on a separator
- std::tuple split( const std::string &value, const std::string &sep );
-
-
std::string format( std::size_t maxsize, const std::string fmtstring, ... );
std::string format( std::size_t maxsize, const std::string fmtstring, va_list &list );
- std::string format( const std::string fmtstring, ... );
std::string format( const std::string fmtstring, va_list &list );
std::string formatMessage( const std::string& uformat, const std::string& data );
@@ -77,9 +52,6 @@ namespace oldstrutil
std::string extractSection( const std::string& value, const std::string& sep, std::string::size_type start, std::string::size_type stop = std::string::npos );
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- // Convert a number to a string
- std::string number( char n, int base = 10 );
- std::string number( unsigned char n, int base = 10 );
// Convert a string to wstring (for UTF8 characters)
std::wstring stringToWstring( const std::string& t_str );
@@ -93,69 +65,7 @@ namespace oldstrutil
// Tackles converting text loaded from dictionary into japanese
std::wstring FromUTF8( const char* str );
- template
- std::string number( T n, int base = 10 )
- {
- std::stringstream conversion;
- if( std::is_integral::value )
- {
- switch( base )
- {
- case 10:
- conversion << std::dec << n;
- break;
- case 16:
- conversion << std::hex << n << std::dec;
- break;
- case 8:
- conversion << std::oct << n << std::dec;
- break;
- default:
- conversion << std::dec << n;
- break;
- }
- }
- else if( std::is_floating_point::value )
- {
- conversion << n;
- }
-
- return conversion.str();
- }
- //++++++++++++++++++++++++++++++++++++++++++++++
- // Convert a string to a value (integer, number)
- //
- template
- T value( const std::string& input, int base = 0 )
- {
- if( std::is_floating_point::value )
- {
- double value = 0.0;
- try
- {
- value = std::stod( input );
- }
- catch(...)
- {
- // ok, it couldn't convert it, leave it a 0.0
- }
- return static_cast( value );
- }
- else
- {
- long long value = 0.0;
- try
- {
- value = std::stoll( input, 0, base );
- }
- catch(...)
- {
- // ok, it couldn't convert, keave it a 0
- }
- return static_cast( value );
- }
- }
}
diff --git a/source/UOXJSMethods.cpp b/source/UOXJSMethods.cpp
index a7dc81496..15c6a779b 100644
--- a/source/UOXJSMethods.cpp
+++ b/source/UOXJSMethods.cpp
@@ -48,6 +48,7 @@
#include "combat.h"
#include "PartySystem.h"
#include "osunique.hpp"
+#include "utility/strutil.hpp"
void BuildAddMenuGump( CSocket *s, UI16 m ); // Menus for item creation
void SpawnGate( CChar *caster, SI16 srcX, SI16 srcY, SI08 srcZ, UI08 srcWorld, SI16 trgX, SI16 trgY, SI08 trgZ, UI08 trgWorld, UI16 trgInstanceId = 0 );
@@ -278,7 +279,7 @@ JSBool CPacket_WriteLong( JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
size_t position = static_cast( JSVAL_TO_INT( argv[0] ));
//UI32 toWrite = static_cast( JSVAL_TO_INT( argv[1] ));
char * toWriteChar = JS_GetStringBytes( JS_ValueToString( cx, argv[1] ));
- UI32 toWrite = oldstrutil::value( toWriteChar );
+ UI32 toWrite = util::ston( toWriteChar );
myPacket->GetPacketStream().WriteLong( position, toWrite );
@@ -596,7 +597,7 @@ JSBool CGump_AddCheckbox( JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
return JS_FALSE;
}
- gList->one->push_back( oldstrutil::format( "checkbox %i %i %i %i %i %i", tL, tR, gImage, gImageChk, initState, relay ));
+ gList->one->push_back( util::format( "checkbox %i %i %i %i %i %i", tL, tR, gImage, gImageChk, initState, relay ));
return JS_TRUE;
}
@@ -741,7 +742,7 @@ JSBool CGump_MasterGump( JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
}
// Also send mastergump command with new gumpId
- gList->one->push_back( oldstrutil::format( "mastergump %i %i %i %i %i", masterGumpId ));
+ gList->one->push_back( util::format( "mastergump %i %i %i %i %i", masterGumpId ));
return JS_TRUE;
}
@@ -773,7 +774,7 @@ JSBool CGump_AddBackground( JSContext *cx, JSObject *obj, uintN argc, jsval *arg
return JS_FALSE;
}
- gList->one->push_back( oldstrutil::format( "resizepic %i %i %i %i %i", tL, tR, gImage, bL, bR ));
+ gList->one->push_back( util::format( "resizepic %i %i %i %i %i", tL, tR, gImage, bL, bR ));
return JS_TRUE;
}
@@ -806,7 +807,7 @@ JSBool CGump_AddButton( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [
return JS_FALSE;
}
- gList->one->push_back( oldstrutil::format( "button %i %i %i %i %i %i %i", tL, tR, gImage, gImage2, x1, x2, x3 ));
+ gList->one->push_back( util::format( "button %i %i %i %i %i %i %i", tL, tR, gImage, gImage2, x1, x2, x3 ));
return JS_TRUE;
}
@@ -845,7 +846,7 @@ JSBool CGump_AddButtonTileArt( JSContext *cx, JSObject *obj, uintN argc, jsval *
return JS_FALSE;
}
- gList->one->push_back( oldstrutil::format( "buttontileart %i %i %i %i %i %i %i %i %i %i %i", tL, tR, tileIdNorm, tileIdPush, buttonType, pageNum, buttonId, tileId, hue, tileX, tileY ));
+ gList->one->push_back( util::format( "buttontileart %i %i %i %i %i %i %i %i %i %i %i", tL, tR, tileIdNorm, tileIdPush, buttonType, pageNum, buttonId, tileId, hue, tileX, tileY ));
return JS_TRUE;
}
@@ -876,7 +877,7 @@ JSBool CGump_AddPageButton( JSContext *cx, JSObject *obj, uintN argc, jsval *arg
return JS_FALSE;
}
- gList->one->push_back( oldstrutil::format( "button %i %i %i %i 0 %i", tL, tR, gImage, gImage2, pageNum ));
+ gList->one->push_back( util::format( "button %i %i %i %i 0 %i", tL, tR, gImage, gImage2, pageNum ));
return JS_TRUE;
}
@@ -908,7 +909,7 @@ JSBool CGump_AddCheckerTrans( JSContext *cx, JSObject *obj, uintN argc, jsval *a
return JS_FALSE;
}
- gList->one->push_back( oldstrutil::format( "checkertrans %i %i %i %i", x, y, width, height ));
+ gList->one->push_back( util::format( "checkertrans %i %i %i %i", x, y, width, height ));
return JS_TRUE;
}
@@ -952,7 +953,7 @@ JSBool CGump_AddCroppedText( JSContext *cx, JSObject *obj, uintN argc, jsval *ar
UI32 textId = gList->textId;
++gList->textId;
- gList->one->push_back( oldstrutil::format( "croppedtext %i %i %i %i %i %u", TextX, TextY, TextWidth, TextHeight, TextHue, textId ));
+ gList->one->push_back( util::format( "croppedtext %i %i %i %i %i %u", TextX, TextY, TextWidth, TextHeight, TextHue, textId ));
gList->two->push_back( TextString );
return JS_TRUE;
@@ -980,7 +981,7 @@ JSBool CGump_AddGroup( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [[
return JS_FALSE;
}
- gList->one->push_back( oldstrutil::format( "group %d", JSVAL_TO_INT( argv[0] )));
+ gList->one->push_back( util::format( "group %d", JSVAL_TO_INT( argv[0] )));
return JS_TRUE;
}
@@ -1006,7 +1007,7 @@ JSBool CGump_EndGroup( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [[
return JS_FALSE;
}
- gList->one->push_back( oldstrutil::format( "endgroup", JSVAL_TO_INT( argv[0] )));
+ gList->one->push_back( util::format( "endgroup", JSVAL_TO_INT( argv[0] )));
return JS_TRUE;
}
@@ -1043,11 +1044,11 @@ JSBool CGump_AddGump( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [[m
if( rgbColor == 0 )
{
- gList->one->push_back( oldstrutil::format( "gumppic %i %i %i", tL, tR, gImage ));
+ gList->one->push_back( util::format( "gumppic %i %i %i", tL, tR, gImage ));
}
else
{
- gList->one->push_back( oldstrutil::format( "gumppic %i %i %i hue=%i", tL, tR, gImage, rgbColor ));
+ gList->one->push_back( util::format( "gumppic %i %i %i hue=%i", tL, tR, gImage, rgbColor ));
}
return JS_TRUE;
@@ -1079,7 +1080,7 @@ JSBool CGump_AddGumpColor( JSContext *cx, JSObject *obj, uintN argc, jsval *argv
return JS_FALSE;
}
- gList->one->push_back( oldstrutil::format( "gumppic %i %i %i hue=%i", tL, tR, gImage, rgbColour ));
+ gList->one->push_back( util::format( "gumppic %i %i %i hue=%i", tL, tR, gImage, rgbColour ));
return JS_TRUE;
}
@@ -1182,7 +1183,7 @@ JSBool CGump_AddHTMLGump( JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
SI32 iBrd = ( hasBorder ? 1 : 0 );
SI32 iScrl = ( hasScrollbar ? 1 : 0 );
- gList->one->push_back( oldstrutil::format( "htmlgump %i %i %i %i %u %i %i", x, y, width, height, textId, iBrd, iScrl ));
+ gList->one->push_back( util::format( "htmlgump %i %i %i %i %u %i %i", x, y, width, height, textId, iBrd, iScrl ));
gList->two->push_back( TextString );
return JS_TRUE;
@@ -1209,7 +1210,7 @@ JSBool CGump_AddPage( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [[m
return JS_FALSE;
}
- gList->one->push_back( oldstrutil::format( "page %d", JSVAL_TO_INT( argv[0] )));
+ gList->one->push_back( util::format( "page %d", JSVAL_TO_INT( argv[0] )));
return JS_TRUE;
}
@@ -1239,7 +1240,7 @@ JSBool CGump_AddPicture( JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
return JS_FALSE;
}
- gList->one->push_back( oldstrutil::format( "tilepic %i %i %i", tL, tR, gImage ));
+ gList->one->push_back( util::format( "tilepic %i %i %i", tL, tR, gImage ));
return JS_TRUE;
}
@@ -1270,7 +1271,7 @@ JSBool CGump_AddPictureColor( JSContext *cx, JSObject *obj, uintN argc, jsval *a
return JS_FALSE;
}
- gList->one->push_back( oldstrutil::format( "tilepichue %i %i %i %i", tL, tR, gImage, rgbColour ));
+ gList->one->push_back( util::format( "tilepichue %i %i %i %i", tL, tR, gImage, rgbColour ));
return JS_TRUE;
}
@@ -1305,7 +1306,7 @@ JSBool CGump_AddPicInPic( JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
return JS_FALSE;
}
- gList->one->push_back( oldstrutil::format( "picinpic %i %i %i %i %i %i %i", x, y, gImage, spriteX, spriteY, width, height ));
+ gList->one->push_back( util::format( "picinpic %i %i %i %i %i %i %i", x, y, gImage, spriteX, spriteY, width, height ));
return JS_TRUE;
}
@@ -1346,7 +1347,7 @@ JSBool CGump_AddItemProperty( JSContext *cx, JSObject *obj, uintN argc, jsval *a
return JS_FALSE;
}
- gList->one->push_back( oldstrutil::format( "itemproperty %i", trgSer ));
+ gList->one->push_back( util::format( "itemproperty %i", trgSer ));
return JS_TRUE;
}
@@ -1399,7 +1400,7 @@ JSBool CGump_AddRadio( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [[
return JS_FALSE;
}
- gList->one->push_back( oldstrutil::format( "radio %i %i %i %i %i %i", tL, tR, gImage, gImageChk, initialState, relay ));
+ gList->one->push_back( util::format( "radio %i %i %i %i %i %i", tL, tR, gImage, gImageChk, initialState, relay ));
return JS_TRUE;
}
@@ -1442,7 +1443,7 @@ JSBool CGump_AddText( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [[m
textId = gList->textId;
++gList->textId;
- gList->one->push_back( oldstrutil::format( "text %i %i %i %u", TextX, TextY, TextHue, textId ));
+ gList->one->push_back( util::format( "text %i %i %i %u", TextX, TextY, TextHue, textId ));
gList->two->push_back( TextString );
return JS_TRUE;
@@ -1484,7 +1485,7 @@ JSBool CGump_AddTextEntry( JSContext *cx, JSObject *obj, uintN argc, jsval *argv
return JS_FALSE;
}
- gList->one->push_back( oldstrutil::format( "textentry %i %i %i %i %i %i %i", tL, tR, width, height, hue, relay, initialTextIndex ));
+ gList->one->push_back( util::format( "textentry %i %i %i %i %i %i %i", tL, tR, width, height, hue, relay, initialTextIndex ));
gList->two->push_back( test );
return JS_TRUE;
@@ -1527,7 +1528,7 @@ JSBool CGump_AddTextEntryLimited( JSContext *cx, JSObject *obj, uintN argc, jsva
return JS_FALSE;
}
- gList->one->push_back( oldstrutil::format( "textentrylimited %i %i %i %i %i %i %i %i", tL, tR, width, height, hue, relay, initialTextIndex, textEntrySize ));
+ gList->one->push_back( util::format( "textentrylimited %i %i %i %i %i %i %i %i", tL, tR, width, height, hue, relay, initialTextIndex, textEntrySize ));
gList->two->push_back( test );
return JS_TRUE;
@@ -1561,7 +1562,7 @@ JSBool CGump_AddTiledGump( JSContext *cx, JSObject *obj, uintN argc, jsval *argv
return JS_FALSE;
}
- gList->one->push_back( oldstrutil::format( "gumppictiled %i %i %i %i %i", x, y, width, height, gumpId ));
+ gList->one->push_back( util::format( "gumppictiled %i %i %i %i %i", x, y, width, height, gumpId ));
return JS_TRUE;
}
@@ -1599,7 +1600,7 @@ JSBool CGump_AddXMFHTMLGump( JSContext *cx, JSObject *obj, uintN argc, jsval *ar
SI32 iBrd = ( hasBorder ? 1 : 0 );
SI32 iScrl = ( hasScrollbar ? 1 : 0 );
- gList->one->push_back( oldstrutil::format( "xmfhtmlgump %i %i %i %i %i %i %i", x, y, width, height, number, iBrd, iScrl ));
+ gList->one->push_back( util::format( "xmfhtmlgump %i %i %i %i %i %i %i", x, y, width, height, number, iBrd, iScrl ));
return JS_TRUE;
}
@@ -1638,7 +1639,7 @@ JSBool CGump_AddXMFHTMLGumpColor( JSContext *cx, JSObject *obj, uintN argc, jsva
SI32 iBrd = ( hasBorder ? 1 : 0 );
SI32 iScrl = ( hasScrollbar ? 1 : 0 );
- gList->one->push_back( oldstrutil::format( "xmfhtmlgumpcolor %i %i %i %i %i %i %i %i", x, y, width, height, number, iBrd, iScrl, rgbColour ));
+ gList->one->push_back( util::format( "xmfhtmlgumpcolor %i %i %i %i %i %i %i %i", x, y, width, height, number, iBrd, iScrl, rgbColour ));
return JS_TRUE;
}
@@ -1680,7 +1681,7 @@ JSBool CGump_AddXMFHTMLTok( JSContext *cx, JSObject *obj, uintN argc, jsval *arg
SI32 iBrd = ( hasBorder ? 1 : 0 );
SI32 iScrl = ( hasScrollbar ? 1 : 0 );
- gList->one->push_back( oldstrutil::format( "xmfhtmltok %i %i %i %i %i %i %i %i @%s\t%s\t%s@", x, y, width, height, iBrd, iScrl, rgbColour, number, TextString1, TextString2, TextString3 ));
+ gList->one->push_back( util::format( "xmfhtmltok %i %i %i %i %i %i %i %i @%s\t%s\t%s@", x, y, width, height, iBrd, iScrl, rgbColour, number, TextString1, TextString2, TextString3 ));
return JS_TRUE;
}
@@ -1885,7 +1886,7 @@ JSBool CBase_TextMessage( JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Char/Item JS Method .TextMessage(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Char/Item JS Method .TextMessage(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -2136,7 +2137,7 @@ JSBool CBase_Delete( JSContext *cx, JSObject *obj, [[maybe_unused]] uintN argc,
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Char/Item JS Method .Delete(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Char/Item JS Method .Delete(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -2494,7 +2495,7 @@ JSBool CSocket_Disconnect( JSContext *cx, JSObject *obj, uintN argc, [[maybe_unu
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Socket JS Method .Disconnect(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Socket JS Method .Disconnect(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
return JS_TRUE;
@@ -2704,7 +2705,7 @@ JSBool CBase_Teleport( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [[
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Char/Item JS Method .Teleport(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Char/Item JS Method .Teleport(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -2914,7 +2915,7 @@ JSBool CMisc_SellTo( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Char/Socket JS Method .SellTo(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Char/Socket JS Method .SellTo(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -2998,7 +2999,7 @@ JSBool CMisc_BuyFrom( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [[m
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Char/Socket JS Method .BuyFrom(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Char/Socket JS Method .BuyFrom(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -3127,7 +3128,7 @@ JSBool CMisc_RemoveSpell( JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Char/Item JS Method .RemoveSpell(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Char/Item JS Method .RemoveSpell(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -3658,7 +3659,7 @@ JSBool CChar_OpenBank( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [[
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Char JS Method .OpenBank(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Char JS Method .OpenBank(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -3703,7 +3704,7 @@ JSBool CSocket_OpenContainer( JSContext *cx, JSObject *obj, uintN argc, jsval *a
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Socket JS Method .OpenContainer(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Socket JS Method .OpenContainer(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
}
@@ -3751,7 +3752,7 @@ JSBool CChar_OpenLayer( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Char JS Method .OpenLayer(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Char JS Method .OpenLayer(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
}
@@ -3843,7 +3844,7 @@ JSBool CChar_TurnToward( JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Character JS Method .TurnToward(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Character JS Method .TurnToward(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -4934,7 +4935,7 @@ JSBool CItem_SetCont( JSContext *cx, JSObject *obj, [[maybe_unused]] uintN argc,
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Item JS Method .SetCont(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Item JS Method .SetCont(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -5661,7 +5662,7 @@ JSBool CItem_PlaceInPack( JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Item JS Method .PlaceInPack(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Item JS Method .PlaceInPack(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -6149,7 +6150,7 @@ JSBool CChar_YellMessage( JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Char JS Method .YellMessage(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Char JS Method .YellMessage(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -6211,7 +6212,7 @@ JSBool CChar_WhisperMessage( JSContext *cx, JSObject *obj, uintN argc, jsval *ar
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Char JS Method .WhisperMessage(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Char JS Method .WhisperMessage(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -6485,7 +6486,7 @@ JSBool CChar_AddSpell( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [[
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Char JS Method .AddSpell(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Char JS Method .AddSpell(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
}
@@ -6579,7 +6580,7 @@ JSBool CBase_Refresh( JSContext *cx, JSObject *obj, uintN argc, [[maybe_unused]]
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Char/Item JS Method .Refresh(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Char/Item JS Method .Refresh(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -6847,7 +6848,7 @@ JSBool CFile_Open( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [[mayb
useScriptDataDir = ( JSVAL_TO_BOOLEAN( argv[3] ) == JS_TRUE );
}
- if( oldstrutil::lower( mode ).find_first_of( "rwa", 0, 3 ) == std::string::npos )
+ if( util::lower( mode ).find_first_of( "rwa", 0, 3 ) == std::string::npos )
{
ScriptError( cx, "Open: Invalid mode must be \"read\", \"write\", or \"append\"!" );
return JS_FALSE;
@@ -6891,7 +6892,7 @@ JSBool CFile_Open( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [[mayb
filePath.append( fileName );
FILE* stream;
- mFile->mWrap = mfopen( &stream, filePath.c_str(), oldstrutil::lower( mode ).substr( 0, 1 ).c_str() );
+ mFile->mWrap = mfopen( &stream, filePath.c_str(), util::lower( mode ).substr( 0, 1 ).c_str() );
return JS_TRUE;
}
@@ -7343,7 +7344,7 @@ JSBool CChar_WalkTo( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [[ma
cMove->FlushPath();
#if defined( UOX_DEBUG_MODE )
- Console.Print( oldstrutil::format( "WalkTo: Moving character 0x%X to (%i,%i) with a maximum of %i steps\n", cMove->GetSerial(), gx, gy, maxSteps ));
+ Console.Print( util::format( "WalkTo: Moving character 0x%X to (%i,%i) with a maximum of %i steps\n", cMove->GetSerial(), gx, gy, maxSteps ));
#endif
if( cMove->GetNpcWander() != WT_PATHFIND )
{
@@ -7368,7 +7369,7 @@ JSBool CChar_WalkTo( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [[ma
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Char JS Method .WalkTo(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Char JS Method .WalkTo(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
return JS_TRUE;
@@ -7456,7 +7457,7 @@ JSBool CChar_RunTo( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [[may
cMove->FlushPath();
#if defined( UOX_DEBUG_MODE )
- Console.Print( oldstrutil::format( "RunTo: Moving character %i to (%i,%i) with a maximum of %i steps", cMove->GetSerial(), gx, gy, maxSteps ));
+ Console.Print( util::format( "RunTo: Moving character %i to (%i,%i) with a maximum of %i steps", cMove->GetSerial(), gx, gy, maxSteps ));
#endif
if( cMove->GetNpcWander() != WT_PATHFIND )
{
@@ -7482,7 +7483,7 @@ JSBool CChar_RunTo( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [[may
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Char JS Method .RunTo(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Char JS Method .RunTo(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -7671,7 +7672,7 @@ JSBool CItem_Glow( JSContext *cx, JSObject *obj, [[maybe_unused]] uintN argc, js
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Item JS Method .Glow(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Item JS Method .Glow(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -7735,7 +7736,7 @@ JSBool CItem_UnGlow( JSContext *cx, JSObject *obj, [[maybe_unused]] uintN argc,
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Item JS Method .UnGlow(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Item JS Method .UnGlow(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -7884,7 +7885,7 @@ JSBool CChar_Recall( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [[ma
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Character JS Method .Recall(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Character JS Method .Recall(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -7929,7 +7930,7 @@ JSBool CChar_Mark( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [[mayb
if( mChar->GetRegion()->GetName()[0] != 0 )
{
- mItem->SetName( oldstrutil::format( Dictionary->GetEntry( 684 ), mChar->GetRegion()->GetName().c_str() ));
+ mItem->SetName( util::format( Dictionary->GetEntry( 684 ), mChar->GetRegion()->GetName().c_str() ));
}
else
{
@@ -8060,7 +8061,7 @@ JSBool CChar_Kill( JSContext *cx, JSObject *obj, uintN argc, [[maybe_unused]] js
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Character JS Method .Kill(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Character JS Method .Kill(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -8101,7 +8102,7 @@ JSBool CChar_Resurrect( JSContext *cx, JSObject *obj, uintN argc, [[maybe_unused
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Character JS Method .Resurrect(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Character JS Method .Resurrect(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -8712,7 +8713,7 @@ JSBool CConsole_Reload( JSContext *cx, [[maybe_unused]] JSObject *obj, uintN arg
ScriptError( cx, "Reload: Section to reload must be between 0 and 8" );
return JS_FALSE;
}
- messageLoop.NewMessage( MSG_RELOAD, oldstrutil::number( mArg ).c_str() );
+ messageLoop.NewMessage( MSG_RELOAD, util::ntos( mArg ).c_str() );
return JS_TRUE;
}
@@ -8947,7 +8948,7 @@ JSBool CItem_Carve( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [[may
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Item JS Method .Carve(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Item JS Method .Carve(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -9868,7 +9869,7 @@ JSBool CChar_Damage( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [[ma
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Character JS Method .Damage(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Character JS Method .Damage(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -9917,7 +9918,7 @@ JSBool CChar_InitiateCombat( JSContext *cx, JSObject *obj, uintN argc, jsval *ar
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Character JS Method .InitiateCombat(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Character JS Method .InitiateCombat(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -9959,7 +9960,7 @@ JSBool CChar_InvalidateAttacker( JSContext *cx, JSObject *obj, uintN argc, [[may
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Character JS Method .InvalidateAttacker(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Character JS Method .InvalidateAttacker(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -10390,7 +10391,7 @@ JSBool CChar_Heal( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, [[mayb
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after using Character JS Method .Heal(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
+ Console.Warning( util::format( "Script context lost after using Character JS Method .Heal(). Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", origScriptID ));
}
}
@@ -10726,7 +10727,7 @@ JSBool CBase_AddScriptTrigger( JSContext *cx, JSObject *obj, uintN argc, jsval *
cScript *toExecute = JSMapping->GetScript( scriptId );
if( toExecute == nullptr )
{
- ScriptError( cx, oldstrutil::format( "Unable to assign script trigger - script ID (%i) not found in jse_fileassociations.scp!", scriptId ).c_str() );
+ ScriptError( cx, util::format( "Unable to assign script trigger - script ID (%i) not found in jse_fileassociations.scp!", scriptId ).c_str() );
return JS_FALSE;
}
else
@@ -10845,7 +10846,7 @@ JSBool CRegion_AddScriptTrigger( JSContext *cx, JSObject *obj, uintN argc, jsval
cScript *toExecute = JSMapping->GetScript( scriptId );
if( toExecute == nullptr )
{
- ScriptError( cx, oldstrutil::format( "Unable to assign script trigger - script ID (%i) not found in jse_fileassociations.scp!", scriptId ).c_str() );
+ ScriptError( cx, util::format( "Unable to assign script trigger - script ID (%i) not found in jse_fileassociations.scp!", scriptId ).c_str() );
return JS_FALSE;
}
else
diff --git a/source/UOXJSPropertyFuncs.cpp b/source/UOXJSPropertyFuncs.cpp
index 69c7d05ff..b7c82ebb5 100644
--- a/source/UOXJSPropertyFuncs.cpp
+++ b/source/UOXJSPropertyFuncs.cpp
@@ -36,6 +36,8 @@
#include "PartySystem.h"
+#include "utility/strutil.hpp"
+
void MakeShop( CChar *c );
void ScriptError( JSContext *cx, const char *txt, ... );
@@ -56,7 +58,7 @@ JSBool CSpellsProps_getProperty( JSContext *cx, JSObject *obj, jsval id, jsval *
if( spellId >= Magic->spells.size() )
{
- ScriptError( cx, oldstrutil::format( "Spells: Invalid Spell ID (%i) provided", spellId ).c_str() );
+ ScriptError( cx, util::format( "Spells: Invalid Spell ID (%i) provided", spellId ).c_str() );
*vp = JSVAL_NULL;
return JS_FALSE;
}
@@ -64,7 +66,7 @@ JSBool CSpellsProps_getProperty( JSContext *cx, JSObject *obj, jsval id, jsval *
CSpellInfo *mySpell = &Magic->spells[spellId];
if( mySpell == nullptr )
{
- ScriptError( cx, oldstrutil::format( "Spells: Invalid Spell with spellId %i", spellId ).c_str() );
+ ScriptError( cx, util::format( "Spells: Invalid Spell with spellId %i", spellId ).c_str() );
*vp = JSVAL_NULL;
return JS_FALSE;
}
@@ -170,7 +172,7 @@ JSBool CGlobalSkillsProps_getProperty( JSContext *cx, JSObject *obj, jsval id, j
if( skillId > THROWING )
{
- ScriptError( cx, oldstrutil::format( "Invalid Skill ID, must be between 0 and 57" ).c_str() );
+ ScriptError( cx, util::format( "Invalid Skill ID, must be between 0 and 57" ).c_str() );
*vp = JSVAL_NULL;
return JS_FALSE;
}
@@ -178,7 +180,7 @@ JSBool CGlobalSkillsProps_getProperty( JSContext *cx, JSObject *obj, jsval id, j
CWorldMain::Skill_st *mySkill = &cwmWorldState->skill[skillId];
if( mySkill == nullptr )
{
- ScriptError( cx, oldstrutil::format( "Invalid Skill" ).c_str() );
+ ScriptError( cx, util::format( "Invalid Skill" ).c_str() );
*vp = JSVAL_NULL;
return JS_FALSE;
}
@@ -285,7 +287,7 @@ JSBool CCreateEntriesProps_getProperty( JSContext *cx, JSObject *obj, jsval id,
CreateEntry_st *myCreateEntry = Skills->FindItem( createEntryId );
if( myCreateEntry == nullptr )
{
- ScriptError( cx, oldstrutil::format( "Invalid create entry ID (%i)", createEntryId ).c_str() );
+ ScriptError( cx, util::format( "Invalid create entry ID (%i)", createEntryId ).c_str() );
*vp = JSVAL_NULL;
return JS_FALSE;
}
@@ -1099,7 +1101,7 @@ JSBool CItemProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval *vp
cScript *toExecute = JSMapping->GetScript( scriptId );
if( toExecute == nullptr )
{
- ScriptError( cx, oldstrutil::format( "Unable to assign script trigger - script ID (%i) not found in jse_fileassociations.scp!", scriptId ).c_str() );
+ ScriptError( cx, util::format( "Unable to assign script trigger - script ID (%i) not found in jse_fileassociations.scp!", scriptId ).c_str() );
}
else
{
@@ -1116,7 +1118,7 @@ JSBool CItemProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval *vp
cScript *toExecute = JSMapping->GetScript( scriptId );
if( toExecute == nullptr )
{
- ScriptError( cx, oldstrutil::format( "Unable to assign script trigger - script ID (%i) not found in jse_fileassociations.scp!", scriptId ).c_str() );
+ ScriptError( cx, util::format( "Unable to assign script trigger - script ID (%i) not found in jse_fileassociations.scp!", scriptId ).c_str() );
}
else
{
@@ -1162,14 +1164,14 @@ JSBool CItemProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval *vp
case CIP_MORE:
{
auto sEncaps = encaps.toString();
- sEncaps = oldstrutil::trim( oldstrutil::removeTrailing( sEncaps, "//" ));
+ sEncaps = util::trim( util::strip( sEncaps, "//" ));
auto encapsSections = oldstrutil::sections( sEncaps, " " );
if( encapsSections.size() >= 4 )
{
- gPriv->SetTempVar( CITV_MORE, 1, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[0], "//" )), nullptr, 0 )));
- gPriv->SetTempVar( CITV_MORE, 2, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[1], "//" )), nullptr, 0 )));
- gPriv->SetTempVar( CITV_MORE, 3, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[2], "//" )), nullptr, 0 )));
- gPriv->SetTempVar( CITV_MORE, 4, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[3], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MORE, 1, static_cast( std::stoul( util::trim( util::strip( encapsSections[0], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MORE, 2, static_cast( std::stoul( util::trim( util::strip( encapsSections[1], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MORE, 3, static_cast( std::stoul( util::trim( util::strip( encapsSections[2], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MORE, 4, static_cast( std::stoul( util::trim( util::strip( encapsSections[3], "//" )), nullptr, 0 )));
}
else
{
@@ -1180,14 +1182,14 @@ JSBool CItemProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval *vp
case CIP_MORE0:
{
auto sEncaps = encaps.toString();
- sEncaps = oldstrutil::trim( oldstrutil::removeTrailing( sEncaps, "//" ));
+ sEncaps = util::trim( util::strip( sEncaps, "//" ));
auto encapsSections = oldstrutil::sections( sEncaps, " " );
if( encapsSections.size() >= 4 )
{
- gPriv->SetTempVar( CITV_MORE0, 1, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[0], "//" )), nullptr, 0 )));
- gPriv->SetTempVar( CITV_MORE0, 2, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[1], "//" )), nullptr, 0 )));
- gPriv->SetTempVar( CITV_MORE0, 3, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[2], "//" )), nullptr, 0 )));
- gPriv->SetTempVar( CITV_MORE0, 4, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[3], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MORE0, 1, static_cast( std::stoul( util::trim( util::strip( encapsSections[0], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MORE0, 2, static_cast( std::stoul( util::trim( util::strip( encapsSections[1], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MORE0, 3, static_cast( std::stoul( util::trim( util::strip( encapsSections[2], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MORE0, 4, static_cast( std::stoul( util::trim( util::strip( encapsSections[3], "//" )), nullptr, 0 )));
}
else
{
@@ -1198,14 +1200,14 @@ JSBool CItemProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval *vp
case CIP_MORE1:
{
auto sEncaps = encaps.toString();
- sEncaps = oldstrutil::trim( oldstrutil::removeTrailing( sEncaps, "//" ));
+ sEncaps = util::trim( util::strip( sEncaps, "//" ));
auto encapsSections = oldstrutil::sections( sEncaps, " " );
if( encapsSections.size() >= 4 )
{
- gPriv->SetTempVar( CITV_MORE1, 1, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[0], "//" )), nullptr, 0 )));
- gPriv->SetTempVar( CITV_MORE1, 2, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[1], "//" )), nullptr, 0 )));
- gPriv->SetTempVar( CITV_MORE1, 3, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[2], "//" )), nullptr, 0 )));
- gPriv->SetTempVar( CITV_MORE1, 4, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[3], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MORE1, 1, static_cast( std::stoul( util::trim( util::strip( encapsSections[0], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MORE1, 2, static_cast( std::stoul( util::trim( util::strip( encapsSections[1], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MORE1, 3, static_cast( std::stoul( util::trim( util::strip( encapsSections[2], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MORE1, 4, static_cast( std::stoul( util::trim( util::strip( encapsSections[3], "//" )), nullptr, 0 )));
}
else
{
@@ -1216,14 +1218,14 @@ JSBool CItemProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval *vp
case CIP_MORE2:
{
auto sEncaps = encaps.toString();
- sEncaps = oldstrutil::trim( oldstrutil::removeTrailing( sEncaps, "//" ));
+ sEncaps = util::trim( util::strip( sEncaps, "//" ));
auto encapsSections = oldstrutil::sections( sEncaps, " " );
if( encapsSections.size() >= 4 )
{
- gPriv->SetTempVar( CITV_MORE2, 1, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[0], "//" )), nullptr, 0 )));
- gPriv->SetTempVar( CITV_MORE2, 2, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[1], "//" )), nullptr, 0 )));
- gPriv->SetTempVar( CITV_MORE2, 3, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[2], "//" )), nullptr, 0 )));
- gPriv->SetTempVar( CITV_MORE2, 4, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[3], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MORE2, 1, static_cast( std::stoul( util::trim( util::strip( encapsSections[0], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MORE2, 2, static_cast( std::stoul( util::trim( util::strip( encapsSections[1], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MORE2, 3, static_cast( std::stoul( util::trim( util::strip( encapsSections[2], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MORE2, 4, static_cast( std::stoul( util::trim( util::strip( encapsSections[3], "//" )), nullptr, 0 )));
}
else
{
@@ -1234,14 +1236,14 @@ JSBool CItemProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval *vp
case CIP_MOREX:
{
auto sEncaps = encaps.toString();
- sEncaps = oldstrutil::trim( oldstrutil::removeTrailing( sEncaps, "//"));
+ sEncaps = util::trim( util::strip( sEncaps, "//"));
auto encapsSections = oldstrutil::sections( sEncaps, " " );
if( encapsSections.size() >= 4 )
{
- gPriv->SetTempVar( CITV_MOREX, 1, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[0], "//" )), nullptr, 0 )));
- gPriv->SetTempVar( CITV_MOREX, 2, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[1], "//" )), nullptr, 0 )));
- gPriv->SetTempVar( CITV_MOREX, 3, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[2], "//" )), nullptr, 0 )));
- gPriv->SetTempVar( CITV_MOREX, 4, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[3], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MOREX, 1, static_cast( std::stoul( util::trim( util::strip( encapsSections[0], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MOREX, 2, static_cast( std::stoul( util::trim( util::strip( encapsSections[1], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MOREX, 3, static_cast( std::stoul( util::trim( util::strip( encapsSections[2], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MOREX, 4, static_cast( std::stoul( util::trim( util::strip( encapsSections[3], "//" )), nullptr, 0 )));
}
else
{
@@ -1252,14 +1254,14 @@ JSBool CItemProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval *vp
case CIP_MOREY:
{
auto sEncaps = encaps.toString();
- sEncaps = oldstrutil::trim( oldstrutil::removeTrailing( sEncaps, "//"));
+ sEncaps = util::trim( util::strip( sEncaps, "//"));
auto encapsSections = oldstrutil::sections( sEncaps, " " );
if( encapsSections.size() >= 4 )
{
- gPriv->SetTempVar( CITV_MOREY, 1, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[0], "//" )), nullptr, 0 )));
- gPriv->SetTempVar( CITV_MOREY, 2, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[1], "//" )), nullptr, 0 )));
- gPriv->SetTempVar( CITV_MOREY, 3, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[2], "//" )), nullptr, 0 )));
- gPriv->SetTempVar( CITV_MOREY, 4, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[3], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MOREY, 1, static_cast( std::stoul( util::trim( util::strip( encapsSections[0], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MOREY, 2, static_cast( std::stoul( util::trim( util::strip( encapsSections[1], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MOREY, 3, static_cast( std::stoul( util::trim( util::strip( encapsSections[2], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MOREY, 4, static_cast( std::stoul( util::trim( util::strip( encapsSections[3], "//" )), nullptr, 0 )));
}
else
{
@@ -1270,14 +1272,14 @@ JSBool CItemProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval *vp
case CIP_MOREZ:
{
auto sEncaps = encaps.toString();
- sEncaps = oldstrutil::trim( oldstrutil::removeTrailing( sEncaps, "//" ));
+ sEncaps = util::trim( util::strip( sEncaps, "//" ));
auto encapsSections = oldstrutil::sections( sEncaps, " " );
if( encapsSections.size() >= 4 )
{
- gPriv->SetTempVar( CITV_MOREZ, 1, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[0], "//" )), nullptr, 0 )));
- gPriv->SetTempVar( CITV_MOREZ, 2, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[1], "//" )), nullptr, 0 )));
- gPriv->SetTempVar( CITV_MOREZ, 3, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[2], "//" )), nullptr, 0 )));
- gPriv->SetTempVar( CITV_MOREZ, 4, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( encapsSections[3], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MOREZ, 1, static_cast( std::stoul( util::trim( util::strip( encapsSections[0], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MOREZ, 2, static_cast( std::stoul( util::trim( util::strip( encapsSections[1], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MOREZ, 3, static_cast( std::stoul( util::trim( util::strip( encapsSections[2], "//" )), nullptr, 0 )));
+ gPriv->SetTempVar( CITV_MOREZ, 4, static_cast( std::stoul( util::trim( util::strip( encapsSections[3], "//" )), nullptr, 0 )));
}
else
{
@@ -1511,7 +1513,7 @@ JSBool CItemProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval *vp
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after setting Item property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
+ Console.Warning( util::format( "Script context lost after setting Item property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
}
}
@@ -2126,7 +2128,7 @@ JSBool CCharacterProps_getProperty( JSContext *cx, JSObject *obj, jsval id, jsva
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after setting Item property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
+ Console.Warning( util::format( "Script context lost after setting Item property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
}
}
@@ -2188,7 +2190,7 @@ JSBool CCharacterProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsva
cScript *toExecute = JSMapping->GetScript( scriptId );
if( toExecute == nullptr )
{
- ScriptError( cx, oldstrutil::format( "Unable to assign script trigger - script ID (%i) not found in jse_fileassociations.scp!", scriptId ).c_str() );
+ ScriptError( cx, util::format( "Unable to assign script trigger - script ID (%i) not found in jse_fileassociations.scp!", scriptId ).c_str() );
}
else
{
@@ -2205,7 +2207,7 @@ JSBool CCharacterProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsva
cScript *toExecute = JSMapping->GetScript( scriptId );
if( toExecute == nullptr )
{
- ScriptError( cx, oldstrutil::format( "Unable to assign script trigger - script ID (%i) not found in jse_fileassociations.scp!", scriptId ).c_str() );
+ ScriptError( cx, util::format( "Unable to assign script trigger - script ID (%i) not found in jse_fileassociations.scp!", scriptId ).c_str() );
}
else
{
@@ -2607,7 +2609,7 @@ JSBool CCharacterProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsva
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after setting Character property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
+ Console.Warning( util::format( "Script context lost after setting Character property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
}
}
@@ -2750,7 +2752,7 @@ JSBool CRegionProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval *
cScript *toExecute = JSMapping->GetScript( scriptId );
if( toExecute == nullptr )
{
- ScriptError( cx, oldstrutil::format( "Unable to assign script trigger - script ID (%i) not found in jse_fileassociations.scp!", scriptId ).c_str() );
+ ScriptError( cx, util::format( "Unable to assign script trigger - script ID (%i) not found in jse_fileassociations.scp!", scriptId ).c_str() );
}
else
{
@@ -2767,7 +2769,7 @@ JSBool CRegionProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval *
cScript *toExecute = JSMapping->GetScript( scriptId );
if( toExecute == nullptr )
{
- ScriptError( cx, oldstrutil::format( "Unable to assign script trigger - script ID (%i) not found in jse_fileassociations.scp!", scriptId ).c_str() );
+ ScriptError( cx, util::format( "Unable to assign script trigger - script ID (%i) not found in jse_fileassociations.scp!", scriptId ).c_str() );
}
else
{
@@ -2803,7 +2805,7 @@ JSBool CRegionProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval *
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after setting Region property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
+ Console.Warning( util::format( "Script context lost after setting Region property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
}
}
@@ -2942,7 +2944,7 @@ JSBool CSpawnRegionProps_setProperty( JSContext *cx, JSObject *obj, jsval id, js
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after setting SpawnRegion property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
+ Console.Warning( util::format( "Script context lost after setting SpawnRegion property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
}
}
@@ -3082,7 +3084,7 @@ JSBool CGuildProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval *v
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after setting Guild property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
+ Console.Warning( util::format( "Script context lost after setting Guild property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
}
}
@@ -3177,7 +3179,7 @@ JSBool CRaceProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval *vp
JSBool retVal = origScript->CallParticularEvent( "_restorecontext_", &id, 0, vp );
if( retVal == JS_FALSE )
{
- Console.Warning( oldstrutil::format( "Script context lost after setting Race property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
+ Console.Warning( util::format( "Script context lost after setting Race property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
}
}
@@ -3281,7 +3283,7 @@ JSBool CSocketProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval *
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after setting Socket property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
+ Console.Warning( util::format( "Script context lost after setting Socket property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
}
}
@@ -3586,7 +3588,7 @@ JSBool CSkillsProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval *
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after setting Skill property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
+ Console.Warning( util::format( "Script context lost after setting Skill property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
}
}
@@ -3830,10 +3832,10 @@ JSBool CAccountProps_getProperty( JSContext *cx, JSObject *obj, jsval id, jsval
}
case CACCOUNT_LASTIP:
{
- std::string ipString = oldstrutil::number( static_cast(( myAccount->dwLastIP & 0xFF000000 ) >> 24 ))
- + "." + oldstrutil::number( static_cast(( myAccount->dwLastIP & 0x00FF0000 ) >> 16 ))
- + "." + oldstrutil::number( static_cast(( myAccount->dwLastIP & 0x0000FF00 ) >> 8 ))
- + "." + oldstrutil::number( static_cast(( myAccount->dwLastIP & 0x000000FF ) % 256 ));
+ std::string ipString = util::ntos( static_cast(( myAccount->dwLastIP & 0xFF000000 ) >> 24 ))
+ + "." + util::ntos( static_cast(( myAccount->dwLastIP & 0x00FF0000 ) >> 16 ))
+ + "." + util::ntos( static_cast(( myAccount->dwLastIP & 0x0000FF00 ) >> 8 ))
+ + "." + util::ntos( static_cast(( myAccount->dwLastIP & 0x000000FF ) % 256 ));
tString = JS_NewStringCopyZ( cx, ipString.c_str() );
*vp = STRING_TO_JSVAL( tString );
break;
@@ -3952,7 +3954,7 @@ JSBool CAccountProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after setting Account property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
+ Console.Warning( util::format( "Script context lost after setting Account property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
}
}
@@ -4070,7 +4072,7 @@ JSBool CResourceProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after setting Resource property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
+ Console.Warning( util::format( "Script context lost after setting Resource property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
}
}
@@ -4151,7 +4153,7 @@ JSBool CPartyProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval *v
if( retVal == JS_FALSE )
{
// Dummy function not found, let shard admin know!
- Console.Warning( oldstrutil::format( "Script context lost after setting Party property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
+ Console.Warning( util::format( "Script context lost after setting Party property %u. Add 'function _restorecontext_() {}' to original script (%u) as safeguard!", JSVAL_TO_INT( id ), origScriptID ));
}
}
diff --git a/source/ai.cpp b/source/ai.cpp
index ab72060ac..3eac41630 100644
--- a/source/ai.cpp
+++ b/source/ai.cpp
@@ -22,6 +22,7 @@
#include "cScript.h"
#include "Dictionary.h"
#include "StringUtility.hpp"
+#include "utility/strutil.hpp"
#undef DBGFILE
#define DBGFILE "ai.cpp"
@@ -671,7 +672,7 @@ void CheckAI( CChar& mChar )
default:
{
std::string mCharName = GetNpcDictName( &mChar, nullptr, NRS_SYSTEM );
- Console.Error( oldstrutil::format( " CheckAI() Error npc %s(0x%X) has invalid AI type %i", mCharName.c_str(), mChar.GetSerial(), mChar.GetNpcAiType() )); //Morrolan
+ Console.Error( util::format( " CheckAI() Error npc %s(0x%X) has invalid AI type %i", mCharName.c_str(), mChar.GetSerial(), mChar.GetNpcAiType() )); //Morrolan
return;
}
}
diff --git a/source/archive.cpp b/source/archive.cpp
index e09d732fa..b89a65b5a 100644
--- a/source/archive.cpp
+++ b/source/archive.cpp
@@ -5,6 +5,7 @@
#include
#include
#include "osunique.hpp"
+#include "utility/strutil.hpp"
//o------------------------------------------------------------------------------------------------o
//| Function - BackupFile()
@@ -33,7 +34,7 @@ void FileArchive( void )
auto mytime = std::chrono::system_clock::to_time_t( std::chrono::system_clock::now() );
struct tm ttemp;
char tbuffer[100];
- auto timenow = oldstrutil::simplify( asciitime( tbuffer, 100, *lcltime( mytime, ttemp )));
+ auto timenow = util::simplify( asciitime( tbuffer, 100, *lcltime( mytime, ttemp )));
timenow = std::regex_replace( timenow, std::regex( "[\\s:]" ), std::string( "-" ));
std::string backupRoot = cwmWorldState->ServerData()->Directory( CSDDP_BACKUP );
@@ -52,13 +53,13 @@ void FileArchive( void )
const SI16 AreaX = UpperX / 8; // we're storing 8x8 grid arrays together
const SI16 AreaY = UpperY / 8;
- auto backupPath = oldstrutil::format( "%s%s/", cwmWorldState->ServerData()->Directory( CSDDP_SHARED ).c_str(), timenow.c_str() );
+ auto backupPath = util::format( "%s%s/", cwmWorldState->ServerData()->Directory( CSDDP_SHARED ).c_str(), timenow.c_str() );
for( SI16 counter1 = 0; counter1 < AreaX; ++counter1 ) // move left->right
{
for( SI16 counter2 = 0; counter2 < AreaY; ++counter2 ) // move up->down
{
- auto filename1 = oldstrutil::format( "%i.%i.wsc", counter1, counter2 );
+ auto filename1 = util::format( "%i.%i.wsc", counter1, counter2 );
BackupFile( filename1, backupRoot );
}
}
diff --git a/source/boats.cpp b/source/boats.cpp
index 8829b2249..50e84a524 100644
--- a/source/boats.cpp
+++ b/source/boats.cpp
@@ -7,6 +7,7 @@
#include "cEffects.h"
#include "Dictionary.h"
#include "StringUtility.hpp"
+#include "utility/strutil.hpp"
#define XP 0
@@ -206,7 +207,7 @@ void OpenPlank( CItem *p )
case 0xD5: p->SetId( 0xB1, 2 ); break;
case 0xD4: p->SetId( 0xB2, 2 ); break;
case 0x89: p->SetId( 0x8A, 2 ); break;
- default: Console.Warning( oldstrutil::format( "Invalid plank ID called! Plank 0x%X '%s' [%u]", p->GetSerial(), p->GetName().c_str(), p->GetId() ));
+ default: Console.Warning( util::format( "Invalid plank ID called! Plank 0x%X '%s' [%u]", p->GetSerial(), p->GetName().c_str(), p->GetId() ));
break;
}
}
@@ -891,7 +892,7 @@ void TurnBoat( CBoatObj *b, bool rightTurn, bool disableChecks )
tiller->IncLocation( iLargeShipOffsets[dir][TILLER][XP], iLargeShipOffsets[dir][TILLER][YP] );
hold->IncLocation( iLargeShipOffsets[dir][HOLD][XP], iLargeShipOffsets[dir][HOLD][YP] );
break;
- default: Console.Error( oldstrutil::format( "TurnBoat() more1 error! more1 = %c not found!", b->GetTempVar( CITV_MOREZ, 1 )));
+ default: Console.Error( util::format( "TurnBoat() more1 error! more1 = %c not found!", b->GetTempVar( CITV_MOREZ, 1 )));
}
for( auto &tSock :nearbyChars )
@@ -1001,15 +1002,15 @@ void CBoatResponse::Handle( CSocket *mSock, CChar *mChar )
}
// Check if player provided anything after the actual set name command
- std::string cmdString = oldstrutil::upper( Dictionary->GetEntry( 1425, mLang )); // SET NAME
- if( oldstrutil::upper( ourText ).size() == cmdString.size() )
+ std::string cmdString = util::upper( Dictionary->GetEntry( 1425, mLang )); // SET NAME
+ if( util::upper( ourText ).size() == cmdString.size() )
{
tiller->TextMessage( mSock, 12 ); // Can ya say that again with an actual name, sir?
return;
}
// Check if we can find the dictionary-based command string in the player's speech
- std::string upperOurText = oldstrutil::upper( ourText );
+ std::string upperOurText = util::upper( ourText );
size_t cmdStringPos = upperOurText.find( cmdString );
if( cmdStringPos == std::string::npos )
{
@@ -1026,7 +1027,7 @@ void CBoatResponse::Handle( CSocket *mSock, CChar *mChar )
}
// Trim spaces from start and end of player provided name, and see if there's actually a name there and not just empty spaces!
- ourText = oldstrutil::trim( ourText );
+ ourText = util::trim( ourText );
if( ourText.size() == 0 )
{
boat->SetName( Dictionary->GetEntry( 2035, mLang )); // a ship
diff --git a/source/books.cpp b/source/books.cpp
index 6dc86b92f..ccd911a1f 100644
--- a/source/books.cpp
+++ b/source/books.cpp
@@ -27,6 +27,8 @@
#include "ssection.h"
#include "CPacketSend.h"
#include "StringUtility.hpp"
+#include "utility/strutil.hpp"
+
#include "osunique.hpp"
using namespace std::string_literals;
@@ -48,7 +50,7 @@ bool CPINewBookHeader::Handle( void )
if( !ValidateObject( mBook ))
return true;
- const std::string fileName = cwmWorldState->ServerData()->Directory( CSDDP_BOOKS ) + oldstrutil::number( bookSer, 16 ) + std::string( ".bok" );
+ const std::string fileName = cwmWorldState->ServerData()->Directory( CSDDP_BOOKS ) + util::ntos( bookSer, 16 ) + std::string( ".bok" );
if( !FileExists( fileName ))
{
@@ -81,18 +83,18 @@ bool CPINewBookHeader::Handle( void )
if( file.fail() )
{
- Console.Error( oldstrutil::format( "Couldn't write to book file %s", fileName.c_str() ));
+ Console.Error( util::format( "Couldn't write to book file %s", fileName.c_str() ));
}
}
else
{
- Console.Error( oldstrutil::format( "Failed to seek to book file %s", fileName.c_str() ));
+ Console.Error( util::format( "Failed to seek to book file %s", fileName.c_str() ));
}
file.close();
}
else
{
- Console.Error( oldstrutil::format( "Couldn't write to book file %s for book 0x%X", fileName.c_str(), bookSer) );
+ Console.Error( util::format( "Couldn't write to book file %s for book 0x%X", fileName.c_str(), bookSer) );
}
}
return true;
@@ -108,7 +110,7 @@ auto CBooks::OpenPreDefBook( CSocket *mSock, CItem *i ) -> void
{
if( mSock )
{
- auto temp = "BOOK "s + oldstrutil::number( i->GetTempVar( CITV_MORE ));
+ auto temp = "BOOK "s + util::ntos( i->GetTempVar( CITV_MORE ));
auto book = FileLookup->FindEntry( temp, misc_def );
if( book )
{
@@ -121,7 +123,7 @@ auto CBooks::OpenPreDefBook( CSocket *mSock, CItem *i ) -> void
for( const auto &sec : book->collection() )
{
auto tag = sec->tag;
- auto UTag = oldstrutil::upper( tag );
+ auto UTag = util::upper( tag );
auto data = sec->data;
if( UTag == "PAGES" )
{
@@ -169,7 +171,7 @@ void CBooks::OpenBook( CSocket *mSock, CItem *mBook, bool isWriteable )
UI16 numPages = 0;
std::string bookTitle, bookAuthor;
- const std::string fileName = cwmWorldState->ServerData()->Directory( CSDDP_BOOKS ) + oldstrutil::number( mBook->GetSerial(), 16 ) + std::string( ".bok" );
+ const std::string fileName = cwmWorldState->ServerData()->Directory( CSDDP_BOOKS ) + util::ntos( mBook->GetSerial(), 16 ) + std::string( ".bok" );
std::ifstream file( fileName.c_str(), std::ios::in | std::ios::binary );
@@ -217,7 +219,7 @@ void CBooks::OpenBook( CSocket *mSock, CItem *mBook, bool isWriteable )
}
else
{
- Console.Error( oldstrutil::format( "Failed to seek to book file %s", fileName.c_str() ));
+ Console.Error( util::format( "Failed to seek to book file %s", fileName.c_str() ));
}
file.close();
@@ -280,7 +282,7 @@ auto CBooks::ReadPreDefBook( CSocket *mSock, CItem *i, UI16 p ) -> void
{
if( mSock )
{
- auto temp = "BOOK "s + oldstrutil::number( i->GetTempVar( CITV_MORE ));
+ auto temp = "BOOK "s + util::ntos( i->GetTempVar( CITV_MORE ));
CScriptSection *book = FileLookup->FindEntry( temp, misc_def );
if( book )
{
@@ -340,7 +342,7 @@ bool CPIBookPage::Handle( void )
return true;
}
- const std::string fileName = cwmWorldState->ServerData()->Directory( CSDDP_BOOKS ) + oldstrutil::number( mBook->GetSerial(), 16 ) + std::string( ".bok" );
+ const std::string fileName = cwmWorldState->ServerData()->Directory( CSDDP_BOOKS ) + util::ntos( mBook->GetSerial(), 16 ) + std::string( ".bok" );
UI16 totalLines = tSock->GetWord( 11 );
// Cap amount of lines sent in one go at 8 per page
@@ -389,13 +391,13 @@ bool CPIBookPage::Handle( void )
}
else
{
- Console.Error( oldstrutil::format( "Failed to seek to book file %s", fileName.c_str() ));
+ Console.Error( util::format( "Failed to seek to book file %s", fileName.c_str() ));
}
file.close();
}
else
{
- Console.Error( oldstrutil::format( "Couldn't write to book file %s", fileName.c_str() ));
+ Console.Error( util::format( "Couldn't write to book file %s", fileName.c_str() ));
}
}
return true;
@@ -409,7 +411,7 @@ bool CPIBookPage::Handle( void )
//o------------------------------------------------------------------------------------------------o
void CBooks::DeleteBook( CItem *id )
{
- std::string fileName = cwmWorldState->ServerData()->Directory( CSDDP_BOOKS ) + oldstrutil::number( id->GetSerial(), 16 ) + std::string( ".bok" );
+ std::string fileName = cwmWorldState->ServerData()->Directory( CSDDP_BOOKS ) + util::ntos( id->GetSerial(), 16 ) + std::string( ".bok" );
[[maybe_unused]] int removeResult = remove( fileName.c_str() );
}
diff --git a/source/cAccountClass.cpp b/source/cAccountClass.cpp
index 10d0c3882..7da152025 100644
--- a/source/cAccountClass.cpp
+++ b/source/cAccountClass.cpp
@@ -14,6 +14,8 @@
#include
#include
#include "StringUtility.hpp"
+#include "utility/strutil.hpp"
+
#include "osunique.hpp"
#if PLATFORM != WINDOWS
#include
@@ -128,27 +130,27 @@ UI16 cAccountClass::CreateAccountSystem( void )
UI08 nLockCount = 0x00;
bool bSkipUAD = false;
actb.reset();
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
while( !fs2.eof() && !fs2.fail() )
{
if( sLine.empty() || sLine.length() == 0 ) // Either nothing on the line, or there was a comment we've ignored
{
std::getline( fs2, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
// Check to see if there is an EOF for those that are like legacy FREAKS!!! Freaks I say!!
if( "EOF" == sLine )
{
std::getline( fs2, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
// Keep track of the section account lines. There is nothing to process till at least one of these has been read
if( sLine.substr( 0, 15 ) == "SECTION ACCOUNT" )
{
// Ok the section block was found, Tokenize the string to get the account #
- auto accountIdFromFile = oldstrutil::value( oldstrutil::extractSection( sLine, " ", 2, 2 ));
+ auto accountIdFromFile = util::ston( oldstrutil::extractSection( sLine, " ", 2, 2 ));
if( accountIdFromFile == 0 && wAccountCount > 0 )
{
actb.wAccountIndex = wAccountCount;
@@ -169,7 +171,7 @@ UI16 cAccountClass::CreateAccountSystem( void )
bBraces[2] = true;
// Get the next line and continue
std::getline( fs2, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
// Fail safe. If bBraces[2] isn't set there is no need to even run this code
@@ -177,7 +179,7 @@ UI16 cAccountClass::CreateAccountSystem( void )
{
// Make sure the get the next line to process.
std::getline( fs2, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
// If we get here then were reading a block now. Check for the openning brace.
@@ -185,7 +187,7 @@ UI16 cAccountClass::CreateAccountSystem( void )
{
bBraces[0] = true;
std::getline( fs2, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
if((( sLine[0] == '{') && bBraces[0] ) || (( sLine[0] == '{' ) && bBraces[1] ))
@@ -206,33 +208,33 @@ UI16 cAccountClass::CreateAccountSystem( void )
bBraces[0] = false;
nLockCount = 0;
std::getline( fs2, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
// Set up the tokenizing
auto ssecs = oldstrutil::sections( sLine, " " );
- auto l = oldstrutil::trim( oldstrutil::removeTrailing( ssecs[0], "//" ));
+ auto l = util::trim( util::strip( ssecs[0], "//" ));
std::string r = "";
if( ssecs.size() > 1 )
{
- r = oldstrutil::trim( oldstrutil::removeTrailing( ssecs[1], "//" ));
+ r = util::trim( util::strip( ssecs[1], "//" ));
}
// Parse and store based on tag
if( "NAME" == l )
{
if( !r.empty() && r.length() != 0 )
{
- actb.sUsername = r; //oldstrutil::lower( r );
+ actb.sUsername = r; //util::lower( r );
if( ssecs.size() > 2 )
{
- actb.sUsername += ssecs[2]; // oldstrutil::lower( ssecs[2] );
+ actb.sUsername += ssecs[2]; // util::lower( ssecs[2] );
}
// Next thing were going to do is make sure there isn't a duplicate username.
while( IsUser( actb.sUsername ))
{
// This username is already on the list, keep adding a random value to the end of the username until we find a free one
- actb.sUsername += oldstrutil::number( RandomNum( 10000, 20000 ));
+ actb.sUsername += util::ntos( RandomNum( 10000, 20000 ));
}
}
else
@@ -240,7 +242,7 @@ UI16 cAccountClass::CreateAccountSystem( void )
actb.sUsername = "ERROR";
}
std::getline( fs2, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
else if( l == "PASS" )
@@ -254,21 +256,21 @@ UI16 cAccountClass::CreateAccountSystem( void )
if( fs1.is_open() )
{
std::getline( fs1, sLine2 );
- sLine2 = oldstrutil::trim( oldstrutil::removeTrailing( sLine2, "//" ));
+ sLine2 = util::trim( util::strip( sLine2, "//" ));
bBraces2[2] = true;
while( !fs1.eof() && bBraces2[2] && !fs1.fail() )
{
if( sLine2.empty() && sLine2.length() != 0 )
{
std::getline( fs1, sLine2 );
- sLine2 = oldstrutil::trim( oldstrutil::removeTrailing( sLine2, "//" ));
+ sLine2 = util::trim( util::strip( sLine2, "//" ));
continue;
}
// Keep track of the section account lines. There is nothing to process till at least one of these has been read
if( sLine2.substr( 0, 14 ) == "SECTION ACCESS" )
{
// Ok the section block was found, Tokenize the string to get the account #
- wAccessId = oldstrutil::value( oldstrutil::extractSection( sLine2, " ", 2 ));
+ wAccessId = util::ston( oldstrutil::extractSection( sLine2, " ", 2 ));
// Ok, we have parsed out the account ID, Set bBraces[2] to true to allow block reading
bBraces2[0] = false;
bBraces2[1] = false;
@@ -310,8 +312,8 @@ UI16 cAccountClass::CreateAccountSystem( void )
break;
}
auto ssecs = oldstrutil::sections( sLine2, " " );
- auto l2 = oldstrutil::trim( oldstrutil::removeTrailing( ssecs[0], "//" ));
- auto r2 = oldstrutil::trim( oldstrutil::removeTrailing( ssecs[1], "//" ));
+ auto l2 = util::trim( util::strip( ssecs[0], "//" ));
+ auto r2 = util::trim( util::strip( ssecs[1], "//" ));
// Parse and store based on tag
if( "PATH" == l2 )
{
@@ -410,7 +412,7 @@ UI16 cAccountClass::CreateAccountSystem( void )
auto psecs = oldstrutil::sections( r, "." );
if( !r.empty() && r.length() != 0 && psecs.size() == 4 )
{
- actb.dwLastIP = CalcSerial( oldstrutil::value( psecs[0] ), oldstrutil::value( psecs[1] ), oldstrutil::value( psecs[2] ), oldstrutil::value( psecs[3] ));
+ actb.dwLastIP = CalcSerial( util::ston( psecs[0] ), util::ston( psecs[1] ), util::ston( psecs[2] ), util::ston( psecs[3] ));
}
else
{
@@ -425,7 +427,7 @@ UI16 cAccountClass::CreateAccountSystem( void )
// Ok strip the name and store it. We need to make it all the same case for comparisons
if( !r.empty() && r.length() != 0 )
{
- actb.sContact = oldstrutil::lower( r );
+ actb.sContact = util::lower( r );
}
else
{
@@ -512,10 +514,10 @@ UI16 cAccountClass::CreateAccountSystem( void )
}
else
{
- r = oldstrutil::trim(r);
+ r = util::trim(r);
if( !r.empty() )
{
- auto temp = oldstrutil::value(r); // int64_t used for promotion from 32-bit int
+ auto temp = util::ston(r); // int64_t used for promotion from 32-bit int
if( (temp > 0) && (temp < static_cast(INVALIDSERIAL)) )
{
actb.dwCharacters[charNum-1] = static_cast(std::stoul( r, nullptr, 0 ));
@@ -566,7 +568,7 @@ UI16 cAccountClass::CreateAccountSystem( void )
auto create_status = std::filesystem::create_directory( std::filesystem::path( sNewPath ));
if( !create_status )
{
- Console.Error( oldstrutil::format( "CreateAccountSystem(): Couldn't create directory %s", sNewPath.c_str() ));
+ Console.Error( util::format( "CreateAccountSystem(): Couldn't create directory %s", sNewPath.c_str() ));
m_mapUsernameIdMap.clear();
m_mapUsernameMap.clear();
return 0L;
@@ -652,7 +654,7 @@ UI16 cAccountClass::CreateAccountSystem( void )
while( nResp == -1 )
{
// Loop through 255 numbers, these will be added to the end of the bu in case a bu exists.
- szltoa2 = oldstrutil::format( "%d", kk++ );
+ szltoa2 = util::format( "%d", kk++ );
sNewPath += szltoa2;
nResp= rename( sAccountsAdm.c_str(), sNewPath.c_str() );
sNewPath = sBUPath;
@@ -738,7 +740,7 @@ UI16 cAccountClass::AddAccount( std::string sUsername, std::string sPassword, co
if( sUsername.length() < 4 || sPassword.length() < 5 )
{
// Username and password must be 4 and 5 characters or more in length, respectively
- Console.Log( oldstrutil::format( "ERROR: Unable to create account for username '%s' with password of '%s'. Username/Password to short", sUsername.c_str(), sPassword.c_str() ), "accounts.log" );
+ Console.Log( util::format( "ERROR: Unable to create account for username '%s' with password of '%s'. Username/Password to short", sUsername.c_str(), sPassword.c_str() ), "accounts.log" );
return 0x0000;
}
// Next thing were going to do is make sure there isn't a duplicate username.
@@ -774,7 +776,7 @@ UI16 cAccountClass::AddAccount( std::string sUsername, std::string sPassword, co
std::string sTempPath( m_sAccountsDirectory );
if( sTempPath[sTempPath.length() - 1] == '\\' || sTempPath[sTempPath.length() - 1] == '/' )
{
- auto szTempBuff = sUsername; // oldstrutil::lower( sUsername );
+ auto szTempBuff = sUsername; // util::lower( sUsername );
sTempPath += szTempBuff;
sTempPath += "/";
sTempPath = oldstrutil::replaceSlash( sTempPath );
@@ -782,7 +784,7 @@ UI16 cAccountClass::AddAccount( std::string sUsername, std::string sPassword, co
}
else
{
- auto szTempBuff = sUsername; //oldstrutil::lower( sUsername );
+ auto szTempBuff = sUsername; //util::lower( sUsername );
sTempPath += "/";
sTempPath += szTempBuff;
sTempPath += "/";
@@ -795,7 +797,7 @@ UI16 cAccountClass::AddAccount( std::string sUsername, std::string sPassword, co
auto create_status = std::filesystem::create_directory( std::filesystem::path( actbTemp.sPath ));
if( !create_status )
{
- Console.Error( oldstrutil::format( "AddAccount(): Couldn't create directory %s", actbTemp.sPath.c_str() ));
+ Console.Error( util::format( "AddAccount(): Couldn't create directory %s", actbTemp.sPath.c_str() ));
return 0x0000;
}
@@ -966,7 +968,7 @@ UI16 cAccountClass::Load( void )
// We need to read from the stream once before entering the loop
std::getline( fsAccountsADM, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
// Ok start the loop and process
bool bBraces[3] = { false, false, false };
[[maybe_unused]] bool bBraces2[3] = { false, false, false };
@@ -983,7 +985,7 @@ UI16 cAccountClass::Load( void )
if( sLine[0] == '\\' || sLine[0] == ';' || sLine[0] == '/' || sLine[0] == '\'' || sLine[0] == 0x13|| sLine[0] == 0x00 )
{
std::getline( fsAccountsADM, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
// Keep track of the section account lines. There is nothing to process till at least one of these has been read
@@ -991,7 +993,7 @@ UI16 cAccountClass::Load( void )
{
// Increment the account acount
++wAccountCount;
- actb.wAccountIndex = wAccountId = oldstrutil::value( oldstrutil::extractSection( sLine, " ", 2 ));
+ actb.wAccountIndex = wAccountId = util::ston( oldstrutil::extractSection( sLine, " ", 2 ));
// Scan for hiegest account. Needed for additional accounts.
if( actb.wAccountIndex>m_wHighestAccount )
@@ -1004,7 +1006,7 @@ UI16 cAccountClass::Load( void )
bBraces[2] = true;
// Get the next line and continue
std::getline( fsAccountsADM, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
// Fail safe. If bBraces[2] isn't set there is no need to even run this code
@@ -1012,7 +1014,7 @@ UI16 cAccountClass::Load( void )
{
// Make sure the get the next line to process.
std::getline( fsAccountsADM, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
// If we get here then were reading a block now. Check for the openning brace.
@@ -1020,7 +1022,7 @@ UI16 cAccountClass::Load( void )
{
bBraces[0]=true;
std::getline( fsAccountsADM, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
if((( sLine[0] == '{' ) && bBraces[0] ) || (( sLine[0] == '{' ) && bBraces[1] ))
@@ -1084,7 +1086,7 @@ UI16 cAccountClass::Load( void )
bBraces[1] = false;
bBraces[2] = false;
std::getline( fsAccountsADM, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
for( UI08 kk = 0; kk < CHARACTERCOUNT; ++kk )
{
dwChars[kk] = INVALIDSERIAL;
@@ -1092,15 +1094,15 @@ UI16 cAccountClass::Load( void )
continue;
}
auto ssecs = oldstrutil::sections( sLine, " " );
- auto l = oldstrutil::trim( oldstrutil::removeTrailing( ssecs[0], "//" ));
- auto r = oldstrutil::trim( oldstrutil::removeTrailing( ssecs[1], "//" ));
+ auto l = util::trim( util::strip( ssecs[0], "//" ));
+ auto r = util::trim( util::strip( ssecs[1], "//" ));
// Parse and store based on tag
if( l == "NAME" )
{
// Ok strip the name and store it. We need to make it all the same case for comparisons
if( !r.empty() && r.length() != 0 )
{
- actb.sUsername = r; //oldstrutil::lower( r );
+ actb.sUsername = r; //util::lower( r );
}
else
{
@@ -1108,7 +1110,7 @@ UI16 cAccountClass::Load( void )
}
std::getline( fsAccountsADM, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
else if( l == "PASS" )
@@ -1128,7 +1130,7 @@ UI16 cAccountClass::Load( void )
bBraces2[1] = false;
bBraces2[2] = false;
std::getline( fsAccountsADM, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
else if( l == "FLAGS" )
@@ -1147,7 +1149,7 @@ UI16 cAccountClass::Load( void )
}
std::getline( fsAccountsADM, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
else if( l == "PATH" )
@@ -1163,7 +1165,7 @@ UI16 cAccountClass::Load( void )
}
std::getline( fsAccountsADM, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
else if( l == "TIMEBAN" )
@@ -1178,7 +1180,7 @@ UI16 cAccountClass::Load( void )
}
std::getline( fsAccountsADM, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
else if( l == "FIRSTLOGIN" )
@@ -1193,7 +1195,7 @@ UI16 cAccountClass::Load( void )
}
std::getline( fsAccountsADM, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
else if( l == "TOTALPLAYTIME" )
@@ -1208,7 +1210,7 @@ UI16 cAccountClass::Load( void )
}
std::getline( fsAccountsADM, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
else if( l == "CONTACT" )
@@ -1216,7 +1218,7 @@ UI16 cAccountClass::Load( void )
// Ok strip the name and store it. We need to make it all the same case for comparisons
if( !r.empty() && r.length() != 0 )
{
- actb.sContact = oldstrutil::lower( r );
+ actb.sContact = util::lower( r );
}
else
{
@@ -1224,7 +1226,7 @@ UI16 cAccountClass::Load( void )
}
std::getline( fsAccountsADM, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
else if( l == "LASTIP" )
@@ -1232,8 +1234,8 @@ UI16 cAccountClass::Load( void )
auto psecs = oldstrutil::sections( r, "." );
if( !r.empty() && r.length() != 0 && psecs.size() == 4 )
{
- actb.dwLastIP = CalcSerial( oldstrutil::value( psecs[0] ), oldstrutil::value( psecs[1] ),
- oldstrutil::value( psecs[2] ), oldstrutil::value( psecs[3] ));
+ actb.dwLastIP = CalcSerial( util::ston( psecs[0] ), util::ston( psecs[1] ),
+ util::ston( psecs[2] ), util::ston( psecs[3] ));
}
else
{
@@ -1241,7 +1243,7 @@ UI16 cAccountClass::Load( void )
}
std::getline( fsAccountsADM, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
else if( l.substr( 0, 10 ) == "CHARACTER-" ) // It's a character
@@ -1266,11 +1268,11 @@ UI16 cAccountClass::Load( void )
}
}
std::getline( fsAccountsADM, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
std::getline( fsAccountsADM, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
actb.reset();
}
// We need to see if there are any new accounts to come.
@@ -1843,7 +1845,7 @@ UI16 cAccountClass::Save( [[maybe_unused]] bool bForceLoad )
if( actbId.sUsername != actbName.sUsername || actbId.sPassword != actbName.sPassword )
{
// there was an error between blocks
- Console.Error( oldstrutil::format( "Save(): Mismatch %s - %s (Duplicate username in accounts file?)", actbId.sUsername.c_str(), actbName.sUsername.c_str() ));
+ Console.Error( util::format( "Save(): Mismatch %s - %s (Duplicate username in accounts file?)", actbId.sUsername.c_str(), actbName.sUsername.c_str() ));
fsAccountsAdm.close();
return 0xFFFF;
}
@@ -1859,7 +1861,7 @@ UI16 cAccountClass::Save( [[maybe_unused]] bool bForceLoad )
std::string sTempPath( m_sAccountsDirectory );
if( sTempPath[sTempPath.length() - 1] == '\\' || sTempPath[sTempPath.length() - 1] == '/' )
{
- auto szTempBuff = actbId.sUsername; // oldstrutil::lower( actbId.sUsername );
+ auto szTempBuff = actbId.sUsername; // util::lower( actbId.sUsername );
sTempPath += szTempBuff;
sTempPath += "/";
sTempPath = oldstrutil::replaceSlash( sTempPath );
@@ -1867,7 +1869,7 @@ UI16 cAccountClass::Save( [[maybe_unused]] bool bForceLoad )
}
else
{
- auto szTempBuff = actbId.sUsername; // oldstrutil::lower( actbId.sUsername );
+ auto szTempBuff = actbId.sUsername; // util::lower( actbId.sUsername );
sTempPath += "/";
sTempPath += szTempBuff;
sTempPath += "/";
@@ -1882,7 +1884,7 @@ UI16 cAccountClass::Save( [[maybe_unused]] bool bForceLoad )
auto create_status = std::filesystem::create_directory( std::filesystem::path( actbId.sPath ));
if( !create_status )
{
- Console.Error( oldstrutil::format( "Save(): Couldn't create directory %s", actbId.sPath.c_str() ));
+ Console.Error( util::format( "Save(): Couldn't create directory %s", actbId.sPath.c_str() ));
fsAccountsAdm << "// !!! Couldn't save .uad file !!!" << std::endl;
continue;
@@ -1909,7 +1911,7 @@ UI16 cAccountClass::Save( [[maybe_unused]] bool bForceLoad )
if( !fsAccountsUad.is_open() )
{
// Ok we were unable to open the file so this user will not be added.
- Console.Error( oldstrutil::format( "Save(): Couldn't open file %s", sUsernameUadPath.c_str() ));
+ Console.Error( util::format( "Save(): Couldn't open file %s", sUsernameUadPath.c_str() ));
fsAccountsAdm << "// !!! Couldn't save .uad file !!!" << std::endl;
continue;
}
@@ -1964,7 +1966,7 @@ UI16 cAccountClass::ImportAccounts( void )
}
// Now that we have a file, we want to read it, and add these accounts to the system
std::getline( fsInputAccountsTest, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
UI16 wAccountCount = 0x0000;
UI16 wCurrentFlags = 0x0004;
while( !fsInputAccountsTest.eof() && !fsInputAccountsTest.fail() )
@@ -1973,22 +1975,22 @@ UI16 cAccountClass::ImportAccounts( void )
if( sLine.empty() || sLine.length() == 0 )
{
std::getline( fsInputAccountsTest, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
auto esecs = oldstrutil::sections( sLine, "=" );
- auto l = oldstrutil::trim( oldstrutil::removeTrailing( esecs[0], "//" ));
- auto r = oldstrutil::trim( oldstrutil::removeTrailing( esecs[1], "//" ));
+ auto l = util::trim( util::strip( esecs[0], "//" ));
+ auto r = util::trim( util::strip( esecs[1], "//" ));
if( l == "USER" )
{
// OK we have an account to import, start parsing it.
std::string user, pass;
auto csecs = oldstrutil::sections( r, "," );
- user = oldstrutil::trim( oldstrutil::removeTrailing( csecs[0], "//" ));
+ user = util::trim( util::strip( csecs[0], "//" ));
if( csecs.size() > 1 )
{
- pass = oldstrutil::trim( oldstrutil::removeTrailing( csecs[1], "//" ));
+ pass = util::trim( util::strip( csecs[1], "//" ));
}
if( user.empty() || user.length() == 0 || pass.empty() || pass.length() == 0 )
@@ -1996,14 +1998,14 @@ UI16 cAccountClass::ImportAccounts( void )
// error there are no NULLS allowed for usernames, passwords. So we move to the next.
// NOTE! This record will be dropped onces parsing is completed as file is deleted.
std::getline( fsInputAccountsTest, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
std::string flags;
if( csecs.size() > 2 )
{
- flags = oldstrutil::trim( oldstrutil::removeTrailing( csecs[2], "//" ));
+ flags = util::trim( util::strip( csecs[2], "//" ));
}
// Set flags to a default value. and in this case I believe that its 0x00000004
@@ -2019,7 +2021,7 @@ UI16 cAccountClass::ImportAccounts( void )
std::string email;
if( csecs.size() > 3 )
{
- email = oldstrutil::trim( oldstrutil::removeTrailing( csecs[3], "//" ));
+ email = util::trim( util::strip( csecs[3], "//" ));
}
if( email.empty() || email.length() == 0 )
@@ -2038,7 +2040,7 @@ UI16 cAccountClass::ImportAccounts( void )
{
// The bad accounts file wasn't writable or something so were going to skip it
std::getline( fsInputAccountsTest, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
// Write the failed line to the file
@@ -2047,14 +2049,14 @@ UI16 cAccountClass::ImportAccounts( void )
// OK there was a problem entering this accounts into the system. Possibly a duplicate? or Other issues
Console << "NOTICE: New account was not processed. Please see failed_accounts.log for details." << myendl;
std::getline( fsInputAccountsTest, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
continue;
}
wAccountCount++;
}
// Need to make sure we get the next line
std::getline( fsInputAccountsTest, sLine );
- sLine = oldstrutil::trim( oldstrutil::removeTrailing( sLine, "//" ));
+ sLine = util::trim( util::strip( sLine, "//" ));
}
// Make sure to close the file
fsInputAccountsTest.close();
diff --git a/source/cBaseObject.cpp b/source/cBaseObject.cpp
index 7f62821e4..30c8119a2 100644
--- a/source/cBaseObject.cpp
+++ b/source/cBaseObject.cpp
@@ -27,8 +27,12 @@
#include "ObjectFactory.h"
#include "weight.h"
#include "Dictionary.h"
+
+#include "utility/strutil.hpp"
+
#include
+
const UI32 BIT_FREE = 0;
const UI32 BIT_DELETED = 1;
const UI32 BIT_POSTLOADED = 2;
@@ -1172,7 +1176,7 @@ void CBaseObject::RemoveFromMulti( bool fireTrigger )
}
else
{
- Console.Error( oldstrutil::format( "Object of type %i with serial 0x%X has a bad multi setting of %i", GetObjType(), serial, multis->GetSerial() ));
+ Console.Error( util::format( "Object of type %i with serial 0x%X has a bad multi setting of %i", GetObjType(), serial, multis->GetSerial() ));
}
}
}
@@ -1234,7 +1238,7 @@ void CBaseObject::AddToMulti( bool fireTrigger )
}
else
{
- Console.Error( oldstrutil::format( "Object of type %i with serial 0x%X has a bad multi setting of %X", GetObjType(), serial, multis->GetSerial() ));
+ Console.Error( util::format( "Object of type %i with serial 0x%X has a bad multi setting of %X", GetObjType(), serial, multis->GetSerial() ));
}
}
}
@@ -1691,10 +1695,10 @@ bool CBaseObject::Load( std::istream &inStream )
ReadWorldTagData( inStream, tag, data );
if( tag != "o---o" )
{
- UTag = oldstrutil::upper( tag );
+ UTag = util::upper( tag );
if( !HandleLine( UTag, data ))
{
- Console.Warning( oldstrutil::format( "Unknown world file tag %s with contents of %s", tag.c_str(), data.c_str() ));
+ Console.Warning( util::format( "Unknown world file tag %s with contents of %s", tag.c_str(), data.c_str() ));
}
}
}
@@ -1720,8 +1724,8 @@ bool CBaseObject::HandleLine( std::string &UTag, std::string &data )
if( UTag == "ATT" )
{
// For backwards compatibility with older UOX3 versions
- loDamage = static_cast( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( data, "//" )), nullptr, 0 ));
- hiDamage = static_cast( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( data, "//" )), nullptr, 0 ));
+ loDamage = static_cast( std::stoi( util::trim( util::strip( data, "//" )), nullptr, 0 ));
+ hiDamage = static_cast( std::stoi( util::trim( util::strip( data, "//" )), nullptr, 0 ));
}
else
{
@@ -1760,19 +1764,19 @@ bool CBaseObject::HandleLine( std::string &UTag, std::string &data )
{
if( csecs.size() >= 2 )
{
- loDamage = static_cast( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( csecs[0], "//" )) , nullptr, 0 ));
- hiDamage = static_cast( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( csecs[1], "//" )), nullptr, 0 ));
+ loDamage = static_cast( std::stoi( util::trim( util::strip( csecs[0], "//" )) , nullptr, 0 ));
+ hiDamage = static_cast( std::stoi( util::trim( util::strip( csecs[1], "//" )), nullptr, 0 ));
}
else
{
// If there's only one value, set both to the same
- loDamage = static_cast( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( data, "//" )), nullptr, 0 ));
+ loDamage = static_cast( std::stoi( util::trim( util::strip( data, "//" )), nullptr, 0 ));
hiDamage = loDamage;
}
}
else if( UTag == "DAMAGEABLE" )
{
- SetDamageable( oldstrutil::value( data ) == 1 );
+ SetDamageable( util::ston( data ) == 1 );
}
else if( UTag == "DIRECTION" || UTag == "DIR" )
{
@@ -1783,17 +1787,17 @@ bool CBaseObject::HandleLine( std::string &UTag, std::string &data )
{
if( csecs.size() >= 2 )
{
- dexterity = static_cast( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( csecs[0], "//" )), nullptr, 0 ));
- dx2 = static_cast( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( csecs[1], "//" )), nullptr, 0 ));
+ dexterity = static_cast( std::stoi( util::trim( util::strip( csecs[0], "//" )), nullptr, 0 ));
+ dx2 = static_cast( std::stoi( util::trim( util::strip( csecs[1], "//" )), nullptr, 0 ));
}
else
{
- dexterity = static_cast( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( data, "//" )), nullptr, 0 ));
+ dexterity = static_cast( std::stoi( util::trim( util::strip( data, "//" )), nullptr, 0 ));
}
}
else if( UTag == "DEXTERITY2" )
{
- dx2 = static_cast( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( data, "//" )), nullptr, 0 ));
+ dx2 = static_cast( std::stoi( util::trim( util::strip( data, "//" )), nullptr, 0 ));
}
else if( UTag == "DEFENSE" )
{
@@ -1804,7 +1808,7 @@ bool CBaseObject::HandleLine( std::string &UTag, std::string &data )
{
if( !val.empty() )
{
- auto temp = oldstrutil::upper( oldstrutil::trim( oldstrutil::removeTrailing( val, "//" )));
+ auto temp = util::upper( util::trim( util::strip( val, "//" )));
if( temp == "[END]" )
{
break;
@@ -1817,12 +1821,12 @@ bool CBaseObject::HandleLine( std::string &UTag, std::string &data )
}
else
{
- SetResist( static_cast( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( data, "//" )), nullptr, 0 )), PHYSICAL );
+ SetResist( static_cast( std::stoi( util::trim( util::strip( data, "//" )), nullptr, 0 )), PHYSICAL );
}
}
else if( UTag == "DISABLED" )
{
- SetDisabled( oldstrutil::value( data ) == 1 );
+ SetDisabled( util::ston( data ) == 1 );
}
else
{
@@ -1832,7 +1836,7 @@ bool CBaseObject::HandleLine( std::string &UTag, std::string &data )
case 'F':
if( UTag == "FAME" )
{
- SetFame( oldstrutil::value( data ));
+ SetFame( util::ston( data ));
}
else
{
@@ -1842,11 +1846,11 @@ bool CBaseObject::HandleLine( std::string &UTag, std::string &data )
case 'H':
if( UTag == "HITPOINTS" )
{
- hitpoints = oldstrutil::value( data );
+ hitpoints = util::ston( data );
}
else if( UTag == "HIDAMAGE" )
{
- hiDamage = oldstrutil::value( data );
+ hiDamage = util::ston( data );
}
else
{
@@ -1856,23 +1860,23 @@ bool CBaseObject::HandleLine( std::string &UTag, std::string &data )
case 'I':
if( UTag == "ID" )
{
- id = oldstrutil::value( data );
+ id = util::ston( data );
}
else if( UTag == "INTELLIGENCE" )
{
if( data.find( "," ) != std::string::npos )
{
- intelligence = static_cast( std::stoi (oldstrutil::trim( oldstrutil::removeTrailing( csecs[0], "//" )), nullptr, 0 ));
- in2 = static_cast( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( csecs[1], "//" )), nullptr, 0 ));
+ intelligence = static_cast( std::stoi (util::trim( util::strip( csecs[0], "//" )), nullptr, 0 ));
+ in2 = static_cast( std::stoi( util::trim( util::strip( csecs[1], "//" )), nullptr, 0 ));
}
else
{
- intelligence = oldstrutil::value( data );
+ intelligence = util::ston( data );
}
}
else if( UTag == "INTELLIGENCE2" )
{
- in2 = oldstrutil::value( data );
+ in2 = util::ston( data );
}
else
{
@@ -1882,11 +1886,11 @@ bool CBaseObject::HandleLine( std::string &UTag, std::string &data )
case 'K':
if( UTag == "KARMA" )
{
- SetKarma( oldstrutil::value( data ));
+ SetKarma( util::ston( data ));
}
else if( UTag == "KILLS" )
{
- SetKills( oldstrutil::value( data ));
+ SetKills( util::ston( data ));
}
else
{
@@ -1896,15 +1900,15 @@ bool CBaseObject::HandleLine( std::string &UTag, std::string &data )
case 'L':
if( UTag == "LOCATION" )
{
- x = static_cast( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( csecs[0], "//" )), nullptr, 0 ));
- y = static_cast( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( csecs[1], "//" )), nullptr, 0 ));
- z = static_cast( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( csecs[2], "//" )), nullptr, 0 ));
- worldNumber = static_cast( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( csecs[3], "//" )), nullptr, 0 ));
+ x = static_cast( std::stoi( util::trim( util::strip( csecs[0], "//" )), nullptr, 0 ));
+ y = static_cast( std::stoi( util::trim( util::strip( csecs[1], "//" )), nullptr, 0 ));
+ z = static_cast( std::stoi( util::trim( util::strip( csecs[2], "//" )), nullptr, 0 ));
+ worldNumber = static_cast( std::stoi( util::trim( util::strip( csecs[3], "//" )), nullptr, 0 ));
// Backwards compatibility with pre-instanceId worldfiles
if( csecs.size() >= 5 )
{
- instanceId = static_cast( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( csecs[4], "//" )), nullptr, 0 ));
+ instanceId = static_cast( std::stoi( util::trim( util::strip( csecs[4], "//" )), nullptr, 0 ));
}
else
{
@@ -1913,7 +1917,7 @@ bool CBaseObject::HandleLine( std::string &UTag, std::string &data )
}
else if( UTag == "LODAMAGE" )
{
- loDamage = oldstrutil::value( data );
+ loDamage = util::ston( data );
}
else
{
@@ -1923,11 +1927,11 @@ bool CBaseObject::HandleLine( std::string &UTag, std::string &data )
case 'M':
if( UTag == "MANA" )
{
- mana = oldstrutil::value( data );
+ mana = util::ston( data );
}
else if( UTag == "MULTIID" )
{
- tempMulti = (oldstrutil::value( data ));
+ tempMulti = (util::ston( data ));
multis = nullptr;
}
else
@@ -1952,7 +1956,7 @@ bool CBaseObject::HandleLine( std::string &UTag, std::string &data )
}
else if( UTag == "OWNERID" )
{
- owner = oldstrutil::value( data );
+ owner = util::ston( data );
}
else
{
@@ -1962,7 +1966,7 @@ bool CBaseObject::HandleLine( std::string &UTag, std::string &data )
case 'P':
if( UTag == "POISONED" )
{
- poisoned = oldstrutil::value( data );
+ poisoned = util::ston( data );
}
else
{
@@ -1972,15 +1976,15 @@ bool CBaseObject::HandleLine( std::string &UTag, std::string &data )
case 'R':
if( UTag == "RACE" )
{
- race = oldstrutil::value( data );
+ race = util::ston( data );
}
else if( UTag == "REPUTATION" )
{
if( csecs.size() == 3 )
{
- SetFame( static_cast( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( csecs[0], "//" )), nullptr, 0 )));
- SetKarma( static_cast( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( csecs[1], "//" )), nullptr, 0 )));
- SetKills( static_cast( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( csecs[2], "//" )), nullptr, 0 )));
+ SetFame( static_cast( std::stoi( util::trim( util::strip( csecs[0], "//" )), nullptr, 0 )));
+ SetKarma( static_cast( std::stoi( util::trim( util::strip( csecs[1], "//" )), nullptr, 0 )));
+ SetKills( static_cast( std::stoi( util::trim( util::strip( csecs[2], "//" )), nullptr, 0 )));
}
}
else
@@ -1996,46 +2000,46 @@ bool CBaseObject::HandleLine( std::string &UTag, std::string &data )
}
else if( UTag == "STAMINA" )
{
- stamina = oldstrutil::value( data );
+ stamina = util::ston( data );
}
else if( UTag == "SPAWNERID" )
{
- spawnSerial = oldstrutil::value( data );
+ spawnSerial = util::ston( data );
}
else if( UTag == "SERIAL" )
{
- serial = oldstrutil::value( data );
+ serial = util::ston( data );
}
else if( UTag == "STRENGTH" )
{
if( csecs.size() >= 2 )
{
- strength = static_cast( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( csecs[0], "//" )), nullptr, 0 ));
- st2 = static_cast( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( csecs[1], "//" )), nullptr, 0 ));
+ strength = static_cast( std::stoi( util::trim( util::strip( csecs[0], "//" )), nullptr, 0 ));
+ st2 = static_cast( std::stoi( util::trim( util::strip( csecs[1], "//" )), nullptr, 0 ));
}
else
{
- strength = oldstrutil::value( data );
+ strength = util::ston( data );
}
}
else if( UTag == "STRENGTH2" )
{
- st2 = oldstrutil::value( data );
+ st2 = util::ston( data );
}
else if( UTag == "SCPTRIG" )
{
- //scriptTrig = oldstrutil::value(data);
- UI16 scriptId = oldstrutil::value( data );
+ //scriptTrig = util::ston(data);
+ UI16 scriptId = util::ston( data );
if( scriptId != 0 && scriptId != 65535 )
{
cScript *toExecute = JSMapping->GetScript( scriptId );
if( toExecute == nullptr )
{
- Console.Warning( oldstrutil::format( "SCPTRIG tag found with invalid script ID (%s) while loading world data!", data.c_str() ));
+ Console.Warning( util::format( "SCPTRIG tag found with invalid script ID (%s) while loading world data!", data.c_str() ));
}
else
{
- this->AddScriptTrigger( oldstrutil::value( data ));
+ this->AddScriptTrigger( util::ston( data ));
}
}
}
@@ -2057,7 +2061,7 @@ bool CBaseObject::HandleLine( std::string &UTag, std::string &data )
{
TAGMAPOBJECT tagvalObject;
tagvalObject.m_ObjectType = TAGMAP_TYPE_INT;
- tagvalObject.m_IntValue = std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( data, "//" )), nullptr, 0 );
+ tagvalObject.m_IntValue = std::stoi( util::trim( util::strip( data, "//" )), nullptr, 0 );
tagvalObject.m_Destroy = false;
tagvalObject.m_StringValue = "";
SetTag( staticTagName, tagvalObject );
@@ -2081,7 +2085,7 @@ bool CBaseObject::HandleLine( std::string &UTag, std::string &data )
case 'V':
if( UTag == "VISIBLE" )
{
- visible = static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( data, "//" ))));
+ visible = static_cast( std::stoul( util::trim( util::strip( data, "//" ))));
}
else
{
@@ -2091,15 +2095,15 @@ bool CBaseObject::HandleLine( std::string &UTag, std::string &data )
case 'W':
if( UTag == "WEIGHT" )
{
- SetWeight( oldstrutil::value( data ));
+ SetWeight( util::ston( data ));
}
else if( UTag == "WIPE" )
{
- SetWipeable( oldstrutil::value( data ) == 1 );
+ SetWipeable( util::ston( data ) == 1 );
}
else if( UTag == "WORLDNUMBER" )
{
- worldNumber = oldstrutil::value( data );
+ worldNumber = util::ston( data );
}
else
{
@@ -2111,7 +2115,7 @@ bool CBaseObject::HandleLine( std::string &UTag, std::string &data )
{
if( csecs.size() >= 1 )
{
- x = static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( csecs[0], "//" )), nullptr, 0 ));
+ x = static_cast( std::stoul( util::trim( util::strip( csecs[0], "//" )), nullptr, 0 ));
}
else
{
@@ -2119,7 +2123,7 @@ bool CBaseObject::HandleLine( std::string &UTag, std::string &data )
}
if( csecs.size() >= 2 )
{
- y = static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( csecs[1], "//" )), nullptr, 0 ));
+ y = static_cast