[0175] Some cleanup and fix buying spells from trainers

Signed-off-by: Yaki Khadafi <ElSolDolLo@gmail.com>
This commit is contained in:
Yaki Khadafi 2012-08-24 16:53:55 +03:00 committed by Antz
parent cd42cc972d
commit b55547e4c4
3 changed files with 13 additions and 15 deletions

View file

@ -128,16 +128,14 @@ static void SendTrainerSpellHelper(WorldPacket& data, TrainerSpell const* tSpell
data << uint32(tSpell->spell); // learned spell (or cast-spell in profession case)
data << uint8(state == TRAINER_SPELL_GREEN_DISABLED ? TRAINER_SPELL_GREEN : state);
data << uint32(floor(tSpell->spellCost * fDiscountMod));
data << uint32(primary_prof_first_rank && can_learn_primary_prof ? 1 : 0);
// primary prof. learn confirmation dialog
data << uint32(primary_prof_first_rank ? 1 : 0); // must be equal prev. field to have learn button in enabled state
data << uint8(reqLevel);
data << uint32(tSpell->reqSkill);
data << uint32(tSpell->reqSkillValue);
data << uint32(primary_prof_first_rank && can_learn_primary_prof ? 1 : 0);
// primary prof. learn confirmation dialog
data << uint32(primary_prof_first_rank ? 1 : 0); // must be equal prev. field to have learn button in enabled state
data << uint32(!tSpell->IsCastable() && chain_node ? (chain_node->prev ? chain_node->prev : chain_node->req) : 0);
data << uint32(!tSpell->IsCastable() && chain_node && chain_node->prev ? chain_node->req : 0);
data << uint32(0);
}
void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle)
@ -178,6 +176,7 @@ void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle)
WorldPacket data(SMSG_TRAINER_LIST, 8 + 4 + 4 + maxcount * 38 + strTitle.size() + 1);
data << ObjectGuid(guid);
data << uint32(trainer_type);
data << uint32(ci->trainerId);
size_t count_pos = data.wpos();
data << uint32(maxcount);
@ -291,14 +290,14 @@ void WorldSession::HandleTrainerBuySpellOpcode(WorldPacket& recv_data)
uint32 nSpellCost = uint32(floor(trainer_spell->spellCost * _player->GetReputationPriceDiscount(unit)));
// check money requirement
if ((_player->GetMoney() < nSpellCost) && trainState > 1)
if (_player->GetMoney() < nSpellCost && trainState > 1)
trainState = 0;
if (trainState != 2)
{
sendData << ObjectGuid(guid);
sendData << uint32(spellId);
sendData << trainState;
sendData << uint32(trainState);
SendPacket(&sendData);
}
else
@ -320,7 +319,6 @@ void WorldSession::HandleTrainerBuySpellOpcode(WorldPacket& recv_data)
else
_player->learnSpell(spellId, false);
sendData << ObjectGuid(guid);
sendData << uint32(spellId); // should be same as in packet from client
sendData << uint32(trainState);

View file

@ -153,9 +153,9 @@ typedef std::map<uint32, SpellCooldown> SpellCooldowns;
enum TrainerSpellState
{
TRAINER_SPELL_GREEN = 0,
TRAINER_SPELL_RED = 1,
TRAINER_SPELL_GRAY = 2,
TRAINER_SPELL_GRAY = 0,
TRAINER_SPELL_GREEN = 1,
TRAINER_SPELL_RED = 2,
TRAINER_SPELL_GREEN_DISABLED = 10 // custom value, not send to client: formally green but learn not allowed
};

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "0172"
#define REVISION_NR "0175"
#endif // __REVISION_NR_H__