Skip to content

Commit 4e38582

Browse files
committed
Core/DataStores: Removed hardcoded cap for taxi nodes mask
(cherry picked from commit 376dc7402a41a03b4c5bc718863c1e0eb410ebec)
1 parent f576472 commit 4e38582

4 files changed

Lines changed: 42 additions & 21 deletions

File tree

src/server/game/DataStores/DBCStores.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -589,11 +589,12 @@ void LoadDBCStores(const std::string& dataPath)
589589
if (sInfo->Effect[j] == SPELL_EFFECT_SEND_TAXI)
590590
spellPaths.insert(sInfo->EffectMiscValue[j]);
591591

592-
sTaxiNodesMask.fill(0);
593-
sOldContinentsNodesMask.fill(0);
594-
sHordeTaxiNodesMask.fill(0);
595-
sAllianceTaxiNodesMask.fill(0);
596-
sDeathKnightTaxiNodesMask.fill(0);
592+
// reinitialize internal storage for globals after loading TaxiNodes.db2
593+
sTaxiNodesMask = {};
594+
sOldContinentsNodesMask = {};
595+
sHordeTaxiNodesMask = {};
596+
sAllianceTaxiNodesMask = {};
597+
sDeathKnightTaxiNodesMask = {};
597598
for (TaxiNodesEntry const* node : sTaxiNodesStore)
598599
{
599600
TaxiPathSetBySource::const_iterator src_i = sTaxiPathSetBySource.find(node->ID);
@@ -985,3 +986,12 @@ EmotesTextSoundEntry const* FindTextSoundEmoteFor(uint32 emote, uint32 race, uin
985986
auto itr = sEmotesTextSoundMap.find(EmotesTextSoundKey(emote, race, gender));
986987
return itr != sEmotesTextSoundMap.end() ? itr->second : nullptr;
987988
}
989+
990+
TaxiMask::TaxiMask()
991+
{
992+
if (sTaxiNodesStore.GetNumRows())
993+
{
994+
_data.resize((sTaxiNodesStore.GetNumRows() + (8 * sizeof(uint64) - 1)) / (8 * sizeof(uint64)) * (sizeof(uint64) / sizeof(value_type)), 0);
995+
ASSERT((_data.size() % (8 / sizeof(value_type))) == 0, "TaxiMask byte size must be aligned to a multiple of uint64");
996+
}
997+
}

src/server/game/Entities/Player/PlayerTaxi.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void PlayerTaxi::InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint8 level
2929
{
3030
case CLASS_DEATH_KNIGHT:
3131
{
32-
for (uint8 i = 0; i < TaxiMaskSize; ++i)
32+
for (std::size_t i = 0; i < m_taximask.size(); ++i)
3333
m_taximask[i] |= sOldContinentsNodesMask[i];
3434
break;
3535
}
@@ -66,7 +66,7 @@ bool PlayerTaxi::LoadTaxiMask(std::string const& data)
6666
{
6767
bool warn = false;
6868
std::vector<std::string_view> tokens = Trinity::Tokenize(data, ' ', false);
69-
for (uint8 index = 0; (index < TaxiMaskSize) && (index < tokens.size()); ++index)
69+
for (size_t index = 0; (index < m_taximask.size()) && (index < tokens.size()); ++index)
7070
{
7171
if (Optional<uint32> mask = Trinity::StringTo<uint32>(tokens[index]))
7272
{
@@ -87,15 +87,9 @@ bool PlayerTaxi::LoadTaxiMask(std::string const& data)
8787
void PlayerTaxi::AppendTaximaskTo(ByteBuffer& data, bool all)
8888
{
8989
if (all)
90-
{
91-
for (uint8 i = 0; i < TaxiMaskSize; ++i)
92-
data << uint32(sTaxiNodesMask[i]); // all existing nodes
93-
}
90+
data.append(sTaxiNodesMask.data(), sTaxiNodesMask.size()); // all existing nodes
9491
else
95-
{
96-
for (uint8 i = 0; i < TaxiMaskSize; ++i)
97-
data << uint32(m_taximask[i]); // known nodes
98-
}
92+
data.append(m_taximask.data(), m_taximask.size()); // known nodes
9993
}
10094

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

177171
std::ostringstream& operator<<(std::ostringstream& ss, PlayerTaxi const& taxi)
178172
{
179-
for (uint8 i = 0; i < TaxiMaskSize; ++i)
180-
ss << taxi.m_taximask[i] << ' ';
173+
for (std::size_t i = 0; i < taxi.m_taximask.size(); ++i)
174+
ss << uint32(taxi.m_taximask[i]) << ' ';
181175
return ss;
182176
}
183177

src/server/game/Entities/Player/PlayerTaxi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct FactionTemplateEntry;
3030
class TC_GAME_API PlayerTaxi
3131
{
3232
public:
33-
PlayerTaxi() : m_flightMasterFactionId(0) { m_taximask.fill(0); }
33+
PlayerTaxi() : m_flightMasterFactionId(0) { }
3434
~PlayerTaxi() { }
3535
// Nodes
3636
void InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint8 level);

src/server/shared/DataStores/DBCEnums.h

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define DBCENUMS_H
2020

2121
#include "Define.h"
22-
#include <array>
22+
#include <vector>
2323

2424
#pragma pack(push, 1)
2525

@@ -433,8 +433,25 @@ enum SummonPropFlags
433433
#define MAX_PET_TALENT_RANK 3 // use in calculations, expected <= MAX_TALENT_RANK
434434
#define MAX_TALENT_TABS 3
435435

436-
static constexpr size_t TaxiMaskSize = 14;
437-
typedef std::array<uint32, TaxiMaskSize> TaxiMask;
436+
class TaxiMask
437+
{
438+
public:
439+
using value_type = uint32;
440+
441+
TaxiMask();
442+
443+
value_type& operator[](size_t i) { return _data[i]; }
444+
value_type const& operator[](size_t i) const { return _data[i]; }
445+
446+
size_t size() const { return _data.size(); }
447+
value_type const* data() const { return _data.data(); }
448+
449+
decltype(auto) begin() { return _data.begin(); }
450+
decltype(auto) end() { return _data.end(); }
451+
452+
private:
453+
std::vector<value_type> _data;
454+
};
438455

439456
enum TotemCategoryType
440457
{

0 commit comments

Comments
 (0)