From be9f9765cf287169fd1efcedfcf2f1bcf67af179 Mon Sep 17 00:00:00 2001 From: LordJZ Date: Sun, 12 Aug 2012 08:10:39 +0400 Subject: [PATCH] Make use of ChrClassesXPowerTypes.dbc, fix MAX_POWERS. --- src/game/DBCStores.cpp | 30 +++++++++++++++++++++++++++++- src/game/DBCStores.h | 1 + src/game/SharedDefines.h | 5 ++++- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/game/DBCStores.cpp b/src/game/DBCStores.cpp index f14713419..b3ebd1987 100644 --- a/src/game/DBCStores.cpp +++ b/src/game/DBCStores.cpp @@ -69,6 +69,8 @@ DBCStorage sCharTitlesStore(CharTitlesEntryfmt); DBCStorage sChatChannelsStore(ChatChannelsEntryfmt); DBCStorage sChrClassesStore(ChrClassesEntryfmt); DBCStorage sChrPowerTypesStore(ChrClassesXPowerTypesfmt); +// pair => powerIndex +uint32 sChrClassXPowerTypesStore[MAX_CLASSES][MAX_POWERS]; DBCStorage sChrRacesStore(ChrRacesEntryfmt); DBCStorage sCinematicSequencesStore(CinematicSequencesEntryfmt); DBCStorage sCreatureDisplayInfoStore(CreatureDisplayInfofmt); @@ -438,7 +440,33 @@ void LoadDBCStores(const std::string& dataPath) LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCharTitlesStore, dbcPath,"CharTitles.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sChatChannelsStore, dbcPath,"ChatChannels.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sChrClassesStore, dbcPath,"ChrClasses.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sChrPowerTypesStore, dbcPath, "ChrClassesXPowerTypes.dbc"); + LoadDBC(availableDbcLocales,bar,bad_dbc_files,sChrPowerTypesStore, dbcPath,"ChrClassesXPowerTypes.dbc"); + for (uint32 i = 0; i < MAX_CLASSES; ++i) + { + for (uint32 j = 0; j < MAX_POWERS; ++j) + sChrClassXPowerTypesStore[i][j] = INVALID_POWER_INDEX; + } + for (uint32 i = 0; i < sChrPowerTypesStore.GetNumRows(); ++i) + { + ChrPowerTypesEntry const* entry = sChrPowerTypesStore.LookupEntry(i); + if (!entry) + continue; + + MANGOS_ASSERT(entry->classId < MAX_CLASSES && "MAX_CLASSES not updated"); + MANGOS_ASSERT(entry->power < MAX_POWERS && "MAX_POWERS not updated"); + + uint32 index = 0; + + for (uint32 j = 0; j < MAX_POWERS; ++j) + { + if (sChrClassXPowerTypesStore[entry->classId][j] != INVALID_POWER_INDEX) + ++index; + } + + MANGOS_ASSERT(index < MAX_STORED_POWERS && "MAX_STORED_POWERS not updated"); + + sChrClassXPowerTypesStore[entry->classId][entry->power] = index; + } LoadDBC(availableDbcLocales,bar,bad_dbc_files,sChrRacesStore, dbcPath,"ChrRaces.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCinematicSequencesStore, dbcPath,"CinematicSequences.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCreatureDisplayInfoStore, dbcPath,"CreatureDisplayInfo.dbc"); diff --git a/src/game/DBCStores.h b/src/game/DBCStores.h index 9f07ba833..37ba37786 100644 --- a/src/game/DBCStores.h +++ b/src/game/DBCStores.h @@ -112,6 +112,7 @@ extern DBCStorage sCharStartOutfitStore; extern DBCStorage sCharTitlesStore; extern DBCStorage sChrClassesStore; extern DBCStorage sChrPowerTypesStore; +extern uint32 sChrClassXPowerTypesStore[MAX_CLASSES][MAX_POWERS]; extern DBCStorage sChrRacesStore; extern DBCStorage sCinematicSequencesStore; extern DBCStorage sCreatureDisplayInfoStore; diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h index 2d79fc242..7e18d606f 100644 --- a/src/game/SharedDefines.h +++ b/src/game/SharedDefines.h @@ -155,10 +155,13 @@ enum Powers POWER_ECLIPSE = 8, POWER_HOLY_POWER = 9, POWER_ALTERNATE = 10, + MAX_POWERS = 11, POWER_HEALTH = 0xFFFFFFFE // (-2 as signed value) }; -#define MAX_POWERS 5 +#define MAX_STORED_POWERS 5 +// Setting this value to something high helps debugging +#define INVALID_POWER_INDEX 10000 enum SpellSchools {