mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 01:37:00 +00:00
Fix SMSG_POWER_UPDATE, thanks @Zakamurite for noticing.
This commit is contained in:
parent
dba1b2fca2
commit
8010d254b6
5 changed files with 22 additions and 1 deletions
|
|
@ -71,6 +71,8 @@ DBCStorage <ChrClassesEntry> sChrClassesStore(ChrClassesEntryfmt);
|
||||||
DBCStorage <ChrPowerTypesEntry> sChrPowerTypesStore(ChrClassesXPowerTypesfmt);
|
DBCStorage <ChrPowerTypesEntry> sChrPowerTypesStore(ChrClassesXPowerTypesfmt);
|
||||||
// pair<class,power> => powerIndex
|
// pair<class,power> => powerIndex
|
||||||
uint32 sChrClassXPowerTypesStore[MAX_CLASSES][MAX_POWERS];
|
uint32 sChrClassXPowerTypesStore[MAX_CLASSES][MAX_POWERS];
|
||||||
|
// pair<class,powerIndex> => power
|
||||||
|
uint32 sChrClassXPowerIndexStore[MAX_CLASSES][MAX_STORED_POWERS];
|
||||||
DBCStorage <ChrRacesEntry> sChrRacesStore(ChrRacesEntryfmt);
|
DBCStorage <ChrRacesEntry> sChrRacesStore(ChrRacesEntryfmt);
|
||||||
DBCStorage <CinematicSequencesEntry> sCinematicSequencesStore(CinematicSequencesEntryfmt);
|
DBCStorage <CinematicSequencesEntry> sCinematicSequencesStore(CinematicSequencesEntryfmt);
|
||||||
DBCStorage <CreatureDisplayInfoEntry> sCreatureDisplayInfoStore(CreatureDisplayInfofmt);
|
DBCStorage <CreatureDisplayInfoEntry> sCreatureDisplayInfoStore(CreatureDisplayInfofmt);
|
||||||
|
|
@ -445,6 +447,8 @@ void LoadDBCStores(const std::string& dataPath)
|
||||||
{
|
{
|
||||||
for (uint32 j = 0; j < MAX_POWERS; ++j)
|
for (uint32 j = 0; j < MAX_POWERS; ++j)
|
||||||
sChrClassXPowerTypesStore[i][j] = INVALID_POWER_INDEX;
|
sChrClassXPowerTypesStore[i][j] = INVALID_POWER_INDEX;
|
||||||
|
for (uint32 j = 0; j < MAX_STORED_POWERS; ++j)
|
||||||
|
sChrClassXPowerIndexStore[i][j] = INVALID_POWER;
|
||||||
}
|
}
|
||||||
for (uint32 i = 0; i < sChrPowerTypesStore.GetNumRows(); ++i)
|
for (uint32 i = 0; i < sChrPowerTypesStore.GetNumRows(); ++i)
|
||||||
{
|
{
|
||||||
|
|
@ -466,6 +470,7 @@ void LoadDBCStores(const std::string& dataPath)
|
||||||
MANGOS_ASSERT(index < MAX_STORED_POWERS && "MAX_STORED_POWERS not updated");
|
MANGOS_ASSERT(index < MAX_STORED_POWERS && "MAX_STORED_POWERS not updated");
|
||||||
|
|
||||||
sChrClassXPowerTypesStore[entry->classId][entry->power] = index;
|
sChrClassXPowerTypesStore[entry->classId][entry->power] = index;
|
||||||
|
sChrClassXPowerIndexStore[entry->classId][index] = entry->power;
|
||||||
}
|
}
|
||||||
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sChrRacesStore, dbcPath,"ChrRaces.dbc");
|
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,sCinematicSequencesStore, dbcPath,"CinematicSequences.dbc");
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@ extern DBCStorage <CharTitlesEntry> sCharTitlesStore;
|
||||||
extern DBCStorage <ChrClassesEntry> sChrClassesStore;
|
extern DBCStorage <ChrClassesEntry> sChrClassesStore;
|
||||||
extern DBCStorage <ChrPowerTypesEntry> sChrPowerTypesStore;
|
extern DBCStorage <ChrPowerTypesEntry> sChrPowerTypesStore;
|
||||||
extern uint32 sChrClassXPowerTypesStore[MAX_CLASSES][MAX_POWERS];
|
extern uint32 sChrClassXPowerTypesStore[MAX_CLASSES][MAX_POWERS];
|
||||||
|
extern uint32 sChrClassXPowerIndexStore[MAX_CLASSES][MAX_STORED_POWERS];
|
||||||
extern DBCStorage <ChrRacesEntry> sChrRacesStore;
|
extern DBCStorage <ChrRacesEntry> sChrRacesStore;
|
||||||
extern DBCStorage <CinematicSequencesEntry> sCinematicSequencesStore;
|
extern DBCStorage <CinematicSequencesEntry> sCinematicSequencesStore;
|
||||||
extern DBCStorage <CreatureDisplayInfoEntry> sCreatureDisplayInfoStore;
|
extern DBCStorage <CreatureDisplayInfoEntry> sCreatureDisplayInfoStore;
|
||||||
|
|
|
||||||
|
|
@ -162,6 +162,7 @@ enum Powers
|
||||||
#define MAX_STORED_POWERS 5
|
#define MAX_STORED_POWERS 5
|
||||||
// Setting this value to something high helps debugging
|
// Setting this value to something high helps debugging
|
||||||
#define INVALID_POWER_INDEX 10000
|
#define INVALID_POWER_INDEX 10000
|
||||||
|
#define INVALID_POWER MAX_POWERS
|
||||||
|
|
||||||
enum SpellSchools
|
enum SpellSchools
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -9816,6 +9816,14 @@ uint32 Unit::GetPowerIndexByClass(Powers powerId, uint32 classId)
|
||||||
return sChrClassXPowerTypesStore[classId][uint32(powerId)];
|
return sChrClassXPowerTypesStore[classId][uint32(powerId)];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Powers Unit::GetPowerTypeByIndex(uint32 index, uint32 classId)
|
||||||
|
{
|
||||||
|
MANGOS_ASSERT(index < MAX_STORED_POWERS);
|
||||||
|
MANGOS_ASSERT(classId < MAX_CLASSES);
|
||||||
|
|
||||||
|
return Powers(sChrClassXPowerIndexStore[classId][index]);
|
||||||
|
}
|
||||||
|
|
||||||
int32 Unit::GetPower(Powers power) const
|
int32 Unit::GetPower(Powers power) const
|
||||||
{
|
{
|
||||||
if (power == POWER_HEALTH)
|
if (power == POWER_HEALTH)
|
||||||
|
|
@ -9878,14 +9886,18 @@ void Unit::SetPowerByIndex(uint32 powerIndex, int32 val)
|
||||||
if (GetPowerByIndex(powerIndex) == val)
|
if (GetPowerByIndex(powerIndex) == val)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
MANGOS_ASSERT(powerIndex < MAX_STORED_POWERS);
|
||||||
SetInt32Value(UNIT_FIELD_POWER1 + powerIndex, val);
|
SetInt32Value(UNIT_FIELD_POWER1 + powerIndex, val);
|
||||||
|
|
||||||
if (IsInWorld())
|
if (IsInWorld())
|
||||||
{
|
{
|
||||||
|
Powers power = getPowerType(powerIndex);
|
||||||
|
MANGOS_ASSERT(power != INVALID_POWER);
|
||||||
|
|
||||||
WorldPacket data(SMSG_POWER_UPDATE);
|
WorldPacket data(SMSG_POWER_UPDATE);
|
||||||
data << GetPackGUID();
|
data << GetPackGUID();
|
||||||
data << uint32(1); // iteration count
|
data << uint32(1); // iteration count
|
||||||
data << uint8(powerIndex);
|
data << uint8(power);
|
||||||
data << uint32(val);
|
data << uint32(val);
|
||||||
SendMessageToSet(&data, true);
|
SendMessageToSet(&data, true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1257,7 +1257,9 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
||||||
void ApplyMaxPowerMod(Powers power, uint32 val, bool apply);
|
void ApplyMaxPowerMod(Powers power, uint32 val, bool apply);
|
||||||
|
|
||||||
static uint32 GetPowerIndexByClass(Powers power, uint32 classId);
|
static uint32 GetPowerIndexByClass(Powers power, uint32 classId);
|
||||||
|
static Powers GetPowerTypeByIndex(uint32 index, uint32 classId);
|
||||||
uint32 GetPowerIndex(Powers power) const { return GetPowerIndexByClass(power, getClass()); }
|
uint32 GetPowerIndex(Powers power) const { return GetPowerIndexByClass(power, getClass()); }
|
||||||
|
Powers getPowerType(uint32 index) const { return GetPowerTypeByIndex(index, getClass()); }
|
||||||
|
|
||||||
uint32 GetAttackTime(WeaponAttackType att) const { return (uint32)(GetFloatValue(UNIT_FIELD_BASEATTACKTIME + att) / m_modAttackSpeedPct[att]); }
|
uint32 GetAttackTime(WeaponAttackType att) const { return (uint32)(GetFloatValue(UNIT_FIELD_BASEATTACKTIME + att) / m_modAttackSpeedPct[att]); }
|
||||||
void SetAttackTime(WeaponAttackType att, uint32 val) { SetFloatValue(UNIT_FIELD_BASEATTACKTIME + att, val * m_modAttackSpeedPct[att]); }
|
void SetAttackTime(WeaponAttackType att, uint32 val) { SetFloatValue(UNIT_FIELD_BASEATTACKTIME + att, val * m_modAttackSpeedPct[att]); }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue