[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 << uint32(tSpell->spell); // learned spell (or cast-spell in profession case)
data << uint8(state == TRAINER_SPELL_GREEN_DISABLED ? TRAINER_SPELL_GREEN : state); data << uint8(state == TRAINER_SPELL_GREEN_DISABLED ? TRAINER_SPELL_GREEN : state);
data << uint32(floor(tSpell->spellCost * fDiscountMod)); 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 << uint8(reqLevel);
data << uint32(tSpell->reqSkill); data << uint32(tSpell->reqSkill);
data << uint32(tSpell->reqSkillValue); 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->prev : chain_node->req) : 0);
data << uint32(!tSpell->IsCastable() && chain_node && 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) 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); WorldPacket data(SMSG_TRAINER_LIST, 8 + 4 + 4 + maxcount * 38 + strTitle.size() + 1);
data << ObjectGuid(guid); data << ObjectGuid(guid);
data << uint32(trainer_type); data << uint32(trainer_type);
data << uint32(ci->trainerId);
size_t count_pos = data.wpos(); size_t count_pos = data.wpos();
data << uint32(maxcount); data << uint32(maxcount);
@ -291,18 +290,18 @@ void WorldSession::HandleTrainerBuySpellOpcode(WorldPacket& recv_data)
uint32 nSpellCost = uint32(floor(trainer_spell->spellCost * _player->GetReputationPriceDiscount(unit))); uint32 nSpellCost = uint32(floor(trainer_spell->spellCost * _player->GetReputationPriceDiscount(unit)));
// check money requirement // check money requirement
if ((_player->GetMoney() < nSpellCost) && trainState > 1) if (_player->GetMoney() < nSpellCost && trainState > 1)
trainState = 0; trainState = 0;
if(trainState != 2) if (trainState != 2)
{ {
sendData << ObjectGuid(guid); sendData << ObjectGuid(guid);
sendData << uint32(spellId); sendData << uint32(spellId);
sendData << trainState; sendData << uint32(trainState);
SendPacket(&sendData); SendPacket(&sendData);
} }
else else
{ {
_player->ModifyMoney(-int32(nSpellCost)); _player->ModifyMoney(-int32(nSpellCost));
// visual effect on trainer // visual effect on trainer
@ -320,7 +319,6 @@ void WorldSession::HandleTrainerBuySpellOpcode(WorldPacket& recv_data)
else else
_player->learnSpell(spellId, false); _player->learnSpell(spellId, false);
sendData << ObjectGuid(guid); sendData << ObjectGuid(guid);
sendData << uint32(spellId); // should be same as in packet from client sendData << uint32(spellId); // should be same as in packet from client
sendData << uint32(trainState); sendData << uint32(trainState);

View file

@ -153,9 +153,9 @@ typedef std::map<uint32, SpellCooldown> SpellCooldowns;
enum TrainerSpellState enum TrainerSpellState
{ {
TRAINER_SPELL_GREEN = 0, TRAINER_SPELL_GRAY = 0,
TRAINER_SPELL_RED = 1, TRAINER_SPELL_GREEN = 1,
TRAINER_SPELL_GRAY = 2, TRAINER_SPELL_RED = 2,
TRAINER_SPELL_GREEN_DISABLED = 10 // custom value, not send to client: formally green but learn not allowed 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__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "0172" #define REVISION_NR "0175"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__