2008-10-02 16:23:55 -05:00
/*
2009-02-04 12:42:26 +01:00
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
2008-10-14 11:57:03 -05:00
*
2010-01-16 20:19:18 +03:00
* Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
2008-10-02 16:23:55 -05:00
*
* 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
2008-12-12 11:21:28 -06:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2008-10-02 16:23:55 -05:00
* 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, write to the Free Software
2008-12-12 11:21:28 -06:00
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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"
#include "Database/DatabaseEnv.h"
#include "WorldPacket.h"
2009-03-09 17:06:13 -06:00
#include "Vehicle.h"
2008-10-02 16:23:55 -05:00
#include "Player.h"
#include "Opcodes.h"
#include "Chat.h"
#include "Log.h"
#include "Unit.h"
#include "GossipDef.h"
#include "Language.h"
2008-12-19 16:05:13 -06:00
#include "BattleGroundMgr.h"
2008-12-12 11:21:28 -06:00
#include <fstream>
#include "ObjectMgr.h"
2009-04-17 15:08:58 -05:00
#include "Cell.h"
#include "CellImpl.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
2009-07-16 10:13:12 +08:00
#include "SpellMgr.h"
2009-08-04 01:44:14 +02:00
#include "ScriptCalls.h"
2009-10-17 15:51:44 -07:00
2009-04-05 16:43:17 -05:00
bool ChatHandler :: HandleDebugSendSpellFailCommand ( const char * args )
2008-10-02 16:23:55 -05:00
{
2009-06-27 18:27:31 -05:00
if ( !* args )
2008-10-02 16:23:55 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
char * px = strtok (( char * ) args , " " );
2009-06-08 17:25:02 -05:00
if ( ! px )
2008-10-02 16:23:55 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
uint8 failnum = ( uint8 ) atoi ( px );
2009-06-27 18:27:31 -05:00
if ( failnum == 0 && * px != '0' )
2009-04-05 16:43:17 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2009-04-05 16:43:17 -05:00
char * p1 = strtok ( NULL , " " );
uint8 failarg1 = p1 ? ( uint8 ) atoi ( p1 ) : 0 ;
2009-10-17 15:51:44 -07:00
2009-04-05 16:43:17 -05:00
char * p2 = strtok ( NULL , " " );
uint8 failarg2 = p2 ? ( uint8 ) atoi ( p2 ) : 0 ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
WorldPacket data ( SMSG_CAST_FAILED , 5 );
2008-12-24 09:58:26 -06:00
data << uint8 ( 0 );
2008-12-12 11:21:28 -06:00
data << uint32 ( 133 );
data << uint8 ( failnum );
2009-06-08 17:25:02 -05:00
if ( p1 || p2 )
2009-04-05 16:43:17 -05:00
data << uint32 ( failarg1 );
2009-06-08 17:25:02 -05:00
if ( p2 )
2009-04-05 16:43:17 -05:00
data << uint32 ( failarg2 );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
m_session -> SendPacket ( & data );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
return true ;
}
2009-10-17 15:51:44 -07:00
2009-04-05 16:43:17 -05:00
bool ChatHandler :: HandleDebugSendPoiCommand ( const char * args )
2008-10-02 16:23:55 -05:00
{
2009-06-27 18:27:31 -05:00
if ( !* args )
return false ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
Player * pPlayer = m_session -> GetPlayer ();
Unit * target = getSelectedUnit ();
2009-06-27 18:27:31 -05:00
if ( ! target )
2008-10-02 16:23:55 -05:00
{
SendSysMessage ( LANG_SELECT_CHAR_OR_CREATURE );
return true ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
char * icon_text = strtok (( char * ) args , " " );
char * flags_text = strtok ( NULL , " " );
2009-06-27 18:27:31 -05:00
if ( ! icon_text || ! flags_text )
2008-10-02 16:23:55 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
uint32 icon = atol ( icon_text );
uint32 flags = atol ( flags_text );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
sLog . outDetail ( "Command : POI, NPC = %u, icon = %u flags = %u" , target -> GetGUIDLow (), icon , flags );
pPlayer -> PlayerTalkClass -> SendPointOfInterest ( target -> GetPositionX (), target -> GetPositionY (), Poi_Icon ( icon ), flags , 30 , "Test POI" );
return true ;
}
2009-10-17 15:51:44 -07:00
2009-04-05 16:43:17 -05:00
bool ChatHandler :: HandleDebugSendEquipErrorCommand ( const char * args )
2008-10-02 16:23:55 -05:00
{
2009-06-27 18:27:31 -05:00
if ( !* args )
2008-10-02 16:23:55 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
uint8 msg = atoi ( args );
m_session -> GetPlayer () -> SendEquipError ( msg , 0 , 0 );
return true ;
}
2009-10-17 15:51:44 -07:00
2009-04-05 16:43:17 -05:00
bool ChatHandler :: HandleDebugSendSellErrorCommand ( const char * args )
2008-10-02 16:23:55 -05:00
{
2009-06-27 18:27:31 -05:00
if ( !* args )
2008-10-02 16:23:55 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
uint8 msg = atoi ( args );
m_session -> GetPlayer () -> SendSellError ( msg , 0 , 0 , 0 );
return true ;
}
2009-10-17 15:51:44 -07:00
2009-04-05 16:43:17 -05:00
bool ChatHandler :: HandleDebugSendBuyErrorCommand ( const char * args )
2008-10-02 16:23:55 -05:00
{
2009-06-27 18:27:31 -05:00
if ( !* args )
2008-10-02 16:23:55 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
uint8 msg = atoi ( args );
m_session -> GetPlayer () -> SendBuyError ( msg , 0 , 0 , 0 );
return true ;
}
2009-10-17 15:51:44 -07:00
2009-03-19 15:06:30 -06:00
bool ChatHandler :: HandleDebugSendOpcodeCommand ( const char * /*args*/ )
2008-10-02 16:23:55 -05:00
{
Unit * unit = getSelectedUnit ();
2009-01-18 17:58:13 -06:00
Player * player = NULL ;
2008-10-02 16:23:55 -05:00
if ( ! unit || ( unit -> GetTypeId () != TYPEID_PLAYER ))
2009-01-18 17:58:13 -06:00
player = m_session -> GetPlayer ();
else
player = ( Player * ) unit ;
if ( ! unit ) unit = player ;
2009-10-17 15:51:44 -07:00
2008-12-12 11:21:28 -06:00
std :: ifstream ifs ( "opcode.txt" );
2009-06-27 18:27:31 -05:00
if ( ifs . bad ())
2008-10-02 16:23:55 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2008-12-12 11:21:28 -06:00
uint32 opcode ;
ifs >> opcode ;
2009-10-17 15:51:44 -07:00
2008-12-12 11:21:28 -06:00
WorldPacket data ( opcode , 0 );
2009-10-17 15:51:44 -07:00
2008-12-12 11:21:28 -06:00
while ( ! ifs . eof ())
2008-10-02 16:23:55 -05:00
{
2008-12-12 11:21:28 -06:00
std :: string type ;
ifs >> type ;
2009-10-17 15:51:44 -07:00
2008-12-12 11:21:28 -06:00
if ( type == "" )
break ;
2009-10-17 15:51:44 -07:00
2008-12-12 11:21:28 -06:00
if ( type == "uint8" )
{
uint16 val1 ;
ifs >> val1 ;
data << uint8 ( val1 );
}
else if ( type == "uint16" )
{
uint16 val2 ;
ifs >> val2 ;
data << val2 ;
}
else if ( type == "uint32" )
{
uint32 val3 ;
ifs >> val3 ;
data << val3 ;
}
else if ( type == "uint64" )
{
uint64 val4 ;
ifs >> val4 ;
data << val4 ;
}
else if ( type == "float" )
{
float val5 ;
ifs >> val5 ;
data << val5 ;
}
else if ( type == "string" )
{
std :: string val6 ;
ifs >> val6 ;
data << val6 ;
}
2009-03-20 09:40:40 -06:00
else if ( type == "appitsguid" )
2008-12-12 11:21:28 -06:00
{
data . append ( unit -> GetPackGUID ());
}
2009-03-20 09:40:40 -06:00
else if ( type == "appmyguid" )
2009-02-24 21:06:12 -06:00
{
2009-01-18 17:58:13 -06:00
data . append ( player -> GetPackGUID ());
2009-02-24 21:06:12 -06:00
}
2009-05-19 15:26:43 -05:00
else if ( type == "appgoguid" )
{
2009-05-21 09:59:49 -05:00
GameObject * obj = GetNearbyGameObject ();
2009-05-19 15:26:43 -05:00
if ( ! obj )
{
2009-05-21 09:59:49 -05:00
PSendSysMessage ( LANG_COMMAND_OBJNOTFOUND , 0 );
2009-05-19 15:26:43 -05:00
SetSentErrorMessage ( true );
ifs . close ();
return false ;
}
data . append ( obj -> GetPackGUID ());
}
else if ( type == "goguid" )
{
2009-05-21 09:59:49 -05:00
GameObject * obj = GetNearbyGameObject ();
2009-05-19 15:26:43 -05:00
if ( ! obj )
{
2009-05-21 09:59:49 -05:00
PSendSysMessage ( LANG_COMMAND_OBJNOTFOUND , 0 );
2009-05-19 15:26:43 -05:00
SetSentErrorMessage ( true );
ifs . close ();
return false ;
}
data << uint64 ( obj -> GetGUID ());
}
2009-03-20 09:40:40 -06:00
else if ( type == "myguid" )
{
data << uint64 ( player -> GetGUID ());
}
else if ( type == "itsguid" )
{
data << uint64 ( unit -> GetGUID ());
}
2009-01-18 17:58:13 -06:00
else if ( type == "pos" )
{
data << unit -> GetPositionX ();
data << unit -> GetPositionY ();
data << unit -> GetPositionZ ();
}
2009-02-24 21:06:12 -06:00
else if ( type == "mypos" )
{
data << player -> GetPositionX ();
data << player -> GetPositionY ();
data << player -> GetPositionZ ();
}
2008-12-12 11:21:28 -06:00
else
2008-10-02 16:23:55 -05:00
{
2008-12-12 11:21:28 -06:00
sLog . outDebug ( "Sending opcode: unknown type '%s'" , type . c_str ());
break ;
2008-10-02 16:23:55 -05:00
}
}
2008-12-12 11:21:28 -06:00
ifs . close ();
2008-10-02 16:23:55 -05:00
sLog . outDebug ( "Sending opcode %u" , data . GetOpcode ());
data . hexlike ();
2009-01-18 17:58:13 -06:00
player -> GetSession () -> SendPacket ( & data );
2008-10-02 16:23:55 -05:00
PSendSysMessage ( LANG_COMMAND_OPCODESENT , data . GetOpcode (), unit -> GetName ());
return true ;
}
2009-10-17 15:51:44 -07:00
2009-03-19 15:06:30 -06:00
bool ChatHandler :: HandleDebugUpdateWorldStateCommand ( const char * args )
2008-10-02 16:23:55 -05:00
{
char * w = strtok (( char * ) args , " " );
char * s = strtok ( NULL , " " );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( ! w || ! s )
return false ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
uint32 world = ( uint32 ) atoi ( w );
uint32 state = ( uint32 ) atoi ( s );
m_session -> GetPlayer () -> SendUpdateWorldState ( world , state );
return true ;
}
2009-10-17 15:51:44 -07:00
2009-04-05 16:58:20 -05:00
bool ChatHandler :: HandleDebugPlayCinematicCommand ( const char * args )
{
// USAGE: .debug play cinematic #cinematicid
// #cinematicid - ID decimal number from CinemaicSequences.dbc (1st column)
2009-06-27 18:27:31 -05:00
if ( !* args )
2009-04-05 16:58:20 -05:00
{
SendSysMessage ( LANG_BAD_VALUE );
SetSentErrorMessage ( true );
return false ;
}
2009-10-17 15:51:44 -07:00
2009-04-05 16:58:20 -05:00
uint32 dwId = atoi (( char * ) args );
2009-10-17 15:51:44 -07:00
2009-06-27 18:27:31 -05:00
if ( ! sCinematicSequencesStore . LookupEntry ( dwId ))
2009-04-05 16:58:20 -05:00
{
PSendSysMessage ( LANG_CINEMATIC_NOT_EXIST , dwId );
SetSentErrorMessage ( true );
return false ;
}
2009-10-17 15:51:44 -07:00
2009-04-05 16:58:20 -05:00
m_session -> GetPlayer () -> SendCinematicStart ( dwId );
return true ;
}
2009-10-17 15:51:44 -07:00
2009-04-05 16:58:20 -05:00
bool ChatHandler :: HandleDebugPlayMovieCommand ( const char * args )
{
// USAGE: .debug play movie #movieid
// #movieid - ID decimal number from Movie.dbc (1st column)
2009-06-27 18:27:31 -05:00
if ( !* args )
2009-04-05 16:58:20 -05:00
{
SendSysMessage ( LANG_BAD_VALUE );
SetSentErrorMessage ( true );
return false ;
}
2009-10-17 15:51:44 -07:00
2009-04-05 16:58:20 -05:00
uint32 dwId = atoi (( char * ) args );
2009-10-17 15:51:44 -07:00
2009-06-27 18:27:31 -05:00
if ( ! sMovieStore . LookupEntry ( dwId ))
2009-04-05 16:58:20 -05:00
{
PSendSysMessage ( LANG_MOVIE_NOT_EXIST , dwId );
SetSentErrorMessage ( true );
return false ;
}
2009-10-17 15:51:44 -07:00
2009-04-05 16:58:20 -05:00
m_session -> GetPlayer () -> SendMovieStart ( dwId );
return true ;
}
2009-10-17 15:51:44 -07:00
2009-03-22 19:20:03 -06:00
//Play sound
bool ChatHandler :: HandleDebugPlaySoundCommand ( const char * args )
2008-10-02 16:23:55 -05:00
{
2009-03-22 19:20:03 -06:00
// USAGE: .debug playsound #soundid
// #soundid - ID decimal number from SoundEntries.dbc (1st column)
2009-06-27 18:27:31 -05:00
if ( !* args )
2009-03-22 19:20:03 -06:00
{
SendSysMessage ( LANG_BAD_VALUE );
SetSentErrorMessage ( true );
return false ;
}
2009-10-17 15:51:44 -07:00
2009-03-22 19:20:03 -06:00
uint32 dwSoundId = atoi (( char * ) args );
2009-10-17 15:51:44 -07:00
2009-06-27 18:27:31 -05:00
if ( ! sSoundEntriesStore . LookupEntry ( dwSoundId ))
2009-03-22 19:20:03 -06:00
{
PSendSysMessage ( LANG_SOUND_NOT_EXIST , dwSoundId );
SetSentErrorMessage ( true );
2008-10-02 16:23:55 -05:00
return false ;
2009-03-22 19:20:03 -06:00
}
2009-10-17 15:51:44 -07:00
2009-03-22 19:20:03 -06:00
Unit * unit = getSelectedUnit ();
2009-06-27 18:27:31 -05:00
if ( ! unit )
2009-03-22 19:20:03 -06:00
{
SendSysMessage ( LANG_SELECT_CHAR_OR_CREATURE );
SetSentErrorMessage ( true );
return false ;
}
2009-10-17 15:51:44 -07:00
2009-06-27 18:27:31 -05:00
if ( m_session -> GetPlayer () -> GetSelection ())
2009-03-22 19:20:03 -06:00
unit -> PlayDistanceSound ( dwSoundId , m_session -> GetPlayer ());
else
unit -> PlayDirectSound ( dwSoundId , m_session -> GetPlayer ());
2009-10-17 15:51:44 -07:00
2009-03-22 19:20:03 -06:00
PSendSysMessage ( LANG_YOU_HEAR_SOUND , dwSoundId );
2008-10-02 16:23:55 -05:00
return true ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
//Send notification in channel
2009-03-19 15:06:30 -06:00
bool ChatHandler :: HandleDebugSendChannelNotifyCommand ( const char * args )
2008-10-02 16:23:55 -05:00
{
2009-06-27 18:27:31 -05:00
if ( !* args )
2008-10-02 16:23:55 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
const char * name = "test" ;
uint8 code = atoi ( args );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
WorldPacket data ( SMSG_CHANNEL_NOTIFY , ( 1 + 10 ));
data << code ; // notify type
data << name ; // channel name
data << uint32 ( 0 );
data << uint32 ( 0 );
m_session -> SendPacket ( & data );
return true ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
//Send notification in chat
2009-03-19 15:06:30 -06:00
bool ChatHandler :: HandleDebugSendChatMsgCommand ( const char * args )
2008-10-02 16:23:55 -05:00
{
2009-06-27 18:27:31 -05:00
if ( !* args )
2008-10-02 16:23:55 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
const char * msg = "testtest" ;
uint8 type = atoi ( args );
WorldPacket data ;
ChatHandler :: FillMessageData ( & data , m_session , type , 0 , "chan" , m_session -> GetPlayer () -> GetGUID (), msg , m_session -> GetPlayer ());
m_session -> SendPacket ( & data );
return true ;
}
2009-10-17 15:51:44 -07:00
2009-03-19 15:06:30 -06:00
bool ChatHandler :: HandleDebugSendQuestPartyMsgCommand ( const char * args )
2008-10-02 16:23:55 -05:00
{
uint32 msg = atol (( char * ) args );
2009-02-24 11:14:28 -06:00
m_session -> GetPlayer () -> SendPushToPartyResponse ( m_session -> GetPlayer (), msg );
2008-10-02 16:23:55 -05:00
return true ;
}
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
bool ChatHandler :: HandleDebugGetLootRecipientCommand ( const char * /*args*/ )
2008-10-02 16:23:55 -05:00
{
Creature * target = getSelectedCreature ();
2009-06-27 18:27:31 -05:00
if ( ! target )
2008-10-02 16:23:55 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
PSendSysMessage ( "loot recipient: %s" , target -> hasLootRecipient () ? ( target -> GetLootRecipient () ? target -> GetLootRecipient () -> GetName () : "offline" ) : "no loot recipient" );
return true ;
}
2009-10-17 15:51:44 -07:00
2009-03-19 15:06:30 -06:00
bool ChatHandler :: HandleDebugSendQuestInvalidMsgCommand ( const char * args )
2008-10-02 16:23:55 -05:00
{
uint32 msg = atol (( char * ) args );
2009-02-24 11:14:28 -06:00
m_session -> GetPlayer () -> SendCanTakeQuestResponse ( msg );
2008-10-02 16:23:55 -05:00
return true ;
}
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
bool ChatHandler :: HandleDebugGetItemStateCommand ( const char * args )
2008-10-02 16:23:55 -05:00
{
2009-06-27 18:27:31 -05:00
if ( !* args )
2008-10-02 16:23:55 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
std :: string state_str = args ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
ItemUpdateState state = ITEM_UNCHANGED ;
bool list_queue = false , check_all = false ;
if ( state_str == "unchanged" ) state = ITEM_UNCHANGED ;
else if ( state_str == "changed" ) state = ITEM_CHANGED ;
else if ( state_str == "new" ) state = ITEM_NEW ;
else if ( state_str == "removed" ) state = ITEM_REMOVED ;
else if ( state_str == "queue" ) list_queue = true ;
else if ( state_str == "check_all" ) check_all = true ;
else return false ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
Player * player = getSelectedPlayer ();
if ( ! player ) player = m_session -> GetPlayer ();
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( ! list_queue && ! check_all )
{
state_str = "The player has the following " + state_str + " items: " ;
SendSysMessage ( state_str . c_str ());
2009-04-29 00:26:07 -05:00
for ( uint8 i = PLAYER_SLOT_START ; i < PLAYER_SLOT_END ; ++ i )
2008-10-02 16:23:55 -05:00
{
if ( i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END )
continue ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
Item * item = player -> GetItemByPos ( INVENTORY_SLOT_BAG_0 , i );
if ( ! item ) continue ;
if ( ! item -> IsBag ())
{
if ( item -> GetState () == state )
PSendSysMessage ( "bag: 255 slot: %d guid: %d owner: %d" , item -> GetSlot (), item -> GetGUIDLow (), GUID_LOPART ( item -> GetOwnerGUID ()));
}
else
{
Bag * bag = ( Bag * ) item ;
2008-11-06 08:20:26 -06:00
for ( uint8 j = 0 ; j < bag -> GetBagSize (); ++ j )
2008-10-02 16:23:55 -05:00
{
2009-04-27 18:42:35 -05:00
Item * item2 = bag -> GetItemByPos ( j );
if ( item2 && item2 -> GetState () == state )
PSendSysMessage ( "bag: 255 slot: %d guid: %d owner: %d" , item2 -> GetSlot (), item2 -> GetGUIDLow (), GUID_LOPART ( item2 -> GetOwnerGUID ()));
2008-10-02 16:23:55 -05:00
}
}
}
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( list_queue )
{
std :: vector < Item *> & updateQueue = player -> GetItemUpdateQueue ();
2009-10-17 16:20:24 -07:00
for ( size_t i = 0 ; i < updateQueue . size (); ++ i )
2008-10-02 16:23:55 -05:00
{
Item * item = updateQueue [ i ];
if ( ! item ) continue ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
Bag * container = item -> GetContainer ();
uint8 bag_slot = container ? container -> GetSlot () : uint8 ( INVENTORY_SLOT_BAG_0 );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
std :: string st ;
switch ( item -> GetState ())
{
case ITEM_UNCHANGED : st = "unchanged" ; break ;
case ITEM_CHANGED : st = "changed" ; break ;
case ITEM_NEW : st = "new" ; break ;
case ITEM_REMOVED : st = "removed" ; break ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
PSendSysMessage ( "bag: %d slot: %d guid: %d - state: %s" , bag_slot , item -> GetSlot (), item -> GetGUIDLow (), st . c_str ());
}
if ( updateQueue . empty ())
PSendSysMessage ( "updatequeue empty" );
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( check_all )
{
bool error = false ;
std :: vector < Item *> & updateQueue = player -> GetItemUpdateQueue ();
2009-04-29 00:26:07 -05:00
for ( uint8 i = PLAYER_SLOT_START ; i < PLAYER_SLOT_END ; ++ i )
2008-10-02 16:23:55 -05:00
{
if ( i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END )
continue ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
Item * item = player -> GetItemByPos ( INVENTORY_SLOT_BAG_0 , i );
if ( ! item ) continue ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( item -> GetSlot () != i )
{
PSendSysMessage ( "item at slot %d, guid %d has an incorrect slot value: %d" , i , item -> GetGUIDLow (), item -> GetSlot ());
error = true ; continue ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( item -> GetOwnerGUID () != player -> GetGUID ())
{
PSendSysMessage ( "for the item at slot %d and itemguid %d, owner's guid (%d) and player's guid (%d) don't match!" , item -> GetSlot (), item -> GetGUIDLow (), GUID_LOPART ( item -> GetOwnerGUID ()), player -> GetGUIDLow ());
error = true ; continue ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( Bag * container = item -> GetContainer ())
{
PSendSysMessage ( "item at slot: %d guid: %d has a container (slot: %d, guid: %d) but shouldnt!" , item -> GetSlot (), item -> GetGUIDLow (), container -> GetSlot (), container -> GetGUIDLow ());
error = true ; continue ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( item -> IsInUpdateQueue ())
{
uint16 qp = item -> GetQueuePos ();
if ( qp > updateQueue . size ())
{
PSendSysMessage ( "item at slot: %d guid: %d has a queuepos (%d) larger than the update queue size! " , item -> GetSlot (), item -> GetGUIDLow (), qp );
error = true ; continue ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( updateQueue [ qp ] == NULL )
{
PSendSysMessage ( "item at slot: %d guid: %d has a queuepos (%d) that points to NULL in the queue!" , item -> GetSlot (), item -> GetGUIDLow (), qp );
error = true ; continue ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( updateQueue [ qp ] != item )
{
PSendSysMessage ( "item at slot: %d guid: %d has has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)" , item -> GetSlot (), item -> GetGUIDLow (), qp , updateQueue [ qp ] -> GetBagSlot (), updateQueue [ qp ] -> GetSlot (), updateQueue [ qp ] -> GetGUIDLow ());
error = true ; continue ;
}
}
else if ( item -> GetState () != ITEM_UNCHANGED )
{
PSendSysMessage ( "item at slot: %d guid: %d is not in queue but should be (state: %d)!" , item -> GetSlot (), item -> GetGUIDLow (), item -> GetState ());
error = true ; continue ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( item -> IsBag ())
{
Bag * bag = ( Bag * ) item ;
2008-11-06 08:20:26 -06:00
for ( uint8 j = 0 ; j < bag -> GetBagSize (); ++ j )
2008-10-02 16:23:55 -05:00
{
2009-04-27 18:42:35 -05:00
Item * item2 = bag -> GetItemByPos ( j );
if ( ! item2 ) continue ;
2009-10-17 15:51:44 -07:00
2009-04-27 18:42:35 -05:00
if ( item2 -> GetSlot () != j )
2008-10-02 16:23:55 -05:00
{
2009-04-27 18:42:35 -05:00
PSendSysMessage ( "the item in bag %d slot %d, guid %d has an incorrect slot value: %d" , bag -> GetSlot (), j , item2 -> GetGUIDLow (), item2 -> GetSlot ());
2008-10-02 16:23:55 -05:00
error = true ; continue ;
}
2009-10-17 15:51:44 -07:00
2009-04-27 18:42:35 -05:00
if ( item2 -> GetOwnerGUID () != player -> GetGUID ())
2008-10-02 16:23:55 -05:00
{
2009-04-27 18:42:35 -05:00
PSendSysMessage ( "for the item in bag %d at slot %d and itemguid %d, owner's guid (%d) and player's guid (%d) don't match!" , bag -> GetSlot (), item2 -> GetSlot (), item2 -> GetGUIDLow (), GUID_LOPART ( item2 -> GetOwnerGUID ()), player -> GetGUIDLow ());
2008-10-02 16:23:55 -05:00
error = true ; continue ;
}
2009-10-17 15:51:44 -07:00
2009-04-27 18:42:35 -05:00
Bag * container = item2 -> GetContainer ();
2008-10-02 16:23:55 -05:00
if ( ! container )
{
2009-04-27 18:42:35 -05:00
PSendSysMessage ( "the item in bag %d at slot %d with guid %d has no container!" , bag -> GetSlot (), item2 -> GetSlot (), item2 -> GetGUIDLow ());
2008-10-02 16:23:55 -05:00
error = true ; continue ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( container != bag )
{
2009-04-27 18:42:35 -05:00
PSendSysMessage ( "the item in bag %d at slot %d with guid %d has a different container(slot %d guid %d)!" , bag -> GetSlot (), item2 -> GetSlot (), item2 -> GetGUIDLow (), container -> GetSlot (), container -> GetGUIDLow ());
2008-10-02 16:23:55 -05:00
error = true ; continue ;
}
2009-10-17 15:51:44 -07:00
2009-04-27 18:42:35 -05:00
if ( item2 -> IsInUpdateQueue ())
2008-10-02 16:23:55 -05:00
{
2009-04-27 18:42:35 -05:00
uint16 qp = item2 -> GetQueuePos ();
2008-10-02 16:23:55 -05:00
if ( qp > updateQueue . size ())
{
2009-04-27 18:42:35 -05:00
PSendSysMessage ( "item in bag: %d at slot: %d guid: %d has a queuepos (%d) larger than the update queue size! " , bag -> GetSlot (), item2 -> GetSlot (), item2 -> GetGUIDLow (), qp );
2008-10-02 16:23:55 -05:00
error = true ; continue ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( updateQueue [ qp ] == NULL )
{
2009-04-27 18:42:35 -05:00
PSendSysMessage ( "item in bag: %d at slot: %d guid: %d has a queuepos (%d) that points to NULL in the queue!" , bag -> GetSlot (), item2 -> GetSlot (), item2 -> GetGUIDLow (), qp );
2008-10-02 16:23:55 -05:00
error = true ; continue ;
}
2009-10-17 15:51:44 -07:00
2009-04-27 18:42:35 -05:00
if ( updateQueue [ qp ] != item2 )
2008-10-02 16:23:55 -05:00
{
2009-04-27 18:42:35 -05:00
PSendSysMessage ( "item in bag: %d at slot: %d guid: %d has has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)" , bag -> GetSlot (), item2 -> GetSlot (), item2 -> GetGUIDLow (), qp , updateQueue [ qp ] -> GetBagSlot (), updateQueue [ qp ] -> GetSlot (), updateQueue [ qp ] -> GetGUIDLow ());
2008-10-02 16:23:55 -05:00
error = true ; continue ;
}
}
2009-04-27 18:42:35 -05:00
else if ( item2 -> GetState () != ITEM_UNCHANGED )
2008-10-02 16:23:55 -05:00
{
2009-04-27 18:42:35 -05:00
PSendSysMessage ( "item in bag: %d at slot: %d guid: %d is not in queue but should be (state: %d)!" , bag -> GetSlot (), item2 -> GetSlot (), item2 -> GetGUIDLow (), item2 -> GetState ());
2008-10-02 16:23:55 -05:00
error = true ; continue ;
}
}
}
}
2009-10-17 15:51:44 -07:00
2009-10-17 16:20:24 -07:00
for ( size_t i = 0 ; i < updateQueue . size (); ++ i )
2008-10-02 16:23:55 -05:00
{
Item * item = updateQueue [ i ];
if ( ! item ) continue ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( item -> GetOwnerGUID () != player -> GetGUID ())
{
2009-07-12 17:52:27 +08:00
PSendSysMessage ( "queue(" SIZEFMTD "): for the an item (guid %d), the owner's guid (%d) and player's guid (%d) don't match!" , i , item -> GetGUIDLow (), GUID_LOPART ( item -> GetOwnerGUID ()), player -> GetGUIDLow ());
2008-10-02 16:23:55 -05:00
error = true ; continue ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( item -> GetQueuePos () != i )
{
2009-07-12 17:52:27 +08:00
PSendSysMessage ( "queue(" SIZEFMTD "): for the an item (guid %d), the queuepos doesn't match it's position in the queue!" , i , item -> GetGUIDLow ());
2008-10-02 16:23:55 -05:00
error = true ; continue ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( item -> GetState () == ITEM_REMOVED ) continue ;
Item * test = player -> GetItemByPos ( item -> GetBagSlot (), item -> GetSlot ());
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( test == NULL )
{
2009-07-12 17:52:27 +08:00
PSendSysMessage ( "queue(" SIZEFMTD "): the bag(%d) and slot(%d) values for the item with guid %d are incorrect, the player doesn't have an item at that position!" , i , item -> GetBagSlot (), item -> GetSlot (), item -> GetGUIDLow ());
2008-10-02 16:23:55 -05:00
error = true ; continue ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if ( test != item )
{
2009-07-12 17:52:27 +08:00
PSendSysMessage ( "queue(" SIZEFMTD "): the bag(%d) and slot(%d) values for the item with guid %d are incorrect, the item with guid %d is there instead!" , i , item -> GetBagSlot (), item -> GetSlot (), item -> GetGUIDLow (), test -> GetGUIDLow ());
2008-10-02 16:23:55 -05:00
error = true ; continue ;
}
}
if ( ! error )
SendSysMessage ( "All OK!" );
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
return true ;
}
2009-10-17 15:51:44 -07:00
2009-02-10 00:39:03 -06:00
bool ChatHandler :: HandleDebugBattlegroundCommand ( const char * /*args*/ )
{
sBattleGroundMgr . ToggleTesting ();
return true ;
}
2009-10-17 15:51:44 -07:00
2008-10-05 08:48:32 -05:00
bool ChatHandler :: HandleDebugArenaCommand ( const char * /*args*/ )
{
sBattleGroundMgr . ToggleArenaTesting ();
return true ;
}
2009-10-17 15:51:44 -07:00
2008-10-14 11:57:03 -05:00
bool ChatHandler :: HandleDebugThreatList ( const char * /*args*/ )
{
Creature * target = getSelectedCreature ();
if ( ! target || target -> isTotem () || target -> isPet ())
return false ;
2009-10-17 15:51:44 -07:00
2008-10-14 11:57:03 -05:00
std :: list < HostilReference *>& tlist = target -> getThreatManager (). getThreatList ();
std :: list < HostilReference *>:: iterator itr ;
uint32 cnt = 0 ;
PSendSysMessage ( "Threat list of %s (guid %u)" , target -> GetName (), target -> GetGUIDLow ());
2009-10-17 16:20:24 -07:00
for ( itr = tlist . begin (); itr != tlist . end (); ++ itr )
2008-10-14 11:57:03 -05:00
{
Unit * unit = ( * itr ) -> getTarget ();
if ( ! unit )
continue ;
++ cnt ;
PSendSysMessage ( " %u. %s (guid %u) - threat %f" , cnt , unit -> GetName (), unit -> GetGUIDLow (), ( * itr ) -> getThreat ());
}
SendSysMessage ( "End of threat list." );
return true ;
}
2009-10-17 15:51:44 -07:00
2008-10-14 11:57:03 -05:00
bool ChatHandler :: HandleDebugHostilRefList ( const char * /*args*/ )
{
Unit * target = getSelectedUnit ();
if ( ! target )
target = m_session -> GetPlayer ();
HostilReference * ref = target -> getHostilRefManager (). getFirst ();
uint32 cnt = 0 ;
PSendSysMessage ( "Hostil reference list of %s (guid %u)" , target -> GetName (), target -> GetGUIDLow ());
while ( ref )
{
if ( Unit * unit = ref -> getSource () -> getOwner ())
{
++ cnt ;
PSendSysMessage ( " %u. %s (guid %u) - threat %f" , cnt , unit -> GetName (), unit -> GetGUIDLow (), ref -> getThreat ());
}
ref = ref -> next ();
}
SendSysMessage ( "End of hostil reference list." );
2008-12-24 09:58:26 -06:00
return true ;
}
2009-10-17 15:51:44 -07:00
2009-04-17 15:08:58 -05:00
bool ChatHandler :: HandleDebugSetVehicleId ( const char * args )
{
Unit * target = getSelectedUnit ();
2009-08-23 22:09:43 -05:00
if ( ! target || target -> IsVehicle ())
2009-04-17 15:08:58 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2009-04-17 15:08:58 -05:00
if ( ! args )
return false ;
2009-10-17 15:51:44 -07:00
2009-04-17 15:08:58 -05:00
char * i = strtok (( char * ) args , " " );
if ( ! i )
return false ;
2009-10-17 15:51:44 -07:00
2009-04-17 15:08:58 -05:00
uint32 id = ( uint32 ) atoi ( i );
2009-08-23 22:09:43 -05:00
//target->SetVehicleId(id);
2009-04-17 15:08:58 -05:00
target -> SendUpdateObjectToAllExcept ( NULL );
PSendSysMessage ( "Vehicle id set to %u" , id );
return true ;
}
2009-10-17 15:51:44 -07:00
2009-04-17 15:08:58 -05:00
bool ChatHandler :: HandleDebugEnterVehicle ( const char * args )
{
Unit * target = getSelectedUnit ();
2009-08-23 22:09:43 -05:00
if ( ! target || ! target -> IsVehicle ())
2009-04-17 15:08:58 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2009-04-17 15:08:58 -05:00
if ( ! args )
return false ;
2009-10-17 15:51:44 -07:00
2009-04-17 15:08:58 -05:00
char * i = strtok (( char * ) args , " " );
if ( ! i )
return false ;
2009-10-17 15:51:44 -07:00
2009-04-25 08:58:16 -05:00
char * j = strtok ( NULL , " " );
2009-10-17 15:51:44 -07:00
2009-04-17 15:08:58 -05:00
uint32 entry = ( uint32 ) atoi ( i );
2009-04-25 08:58:16 -05:00
int8 seatId = j ? ( int8 ) atoi ( j ) : - 1 ;
2009-10-17 15:51:44 -07:00
2009-05-23 20:41:48 -05:00
if ( ! entry )
2009-08-23 22:09:43 -05:00
m_session -> GetPlayer () -> EnterVehicle ( target , seatId );
2009-05-23 20:41:48 -05:00
else
{
Creature * passenger = NULL ;
Trinity :: AllCreaturesOfEntryInRange check ( m_session -> GetPlayer (), entry , 20.0f );
2009-08-15 19:08:39 -07:00
Trinity :: CreatureSearcher < Trinity :: AllCreaturesOfEntryInRange > searcher ( m_session -> GetPlayer (), passenger , check );
2009-05-23 20:41:48 -05:00
m_session -> GetPlayer () -> VisitNearbyObject ( 30.0f , searcher );
if ( ! passenger || passenger == target )
return false ;
2009-08-23 22:09:43 -05:00
passenger -> EnterVehicle ( target , seatId );
2009-05-23 20:41:48 -05:00
}
2009-10-17 15:51:44 -07:00
2009-05-23 20:41:48 -05:00
PSendSysMessage ( "Unit %u entered vehicle %d" , entry , ( int32 ) seatId );
2009-04-17 15:08:58 -05:00
return true ;
}
2009-10-17 15:51:44 -07:00
2009-03-19 15:06:30 -06:00
bool ChatHandler :: HandleDebugSpawnVehicle ( const char * args )
2008-12-24 09:58:26 -06:00
{
2009-06-27 18:27:31 -05:00
if ( !* args )
2008-12-24 09:58:26 -06:00
return false ;
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
char * e = strtok (( char * ) args , " " );
char * i = strtok ( NULL , " " );
2009-10-17 15:51:44 -07:00
2009-06-14 09:57:57 -05:00
if ( ! e )
2008-12-24 09:58:26 -06:00
return false ;
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
uint32 entry = ( uint32 ) atoi ( e );
2009-10-17 15:51:44 -07:00
2009-06-14 09:57:57 -05:00
float x , y , z , o = m_session -> GetPlayer () -> GetOrientation ();
m_session -> GetPlayer () -> GetClosePoint ( x , y , z , m_session -> GetPlayer () -> GetObjectSize ());
2009-10-17 15:51:44 -07:00
2009-06-14 09:57:57 -05:00
if ( ! i )
2009-08-29 14:58:45 -05:00
return m_session -> GetPlayer () -> SummonCreature ( entry , x , y , z , o );
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
uint32 id = ( uint32 ) atoi ( i );
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
CreatureInfo const * ci = objmgr . GetCreatureTemplate ( entry );
2009-10-17 15:51:44 -07:00
2009-06-27 18:27:31 -05:00
if ( ! ci )
2008-12-24 09:58:26 -06:00
return false ;
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
VehicleEntry const * ve = sVehicleStore . LookupEntry ( id );
2009-10-17 15:51:44 -07:00
2009-06-27 18:27:31 -05:00
if ( ! ve )
2008-12-24 09:58:26 -06:00
return false ;
2009-10-17 15:51:44 -07:00
2009-08-23 22:09:43 -05:00
Creature * v = new Creature ;
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
Map * map = m_session -> GetPlayer () -> GetMap ();
2009-10-17 15:51:44 -07:00
2009-05-30 22:15:05 -05:00
if ( ! v -> Create ( objmgr . GenerateLowGuid ( HIGHGUID_VEHICLE ), map , m_session -> GetPlayer () -> GetPhaseMask (), entry , id , m_session -> GetPlayer () -> GetTeam (), x , y , z , o ))
2008-12-24 09:58:26 -06:00
{
2010-01-18 18:42:36 +01:00
v -> CleanupsBeforeDelete ();
2008-12-24 09:58:26 -06:00
delete v ;
return false ;
}
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
map -> Add (( Creature * ) v );
2009-10-17 15:51:44 -07:00
2008-10-14 11:57:03 -05:00
return true ;
2009-01-04 16:37:14 -06:00
}
2009-10-17 15:51:44 -07:00
2009-03-19 15:06:30 -06:00
bool ChatHandler :: HandleDebugSendLargePacketCommand ( const char * /*args*/ )
2009-01-04 16:37:14 -06:00
{
const char * stuffingString = "This is a dummy string to push the packet's size beyond 128000 bytes. " ;
std :: ostringstream ss ;
2009-02-24 11:14:28 -06:00
while ( ss . str (). size () < 128000 )
2009-01-04 16:37:14 -06:00
ss << stuffingString ;
SendSysMessage ( ss . str (). c_str ());
return true ;
}
2009-10-17 15:51:44 -07:00
2009-03-19 15:06:30 -06:00
bool ChatHandler :: HandleDebugSendSetPhaseShiftCommand ( const char * args )
2009-02-15 12:13:34 -06:00
{
2009-06-27 18:27:31 -05:00
if ( !* args )
2009-02-15 12:13:34 -06:00
return false ;
2009-10-17 15:51:44 -07:00
2009-02-15 12:13:34 -06:00
uint32 PhaseShift = atoi ( args );
m_session -> SendSetPhaseShift ( PhaseShift );
2009-02-19 22:30:30 -06:00
return true ;
2009-02-18 22:39:00 +01:00
}
2009-10-17 15:51:44 -07:00
2009-12-17 14:06:20 +01:00
bool ChatHandler :: HandleDebugGetItemValueCommand ( const char * args )
2009-03-21 14:53:38 -06:00
{
2009-06-27 18:27:31 -05:00
if ( !* args )
2009-03-21 14:53:38 -06:00
return false ;
2009-10-17 15:51:44 -07:00
2009-03-21 14:53:38 -06:00
char * e = strtok (( char * ) args , " " );
char * f = strtok ( NULL , " " );
2009-10-17 15:51:44 -07:00
2009-03-21 14:53:38 -06:00
if ( ! e || ! f )
return false ;
2009-10-17 15:51:44 -07:00
2009-03-21 14:53:38 -06:00
uint32 guid = ( uint32 ) atoi ( e );
2009-12-17 14:06:20 +01:00
uint32 index = ( uint32 ) atoi ( f );
2009-10-17 15:51:44 -07:00
2009-03-21 14:53:38 -06:00
Item * i = m_session -> GetPlayer () -> GetItemByGuid ( MAKE_NEW_GUID ( guid , 0 , HIGHGUID_ITEM ));
2009-10-17 15:51:44 -07:00
2009-06-27 18:27:31 -05:00
if ( ! i )
2009-03-21 14:53:38 -06:00
return false ;
2009-10-17 15:51:44 -07:00
2009-12-17 14:06:20 +01:00
if ( index >= i -> GetValuesCount ())
return false ;
uint32 value = i -> GetUInt32Value ( index );
PSendSysMessage ( "Item %u: value at %u is %u" , guid , index , value );
return true ;
}
bool ChatHandler :: HandleDebugSetItemValueCommand ( const char * args )
{
if ( !* args )
return false ;
char * e = strtok (( char * ) args , " " );
char * f = strtok ( NULL , " " );
char * g = strtok ( NULL , " " );
if ( ! e || ! f || ! g )
return false ;
uint32 guid = ( uint32 ) atoi ( e );
uint32 index = ( uint32 ) atoi ( f );
uint32 value = ( uint32 ) atoi ( g );
Item * i = m_session -> GetPlayer () -> GetItemByGuid ( MAKE_NEW_GUID ( guid , 0 , HIGHGUID_ITEM ));
if ( ! i )
return false ;
if ( index >= i -> GetValuesCount ())
return false ;
i -> SetUInt32Value ( index , value );
2009-10-17 15:51:44 -07:00
2009-03-21 14:53:38 -06:00
return true ;
}
2009-10-17 15:51:44 -07:00
2009-08-04 01:44:14 +02:00
bool ChatHandler :: HandleDebugItemExpireCommand ( const char * args )
{
if ( !* args )
return false ;
2009-10-17 15:51:44 -07:00
2009-08-04 01:44:14 +02:00
char * e = strtok (( char * ) args , " " );
if ( ! e )
return false ;
2009-10-17 15:51:44 -07:00
2009-08-04 01:44:14 +02:00
uint32 guid = ( uint32 ) atoi ( e );
2009-10-17 15:51:44 -07:00
2009-08-04 01:44:14 +02:00
Item * i = m_session -> GetPlayer () -> GetItemByGuid ( MAKE_NEW_GUID ( guid , 0 , HIGHGUID_ITEM ));
2009-10-17 15:51:44 -07:00
2009-08-04 01:44:14 +02:00
if ( ! i )
return false ;
2009-10-17 15:51:44 -07:00
2009-08-04 01:44:14 +02:00
m_session -> GetPlayer () -> DestroyItem ( i -> GetBagSlot (), i -> GetSlot (), true );
Script -> ItemExpire ( m_session -> GetPlayer (), i -> GetProto ());
2009-10-17 15:51:44 -07:00
2009-08-04 01:44:14 +02:00
return true ;
}
2009-10-17 15:51:44 -07:00
2009-04-05 16:43:17 -05:00
//show animation
bool ChatHandler :: HandleDebugAnimCommand ( const char * args )
{
if ( !* args )
return false ;
2009-10-17 15:51:44 -07:00
2009-04-05 16:43:17 -05:00
uint32 anim_id = atoi (( char * ) args );
m_session -> GetPlayer () -> HandleEmoteCommand ( anim_id );
return true ;
}
2009-10-17 15:51:44 -07:00
2009-06-27 18:27:31 -05:00
bool ChatHandler :: HandleDebugSetAuraStateCommand ( const char * args )
{
if ( !* args )
{
SendSysMessage ( LANG_BAD_VALUE );
SetSentErrorMessage ( true );
return false ;
}
2009-10-17 15:51:44 -07:00
2009-06-27 18:27:31 -05:00
Unit * unit = getSelectedUnit ();
if ( ! unit )
{
SendSysMessage ( LANG_SELECT_CHAR_OR_CREATURE );
SetSentErrorMessage ( true );
return false ;
}
2009-10-17 15:51:44 -07:00
2009-06-27 18:27:31 -05:00
int32 state = atoi (( char * ) args );
if ( ! state )
{
// reset all states
2009-10-17 16:20:24 -07:00
for ( int i = 1 ; i <= 32 ; ++ i )
2009-06-27 18:27:31 -05:00
unit -> ModifyAuraState ( AuraState ( i ), false );
return true ;
}
2009-10-17 15:51:44 -07:00
2009-06-27 18:27:31 -05:00
unit -> ModifyAuraState ( AuraState ( abs ( state )), state > 0 );
return true ;
}
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
bool ChatHandler :: HandleDebugSetValueCommand ( const char * args )
{
if ( !* args )
return false ;
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
char * px = strtok (( char * ) args , " " );
char * py = strtok ( NULL , " " );
char * pz = strtok ( NULL , " " );
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
if ( ! px || ! py )
return false ;
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
WorldObject * target = getSelectedObject ();
if ( ! target )
{
SendSysMessage ( LANG_SELECT_CHAR_OR_CREATURE );
SetSentErrorMessage ( true );
return false ;
}
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
uint64 guid = target -> GetGUID ();
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
uint32 Opcode = ( uint32 ) atoi ( px );
if ( Opcode >= target -> GetValuesCount ())
{
PSendSysMessage ( LANG_TOO_BIG_INDEX , Opcode , GUID_LOPART ( guid ), target -> GetValuesCount ());
return false ;
}
uint32 iValue ;
float fValue ;
bool isint32 = true ;
if ( pz )
isint32 = ( bool ) atoi ( pz );
if ( isint32 )
{
iValue = ( uint32 ) atoi ( py );
sLog . outDebug ( GetTrinityString ( LANG_SET_UINT ), GUID_LOPART ( guid ), Opcode , iValue );
target -> SetUInt32Value ( Opcode , iValue );
PSendSysMessage ( LANG_SET_UINT_FIELD , GUID_LOPART ( guid ), Opcode , iValue );
}
else
{
fValue = ( float ) atof ( py );
sLog . outDebug ( GetTrinityString ( LANG_SET_FLOAT ), GUID_LOPART ( guid ), Opcode , fValue );
target -> SetFloatValue ( Opcode , fValue );
PSendSysMessage ( LANG_SET_FLOAT_FIELD , GUID_LOPART ( guid ), Opcode , fValue );
}
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
return true ;
}
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
bool ChatHandler :: HandleDebugGetValueCommand ( const char * args )
{
if ( !* args )
return false ;
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
char * px = strtok (( char * ) args , " " );
char * pz = strtok ( NULL , " " );
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
if ( ! px )
return false ;
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
Unit * target = getSelectedUnit ();
if ( ! target )
{
SendSysMessage ( LANG_SELECT_CHAR_OR_CREATURE );
SetSentErrorMessage ( true );
return false ;
}
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
uint64 guid = target -> GetGUID ();
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
uint32 Opcode = ( uint32 ) atoi ( px );
if ( Opcode >= target -> GetValuesCount ())
{
PSendSysMessage ( LANG_TOO_BIG_INDEX , Opcode , GUID_LOPART ( guid ), target -> GetValuesCount ());
return false ;
}
uint32 iValue ;
float fValue ;
bool isint32 = true ;
if ( pz )
isint32 = ( bool ) atoi ( pz );
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
if ( isint32 )
{
iValue = target -> GetUInt32Value ( Opcode );
sLog . outDebug ( GetTrinityString ( LANG_GET_UINT ), GUID_LOPART ( guid ), Opcode , iValue );
PSendSysMessage ( LANG_GET_UINT_FIELD , GUID_LOPART ( guid ), Opcode , iValue );
}
else
{
fValue = target -> GetFloatValue ( Opcode );
sLog . outDebug ( GetTrinityString ( LANG_GET_FLOAT ), GUID_LOPART ( guid ), Opcode , fValue );
PSendSysMessage ( LANG_GET_FLOAT_FIELD , GUID_LOPART ( guid ), Opcode , fValue );
}
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
return true ;
}
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
bool ChatHandler :: HandleDebugMod32ValueCommand ( const char * args )
{
if ( !* args )
return false ;
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
char * px = strtok (( char * ) args , " " );
char * py = strtok ( NULL , " " );
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
if ( ! px || ! py )
return false ;
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
uint32 Opcode = ( uint32 ) atoi ( px );
int Value = atoi ( py );
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
if ( Opcode >= m_session -> GetPlayer () -> GetValuesCount ())
{
PSendSysMessage ( LANG_TOO_BIG_INDEX , Opcode , m_session -> GetPlayer () -> GetGUIDLow (), m_session -> GetPlayer ( ) -> GetValuesCount ());
return false ;
}
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
sLog . outDebug ( GetTrinityString ( LANG_CHANGE_32BIT ), Opcode , Value );
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
int CurrentValue = ( int ) m_session -> GetPlayer ( ) -> GetUInt32Value ( Opcode );
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
CurrentValue += Value ;
m_session -> GetPlayer ( ) -> SetUInt32Value ( Opcode , ( uint32 ) CurrentValue );
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
PSendSysMessage ( LANG_CHANGE_32BIT_FIELD , Opcode , CurrentValue );
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
return true ;
}
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
bool ChatHandler :: HandleDebugUpdateCommand ( const char * args )
{
if ( !* args )
return false ;
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
uint32 updateIndex ;
uint32 value ;
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
char * pUpdateIndex = strtok (( char * ) args , " " );
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
Unit * chr = getSelectedUnit ();
if ( chr == NULL )
{
SendSysMessage ( LANG_SELECT_CHAR_OR_CREATURE );
SetSentErrorMessage ( true );
return false ;
}
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
if ( ! pUpdateIndex )
{
return true ;
}
updateIndex = atoi ( pUpdateIndex );
//check updateIndex
if ( chr -> GetTypeId () == TYPEID_PLAYER )
{
if ( updateIndex >= PLAYER_END ) return true ;
}
else
{
if ( updateIndex >= UNIT_END ) return true ;
}
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
char * pvalue = strtok ( NULL , " " );
if ( ! pvalue )
{
value = chr -> GetUInt32Value ( updateIndex );
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
PSendSysMessage ( LANG_UPDATE , chr -> GetGUIDLow (), updateIndex , value );
return true ;
}
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
value = atoi ( pvalue );
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
PSendSysMessage ( LANG_UPDATE_CHANGE , chr -> GetGUIDLow (), updateIndex , value );
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
chr -> SetUInt32Value ( updateIndex , value );
2009-10-17 15:51:44 -07:00
2009-07-16 09:28:00 +08:00
return true ;
}