diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index d6a0c8a8e..512848107 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -62,7 +62,7 @@ bool LoginQueryHolder::Initialize() res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADFROM, "SELECT guid, account, data, name, race, class, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGROUP, "SELECT leaderGuid FROM group_member WHERE memberGuid ='%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES, "SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid)); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS, "SELECT caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'", GUID_LOPART(m_guid)); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS, "SELECT caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u' ORDER by spell,effect_index", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSPELLS, "SELECT spell,slot,active,disabled FROM character_spell WHERE guid = '%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADQUESTSTATUS, "SELECT quest,status,rewarded,explored,timer,mobcount1,mobcount2,mobcount3,mobcount4,itemcount1,itemcount2,itemcount3,itemcount4 FROM character_queststatus WHERE guid = '%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS,"SELECT quest,time FROM character_queststatus_daily WHERE guid = '%u'", GUID_LOPART(m_guid)); diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 3662ad4e0..d77838cfe 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -531,7 +531,7 @@ ChatCommand * ChatHandler::getCommandTable() { "cometome", SEC_ADMINISTRATOR, false, &ChatHandler::HandleComeToMeCommand, "", NULL }, { "damage", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDamageCommand, "", NULL }, { "combatstop", SEC_GAMEMASTER, false, &ChatHandler::HandleCombatStopCommand, "", NULL }, - { "chardelete", SEC_CONSOLE, true, &ChatHandler::HandleCombatStopCommand, "", NULL }, + { "chardelete", SEC_CONSOLE, true, &ChatHandler::HandleCharacterDeleteCommand, "", NULL }, { "sendmessage", SEC_ADMINISTRATOR, true, &ChatHandler::HandleSendMessageCommand, "", NULL }, { "repairitems", SEC_GAMEMASTER, false, &ChatHandler::HandleRepairitemsCommand, "", NULL }, { "waterwalk", SEC_GAMEMASTER, false, &ChatHandler::HandleWaterwalkCommand, "", NULL }, diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 7323f45da..838e673d7 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -17756,31 +17756,38 @@ void Player::SendAurasForTarget(Unit *target) WorldPacket data(SMSG_AURA_UPDATE_ALL); data.append(target->GetPackGUID()); - for(Unit::AuraMap::const_iterator itr = target->GetAuras().begin(); itr != target->GetAuras().end(); ++itr) + Unit::VisibleAuraMap const *visibleAuras = target->GetVisibleAuras(); + for(Unit::VisibleAuraMap::const_iterator itr = visibleAuras->begin(); itr != visibleAuras->end(); ++itr) { - Aura* aura = itr->second; - if(aura->GetAuraSlot() >= MAX_AURAS || aura->IsPassive() || aura->GetCasterGUID()!=GetGUID()) - continue; - - data << uint8(aura->GetAuraSlot()); - data << uint32(aura->GetId()); - - if(aura->GetId()) + for(uint32 j = 0; j < 3; ++j) { - uint8 auraFlags = aura->GetAuraFlags(); - data << uint8(auraFlags); // flags - data << uint8(aura->GetAuraLevel()); // level - data << uint8(aura->m_procCharges); // charges - - /*if(!(auraFlags & AFLAG_NOT_GUID)) + if(Aura *aura = target->GetAura(itr->second, j)) { - data << uint8(0) // packed GUID of someone (caster?) - }*/ + data << uint8(aura->GetAuraSlot()); + data << uint32(aura->GetId()); - if(auraFlags & AFLAG_DURATION) // include aura duration - { - data << uint32(aura->GetAuraMaxDuration()); - data << uint32(aura->GetAuraDuration()); + if(aura->GetId()) + { + uint8 auraFlags = aura->GetAuraFlags(); + // flags + data << uint8(auraFlags); + // level + data << uint8(aura->GetAuraLevel()); + // charges + data << uint8(aura->m_procCharges); + + if(!(auraFlags & AFLAG_NOT_GUID)) + { + data << uint8(0); // packed GUID of someone (caster?) + } + + if(auraFlags & AFLAG_DURATION) // include aura duration + { + data << uint32(aura->GetAuraMaxDuration()); + data << uint32(aura->GetAuraDuration()); + } + } + break; } } } diff --git a/src/game/SpellAuraDefines.h b/src/game/SpellAuraDefines.h index 977bceb93..47f1b28d0 100644 --- a/src/game/SpellAuraDefines.h +++ b/src/game/SpellAuraDefines.h @@ -18,8 +18,7 @@ #ifndef MANGOS_SPELLAURADEFINES_H #define MANGOS_SPELLAURADEFINES_H -#define MAX_AURAS 56 // probably changes to 64 in WotLK -#define MAX_POSITIVE_AURAS 40 +#define MAX_AURAS 64 // client support up to 255, but it will cause problems with group auras updating enum AURA_FLAGS { @@ -27,14 +26,11 @@ enum AURA_FLAGS AFLAG_EFF_INDEX_0 = 0x01, AFLAG_EFF_INDEX_1 = 0x02, AFLAG_EFF_INDEX_2 = 0x04, - AFLAG_NOT_GUID = 0x08, + AFLAG_NOT_GUID = 0x08, // caster guid? AFLAG_UNK1 = 0x10, // positive? AFLAG_DURATION = 0x20, AFLAG_UNK2 = 0x40, - AFLAG_UNK3 = 0x80, - AFLAG_NEGATIVE = 0x09, - AFLAG_POSITIVE = 0x1F, - AFLAG_MASK = 0xFF + AFLAG_NEGATIVE = 0x80 }; //m_schoolAbsorb diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index c6acb80c4..81b883ae9 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -947,22 +947,13 @@ void Aura::_AddAura() { if(!samespell) // new slot need { - if (IsPositive()) // empty positive slot + if(m_target->GetVisibleAurasCount() < MAX_AURAS) { - for (uint8 i = 0; i < MAX_POSITIVE_AURAS; i++) + Unit::VisibleAuraMap const *visibleAuras = m_target->GetVisibleAuras(); + for(uint8 i = 0; i < MAX_AURAS; ++i) { - if (m_target->GetVisibleAura(i) == 0) - { - slot = i; - break; - } - } - } - else // empty negative slot - { - for (uint8 i = MAX_POSITIVE_AURAS; i < MAX_AURAS; i++) - { - if (m_target->GetVisibleAura(i) == 0) + Unit::VisibleAuraMap::const_iterator itr = visibleAuras->find(i); + if(itr == visibleAuras->end()) { slot = i; break; @@ -978,7 +969,7 @@ void Aura::_AddAura() if(slot < MAX_AURAS) // slot found { SetAura(false); - SetAuraFlags(AFLAG_EFF_INDEX_0 | AFLAG_NOT_GUID | (GetAuraMaxDuration() ? AFLAG_DURATION : AFLAG_NONE) | (IsPositive() ? AFLAG_UNK1 : AFLAG_NONE)); + SetAuraFlags((1 << GetEffIndex()) | AFLAG_NOT_GUID | (GetAuraMaxDuration() ? AFLAG_DURATION : AFLAG_NONE) | (IsPositive() ? AFLAG_NONE : AFLAG_NEGATIVE)); SetAuraLevel(caster ? caster->getLevel() : sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)); UpdateAuraCharges(); SendAuraUpdate(false); @@ -1135,10 +1126,10 @@ void Aura::SendAuraUpdate(bool remove) data << uint8(GetAuraLevel()); data << uint8(GetAuraCharges()); - /*if(!(auraFlags & AFLAG_NOT_GUID)) + if(!(auraFlags & AFLAG_NOT_GUID)) { data << uint8(0); // pguid - }*/ + } if(auraFlags & AFLAG_DURATION) { diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 5c3eadc8d..355e122ed 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -184,8 +184,6 @@ Unit::Unit() m_ShapeShiftFormSpellId = 0; m_canModifyStats = false; - for (int i = 0; i < MAX_AURAS; ++i) - m_visibleAuras[i] = 0; for (int i = 0; i < MAX_SPELL_IMMUNITY; i++) m_spellImmune[i].clear(); for (int i = 0; i < UNIT_MOD_END; i++) diff --git a/src/game/Unit.h b/src/game/Unit.h index 3dfcfdcb8..c766bea1e 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -716,6 +716,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject typedef std::list Diminishing; typedef std::set AuraTypeSet; typedef std::set ComboPointHolderSet; + typedef std::map VisibleAuraMap; virtual ~Unit ( ); @@ -1155,8 +1156,29 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void removeHatedBy(HostilReference* /*pHostilReference*/ ) { /* nothing to do yet */ } HostilRefManager& getHostilRefManager() { return m_HostilRefManager; } - uint32 GetVisibleAura(uint32 slot) { return m_visibleAuras[slot]; } - void SetVisibleAura(uint32 slot, uint32 spellid) { m_visibleAuras[slot] = spellid; } + uint32 GetVisibleAura(uint8 slot) + { + VisibleAuraMap::iterator itr = m_visibleAuras.find(slot); + if(itr != m_visibleAuras.end()) + return itr->second; + return 0; + } + void SetVisibleAura(uint8 slot, uint32 spellid) + { + if(spellid == 0) + { + VisibleAuraMap::iterator itr = m_visibleAuras.find(slot); + if(itr != m_visibleAuras.end()) + { + m_visibleAuras.erase(itr); + return; + } + } + else + m_visibleAuras[slot] = spellid; + } + VisibleAuraMap const *GetVisibleAuras() { return &m_visibleAuras; } + uint8 GetVisibleAurasCount() { return m_visibleAuras.size(); } Aura* GetAura(uint32 spellId, uint32 effindex); AuraMap & GetAuras() { return m_Auras; } @@ -1330,7 +1352,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject float m_weaponDamage[MAX_ATTACK][2]; bool m_canModifyStats; //std::list< spellEffectPair > AuraSpells[TOTAL_AURAS]; // TODO: use this if ok for mem - uint32 m_visibleAuras[MAX_AURAS]; + VisibleAuraMap m_visibleAuras; float m_speed_rate[MAX_MOVE_TYPE];