diff options
Diffstat (limited to 'src/game/Debugcmds.cpp')
-rw-r--r-- | src/game/Debugcmds.cpp | 307 |
1 files changed, 272 insertions, 35 deletions
diff --git a/src/game/Debugcmds.cpp b/src/game/Debugcmds.cpp index d8b94df4e10..69b3bcb1284 100644 --- a/src/game/Debugcmds.cpp +++ b/src/game/Debugcmds.cpp @@ -36,10 +36,12 @@ #include "CellImpl.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" +#include "SpellMgr.h" +#include "ScriptCalls.h" bool ChatHandler::HandleDebugSendSpellFailCommand(const char* args) { - if(!args) + if (!*args) return false; char* px = strtok((char*)args, " "); @@ -47,7 +49,7 @@ bool ChatHandler::HandleDebugSendSpellFailCommand(const char* args) return false; uint8 failnum = (uint8)atoi(px); - if(failnum==0 && *px!='0') + if (failnum==0 && *px!='0') return false; char* p1 = strtok(NULL, " "); @@ -72,20 +74,20 @@ bool ChatHandler::HandleDebugSendSpellFailCommand(const char* args) bool ChatHandler::HandleDebugSendPoiCommand(const char* args) { + if (!*args) + return false; + Player *pPlayer = m_session->GetPlayer(); Unit* target = getSelectedUnit(); - if(!target) + if (!target) { SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); return true; } - if(!args) - return false; - char* icon_text = strtok((char*)args, " "); char* flags_text = strtok(NULL, " "); - if(!icon_text || !flags_text) + if (!icon_text || !flags_text) return false; uint32 icon = atol(icon_text); @@ -98,7 +100,7 @@ bool ChatHandler::HandleDebugSendPoiCommand(const char* args) bool ChatHandler::HandleDebugSendEquipErrorCommand(const char* args) { - if(!args) + if (!*args) return false; uint8 msg = atoi(args); @@ -108,7 +110,7 @@ bool ChatHandler::HandleDebugSendEquipErrorCommand(const char* args) bool ChatHandler::HandleDebugSendSellErrorCommand(const char* args) { - if(!args) + if (!*args) return false; uint8 msg = atoi(args); @@ -118,7 +120,7 @@ bool ChatHandler::HandleDebugSendSellErrorCommand(const char* args) bool ChatHandler::HandleDebugSendBuyErrorCommand(const char* args) { - if(!args) + if (!*args) return false; uint8 msg = atoi(args); @@ -137,7 +139,7 @@ bool ChatHandler::HandleDebugSendOpcodeCommand(const char* /*args*/) if(!unit) unit = player; std::ifstream ifs("opcode.txt"); - if(ifs.bad()) + if (ifs.bad()) return false; uint32 opcode; @@ -273,7 +275,7 @@ bool ChatHandler::HandleDebugPlayCinematicCommand(const char* args) { // USAGE: .debug play cinematic #cinematicid // #cinematicid - ID decimal number from CinemaicSequences.dbc (1st column) - if( !*args ) + if (!*args) { SendSysMessage(LANG_BAD_VALUE); SetSentErrorMessage(true); @@ -282,7 +284,7 @@ bool ChatHandler::HandleDebugPlayCinematicCommand(const char* args) uint32 dwId = atoi((char*)args); - if(!sCinematicSequencesStore.LookupEntry(dwId)) + if (!sCinematicSequencesStore.LookupEntry(dwId)) { PSendSysMessage(LANG_CINEMATIC_NOT_EXIST, dwId); SetSentErrorMessage(true); @@ -297,7 +299,7 @@ bool ChatHandler::HandleDebugPlayMovieCommand(const char* args) { // USAGE: .debug play movie #movieid // #movieid - ID decimal number from Movie.dbc (1st column) - if( !*args ) + if (!*args) { SendSysMessage(LANG_BAD_VALUE); SetSentErrorMessage(true); @@ -306,7 +308,7 @@ bool ChatHandler::HandleDebugPlayMovieCommand(const char* args) uint32 dwId = atoi((char*)args); - if(!sMovieStore.LookupEntry(dwId)) + if (!sMovieStore.LookupEntry(dwId)) { PSendSysMessage(LANG_MOVIE_NOT_EXIST, dwId); SetSentErrorMessage(true); @@ -322,7 +324,7 @@ bool ChatHandler::HandleDebugPlaySoundCommand(const char* args) { // USAGE: .debug playsound #soundid // #soundid - ID decimal number from SoundEntries.dbc (1st column) - if( !*args ) + if (!*args) { SendSysMessage(LANG_BAD_VALUE); SetSentErrorMessage(true); @@ -331,7 +333,7 @@ bool ChatHandler::HandleDebugPlaySoundCommand(const char* args) uint32 dwSoundId = atoi((char*)args); - if(!sSoundEntriesStore.LookupEntry(dwSoundId)) + if (!sSoundEntriesStore.LookupEntry(dwSoundId)) { PSendSysMessage(LANG_SOUND_NOT_EXIST, dwSoundId); SetSentErrorMessage(true); @@ -339,14 +341,14 @@ bool ChatHandler::HandleDebugPlaySoundCommand(const char* args) } Unit* unit = getSelectedUnit(); - if(!unit) + if (!unit) { SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); SetSentErrorMessage(true); return false; } - if(m_session->GetPlayer()->GetSelection()) + if (m_session->GetPlayer()->GetSelection()) unit->PlayDistanceSound(dwSoundId,m_session->GetPlayer()); else unit->PlayDirectSound(dwSoundId,m_session->GetPlayer()); @@ -358,7 +360,7 @@ bool ChatHandler::HandleDebugPlaySoundCommand(const char* args) //Send notification in channel bool ChatHandler::HandleDebugSendChannelNotifyCommand(const char* args) { - if(!args) + if (!*args) return false; const char *name = "test"; @@ -376,7 +378,7 @@ bool ChatHandler::HandleDebugSendChannelNotifyCommand(const char* args) //Send notification in chat bool ChatHandler::HandleDebugSendChatMsgCommand(const char* args) { - if(!args) + if (!*args) return false; const char *msg = "testtest"; @@ -394,10 +396,10 @@ bool ChatHandler::HandleDebugSendQuestPartyMsgCommand(const char* args) return true; } -bool ChatHandler::HandleDebugGetLootRecipient(const char* /*args*/) +bool ChatHandler::HandleDebugGetLootRecipientCommand(const char* /*args*/) { Creature* target = getSelectedCreature(); - if(!target) + if (!target) return false; PSendSysMessage("loot recipient: %s", target->hasLootRecipient()?(target->GetLootRecipient()?target->GetLootRecipient()->GetName():"offline"):"no loot recipient"); @@ -411,9 +413,9 @@ bool ChatHandler::HandleDebugSendQuestInvalidMsgCommand(const char* args) return true; } -bool ChatHandler::HandleDebugGetItemState(const char* args) +bool ChatHandler::HandleDebugGetItemStateCommand(const char* args) { - if (!args) + if (!*args) return false; std::string state_str = args; @@ -613,13 +615,13 @@ bool ChatHandler::HandleDebugGetItemState(const char* args) if (item->GetOwnerGUID() != player->GetGUID()) { - PSendSysMessage("queue(%d): 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()); + 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; } if (item->GetQueuePos() != i) { - PSendSysMessage("queue(%d): for the an item (guid %d), the queuepos doesn't match it's position in the queue!", i, item->GetGUIDLow()); + 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; } @@ -628,13 +630,13 @@ bool ChatHandler::HandleDebugGetItemState(const char* args) if (test == NULL) { - PSendSysMessage("queue(%d): 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()); + 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; } if (test != item) { - PSendSysMessage("queue(%d): 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()); + 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; } } @@ -757,7 +759,7 @@ bool ChatHandler::HandleDebugEnterVehicle(const char * args) bool ChatHandler::HandleDebugSpawnVehicle(const char* args) { - if(!args) + if (!*args) return false; char* e = strtok((char*)args, " "); @@ -778,12 +780,12 @@ bool ChatHandler::HandleDebugSpawnVehicle(const char* args) CreatureInfo const *ci = objmgr.GetCreatureTemplate(entry); - if(!ci) + if (!ci) return false; VehicleEntry const *ve = sVehicleStore.LookupEntry(id); - if(!ve) + if (!ve) return false; Vehicle *v = new Vehicle; @@ -812,7 +814,7 @@ bool ChatHandler::HandleDebugSendLargePacketCommand(const char* /*args*/) bool ChatHandler::HandleDebugSendSetPhaseShiftCommand(const char* args) { - if(!args) + if (!*args) return false; uint32 PhaseShift = atoi(args); @@ -822,7 +824,7 @@ bool ChatHandler::HandleDebugSendSetPhaseShiftCommand(const char* args) bool ChatHandler::HandleDebugSetItemFlagCommand(const char* args) { - if(!args) + if (!*args) return false; char* e = strtok((char*)args, " "); @@ -836,7 +838,7 @@ bool ChatHandler::HandleDebugSetItemFlagCommand(const char* args) Item *i = m_session->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM)); - if(!i) + if (!i) return false; i->SetUInt32Value(ITEM_FIELD_FLAGS, flag); @@ -844,6 +846,28 @@ bool ChatHandler::HandleDebugSetItemFlagCommand(const char* args) return true; } +bool ChatHandler::HandleDebugItemExpireCommand(const char* args) +{ + if (!*args) + return false; + + char* e = strtok((char*)args, " "); + if (!e) + return false; + + uint32 guid = (uint32)atoi(e); + + Item *i = m_session->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM)); + + if (!i) + return false; + + m_session->GetPlayer()->DestroyItem( i->GetBagSlot(),i->GetSlot(), true); + Script->ItemExpire(m_session->GetPlayer(),i->GetProto()); + + return true; +} + //show animation bool ChatHandler::HandleDebugAnimCommand(const char* args) { @@ -854,3 +878,216 @@ bool ChatHandler::HandleDebugAnimCommand(const char* args) m_session->GetPlayer()->HandleEmoteCommand(anim_id); return true; } + +bool ChatHandler::HandleDebugSetAuraStateCommand(const char* args) +{ + if (!*args) + { + SendSysMessage(LANG_BAD_VALUE); + SetSentErrorMessage(true); + return false; + } + + Unit* unit = getSelectedUnit(); + if (!unit) + { + SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + SetSentErrorMessage(true); + return false; + } + + int32 state = atoi((char*)args); + if (!state) + { + // reset all states + for(int i = 1; i <= 32; ++i) + unit->ModifyAuraState(AuraState(i),false); + return true; + } + + unit->ModifyAuraState(AuraState(abs(state)),state > 0); + return true; +} + +bool ChatHandler::HandleDebugSetValueCommand(const char* args) +{ + if(!*args) + return false; + + char* px = strtok((char*)args, " "); + char* py = strtok(NULL, " "); + char* pz = strtok(NULL, " "); + + if (!px || !py) + return false; + + WorldObject* target = getSelectedObject(); + if(!target) + { + SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + SetSentErrorMessage(true); + return false; + } + + uint64 guid = target->GetGUID(); + + uint32 Opcode = (uint32)atoi(px); + if(Opcode >= target->GetValuesCount()) + { + PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount()); + return false; + } + uint32 iValue; + float fValue; + bool isint32 = true; + if(pz) + isint32 = (bool)atoi(pz); + if(isint32) + { + iValue = (uint32)atoi(py); + sLog.outDebug(GetTrinityString(LANG_SET_UINT), GUID_LOPART(guid), Opcode, iValue); + target->SetUInt32Value( Opcode , iValue ); + PSendSysMessage(LANG_SET_UINT_FIELD, GUID_LOPART(guid), Opcode,iValue); + } + else + { + fValue = (float)atof(py); + sLog.outDebug(GetTrinityString(LANG_SET_FLOAT), GUID_LOPART(guid), Opcode, fValue); + target->SetFloatValue( Opcode , fValue ); + PSendSysMessage(LANG_SET_FLOAT_FIELD, GUID_LOPART(guid), Opcode,fValue); + } + + return true; +} + +bool ChatHandler::HandleDebugGetValueCommand(const char* args) +{ + if(!*args) + return false; + + char* px = strtok((char*)args, " "); + char* pz = strtok(NULL, " "); + + if (!px) + return false; + + Unit* target = getSelectedUnit(); + if(!target) + { + SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + SetSentErrorMessage(true); + return false; + } + + uint64 guid = target->GetGUID(); + + uint32 Opcode = (uint32)atoi(px); + if(Opcode >= target->GetValuesCount()) + { + PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount()); + return false; + } + uint32 iValue; + float fValue; + bool isint32 = true; + if(pz) + isint32 = (bool)atoi(pz); + + if(isint32) + { + iValue = target->GetUInt32Value( Opcode ); + sLog.outDebug(GetTrinityString(LANG_GET_UINT), GUID_LOPART(guid), Opcode, iValue); + PSendSysMessage(LANG_GET_UINT_FIELD, GUID_LOPART(guid), Opcode, iValue); + } + else + { + fValue = target->GetFloatValue( Opcode ); + sLog.outDebug(GetTrinityString(LANG_GET_FLOAT), GUID_LOPART(guid), Opcode, fValue); + PSendSysMessage(LANG_GET_FLOAT_FIELD, GUID_LOPART(guid), Opcode, fValue); + } + + return true; +} + +bool ChatHandler::HandleDebugMod32ValueCommand(const char* args) +{ + if(!*args) + return false; + + char* px = strtok((char*)args, " "); + char* py = strtok(NULL, " "); + + if (!px || !py) + return false; + + uint32 Opcode = (uint32)atoi(px); + int Value = atoi(py); + + if(Opcode >= m_session->GetPlayer()->GetValuesCount()) + { + PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, m_session->GetPlayer()->GetGUIDLow(), m_session->GetPlayer( )->GetValuesCount()); + return false; + } + + sLog.outDebug(GetTrinityString(LANG_CHANGE_32BIT), Opcode, Value); + + int CurrentValue = (int)m_session->GetPlayer( )->GetUInt32Value( Opcode ); + + CurrentValue += Value; + m_session->GetPlayer( )->SetUInt32Value( Opcode , (uint32)CurrentValue ); + + PSendSysMessage(LANG_CHANGE_32BIT_FIELD, Opcode,CurrentValue); + + return true; +} + +bool ChatHandler::HandleDebugUpdateCommand(const char* args) +{ + if(!*args) + return false; + + uint32 updateIndex; + uint32 value; + + char* pUpdateIndex = strtok((char*)args, " "); + + Unit* chr = getSelectedUnit(); + if (chr == NULL) + { + SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + SetSentErrorMessage(true); + return false; + } + + if(!pUpdateIndex) + { + return true; + } + updateIndex = atoi(pUpdateIndex); + //check updateIndex + if(chr->GetTypeId() == TYPEID_PLAYER) + { + if (updateIndex>=PLAYER_END) return true; + } + else + { + if (updateIndex>=UNIT_END) return true; + } + + char* pvalue = strtok(NULL, " "); + if (!pvalue) + { + value=chr->GetUInt32Value(updateIndex); + + PSendSysMessage(LANG_UPDATE, chr->GetGUIDLow(),updateIndex,value); + return true; + } + + value=atoi(pvalue); + + PSendSysMessage(LANG_UPDATE_CHANGE, chr->GetGUIDLow(),updateIndex,value); + + chr->SetUInt32Value(updateIndex,value); + + return true; +} |