Core/Commands: Convert list commands in commandscript
This commit is contained in:
@@ -122,15 +122,6 @@ ChatCommand* ChatHandler::getCommandTable()
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand listCommandTable[] =
|
||||
{
|
||||
{ "creature", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleListCreatureCommand>, "", NULL },
|
||||
{ "item", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleListItemCommand>, "", NULL },
|
||||
{ "object", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleListObjectCommand>, "", NULL },
|
||||
{ "auras", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleListAurasCommand>, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand lookupPlayerCommandTable[] =
|
||||
{
|
||||
{ "ip", SEC_GAMEMASTER, true, OldHandler<&ChatHandler::HandleLookupPlayerIpCommand>, "", NULL },
|
||||
@@ -234,7 +225,6 @@ ChatCommand* ChatHandler::getCommandTable()
|
||||
|
||||
static ChatCommand commandTable[] =
|
||||
{
|
||||
{ "list", SEC_ADMINISTRATOR, true, NULL, "", listCommandTable },
|
||||
{ "lookup", SEC_ADMINISTRATOR, true, NULL, "", lookupCommandTable },
|
||||
{ "pdump", SEC_ADMINISTRATOR, true, NULL, "", pdumpCommandTable },
|
||||
{ "guild", SEC_ADMINISTRATOR, true, NULL, "", guildCommandTable },
|
||||
|
||||
@@ -163,11 +163,6 @@ class ChatHandler
|
||||
bool HandleGuildRankCommand(const char* args);
|
||||
bool HandleGuildDeleteCommand(const char* args);
|
||||
|
||||
bool HandleListAurasCommand(const char * args);
|
||||
bool HandleListCreatureCommand(const char* args);
|
||||
bool HandleListItemCommand(const char* args);
|
||||
bool HandleListObjectCommand(const char* args);
|
||||
|
||||
bool HandleLookupAreaCommand(const char* args);
|
||||
bool HandleLookupCreatureCommand(const char* args);
|
||||
bool HandleLookupEventCommand(const char* args);
|
||||
|
||||
@@ -385,365 +385,6 @@ bool ChatHandler::HandleAddItemSetCommand(const char *args)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleListItemCommand(const char *args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char* cId = extractKeyFromLink((char*)args, "Hitem");
|
||||
if (!cId)
|
||||
return false;
|
||||
|
||||
uint32 item_id = atol(cId);
|
||||
if (!item_id)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(item_id);
|
||||
if (!itemProto)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
char* c_count = strtok(NULL, " ");
|
||||
int _count = c_count ? atol(c_count) : 10;
|
||||
|
||||
if (_count < 0)
|
||||
return false;
|
||||
uint32 count = uint32(_count);
|
||||
|
||||
PreparedQueryResult result;
|
||||
|
||||
// inventory case
|
||||
uint32 inv_count = 0;
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_COUNT_ITEM);
|
||||
stmt->setUInt32(0, item_id);
|
||||
result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (result)
|
||||
inv_count = (*result)[0].GetUInt64();
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY);
|
||||
stmt->setUInt32(0, item_id);
|
||||
stmt->setUInt32(1, count);
|
||||
result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 item_guid = fields[0].GetUInt32();
|
||||
uint32 item_bag = fields[1].GetUInt32();
|
||||
uint8 item_slot = fields[2].GetUInt8();
|
||||
uint32 owner_guid = fields[3].GetUInt32();
|
||||
uint32 owner_acc = fields[4].GetUInt32();
|
||||
std::string owner_name = fields[5].GetString();
|
||||
|
||||
char const* item_pos = 0;
|
||||
if (Player::IsEquipmentPos(item_bag, item_slot))
|
||||
item_pos = "[equipped]";
|
||||
else if (Player::IsInventoryPos(item_bag, item_slot))
|
||||
item_pos = "[in inventory]";
|
||||
else if (Player::IsBankPos(item_bag, item_slot))
|
||||
item_pos = "[in bank]";
|
||||
else
|
||||
item_pos = "";
|
||||
|
||||
PSendSysMessage(LANG_ITEMLIST_SLOT, item_guid, owner_name.c_str(), owner_guid, owner_acc, item_pos);
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
uint32 res_count = uint32(result->GetRowCount());
|
||||
|
||||
if (count > res_count)
|
||||
count -= res_count;
|
||||
else if (count)
|
||||
count = 0;
|
||||
}
|
||||
|
||||
// mail case
|
||||
uint32 mail_count = 0;
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_COUNT_ITEM);
|
||||
stmt->setUInt32(0, item_id);
|
||||
result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (result)
|
||||
mail_count = (*result)[0].GetUInt64();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_ITEMS_BY_ENTRY);
|
||||
stmt->setUInt32(0, item_id);
|
||||
stmt->setUInt32(1, count);
|
||||
result = CharacterDatabase.Query(stmt);
|
||||
}
|
||||
else
|
||||
result = PreparedQueryResult(NULL);
|
||||
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 item_guid = fields[0].GetUInt32();
|
||||
uint32 item_s = fields[1].GetUInt32();
|
||||
uint32 item_r = fields[2].GetUInt32();
|
||||
uint32 item_s_acc = fields[3].GetUInt32();
|
||||
std::string item_s_name = fields[4].GetString();
|
||||
uint32 item_r_acc = fields[5].GetUInt32();
|
||||
std::string item_r_name = fields[6].GetString();
|
||||
|
||||
char const* item_pos = "[in mail]";
|
||||
|
||||
PSendSysMessage(LANG_ITEMLIST_MAIL, item_guid, item_s_name.c_str(), item_s, item_s_acc, item_r_name.c_str(), item_r, item_r_acc, item_pos);
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
uint32 res_count = uint32(result->GetRowCount());
|
||||
|
||||
if (count > res_count)
|
||||
count -= res_count;
|
||||
else if (count)
|
||||
count = 0;
|
||||
}
|
||||
|
||||
// auction case
|
||||
uint32 auc_count = 0;
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_AUCTIONHOUSE_COUNT_ITEM);
|
||||
stmt->setUInt32(0, item_id);
|
||||
result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (result)
|
||||
auc_count = (*result)[0].GetUInt64();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_AUCTIONHOUSE_ITEM_BY_ENTRY);
|
||||
stmt->setUInt32(0, item_id);
|
||||
stmt->setUInt32(1, count);
|
||||
result = CharacterDatabase.Query(stmt);
|
||||
}
|
||||
else
|
||||
result = PreparedQueryResult(NULL);
|
||||
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 item_guid = fields[0].GetUInt32();
|
||||
uint32 owner = fields[1].GetUInt32();
|
||||
uint32 owner_acc = fields[2].GetUInt32();
|
||||
std::string owner_name = fields[3].GetString();
|
||||
|
||||
char const* item_pos = "[in auction]";
|
||||
|
||||
PSendSysMessage(LANG_ITEMLIST_AUCTION, item_guid, owner_name.c_str(), owner, owner_acc, item_pos);
|
||||
}
|
||||
while (result->NextRow());
|
||||
}
|
||||
|
||||
// guild bank case
|
||||
uint32 guild_count = 0;
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_BANK_COUNT_ITEM);
|
||||
stmt->setUInt32(0, item_id);
|
||||
result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (result)
|
||||
guild_count = (*result)[0].GetUInt64();
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_BANK_ITEM_BY_ENTRY);
|
||||
stmt->setUInt32(0, item_id);
|
||||
stmt->setUInt32(1, count);
|
||||
result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 item_guid = fields[0].GetUInt32();
|
||||
uint32 guild_guid = fields[1].GetUInt32();
|
||||
std::string guild_name = fields[2].GetString();
|
||||
|
||||
char const* item_pos = "[in guild bank]";
|
||||
|
||||
PSendSysMessage(LANG_ITEMLIST_GUILD, item_guid, guild_name.c_str(), guild_guid, item_pos);
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
uint32 res_count = uint32(result->GetRowCount());
|
||||
|
||||
if (count > res_count)
|
||||
count -= res_count;
|
||||
else if (count)
|
||||
count = 0;
|
||||
}
|
||||
|
||||
if (inv_count + mail_count + auc_count + guild_count == 0)
|
||||
{
|
||||
SendSysMessage(LANG_COMMAND_NOITEMFOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
PSendSysMessage(LANG_COMMAND_LISTITEMMESSAGE, item_id, inv_count + mail_count + auc_count + guild_count, inv_count, mail_count, auc_count, guild_count);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleListObjectCommand(const char *args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
// number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r
|
||||
char* cId = extractKeyFromLink((char*)args, "Hgameobject_entry");
|
||||
if (!cId)
|
||||
return false;
|
||||
|
||||
uint32 go_id = atol(cId);
|
||||
if (!go_id)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID, go_id);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
GameObjectTemplate const* gInfo = sObjectMgr->GetGameObjectTemplate(go_id);
|
||||
if (!gInfo)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID, go_id);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
char* c_count = strtok(NULL, " ");
|
||||
int count = c_count ? atol(c_count) : 10;
|
||||
|
||||
if (count < 0)
|
||||
return false;
|
||||
|
||||
QueryResult result;
|
||||
|
||||
uint32 obj_count = 0;
|
||||
result = WorldDatabase.PQuery("SELECT COUNT(guid) FROM gameobject WHERE id='%u'", go_id);
|
||||
if (result)
|
||||
obj_count = (*result)[0].GetUInt64();
|
||||
|
||||
if (m_session)
|
||||
{
|
||||
Player* player = m_session->GetPlayer();
|
||||
result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, id, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE id = '%u' ORDER BY order_ ASC LIMIT %u",
|
||||
player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), go_id, uint32(count));
|
||||
}
|
||||
else
|
||||
result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, id FROM gameobject WHERE id = '%u' LIMIT %u",
|
||||
go_id, uint32(count));
|
||||
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guid = fields[0].GetUInt32();
|
||||
float x = fields[1].GetFloat();
|
||||
float y = fields[2].GetFloat();
|
||||
float z = fields[3].GetFloat();
|
||||
int mapid = fields[4].GetUInt16();
|
||||
uint32 entry = fields[5].GetUInt32();
|
||||
|
||||
if (m_session)
|
||||
PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name.c_str(), x, y, z, mapid);
|
||||
else
|
||||
PSendSysMessage(LANG_GO_LIST_CONSOLE, guid, gInfo->name.c_str(), x, y, z, mapid);
|
||||
} while (result->NextRow());
|
||||
}
|
||||
|
||||
PSendSysMessage(LANG_COMMAND_LISTOBJMESSAGE, go_id, obj_count);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleListCreatureCommand(const char *args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
// number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r
|
||||
char* cId = extractKeyFromLink((char*)args, "Hcreature_entry");
|
||||
if (!cId)
|
||||
return false;
|
||||
|
||||
uint32 cr_id = atol(cId);
|
||||
if (!cr_id)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID, cr_id);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(cr_id);
|
||||
if (!cInfo)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID, cr_id);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
char* c_count = strtok(NULL, " ");
|
||||
int count = c_count ? atol(c_count) : 10;
|
||||
|
||||
if (count < 0)
|
||||
return false;
|
||||
|
||||
QueryResult result;
|
||||
|
||||
uint32 cr_count = 0;
|
||||
result = WorldDatabase.PQuery("SELECT COUNT(guid) FROM creature WHERE id='%u'", cr_id);
|
||||
if (result)
|
||||
cr_count = (*result)[0].GetUInt64();
|
||||
|
||||
if (m_session)
|
||||
{
|
||||
Player* player = m_session->GetPlayer();
|
||||
result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM creature WHERE id = '%u' ORDER BY order_ ASC LIMIT %u",
|
||||
player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), cr_id, uint32(count));
|
||||
}
|
||||
else
|
||||
result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id = '%u' LIMIT %u",
|
||||
cr_id, uint32(count));
|
||||
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guid = fields[0].GetUInt32();
|
||||
float x = fields[1].GetFloat();
|
||||
float y = fields[2].GetFloat();
|
||||
float z = fields[3].GetFloat();
|
||||
int mapid = fields[4].GetUInt16();
|
||||
|
||||
if (m_session)
|
||||
PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, cInfo->Name.c_str(), x, y, z, mapid);
|
||||
else
|
||||
PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, cInfo->Name.c_str(), x, y, z, mapid);
|
||||
} while (result->NextRow());
|
||||
}
|
||||
|
||||
PSendSysMessage(LANG_COMMAND_LISTCREATUREMESSAGE, cr_id, cr_count);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleLookupItemCommand(const char *args)
|
||||
{
|
||||
if (!*args)
|
||||
@@ -2349,54 +1990,6 @@ bool ChatHandler::HandleChangeWeather(const char *args)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleListAurasCommand (const char * /*args*/)
|
||||
{
|
||||
Unit* unit = getSelectedUnit();
|
||||
if (!unit)
|
||||
{
|
||||
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
char const* talentStr = GetTrinityString(LANG_TALENT);
|
||||
char const* passiveStr = GetTrinityString(LANG_PASSIVE);
|
||||
|
||||
Unit::AuraApplicationMap const& uAuras = unit->GetAppliedAuras();
|
||||
PSendSysMessage(LANG_COMMAND_TARGET_LISTAURAS, uAuras.size());
|
||||
for (Unit::AuraApplicationMap::const_iterator itr = uAuras.begin(); itr != uAuras.end(); ++itr)
|
||||
{
|
||||
bool talent = GetTalentSpellCost(itr->second->GetBase()->GetId()) > 0;
|
||||
|
||||
AuraApplication const* aurApp = itr->second;
|
||||
Aura const* aura = aurApp->GetBase();
|
||||
char const* name = aura->GetSpellInfo()->SpellName[GetSessionDbcLocale()];
|
||||
|
||||
std::ostringstream ss_name;
|
||||
ss_name << "|cffffffff|Hspell:" << aura->GetId() << "|h[" << name << "]|h|r";
|
||||
|
||||
PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, aura->GetId(), (m_session ? ss_name.str().c_str() : name),
|
||||
aurApp->GetEffectMask(), aura->GetCharges(), aura->GetStackAmount(), aurApp->GetSlot(),
|
||||
aura->GetDuration(), aura->GetMaxDuration(), (aura->IsPassive() ? passiveStr : ""),
|
||||
(talent ? talentStr : ""), IS_PLAYER_GUID(aura->GetCasterGUID()) ? "player" : "creature",
|
||||
GUID_LOPART(aura->GetCasterGUID()));
|
||||
}
|
||||
for (uint16 i = 0; i < TOTAL_AURAS; ++i)
|
||||
{
|
||||
Unit::AuraEffectList const& uAuraList = unit->GetAuraEffectsByType(AuraType(i));
|
||||
if (uAuraList.empty())
|
||||
continue;
|
||||
|
||||
PSendSysMessage(LANG_COMMAND_TARGET_LISTAURATYPE, uAuraList.size(), i);
|
||||
for (Unit::AuraEffectList::const_iterator itr = uAuraList.begin(); itr != uAuraList.end(); ++itr)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE, (*itr)->GetId(), (*itr)->GetEffIndex(),
|
||||
(*itr)->GetAmount());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleResetAchievementsCommand (const char * args)
|
||||
{
|
||||
Player* target;
|
||||
|
||||
Reference in New Issue
Block a user