Skip to content

Commit

Permalink
Core/DataStores: Removed hardcoded cap for taxi nodes mask
Browse files Browse the repository at this point in the history
(cherry picked from commit 376dc7402a41a03b4c5bc718863c1e0eb410ebec)
  • Loading branch information
Shauren committed Jul 19, 2024
1 parent f576472 commit 4e38582
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 21 deletions.
20 changes: 15 additions & 5 deletions src/server/game/DataStores/DBCStores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,11 +589,12 @@ void LoadDBCStores(const std::string& dataPath)
if (sInfo->Effect[j] == SPELL_EFFECT_SEND_TAXI)
spellPaths.insert(sInfo->EffectMiscValue[j]);

sTaxiNodesMask.fill(0);
sOldContinentsNodesMask.fill(0);
sHordeTaxiNodesMask.fill(0);
sAllianceTaxiNodesMask.fill(0);
sDeathKnightTaxiNodesMask.fill(0);
// reinitialize internal storage for globals after loading TaxiNodes.db2
sTaxiNodesMask = {};
sOldContinentsNodesMask = {};
sHordeTaxiNodesMask = {};
sAllianceTaxiNodesMask = {};
sDeathKnightTaxiNodesMask = {};
for (TaxiNodesEntry const* node : sTaxiNodesStore)
{
TaxiPathSetBySource::const_iterator src_i = sTaxiPathSetBySource.find(node->ID);
Expand Down Expand Up @@ -985,3 +986,12 @@ EmotesTextSoundEntry const* FindTextSoundEmoteFor(uint32 emote, uint32 race, uin
auto itr = sEmotesTextSoundMap.find(EmotesTextSoundKey(emote, race, gender));
return itr != sEmotesTextSoundMap.end() ? itr->second : nullptr;
}

TaxiMask::TaxiMask()
{
if (sTaxiNodesStore.GetNumRows())
{
_data.resize((sTaxiNodesStore.GetNumRows() + (8 * sizeof(uint64) - 1)) / (8 * sizeof(uint64)) * (sizeof(uint64) / sizeof(value_type)), 0);
ASSERT((_data.size() % (8 / sizeof(value_type))) == 0, "TaxiMask byte size must be aligned to a multiple of uint64");
}
}
18 changes: 6 additions & 12 deletions src/server/game/Entities/Player/PlayerTaxi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void PlayerTaxi::InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint8 level
{
case CLASS_DEATH_KNIGHT:
{
for (uint8 i = 0; i < TaxiMaskSize; ++i)
for (std::size_t i = 0; i < m_taximask.size(); ++i)
m_taximask[i] |= sOldContinentsNodesMask[i];
break;
}
Expand Down Expand Up @@ -66,7 +66,7 @@ bool PlayerTaxi::LoadTaxiMask(std::string const& data)
{
bool warn = false;
std::vector<std::string_view> tokens = Trinity::Tokenize(data, ' ', false);
for (uint8 index = 0; (index < TaxiMaskSize) && (index < tokens.size()); ++index)
for (size_t index = 0; (index < m_taximask.size()) && (index < tokens.size()); ++index)
{
if (Optional<uint32> mask = Trinity::StringTo<uint32>(tokens[index]))
{
Expand All @@ -87,15 +87,9 @@ bool PlayerTaxi::LoadTaxiMask(std::string const& data)
void PlayerTaxi::AppendTaximaskTo(ByteBuffer& data, bool all)
{
if (all)
{
for (uint8 i = 0; i < TaxiMaskSize; ++i)
data << uint32(sTaxiNodesMask[i]); // all existing nodes
}
data.append(sTaxiNodesMask.data(), sTaxiNodesMask.size()); // all existing nodes
else
{
for (uint8 i = 0; i < TaxiMaskSize; ++i)
data << uint32(m_taximask[i]); // known nodes
}
data.append(m_taximask.data(), m_taximask.size()); // known nodes
}

bool PlayerTaxi::LoadTaxiDestinationsFromString(const std::string& values, uint32 team)
Expand Down Expand Up @@ -176,8 +170,8 @@ uint32 PlayerTaxi::GetCurrentTaxiPath() const

std::ostringstream& operator<<(std::ostringstream& ss, PlayerTaxi const& taxi)
{
for (uint8 i = 0; i < TaxiMaskSize; ++i)
ss << taxi.m_taximask[i] << ' ';
for (std::size_t i = 0; i < taxi.m_taximask.size(); ++i)
ss << uint32(taxi.m_taximask[i]) << ' ';
return ss;
}

Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Entities/Player/PlayerTaxi.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct FactionTemplateEntry;
class TC_GAME_API PlayerTaxi
{
public:
PlayerTaxi() : m_flightMasterFactionId(0) { m_taximask.fill(0); }
PlayerTaxi() : m_flightMasterFactionId(0) { }
~PlayerTaxi() { }
// Nodes
void InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint8 level);
Expand Down
23 changes: 20 additions & 3 deletions src/server/shared/DataStores/DBCEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define DBCENUMS_H

#include "Define.h"
#include <array>
#include <vector>

#pragma pack(push, 1)

Expand Down Expand Up @@ -433,8 +433,25 @@ enum SummonPropFlags
#define MAX_PET_TALENT_RANK 3 // use in calculations, expected <= MAX_TALENT_RANK
#define MAX_TALENT_TABS 3

static constexpr size_t TaxiMaskSize = 14;
typedef std::array<uint32, TaxiMaskSize> TaxiMask;
class TaxiMask
{
public:
using value_type = uint32;

TaxiMask();

value_type& operator[](size_t i) { return _data[i]; }
value_type const& operator[](size_t i) const { return _data[i]; }

size_t size() const { return _data.size(); }
value_type const* data() const { return _data.data(); }

decltype(auto) begin() { return _data.begin(); }
decltype(auto) end() { return _data.end(); }

private:
std::vector<value_type> _data;
};

enum TotemCategoryType
{
Expand Down

0 comments on commit 4e38582

Please sign in to comment.