Core/Common: Tokenizer -> Trinity::Tokenize
This commit is contained in:
1 parent
95329dc15c
commit
f95a8bfdca
32 files changed
+414
-354
No files matched your search
@@ -53,6 +53,7 @@
|
||||
#include "ScriptMgr.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "SocialMgr.h"
|
||||
#include "StringConvert.h"
|
||||
#include "SystemPackets.h"
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
@@ -2167,18 +2168,24 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
|
||||
// Title conversion
|
||||
if (!knownTitlesStr.empty())
|
||||
{
|
||||
uint32 const ktcount = KNOWN_TITLES_SIZE * 2;
|
||||
uint32 knownTitles[ktcount];
|
||||
Tokenizer tokens(knownTitlesStr, ' ', ktcount);
|
||||
std::vector<std::string_view> tokens = Trinity::Tokenize(knownTitlesStr, ' ', false);
|
||||
std::array<uint32, KNOWN_TITLES_SIZE * 2> knownTitles;
|
||||
|
||||
if (tokens.size() != ktcount)
|
||||
for (uint32 index = 0; index < knownTitles.size(); ++index)
|
||||
{
|
||||
SendCharFactionChange(CHAR_CREATE_ERROR, factionChangeInfo.get());
|
||||
return;
|
||||
}
|
||||
Optional<uint32> thisMask;
|
||||
if (index < tokens.size())
|
||||
thisMask = Trinity::StringTo<uint32>(tokens[index]);
|
||||
|
||||
for (uint32 index = 0; index < ktcount; ++index)
|
||||
knownTitles[index] = atoul(tokens[index]);
|
||||
if (thisMask)
|
||||
knownTitles[index] = *thisMask;
|
||||
else
|
||||
{
|
||||
TC_LOG_WARN("entities.player", "%s has invalid title data '%s' at index %u - skipped, this may result in titles being lost",
|
||||
GetPlayerInfo().c_str(), (index < tokens.size()) ? std::string(tokens[index]).c_str() : "<none>", index);
|
||||
knownTitles[index] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChangeTitles.begin(); it != sObjectMgr->FactionChangeTitles.end(); ++it)
|
||||
{
|
||||
@@ -2216,8 +2223,8 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
|
||||
}
|
||||
|
||||
std::ostringstream ss;
|
||||
for (uint32 index = 0; index < ktcount; ++index)
|
||||
ss << knownTitles[index] << ' ';
|
||||
for (uint32 mask : knownTitles)
|
||||
ss << mask << ' ';
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TITLES_FACTION_CHANGE);
|
||||
stmt->setString(0, ss.str());
|
||||
|
||||
Reference in new issue
Block a user