2010-10-07 15:35:36 +02:00
/*
2012-01-01 00:32:13 +01:00
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
2010-10-07 15:35:36 +02:00
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
2008-10-02 16:23:55 -05:00
*/
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
#include "Common.h"
2010-06-08 17:01:03 -06:00
#include "DatabaseEnv.h"
2008-10-02 16:23:55 -05:00
#include "Opcodes.h"
#include "Log.h"
#include "Player.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include "ObjectAccessor.h"
#include "UpdateMask.h"
2009-10-17 15:51:44 -07:00
2012-11-02 22:23:14 +01:00
void WorldSession :: HandleLearnTalentOpcode ( WorldPacket & recvData )
2008-10-02 16:23:55 -05:00
{
uint32 talent_id , requested_rank ;
2012-11-02 22:23:14 +01:00
recvData >> talent_id >> requested_rank ;
2009-10-17 15:51:44 -07:00
2009-03-21 14:53:38 -06:00
_player -> LearnTalent ( talent_id , requested_rank );
2009-06-11 00:45:59 -05:00
_player -> SendTalentsInfoData ( false );
}
2009-10-17 15:51:44 -07:00
2009-06-11 00:45:59 -05:00
void WorldSession :: HandleLearnPreviewTalents ( WorldPacket & recvPacket )
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "CMSG_LEARN_PREVIEW_TALENTS" );
2009-10-17 15:51:44 -07:00
2009-06-11 00:45:59 -05:00
uint32 talentsCount ;
recvPacket >> talentsCount ;
2009-10-17 15:51:44 -07:00
2009-06-11 00:45:59 -05:00
uint32 talentId , talentRank ;
2009-10-17 15:51:44 -07:00
2009-10-17 16:20:24 -07:00
for ( uint32 i = 0 ; i < talentsCount ; ++ i )
2009-06-11 00:45:59 -05:00
{
recvPacket >> talentId >> talentRank ;
2009-10-17 15:51:44 -07:00
2009-06-11 00:45:59 -05:00
_player -> LearnTalent ( talentId , talentRank );
}
2009-10-17 15:51:44 -07:00
2009-06-11 00:45:59 -05:00
_player -> SendTalentsInfoData ( false );
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2012-11-02 22:23:14 +01:00
void WorldSession :: HandleTalentWipeConfirmOpcode ( WorldPacket & recvData )
2008-10-02 16:23:55 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "MSG_TALENT_WIPE_CONFIRM" );
2008-10-02 16:23:55 -05:00
uint64 guid ;
2012-11-02 22:23:14 +01:00
recvData >> guid ;
2009-10-17 15:51:44 -07:00
2011-06-12 01:47:45 +02:00
Creature * unit = GetPlayer () -> GetNPCIfCanInteractWith ( guid , UNIT_NPC_FLAG_TRAINER );
2008-10-02 16:23:55 -05:00
if ( ! unit )
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "WORLD: HandleTalentWipeConfirmOpcode - Unit (GUID: %u) not found or you can't interact with him." , uint32 ( GUID_LOPART ( guid )));
2008-10-02 16:23:55 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// remove fake death
2012-02-03 19:02:17 +02:00
if ( GetPlayer () -> HasUnitState ( UNIT_STATE_DIED ))
2009-04-06 13:31:14 +02:00
GetPlayer () -> RemoveAurasByType ( SPELL_AURA_FEIGN_DEATH );
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( ! ( _player -> resetTalents ()))
2008-10-02 16:23:55 -05:00
{
2010-04-07 22:59:46 +02:00
WorldPacket data ( MSG_TALENT_WIPE_CONFIRM , 8 + 4 ); //you have not any talent
2008-10-02 16:23:55 -05:00
data << uint64 ( 0 );
data << uint32 ( 0 );
2010-04-07 22:59:46 +02:00
SendPacket ( & data );
2008-10-02 16:23:55 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2009-06-11 00:45:59 -05:00
_player -> SendTalentsInfoData ( false );
2008-10-02 16:23:55 -05:00
unit -> CastSpell ( _player , 14867 , true ); //spell: "Untalent Visual Effect"
}
2009-10-17 15:51:44 -07:00
2012-09-07 14:17:17 +02:00
void WorldSession :: HandleUnlearnSkillOpcode ( WorldPacket & recvData )
2008-10-02 16:23:55 -05:00
{
2012-09-07 14:17:17 +02:00
uint32 skillId ;
recvData >> skillId ;
if ( ! IsPrimaryProfessionSkill ( skillId ))
return ;
GetPlayer () -> SetSkill ( skillId , 0 , 0 , 0 );
2008-10-02 16:23:55 -05:00
}