Fix a crash caused by spell with CAST_FLAG_RUNE_LIST casted by a creature mover. Thanks to Vasago.
This commit is contained in:
@@ -3834,19 +3834,23 @@ void Spell::SendSpellGo()
|
|||||||
|
|
||||||
if (castFlags & CAST_FLAG_RUNE_LIST) // rune cooldowns list
|
if (castFlags & CAST_FLAG_RUNE_LIST) // rune cooldowns list
|
||||||
{
|
{
|
||||||
Player* player = m_caster->ToPlayer();
|
//TODO: There is a crash caused by a spell with CAST_FLAG_RUNE_LIST casted by a creature
|
||||||
uint8 runeMaskInitial = m_runesState;
|
//The creature is the mover of a player, so HandleCastSpellOpcode uses it as the caster
|
||||||
uint8 runeMaskAfterCast = player->GetRunesState();
|
if (Player* player = m_caster->ToPlayer())
|
||||||
data << uint8(runeMaskInitial); // runes state before
|
|
||||||
data << uint8(runeMaskAfterCast); // runes state after
|
|
||||||
for (uint8 i = 0; i < MAX_RUNES; ++i)
|
|
||||||
{
|
{
|
||||||
uint8 mask = (1 << i);
|
uint8 runeMaskInitial = m_runesState;
|
||||||
if (mask & runeMaskInitial && !(mask & runeMaskAfterCast)) // usable before andon cooldown now...
|
uint8 runeMaskAfterCast = player->GetRunesState();
|
||||||
|
data << uint8(runeMaskInitial); // runes state before
|
||||||
|
data << uint8(runeMaskAfterCast); // runes state after
|
||||||
|
for (uint8 i = 0; i < MAX_RUNES; ++i)
|
||||||
{
|
{
|
||||||
// float casts ensure the division is performed on floats as we need float result
|
uint8 mask = (1 << i);
|
||||||
float baseCd = float(player->GetRuneBaseCooldown(i));
|
if (mask & runeMaskInitial && !(mask & runeMaskAfterCast)) // usable before andon cooldown now...
|
||||||
data << uint8((baseCd - float(player->GetRuneCooldown(i))) / baseCd * 255); // rune cooldown passed
|
{
|
||||||
|
// float casts ensure the division is performed on floats as we need float result
|
||||||
|
float baseCd = float(player->GetRuneBaseCooldown(i));
|
||||||
|
data << uint8((baseCd - float(player->GetRuneCooldown(i))) / baseCd * 255); // rune cooldown passed
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user