[7918] Improve portability in work with uint64 string format specifiers and in code...
[getmangos.git] / src / game / SkillHandler.cpp
blob734bf36e65bc21bbb44b1920a57b505edbf1ab8a
1 /*
2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "Common.h"
20 #include "Database/DatabaseEnv.h"
21 #include "Opcodes.h"
22 #include "Log.h"
23 #include "Player.h"
24 #include "WorldPacket.h"
25 #include "WorldSession.h"
26 #include "ObjectAccessor.h"
27 #include "UpdateMask.h"
29 void WorldSession::HandleLearnTalentOpcode( WorldPacket & recv_data )
31 CHECK_PACKET_SIZE(recv_data,4+4);
33 uint32 talent_id, requested_rank;
34 recv_data >> talent_id >> requested_rank;
36 _player->LearnTalent(talent_id, requested_rank);
39 void WorldSession::HandleTalentWipeConfirmOpcode( WorldPacket & recv_data )
41 CHECK_PACKET_SIZE(recv_data,8);
43 sLog.outDetail("MSG_TALENT_WIPE_CONFIRM");
44 uint64 guid;
45 recv_data >> guid;
47 Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_TRAINER);
48 if (!unit)
50 sLog.outDebug( "WORLD: HandleTalentWipeConfirmOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) );
51 return;
54 // remove fake death
55 if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
56 GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
58 if(!(_player->resetTalents()))
60 WorldPacket data( MSG_TALENT_WIPE_CONFIRM, 8+4); //you have not any talent
61 data << uint64(0);
62 data << uint32(0);
63 SendPacket( &data );
64 return;
67 unit->CastSpell(_player, 14867, true); //spell: "Untalent Visual Effect"
70 void WorldSession::HandleUnlearnSkillOpcode(WorldPacket & recv_data)
72 CHECK_PACKET_SIZE(recv_data,4);
74 uint32 skill_id;
75 recv_data >> skill_id;
76 GetPlayer()->SetSkill(skill_id, 0, 0);