2010-11-09 10:15:35 -05:00
/*
2012-01-01 00:32:13 +01:00
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
2010-11-09 10:15:35 -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 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/>.
*/
/* ScriptData
Name: debug_commandscript
%Complete: 100
Comment: All debug related commands
Category: commandscripts
EndScriptData */
2010-11-13 22:29:46 +01:00
#include "ScriptMgr.h"
#include "ObjectMgr.h"
2010-11-09 10:15:35 -05:00
#include "BattlegroundMgr.h"
2010-11-13 22:29:46 +01:00
#include "Chat.h"
2010-11-14 00:13:51 +01:00
#include "Cell.h"
#include "CellImpl.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "GossipDef.h"
2010-11-13 22:29:46 +01:00
#include <fstream>
2010-11-09 10:15:35 -05:00
class debug_commandscript : public CommandScript
{
2010-11-19 14:04:21 +01:00
public :
debug_commandscript () : CommandScript ( "debug_commandscript" ) { }
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
ChatCommand * GetCommands () const
{
static ChatCommand debugPlayCommandTable [] =
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
{ "cinematic" , SEC_MODERATOR , false , & HandleDebugPlayCinematicCommand , "" , NULL },
{ "movie" , SEC_MODERATOR , false , & HandleDebugPlayMovieCommand , "" , NULL },
{ "sound" , SEC_MODERATOR , false , & HandleDebugPlaySoundCommand , "" , NULL },
2012-03-07 14:08:30 +01:00
{ NULL , SEC_PLAYER , false , NULL , "" , NULL }
2010-11-19 14:04:21 +01:00
};
static ChatCommand debugSendCommandTable [] =
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
{ "buyerror" , SEC_ADMINISTRATOR , false , & HandleDebugSendBuyErrorCommand , "" , NULL },
{ "channelnotify" , SEC_ADMINISTRATOR , false , & HandleDebugSendChannelNotifyCommand , "" , NULL },
{ "chatmmessage" , SEC_ADMINISTRATOR , false , & HandleDebugSendChatMsgCommand , "" , NULL },
{ "equiperror" , SEC_ADMINISTRATOR , false , & HandleDebugSendEquipErrorCommand , "" , NULL },
{ "largepacket" , SEC_ADMINISTRATOR , false , & HandleDebugSendLargePacketCommand , "" , NULL },
{ "opcode" , SEC_ADMINISTRATOR , false , & HandleDebugSendOpcodeCommand , "" , NULL },
{ "qpartymsg" , SEC_ADMINISTRATOR , false , & HandleDebugSendQuestPartyMsgCommand , "" , NULL },
2011-04-29 20:47:02 +02:00
{ "qinvalidmsg" , SEC_ADMINISTRATOR , false , & HandleDebugSendQuestInvalidMsgCommand , "" , NULL },
2010-11-19 14:04:21 +01:00
{ "sellerror" , SEC_ADMINISTRATOR , false , & HandleDebugSendSellErrorCommand , "" , NULL },
{ "setphaseshift" , SEC_ADMINISTRATOR , false , & HandleDebugSendSetPhaseShiftCommand , "" , NULL },
{ "spellfail" , SEC_ADMINISTRATOR , false , & HandleDebugSendSpellFailCommand , "" , NULL },
2012-03-07 14:08:30 +01:00
{ NULL , SEC_PLAYER , false , NULL , "" , NULL }
2010-11-19 14:04:21 +01:00
};
static ChatCommand debugCommandTable [] =
{
{ "setbit" , SEC_ADMINISTRATOR , false , & HandleDebugSet32BitCommand , "" , NULL },
{ "threat" , SEC_ADMINISTRATOR , false , & HandleDebugThreatListCommand , "" , NULL },
{ "hostil" , SEC_ADMINISTRATOR , false , & HandleDebugHostileRefListCommand , "" , NULL },
{ "anim" , SEC_GAMEMASTER , false , & HandleDebugAnimCommand , "" , NULL },
{ "arena" , SEC_ADMINISTRATOR , false , & HandleDebugArenaCommand , "" , NULL },
{ "bg" , SEC_ADMINISTRATOR , false , & HandleDebugBattlegroundCommand , "" , NULL },
{ "getitemstate" , SEC_ADMINISTRATOR , false , & HandleDebugGetItemStateCommand , "" , NULL },
2011-04-29 20:47:02 +02:00
{ "lootrecipient" , SEC_GAMEMASTER , false , & HandleDebugGetLootRecipientCommand , "" , NULL },
2010-11-19 14:04:21 +01:00
{ "getvalue" , SEC_ADMINISTRATOR , false , & HandleDebugGetValueCommand , "" , NULL },
{ "getitemvalue" , SEC_ADMINISTRATOR , false , & HandleDebugGetItemValueCommand , "" , NULL },
{ "Mod32Value" , SEC_ADMINISTRATOR , false , & HandleDebugMod32ValueCommand , "" , NULL },
{ "play" , SEC_MODERATOR , false , NULL , "" , debugPlayCommandTable },
{ "send" , SEC_ADMINISTRATOR , false , NULL , "" , debugSendCommandTable },
{ "setaurastate" , SEC_ADMINISTRATOR , false , & HandleDebugSetAuraStateCommand , "" , NULL },
{ "setitemvalue" , SEC_ADMINISTRATOR , false , & HandleDebugSetItemValueCommand , "" , NULL },
{ "setvalue" , SEC_ADMINISTRATOR , false , & HandleDebugSetValueCommand , "" , NULL },
{ "spawnvehicle" , SEC_ADMINISTRATOR , false , & HandleDebugSpawnVehicleCommand , "" , NULL },
{ "setvid" , SEC_ADMINISTRATOR , false , & HandleDebugSetVehicleIdCommand , "" , NULL },
{ "entervehicle" , SEC_ADMINISTRATOR , false , & HandleDebugEnterVehicleCommand , "" , NULL },
2011-04-29 20:47:02 +02:00
{ "uws" , SEC_ADMINISTRATOR , false , & HandleDebugUpdateWorldStateCommand , "" , NULL },
2010-11-19 14:04:21 +01:00
{ "update" , SEC_ADMINISTRATOR , false , & HandleDebugUpdateCommand , "" , NULL },
{ "itemexpire" , SEC_ADMINISTRATOR , false , & HandleDebugItemExpireCommand , "" , NULL },
{ "areatriggers" , SEC_ADMINISTRATOR , false , & HandleDebugAreaTriggersCommand , "" , NULL },
2012-02-03 16:03:52 -05:00
{ "los" , SEC_MODERATOR , false , & HandleDebugLoSCommand , "" , NULL },
2012-03-03 16:12:28 +01:00
{ "moveflags" , SEC_ADMINISTRATOR , false , & HandleDebugMoveflagsCommand , "" , NULL },
2012-03-07 14:08:30 +01:00
{ NULL , SEC_PLAYER , false , NULL , "" , NULL }
2010-11-19 14:04:21 +01:00
};
static ChatCommand commandTable [] =
{
{ "debug" , SEC_MODERATOR , true , NULL , "" , debugCommandTable },
2012-04-05 17:43:06 -05:00
{ "wpgps" , SEC_ADMINISTRATOR , false , & HandleWPGPSCommand , "" , NULL },
2012-03-07 14:08:30 +01:00
{ NULL , SEC_PLAYER , false , NULL , "" , NULL }
2010-11-19 14:04:21 +01:00
};
return commandTable ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugPlayCinematicCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
// USAGE: .debug play cinematic #cinematicid
// #cinematicid - ID decimal number from CinemaicSequences.dbc (1st column)
if ( !* args )
{
handler -> SendSysMessage ( LANG_BAD_VALUE );
handler -> SetSentErrorMessage ( true );
return false ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
uint32 id = atoi (( char * ) args );
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
if ( ! sCinematicSequencesStore . LookupEntry ( id ))
2010-11-19 14:04:21 +01:00
{
2011-10-10 10:33:13 -03:00
handler -> PSendSysMessage ( LANG_CINEMATIC_NOT_EXIST , id );
2010-11-19 14:04:21 +01:00
handler -> SetSentErrorMessage ( true );
return false ;
2010-11-09 10:15:35 -05:00
}
2011-10-10 10:33:13 -03:00
handler -> GetSession () -> GetPlayer () -> SendCinematicStart ( id );
2010-11-19 14:04:21 +01:00
return true ;
}
2011-10-10 10:33:13 -03:00
static bool HandleDebugPlayMovieCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
// USAGE: .debug play movie #movieid
// #movieid - ID decimal number from Movie.dbc (1st column)
if ( !* args )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
handler -> SendSysMessage ( LANG_BAD_VALUE );
handler -> SetSentErrorMessage ( true );
return false ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
uint32 id = atoi (( char * ) args );
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
if ( ! sMovieStore . LookupEntry ( id ))
2010-11-19 14:04:21 +01:00
{
2011-10-10 10:33:13 -03:00
handler -> PSendSysMessage ( LANG_MOVIE_NOT_EXIST , id );
2010-11-19 14:04:21 +01:00
handler -> SetSentErrorMessage ( true );
return false ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
handler -> GetSession () -> GetPlayer () -> SendMovieStart ( id );
2010-11-19 14:04:21 +01:00
return true ;
}
//Play sound
2011-10-10 10:33:13 -03:00
static bool HandleDebugPlaySoundCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
// USAGE: .debug playsound #soundid
// #soundid - ID decimal number from SoundEntries.dbc (1st column)
if ( !* args )
{
handler -> SendSysMessage ( LANG_BAD_VALUE );
handler -> SetSentErrorMessage ( true );
return false ;
2010-11-09 10:15:35 -05:00
}
2011-10-10 10:33:13 -03:00
uint32 soundId = atoi (( char * ) args );
2010-11-19 14:04:21 +01:00
2011-10-10 10:33:13 -03:00
if ( ! sSoundEntriesStore . LookupEntry ( soundId ))
2010-11-09 10:15:35 -05:00
{
2011-10-10 10:33:13 -03:00
handler -> PSendSysMessage ( LANG_SOUND_NOT_EXIST , soundId );
2010-11-19 14:04:21 +01:00
handler -> SetSentErrorMessage ( true );
return false ;
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
Unit * unit = handler -> getSelectedUnit ();
if ( ! unit )
{
handler -> SendSysMessage ( LANG_SELECT_CHAR_OR_CREATURE );
handler -> SetSentErrorMessage ( true );
return false ;
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( handler -> GetSession () -> GetPlayer () -> GetSelection ())
2011-10-10 10:33:13 -03:00
unit -> PlayDistanceSound ( soundId , handler -> GetSession () -> GetPlayer ());
2010-11-19 14:04:21 +01:00
else
2011-10-10 10:33:13 -03:00
unit -> PlayDirectSound ( soundId , handler -> GetSession () -> GetPlayer ());
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
handler -> PSendSysMessage ( LANG_YOU_HEAR_SOUND , soundId );
2010-11-19 14:04:21 +01:00
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugSendSpellFailCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
if ( !* args )
return false ;
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
char * result = strtok (( char * ) args , " " );
if ( ! result )
2010-11-19 14:04:21 +01:00
return false ;
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
uint8 failNum = ( uint8 ) atoi ( result );
if ( failNum == 0 && * result != '0' )
2010-11-19 14:04:21 +01:00
return false ;
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
char * fail1 = strtok ( NULL , " " );
uint8 failArg1 = fail1 ? ( uint8 ) atoi ( fail1 ) : 0 ;
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
char * fail2 = strtok ( NULL , " " );
uint8 failArg2 = fail2 ? ( uint8 ) atoi ( fail2 ) : 0 ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
WorldPacket data ( SMSG_CAST_FAILED , 5 );
data << uint8 ( 0 );
data << uint32 ( 133 );
2011-10-10 10:33:13 -03:00
data << uint8 ( failNum );
if ( fail1 || fail2 )
data << uint32 ( failArg1 );
if ( fail2 )
data << uint32 ( failArg2 );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
handler -> GetSession () -> SendPacket ( & data );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugSendEquipErrorCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
if ( !* args )
return false ;
2010-11-09 10:15:35 -05:00
2011-04-29 16:48:15 +06:00
InventoryResult msg = InventoryResult ( atoi ( args ));
2010-11-19 14:04:21 +01:00
handler -> GetSession () -> GetPlayer () -> SendEquipError ( msg , NULL , NULL );
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugSendSellErrorCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
if ( !* args )
return false ;
2010-11-09 10:15:35 -05:00
2011-04-29 16:48:15 +06:00
SellResult msg = SellResult ( atoi ( args ));
2010-11-19 14:04:21 +01:00
handler -> GetSession () -> GetPlayer () -> SendSellError ( msg , 0 , 0 , 0 );
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugSendBuyErrorCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
if ( !* args )
return false ;
2010-11-09 10:15:35 -05:00
2011-04-29 16:48:15 +06:00
BuyResult msg = BuyResult ( atoi ( args ));
2010-11-19 14:04:21 +01:00
handler -> GetSession () -> GetPlayer () -> SendBuyError ( msg , 0 , 0 , 0 );
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugSendOpcodeCommand ( ChatHandler * handler , char const * /*args*/ )
2010-11-19 14:04:21 +01:00
{
2011-06-30 14:24:56 +02:00
Unit * unit = handler -> getSelectedUnit ();
2011-06-12 01:47:45 +02:00
Player * player = NULL ;
2010-11-19 14:04:21 +01:00
if ( ! unit || ( unit -> GetTypeId () != TYPEID_PLAYER ))
player = handler -> GetSession () -> GetPlayer ();
else
player = ( Player * ) unit ;
2011-10-10 10:33:13 -03:00
if ( ! unit )
unit = player ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
std :: ifstream ifs ( "opcode.txt" );
if ( ifs . bad ())
return false ;
2010-11-09 10:15:35 -05:00
2011-09-01 10:46:15 +02:00
// remove comments from file
std :: stringstream parsedStream ;
while ( ! ifs . eof ())
{
char commentToken [ 2 ];
ifs . get ( commentToken [ 0 ]);
if ( commentToken [ 0 ] == '/' && ! ifs . eof ())
{
ifs . get ( commentToken [ 1 ]);
// /* comment
if ( commentToken [ 1 ] == '*' )
{
while ( ! ifs . eof ())
{
ifs . get ( commentToken [ 0 ]);
if ( commentToken [ 0 ] == '*' && ! ifs . eof ())
{
ifs . get ( commentToken [ 1 ]);
if ( commentToken [ 1 ] == '/' )
break ;
else
ifs . putback ( commentToken [ 1 ]);
}
}
continue ;
}
// line comment
else if ( commentToken [ 1 ] == '/' )
{
std :: string str ;
2011-09-29 12:43:05 +02:00
getline ( ifs , str );
2011-09-01 10:46:15 +02:00
continue ;
}
// regular data
else
ifs . putback ( commentToken [ 1 ]);
}
parsedStream . put ( commentToken [ 0 ]);
}
ifs . close ();
2010-11-19 14:04:21 +01:00
uint32 opcode ;
2011-09-01 10:46:15 +02:00
parsedStream >> opcode ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
WorldPacket data ( opcode , 0 );
2010-11-09 10:15:35 -05:00
2011-09-01 10:46:15 +02:00
while ( ! parsedStream . eof ())
2010-11-19 14:04:21 +01:00
{
std :: string type ;
2011-09-01 10:46:15 +02:00
parsedStream >> type ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( type == "" )
break ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( type == "uint8" )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
uint16 val1 ;
2011-09-01 10:46:15 +02:00
parsedStream >> val1 ;
2010-11-19 14:04:21 +01:00
data << uint8 ( val1 );
}
else if ( type == "uint16" )
{
uint16 val2 ;
2011-09-01 10:46:15 +02:00
parsedStream >> val2 ;
2010-11-19 14:04:21 +01:00
data << val2 ;
}
else if ( type == "uint32" )
{
uint32 val3 ;
2011-09-01 10:46:15 +02:00
parsedStream >> val3 ;
2010-11-19 14:04:21 +01:00
data << val3 ;
}
else if ( type == "uint64" )
{
uint64 val4 ;
2011-09-01 10:46:15 +02:00
parsedStream >> val4 ;
2010-11-19 14:04:21 +01:00
data << val4 ;
}
else if ( type == "float" )
{
float val5 ;
2011-09-01 10:46:15 +02:00
parsedStream >> val5 ;
2010-11-19 14:04:21 +01:00
data << val5 ;
}
else if ( type == "string" )
{
std :: string val6 ;
2011-09-01 10:46:15 +02:00
parsedStream >> val6 ;
2010-11-19 14:04:21 +01:00
data << val6 ;
}
else if ( type == "appitsguid" )
{
data . append ( unit -> GetPackGUID ());
}
else if ( type == "appmyguid" )
{
data . append ( player -> GetPackGUID ());
}
else if ( type == "appgoguid" )
{
2011-06-30 14:24:56 +02:00
GameObject * obj = handler -> GetNearbyGameObject ();
2010-11-19 14:04:21 +01:00
if ( ! obj )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
handler -> PSendSysMessage ( LANG_COMMAND_OBJNOTFOUND , 0 );
handler -> SetSentErrorMessage ( true );
ifs . close ();
return false ;
2010-11-09 10:15:35 -05:00
}
2010-11-19 14:04:21 +01:00
data . append ( obj -> GetPackGUID ());
}
else if ( type == "goguid" )
{
2011-06-30 14:24:56 +02:00
GameObject * obj = handler -> GetNearbyGameObject ();
2010-11-19 14:04:21 +01:00
if ( ! obj )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
handler -> PSendSysMessage ( LANG_COMMAND_OBJNOTFOUND , 0 );
handler -> SetSentErrorMessage ( true );
ifs . close ();
return false ;
2010-11-09 10:15:35 -05:00
}
2010-11-19 14:04:21 +01:00
data << uint64 ( obj -> GetGUID ());
2010-11-09 10:15:35 -05:00
}
2010-11-19 14:04:21 +01:00
else if ( type == "myguid" )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
data << uint64 ( player -> GetGUID ());
}
else if ( type == "itsguid" )
{
data << uint64 ( unit -> GetGUID ());
}
2011-09-01 10:46:15 +02:00
else if ( type == "itspos" )
2010-11-19 14:04:21 +01:00
{
data << unit -> GetPositionX ();
data << unit -> GetPositionY ();
data << unit -> GetPositionZ ();
}
else if ( type == "mypos" )
{
data << player -> GetPositionX ();
data << player -> GetPositionY ();
data << player -> GetPositionZ ();
}
else
{
2011-08-09 07:40:49 -03:00
sLog -> outError ( "Sending opcode that has unknown type '%s'" , type . c_str ());
2010-11-19 14:04:21 +01:00
break ;
2010-11-09 10:15:35 -05:00
}
}
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_NETWORKIO , "Sending opcode %u" , data . GetOpcode ());
2010-11-19 14:04:21 +01:00
data . hexlike ();
player -> GetSession () -> SendPacket ( & data );
handler -> PSendSysMessage ( LANG_COMMAND_OPCODESENT , data . GetOpcode (), unit -> GetName ());
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugUpdateWorldStateCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
char * w = strtok (( char * ) args , " " );
char * s = strtok ( NULL , " " );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( ! w || ! s )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
uint32 world = ( uint32 ) atoi ( w );
uint32 state = ( uint32 ) atoi ( s );
handler -> GetSession () -> GetPlayer () -> SendUpdateWorldState ( world , state );
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugAreaTriggersCommand ( ChatHandler * handler , char const * /*args*/ )
2010-11-19 14:04:21 +01:00
{
2011-07-01 03:00:39 +02:00
Player * player = handler -> GetSession () -> GetPlayer ();
if ( ! player -> isDebugAreaTriggers )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
handler -> PSendSysMessage ( LANG_DEBUG_AREATRIGGER_ON );
2011-07-01 03:00:39 +02:00
player -> isDebugAreaTriggers = true ;
2011-10-10 10:33:13 -03:00
}
else
{
2010-11-19 14:04:21 +01:00
handler -> PSendSysMessage ( LANG_DEBUG_AREATRIGGER_OFF );
2011-07-01 03:00:39 +02:00
player -> isDebugAreaTriggers = false ;
2010-11-09 10:15:35 -05:00
}
2010-11-19 14:04:21 +01:00
return true ;
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
//Send notification in channel
2011-10-10 10:33:13 -03:00
static bool HandleDebugSendChannelNotifyCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
if ( !* args )
return false ;
2011-10-10 10:33:13 -03:00
char const * name = "test" ;
2010-11-19 14:04:21 +01:00
uint8 code = atoi ( args );
WorldPacket data ( SMSG_CHANNEL_NOTIFY , ( 1 + 10 ));
data << code ; // notify type
data << name ; // channel name
data << uint32 ( 0 );
data << uint32 ( 0 );
handler -> GetSession () -> SendPacket ( & data );
return true ;
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
//Send notification in chat
2011-10-10 10:33:13 -03:00
static bool HandleDebugSendChatMsgCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
if ( !* args )
return false ;
2011-10-10 10:33:13 -03:00
char const * msg = "testtest" ;
2010-11-19 14:04:21 +01:00
uint8 type = atoi ( args );
WorldPacket data ;
ChatHandler :: FillMessageData ( & data , handler -> GetSession (), type , 0 , "chan" , handler -> GetSession () -> GetPlayer () -> GetGUID (), msg , handler -> GetSession () -> GetPlayer ());
handler -> GetSession () -> SendPacket ( & data );
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugSendQuestPartyMsgCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
uint32 msg = atol (( char * ) args );
handler -> GetSession () -> GetPlayer () -> SendPushToPartyResponse ( handler -> GetSession () -> GetPlayer (), msg );
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugGetLootRecipientCommand ( ChatHandler * handler , char const * /*args*/ )
2010-11-19 14:04:21 +01:00
{
Creature * target = handler -> getSelectedCreature ();
if ( ! target )
return false ;
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
handler -> PSendSysMessage ( "Loot recipient for creature %s (GUID %u, DB GUID %u) is %s" , target -> GetName (), target -> GetGUIDLow (), target -> GetDBTableGUIDLow (), target -> hasLootRecipient () ? ( target -> GetLootRecipient () ? target -> GetLootRecipient () -> GetName () : "offline" ) : "no loot recipient" );
2010-11-19 14:04:21 +01:00
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugSendQuestInvalidMsgCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
uint32 msg = atol (( char * ) args );
handler -> GetSession () -> GetPlayer () -> SendCanTakeQuestResponse ( msg );
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugGetItemStateCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
if ( !* args )
return false ;
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
std :: string itemState = args ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
ItemUpdateState state = ITEM_UNCHANGED ;
2011-10-10 10:33:13 -03:00
bool listQueue = false ;
bool checkAll = false ;
if ( itemState == "unchanged" )
state = ITEM_UNCHANGED ;
else if ( itemState == "changed" )
state = ITEM_CHANGED ;
else if ( itemState == "new" )
state = ITEM_NEW ;
else if ( itemState == "removed" )
state = ITEM_REMOVED ;
else if ( itemState == "queue" )
listQueue = true ;
else if ( itemState == "check_all" )
checkAll = true ;
else
return false ;
2010-11-19 14:04:21 +01:00
Player * player = handler -> getSelectedPlayer ();
2011-10-10 10:33:13 -03:00
if ( ! player )
player = handler -> GetSession () -> GetPlayer ();
2010-11-19 14:04:21 +01:00
2011-10-10 10:33:13 -03:00
if ( ! listQueue && ! checkAll )
2010-11-19 14:04:21 +01:00
{
2011-10-10 10:33:13 -03:00
itemState = "The player has the following " + itemState + " items: " ;
handler -> SendSysMessage ( itemState . c_str ());
2010-11-19 14:04:21 +01:00
for ( uint8 i = PLAYER_SLOT_START ; i < PLAYER_SLOT_END ; ++ i )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
if ( i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END )
continue ;
2010-11-09 10:15:35 -05:00
2011-06-30 14:24:56 +02:00
if ( Item * item = player -> GetItemByPos ( INVENTORY_SLOT_BAG_0 , i ))
2010-11-19 14:04:21 +01:00
{
2011-03-18 15:58:08 +06:00
if ( Bag * bag = item -> ToBag ())
2010-11-09 10:15:35 -05:00
{
2011-03-18 15:58:08 +06:00
for ( uint8 j = 0 ; j < bag -> GetBagSize (); ++ j )
if ( Item * item2 = bag -> GetItemByPos ( j ))
if ( item2 -> GetState () == state )
handler -> PSendSysMessage ( "bag: 255 slot: %d guid: %d owner: %d" , item2 -> GetSlot (), item2 -> GetGUIDLow (), GUID_LOPART ( item2 -> GetOwnerGUID ()));
2010-11-09 10:15:35 -05:00
}
2011-03-18 15:58:08 +06:00
else if ( item -> GetState () == state )
handler -> PSendSysMessage ( "bag: 255 slot: %d guid: %d owner: %d" , item -> GetSlot (), item -> GetGUIDLow (), GUID_LOPART ( item -> GetOwnerGUID ()));
2010-11-09 10:15:35 -05:00
}
}
2010-11-19 14:04:21 +01:00
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
if ( listQueue )
2010-11-19 14:04:21 +01:00
{
2011-10-10 10:33:13 -03:00
std :: vector < Item *>& updateQueue = player -> GetItemUpdateQueue ();
2010-11-19 14:04:21 +01:00
for ( size_t i = 0 ; i < updateQueue . size (); ++ i )
2010-11-09 10:15:35 -05:00
{
2011-06-30 14:24:56 +02:00
Item * item = updateQueue [ i ];
2011-10-10 10:33:13 -03:00
if ( ! item )
continue ;
2010-11-09 10:15:35 -05:00
2011-09-15 14:08:17 +02:00
Bag * container = item -> GetContainer ();
2011-10-10 10:33:13 -03:00
uint8 bagSlot = container ? container -> GetSlot () : uint8 ( INVENTORY_SLOT_BAG_0 );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
std :: string st ;
2011-09-29 12:43:05 +02:00
switch ( item -> GetState ())
2010-11-19 14:04:21 +01:00
{
2011-10-10 10:33:13 -03:00
case ITEM_UNCHANGED :
st = "unchanged" ;
break ;
case ITEM_CHANGED :
st = "changed" ;
break ;
case ITEM_NEW :
st = "new" ;
break ;
case ITEM_REMOVED :
st = "removed" ;
break ;
2010-11-09 10:15:35 -05:00
}
2010-11-19 14:04:21 +01:00
2011-10-10 10:33:13 -03:00
handler -> PSendSysMessage ( "bag: %d slot: %d guid: %d - state: %s" , bagSlot , item -> GetSlot (), item -> GetGUIDLow (), st . c_str ());
2010-11-09 10:15:35 -05:00
}
2010-11-19 14:04:21 +01:00
if ( updateQueue . empty ())
2011-08-09 07:40:49 -03:00
handler -> PSendSysMessage ( "The player's updatequeue is empty" );
2010-11-19 14:04:21 +01:00
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
if ( checkAll )
2010-11-19 14:04:21 +01:00
{
bool error = false ;
2011-10-10 10:33:13 -03:00
std :: vector < Item *>& updateQueue = player -> GetItemUpdateQueue ();
2010-11-19 14:04:21 +01:00
for ( uint8 i = PLAYER_SLOT_START ; i < PLAYER_SLOT_END ; ++ i )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
if ( i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END )
continue ;
2011-06-30 14:24:56 +02:00
Item * item = player -> GetItemByPos ( INVENTORY_SLOT_BAG_0 , i );
2011-10-10 10:33:13 -03:00
if ( ! item )
continue ;
2010-11-19 14:04:21 +01:00
if ( item -> GetSlot () != i )
2010-11-09 10:15:35 -05:00
{
2011-08-09 07:40:49 -03:00
handler -> PSendSysMessage ( "Item with slot %d and guid %d has an incorrect slot value: %d" , i , item -> GetGUIDLow (), item -> GetSlot ());
2011-10-10 10:33:13 -03:00
error = true ;
continue ;
2010-11-19 14:04:21 +01:00
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( item -> GetOwnerGUID () != player -> GetGUID ())
{
2011-08-09 07:40:49 -03:00
handler -> PSendSysMessage ( "The item with slot %d and itemguid %d does have non-matching owner guid (%d) and player guid (%d) !" , item -> GetSlot (), item -> GetGUIDLow (), GUID_LOPART ( item -> GetOwnerGUID ()), player -> GetGUIDLow ());
2011-10-10 10:33:13 -03:00
error = true ;
continue ;
2010-11-19 14:04:21 +01:00
}
2010-11-09 10:15:35 -05:00
2011-09-15 14:08:17 +02:00
if ( Bag * container = item -> GetContainer ())
2010-11-19 14:04:21 +01:00
{
2011-08-09 07:40:49 -03:00
handler -> PSendSysMessage ( "The item with slot %d and guid %d has a container (slot: %d, guid: %d) but shouldn't!" , item -> GetSlot (), item -> GetGUIDLow (), container -> GetSlot (), container -> GetGUIDLow ());
2011-10-10 10:33:13 -03:00
error = true ;
continue ;
2010-11-19 14:04:21 +01:00
}
if ( item -> IsInUpdateQueue ())
{
uint16 qp = item -> GetQueuePos ();
if ( qp > updateQueue . size ())
2010-11-09 10:15:35 -05:00
{
2011-08-09 07:40:49 -03:00
handler -> PSendSysMessage ( "The item with slot %d and guid %d has its queuepos (%d) larger than the update queue size! " , item -> GetSlot (), item -> GetGUIDLow (), qp );
2011-10-10 10:33:13 -03:00
error = true ;
continue ;
2010-11-09 10:15:35 -05:00
}
2010-11-19 14:04:21 +01:00
if ( updateQueue [ qp ] == NULL )
2010-11-09 10:15:35 -05:00
{
2011-08-09 07:40:49 -03:00
handler -> PSendSysMessage ( "The item with slot %d and guid %d has its queuepos (%d) pointing to NULL in the queue!" , item -> GetSlot (), item -> GetGUIDLow (), qp );
2011-10-10 10:33:13 -03:00
error = true ;
continue ;
2010-11-09 10:15:35 -05:00
}
2010-11-19 14:04:21 +01:00
if ( updateQueue [ qp ] != item )
2010-11-09 10:15:35 -05:00
{
2011-08-09 07:40:49 -03:00
handler -> PSendSysMessage ( "The item with slot %d and guid %d 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 ());
2011-10-10 10:33:13 -03:00
error = true ;
continue ;
2010-11-09 10:15:35 -05:00
}
2010-11-19 14:04:21 +01:00
}
else if ( item -> GetState () != ITEM_UNCHANGED )
{
2011-08-09 07:40:49 -03:00
handler -> PSendSysMessage ( "The item with slot %d and guid %d is not in queue but should be (state: %d)!" , item -> GetSlot (), item -> GetGUIDLow (), item -> GetState ());
2011-10-10 10:33:13 -03:00
error = true ;
continue ;
2010-11-19 14:04:21 +01:00
}
2010-11-09 10:15:35 -05:00
2011-03-18 15:58:08 +06:00
if ( Bag * bag = item -> ToBag ())
2010-11-19 14:04:21 +01:00
{
for ( uint8 j = 0 ; j < bag -> GetBagSize (); ++ j )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
Item * item2 = bag -> GetItemByPos ( j );
2011-10-10 10:33:13 -03:00
if ( ! item2 )
continue ;
2010-11-19 14:04:21 +01:00
if ( item2 -> GetSlot () != j )
2010-11-09 10:15:35 -05:00
{
2011-08-09 07:40:49 -03:00
handler -> PSendSysMessage ( "The item in bag %d and slot %d (guid: %d) has an incorrect slot value: %d" , bag -> GetSlot (), j , item2 -> GetGUIDLow (), item2 -> GetSlot ());
2011-10-10 10:33:13 -03:00
error = true ;
continue ;
2010-11-09 10:15:35 -05:00
}
2010-11-19 14:04:21 +01:00
if ( item2 -> GetOwnerGUID () != player -> GetGUID ())
2010-11-09 10:15:35 -05:00
{
2011-08-09 07:40:49 -03:00
handler -> PSendSysMessage ( "The item in bag %d at slot %d and with itemguid %d, the owner's guid (%d) and the player's guid (%d) don't match!" , bag -> GetSlot (), item2 -> GetSlot (), item2 -> GetGUIDLow (), GUID_LOPART ( item2 -> GetOwnerGUID ()), player -> GetGUIDLow ());
2011-10-10 10:33:13 -03:00
error = true ;
continue ;
2010-11-09 10:15:35 -05:00
}
2011-09-15 14:08:17 +02:00
Bag * container = item2 -> GetContainer ();
2010-11-19 14:04:21 +01:00
if ( ! container )
2010-11-09 10:15:35 -05:00
{
2011-08-09 07:40:49 -03:00
handler -> PSendSysMessage ( "The item in bag %d at slot %d with guid %d has no container!" , bag -> GetSlot (), item2 -> GetSlot (), item2 -> GetGUIDLow ());
2011-10-10 10:33:13 -03:00
error = true ;
continue ;
2010-11-09 10:15:35 -05:00
}
2010-11-19 14:04:21 +01:00
if ( container != bag )
2010-11-09 10:15:35 -05:00
{
2011-08-09 07:40:49 -03:00
handler -> 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 ());
2011-10-10 10:33:13 -03:00
error = true ;
continue ;
2010-11-19 14:04:21 +01:00
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( item2 -> IsInUpdateQueue ())
{
uint16 qp = item2 -> GetQueuePos ();
if ( qp > updateQueue . size ())
2010-11-09 10:15:35 -05:00
{
2011-08-09 07:40:49 -03:00
handler -> PSendSysMessage ( "The item in bag %d at slot %d having guid %d has a queuepos (%d) larger than the update queue size! " , bag -> GetSlot (), item2 -> GetSlot (), item2 -> GetGUIDLow (), qp );
2011-10-10 10:33:13 -03:00
error = true ;
continue ;
2010-11-09 10:15:35 -05:00
}
2010-11-19 14:04:21 +01:00
if ( updateQueue [ qp ] == NULL )
2010-11-09 10:15:35 -05:00
{
2011-08-09 07:40:49 -03:00
handler -> PSendSysMessage ( "The item in bag %d at slot %d having guid %d has a queuepos (%d) that points to NULL in the queue!" , bag -> GetSlot (), item2 -> GetSlot (), item2 -> GetGUIDLow (), qp );
2011-10-10 10:33:13 -03:00
error = true ;
continue ;
2010-11-09 10:15:35 -05:00
}
2010-11-19 14:04:21 +01:00
if ( updateQueue [ qp ] != item2 )
2010-11-09 10:15:35 -05:00
{
2011-08-09 07:40:49 -03:00
handler -> PSendSysMessage ( "The item in bag %d at slot %d having guid %d 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 ());
2011-10-10 10:33:13 -03:00
error = true ;
continue ;
2010-11-09 10:15:35 -05:00
}
}
2010-11-19 14:04:21 +01:00
else if ( item2 -> GetState () != ITEM_UNCHANGED )
{
2011-08-09 07:40:49 -03:00
handler -> PSendSysMessage ( "The item in bag %d at slot %d having guid %d is not in queue but should be (state: %d)!" , bag -> GetSlot (), item2 -> GetSlot (), item2 -> GetGUIDLow (), item2 -> GetState ());
2011-10-10 10:33:13 -03:00
error = true ;
continue ;
2010-11-19 14:04:21 +01:00
}
2010-11-09 10:15:35 -05:00
}
}
2010-11-19 14:04:21 +01:00
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
for ( size_t i = 0 ; i < updateQueue . size (); ++ i )
{
2011-06-30 14:24:56 +02:00
Item * item = updateQueue [ i ];
2011-10-10 10:33:13 -03:00
if ( ! item )
continue ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( item -> GetOwnerGUID () != player -> GetGUID ())
{
2011-08-09 07:40:49 -03:00
handler -> PSendSysMessage ( "queue(" SIZEFMTD "): For the item with guid %d, the owner's guid (%d) and the player's guid (%d) don't match!" , i , item -> GetGUIDLow (), GUID_LOPART ( item -> GetOwnerGUID ()), player -> GetGUIDLow ());
2011-10-10 10:33:13 -03:00
error = true ;
continue ;
2010-11-19 14:04:21 +01:00
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( item -> GetQueuePos () != i )
{
2011-08-09 07:40:49 -03:00
handler -> PSendSysMessage ( "queue(" SIZEFMTD "): For the item with guid %d, the queuepos doesn't match it's position in the queue!" , i , item -> GetGUIDLow ());
2011-10-10 10:33:13 -03:00
error = true ;
continue ;
2010-11-19 14:04:21 +01:00
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
if ( item -> GetState () == ITEM_REMOVED )
continue ;
2011-06-30 14:24:56 +02:00
Item * test = player -> GetItemByPos ( item -> GetBagSlot (), item -> GetSlot ());
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( test == NULL )
{
2011-08-09 07:40:49 -03:00
handler -> PSendSysMessage ( "queue(" SIZEFMTD "): The bag(%d) and slot(%d) values for the item with guid %d are incorrect, the player doesn't have any item at that position!" , i , item -> GetBagSlot (), item -> GetSlot (), item -> GetGUIDLow ());
2011-10-10 10:33:13 -03:00
error = true ;
continue ;
2010-11-19 14:04:21 +01:00
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( test != item )
{
2011-08-09 07:40:49 -03:00
handler -> PSendSysMessage ( "queue(" SIZEFMTD "): The bag(%d) and slot(%d) values for the item with guid %d are incorrect, an item which guid is %d is there instead!" , i , item -> GetBagSlot (), item -> GetSlot (), item -> GetGUIDLow (), test -> GetGUIDLow ());
2011-10-10 10:33:13 -03:00
error = true ;
continue ;
2010-11-09 10:15:35 -05:00
}
}
2010-11-19 14:04:21 +01:00
if ( ! error )
handler -> SendSysMessage ( "All OK!" );
2010-11-09 10:15:35 -05:00
}
2010-11-19 14:04:21 +01:00
return true ;
}
2011-10-10 10:33:13 -03:00
static bool HandleDebugBattlegroundCommand ( ChatHandler * /*handler*/ , char const * /*args*/ )
2010-11-19 14:04:21 +01:00
{
2010-12-22 21:25:23 +01:00
sBattlegroundMgr -> ToggleTesting ();
2010-11-19 14:04:21 +01:00
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugArenaCommand ( ChatHandler * /*handler*/ , char const * /*args*/ )
2010-11-19 14:04:21 +01:00
{
2010-12-22 21:25:23 +01:00
sBattlegroundMgr -> ToggleArenaTesting ();
2010-11-19 14:04:21 +01:00
return true ;
}
2011-10-10 10:33:13 -03:00
static bool HandleDebugThreatListCommand ( ChatHandler * handler , char const * /*args*/ )
2010-11-19 14:04:21 +01:00
{
Creature * target = handler -> getSelectedCreature ();
if ( ! target || target -> isTotem () || target -> isPet ())
return false ;
2011-10-10 10:33:13 -03:00
std :: list < HostileReference *>& threatList = target -> getThreatManager (). getThreatList ();
2010-11-19 14:04:21 +01:00
std :: list < HostileReference *>:: iterator itr ;
2011-10-10 10:33:13 -03:00
uint32 count = 0 ;
2011-04-29 20:47:02 +02:00
handler -> PSendSysMessage ( "Threat list of %s (guid %u)" , target -> GetName (), target -> GetGUIDLow ());
2011-10-10 10:33:13 -03:00
for ( itr = threatList . begin (); itr != threatList . end (); ++ itr )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
Unit * unit = ( * itr ) -> getTarget ();
if ( ! unit )
continue ;
2011-10-10 10:33:13 -03:00
++ count ;
handler -> PSendSysMessage ( " %u. %s (guid %u) - threat %f" , count , unit -> GetName (), unit -> GetGUIDLow (), ( * itr ) -> getThreat ());
2010-11-09 10:15:35 -05:00
}
2010-11-19 14:04:21 +01:00
handler -> SendSysMessage ( "End of threat list." );
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugHostileRefListCommand ( ChatHandler * handler , char const * /*args*/ )
2010-11-19 14:04:21 +01:00
{
Unit * target = handler -> getSelectedUnit ();
if ( ! target )
target = handler -> GetSession () -> GetPlayer ();
HostileReference * ref = target -> getHostileRefManager (). getFirst ();
2011-10-10 10:33:13 -03:00
uint32 count = 0 ;
2011-04-29 20:47:02 +02:00
handler -> PSendSysMessage ( "Hostil reference list of %s (guid %u)" , target -> GetName (), target -> GetGUIDLow ());
2010-11-19 14:04:21 +01:00
while ( ref )
2010-11-09 10:15:35 -05:00
{
2011-06-11 22:35:29 +02:00
if ( Unit * unit = ref -> getSource () -> getOwner ())
2010-11-09 10:15:35 -05:00
{
2011-10-10 10:33:13 -03:00
++ count ;
handler -> PSendSysMessage ( " %u. %s (guid %u) - threat %f" , count , unit -> GetName (), unit -> GetGUIDLow (), ref -> getThreat ());
2010-11-09 10:15:35 -05:00
}
2010-11-19 14:04:21 +01:00
ref = ref -> next ();
2010-11-09 10:15:35 -05:00
}
2010-11-19 14:04:21 +01:00
handler -> SendSysMessage ( "End of hostil reference list." );
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugSetVehicleIdCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
Unit * target = handler -> getSelectedUnit ();
if ( ! target || target -> IsVehicle ())
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( ! args )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
char * i = strtok (( char * ) args , " " );
if ( ! i )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
uint32 id = ( uint32 ) atoi ( i );
//target->SetVehicleId(id);
handler -> PSendSysMessage ( "Vehicle id set to %u" , id );
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugEnterVehicleCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
Unit * target = handler -> getSelectedUnit ();
if ( ! target || ! target -> IsVehicle ())
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( ! args )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
char * i = strtok (( char * ) args , " " );
if ( ! i )
return false ;
char * j = strtok ( NULL , " " );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
uint32 entry = ( uint32 ) atoi ( i );
int8 seatId = j ? ( int8 ) atoi ( j ) : - 1 ;
if ( ! entry )
handler -> GetSession () -> GetPlayer () -> EnterVehicle ( target , seatId );
else
{
2011-06-30 14:24:56 +02:00
Creature * passenger = NULL ;
2010-11-19 14:04:21 +01:00
Trinity :: AllCreaturesOfEntryInRange check ( handler -> GetSession () -> GetPlayer (), entry , 20.0f );
Trinity :: CreatureSearcher < Trinity :: AllCreaturesOfEntryInRange > searcher ( handler -> GetSession () -> GetPlayer (), passenger , check );
handler -> GetSession () -> GetPlayer () -> VisitNearbyObject ( 30.0f , searcher );
if ( ! passenger || passenger == target )
2010-11-09 10:15:35 -05:00
return false ;
2010-11-19 14:04:21 +01:00
passenger -> EnterVehicle ( target , seatId );
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
handler -> PSendSysMessage ( "Unit %u entered vehicle %d" , entry , ( int32 ) seatId );
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugSpawnVehicleCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
if ( !* args )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
char * e = strtok (( char * ) args , " " );
char * i = strtok ( NULL , " " );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( ! e )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
uint32 entry = ( uint32 ) atoi ( e );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
float x , y , z , o = handler -> GetSession () -> GetPlayer () -> GetOrientation ();
handler -> GetSession () -> GetPlayer () -> GetClosePoint ( x , y , z , handler -> GetSession () -> GetPlayer () -> GetObjectSize ());
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( ! i )
return handler -> GetSession () -> GetPlayer () -> SummonCreature ( entry , x , y , z , o );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
uint32 id = ( uint32 ) atoi ( i );
2010-11-09 10:15:35 -05:00
2011-09-15 14:08:17 +02:00
CreatureTemplate const * ci = sObjectMgr -> GetCreatureTemplate ( entry );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( ! ci )
return false ;
2010-11-09 10:15:35 -05:00
2011-09-15 14:08:17 +02:00
VehicleEntry const * ve = sVehicleStore . LookupEntry ( id );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( ! ve )
return false ;
2010-11-09 10:15:35 -05:00
2011-06-30 14:24:56 +02:00
Creature * v = new Creature ;
2010-11-09 10:15:35 -05:00
2011-09-15 14:08:17 +02:00
Map * map = handler -> GetSession () -> GetPlayer () -> GetMap ();
2010-11-09 10:15:35 -05:00
2010-12-22 21:25:23 +01:00
if ( ! v -> Create ( sObjectMgr -> GenerateLowGuid ( HIGHGUID_VEHICLE ), map , handler -> GetSession () -> GetPlayer () -> GetPhaseMask (), entry , id , handler -> GetSession () -> GetPlayer () -> GetTeam (), x , y , z , o ))
2010-11-19 14:04:21 +01:00
{
delete v ;
return false ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 17:39:34 -04:00
map -> AddToMap ( v -> ToCreature ());
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugSendLargePacketCommand ( ChatHandler * handler , char const * /*args*/ )
2010-11-19 14:04:21 +01:00
{
const char * stuffingString = "This is a dummy string to push the packet's size beyond 128000 bytes. " ;
std :: ostringstream ss ;
while ( ss . str (). size () < 128000 )
ss << stuffingString ;
handler -> SendSysMessage ( ss . str (). c_str ());
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugSendSetPhaseShiftCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
if ( !* args )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
uint32 PhaseShift = atoi ( args );
handler -> GetSession () -> SendSetPhaseShift ( PhaseShift );
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugGetItemValueCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
if ( !* args )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
char * e = strtok (( char * ) args , " " );
char * f = strtok ( NULL , " " );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( ! e || ! f )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
uint32 guid = ( uint32 ) atoi ( e );
uint32 index = ( uint32 ) atoi ( f );
2010-11-09 10:15:35 -05:00
2011-06-30 14:24:56 +02:00
Item * i = handler -> GetSession () -> GetPlayer () -> GetItemByGuid ( MAKE_NEW_GUID ( guid , 0 , HIGHGUID_ITEM ));
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( ! i )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( index >= i -> GetValuesCount ())
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
uint32 value = i -> GetUInt32Value ( index );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
handler -> PSendSysMessage ( "Item %u: value at %u is %u" , guid , index , value );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugSetItemValueCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
if ( !* args )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
char * e = strtok (( char * ) args , " " );
char * f = strtok ( NULL , " " );
char * g = strtok ( NULL , " " );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( ! e || ! f || ! g )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
uint32 guid = ( uint32 ) atoi ( e );
uint32 index = ( uint32 ) atoi ( f );
uint32 value = ( uint32 ) atoi ( g );
2010-11-09 10:15:35 -05:00
2011-06-30 14:24:56 +02:00
Item * i = handler -> GetSession () -> GetPlayer () -> GetItemByGuid ( MAKE_NEW_GUID ( guid , 0 , HIGHGUID_ITEM ));
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( ! i )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( index >= i -> GetValuesCount ())
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
i -> SetUInt32Value ( index , value );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugItemExpireCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
if ( !* args )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
char * e = strtok (( char * ) args , " " );
if ( ! e )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
uint32 guid = ( uint32 ) atoi ( e );
2010-11-09 10:15:35 -05:00
2011-06-30 14:24:56 +02:00
Item * i = handler -> GetSession () -> GetPlayer () -> GetItemByGuid ( MAKE_NEW_GUID ( guid , 0 , HIGHGUID_ITEM ));
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( ! i )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
handler -> GetSession () -> GetPlayer () -> DestroyItem ( i -> GetBagSlot (), i -> GetSlot (), true );
2011-04-28 22:42:33 +02:00
sScriptMgr -> OnItemExpire ( handler -> GetSession () -> GetPlayer (), i -> GetTemplate ());
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
return true ;
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
//show animation
2011-10-10 10:33:13 -03:00
static bool HandleDebugAnimCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
if ( !* args )
return false ;
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
uint32 animId = atoi (( char * ) args );
handler -> GetSession () -> GetPlayer () -> HandleEmoteCommand ( animId );
2010-11-19 14:04:21 +01:00
return true ;
}
2012-02-18 16:52:08 +01:00
2012-02-16 13:56:08 +01:00
static bool HandleDebugLoSCommand ( ChatHandler * handler , char const * /*args*/ )
2012-02-03 16:03:52 -05:00
{
if ( Unit * unit = handler -> getSelectedUnit ())
handler -> PSendSysMessage ( "Unit %s (GuidLow: %u) is %sin LoS" , unit -> GetName (), unit -> GetGUIDLow (), handler -> GetSession () -> GetPlayer () -> IsWithinLOSInMap ( unit ) ? "" : "not " );
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugSetAuraStateCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
if ( !* args )
{
handler -> SendSysMessage ( LANG_BAD_VALUE );
handler -> SetSentErrorMessage ( true );
return false ;
2010-11-09 10:15:35 -05:00
}
2010-11-19 14:04:21 +01:00
Unit * unit = handler -> getSelectedUnit ();
if ( ! unit )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
handler -> SendSysMessage ( LANG_SELECT_CHAR_OR_CREATURE );
handler -> SetSentErrorMessage ( true );
return false ;
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
int32 state = atoi (( char * ) args );
if ( ! state )
{
// reset all states
for ( int i = 1 ; i <= 32 ; ++ i )
2011-07-26 23:09:28 +02:00
unit -> ModifyAuraState ( AuraStateType ( i ), false );
2010-11-09 10:15:35 -05:00
return true ;
}
2011-07-26 23:09:28 +02:00
unit -> ModifyAuraState ( AuraStateType ( abs ( state )), state > 0 );
2010-11-19 14:04:21 +01:00
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugSetValueCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
if ( !* args )
return false ;
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
char * x = strtok (( char * ) args , " " );
char * y = strtok ( NULL , " " );
char * z = strtok ( NULL , " " );
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
if ( ! x || ! y )
2010-11-19 14:04:21 +01:00
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
WorldObject * target = handler -> getSelectedObject ();
if ( ! target )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
handler -> SendSysMessage ( LANG_SELECT_CHAR_OR_CREATURE );
handler -> SetSentErrorMessage ( true );
return false ;
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
uint64 guid = target -> GetGUID ();
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
uint32 opcode = ( uint32 ) atoi ( x );
if ( opcode >= target -> GetValuesCount ())
2010-11-19 14:04:21 +01:00
{
2011-10-10 10:33:13 -03:00
handler -> PSendSysMessage ( LANG_TOO_BIG_INDEX , opcode , GUID_LOPART ( guid ), target -> GetValuesCount ());
2010-11-19 14:04:21 +01:00
return false ;
}
2011-08-30 23:09:39 +03:00
2011-10-10 10:33:13 -03:00
bool isInt32 = true ;
if ( z )
isInt32 = ( bool ) atoi ( z );
if ( isInt32 )
2010-11-19 14:04:21 +01:00
{
2011-10-10 10:33:13 -03:00
uint32 value = ( uint32 ) atoi ( y );
target -> SetUInt32Value ( opcode , value );
handler -> PSendSysMessage ( LANG_SET_UINT_FIELD , GUID_LOPART ( guid ), opcode , value );
2010-11-19 14:04:21 +01:00
}
else
{
2011-10-10 10:33:13 -03:00
float value = ( float ) atof ( y );
target -> SetFloatValue ( opcode , value );
handler -> PSendSysMessage ( LANG_SET_FLOAT_FIELD , GUID_LOPART ( guid ), opcode , value );
2010-11-19 14:04:21 +01:00
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugGetValueCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
if ( !* args )
return false ;
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
char * x = strtok (( char * ) args , " " );
char * z = strtok ( NULL , " " );
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
if ( ! x )
2010-11-19 14:04:21 +01:00
return false ;
Unit * target = handler -> getSelectedUnit ();
if ( ! target )
{
handler -> SendSysMessage ( LANG_SELECT_CHAR_OR_CREATURE );
handler -> SetSentErrorMessage ( true );
return false ;
2010-11-09 10:15:35 -05:00
}
2010-11-19 14:04:21 +01:00
uint64 guid = target -> GetGUID ();
2011-10-10 10:33:13 -03:00
uint32 opcode = ( uint32 ) atoi ( x );
if ( opcode >= target -> GetValuesCount ())
2010-11-09 10:15:35 -05:00
{
2011-10-10 10:33:13 -03:00
handler -> PSendSysMessage ( LANG_TOO_BIG_INDEX , opcode , GUID_LOPART ( guid ), target -> GetValuesCount ());
2010-11-19 14:04:21 +01:00
return false ;
}
2011-08-30 23:09:39 +03:00
2011-10-10 10:33:13 -03:00
bool isInt32 = true ;
if ( z )
isInt32 = ( bool ) atoi ( z );
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
if ( isInt32 )
2010-11-19 14:04:21 +01:00
{
2011-10-10 10:33:13 -03:00
uint32 value = target -> GetUInt32Value ( opcode );
handler -> PSendSysMessage ( LANG_GET_UINT_FIELD , GUID_LOPART ( guid ), opcode , value );
2010-11-19 14:04:21 +01:00
}
else
{
2011-10-10 10:33:13 -03:00
float value = target -> GetFloatValue ( opcode );
handler -> PSendSysMessage ( LANG_GET_FLOAT_FIELD , GUID_LOPART ( guid ), opcode , value );
2010-11-19 14:04:21 +01:00
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugMod32ValueCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
if ( !* args )
return false ;
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
char * x = strtok (( char * ) args , " " );
char * y = strtok ( NULL , " " );
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
if ( ! x || ! y )
2010-11-19 14:04:21 +01:00
return false ;
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
uint32 opcode = ( uint32 ) atoi ( x );
int value = atoi ( y );
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
if ( opcode >= handler -> GetSession () -> GetPlayer () -> GetValuesCount ())
2010-11-19 14:04:21 +01:00
{
2011-10-10 10:33:13 -03:00
handler -> PSendSysMessage ( LANG_TOO_BIG_INDEX , opcode , handler -> GetSession () -> GetPlayer () -> GetGUIDLow (), handler -> GetSession () -> GetPlayer () -> GetValuesCount ());
2010-11-19 14:04:21 +01:00
return false ;
2010-11-09 10:15:35 -05:00
}
2011-10-10 10:33:13 -03:00
int currentValue = ( int ) handler -> GetSession () -> GetPlayer () -> GetUInt32Value ( opcode );
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
currentValue += value ;
2012-03-07 14:08:30 +01:00
handler -> GetSession () -> GetPlayer () -> SetUInt32Value ( opcode , ( uint32 ) currentValue );
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
handler -> PSendSysMessage ( LANG_CHANGE_32BIT_FIELD , opcode , currentValue );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
static bool HandleDebugUpdateCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
if ( !* args )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
uint32 updateIndex ;
uint32 value ;
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
char * index = strtok (( char * ) args , " " );
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
Unit * unit = handler -> getSelectedUnit ();
if ( ! unit )
2010-11-19 14:04:21 +01:00
{
handler -> SendSysMessage ( LANG_SELECT_CHAR_OR_CREATURE );
handler -> SetSentErrorMessage ( true );
return false ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
if ( ! index )
2010-11-09 10:15:35 -05:00
return true ;
2011-10-10 10:33:13 -03:00
updateIndex = atoi ( index );
2010-11-19 14:04:21 +01:00
//check updateIndex
2011-10-10 10:33:13 -03:00
if ( unit -> GetTypeId () == TYPEID_PLAYER )
2010-11-19 14:04:21 +01:00
{
2011-10-10 10:33:13 -03:00
if ( updateIndex >= PLAYER_END )
return true ;
2010-11-19 14:04:21 +01:00
}
2011-10-10 10:33:13 -03:00
else if ( updateIndex >= UNIT_END )
return true ;
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
char * val = strtok ( NULL , " " );
if ( ! val )
2010-11-19 14:04:21 +01:00
{
2011-10-10 10:33:13 -03:00
value = unit -> GetUInt32Value ( updateIndex );
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
handler -> PSendSysMessage ( LANG_UPDATE , unit -> GetGUIDLow (), updateIndex , value );
2010-11-19 14:04:21 +01:00
return true ;
}
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
value = atoi ( val );
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
handler -> PSendSysMessage ( LANG_UPDATE_CHANGE , unit -> GetGUIDLow (), updateIndex , value );
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
unit -> SetUInt32Value ( updateIndex , value );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
return true ;
}
2011-10-10 10:33:13 -03:00
static bool HandleDebugSet32BitCommand ( ChatHandler * handler , char const * args )
2010-11-19 14:04:21 +01:00
{
if ( !* args )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
WorldObject * target = handler -> getSelectedObject ();
if ( ! target )
{
handler -> SendSysMessage ( LANG_SELECT_CHAR_OR_CREATURE );
handler -> SetSentErrorMessage ( true );
return false ;
2010-11-09 10:15:35 -05:00
}
2011-10-10 10:33:13 -03:00
char * x = strtok (( char * ) args , " " );
char * y = strtok ( NULL , " " );
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
if ( ! x || ! y )
2010-11-19 14:04:21 +01:00
return false ;
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
uint32 opcode = ( uint32 ) atoi ( x );
uint32 val = ( uint32 ) atoi ( y );
if ( val > 32 ) //uint32 = 32 bits
2010-11-19 14:04:21 +01:00
return false ;
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
uint32 value = val ? 1 << ( val - 1 ) : 0 ;
target -> SetUInt32Value ( opcode , value );
2010-11-09 10:15:35 -05:00
2011-10-10 10:33:13 -03:00
handler -> PSendSysMessage ( LANG_SET_32BIT_FIELD , opcode , value );
2010-11-19 14:04:21 +01:00
return true ;
}
2012-03-03 16:12:28 +01:00
static bool HandleDebugMoveflagsCommand ( ChatHandler * handler , char const * args )
{
Unit * target = handler -> getSelectedUnit ();
if ( ! target )
target = handler -> GetSession () -> GetPlayer ();
if ( !* args )
{
//! Display case
handler -> PSendSysMessage ( LANG_MOVEFLAGS_GET , target -> GetUnitMovementFlags (), target -> GetExtraUnitMovementFlags ());
}
else
{
char * mask1 = strtok (( char * ) args , " " );
if ( ! mask1 )
return false ;
char * mask2 = strtok ( NULL , " \n " );
2012-03-07 00:05:34 +01:00
2012-03-03 16:12:28 +01:00
uint32 moveFlags = ( uint32 ) atoi ( mask1 );
target -> SetUnitMovementFlags ( moveFlags );
2012-03-07 00:05:34 +01:00
2012-03-03 16:12:28 +01:00
if ( mask2 )
{
uint32 moveFlagsExtra = uint32 ( atoi ( mask2 ));
target -> SetExtraUnitMovementFlags ( moveFlagsExtra );
}
target -> SendMovementFlagUpdate ();
handler -> PSendSysMessage ( LANG_MOVEFLAGS_SET , target -> GetUnitMovementFlags (), target -> GetExtraUnitMovementFlags ());
}
2012-03-07 00:05:34 +01:00
2012-03-03 16:23:16 +01:00
return true ;
2012-03-03 16:12:28 +01:00
}
2012-04-05 17:43:06 -05:00
static bool HandleWPGPSCommand ( ChatHandler * handler , char const * /*args*/ )
{
Player * player = handler -> GetSession () -> GetPlayer ();
sLog -> outSQLDev ( "(@PATH, XX, %.3f, %.3f, %.5f, 0,0, 0,100, 0)," , player -> GetPositionX (), player -> GetPositionY (), player -> GetPositionZ ());
handler -> PSendSysMessage ( "Waypoint SQL written to SQL Developer log" );
return true ;
}
2010-11-09 10:15:35 -05:00
};
void AddSC_debug_commandscript ()
{
new debug_commandscript ();
}