Core/Units: Fixed setting power fields from regeneration
Signed-off-by: Shauren <shauren.trinity@gmail.com>
This commit is contained in:
1 parent
8fe7fd4bd5
commit
38dbea7583
3 files changed
+24
-18
No files matched your search
@@ -836,7 +836,7 @@ Player::Player(WorldSession* session): Unit(true), m_achievementMgr(this), m_rep
|
||||
|
||||
m_ChampioningFaction = 0;
|
||||
|
||||
for (uint8 i = 0; i < MAX_POWERS; ++i)
|
||||
for (uint8 i = 0; i < MAX_POWERS_PER_CLASS; ++i)
|
||||
m_powerFraction[i] = 0;
|
||||
|
||||
isDebugAreaTriggers = false;
|
||||
@@ -846,7 +846,7 @@ Player::Player(WorldSession* session): Unit(true), m_achievementMgr(this), m_rep
|
||||
m_SeasonalQuestChanged = false;
|
||||
|
||||
SetPendingBind(0, 0);
|
||||
|
||||
|
||||
_activeCheats = CHEAT_NONE;
|
||||
|
||||
memset(_voidStorageItems, 0, VOID_STORAGE_MAX_SLOT * sizeof(VoidStorageItem*));
|
||||
@@ -2566,6 +2566,11 @@ void Player::Regenerate(Powers power)
|
||||
if (HasAuraTypeWithValue(SPELL_AURA_PREVENT_REGENERATE_POWER, power))
|
||||
return;
|
||||
|
||||
// Skip regeneration for power type we cannot have
|
||||
uint32 powerIndex = GetPowerIndexByClass(power, getClass());
|
||||
if (powerIndex == MAX_POWERS)
|
||||
return;
|
||||
|
||||
float addvalue = 0.0f;
|
||||
|
||||
// Powers now benefit from haste.
|
||||
@@ -2648,7 +2653,7 @@ void Player::Regenerate(Powers power)
|
||||
else
|
||||
return;
|
||||
|
||||
addvalue += m_powerFraction[power];
|
||||
addvalue += m_powerFraction[powerIndex];
|
||||
uint32 integerValue = uint32(fabs(addvalue));
|
||||
|
||||
if (addvalue < 0.0f)
|
||||
@@ -2656,12 +2661,12 @@ void Player::Regenerate(Powers power)
|
||||
if (curValue > integerValue)
|
||||
{
|
||||
curValue -= integerValue;
|
||||
m_powerFraction[power] = addvalue + integerValue;
|
||||
m_powerFraction[powerIndex] = addvalue + integerValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
curValue = 0;
|
||||
m_powerFraction[power] = 0;
|
||||
m_powerFraction[powerIndex] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2671,15 +2676,16 @@ void Player::Regenerate(Powers power)
|
||||
if (curValue > maxValue)
|
||||
{
|
||||
curValue = maxValue;
|
||||
m_powerFraction[power] = 0;
|
||||
m_powerFraction[powerIndex] = 0;
|
||||
}
|
||||
else
|
||||
m_powerFraction[power] = addvalue - integerValue;
|
||||
m_powerFraction[powerIndex] = addvalue - integerValue;
|
||||
}
|
||||
|
||||
if (m_regenTimerCount >= 2000)
|
||||
SetPower(power, curValue);
|
||||
else
|
||||
UpdateUInt32Value(UNIT_FIELD_POWER1 + power, curValue);
|
||||
UpdateUInt32Value(UNIT_FIELD_POWER1 + powerIndex, curValue);
|
||||
}
|
||||
|
||||
void Player::RegenerateHealth()
|
||||
@@ -3105,7 +3111,7 @@ void Player::GiveLevel(uint8 level)
|
||||
sObjectMgr->GetPlayerClassLevelInfo(getClass(), level, basehp, basemana);
|
||||
|
||||
// send levelup info to client
|
||||
WorldPacket data(SMSG_LEVELUP_INFO, (4+4+MAX_STORED_POWERS*4+MAX_STATS*4));
|
||||
WorldPacket data(SMSG_LEVELUP_INFO, (4+4+MAX_POWERS_PER_CLASS*4+MAX_STATS*4));
|
||||
data << uint32(level);
|
||||
data << uint32(int32(basehp) - int32(GetCreateHealth()));
|
||||
// for (int i = 0; i < MAX_STORED_POWERS; ++i) // Powers loop (0-10)
|
||||
@@ -17230,12 +17236,12 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
|
||||
uint32 savedPower = fields[47+loadedPowers].GetUInt32();
|
||||
uint32 maxPower = GetUInt32Value(UNIT_FIELD_MAXPOWER1 + loadedPowers);
|
||||
SetPower(Powers(i), (savedPower > maxPower) ? maxPower : savedPower);
|
||||
if (++loadedPowers >= MAX_STORED_POWERS)
|
||||
if (++loadedPowers >= MAX_POWERS_PER_CLASS)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (; loadedPowers < MAX_STORED_POWERS; ++loadedPowers)
|
||||
for (; loadedPowers < MAX_POWERS_PER_CLASS; ++loadedPowers)
|
||||
SetUInt32Value(UNIT_FIELD_POWER1 + loadedPowers, 0);
|
||||
|
||||
SetPower(POWER_ECLIPSE, 0);
|
||||
@@ -18740,12 +18746,12 @@ void Player::SaveToDB(bool create /*=false*/)
|
||||
if (GetPowerIndexByClass(Powers(i), getClass()) != MAX_POWERS)
|
||||
{
|
||||
stmt->setUInt32(index++, GetUInt32Value(UNIT_FIELD_POWER1 + storedPowers));
|
||||
if (++storedPowers >= MAX_STORED_POWERS)
|
||||
if (++storedPowers >= MAX_POWERS_PER_CLASS)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (; storedPowers < MAX_STORED_POWERS; ++storedPowers)
|
||||
for (; storedPowers < MAX_POWERS_PER_CLASS; ++storedPowers)
|
||||
stmt->setUInt32(index++, 0);
|
||||
|
||||
stmt->setUInt32(index++, GetSession()->GetLatency());
|
||||
@@ -18860,12 +18866,12 @@ void Player::SaveToDB(bool create /*=false*/)
|
||||
if (GetPowerIndexByClass(Powers(i), getClass()) != MAX_POWERS)
|
||||
{
|
||||
stmt->setUInt32(index++, GetUInt32Value(UNIT_FIELD_POWER1 + storedPowers));
|
||||
if (++storedPowers >= MAX_STORED_POWERS)
|
||||
if (++storedPowers >= MAX_POWERS_PER_CLASS)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (; storedPowers < MAX_STORED_POWERS; ++storedPowers)
|
||||
for (; storedPowers < MAX_POWERS_PER_CLASS; ++storedPowers)
|
||||
stmt->setUInt32(index++, 0);
|
||||
|
||||
stmt->setUInt32(index++, GetSession()->GetLatency());
|
||||
@@ -19571,7 +19577,7 @@ void Player::_SaveStats(SQLTransaction& trans)
|
||||
stmt->setUInt32(index++, GetGUIDLow());
|
||||
stmt->setUInt32(index++, GetMaxHealth());
|
||||
|
||||
for (uint8 i = 0; i < MAX_STORED_POWERS; ++i)
|
||||
for (uint8 i = 0; i < MAX_POWERS_PER_CLASS; ++i)
|
||||
stmt->setUInt32(index++, GetMaxPower(Powers(i)));
|
||||
|
||||
for (uint8 i = 0; i < MAX_STATS; ++i)
|
||||
|
||||
@@ -2644,7 +2644,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
uint32 m_regenTimerCount;
|
||||
uint32 m_holyPowerRegenTimerCount;
|
||||
uint32 m_focusRegenTimerCount;
|
||||
float m_powerFraction[MAX_POWERS];
|
||||
float m_powerFraction[MAX_POWERS_PER_CLASS];
|
||||
uint32 m_contestedPvPTimer;
|
||||
|
||||
/*********************************************************/
|
||||
|
||||
@@ -191,7 +191,7 @@ enum Powers
|
||||
POWER_HEALTH = 0xFFFFFFFE // (-2 as signed value)
|
||||
};
|
||||
|
||||
#define MAX_STORED_POWERS 5
|
||||
#define MAX_POWERS_PER_CLASS 5
|
||||
|
||||
enum SpellSchools
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user