2 * Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "Database/DatabaseEnv.h"
21 #include "WorldPacket.h"
28 #include "GossipDef.h"
30 #include "BattleGroundMgr.h"
32 #include "ObjectMgr.h"
33 #include "ObjectDefines.h"
36 bool ChatHandler::HandleDebugSendSpellFailCommand(const char* args
)
41 char* px
= strtok((char*)args
, " ");
45 uint8 failnum
= (uint8
)atoi(px
);
46 if (failnum
==0 && *px
!='0')
49 char* p1
= strtok(NULL
, " ");
50 uint8 failarg1
= p1
? (uint8
)atoi(p1
) : 0;
52 char* p2
= strtok(NULL
, " ");
53 uint8 failarg2
= p2
? (uint8
)atoi(p2
) : 0;
55 WorldPacket
data(SMSG_CAST_FAILED
, 5);
58 data
<< uint8(failnum
);
60 data
<< uint32(failarg1
);
62 data
<< uint32(failarg2
);
64 m_session
->SendPacket(&data
);
69 bool ChatHandler::HandleDebugSendPoiCommand(const char* args
)
74 Player
*pPlayer
= m_session
->GetPlayer();
75 Unit
* target
= getSelectedUnit();
78 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
82 char* icon_text
= strtok((char*)args
, " ");
83 char* flags_text
= strtok(NULL
, " ");
84 if (!icon_text
|| !flags_text
)
87 uint32 icon
= atol(icon_text
);
88 uint32 flags
= atol(flags_text
);
90 sLog
.outDetail("Command : POI, NPC = %u, icon = %u flags = %u", target
->GetGUIDLow(), icon
,flags
);
91 pPlayer
->PlayerTalkClass
->SendPointOfInterest(target
->GetPositionX(), target
->GetPositionY(), Poi_Icon(icon
), flags
, 30, "Test POI");
95 bool ChatHandler::HandleDebugSendEquipErrorCommand(const char* args
)
100 uint8 msg
= atoi(args
);
101 m_session
->GetPlayer()->SendEquipError(msg
, 0, 0);
105 bool ChatHandler::HandleDebugSendSellErrorCommand(const char* args
)
110 uint8 msg
= atoi(args
);
111 m_session
->GetPlayer()->SendSellError(msg
, 0, 0, 0);
115 bool ChatHandler::HandleDebugSendBuyErrorCommand(const char* args
)
120 uint8 msg
= atoi(args
);
121 m_session
->GetPlayer()->SendBuyError(msg
, 0, 0, 0);
125 bool ChatHandler::HandleDebugSendOpcodeCommand(const char* /*args*/)
127 Unit
*unit
= getSelectedUnit();
128 if (!unit
|| (unit
->GetTypeId() != TYPEID_PLAYER
))
129 unit
= m_session
->GetPlayer();
131 std::ifstream
ifs("opcode.txt");
138 WorldPacket
data(opcode
, 0);
154 else if(type
== "uint16")
160 else if(type
== "uint32")
166 else if(type
== "uint64")
172 else if(type
== "float")
178 else if(type
== "string")
184 else if(type
== "pguid")
186 data
.append(unit
->GetPackGUID());
190 sLog
.outDebug("Sending opcode: unknown type '%s'", type
.c_str());
195 sLog
.outDebug("Sending opcode %u", data
.GetOpcode());
197 ((Player
*)unit
)->GetSession()->SendPacket(&data
);
198 PSendSysMessage(LANG_COMMAND_OPCODESENT
, data
.GetOpcode(), unit
->GetName());
202 bool ChatHandler::HandleDebugUpdateWorldStateCommand(const char* args
)
204 char* w
= strtok((char*)args
, " ");
205 char* s
= strtok(NULL
, " ");
210 uint32 world
= (uint32
)atoi(w
);
211 uint32 state
= (uint32
)atoi(s
);
212 m_session
->GetPlayer()->SendUpdateWorldState(world
, state
);
216 bool ChatHandler::HandleDebugPlayCinematicCommand(const char* args
)
218 // USAGE: .debug play cinematic #cinematicid
219 // #cinematicid - ID decimal number from CinemaicSequences.dbc (1st column)
222 SendSysMessage(LANG_BAD_VALUE
);
223 SetSentErrorMessage(true);
227 uint32 dwId
= atoi((char*)args
);
229 if (!sCinematicSequencesStore
.LookupEntry(dwId
))
231 PSendSysMessage(LANG_CINEMATIC_NOT_EXIST
, dwId
);
232 SetSentErrorMessage(true);
236 m_session
->GetPlayer()->SendCinematicStart(dwId
);
240 bool ChatHandler::HandleDebugPlayMovieCommand(const char* args
)
242 // USAGE: .debug play movie #movieid
243 // #movieid - ID decimal number from Movie.dbc (1st column)
246 SendSysMessage(LANG_BAD_VALUE
);
247 SetSentErrorMessage(true);
251 uint32 dwId
= atoi((char*)args
);
253 if (!sMovieStore
.LookupEntry(dwId
))
255 PSendSysMessage(LANG_MOVIE_NOT_EXIST
, dwId
);
256 SetSentErrorMessage(true);
260 m_session
->GetPlayer()->SendMovieStart(dwId
);
265 bool ChatHandler::HandleDebugPlaySoundCommand(const char* args
)
267 // USAGE: .debug playsound #soundid
268 // #soundid - ID decimal number from SoundEntries.dbc (1st column)
271 SendSysMessage(LANG_BAD_VALUE
);
272 SetSentErrorMessage(true);
276 uint32 dwSoundId
= atoi((char*)args
);
278 if (!sSoundEntriesStore
.LookupEntry(dwSoundId
))
280 PSendSysMessage(LANG_SOUND_NOT_EXIST
, dwSoundId
);
281 SetSentErrorMessage(true);
285 Unit
* unit
= getSelectedUnit();
288 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
289 SetSentErrorMessage(true);
293 if (m_session
->GetPlayer()->GetSelection())
294 unit
->PlayDistanceSound(dwSoundId
,m_session
->GetPlayer());
296 unit
->PlayDirectSound(dwSoundId
,m_session
->GetPlayer());
298 PSendSysMessage(LANG_YOU_HEAR_SOUND
, dwSoundId
);
302 //Send notification in channel
303 bool ChatHandler::HandleDebugSendChannelNotifyCommand(const char* args
)
308 const char *name
= "test";
309 uint8 code
= atoi(args
);
311 WorldPacket
data(SMSG_CHANNEL_NOTIFY
, (1+10));
312 data
<< code
; // notify type
313 data
<< name
; // channel name
316 m_session
->SendPacket(&data
);
320 //Send notification in chat
321 bool ChatHandler::HandleDebugSendChatMsgCommand(const char* args
)
326 const char *msg
= "testtest";
327 uint8 type
= atoi(args
);
329 ChatHandler::FillMessageData(&data
, m_session
, type
, 0, "chan", m_session
->GetPlayer()->GetGUID(), msg
, m_session
->GetPlayer());
330 m_session
->SendPacket(&data
);
334 bool ChatHandler::HandleDebugSendQuestPartyMsgCommand(const char* args
)
336 uint32 msg
= atol((char*)args
);
337 m_session
->GetPlayer()->SendPushToPartyResponse(m_session
->GetPlayer(), msg
);
341 bool ChatHandler::HandleDebugGetLootRecipientCommand(const char* /*args*/)
343 Creature
* target
= getSelectedCreature();
347 PSendSysMessage("loot recipient: %s", target
->hasLootRecipient()?(target
->GetLootRecipient()?target
->GetLootRecipient()->GetName():"offline"):"no loot recipient");
351 bool ChatHandler::HandleDebugSendQuestInvalidMsgCommand(const char* args
)
353 uint32 msg
= atol((char*)args
);
354 m_session
->GetPlayer()->SendCanTakeQuestResponse(msg
);
358 bool ChatHandler::HandleDebugGetItemStateCommand(const char* args
)
363 std::string state_str
= args
;
365 ItemUpdateState state
= ITEM_UNCHANGED
;
366 bool list_queue
= false, check_all
= false;
367 if (state_str
== "unchanged") state
= ITEM_UNCHANGED
;
368 else if (state_str
== "changed") state
= ITEM_CHANGED
;
369 else if (state_str
== "new") state
= ITEM_NEW
;
370 else if (state_str
== "removed") state
= ITEM_REMOVED
;
371 else if (state_str
== "queue") list_queue
= true;
372 else if (state_str
== "check_all") check_all
= true;
375 Player
* player
= getSelectedPlayer();
376 if (!player
) player
= m_session
->GetPlayer();
378 if (!list_queue
&& !check_all
)
380 state_str
= "The player has the following " + state_str
+ " items: ";
381 SendSysMessage(state_str
.c_str());
382 for (uint8 i
= PLAYER_SLOT_START
; i
< PLAYER_SLOT_END
; ++i
)
384 if(i
>= BUYBACK_SLOT_START
&& i
< BUYBACK_SLOT_END
)
387 Item
*item
= player
->GetItemByPos(INVENTORY_SLOT_BAG_0
, i
);
391 if (item
->GetState() == state
)
392 PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item
->GetSlot(), item
->GetGUIDLow(), GUID_LOPART(item
->GetOwnerGUID()));
396 Bag
*bag
= (Bag
*)item
;
397 for (uint8 j
= 0; j
< bag
->GetBagSize(); ++j
)
399 Item
* item2
= bag
->GetItemByPos(j
);
400 if (item2
&& item2
->GetState() == state
)
401 PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item2
->GetSlot(), item2
->GetGUIDLow(), GUID_LOPART(item2
->GetOwnerGUID()));
409 std::vector
<Item
*> &updateQueue
= player
->GetItemUpdateQueue();
410 for(size_t i
= 0; i
< updateQueue
.size(); ++i
)
412 Item
*item
= updateQueue
[i
];
415 Bag
*container
= item
->GetContainer();
416 uint8 bag_slot
= container
? container
->GetSlot() : uint8(INVENTORY_SLOT_BAG_0
);
419 switch(item
->GetState())
421 case ITEM_UNCHANGED
: st
= "unchanged"; break;
422 case ITEM_CHANGED
: st
= "changed"; break;
423 case ITEM_NEW
: st
= "new"; break;
424 case ITEM_REMOVED
: st
= "removed"; break;
427 PSendSysMessage("bag: %d slot: %d guid: %d - state: %s", bag_slot
, item
->GetSlot(), item
->GetGUIDLow(), st
.c_str());
429 if (updateQueue
.empty())
430 PSendSysMessage("updatequeue empty");
436 std::vector
<Item
*> &updateQueue
= player
->GetItemUpdateQueue();
437 for (uint8 i
= PLAYER_SLOT_START
; i
< PLAYER_SLOT_END
; ++i
)
439 if(i
>= BUYBACK_SLOT_START
&& i
< BUYBACK_SLOT_END
)
442 Item
*item
= player
->GetItemByPos(INVENTORY_SLOT_BAG_0
, i
);
445 if (item
->GetSlot() != i
)
447 PSendSysMessage("item at slot %d, guid %d has an incorrect slot value: %d", i
, item
->GetGUIDLow(), item
->GetSlot());
448 error
= true; continue;
451 if (item
->GetOwnerGUID() != player
->GetGUID())
453 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());
454 error
= true; continue;
457 if (Bag
*container
= item
->GetContainer())
459 PSendSysMessage("item at slot: %d guid: %d has a container (slot: %d, guid: %d) but shouldnt!", item
->GetSlot(), item
->GetGUIDLow(), container
->GetSlot(), container
->GetGUIDLow());
460 error
= true; continue;
463 if (item
->IsInUpdateQueue())
465 uint16 qp
= item
->GetQueuePos();
466 if (qp
> updateQueue
.size())
468 PSendSysMessage("item at slot: %d guid: %d has a queuepos (%d) larger than the update queue size! ", item
->GetSlot(), item
->GetGUIDLow(), qp
);
469 error
= true; continue;
472 if (updateQueue
[qp
] == NULL
)
474 PSendSysMessage("item at slot: %d guid: %d has a queuepos (%d) that points to NULL in the queue!", item
->GetSlot(), item
->GetGUIDLow(), qp
);
475 error
= true; continue;
478 if (updateQueue
[qp
] != item
)
480 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());
481 error
= true; continue;
484 else if (item
->GetState() != ITEM_UNCHANGED
)
486 PSendSysMessage("item at slot: %d guid: %d is not in queue but should be (state: %d)!", item
->GetSlot(), item
->GetGUIDLow(), item
->GetState());
487 error
= true; continue;
492 Bag
*bag
= (Bag
*)item
;
493 for (uint8 j
= 0; j
< bag
->GetBagSize(); ++j
)
495 Item
* item2
= bag
->GetItemByPos(j
);
496 if (!item2
) continue;
498 if (item2
->GetSlot() != j
)
500 PSendSysMessage("the item in bag %d slot %d, guid %d has an incorrect slot value: %d", bag
->GetSlot(), j
, item2
->GetGUIDLow(), item2
->GetSlot());
501 error
= true; continue;
504 if (item2
->GetOwnerGUID() != player
->GetGUID())
506 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());
507 error
= true; continue;
510 Bag
*container
= item2
->GetContainer();
513 PSendSysMessage("the item in bag %d at slot %d with guid %d has no container!", bag
->GetSlot(), item2
->GetSlot(), item2
->GetGUIDLow());
514 error
= true; continue;
517 if (container
!= bag
)
519 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());
520 error
= true; continue;
523 if (item2
->IsInUpdateQueue())
525 uint16 qp
= item2
->GetQueuePos();
526 if (qp
> updateQueue
.size())
528 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
);
529 error
= true; continue;
532 if (updateQueue
[qp
] == NULL
)
534 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
);
535 error
= true; continue;
538 if (updateQueue
[qp
] != item2
)
540 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());
541 error
= true; continue;
544 else if (item2
->GetState() != ITEM_UNCHANGED
)
546 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());
547 error
= true; continue;
553 for(size_t i
= 0; i
< updateQueue
.size(); ++i
)
555 Item
*item
= updateQueue
[i
];
558 if (item
->GetOwnerGUID() != player
->GetGUID())
560 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());
561 error
= true; continue;
564 if (item
->GetQueuePos() != i
)
566 PSendSysMessage("queue(" SIZEFMTD
"): for the an item (guid %d), the queuepos doesn't match it's position in the queue!", i
, item
->GetGUIDLow());
567 error
= true; continue;
570 if (item
->GetState() == ITEM_REMOVED
) continue;
571 Item
*test
= player
->GetItemByPos( item
->GetBagSlot(), item
->GetSlot());
575 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());
576 error
= true; continue;
581 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());
582 error
= true; continue;
586 SendSysMessage("All OK!");
592 bool ChatHandler::HandleDebugBattlegroundCommand(const char * /*args*/)
594 sBattleGroundMgr
.ToggleTesting();
598 bool ChatHandler::HandleDebugArenaCommand(const char * /*args*/)
600 sBattleGroundMgr
.ToggleArenaTesting();
604 bool ChatHandler::HandleDebugSpawnVehicle(const char* args
)
609 char* e
= strtok((char*)args
, " ");
610 char* i
= strtok(NULL
, " ");
615 uint32 entry
= (uint32
)atoi(e
);
616 uint32 id
= (uint32
)atoi(i
);
618 CreatureInfo
const *ci
= ObjectMgr::GetCreatureTemplate(entry
);
623 VehicleEntry
const *ve
= sVehicleStore
.LookupEntry(id
);
628 Vehicle
*v
= new Vehicle
;
629 Map
*map
= m_session
->GetPlayer()->GetMap();
630 if (!v
->Create(map
->GenerateLocalLowGuid(HIGHGUID_VEHICLE
), map
, entry
, id
, m_session
->GetPlayer()->GetTeam()))
637 m_session
->GetPlayer()->GetClosePoint(px
, py
, pz
, m_session
->GetPlayer()->GetObjectSize());
639 v
->Relocate(px
, py
, pz
, m_session
->GetPlayer()->GetOrientation());
641 if (!v
->IsPositionValid())
643 sLog
.outError("Vehicle (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",
644 v
->GetGUIDLow(), v
->GetEntry(), v
->GetPositionX(), v
->GetPositionY());
649 map
->Add((Creature
*)v
);
654 bool ChatHandler::HandleDebugSpellCheckCommand(const char* /*args*/)
656 sLog
.outString( "Check expected in code spell properties base at table 'spell_check' content...");
657 sSpellMgr
.CheckUsedSpells("spell_check");
661 bool ChatHandler::HandleDebugSendLargePacketCommand(const char* /*args*/)
663 const char* stuffingString
= "This is a dummy string to push the packet's size beyond 128000 bytes. ";
664 std::ostringstream ss
;
665 while(ss
.str().size() < 128000)
666 ss
<< stuffingString
;
667 SendSysMessage(ss
.str().c_str());
671 bool ChatHandler::HandleDebugSendSetPhaseShiftCommand(const char* args
)
676 uint32 PhaseShift
= atoi(args
);
677 m_session
->SendSetPhaseShift(PhaseShift
);
681 bool ChatHandler::HandleDebugGetItemValueCommand(const char* args
)
686 char* e
= strtok((char*)args
, " ");
687 char* f
= strtok(NULL
, " ");
692 uint32 guid
= (uint32
)atoi(e
);
693 uint32 index
= (uint32
)atoi(f
);
695 Item
*i
= m_session
->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid
, 0, HIGHGUID_ITEM
));
700 if (index
>= i
->GetValuesCount())
703 uint32 value
= i
->GetUInt32Value(index
);
705 PSendSysMessage("Item %u: value at %u is %u", guid
, index
, value
);
710 bool ChatHandler::HandleDebugSetItemValueCommand(const char* args
)
715 char* e
= strtok((char*)args
, " ");
716 char* f
= strtok(NULL
, " ");
717 char* g
= strtok(NULL
, " ");
722 uint32 guid
= (uint32
)atoi(e
);
723 uint32 index
= (uint32
)atoi(f
);
724 uint32 value
= (uint32
)atoi(g
);
726 Item
*i
= m_session
->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid
, 0, HIGHGUID_ITEM
));
731 if (index
>= i
->GetValuesCount())
734 i
->SetUInt32Value(index
, value
);
740 bool ChatHandler::HandleDebugAnimCommand(const char* args
)
745 uint32 anim_id
= atoi((char*)args
);
746 m_session
->GetPlayer()->HandleEmoteCommand(anim_id
);
750 bool ChatHandler::HandleDebugSetAuraStateCommand(const char* args
)
754 SendSysMessage(LANG_BAD_VALUE
);
755 SetSentErrorMessage(true);
759 Unit
* unit
= getSelectedUnit();
762 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
763 SetSentErrorMessage(true);
767 int32 state
= atoi((char*)args
);
771 for(int i
= 1; i
<= 32; ++i
)
772 unit
->ModifyAuraState(AuraState(i
),false);
776 unit
->ModifyAuraState(AuraState(abs(state
)),state
> 0);
780 bool ChatHandler::HandleDebugSetValueCommand(const char* args
)
785 char* px
= strtok((char*)args
, " ");
786 char* py
= strtok(NULL
, " ");
787 char* pz
= strtok(NULL
, " ");
792 Unit
* target
= getSelectedUnit();
795 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
796 SetSentErrorMessage(true);
800 uint64 guid
= target
->GetGUID();
802 uint32 Opcode
= (uint32
)atoi(px
);
803 if(Opcode
>= target
->GetValuesCount())
805 PSendSysMessage(LANG_TOO_BIG_INDEX
, Opcode
, GUID_LOPART(guid
), target
->GetValuesCount());
812 isint32
= (bool)atoi(pz
);
815 iValue
= (uint32
)atoi(py
);
816 sLog
.outDebug(GetMangosString(LANG_SET_UINT
), GUID_LOPART(guid
), Opcode
, iValue
);
817 target
->SetUInt32Value( Opcode
, iValue
);
818 PSendSysMessage(LANG_SET_UINT_FIELD
, GUID_LOPART(guid
), Opcode
,iValue
);
822 fValue
= (float)atof(py
);
823 sLog
.outDebug(GetMangosString(LANG_SET_FLOAT
), GUID_LOPART(guid
), Opcode
, fValue
);
824 target
->SetFloatValue( Opcode
, fValue
);
825 PSendSysMessage(LANG_SET_FLOAT_FIELD
, GUID_LOPART(guid
), Opcode
,fValue
);
831 bool ChatHandler::HandleDebugGetValueCommand(const char* args
)
836 char* px
= strtok((char*)args
, " ");
837 char* pz
= strtok(NULL
, " ");
842 Unit
* target
= getSelectedUnit();
845 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
846 SetSentErrorMessage(true);
850 uint64 guid
= target
->GetGUID();
852 uint32 Opcode
= (uint32
)atoi(px
);
853 if(Opcode
>= target
->GetValuesCount())
855 PSendSysMessage(LANG_TOO_BIG_INDEX
, Opcode
, GUID_LOPART(guid
), target
->GetValuesCount());
862 isint32
= (bool)atoi(pz
);
866 iValue
= target
->GetUInt32Value( Opcode
);
867 sLog
.outDebug(GetMangosString(LANG_GET_UINT
), GUID_LOPART(guid
), Opcode
, iValue
);
868 PSendSysMessage(LANG_GET_UINT_FIELD
, GUID_LOPART(guid
), Opcode
, iValue
);
872 fValue
= target
->GetFloatValue( Opcode
);
873 sLog
.outDebug(GetMangosString(LANG_GET_FLOAT
), GUID_LOPART(guid
), Opcode
, fValue
);
874 PSendSysMessage(LANG_GET_FLOAT_FIELD
, GUID_LOPART(guid
), Opcode
, fValue
);
880 bool ChatHandler::HandleDebugMod32ValueCommand(const char* args
)
885 char* px
= strtok((char*)args
, " ");
886 char* py
= strtok(NULL
, " ");
891 uint32 Opcode
= (uint32
)atoi(px
);
892 int Value
= atoi(py
);
894 if(Opcode
>= m_session
->GetPlayer()->GetValuesCount())
896 PSendSysMessage(LANG_TOO_BIG_INDEX
, Opcode
, m_session
->GetPlayer()->GetGUIDLow(), m_session
->GetPlayer( )->GetValuesCount());
900 sLog
.outDebug(GetMangosString(LANG_CHANGE_32BIT
), Opcode
, Value
);
902 int CurrentValue
= (int)m_session
->GetPlayer( )->GetUInt32Value( Opcode
);
904 CurrentValue
+= Value
;
905 m_session
->GetPlayer( )->SetUInt32Value( Opcode
, (uint32
)CurrentValue
);
907 PSendSysMessage(LANG_CHANGE_32BIT_FIELD
, Opcode
,CurrentValue
);
912 bool ChatHandler::HandleDebugUpdateCommand(const char* args
)
920 char* pUpdateIndex
= strtok((char*)args
, " ");
922 Unit
* chr
= getSelectedUnit();
925 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
926 SetSentErrorMessage(true);
934 updateIndex
= atoi(pUpdateIndex
);
936 if(chr
->GetTypeId() == TYPEID_PLAYER
)
938 if (updateIndex
>=PLAYER_END
) return true;
942 if (updateIndex
>=UNIT_END
) return true;
945 char* pvalue
= strtok(NULL
, " ");
948 value
=chr
->GetUInt32Value(updateIndex
);
950 PSendSysMessage(LANG_UPDATE
, chr
->GetGUIDLow(),updateIndex
,value
);
956 PSendSysMessage(LANG_UPDATE_CHANGE
, chr
->GetGUIDLow(),updateIndex
,value
);
958 chr
->SetUInt32Value(updateIndex
,value
);