From 1ea085ae7b1c8f51d258766fe485a864c530cf86 Mon Sep 17 00:00:00 2001 From: "False.Genesis" Date: Sat, 24 Mar 2007 00:21:42 +0000 Subject: [PATCH] * added SMSG_SPELL_REMOVED opcode handler & related functions. * spell ids are uint32, not uint16! --- src/Client/World/Player.cpp | 12 +++++++++++- src/Client/World/Player.h | 3 ++- src/Client/World/WorldSession.cpp | 13 +++++++++++-- src/Client/World/WorldSession.h | 3 ++- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/Client/World/Player.cpp b/src/Client/World/Player.cpp index c377a94..e26f731 100644 --- a/src/Client/World/Player.cpp +++ b/src/Client/World/Player.cpp @@ -32,7 +32,7 @@ void MyCharacter::SetActionButtons(WorldPacket &data) } -void MyCharacter::AddSpell(uint16 spellid, uint16 spellslot) +void MyCharacter::AddSpell(uint32 spellid, uint16 spellslot) { SpellBookEntry _spell; _spell.id = spellid; @@ -41,6 +41,16 @@ void MyCharacter::AddSpell(uint16 spellid, uint16 spellslot) _spells.push_back(_spell); } +void MyCharacter::RemoveSpell(uint32 spellid) +{ + for(std::vector::iterator i=_spells.begin(); i != _spells.end(); i++) + if(i->id == spellid) + { + _spells.erase(i); + break; + } +} + uint16 MyCharacter::GetSpellSlot(uint32 spellid) { for(std::vector::iterator i=_spells.begin(); i != _spells.end(); i++) diff --git a/src/Client/World/Player.h b/src/Client/World/Player.h index 452e94f..0f00cf7 100644 --- a/src/Client/World/Player.h +++ b/src/Client/World/Player.h @@ -202,7 +202,8 @@ public: MyCharacter(); void SetActionButtons(WorldPacket &data); - void AddSpell(uint16 spellid, uint16 spellslot); + void AddSpell(uint32 spellid, uint16 spellslot); + void RemoveSpell(uint32 spellid); 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 5dabda1..7d04afc 100644 --- a/src/Client/World/WorldSession.cpp +++ b/src/Client/World/WorldSession.cpp @@ -186,6 +186,7 @@ OpcodeHandler *WorldSession::_GetOpcodeHandlerTable() const {SMSG_DESTROY_OBJECT, &WorldSession::_HandleDestroyObjectOpcode}, {SMSG_INITIAL_SPELLS, &WorldSession::_HandleInitialSpellsOpcode}, {SMSG_LEARNED_SPELL, &WorldSession::_HandleLearnedSpellOpcode}, + {SMSG_REMOVED_SPELL, &WorldSession::_HandleLearnedSpellOpcode}, // table termination { 0, NULL } @@ -658,10 +659,18 @@ void WorldSession::_HandleInitialSpellsOpcode(WorldPacket& recvPacket) void WorldSession::_HandleLearnedSpellOpcode(WorldPacket& recvPacket) { - uint16 spellid; + uint32 spellid; recvPacket >> spellid; - GetMyChar()->AddSpell(spellid, 0); + GetMyChar()->AddSpell(spellid, 0); // other spells must be moved by +1 in slot? logdebug("Learned spell: id=%u",spellid); } +void WorldSession::_HandleRemovedSpellOpcode(WorldPacket& recvPacket) +{ + uint32 spellid; + recvPacket >> spellid; + GetMyChar()->RemoveSpell(spellid); + logdebug("Unlearned spell: id=%u",spellid); +} + diff --git a/src/Client/World/WorldSession.h b/src/Client/World/WorldSession.h index a1d43d4..ab5f687 100644 --- a/src/Client/World/WorldSession.h +++ b/src/Client/World/WorldSession.h @@ -92,7 +92,8 @@ private: void _HandleItemQuerySingleResponseOpcode(WorldPacket& recvPacket); void _HandleDestroyObjectOpcode(WorldPacket& recvPacket); void _HandleInitialSpellsOpcode(WorldPacket& recvPacket); - void _HandleLearnedSpellOpcode(WorldPacket& recvPacket); + void _HandleLearnedSpellOpcode(WorldPacket& recvPacket); + void _HandleRemovedSpellOpcode(WorldPacket& recvPacket); void _MovementUpdate(uint8 objtypeid, uint64 guid, WorldPacket& recvPacket); // Helper for _HandleUpdateObjectOpcode void _ValuesUpdate(uint64 uguid, WorldPacket& recvPacket); // ...