mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-14 17:49:10 +00:00
feat(Core/Common): delete old Tokenizer (#10121)
This commit is contained in:
@@ -67,6 +67,8 @@
|
||||
#include "Vehicle.h"
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "Tokenize.h"
|
||||
#include "StringConvert.h"
|
||||
#include <math.h>
|
||||
|
||||
float baseMoveSpeed[MAX_MOVE_TYPE] =
|
||||
@@ -15218,30 +15220,36 @@ void CharmInfo::SetPetNumber(uint32 petnumber, bool statwindow)
|
||||
|
||||
void CharmInfo::LoadPetActionBar(const std::string& data)
|
||||
{
|
||||
Tokenizer tokens(data, ' ');
|
||||
std::vector<std::string_view> tokens = Acore::Tokenize(data, ' ', false);
|
||||
|
||||
if (tokens.size() != (ACTION_BAR_INDEX_END - ACTION_BAR_INDEX_START) * 2)
|
||||
return; // non critical, will reset to default
|
||||
|
||||
uint8 index = ACTION_BAR_INDEX_START;
|
||||
Tokenizer::const_iterator iter = tokens.begin();
|
||||
for (; index < ACTION_BAR_INDEX_END; ++iter, ++index)
|
||||
auto iter = tokens.begin();
|
||||
for (uint8 index = ACTION_BAR_INDEX_START; index < ACTION_BAR_INDEX_END; ++index)
|
||||
{
|
||||
// use unsigned cast to avoid sign negative format use at long-> ActiveStates (int) conversion
|
||||
ActiveStates type = ActiveStates(atol(*iter));
|
||||
++iter;
|
||||
uint32 action = uint32(atol(*iter));
|
||||
Optional<uint8> type = Acore::StringTo<uint8>(*(iter++));
|
||||
Optional<uint32> action = Acore::StringTo<uint32>(*(iter++));
|
||||
|
||||
PetActionBar[index].SetActionAndType(action, type);
|
||||
if (!type || !action)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
PetActionBar[index].SetActionAndType(*action, static_cast<ActiveStates>(*type));
|
||||
|
||||
// check correctness
|
||||
if (PetActionBar[index].IsActionBarForSpell())
|
||||
{
|
||||
SpellInfo const* spelInfo = sSpellMgr->GetSpellInfo(PetActionBar[index].GetAction());
|
||||
if (!spelInfo)
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(PetActionBar[index].GetAction());
|
||||
if (!spellInfo)
|
||||
{
|
||||
SetActionBar(index, 0, ACT_PASSIVE);
|
||||
else if (!spelInfo->IsAutocastable())
|
||||
}
|
||||
else if (!spellInfo->IsAutocastable())
|
||||
{
|
||||
SetActionBar(index, PetActionBar[index].GetAction(), ACT_PASSIVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user