From 739ee2eae21d4b3e10098f50df00920dba47064d Mon Sep 17 00:00:00 2001 From: Mini Date: Fri, 23 Mar 2007 22:34:19 +0000 Subject: [PATCH] * Changed SetSpells() to AddSpell(spellid, spellslot) * Added handling of SMSG_LEARNED_SPELL opcode --- src/Client/World/Player.cpp | 20 +++++--------------- src/Client/World/Player.h | 2 +- src/Client/World/WorldSession.cpp | 23 +++++++++++++++++++++-- src/Client/World/WorldSession.h | 1 + 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/Client/World/Player.cpp b/src/Client/World/Player.cpp index 0cc23cd..c377a94 100644 --- a/src/Client/World/Player.cpp +++ b/src/Client/World/Player.cpp @@ -32,23 +32,13 @@ void MyCharacter::SetActionButtons(WorldPacket &data) } -void MyCharacter::SetSpells(WorldPacket &data) +void MyCharacter::AddSpell(uint16 spellid, uint16 spellslot) { - uint8 unk; - uint16 spellid,spellslot,count; - data >> unk >> count; - logdebug("Got initial spells list, %u spells.",count); - for(uint16 i = 0; i < count; i++) - { - data >> spellid >> spellslot; - logdebug("Initial Spell: id=%u slot=%u",spellid,spellslot); + SpellBookEntry _spell; + _spell.id = spellid; + _spell.slot = spellslot; - SpellBookEntry _spell; - _spell.id = spellid; - _spell.slot = spellslot; - - _spells.push_back(_spell); - } + _spells.push_back(_spell); } uint16 MyCharacter::GetSpellSlot(uint32 spellid) diff --git a/src/Client/World/Player.h b/src/Client/World/Player.h index 2c15c17..452e94f 100644 --- a/src/Client/World/Player.h +++ b/src/Client/World/Player.h @@ -202,7 +202,7 @@ public: MyCharacter(); void SetActionButtons(WorldPacket &data); - void SetSpells(WorldPacket &data); + void AddSpell(uint16 spellid, uint16 spellslot); uint64 GetTarget(void) { return _target; } void SetTarget(uint64 guid) { _target = guid; } // should only be called by WorldSession::SendSetSelection() !! bool HasSpell(uint32 spellid) { return GetSpellSlot(spellid) != 0; } diff --git a/src/Client/World/WorldSession.cpp b/src/Client/World/WorldSession.cpp index c89ec4c..5dabda1 100644 --- a/src/Client/World/WorldSession.cpp +++ b/src/Client/World/WorldSession.cpp @@ -185,6 +185,7 @@ OpcodeHandler *WorldSession::_GetOpcodeHandlerTable() const {SMSG_ITEM_QUERY_SINGLE_RESPONSE, &WorldSession::_HandleItemQuerySingleResponseOpcode}, {SMSG_DESTROY_OBJECT, &WorldSession::_HandleDestroyObjectOpcode}, {SMSG_INITIAL_SPELLS, &WorldSession::_HandleInitialSpellsOpcode}, + {SMSG_LEARNED_SPELL, &WorldSession::_HandleLearnedSpellOpcode}, // table termination { 0, NULL } @@ -642,7 +643,25 @@ void WorldSession::_HandleCastResultOpcode(WorldPacket& recvPacket) void WorldSession::_HandleInitialSpellsOpcode(WorldPacket& recvPacket) { - // suggestion for later: what about MyCharacter->AddSpellBookEntry() ? - GetMyChar()->SetSpells(recvPacket); + uint8 unk; + uint16 spellid,spellslot,count; + recvPacket >> unk >> count; + logdebug("Got initial spells list, %u spells.",count); + for(uint16 i = 0; i < count; i++) + { + recvPacket >> spellid >> spellslot; + logdebug("Initial Spell: id=%u slot=%u",spellid,spellslot); + + GetMyChar()->AddSpell(spellid, spellslot); + } +} + +void WorldSession::_HandleLearnedSpellOpcode(WorldPacket& recvPacket) +{ + uint16 spellid; + recvPacket >> spellid; + GetMyChar()->AddSpell(spellid, 0); + + logdebug("Learned spell: id=%u",spellid); } diff --git a/src/Client/World/WorldSession.h b/src/Client/World/WorldSession.h index 8ebeb96..a1d43d4 100644 --- a/src/Client/World/WorldSession.h +++ b/src/Client/World/WorldSession.h @@ -92,6 +92,7 @@ private: void _HandleItemQuerySingleResponseOpcode(WorldPacket& recvPacket); void _HandleDestroyObjectOpcode(WorldPacket& recvPacket); void _HandleInitialSpellsOpcode(WorldPacket& recvPacket); + void _HandleLearnedSpellOpcode(WorldPacket& recvPacket); void _MovementUpdate(uint8 objtypeid, uint64 guid, WorldPacket& recvPacket); // Helper for _HandleUpdateObjectOpcode void _ValuesUpdate(uint64 uguid, WorldPacket& recvPacket); // ...