From 17e66920074c2788add3d684a4f193e0ef53e586 Mon Sep 17 00:00:00 2001 From: Mini Date: Sun, 4 Mar 2007 12:33:16 +0000 Subject: [PATCH] Started with MyCharacter class, added handling of spells opcode, more to come. --- src/Client/World/Player.cpp | 58 +++++++++++++++++++------------ src/Client/World/Player.h | 12 +++++-- src/Client/World/WorldSession.cpp | 12 ++----- src/Client/World/WorldSession.h | 1 + 4 files changed, 49 insertions(+), 34 deletions(-) diff --git a/src/Client/World/Player.cpp b/src/Client/World/Player.cpp index 0f6175e..9befed4 100644 --- a/src/Client/World/Player.cpp +++ b/src/Client/World/Player.cpp @@ -22,28 +22,42 @@ void Player::Create(uint64 guid) Object::Create(guid); } - -/*void PlayerSettings::SetSpells(WorldPacket &data) +MyCharacter::MyCharacter() { - if (!init) - return; - - uint8 unk; - uint16 numSpells; - - data >> unk >> numSpells; - - logdetail("Got %d spells", numSpells); - - // TODO: Finish implenting this + _castingSpell = false; } -void PlayerSettings::CastSpell(uint32 spellId, uint64 target) +void MyCharacter::SetActionButtons(WorldPacket &data) { - if (castingSpell || !init) + +} + +void MyCharacter::SetSpells(WorldPacket &data) +{ + 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); + + spell _spell; + _spell.spellId = spellid; + _spell.spellSlot = spellslot; + + _spells.push_back(_spell); + } +} + +void MyCharacter::CastSpell(uint32 spellId, uint64 target) +{ + /* + if (_castingSpell) return; - castingSpell = !castingSpell; + _castingSpell = !_castingSpell; WorldPacket packet; packet.SetOpcode(CMSG_CAST_SPELL); @@ -52,13 +66,12 @@ void PlayerSettings::CastSpell(uint32 spellId, uint64 target) // Damn packed guid stuff! xD _worldSession->SendWorldPacket(packet); + */ } -void PlayerSettings::HandleCastResultOpcode(WorldPacket &packet) +void MyCharacter::HandleCastResultOpcode(WorldPacket &packet) { - if (!init) - return; - + /* uint32 spellId; uint8 statusFail; uint8 failProblem; @@ -66,7 +79,7 @@ void PlayerSettings::HandleCastResultOpcode(WorldPacket &packet) packet >> spellId >> statusFail; - castingSpell = false; + _castingSpell = false; sprintf(l, "Received cast result opcode. Spell = %d, statusFail = %d", spellId, statusFail); @@ -78,4 +91,5 @@ void PlayerSettings::HandleCastResultOpcode(WorldPacket &packet) //logdetail(l); -}*/ \ No newline at end of file + */ +} \ No newline at end of file diff --git a/src/Client/World/Player.h b/src/Client/World/Player.h index 0d05894..93919ba 100644 --- a/src/Client/World/Player.h +++ b/src/Client/World/Player.h @@ -195,13 +195,21 @@ class MyCharacter : public Player public: MyCharacter(); - /*void SetActionButtons(WorldPacket &data); + void SetActionButtons(WorldPacket &data); void SetSpells(WorldPacket &data); void CastSpell(uint32 spellId, uint64 target); - void HandleCastResultOpcode(WorldPacket &packet);*/ + void HandleCastResultOpcode(WorldPacket &packet); private: + bool _castingSpell; + typedef struct + { + uint16 spellId; + uint16 spellSlot; + } spell; + + std::vector _spells; }; diff --git a/src/Client/World/WorldSession.cpp b/src/Client/World/WorldSession.cpp index 485a6c5..ca6c2d1 100644 --- a/src/Client/World/WorldSession.cpp +++ b/src/Client/World/WorldSession.cpp @@ -24,6 +24,7 @@ WorldSession::WorldSession(PseuInstance *in) _myGUID=0; // i dont have a guid yet plrNameCache.ReadFromFile(); // load names/guids of known players ItemProtoCache_InsertDataToSession(this); + myCharacter = new MyCharacter(); _deleteme = false; _channels = new Channel(this); // _playerSettings->Init(this); @@ -636,15 +637,6 @@ void WorldSession::_HandleCastResultOpcode(WorldPacket& recvPacket) void WorldSession::_HandleInitialSpellsOpcode(WorldPacket& 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); - // these data need to be added to MyCharacter later - } + myCharacter->SetSpells(recvPacket); } diff --git a/src/Client/World/WorldSession.h b/src/Client/World/WorldSession.h index 8d88787..9d3ebc8 100644 --- a/src/Client/World/WorldSession.h +++ b/src/Client/World/WorldSession.h @@ -63,6 +63,7 @@ public: void SendSetSelection(uint64); PlayerNameCache plrNameCache; + MyCharacter *myCharacter; ObjMgr objmgr; private: