All pastes #338763 Raw Edit

Mine

public cpp v1 · immutable
·published 2007-02-03 17:59 UTC
rendered paste body
uint32 Unit::AddAuraVisual(uint32 spellid, uint32 count, bool positive){    int32 free = -1;    uint32 start = positive ? 0 : MAX_POSITIVE_AURAS;    uint32 end_  = positive ? MAX_POSITIVE_AURAS : MAX_AURAS;    for(uint32 x = start; x < end_; ++x)    {        if(free == -1 && m_uint32Values[UNIT_FIELD_AURA+x] == 0)            free = x;        if(m_uint32Values[UNIT_FIELD_AURA+x] == spellid)        {            // Increase count of this aura.            ModAuraStackCount(x, count);            return free;        }    }    if(free == -1) return 0xFF;    uint8 flagslot = free >> 3;    uint32 value = GetUInt32Value((uint16)(UNIT_FIELD_AURAFLAGS + flagslot));    uint8 aurapos = (free & 7) << 2;    uint32 value1 = (uint32)AFLAG_SET << aurapos;    value |= value1;    SetUInt32Value((uint16)(UNIT_FIELD_AURAFLAGS + flagslot), value);    SetUInt32Value(UNIT_FIELD_AURA + free, spellid);    ModAuraStackCount(free, 1);        return free;}void Unit::RemoveAuraVisual(uint32 spellid, uint32 count){    for(uint32 x = 0; x < MAX_AURAS; ++x)    {        if(m_uint32Values[UNIT_FIELD_AURA+x] == spellid)        {            // Decrease count of this aura.            if(ModAuraStackCount(x, -(int32)count) == 0)            {                // Aura has been removed completely.                uint8 flagslot = x >> 3;                uint32 value = GetUInt32Value((uint16)(UNIT_FIELD_AURAFLAGS + flagslot));                uint8 aurapos = (x & 7) << 2;                uint32 value1 = ~( (uint32)AFLAG_SET << aurapos );                value &= value1;                SetUInt32Value(UNIT_FIELD_AURAFLAGS + flagslot,value);                SetUInt32Value(UNIT_FIELD_AURA + x, 0);            }                    }    }}uint32 Unit::ModAuraStackCount(uint32 slot, int32 count){    uint32 index = (slot / 4);    uint32 byte  = (slot % 4);    uint32 val   = m_uint32Values[UNIT_FIELD_AURAAPPLICATIONS+index];    // shouldn't happen    uint32 ac;    if(count < 0 && m_auraStackCount[slot] < abs(count))    {        m_auraStackCount[slot] = ac = 0;    }    else    {        m_auraStackCount[slot] += count;        ac = (m_auraStackCount[slot] > 0) ? m_auraStackCount[slot] - 1 : 0;    }    if(byte == 0)        val = (val & 0xFFFFFF00) | (ac << byte * 8);    else if(byte == 1)        val = (val & 0xFFFF00FF) | (ac << byte * 8);    else if(byte == 2)        val = (val & 0xFF00FFFF) | (ac << byte * 8);    else if(byte == 3)        val = (val & 0x00FFFFFF) | (ac << byte * 8);    SetUInt32Value(UNIT_FIELD_AURAAPPLICATIONS+index, val);    return m_auraStackCount[slot];}