* added SMSG_SPELL_REMOVED opcode handler & related functions.

* spell ids are uint32, not uint16!
This commit is contained in:
False.Genesis 2007-03-24 00:21:42 +00:00
parent 1299c5490f
commit 1ea085ae7b
4 changed files with 26 additions and 5 deletions

View File

@ -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<SpellBookEntry>::iterator i=_spells.begin(); i != _spells.end(); i++)
if(i->id == spellid)
{
_spells.erase(i);
break;
}
}
uint16 MyCharacter::GetSpellSlot(uint32 spellid)
{
for(std::vector<SpellBookEntry>::iterator i=_spells.begin(); i != _spells.end(); i++)

View File

@ -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; }

View File

@ -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);
}

View File

@ -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); // ...