Started with MyCharacter class, added handling of spells opcode, more to come.

This commit is contained in:
Mini 2007-03-04 12:33:16 +00:00
parent 06942daea6
commit 17e6692007
4 changed files with 49 additions and 34 deletions

View File

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

View File

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

View File

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

View File

@ -63,6 +63,7 @@ public:
void SendSetSelection(uint64);
PlayerNameCache plrNameCache;
MyCharacter *myCharacter;
ObjMgr objmgr;
private: