2010-11-09 10:15:35 -05:00
/*
2011-01-01 15:01:13 +01:00
* Copyright (C) 2008-2011 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 },
{ NULL , 0 , false , NULL , "" , NULL }
};
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 },
{ NULL , 0 , false , NULL , "" , NULL }
};
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 },
{ NULL , 0 , false , NULL , "" , NULL }
};
static ChatCommand commandTable [] =
{
{ "debug" , SEC_MODERATOR , true , NULL , "" , debugCommandTable },
{ NULL , 0 , false , NULL , "" , NULL }
};
return commandTable ;
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
static bool HandleDebugPlayCinematicCommand ( ChatHandler * handler , const char * args )
{
// 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
2010-11-19 14:04:21 +01:00
uint32 dwId = atoi (( char * ) args );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( ! sCinematicSequencesStore . LookupEntry ( dwId ))
{
handler -> PSendSysMessage ( LANG_CINEMATIC_NOT_EXIST , dwId );
handler -> SetSentErrorMessage ( true );
return false ;
2010-11-09 10:15:35 -05:00
}
2010-11-19 14:04:21 +01:00
handler -> GetSession () -> GetPlayer () -> SendCinematicStart ( dwId );
return true ;
}
static bool HandleDebugPlayMovieCommand ( ChatHandler * handler , const char * args )
{
// 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
2010-11-19 14:04:21 +01:00
uint32 dwId = atoi (( char * ) args );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( ! sMovieStore . LookupEntry ( dwId ))
{
handler -> PSendSysMessage ( LANG_MOVIE_NOT_EXIST , dwId );
handler -> SetSentErrorMessage ( true );
return false ;
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
handler -> GetSession () -> GetPlayer () -> SendMovieStart ( dwId );
return true ;
}
//Play sound
static bool HandleDebugPlaySoundCommand ( ChatHandler * handler , const char * args )
{
// 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
}
2010-11-19 14:04:21 +01:00
uint32 dwSoundId = atoi (( char * ) args );
if ( ! sSoundEntriesStore . LookupEntry ( dwSoundId ))
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
handler -> PSendSysMessage ( LANG_SOUND_NOT_EXIST , dwSoundId );
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-04-29 20:47:02 +02:00
unit -> PlayDistanceSound ( dwSoundId , handler -> GetSession () -> GetPlayer ());
2010-11-19 14:04:21 +01:00
else
2011-04-29 20:47:02 +02:00
unit -> PlayDirectSound ( dwSoundId , handler -> GetSession () -> GetPlayer ());
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
handler -> PSendSysMessage ( LANG_YOU_HEAR_SOUND , dwSoundId );
return true ;
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
static bool HandleDebugSendSpellFailCommand ( ChatHandler * handler , const char * args )
{
if ( !* args )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
char * px = strtok (( char * ) args , " " );
if ( ! px )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
uint8 failnum = ( uint8 ) atoi ( px );
if ( failnum == 0 && * px != '0' )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
char * p1 = strtok ( NULL , " " );
uint8 failarg1 = p1 ? ( uint8 ) atoi ( p1 ) : 0 ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
char * p2 = strtok ( NULL , " " );
uint8 failarg2 = p2 ? ( uint8 ) atoi ( p2 ) : 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 );
data << uint8 ( failnum );
if ( p1 || p2 )
data << uint32 ( failarg1 );
if ( p2 )
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
2010-11-19 14:04:21 +01:00
static bool HandleDebugSendEquipErrorCommand ( ChatHandler * handler , const char * args )
{
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
2010-11-19 14:04:21 +01:00
static bool HandleDebugSendSellErrorCommand ( ChatHandler * handler , const char * args )
{
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
2010-11-19 14:04:21 +01:00
static bool HandleDebugSendBuyErrorCommand ( ChatHandler * handler , const char * args )
{
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
2010-11-19 14:04:21 +01:00
static bool HandleDebugSendOpcodeCommand ( ChatHandler * handler , const char * /*args*/ )
{
Unit * unit = handler -> getSelectedUnit ();
Player * player = NULL ;
if ( ! unit || ( unit -> GetTypeId () != TYPEID_PLAYER ))
player = handler -> GetSession () -> GetPlayer ();
else
player = ( Player * ) unit ;
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
2010-11-19 14:04:21 +01:00
uint32 opcode ;
ifs >> 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
2010-11-19 14:04:21 +01:00
while ( ! ifs . eof ())
{
std :: string type ;
ifs >> 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 ;
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 ;
}
else if ( type == "appitsguid" )
{
data . append ( unit -> GetPackGUID ());
}
else if ( type == "appmyguid" )
{
data . append ( player -> GetPackGUID ());
}
else if ( type == "appgoguid" )
{
GameObject * obj = handler -> GetNearbyGameObject ();
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" )
{
GameObject * obj = handler -> GetNearbyGameObject ();
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 ());
}
else if ( type == "pos" )
{
data << unit -> GetPositionX ();
data << unit -> GetPositionY ();
data << unit -> GetPositionZ ();
}
else if ( type == "mypos" )
{
data << player -> GetPositionX ();
data << player -> GetPositionY ();
data << player -> GetPositionZ ();
}
else
{
2011-02-20 20:16:34 +01:00
sLog -> outError ( "Sending opcode: unknown type '%s'" , type . c_str ());
2010-11-19 14:04:21 +01:00
break ;
2010-11-09 10:15:35 -05:00
}
}
2010-11-19 14:04:21 +01:00
ifs . close ();
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
2010-11-19 14:04:21 +01:00
static bool HandleDebugUpdateWorldStateCommand ( ChatHandler * handler , const char * args )
{
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
2010-11-19 14:04:21 +01:00
static bool HandleDebugAreaTriggersCommand ( ChatHandler * handler , const char * /*args*/ )
{
Player * plr = handler -> GetSession () -> GetPlayer ();
if ( ! plr -> isDebugAreaTriggers )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
handler -> PSendSysMessage ( LANG_DEBUG_AREATRIGGER_ON );
plr -> isDebugAreaTriggers = true ;
} else {
handler -> PSendSysMessage ( LANG_DEBUG_AREATRIGGER_OFF );
plr -> 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
static bool HandleDebugSendChannelNotifyCommand ( ChatHandler * handler , const char * args )
{
if ( !* args )
return false ;
const char * name = "test" ;
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
static bool HandleDebugSendChatMsgCommand ( ChatHandler * handler , const char * args )
{
if ( !* args )
return false ;
const char * msg = "testtest" ;
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
2010-11-19 14:04:21 +01:00
static bool HandleDebugSendQuestPartyMsgCommand ( ChatHandler * handler , const char * args )
{
uint32 msg = atol (( char * ) args );
handler -> GetSession () -> GetPlayer () -> SendPushToPartyResponse ( handler -> GetSession () -> GetPlayer (), msg );
return true ;
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
static bool HandleDebugGetLootRecipientCommand ( ChatHandler * handler , const char * /*args*/ )
{
Creature * target = handler -> getSelectedCreature ();
if ( ! target )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
handler -> PSendSysMessage ( "loot recipient: %s" , target -> hasLootRecipient () ? ( target -> GetLootRecipient () ? target -> GetLootRecipient () -> GetName () : "offline" ) : "no loot recipient" );
return true ;
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
static bool HandleDebugSendQuestInvalidMsgCommand ( ChatHandler * handler , const char * args )
{
uint32 msg = atol (( char * ) args );
handler -> GetSession () -> GetPlayer () -> SendCanTakeQuestResponse ( msg );
return true ;
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
static bool HandleDebugGetItemStateCommand ( ChatHandler * handler , const char * args )
{
if ( !* args )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
std :: string state_str = args ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01: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 ;
Player * player = handler -> getSelectedPlayer ();
if ( ! player ) player = handler -> GetSession () -> GetPlayer ();
if ( ! list_queue && ! check_all )
{
state_str = "The player has the following " + state_str + " items: " ;
handler -> SendSysMessage ( state_str . c_str ());
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-03-18 15:58:08 +06: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
2010-11-19 14:04:21 +01:00
if ( list_queue )
{
std :: vector < Item *> & updateQueue = player -> GetItemUpdateQueue ();
for ( size_t i = 0 ; i < updateQueue . size (); ++ i )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
Item * item = updateQueue [ i ];
if ( ! item ) continue ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
Bag * container = item -> GetContainer ();
uint8 bag_slot = 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 ;
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 ;
2010-11-09 10:15:35 -05:00
}
2010-11-19 14:04:21 +01:00
handler -> PSendSysMessage ( "bag: %d slot: %d guid: %d - state: %s" , bag_slot , 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 ())
handler -> PSendSysMessage ( "updatequeue empty" );
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( check_all )
{
bool error = false ;
std :: vector < Item *> & updateQueue = player -> GetItemUpdateQueue ();
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 ;
Item * item = player -> GetItemByPos ( INVENTORY_SLOT_BAG_0 , i );
if ( ! item ) continue ;
if ( item -> GetSlot () != i )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
handler -> PSendSysMessage ( "item at slot %d, guid %d has an incorrect slot value: %d" , i , item -> GetGUIDLow (), item -> GetSlot ());
error = true ; continue ;
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( item -> GetOwnerGUID () != player -> GetGUID ())
{
handler -> 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 ;
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( Bag * container = item -> GetContainer ())
{
handler -> 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 ;
}
if ( item -> IsInUpdateQueue ())
{
uint16 qp = item -> GetQueuePos ();
if ( qp > updateQueue . size ())
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
handler -> PSendSysMessage ( "item at slot: %d guid: %d has a queuepos (%d) larger than the update queue size! " , item -> GetSlot (), item -> GetGUIDLow (), qp );
2010-11-09 10:15:35 -05:00
error = true ; continue ;
}
2010-11-19 14:04:21 +01:00
if ( updateQueue [ qp ] == NULL )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
handler -> PSendSysMessage ( "item at slot: %d guid: %d has a queuepos (%d) that points to NULL in the queue!" , item -> GetSlot (), item -> GetGUIDLow (), qp );
2010-11-09 10:15:35 -05:00
error = true ; continue ;
}
2010-11-19 14:04:21 +01:00
if ( updateQueue [ qp ] != item )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
handler -> 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 ());
2010-11-09 10:15:35 -05:00
error = true ; continue ;
}
2010-11-19 14:04:21 +01:00
}
else if ( item -> GetState () != ITEM_UNCHANGED )
{
handler -> 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 ;
}
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 );
if ( ! item2 ) continue ;
if ( item2 -> GetSlot () != j )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
handler -> PSendSysMessage ( "the item in bag %d slot %d, guid %d has an incorrect slot value: %d" , bag -> GetSlot (), j , item2 -> GetGUIDLow (), item2 -> GetSlot ());
2010-11-09 10:15:35 -05:00
error = true ; continue ;
}
2010-11-19 14:04:21 +01:00
if ( item2 -> GetOwnerGUID () != player -> GetGUID ())
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
handler -> 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 ());
2010-11-09 10:15:35 -05:00
error = true ; continue ;
}
2010-11-19 14:04:21 +01:00
Bag * container = item2 -> GetContainer ();
if ( ! container )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
handler -> PSendSysMessage ( "the item in bag %d at slot %d with guid %d has no container!" , bag -> GetSlot (), item2 -> GetSlot (), item2 -> GetGUIDLow ());
2010-11-09 10:15:35 -05:00
error = true ; continue ;
}
2010-11-19 14:04:21 +01:00
if ( container != bag )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01: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 ());
error = true ; continue ;
}
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
{
2010-11-19 14:04:21 +01:00
handler -> 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 );
2010-11-09 10:15:35 -05:00
error = true ; continue ;
}
2010-11-19 14:04:21 +01:00
if ( updateQueue [ qp ] == NULL )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
handler -> 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 );
2010-11-09 10:15:35 -05:00
error = true ; continue ;
}
2010-11-19 14:04:21 +01:00
if ( updateQueue [ qp ] != item2 )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
handler -> 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 ());
2010-11-09 10:15:35 -05:00
error = true ; continue ;
}
}
2010-11-19 14:04:21 +01:00
else if ( item2 -> GetState () != ITEM_UNCHANGED )
{
handler -> 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 ());
error = true ; continue ;
}
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 )
{
Item * item = updateQueue [ i ];
if ( ! item ) continue ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( item -> GetOwnerGUID () != player -> GetGUID ())
{
handler -> 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 ());
error = true ; continue ;
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( item -> GetQueuePos () != i )
{
handler -> PSendSysMessage ( "queue(" SIZEFMTD "): for the an item (guid %d), the queuepos doesn't match it's position in the queue!" , i , item -> GetGUIDLow ());
error = true ; continue ;
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( item -> GetState () == ITEM_REMOVED ) continue ;
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 )
{
handler -> 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 ());
error = true ; continue ;
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( test != item )
{
handler -> 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 ());
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 ;
}
static bool HandleDebugBattlegroundCommand ( ChatHandler * /*handler*/ , const char * /*args*/ )
{
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
2010-11-19 14:04:21 +01:00
static bool HandleDebugArenaCommand ( ChatHandler * /*handler*/ , const char * /*args*/ )
{
2010-12-22 21:25:23 +01:00
sBattlegroundMgr -> ToggleArenaTesting ();
2010-11-19 14:04:21 +01:00
return true ;
}
static bool HandleDebugThreatListCommand ( ChatHandler * handler , const char * /*args*/ )
{
Creature * target = handler -> getSelectedCreature ();
if ( ! target || target -> isTotem () || target -> isPet ())
return false ;
std :: list < HostileReference *>& tlist = target -> getThreatManager (). getThreatList ();
std :: list < HostileReference *>:: iterator itr ;
uint32 cnt = 0 ;
2011-04-29 20:47:02 +02:00
handler -> PSendSysMessage ( "Threat list of %s (guid %u)" , target -> GetName (), target -> GetGUIDLow ());
2010-11-19 14:04:21 +01:00
for ( itr = tlist . begin (); itr != tlist . 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 ;
++ cnt ;
2011-04-29 20:47:02 +02:00
handler -> PSendSysMessage ( " %u. %s (guid %u) - threat %f" , cnt , 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
2010-11-19 14:04:21 +01:00
static bool HandleDebugHostileRefListCommand ( ChatHandler * handler , const char * /*args*/ )
{
Unit * target = handler -> getSelectedUnit ();
if ( ! target )
target = handler -> GetSession () -> GetPlayer ();
HostileReference * ref = target -> getHostileRefManager (). getFirst ();
uint32 cnt = 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
{
++ cnt ;
2011-04-29 20:47:02 +02:00
handler -> PSendSysMessage ( " %u. %s (guid %u) - threat %f" , cnt , 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
2010-11-19 14:04:21 +01:00
static bool HandleDebugSetVehicleIdCommand ( ChatHandler * handler , const char * args )
{
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
2010-11-19 14:04:21 +01:00
static bool HandleDebugEnterVehicleCommand ( ChatHandler * handler , const char * args )
{
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
{
Creature * passenger = NULL ;
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
2010-11-19 14:04:21 +01:00
static bool HandleDebugSpawnVehicleCommand ( ChatHandler * handler , const char * args )
{
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-04-28 22:57:08 +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
2010-11-19 14:04:21 +01: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
2010-11-19 14:04:21 +01:00
Creature * v = new Creature ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01: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
2010-11-19 14:04:21 +01:00
map -> Add ( 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
2010-11-19 14:04:21 +01:00
static bool HandleDebugSendLargePacketCommand ( ChatHandler * handler , const char * /*args*/ )
{
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
2010-11-19 14:04:21 +01:00
static bool HandleDebugSendSetPhaseShiftCommand ( ChatHandler * handler , const char * args )
{
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
2010-11-19 14:04:21 +01:00
static bool HandleDebugGetItemValueCommand ( ChatHandler * handler , const char * args )
{
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
2010-11-19 14:04:21 +01: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
2010-11-19 14:04:21 +01:00
static bool HandleDebugSetItemValueCommand ( ChatHandler * handler , const char * args )
{
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
2010-11-19 14:04:21 +01: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
2010-11-19 14:04:21 +01:00
static bool HandleDebugItemExpireCommand ( ChatHandler * handler , const char * args )
{
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
2010-11-19 14:04:21 +01: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
static bool HandleDebugAnimCommand ( ChatHandler * handler , const char * args )
{
if ( !* args )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
uint32 anim_id = atoi (( char * ) args );
handler -> GetSession () -> GetPlayer () -> HandleEmoteCommand ( anim_id );
return true ;
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
static bool HandleDebugSetAuraStateCommand ( ChatHandler * handler , const char * args )
{
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-04-29 20:47:02 +02:00
unit -> ModifyAuraState ( AuraState ( i ), false );
2010-11-09 10:15:35 -05:00
return true ;
}
2011-04-29 20:47:02 +02:00
unit -> ModifyAuraState ( AuraState ( abs ( state )), state > 0 );
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
static bool HandleDebugSetValueCommand ( ChatHandler * handler , const char * args )
{
if ( !* args )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
char * px = strtok (( char * ) args , " " );
char * py = strtok ( NULL , " " );
char * pz = strtok ( NULL , " " );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( ! px || ! py )
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
2010-11-19 14:04:21 +01:00
uint32 Opcode = ( uint32 ) atoi ( px );
if ( Opcode >= target -> GetValuesCount ())
{
handler -> 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 );
target -> SetUInt32Value ( Opcode , iValue );
2011-04-29 20:47:02 +02:00
handler -> PSendSysMessage ( LANG_SET_UINT_FIELD , GUID_LOPART ( guid ), Opcode , iValue );
2010-11-19 14:04:21 +01:00
}
else
{
fValue = ( float ) atof ( py );
target -> SetFloatValue ( Opcode , fValue );
2011-04-29 20:47:02 +02:00
handler -> PSendSysMessage ( LANG_SET_FLOAT_FIELD , GUID_LOPART ( guid ), Opcode , fValue );
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
2010-11-19 14:04:21 +01:00
static bool HandleDebugGetValueCommand ( ChatHandler * handler , const char * args )
{
if ( !* args )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
char * px = strtok (( char * ) args , " " );
char * pz = strtok ( NULL , " " );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( ! px )
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 ();
uint32 Opcode = ( uint32 ) atoi ( px );
if ( Opcode >= target -> GetValuesCount ())
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
handler -> 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 );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( isint32 )
{
iValue = target -> GetUInt32Value ( Opcode );
handler -> PSendSysMessage ( LANG_GET_UINT_FIELD , GUID_LOPART ( guid ), Opcode , iValue );
}
else
{
fValue = target -> GetFloatValue ( Opcode );
handler -> PSendSysMessage ( LANG_GET_FLOAT_FIELD , GUID_LOPART ( guid ), Opcode , fValue );
}
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
static bool HandleDebugMod32ValueCommand ( ChatHandler * handler , const char * args )
{
if ( !* args )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
char * px = strtok (( char * ) args , " " );
char * py = strtok ( NULL , " " );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( ! px || ! py )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
uint32 Opcode = ( uint32 ) atoi ( px );
int Value = atoi ( py );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( Opcode >= handler -> GetSession () -> GetPlayer () -> GetValuesCount ())
{
handler -> PSendSysMessage ( LANG_TOO_BIG_INDEX , Opcode , handler -> GetSession () -> GetPlayer () -> GetGUIDLow (), handler -> GetSession () -> GetPlayer () -> GetValuesCount ());
return false ;
2010-11-09 10:15:35 -05:00
}
2010-11-19 14:04:21 +01:00
int CurrentValue = ( int ) handler -> GetSession () -> GetPlayer () -> GetUInt32Value ( Opcode );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
CurrentValue += Value ;
handler -> GetSession () -> GetPlayer () -> SetUInt32Value ( Opcode , ( uint32 ) CurrentValue );
2010-11-09 10:15:35 -05:00
2011-04-29 20:47:02 +02: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
2010-11-19 14:04:21 +01:00
static bool HandleDebugUpdateCommand ( ChatHandler * handler , const char * args )
{
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
2010-11-19 14:04:21 +01:00
char * pUpdateIndex = strtok (( char * ) args , " " );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
Unit * chr = handler -> getSelectedUnit ();
if ( chr == NULL )
{
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 ( ! pUpdateIndex )
{
2010-11-09 10:15:35 -05:00
return true ;
}
2010-11-19 14:04:21 +01:00
updateIndex = atoi ( pUpdateIndex );
//check updateIndex
if ( chr -> GetTypeId () == TYPEID_PLAYER )
2010-11-09 10:15:35 -05:00
{
2010-11-19 14:04:21 +01:00
if ( updateIndex >= PLAYER_END ) return true ;
}
else
{
if ( updateIndex >= UNIT_END ) return true ;
}
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
char * pvalue = strtok ( NULL , " " );
if ( ! pvalue )
{
value = chr -> GetUInt32Value ( updateIndex );
2010-11-09 10:15:35 -05:00
2011-04-29 20:47:02 +02:00
handler -> PSendSysMessage ( LANG_UPDATE , chr -> GetGUIDLow (), updateIndex , value );
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
value = atoi ( pvalue );
2010-11-09 10:15:35 -05:00
2011-04-29 20:47:02 +02:00
handler -> PSendSysMessage ( LANG_UPDATE_CHANGE , chr -> GetGUIDLow (), updateIndex , value );
2010-11-09 10:15:35 -05:00
2011-04-29 20:47:02 +02:00
chr -> SetUInt32Value ( updateIndex , value );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
return true ;
}
static bool HandleDebugSet32BitCommand ( ChatHandler * handler , const char * args )
{
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
}
2010-11-19 14:04:21 +01:00
char * px = strtok (( char * ) args , " " );
char * py = strtok ( NULL , " " );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
if ( ! px || ! py )
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
uint32 Opcode = ( uint32 ) atoi ( px );
uint32 Value = ( uint32 ) atoi ( py );
if ( Value > 32 ) //uint32 = 32 bits
return false ;
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
uint32 iValue = Value ? 1 << ( Value - 1 ) : 0 ;
target -> SetUInt32Value ( Opcode , iValue );
2010-11-09 10:15:35 -05:00
2010-11-19 14:04:21 +01:00
handler -> PSendSysMessage ( LANG_SET_32BIT_FIELD , Opcode , iValue );
return true ;
}
2010-11-09 10:15:35 -05:00
};
void AddSC_debug_commandscript ()
{
new debug_commandscript ();
}