Script/Commands: Codestyle and cleanups

This commit is contained in:
Fredi Machado
2011-10-10 10:33:13 -03:00
parent 3b4b6a2d9a
commit fd76ef3cd0
7 changed files with 825 additions and 798 deletions

View File

@@ -98,7 +98,7 @@ public:
return commandTable;
}
static bool HandleDebugPlayCinematicCommand(ChatHandler* handler, const char* args)
static bool HandleDebugPlayCinematicCommand(ChatHandler* handler, char const* args)
{
// USAGE: .debug play cinematic #cinematicid
// #cinematicid - ID decimal number from CinemaicSequences.dbc (1st column)
@@ -109,20 +109,20 @@ public:
return false;
}
uint32 dwId = atoi((char*)args);
uint32 id = atoi((char*)args);
if (!sCinematicSequencesStore.LookupEntry(dwId))
if (!sCinematicSequencesStore.LookupEntry(id))
{
handler->PSendSysMessage(LANG_CINEMATIC_NOT_EXIST, dwId);
handler->PSendSysMessage(LANG_CINEMATIC_NOT_EXIST, id);
handler->SetSentErrorMessage(true);
return false;
}
handler->GetSession()->GetPlayer()->SendCinematicStart(dwId);
handler->GetSession()->GetPlayer()->SendCinematicStart(id);
return true;
}
static bool HandleDebugPlayMovieCommand(ChatHandler* handler, const char* args)
static bool HandleDebugPlayMovieCommand(ChatHandler* handler, char const* args)
{
// USAGE: .debug play movie #movieid
// #movieid - ID decimal number from Movie.dbc (1st column)
@@ -133,21 +133,21 @@ public:
return false;
}
uint32 dwId = atoi((char*)args);
uint32 id = atoi((char*)args);
if (!sMovieStore.LookupEntry(dwId))
if (!sMovieStore.LookupEntry(id))
{
handler->PSendSysMessage(LANG_MOVIE_NOT_EXIST, dwId);
handler->PSendSysMessage(LANG_MOVIE_NOT_EXIST, id);
handler->SetSentErrorMessage(true);
return false;
}
handler->GetSession()->GetPlayer()->SendMovieStart(dwId);
handler->GetSession()->GetPlayer()->SendMovieStart(id);
return true;
}
//Play sound
static bool HandleDebugPlaySoundCommand(ChatHandler* handler, const char* args)
static bool HandleDebugPlaySoundCommand(ChatHandler* handler, char const* args)
{
// USAGE: .debug playsound #soundid
// #soundid - ID decimal number from SoundEntries.dbc (1st column)
@@ -158,11 +158,11 @@ public:
return false;
}
uint32 dwSoundId = atoi((char*)args);
uint32 soundId = atoi((char*)args);
if (!sSoundEntriesStore.LookupEntry(dwSoundId))
if (!sSoundEntriesStore.LookupEntry(soundId))
{
handler->PSendSysMessage(LANG_SOUND_NOT_EXIST, dwSoundId);
handler->PSendSysMessage(LANG_SOUND_NOT_EXIST, soundId);
handler->SetSentErrorMessage(true);
return false;
}
@@ -176,48 +176,48 @@ public:
}
if (handler->GetSession()->GetPlayer()->GetSelection())
unit->PlayDistanceSound(dwSoundId, handler->GetSession()->GetPlayer());
unit->PlayDistanceSound(soundId, handler->GetSession()->GetPlayer());
else
unit->PlayDirectSound(dwSoundId, handler->GetSession()->GetPlayer());
unit->PlayDirectSound(soundId, handler->GetSession()->GetPlayer());
handler->PSendSysMessage(LANG_YOU_HEAR_SOUND, dwSoundId);
handler->PSendSysMessage(LANG_YOU_HEAR_SOUND, soundId);
return true;
}
static bool HandleDebugSendSpellFailCommand(ChatHandler* handler, const char* args)
static bool HandleDebugSendSpellFailCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
char* px = strtok((char*)args, " ");
if (!px)
char* result = strtok((char*)args, " ");
if (!result)
return false;
uint8 failnum = (uint8)atoi(px);
if (failnum == 0 && *px != '0')
uint8 failNum = (uint8)atoi(result);
if (failNum == 0 && *result != '0')
return false;
char* p1 = strtok(NULL, " ");
uint8 failarg1 = p1 ? (uint8)atoi(p1) : 0;
char* fail1 = strtok(NULL, " ");
uint8 failArg1 = fail1 ? (uint8)atoi(fail1) : 0;
char* p2 = strtok(NULL, " ");
uint8 failarg2 = p2 ? (uint8)atoi(p2) : 0;
char* fail2 = strtok(NULL, " ");
uint8 failArg2 = fail2 ? (uint8)atoi(fail2) : 0;
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);
data << uint8(failNum);
if (fail1 || fail2)
data << uint32(failArg1);
if (fail2)
data << uint32(failArg2);
handler->GetSession()->SendPacket(&data);
return true;
}
static bool HandleDebugSendEquipErrorCommand(ChatHandler* handler, const char* args)
static bool HandleDebugSendEquipErrorCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
@@ -227,7 +227,7 @@ public:
return true;
}
static bool HandleDebugSendSellErrorCommand(ChatHandler* handler, const char* args)
static bool HandleDebugSendSellErrorCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
@@ -237,7 +237,7 @@ public:
return true;
}
static bool HandleDebugSendBuyErrorCommand(ChatHandler* handler, const char* args)
static bool HandleDebugSendBuyErrorCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
@@ -247,7 +247,7 @@ public:
return true;
}
static bool HandleDebugSendOpcodeCommand(ChatHandler* handler, const char* /*args*/)
static bool HandleDebugSendOpcodeCommand(ChatHandler* handler, char const* /*args*/)
{
Unit* unit = handler->getSelectedUnit();
Player* player = NULL;
@@ -255,7 +255,9 @@ public:
player = handler->GetSession()->GetPlayer();
else
player = (Player*)unit;
if (!unit) unit = player;
if (!unit)
unit = player;
std::ifstream ifs("opcode.txt");
if (ifs.bad())
@@ -296,9 +298,7 @@ public:
}
// regular data
else
{
ifs.putback(commentToken[1]);
}
}
parsedStream.put(commentToken[0]);
}
@@ -418,7 +418,7 @@ public:
return true;
}
static bool HandleDebugUpdateWorldStateCommand(ChatHandler* handler, const char* args)
static bool HandleDebugUpdateWorldStateCommand(ChatHandler* handler, char const* args)
{
char* w = strtok((char*)args, " ");
char* s = strtok(NULL, " ");
@@ -432,14 +432,16 @@ public:
return true;
}
static bool HandleDebugAreaTriggersCommand(ChatHandler* handler, const char* /*args*/)
static bool HandleDebugAreaTriggersCommand(ChatHandler* handler, char const* /*args*/)
{
Player* player = handler->GetSession()->GetPlayer();
if (!player->isDebugAreaTriggers)
{
handler->PSendSysMessage(LANG_DEBUG_AREATRIGGER_ON);
player->isDebugAreaTriggers = true;
} else {
}
else
{
handler->PSendSysMessage(LANG_DEBUG_AREATRIGGER_OFF);
player->isDebugAreaTriggers = false;
}
@@ -447,12 +449,12 @@ public:
}
//Send notification in channel
static bool HandleDebugSendChannelNotifyCommand(ChatHandler* handler, const char* args)
static bool HandleDebugSendChannelNotifyCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
const char *name = "test";
char const* name = "test";
uint8 code = atoi(args);
WorldPacket data(SMSG_CHANNEL_NOTIFY, (1+10));
@@ -465,12 +467,12 @@ public:
}
//Send notification in chat
static bool HandleDebugSendChatMsgCommand(ChatHandler* handler, const char* args)
static bool HandleDebugSendChatMsgCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
const char *msg = "testtest";
char const* msg = "testtest";
uint8 type = atoi(args);
WorldPacket data;
ChatHandler::FillMessageData(&data, handler->GetSession(), type, 0, "chan", handler->GetSession()->GetPlayer()->GetGUID(), msg, handler->GetSession()->GetPlayer());
@@ -478,54 +480,64 @@ public:
return true;
}
static bool HandleDebugSendQuestPartyMsgCommand(ChatHandler* handler, const char* args)
static bool HandleDebugSendQuestPartyMsgCommand(ChatHandler* handler, char const* args)
{
uint32 msg = atol((char*)args);
handler->GetSession()->GetPlayer()->SendPushToPartyResponse(handler->GetSession()->GetPlayer(), msg);
return true;
}
static bool HandleDebugGetLootRecipientCommand(ChatHandler* handler, const char* /*args*/)
static bool HandleDebugGetLootRecipientCommand(ChatHandler* handler, char const* /*args*/)
{
Creature* target = handler->getSelectedCreature();
if (!target)
return false;
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");
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");
return true;
}
static bool HandleDebugSendQuestInvalidMsgCommand(ChatHandler* handler, const char* args)
static bool HandleDebugSendQuestInvalidMsgCommand(ChatHandler* handler, char const* args)
{
uint32 msg = atol((char*)args);
handler->GetSession()->GetPlayer()->SendCanTakeQuestResponse(msg);
return true;
}
static bool HandleDebugGetItemStateCommand(ChatHandler* handler, const char* args)
static bool HandleDebugGetItemStateCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
std::string state_str = args;
std::string itemState = args;
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;
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;
Player* player = handler->getSelectedPlayer();
if (!player) player = handler->GetSession()->GetPlayer();
if (!player)
player = handler->GetSession()->GetPlayer();
if (!list_queue && !check_all)
if (!listQueue && !checkAll)
{
state_str = "The player has the following " + state_str + " items: ";
handler->SendSysMessage(state_str.c_str());
itemState = "The player has the following " + itemState + " items: ";
handler->SendSysMessage(itemState.c_str());
for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i)
{
if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END)
@@ -546,60 +558,73 @@ public:
}
}
if (list_queue)
if (listQueue)
{
std::vector<Item*> &updateQueue = player->GetItemUpdateQueue();
std::vector<Item*>& updateQueue = player->GetItemUpdateQueue();
for (size_t i = 0; i < updateQueue.size(); ++i)
{
Item* item = updateQueue[i];
if (!item) continue;
if (!item)
continue;
Bag* container = item->GetContainer();
uint8 bag_slot = container ? container->GetSlot() : uint8(INVENTORY_SLOT_BAG_0);
uint8 bagSlot = container ? container->GetSlot() : uint8(INVENTORY_SLOT_BAG_0);
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;
case ITEM_UNCHANGED:
st = "unchanged";
break;
case ITEM_CHANGED:
st = "changed";
break;
case ITEM_NEW:
st = "new";
break;
case ITEM_REMOVED:
st = "removed";
break;
}
handler->PSendSysMessage("bag: %d slot: %d guid: %d - state: %s", bag_slot, item->GetSlot(), item->GetGUIDLow(), st.c_str());
handler->PSendSysMessage("bag: %d slot: %d guid: %d - state: %s", bagSlot, item->GetSlot(), item->GetGUIDLow(), st.c_str());
}
if (updateQueue.empty())
handler->PSendSysMessage("The player's updatequeue is empty");
}
if (check_all)
if (checkAll)
{
bool error = false;
std::vector<Item*> &updateQueue = player->GetItemUpdateQueue();
std::vector<Item*>& updateQueue = player->GetItemUpdateQueue();
for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i)
{
if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END)
continue;
Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
if (!item) continue;
if (!item)
continue;
if (item->GetSlot() != i)
{
handler->PSendSysMessage("Item with slot %d and guid %d has an incorrect slot value: %d", i, item->GetGUIDLow(), item->GetSlot());
error = true; continue;
error = true;
continue;
}
if (item->GetOwnerGUID() != player->GetGUID())
{
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());
error = true; continue;
error = true;
continue;
}
if (Bag* container = item->GetContainer())
{
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());
error = true; continue;
error = true;
continue;
}
if (item->IsInUpdateQueue())
@@ -608,25 +633,29 @@ public:
if (qp > updateQueue.size())
{
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);
error = true; continue;
error = true;
continue;
}
if (updateQueue[qp] == NULL)
{
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);
error = true; continue;
error = true;
continue;
}
if (updateQueue[qp] != item)
{
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());
error = true; continue;
error = true;
continue;
}
}
else if (item->GetState() != ITEM_UNCHANGED)
{
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());
error = true; continue;
error = true;
continue;
}
if (Bag* bag = item->ToBag())
@@ -634,31 +663,36 @@ public:
for (uint8 j = 0; j < bag->GetBagSize(); ++j)
{
Item* item2 = bag->GetItemByPos(j);
if (!item2) continue;
if (!item2)
continue;
if (item2->GetSlot() != j)
{
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());
error = true; continue;
error = true;
continue;
}
if (item2->GetOwnerGUID() != player->GetGUID())
{
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());
error = true; continue;
error = true;
continue;
}
Bag* container = item2->GetContainer();
if (!container)
{
handler->PSendSysMessage("The item in bag %d at slot %d with guid %d has no container!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow());
error = true; continue;
error = true;
continue;
}
if (container != bag)
{
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;
error = true;
continue;
}
if (item2->IsInUpdateQueue())
@@ -667,25 +701,29 @@ public:
if (qp > updateQueue.size())
{
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);
error = true; continue;
error = true;
continue;
}
if (updateQueue[qp] == NULL)
{
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);
error = true; continue;
error = true;
continue;
}
if (updateQueue[qp] != item2)
{
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());
error = true; continue;
error = true;
continue;
}
}
else if (item2->GetState() != ITEM_UNCHANGED)
{
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());
error = true; continue;
error = true;
continue;
}
}
}
@@ -694,33 +732,40 @@ public:
for (size_t i = 0; i < updateQueue.size(); ++i)
{
Item* item = updateQueue[i];
if (!item) continue;
if (!item)
continue;
if (item->GetOwnerGUID() != player->GetGUID())
{
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());
error = true; continue;
error = true;
continue;
}
if (item->GetQueuePos() != i)
{
handler->PSendSysMessage("queue(" SIZEFMTD "): For the item with guid %d, the queuepos doesn't match it's position in the queue!", i, item->GetGUIDLow());
error = true; continue;
error = true;
continue;
}
if (item->GetState() == ITEM_REMOVED) continue;
if (item->GetState() == ITEM_REMOVED)
continue;
Item* test = player->GetItemByPos(item->GetBagSlot(), item->GetSlot());
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 any item at that position!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow());
error = true; continue;
error = true;
continue;
}
if (test != item)
{
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());
error = true; continue;
error = true;
continue;
}
}
if (!error)
@@ -730,54 +775,54 @@ public:
return true;
}
static bool HandleDebugBattlegroundCommand(ChatHandler* /*handler*/, const char* /*args*/)
static bool HandleDebugBattlegroundCommand(ChatHandler* /*handler*/, char const* /*args*/)
{
sBattlegroundMgr->ToggleTesting();
return true;
}
static bool HandleDebugArenaCommand(ChatHandler* /*handler*/, const char* /*args*/)
static bool HandleDebugArenaCommand(ChatHandler* /*handler*/, char const* /*args*/)
{
sBattlegroundMgr->ToggleArenaTesting();
return true;
}
static bool HandleDebugThreatListCommand(ChatHandler* handler, const char* /*args*/)
static bool HandleDebugThreatListCommand(ChatHandler* handler, char const* /*args*/)
{
Creature* target = handler->getSelectedCreature();
if (!target || target->isTotem() || target->isPet())
return false;
std::list<HostileReference*>& tlist = target->getThreatManager().getThreatList();
std::list<HostileReference*>& threatList = target->getThreatManager().getThreatList();
std::list<HostileReference*>::iterator itr;
uint32 cnt = 0;
uint32 count = 0;
handler->PSendSysMessage("Threat list of %s (guid %u)", target->GetName(), target->GetGUIDLow());
for (itr = tlist.begin(); itr != tlist.end(); ++itr)
for (itr = threatList.begin(); itr != threatList.end(); ++itr)
{
Unit* unit = (*itr)->getTarget();
if (!unit)
continue;
++cnt;
handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", cnt, unit->GetName(), unit->GetGUIDLow(), (*itr)->getThreat());
++count;
handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", count, unit->GetName(), unit->GetGUIDLow(), (*itr)->getThreat());
}
handler->SendSysMessage("End of threat list.");
return true;
}
static bool HandleDebugHostileRefListCommand(ChatHandler* handler, const char* /*args*/)
static bool HandleDebugHostileRefListCommand(ChatHandler* handler, char const* /*args*/)
{
Unit* target = handler->getSelectedUnit();
if (!target)
target = handler->GetSession()->GetPlayer();
HostileReference* ref = target->getHostileRefManager().getFirst();
uint32 cnt = 0;
uint32 count = 0;
handler->PSendSysMessage("Hostil reference list of %s (guid %u)", target->GetName(), target->GetGUIDLow());
while (ref)
{
if (Unit* unit = ref->getSource()->getOwner())
{
++cnt;
handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", cnt, unit->GetName(), unit->GetGUIDLow(), ref->getThreat());
++count;
handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", count, unit->GetName(), unit->GetGUIDLow(), ref->getThreat());
}
ref = ref->next();
}
@@ -785,7 +830,7 @@ public:
return true;
}
static bool HandleDebugSetVehicleIdCommand(ChatHandler* handler, const char* args)
static bool HandleDebugSetVehicleIdCommand(ChatHandler* handler, char const* args)
{
Unit* target = handler->getSelectedUnit();
if (!target || target->IsVehicle())
@@ -804,7 +849,7 @@ public:
return true;
}
static bool HandleDebugEnterVehicleCommand(ChatHandler* handler, const char* args)
static bool HandleDebugEnterVehicleCommand(ChatHandler* handler, char const* args)
{
Unit* target = handler->getSelectedUnit();
if (!target || !target->IsVehicle())
@@ -839,7 +884,7 @@ public:
return true;
}
static bool HandleDebugSpawnVehicleCommand(ChatHandler* handler, const char* args)
static bool HandleDebugSpawnVehicleCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
@@ -885,7 +930,7 @@ public:
return true;
}
static bool HandleDebugSendLargePacketCommand(ChatHandler* handler, const char* /*args*/)
static bool HandleDebugSendLargePacketCommand(ChatHandler* handler, char const* /*args*/)
{
const char* stuffingString = "This is a dummy string to push the packet's size beyond 128000 bytes. ";
std::ostringstream ss;
@@ -895,7 +940,7 @@ public:
return true;
}
static bool HandleDebugSendSetPhaseShiftCommand(ChatHandler* handler, const char* args)
static bool HandleDebugSendSetPhaseShiftCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
@@ -905,7 +950,7 @@ public:
return true;
}
static bool HandleDebugGetItemValueCommand(ChatHandler* handler, const char* args)
static bool HandleDebugGetItemValueCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
@@ -934,7 +979,7 @@ public:
return true;
}
static bool HandleDebugSetItemValueCommand(ChatHandler* handler, const char* args)
static bool HandleDebugSetItemValueCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
@@ -963,7 +1008,7 @@ public:
return true;
}
static bool HandleDebugItemExpireCommand(ChatHandler* handler, const char* args)
static bool HandleDebugItemExpireCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
@@ -986,17 +1031,17 @@ public:
}
//show animation
static bool HandleDebugAnimCommand(ChatHandler* handler, const char* args)
static bool HandleDebugAnimCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
uint32 anim_id = atoi((char*)args);
handler->GetSession()->GetPlayer()->HandleEmoteCommand(anim_id);
uint32 animId = atoi((char*)args);
handler->GetSession()->GetPlayer()->HandleEmoteCommand(animId);
return true;
}
static bool HandleDebugSetAuraStateCommand(ChatHandler* handler, const char* args)
static bool HandleDebugSetAuraStateCommand(ChatHandler* handler, char const* args)
{
if (!*args)
{
@@ -1026,16 +1071,16 @@ public:
return true;
}
static bool HandleDebugSetValueCommand(ChatHandler* handler, const char* args)
static bool HandleDebugSetValueCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
char* px = strtok((char*)args, " ");
char* py = strtok(NULL, " ");
char* pz = strtok(NULL, " ");
char* x = strtok((char*)args, " ");
char* y = strtok(NULL, " ");
char* z = strtok(NULL, " ");
if (!px || !py)
if (!x || !y)
return false;
WorldObject* target = handler->getSelectedObject();
@@ -1048,41 +1093,42 @@ public:
uint64 guid = target->GetGUID();
uint32 Opcode = (uint32)atoi(px);
if (Opcode >= target->GetValuesCount())
uint32 opcode = (uint32)atoi(x);
if (opcode >= target->GetValuesCount())
{
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount());
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, GUID_LOPART(guid), target->GetValuesCount());
return false;
}
bool isint32 = true;
if (pz)
isint32 = (bool)atoi(pz);
if (isint32)
bool isInt32 = true;
if (z)
isInt32 = (bool)atoi(z);
if (isInt32)
{
uint32 iValue = (uint32)atoi(py);
target->SetUInt32Value(Opcode, iValue);
handler->PSendSysMessage(LANG_SET_UINT_FIELD, GUID_LOPART(guid), Opcode, iValue);
uint32 value = (uint32)atoi(y);
target->SetUInt32Value(opcode , value);
handler->PSendSysMessage(LANG_SET_UINT_FIELD, GUID_LOPART(guid), opcode, value);
}
else
{
float fValue = (float)atof(py);
target->SetFloatValue(Opcode, fValue);
handler->PSendSysMessage(LANG_SET_FLOAT_FIELD, GUID_LOPART(guid), Opcode, fValue);
float value = (float)atof(y);
target->SetFloatValue(opcode , value);
handler->PSendSysMessage(LANG_SET_FLOAT_FIELD, GUID_LOPART(guid), opcode, value);
}
return true;
}
static bool HandleDebugGetValueCommand(ChatHandler* handler, const char* args)
static bool HandleDebugGetValueCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
char* px = strtok((char*)args, " ");
char* pz = strtok(NULL, " ");
char* x = strtok((char*)args, " ");
char* z = strtok(NULL, " ");
if (!px)
if (!x)
return false;
Unit* target = handler->getSelectedUnit();
@@ -1095,62 +1141,62 @@ public:
uint64 guid = target->GetGUID();
uint32 Opcode = (uint32)atoi(px);
if (Opcode >= target->GetValuesCount())
uint32 opcode = (uint32)atoi(x);
if (opcode >= target->GetValuesCount())
{
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount());
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, GUID_LOPART(guid), target->GetValuesCount());
return false;
}
bool isint32 = true;
if (pz)
isint32 = (bool)atoi(pz);
bool isInt32 = true;
if (z)
isInt32 = (bool)atoi(z);
if (isint32)
if (isInt32)
{
uint32 iValue = target->GetUInt32Value(Opcode);
handler->PSendSysMessage(LANG_GET_UINT_FIELD, GUID_LOPART(guid), Opcode, iValue);
uint32 value = target->GetUInt32Value(opcode);
handler->PSendSysMessage(LANG_GET_UINT_FIELD, GUID_LOPART(guid), opcode, value);
}
else
{
float fValue = target->GetFloatValue(Opcode);
handler->PSendSysMessage(LANG_GET_FLOAT_FIELD, GUID_LOPART(guid), Opcode, fValue);
float value = target->GetFloatValue(opcode);
handler->PSendSysMessage(LANG_GET_FLOAT_FIELD, GUID_LOPART(guid), opcode, value);
}
return true;
}
static bool HandleDebugMod32ValueCommand(ChatHandler* handler, const char* args)
static bool HandleDebugMod32ValueCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
char* px = strtok((char*)args, " ");
char* py = strtok(NULL, " ");
char* x = strtok((char*)args, " ");
char* y = strtok(NULL, " ");
if (!px || !py)
if (!x || !y)
return false;
uint32 Opcode = (uint32)atoi(px);
int Value = atoi(py);
uint32 opcode = (uint32)atoi(x);
int value = atoi(y);
if (Opcode >= handler->GetSession()->GetPlayer()->GetValuesCount())
if (opcode >= handler->GetSession()->GetPlayer()->GetValuesCount())
{
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, handler->GetSession()->GetPlayer()->GetGUIDLow(), handler->GetSession()->GetPlayer()->GetValuesCount());
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, handler->GetSession()->GetPlayer()->GetGUIDLow(), handler->GetSession()->GetPlayer()->GetValuesCount());
return false;
}
int CurrentValue = (int)handler->GetSession()->GetPlayer()->GetUInt32Value(Opcode);
int currentValue = (int)handler->GetSession()->GetPlayer()->GetUInt32Value(opcode);
CurrentValue += Value;
handler->GetSession()->GetPlayer()->SetUInt32Value(Opcode, (uint32)CurrentValue);
currentValue += value;
handler->GetSession()->GetPlayer()->SetUInt32Value(opcode , (uint32)currentValue);
handler->PSendSysMessage(LANG_CHANGE_32BIT_FIELD, Opcode, CurrentValue);
handler->PSendSysMessage(LANG_CHANGE_32BIT_FIELD, opcode, currentValue);
return true;
}
static bool HandleDebugUpdateCommand(ChatHandler* handler, const char* args)
static bool HandleDebugUpdateCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
@@ -1158,49 +1204,48 @@ public:
uint32 updateIndex;
uint32 value;
char* pUpdateIndex = strtok((char*)args, " ");
char* index = strtok((char*)args, " ");
Unit* chr = handler->getSelectedUnit();
if (chr == NULL)
Unit* unit = handler->getSelectedUnit();
if (!unit)
{
handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
handler->SetSentErrorMessage(true);
return false;
}
if (!pUpdateIndex)
{
if (!index)
return true;
}
updateIndex = atoi(pUpdateIndex);
updateIndex = atoi(index);
//check updateIndex
if (chr->GetTypeId() == TYPEID_PLAYER)
if (unit->GetTypeId() == TYPEID_PLAYER)
{
if (updateIndex >= PLAYER_END) return true;
}
else
{
if (updateIndex >= UNIT_END) return true;
if (updateIndex >= PLAYER_END)
return true;
}
else if (updateIndex >= UNIT_END)
return true;
char* pvalue = strtok(NULL, " ");
if (!pvalue)
char* val = strtok(NULL, " ");
if (!val)
{
value=chr->GetUInt32Value(updateIndex);
value = unit->GetUInt32Value(updateIndex);
handler->PSendSysMessage(LANG_UPDATE, chr->GetGUIDLow(), updateIndex, value);
handler->PSendSysMessage(LANG_UPDATE, unit->GetGUIDLow(), updateIndex, value);
return true;
}
value=atoi(pvalue);
value = atoi(val);
handler->PSendSysMessage(LANG_UPDATE_CHANGE, chr->GetGUIDLow(), updateIndex, value);
handler->PSendSysMessage(LANG_UPDATE_CHANGE, unit->GetGUIDLow(), updateIndex, value);
chr->SetUInt32Value(updateIndex, value);
unit->SetUInt32Value(updateIndex, value);
return true;
}
static bool HandleDebugSet32BitCommand(ChatHandler* handler, const char* args)
static bool HandleDebugSet32BitCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
@@ -1213,21 +1258,21 @@ public:
return false;
}
char* px = strtok((char*)args, " ");
char* py = strtok(NULL, " ");
char* x = strtok((char*)args, " ");
char* y = strtok(NULL, " ");
if (!px || !py)
if (!x || !y)
return false;
uint32 Opcode = (uint32)atoi(px);
uint32 Value = (uint32)atoi(py);
if (Value > 32) //uint32 = 32 bits
uint32 opcode = (uint32)atoi(x);
uint32 val = (uint32)atoi(y);
if (val > 32) //uint32 = 32 bits
return false;
uint32 iValue = Value ? 1 << (Value - 1) : 0;
target->SetUInt32Value(Opcode, iValue);
uint32 value = val ? 1 << (val - 1) : 0;
target->SetUInt32Value(opcode, value);
handler->PSendSysMessage(LANG_SET_32BIT_FIELD, Opcode, iValue);
handler->PSendSysMessage(LANG_SET_32BIT_FIELD, opcode, value);
return true;
}
};