From 1b1d0136237072382504fb53641155ae08c92f75 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Tue, 18 Aug 2009 01:01:00 +0400 Subject: [PATCH 1/4] [8380] Use CastSpell instead create triggered channaled spell in Spell::EffectTriggerRitualOfSummoning. --- src/game/SpellEffects.cpp | 9 +-------- src/shared/revision_nr.h | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 60ac24616..a153c784e 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -1931,15 +1931,8 @@ void Spell::EffectTriggerRitualOfSummoning(uint32 i) } finish(); - Spell *spell = new Spell(m_caster, spellInfo, true); - - SpellCastTargets targets; - targets.setUnitTarget( unitTarget); - spell->prepare(&targets); - - m_caster->SetCurrentCastedSpell(spell); - spell->m_selfContainer = &(m_caster->m_currentSpells[spell->GetCurrentContainer()]); + m_caster->CastSpell(unitTarget,spellInfo,false); } void Spell::EffectForceCast(uint32 i) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 1f4e0f53f..05e1c9bf5 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8379" + #define REVISION_NR "8380" #endif // __REVISION_NR_H__ From 74d27294aa01ea6de02dc5304fa117a099de7b2f Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Tue, 18 Aug 2009 02:07:39 +0400 Subject: [PATCH 2/4] [8381] Some refactoring work in Unit::m_currentSpells code. * Restrict access, use enum args, move some repeated code parts to function. * Make m_selfContainer set only part of Unit::SetCurrentCastedSpell --- src/game/GameObject.cpp | 17 ++++------------- src/game/Player.cpp | 18 +++++++++--------- src/game/Spell.cpp | 1 - src/game/Spell.h | 1 + src/game/SpellAuras.cpp | 32 ++++++++++++-------------------- src/game/SpellEffects.cpp | 11 ++++++----- src/game/SpellHandler.cpp | 6 +++--- src/game/Unit.cpp | 29 +++++++++++++++++++++-------- src/game/Unit.h | 22 +++++++++++++--------- src/shared/revision_nr.h | 2 +- 10 files changed, 70 insertions(+), 69 deletions(-) diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 2f77ee9c3..ad8c23ea6 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -240,11 +240,7 @@ void GameObject::Update(uint32 /*p_time*/) Unit* caster = GetOwner(); if(caster && caster->GetTypeId()==TYPEID_PLAYER) { - if(caster->m_currentSpells[CURRENT_CHANNELED_SPELL]) - { - caster->m_currentSpells[CURRENT_CHANNELED_SPELL]->SendChannelUpdate(0); - caster->m_currentSpells[CURRENT_CHANNELED_SPELL]->finish(false); - } + caster->FinishSpell(CURRENT_CHANNELED_SPELL); WorldPacket data(SMSG_FISH_NOT_HOOKED,0); ((Player*)caster)->GetSession()->SendPacket(&data); @@ -1065,11 +1061,7 @@ void GameObject::Use(Unit* user) } } - if(player->m_currentSpells[CURRENT_CHANNELED_SPELL]) - { - player->m_currentSpells[CURRENT_CHANNELED_SPELL]->SendChannelUpdate(0); - player->m_currentSpells[CURRENT_CHANNELED_SPELL]->finish(); - } + player->FinishSpell(CURRENT_CHANNELED_SPELL); return; } @@ -1100,7 +1092,7 @@ void GameObject::Use(Unit* user) // in case summoning ritual caster is GO creator spellCaster = caster; - if(!caster->m_currentSpells[CURRENT_CHANNELED_SPELL]) + if(!caster->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) return; spellId = info->summoningRitual.spellId; @@ -1113,8 +1105,7 @@ void GameObject::Use(Unit* user) } // finish spell - caster->m_currentSpells[CURRENT_CHANNELED_SPELL]->SendChannelUpdate(0); - caster->m_currentSpells[CURRENT_CHANNELED_SPELL]->finish(); + player->FinishSpell(CURRENT_CHANNELED_SPELL); // can be deleted now SetLootState(GO_JUST_DEACTIVATED); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 46bbf5a4c..32d63d8b8 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -16896,13 +16896,15 @@ bool Player::ActivateTaxiPathTo(std::vector const& nodes, Creature* npc if( m_ShapeShiftFormSpellId && m_form != FORM_BATTLESTANCE && m_form != FORM_BERSERKERSTANCE && m_form != FORM_DEFENSIVESTANCE && m_form != FORM_SHADOW ) RemoveAurasDueToSpell(m_ShapeShiftFormSpellId); - if(m_currentSpells[CURRENT_GENERIC_SPELL] && m_currentSpells[CURRENT_GENERIC_SPELL]->m_spellInfo->Id != spellid) - InterruptSpell(CURRENT_GENERIC_SPELL,false); + if (Spell* spell = GetCurrentSpell(CURRENT_GENERIC_SPELL)) + if (spell->m_spellInfo->Id != spellid) + InterruptSpell(CURRENT_GENERIC_SPELL,false); InterruptSpell(CURRENT_AUTOREPEAT_SPELL,false); - if(m_currentSpells[CURRENT_CHANNELED_SPELL] && m_currentSpells[CURRENT_CHANNELED_SPELL]->m_spellInfo->Id != spellid) - InterruptSpell(CURRENT_CHANNELED_SPELL,true); + if (Spell* spell = GetCurrentSpell(CURRENT_CHANNELED_SPELL)) + if (spell->m_spellInfo->Id != spellid) + InterruptSpell(CURRENT_CHANNELED_SPELL,true); } uint32 sourcenode = nodes[0]; @@ -18852,11 +18854,9 @@ void Player::RemoveItemDependentAurasAndCasts( Item * pItem ) // currently casted spells can be dependent from item for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i) - { - if( m_currentSpells[i] && m_currentSpells[i]->getState()!=SPELL_STATE_DELAYED && - !HasItemFitToSpellReqirements(m_currentSpells[i]->m_spellInfo,pItem) ) - InterruptSpell(i); - } + if (Spell* spell = GetCurrentSpell(CurrentSpellTypes(i))) + if (spell->getState()!=SPELL_STATE_DELAYED && !HasItemFitToSpellReqirements(spell->m_spellInfo,pItem) ) + InterruptSpell(CurrentSpellTypes(i)); } uint32 Player::GetResurrectionSpellId() diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 6d350265f..19362bcef 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -2265,7 +2265,6 @@ void Spell::prepare(SpellCastTargets const* targets, Aura* triggeredByAura) else { m_caster->SetCurrentCastedSpell( this ); - m_selfContainer = &(m_caster->m_currentSpells[GetCurrentContainer()]); SendSpellStart(); } } diff --git a/src/game/Spell.h b/src/game/Spell.h index 288a0cf15..8e8dcf412 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -210,6 +210,7 @@ class Spell { friend struct MaNGOS::SpellNotifierPlayer; friend struct MaNGOS::SpellNotifierCreatureAndPlayer; + friend void Unit::SetCurrentCastedSpell( Spell * pSpell ); public: void EffectNULL(uint32 ); diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index c35188466..1d3e36181 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -3483,8 +3483,8 @@ void Aura::HandleFeignDeath(bool apply, bool Real) m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION); // prevent interrupt message - if(m_caster_guid==m_target->GetGUID() && m_target->m_currentSpells[CURRENT_GENERIC_SPELL]) - m_target->m_currentSpells[CURRENT_GENERIC_SPELL]->finish(); + if (m_caster_guid==m_target->GetGUID()) + m_target->FinishSpell(CURRENT_GENERIC_SPELL,false); m_target->InterruptNonMeleeSpells(true); m_target->getHostilRefManager().deleteReferences(); } @@ -3905,9 +3905,11 @@ void Aura::HandleAuraModSilence(bool apply, bool Real) { m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED); // Stop cast only spells vs PreventionType == SPELL_PREVENTION_TYPE_SILENCE - for (uint32 i = CURRENT_MELEE_SPELL; i < CURRENT_MAX_SPELL;i++) - if (m_target->m_currentSpells[i] && m_target->m_currentSpells[i]->m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE) - m_target->InterruptSpell(i, false); // Stop spells on prepare or casting state + for (uint32 i = CURRENT_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i) + if (Spell* spell = m_target->GetCurrentSpell(CurrentSpellTypes(i))) + if(spell->m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE) + // Stop spells on prepare or casting state + m_target->InterruptSpell(CurrentSpellTypes(i), false); } else { @@ -6268,13 +6270,10 @@ void Aura::PeriodicTick() int32 new_damage = pCaster->DealDamage(m_target, pdamage, &cleanDamage, DOT, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), false); if (!m_target->isAlive() && pCaster->IsNonMeleeSpellCasted(false)) - { for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i) - { - if (pCaster->m_currentSpells[i] && pCaster->m_currentSpells[i]->m_spellInfo->Id == GetId()) - pCaster->m_currentSpells[i]->cancel(); - } - } + if (Spell* spell = pCaster->GetCurrentSpell(CurrentSpellTypes(i))) + if (spell->m_spellInfo->Id == GetId()) + spell->cancel(); if(Player *modOwner = pCaster->GetSpellModOwner()) @@ -6348,15 +6347,8 @@ void Aura::PeriodicTick() pCaster->RemoveAurasDueToSpell(GetId()); // finish current generic/channeling spells, don't affect autorepeat - if(pCaster->m_currentSpells[CURRENT_GENERIC_SPELL]) - { - pCaster->m_currentSpells[CURRENT_GENERIC_SPELL]->finish(); - } - if(pCaster->m_currentSpells[CURRENT_CHANNELED_SPELL]) - { - pCaster->m_currentSpells[CURRENT_CHANNELED_SPELL]->SendChannelUpdate(0); - pCaster->m_currentSpells[CURRENT_CHANNELED_SPELL]->finish(); - } + pCaster->FinishSpell(CURRENT_GENERIC_SPELL); + pCaster->FinishSpell(CURRENT_CHANNELED_SPELL); } else { diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index a153c784e..fd987c8d8 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -4681,15 +4681,16 @@ void Spell::EffectInterruptCast(uint32 /*i*/) // TODO: not all spells that used this effect apply cooldown at school spells // also exist case: apply cooldown to interrupted cast only and to all spells - for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++) + for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i) { - if (unitTarget->m_currentSpells[i]) + if (Spell* spell = unitTarget->GetCurrentSpell(CurrentSpellTypes(i))) { + SpellEntry const* curSpellInfo = spell->m_spellInfo; // check if we can interrupt spell - if ( unitTarget->m_currentSpells[i]->m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_INTERRUPT && unitTarget->m_currentSpells[i]->m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE ) + if ((curSpellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_INTERRUPT) && curSpellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE ) { - unitTarget->ProhibitSpellScholl(GetSpellSchoolMask(unitTarget->m_currentSpells[i]->m_spellInfo), GetSpellDuration(m_spellInfo)); - unitTarget->InterruptSpell(i,false); + unitTarget->ProhibitSpellScholl(GetSpellSchoolMask(curSpellInfo), GetSpellDuration(m_spellInfo)); + unitTarget->InterruptSpell(CurrentSpellTypes(i),false); } } } diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp index f616c8266..ec9fb6cfd 100644 --- a/src/game/SpellHandler.cpp +++ b/src/game/SpellHandler.cpp @@ -402,9 +402,9 @@ void WorldSession::HandleCancelAuraOpcode( WorldPacket& recvPacket) // channeled spell case (it currently casted then) if (IsChanneledSpell(spellInfo)) { - if (_player->m_currentSpells[CURRENT_CHANNELED_SPELL] && - _player->m_currentSpells[CURRENT_CHANNELED_SPELL]->m_spellInfo->Id==spellId) - _player->InterruptSpell(CURRENT_CHANNELED_SPELL); + if (Spell* curSpell = _player->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) + if (curSpell->m_spellInfo->Id==spellId) + _player->InterruptSpell(CURRENT_CHANNELED_SPELL); return; } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index a118ead6b..50717b657 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -816,14 +816,16 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa if (i == CURRENT_CHANNELED_SPELL) continue; - if(Spell* spell = pVictim->m_currentSpells[i]) + if(Spell* spell = pVictim->GetCurrentSpell(CurrentSpellTypes(i))) + { if(spell->getState() == SPELL_STATE_PREPARING) { if(spell->m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_ABORT_ON_DMG) - pVictim->InterruptSpell(i); + pVictim->InterruptSpell(CurrentSpellTypes(i)); else spell->Delayed(); } + } } } @@ -879,7 +881,7 @@ void Unit::CastStop(uint32 except_spellid) { for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i) if (m_currentSpells[i] && m_currentSpells[i]->m_spellInfo->Id!=except_spellid) - InterruptSpell(i,false); + InterruptSpell(CurrentSpellTypes(i),false); } void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem, Aura* triggeredByAura, uint64 originalCaster) @@ -2705,13 +2707,9 @@ float Unit::MeleeMissChanceCalc(const Unit *pVictim, WeaponAttackType attType) c } } if (isNormal || m_currentSpells[CURRENT_MELEE_SPELL]) - { misschance = 5.0f; - } else - { misschance = 24.0f; - } } // PvP : PvE melee misschances per leveldif > 2 @@ -3107,9 +3105,11 @@ void Unit::SetCurrentCastedSpell( Spell * pSpell ) // set new current spell m_currentSpells[CSpellType] = pSpell; pSpell->SetReferencedFromCurrent(true); + + pSpell->m_selfContainer = &(m_currentSpells[pSpell->GetCurrentContainer()]); } -void Unit::InterruptSpell(uint32 spellType, bool withDelayed) +void Unit::InterruptSpell(CurrentSpellTypes spellType, bool withDelayed) { assert(spellType < CURRENT_MAX_SPELL); @@ -3134,6 +3134,19 @@ void Unit::InterruptSpell(uint32 spellType, bool withDelayed) } } +void Unit::FinishSpell(CurrentSpellTypes spellType, bool ok /*= true*/) +{ + Spell* spell = m_currentSpells[spellType]; + if (!spell) + return; + + if (spellType == CURRENT_CHANNELED_SPELL) + spell->SendChannelUpdate(0); + + spell->finish(ok); +} + + bool Unit::IsNonMeleeSpellCasted(bool withDelayed, bool skipChanneled, bool skipAutorepeat) const { // We don't do loop here to explicitly show that melee spell is excluded. diff --git a/src/game/Unit.h b/src/game/Unit.h index d4ca820a5..6312968b0 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -710,14 +710,16 @@ struct DeclinedName enum CurrentSpellTypes { - CURRENT_MELEE_SPELL = 0, - CURRENT_FIRST_NON_MELEE_SPELL = 1, // just counter - CURRENT_GENERIC_SPELL = 1, - CURRENT_AUTOREPEAT_SPELL = 2, - CURRENT_CHANNELED_SPELL = 3, - CURRENT_MAX_SPELL = 4 // just counter + CURRENT_MELEE_SPELL = 0, + CURRENT_GENERIC_SPELL = 1, + CURRENT_AUTOREPEAT_SPELL = 2, + CURRENT_CHANNELED_SPELL = 3 }; +#define CURRENT_FIRST_NON_MELEE_SPELL 1 +#define CURRENT_MAX_SPELL 4 + + enum ActiveStates { ACT_PASSIVE = 0x01, // 0x01 - passive @@ -1249,7 +1251,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void SetCurrentCastedSpell(Spell * pSpell); virtual void ProhibitSpellScholl(SpellSchoolMask /*idSchoolMask*/, uint32 /*unTimeMs*/ ) { } - void InterruptSpell(uint32 spellType, bool withDelayed = true); + void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed = true); + void FinishSpell(CurrentSpellTypes spellType, bool ok = true); // set withDelayed to true to account delayed spells as casted // delayed+channeled spells are always accounted as casted @@ -1260,10 +1263,9 @@ class MANGOS_DLL_SPEC Unit : public WorldObject // delayed+channeled spells are always interrupted void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid = 0); + Spell* GetCurrentSpell(CurrentSpellTypes spellType) const { return m_currentSpells[spellType]; } Spell* FindCurrentSpellBySpellId(uint32 spell_id) const; - Spell* m_currentSpells[CURRENT_MAX_SPELL]; - uint32 m_addDmgOnce; uint64 m_TotemSlot[MAX_TOTEM]; uint64 m_ObjectSlot[4]; @@ -1557,6 +1559,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject uint32 m_CombatTimer; uint32 m_lastManaUse; // msecs + Spell* m_currentSpells[CURRENT_MAX_SPELL]; + UnitVisibility m_Visibility; Diminishing m_Diminishing; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 05e1c9bf5..4071b140f 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8380" + #define REVISION_NR "8381" #endif // __REVISION_NR_H__ From 2b534cbc23b7c4ef63b400b2a3befe7cf45420a5 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Tue, 18 Aug 2009 03:45:49 +0400 Subject: [PATCH 3/4] [8382] Implement ByteArray functions for skip read of fields not needed for server in received packets. * Use this fucntions in some case. * Change some packets to form: read fields first check later for better control recieved packets structure. * Fix CMSG_STAND_STATE_CHANGE packet structure to more correct. --- src/game/BattleGroundHandler.cpp | 10 ++++---- src/game/CalendarHandler.cpp | 22 +++++++---------- src/game/GuildHandler.cpp | 6 +++-- src/game/MiscHandler.cpp | 41 ++++++++++++++++++++------------ src/game/QueryHandler.cpp | 2 ++ src/game/SpellHandler.cpp | 5 ++-- src/game/VoiceChatHandler.cpp | 4 +++- src/shared/ByteBuffer.h | 26 ++++++++++++++++++++ src/shared/revision_nr.h | 2 +- 9 files changed, 77 insertions(+), 41 deletions(-) diff --git a/src/game/BattleGroundHandler.cpp b/src/game/BattleGroundHandler.cpp index 181dcfd08..9a080c53f 100644 --- a/src/game/BattleGroundHandler.cpp +++ b/src/game/BattleGroundHandler.cpp @@ -610,11 +610,7 @@ void WorldSession::HandleAreaSpiritHealerQueueOpcode( WorldPacket & recv_data ) void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data ) { sLog.outDebug("WORLD: CMSG_BATTLEMASTER_JOIN_ARENA"); - recv_data.hexlike(); - - // ignore if we already in BG or BG queue - if (_player->InBattleGround()) - return; + //recv_data.hexlike(); uint64 guid; // arena Battlemaster guid uint8 arenaslot; // 2v2, 3v3 or 5v5 @@ -624,6 +620,10 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data ) recv_data >> guid >> arenaslot >> asGroup >> isRated; + // ignore if we already in BG or BG queue + if (_player->InBattleGround()) + return; + Creature *unit = GetPlayer()->GetMap()->GetCreature(guid); if (!unit) return; diff --git a/src/game/CalendarHandler.cpp b/src/game/CalendarHandler.cpp index 4d3f9f074..b7a7ca6a4 100644 --- a/src/game/CalendarHandler.cpp +++ b/src/game/CalendarHandler.cpp @@ -26,8 +26,7 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket &recv_data) { - sLog.outDebug("WORLD: CMSG_CALENDAR_GET_CALENDAR"); - recv_data.hexlike(); + sLog.outDebug("WORLD: CMSG_CALENDAR_GET_CALENDAR"); // empty time_t cur_time = time(NULL); @@ -74,27 +73,23 @@ void WorldSession::HandleCalendarGetEvent(WorldPacket &recv_data) { sLog.outDebug("WORLD: CMSG_CALENDAR_GET_EVENT"); recv_data.hexlike(); - //uint64 unk1; - //recv_data >> (uint64)unk1; + recv_data.read_skip(); // unk } void WorldSession::HandleCalendarGuildFilter(WorldPacket &recv_data) { sLog.outDebug("WORLD: CMSG_CALENDAR_GUILD_FILTER"); recv_data.hexlike(); - //uint32 unk1, unk2, unk3; - //recv_data >> (uint32)unk1; - //recv_data >> (uint32)unk2; - //recv_data >> (uint32)unk3; + recv_data.read_skip(); // unk1 + recv_data.read_skip(); // unk2 + recv_data.read_skip(); // unk3 } void WorldSession::HandleCalendarArenaTeam(WorldPacket &recv_data) { sLog.outDebug("WORLD: CMSG_CALENDAR_ARENA_TEAM"); recv_data.hexlike(); - //uint32 unk; - //recv_data >> (uint32)unk; - + recv_data.read_skip(); // unk } void WorldSession::HandleCalendarAddEvent(WorldPacket &recv_data) @@ -241,10 +236,9 @@ void WorldSession::HandleCalendarComplain(WorldPacket &recv_data) //recv_data >> uint64 } -void WorldSession::HandleCalendarGetNumPending(WorldPacket &recv_data) +void WorldSession::HandleCalendarGetNumPending(WorldPacket & /*recv_data*/) { - sLog.outDebug("WORLD: CMSG_CALENDAR_GET_NUM_PENDING"); - recv_data.hexlike(); + sLog.outDebug("WORLD: CMSG_CALENDAR_GET_NUM_PENDING"); // empty WorldPacket data(SMSG_CALENDAR_SEND_NUM_PENDING, 4); data << uint32(0); // 0 - no pending invites, 1 - some pending invites diff --git a/src/game/GuildHandler.cpp b/src/game/GuildHandler.cpp index 26bb22a35..b950a80eb 100644 --- a/src/game/GuildHandler.cpp +++ b/src/game/GuildHandler.cpp @@ -608,8 +608,6 @@ void WorldSession::HandleGuildRankOpcode(WorldPacket& recvPacket) std::string rankname; uint32 rankId; uint32 rights, MoneyPerDay; - uint32 BankRights; - uint32 BankSlotPerDay; //sLog.outDebug("WORLD: Received CMSG_GUILD_RANK"); @@ -633,10 +631,14 @@ void WorldSession::HandleGuildRankOpcode(WorldPacket& recvPacket) for (int i = 0; i < GUILD_BANK_MAX_TABS; ++i) { + uint32 BankRights; + uint32 BankSlotPerDay; + recvPacket >> BankRights; recvPacket >> BankSlotPerDay; guild->SetBankRightsAndSlots(rankId, uint8(i), uint16(BankRights & 0xFF), uint16(BankSlotPerDay), true); } + sLog.outDebug("WORLD: Changed RankName to %s , Rights to 0x%.4X", rankname.c_str(), rights); guild->SetBankMoneyPerDay(rankId, MoneyPerDay); diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index 4531f5146..483b5ab8f 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -410,8 +410,8 @@ void WorldSession::HandleSetSelectionOpcode( WorldPacket & recv_data ) void WorldSession::HandleStandStateChangeOpcode( WorldPacket & recv_data ) { - sLog.outDebug( "WORLD: Received CMSG_STAND_STATE_CHANGE" ); - uint8 animstate; + // sLog.outDebug( "WORLD: Received CMSG_STANDSTATECHANGE" ); -- too many spam in log at lags/debug stop + uint32 animstate; recv_data >> animstate; _player->SetStandState(animstate); @@ -982,11 +982,12 @@ void WorldSession::HandleNextCinematicCamera( WorldPacket & /*recv_data*/ ) DEBUG_LOG( "WORLD: Which movie to play" ); } -void WorldSession::HandleMoveTimeSkippedOpcode( WorldPacket & /*recv_data*/ ) +void WorldSession::HandleMoveTimeSkippedOpcode( WorldPacket & recv_data ) { /* WorldSession::Update( getMSTime() );*/ DEBUG_LOG( "WORLD: Time Lag/Synchronization Resent/Update" ); + recv_data.read_skip2(); /* uint64 guid; uint32 time_skipped; @@ -1007,19 +1008,20 @@ void WorldSession::HandleFeatherFallAck(WorldPacket &/*recv_data*/) DEBUG_LOG("WORLD: CMSG_MOVE_FEATHER_FALL_ACK"); } -void WorldSession::HandleMoveUnRootAck(WorldPacket&/* recv_data*/) +void WorldSession::HandleMoveUnRootAck(WorldPacket& recv_data) { - /* + sLog.outDebug( "WORLD: CMSG_FORCE_MOVE_UNROOT_ACK" ); - sLog.outDebug( "WORLD: CMSG_FORCE_MOVE_UNROOT_ACK" ); + recv_data.read_skip(); // guid + recv_data.read_skip(); // unknown1 + recv_data.read_skip(); // unknown2 + recv_data.read_skip(); // PositionX + recv_data.read_skip(); // PositionY + recv_data.read_skip(); // PositionZ + recv_data.read_skip(); // Orientation + + /* recv_data.hexlike(); - uint64 guid; - uint64 unknown1; - uint32 unknown2; - float PositionX; - float PositionY; - float PositionZ; - float Orientation; recv_data >> guid; recv_data >> unknown1; @@ -1040,8 +1042,16 @@ void WorldSession::HandleMoveUnRootAck(WorldPacket&/* recv_data*/) */ } -void WorldSession::HandleMoveRootAck(WorldPacket&/* recv_data*/) +void WorldSession::HandleMoveRootAck(WorldPacket& recv_data) { + recv_data.read_skip(); // guid + recv_data.read_skip(); // unknown1 + recv_data.read_skip(); // unknown2 + recv_data.read_skip(); // PositionX + recv_data.read_skip(); // PositionY + recv_data.read_skip(); // PositionZ + recv_data.read_skip(); // Orientation + /* sLog.outDebug( "WORLD: CMSG_FORCE_MOVE_ROOT_ACK" ); recv_data.hexlike(); @@ -1088,8 +1098,9 @@ void WorldSession::HandleSetActionBarToggles(WorldPacket& recv_data) GetPlayer()->SetByteValue(PLAYER_FIELD_BYTES, 2, ActionBar); } -void WorldSession::HandleWardenDataOpcode(WorldPacket& /*recv_data*/) +void WorldSession::HandleWardenDataOpcode(WorldPacket& recv_data) { + recv_data.read_skip(); /* uint8 tmp; recv_data >> tmp; diff --git a/src/game/QueryHandler.cpp b/src/game/QueryHandler.cpp index 87db09de6..2b836521d 100644 --- a/src/game/QueryHandler.cpp +++ b/src/game/QueryHandler.cpp @@ -152,6 +152,7 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data ) { uint32 entry; recv_data >> entry; + recv_data.read_skip(); // guid CreatureInfo const *ci = objmgr.GetCreatureTemplate(entry); if (ci) @@ -219,6 +220,7 @@ void WorldSession::HandleGameObjectQueryOpcode( WorldPacket & recv_data ) { uint32 entryID; recv_data >> entryID; + recv_data.read_skip(); // guid const GameObjectInfo *info = objmgr.GetGameObjectInfo(entryID); if(info) diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp index ec9fb6cfd..a8e66e8ff 100644 --- a/src/game/SpellHandler.cpp +++ b/src/game/SpellHandler.cpp @@ -348,10 +348,9 @@ void WorldSession::HandleCancelCastOpcode(WorldPacket& recvPacket) if(mover != _player && mover->GetTypeId()==TYPEID_PLAYER) return; - // increments with every CANCEL packet, don't use for now - uint8 counter; uint32 spellId; - recvPacket >> counter; + + recvPacket.read_skip(); // counter, increments with every CANCEL packet, don't use for now recvPacket >> spellId; //FIXME: hack, ignore unexpected client cancel Deadly Throw cast diff --git a/src/game/VoiceChatHandler.cpp b/src/game/VoiceChatHandler.cpp index b6ff674c4..3fc23ffcf 100644 --- a/src/game/VoiceChatHandler.cpp +++ b/src/game/VoiceChatHandler.cpp @@ -26,6 +26,7 @@ void WorldSession::HandleVoiceSessionEnableOpcode( WorldPacket & recv_data ) { sLog.outDebug("WORLD: CMSG_VOICE_SESSION_ENABLE"); // uint8 isVoiceEnabled, uint8 isMicrophoneEnabled + recv_data.read_skip2(); recv_data.hexlike(); } @@ -39,6 +40,7 @@ void WorldSession::HandleChannelVoiceOnOpcode( WorldPacket & recv_data ) void WorldSession::HandleSetActiveVoiceChannel( WorldPacket & recv_data ) { sLog.outDebug("WORLD: CMSG_SET_ACTIVE_VOICE_CHANNEL"); - // uint32, string + recv_data.read_skip(); + recv_data.read_skip(); recv_data.hexlike(); } diff --git a/src/shared/ByteBuffer.h b/src/shared/ByteBuffer.h index 795c76972..09842781b 100644 --- a/src/shared/ByteBuffer.h +++ b/src/shared/ByteBuffer.h @@ -259,6 +259,32 @@ class ByteBuffer return _wpos; } + template + void read_skip() { read_skip(sizeof(T)); } + + template + void read_skip2() { read_skip(sizeof(T1)+sizeof(T2)); } + + template<> + void read_skip() + { + uint8 size = read(); + read_skip(size); + } + + template<> + void read_skip() { read_skip(); } + + template<> + void read_skip() { read_skip(); } + + void read_skip(size_t skip) + { + if(_rpos + skip > size()) + throw ByteBufferException(false, _rpos, skip, size()); + _rpos += skip; + } + template T read() { T r = read(_rpos); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 4071b140f..a0e86162a 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8381" + #define REVISION_NR "8382" #endif // __REVISION_NR_H__ From 55a56ad71eafe9431ac89416907537698889a5ab Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Tue, 18 Aug 2009 04:12:31 +0400 Subject: [PATCH 4/4] [8383] Implement WorldSession::HandleCancelChanneling. --- src/game/SpellHandler.cpp | 15 +++++++++------ src/shared/revision_nr.h | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp index a8e66e8ff..41d752315 100644 --- a/src/game/SpellHandler.cpp +++ b/src/game/SpellHandler.cpp @@ -467,13 +467,16 @@ void WorldSession::HandleCancelAutoRepeatSpellOpcode( WorldPacket& /*recvPacket* _player->m_mover->InterruptSpell(CURRENT_AUTOREPEAT_SPELL); } -/// \todo Complete HandleCancelChanneling function -void WorldSession::HandleCancelChanneling( WorldPacket & /*recv_data */) +void WorldSession::HandleCancelChanneling( WorldPacket & recv_data) { - /* - uint32 spellid; - recv_data >> spellid; - */ + recv_data.read_skip(); // spellid, not used + + // ignore for remote control state (for player case) + Unit* mover = _player->m_mover; + if(mover != _player && mover->GetTypeId()==TYPEID_PLAYER) + return; + + mover->InterruptSpell(CURRENT_CHANNELED_SPELL); } void WorldSession::HandleTotemDestroyed( WorldPacket& recvPacket) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index a0e86162a..1f3737b85 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8382" + #define REVISION_NR "8383" #endif // __REVISION_NR_H__