TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
list_commandscript Class Reference

Public Member Functions

 list_commandscript ()
 
std::vector< ChatCommandGetCommands () const override
 
- Public Member Functions inherited from ScriptObject
const std::string & GetName () const
 

Static Public Member Functions

static bool HandleListCreatureCommand (ChatHandler *handler, char const *args)
 
static bool HandleListItemCommand (ChatHandler *handler, char const *args)
 
static bool HandleListObjectCommand (ChatHandler *handler, char const *args)
 
static bool HandleListAurasCommand (ChatHandler *handler, char const *)
 
static bool HandleListMailCommand (ChatHandler *handler, char const *args)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name)
 
virtual ~ScriptObject ()
 

Constructor & Destructor Documentation

list_commandscript::list_commandscript ( )
inline
37 : CommandScript("list_commandscript") { }
CommandScript(const char *name)
Definition: ScriptMgr.cpp:1616

Member Function Documentation

std::vector<ChatCommand> list_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

40  {
41  static std::vector<ChatCommand> listCommandTable =
42  {
48  };
49  static std::vector<ChatCommand> commandTable =
50  {
51  { "list", rbac::RBAC_PERM_COMMAND_LIST,true, NULL, "", listCommandTable },
52  };
53  return commandTable;
54  }
arena_t NULL
Definition: jemalloc_internal.h:624
static bool HandleListItemCommand(ChatHandler *handler, char const *args)
Definition: cs_list.cpp:129
static bool HandleListObjectCommand(ChatHandler *handler, char const *args)
Definition: cs_list.cpp:345
static bool HandleListCreatureCommand(ChatHandler *handler, char const *args)
Definition: cs_list.cpp:56
Definition: RBAC.h:348
static bool HandleListAurasCommand(ChatHandler *handler, char const *)
Definition: cs_list.cpp:419
Definition: RBAC.h:343
Definition: RBAC.h:345
static bool HandleListMailCommand(ChatHandler *handler, char const *args)
Definition: cs_list.cpp:467

+ Here is the call graph for this function:

static bool list_commandscript::HandleListAurasCommand ( ChatHandler handler,
char const  
)
inlinestatic
420  {
421  Unit* unit = handler->getSelectedUnit();
422  if (!unit)
423  {
425  handler->SetSentErrorMessage(true);
426  return false;
427  }
428 
429  char const* talentStr = handler->GetTrinityString(LANG_TALENT);
430  char const* passiveStr = handler->GetTrinityString(LANG_PASSIVE);
431 
432  Unit::AuraApplicationMap const& auras = unit->GetAppliedAuras();
433  handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURAS, auras.size());
434  for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
435  {
436 
437  AuraApplication const* aurApp = itr->second;
438  Aura const* aura = aurApp->GetBase();
439  char const* name = aura->GetSpellInfo()->SpellName;
440  bool talent = aura->GetSpellInfo()->HasAttribute(SPELL_ATTR0_CU_IS_TALENT);
441 
442  std::ostringstream ss_name;
443  ss_name << "|cffffffff|Hspell:" << aura->GetId() << "|h[" << name << "]|h|r";
444 
445  handler->PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, aura->GetId(), (handler->GetSession() ? ss_name.str().c_str() : name),
446  aurApp->GetEffectMask(), aura->GetCharges(), aura->GetStackAmount(), aurApp->GetSlot(),
447  aura->GetDuration(), aura->GetMaxDuration(), (aura->IsPassive() ? passiveStr : ""),
448  (talent ? talentStr : ""), aura->GetCasterGUID().IsPlayer() ? "player" : "creature",
449  aura->GetCasterGUID().ToString().c_str());
450  }
451 
452  for (uint16 i = 0; i < TOTAL_AURAS; ++i)
453  {
454  Unit::AuraEffectList const& auraList = unit->GetAuraEffectsByType(AuraType(i));
455  if (auraList.empty())
456  continue;
457 
458  handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURATYPE, auraList.size(), i);
459 
460  for (Unit::AuraEffectList::const_iterator itr = auraList.begin(); itr != auraList.end(); ++itr)
461  handler->PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE, (*itr)->GetId(), (*itr)->GetEffIndex(), (*itr)->GetAmount());
462  }
463 
464  return true;
465  }
AuraType
Definition: SpellAuraDefines.h:58
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
bool IsPassive() const
Definition: SpellAuras.cpp:1026
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
bool IsPlayer() const
Definition: ObjectGuid.h:249
Definition: SpellAuraDefines.h:543
int32 GetMaxDuration() const
Definition: SpellAuras.h:159
Unit * getSelectedUnit()
Definition: Chat.cpp:591
Definition: Language.h:32
Definition: Language.h:469
Aura * GetBase() const
Definition: SpellAuras.h:75
Definition: SpellAuras.h:50
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
uint32 GetEffectMask() const
Definition: SpellAuras.h:79
uint8 GetSlot() const
Definition: SpellAuras.h:77
AuraApplicationMap & GetAppliedAuras()
Definition: Unit.h:1789
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
char * SpellName
Definition: SpellInfo.h:392
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint16_t uint16
Definition: Define.h:151
Definition: Language.h:472
Definition: Language.h:471
int32 GetDuration() const
Definition: SpellAuras.h:163
Definition: Language.h:67
Definition: Language.h:470
uint8 GetStackAmount() const
Definition: SpellAuras.h:179
virtual char const * GetTrinityString(uint32 entry) const
Definition: Chat.cpp:67
WorldSession * GetSession()
Definition: Chat.h:59
uint8 GetCharges() const
Definition: SpellAuras.h:170
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition: Unit.h:1315
Definition: SpellAuras.h:116
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
ObjectGuid GetCasterGUID() const
Definition: SpellAuras.h:135
Definition: Unit.h:1305
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: Language.h:66
uint32 GetId() const
Definition: SpellAuras.h:131
Definition: SpellInfo.h:189

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool list_commandscript::HandleListCreatureCommand ( ChatHandler handler,
char const args 
)
inlinestatic
57  {
58  if (!*args)
59  return false;
60 
61  // number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r
62  char* id = handler->extractKeyFromLink((char*)args, "Hcreature_entry");
63  if (!id)
64  return false;
65 
66  uint32 creatureId = atoul(id);
67  if (!creatureId)
68  {
69  handler->PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID, creatureId);
70  handler->SetSentErrorMessage(true);
71  return false;
72  }
73 
74  CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(creatureId);
75  if (!cInfo)
76  {
77  handler->PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID, creatureId);
78  handler->SetSentErrorMessage(true);
79  return false;
80  }
81 
82  char* countStr = strtok(NULL, " ");
83  uint32 count = countStr ? atoul(countStr) : 10;
84 
85  if (count == 0)
86  return false;
87 
88  QueryResult result;
89 
90  uint32 creatureCount = 0;
91  result = WorldDatabase.PQuery("SELECT COUNT(guid) FROM creature WHERE id='%u'", creatureId);
92  if (result)
93  creatureCount = (*result)[0].GetUInt64();
94 
95  if (handler->GetSession())
96  {
97  Player* player = handler->GetSession()->GetPlayer();
98  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",
99  player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), creatureId, count);
100  }
101  else
102  result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id = '%u' LIMIT %u",
103  creatureId, count);
104 
105  if (result)
106  {
107  do
108  {
109  Field* fields = result->Fetch();
110  ObjectGuid::LowType guid = fields[0].GetUInt64();
111  float x = fields[1].GetFloat();
112  float y = fields[2].GetFloat();
113  float z = fields[3].GetFloat();
114  uint16 mapId = fields[4].GetUInt16();
115 
116  if (handler->GetSession())
117  handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, cInfo->Name.c_str(), x, y, z, mapId);
118  else
119  handler->PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, cInfo->Name.c_str(), x, y, z, mapId);
120  }
121  while (result->NextRow());
122  }
123 
124  handler->PSendSysMessage(LANG_COMMAND_LISTCREATUREMESSAGE, creatureId, creatureCount);
125 
126  return true;
127  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
std::string Name
Definition: Creature.h:88
uint64 GetUInt64() const
Definition: Field.h:184
float GetFloat() const
Definition: Field.h:222
QueryResult PQuery(Format &&sql, T *conn, Args &&...args)
Definition: DatabaseWorkerPool.h:165
Class used to access individual fields of database query result.
Definition: Field.h:56
Definition: Language.h:442
arena_t NULL
Definition: jemalloc_internal.h:624
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Player * GetPlayer() const
Definition: WorldSession.h:927
uint64 LowType
Definition: ObjectGuid.h:199
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: Language.h:913
Definition: Language.h:443
unsigned long atoul(char const *str)
Definition: Common.h:90
G3D::int16 z
Definition: Vector3int16.h:46
uint32_t uint32
Definition: Define.h:150
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
G3D::int16 y
Definition: Vector2int16.h:38
uint16_t uint16
Definition: Define.h:151
uint16 GetUInt16() const
Definition: Field.h:108
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
G3D::int16 x
Definition: Vector2int16.h:37
char * extractKeyFromLink(char *text, char const *linkType, char **something1=NULL)
Definition: Chat.cpp:641
Definition: Creature.h:79
Definition: Language.h:528

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool list_commandscript::HandleListItemCommand ( ChatHandler handler,
char const args 
)
inlinestatic
130  {
131  if (!*args)
132  return false;
133 
134  char const* id = handler->extractKeyFromLink((char*)args, "Hitem");
135  if (!id)
136  return false;
137 
138  uint32 itemId = atoul(id);
139  if (!itemId)
140  {
142  handler->SetSentErrorMessage(true);
143  return false;
144  }
145 
146  ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(itemId);
147  if (!itemTemplate)
148  {
150  handler->SetSentErrorMessage(true);
151  return false;
152  }
153 
154  char* countStr = strtok(NULL, " ");
155  uint32 count = countStr ? atoul(countStr) : 10;
156 
157  if (count == 0)
158  return false;
159 
160  PreparedQueryResult result;
161 
162  // inventory case
163  uint32 inventoryCount = 0;
164 
166  stmt->setUInt32(0, itemId);
167  result = CharacterDatabase.Query(stmt);
168 
169  if (result)
170  inventoryCount = (*result)[0].GetUInt64();
171 
173  stmt->setUInt32(0, itemId);
174  stmt->setUInt32(1, count);
175  result = CharacterDatabase.Query(stmt);
176 
177  if (result)
178  {
179  do
180  {
181  Field* fields = result->Fetch();
182  ObjectGuid itemGuid = ObjectGuid::Create<HighGuid::Item>(fields[0].GetUInt64());
183  uint32 itemBag = fields[1].GetUInt32();
184  uint8 itemSlot = fields[2].GetUInt8();
185  ObjectGuid ownerGuid = ObjectGuid::Create<HighGuid::Player>(fields[3].GetUInt64());
186  uint32 ownerAccountId = fields[4].GetUInt32();
187  std::string ownerName = fields[5].GetString();
188 
189  char const* itemPos = 0;
190  if (Player::IsEquipmentPos(itemBag, itemSlot))
191  itemPos = "[equipped]";
192  else if (Player::IsInventoryPos(itemBag, itemSlot))
193  itemPos = "[in inventory]";
194  else if (Player::IsBankPos(itemBag, itemSlot))
195  itemPos = "[in bank]";
196  else
197  itemPos = "";
198 
199  handler->PSendSysMessage(LANG_ITEMLIST_SLOT, itemGuid.ToString().c_str(), ownerName.c_str(), ownerGuid.ToString().c_str(), ownerAccountId, itemPos);
200  }
201  while (result->NextRow());
202 
203  uint32 resultCount = uint32(result->GetRowCount());
204 
205  if (count > resultCount)
206  count -= resultCount;
207  else if (count)
208  count = 0;
209  }
210 
211  // mail case
212  uint32 mailCount = 0;
213 
215  stmt->setUInt32(0, itemId);
216  result = CharacterDatabase.Query(stmt);
217 
218  if (result)
219  mailCount = (*result)[0].GetUInt64();
220 
221  if (count > 0)
222  {
224  stmt->setUInt32(0, itemId);
225  stmt->setUInt32(1, count);
226  result = CharacterDatabase.Query(stmt);
227  }
228  else
229  result = PreparedQueryResult(NULL);
230 
231  if (result)
232  {
233  do
234  {
235  Field* fields = result->Fetch();
236  ObjectGuid::LowType itemGuid = fields[0].GetUInt64();
237  ObjectGuid::LowType itemSender = fields[1].GetUInt64();
238  ObjectGuid::LowType itemReceiver = fields[2].GetUInt64();
239  uint32 itemSenderAccountId = fields[3].GetUInt32();
240  std::string itemSenderName = fields[4].GetString();
241  uint32 itemReceiverAccount = fields[5].GetUInt32();
242  std::string itemReceiverName = fields[6].GetString();
243 
244  char const* itemPos = "[in mail]";
245 
246  handler->PSendSysMessage(LANG_ITEMLIST_MAIL, itemGuid, itemSenderName.c_str(), itemSender, itemSenderAccountId, itemReceiverName.c_str(), itemReceiver, itemReceiverAccount, itemPos);
247  }
248  while (result->NextRow());
249 
250  uint32 resultCount = uint32(result->GetRowCount());
251 
252  if (count > resultCount)
253  count -= resultCount;
254  else if (count)
255  count = 0;
256  }
257 
258  // auction case
259  uint32 auctionCount = 0;
260 
262  stmt->setUInt32(0, itemId);
263  result = CharacterDatabase.Query(stmt);
264 
265  if (result)
266  auctionCount = (*result)[0].GetUInt64();
267 
268  if (count > 0)
269  {
271  stmt->setUInt32(0, itemId);
272  stmt->setUInt32(1, count);
273  result = CharacterDatabase.Query(stmt);
274  }
275  else
276  result = PreparedQueryResult(NULL);
277 
278  if (result)
279  {
280  do
281  {
282  Field* fields = result->Fetch();
283  ObjectGuid itemGuid = ObjectGuid::Create<HighGuid::Item>(fields[0].GetUInt64());
284  ObjectGuid owner = ObjectGuid::Create<HighGuid::Player>(fields[1].GetUInt64());
285  uint32 ownerAccountId = fields[2].GetUInt32();
286  std::string ownerName = fields[3].GetString();
287 
288  char const* itemPos = "[in auction]";
289 
290  handler->PSendSysMessage(LANG_ITEMLIST_AUCTION, itemGuid.ToString().c_str(), ownerName.c_str(), owner.ToString().c_str(), ownerAccountId, itemPos);
291  }
292  while (result->NextRow());
293  }
294 
295  // guild bank case
296  uint32 guildCount = 0;
297 
299  stmt->setUInt32(0, itemId);
300  result = CharacterDatabase.Query(stmt);
301 
302  if (result)
303  guildCount = (*result)[0].GetUInt64();
304 
306  stmt->setUInt32(0, itemId);
307  stmt->setUInt32(1, count);
308  result = CharacterDatabase.Query(stmt);
309 
310  if (result)
311  {
312  do
313  {
314  Field* fields = result->Fetch();
315  ObjectGuid itemGuid = ObjectGuid::Create<HighGuid::Item>(fields[0].GetUInt64());
316  ObjectGuid guildGuid = ObjectGuid::Create<HighGuid::Guild>(fields[1].GetUInt64());
317  std::string guildName = fields[2].GetString();
318 
319  char const* itemPos = "[in guild bank]";
320 
321  handler->PSendSysMessage(LANG_ITEMLIST_GUILD, itemGuid.ToString().c_str(), guildName.c_str(), guildGuid.ToString().c_str(), itemPos);
322  }
323  while (result->NextRow());
324 
325  uint32 resultCount = uint32(result->GetRowCount());
326 
327  if (count > resultCount)
328  count -= resultCount;
329  else if (count)
330  count = 0;
331  }
332 
333  if (inventoryCount + mailCount + auctionCount + guildCount == 0)
334  {
336  handler->SetSentErrorMessage(true);
337  return false;
338  }
339 
340  handler->PSendSysMessage(LANG_COMMAND_LISTITEMMESSAGE, itemId, inventoryCount + mailCount + auctionCount + guildCount, inventoryCount, mailCount, auctionCount, guildCount);
341 
342  return true;
343  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
uint64 GetUInt64() const
Definition: Field.h:184
Definition: Language.h:438
Definition: CharacterDatabase.h:401
Class used to access individual fields of database query result.
Definition: Field.h:56
Definition: CharacterDatabase.h:405
Definition: Language.h:520
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: CharacterDatabase.h:400
Definition: CharacterDatabase.h:404
uint64 LowType
Definition: ObjectGuid.h:199
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PreparedStatement.h:74
Definition: Language.h:921
Definition: CharacterDatabase.h:399
Definition: Language.h:522
uint8 GetUInt8() const
Definition: Field.h:70
unsigned long atoul(char const *str)
Definition: Common.h:90
Definition: CharacterDatabase.h:403
uint32_t uint32
Definition: Define.h:150
Definition: CharacterDatabase.h:406
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
Definition: ItemTemplate.h:647
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
Definition: Language.h:437
uint32 GetUInt32() const
Definition: Field.h:146
Definition: Language.h:440
uint8_t uint8
Definition: Define.h:152
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: ObjectGuid.h:189
uint32_t uint32
Definition: g3dmath.h:168
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
char * extractKeyFromLink(char *text, char const *linkType, char **something1=NULL)
Definition: Chat.cpp:641
std::string GetString() const
Definition: Field.h:276
Definition: CharacterDatabase.h:402
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: Language.h:521

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool list_commandscript::HandleListMailCommand ( ChatHandler handler,
char const args 
)
inlinestatic
468  {
469  Player* target;
470  ObjectGuid targetGuid;
471  std::string targetName;
472  PreparedStatement* stmt = NULL;
473 
474  if (!*args)
475  return false;
476 
477  ObjectGuid parseGUID = ObjectGuid::Create<HighGuid::Player>(strtoull(args, nullptr, 10));
478 
479  if (ObjectMgr::GetPlayerNameByGUID(parseGUID, targetName))
480  {
481  target = ObjectAccessor::FindPlayer(parseGUID);
482  targetGuid = parseGUID;
483  }
484  else if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
485  return false;
486 
488  stmt->setUInt64(0, targetGuid.GetCounter());
489  PreparedQueryResult queryResult = CharacterDatabase.Query(stmt);
490  if (queryResult)
491  {
492  Field* fields = queryResult->Fetch();
493  uint32 countMail = fields[0].GetUInt64();
494 
495  std::string nameLink = handler->playerLink(targetName);
496  handler->PSendSysMessage(LANG_LIST_MAIL_HEADER, countMail, nameLink.c_str(), targetGuid.ToString().c_str());
498 
500  stmt->setUInt64(0, targetGuid.GetCounter());
501  queryResult = CharacterDatabase.Query(stmt);
502 
503  if (queryResult)
504  {
505  do
506  {
507  Field* queryFields = queryResult->Fetch();
508  uint32 messageId = queryFields[0].GetUInt32();
509  ObjectGuid::LowType senderId = queryFields[1].GetUInt64();
510  std::string sender = queryFields[2].GetString();
511  ObjectGuid::LowType receiverId = queryFields[3].GetUInt64();
512  std::string receiver = queryFields[4].GetString();
513  std::string subject = queryFields[5].GetString();
514  uint64 deliverTime = queryFields[6].GetUInt32();
515  uint64 expireTime = queryFields[7].GetUInt32();
516  uint32 money = queryFields[8].GetUInt32();
517  uint8 hasItem = queryFields[9].GetUInt8();
518  uint32 gold = money / GOLD;
519  uint32 silv = (money % GOLD) / SILVER;
520  uint32 copp = (money % GOLD) % SILVER;
521  std::string receiverStr = handler->playerLink(receiver);
522  std::string senderStr = handler->playerLink(sender);
523  handler->PSendSysMessage(LANG_LIST_MAIL_INFO_1, messageId, subject.c_str(), gold, silv, copp);
524  handler->PSendSysMessage(LANG_LIST_MAIL_INFO_2, senderStr.c_str(), senderId, receiverStr.c_str(), receiverId);
525  handler->PSendSysMessage(LANG_LIST_MAIL_INFO_3, TimeToTimestampStr(deliverTime).c_str(), TimeToTimestampStr(expireTime).c_str());
526 
527  if (hasItem == 1)
528  {
529  QueryResult result2;
530  result2 = CharacterDatabase.PQuery("SELECT item_guid FROM mail_items WHERE mail_id = '%u'", messageId);
531  if (result2)
532  {
533  do
534  {
535  uint32 item_guid = (*result2)[0].GetUInt32();
537  stmt->setUInt64(0, item_guid);
539  if (result3)
540  {
541  do
542  {
543  Field* fields3 = result3->Fetch();
544  uint32 item_entry = fields3[0].GetUInt32();
545  uint32 item_count = fields3[1].GetUInt32();
546  QueryResult result4;
547  result4 = WorldDatabase.PQuery("SELECT name, quality FROM item_template WHERE entry = '%u'", item_entry);
548  Field* fields1 = result4->Fetch();
549  std::string item_name = fields1[0].GetString();
550  int item_quality = fields1[1].GetUInt8();
551  if (handler->GetSession())
552  {
553  uint32 color = ItemQualityColors[item_quality];
554  std::ostringstream itemStr;
555  itemStr << "|c" << std::hex << color << "|Hitem:" << item_entry << ":0:0:0:0:0:0:0:0:0|h[" << item_name << "]|h|r";
556  handler->PSendSysMessage(LANG_LIST_MAIL_INFO_ITEM, itemStr.str().c_str(), item_entry, item_guid, item_count);
557  }
558  else
559  handler->PSendSysMessage(LANG_LIST_MAIL_INFO_ITEM, item_name.c_str(), item_entry, item_guid, item_count);
560  }
561  while (result3->NextRow());
562  }
563  }
564  while (result2->NextRow());
565  }
566  }
568  }
569  while (queryResult->NextRow());
570  }
571  else
573  return true;
574  }
575  else
577  return true;
578  }
Definition: SharedDefines.h:231
Definition: Language.h:956
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
uint64 GetUInt64() const
Definition: Field.h:184
IntFormatSpec< int, TypeSpec<'x'> > hex(int value)
QueryResult PQuery(Format &&sql, T *conn, Args &&...args)
Definition: DatabaseWorkerPool.h:165
Definition: Language.h:958
Class used to access individual fields of database query result.
Definition: Field.h:56
arena_t NULL
Definition: jemalloc_internal.h:624
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
uint64 LowType
Definition: ObjectGuid.h:199
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=NULL, std::string *player_name=NULL)
Definition: Chat.cpp:945
Definition: PreparedStatement.h:74
uint8 GetUInt8() const
Definition: Field.h:70
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
Definition: CharacterDatabase.h:48
Definition: CharacterDatabase.h:49
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
std::string TimeToTimestampStr(time_t t)
Definition: Util.cpp:195
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: Language.h:955
Definition: SharedDefines.h:232
static bool GetPlayerNameByGUID(ObjectGuid const &guid, std::string &name)
Definition: ObjectMgr.cpp:2258
Definition: CharacterDatabase.h:50
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
Definition: Language.h:959
uint32 GetUInt32() const
Definition: Field.h:146
const uint32 ItemQualityColors[MAX_ITEM_QUALITY]
Definition: SharedDefines.h:338
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
WorldSession * GetSession()
Definition: Chat.h:59
uint8_t uint8
Definition: Define.h:152
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: ObjectGuid.h:189
Definition: Language.h:881
std::string GetString() const
Definition: Field.h:276
std::string ToString() const
Definition: ObjectGuid.cpp:99
std::string playerLink(std::string const &name) const
Definition: Chat.h:132
Definition: Language.h:957
Definition: Language.h:954
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool list_commandscript::HandleListObjectCommand ( ChatHandler handler,
char const args 
)
inlinestatic
346  {
347  if (!*args)
348  return false;
349 
350  // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r
351  char* id = handler->extractKeyFromLink((char*)args, "Hgameobject_entry");
352  if (!id)
353  return false;
354 
355  uint32 gameObjectId = atoul(id);
356  if (!gameObjectId)
357  {
358  handler->PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID, gameObjectId);
359  handler->SetSentErrorMessage(true);
360  return false;
361  }
362 
363  GameObjectTemplate const* gInfo = sObjectMgr->GetGameObjectTemplate(gameObjectId);
364  if (!gInfo)
365  {
366  handler->PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID, gameObjectId);
367  handler->SetSentErrorMessage(true);
368  return false;
369  }
370 
371  char* countStr = strtok(NULL, " ");
372  uint32 count = countStr ? atoul(countStr) : 10;
373 
374  if (count == 0)
375  return false;
376 
377  QueryResult result;
378 
379  uint32 objectCount = 0;
380  result = WorldDatabase.PQuery("SELECT COUNT(guid) FROM gameobject WHERE id='%u'", gameObjectId);
381  if (result)
382  objectCount = (*result)[0].GetUInt64();
383 
384  if (handler->GetSession())
385  {
386  Player* player = handler->GetSession()->GetPlayer();
387  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",
388  player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), gameObjectId, count);
389  }
390  else
391  result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, id FROM gameobject WHERE id = '%u' LIMIT %u",
392  gameObjectId, count);
393 
394  if (result)
395  {
396  do
397  {
398  Field* fields = result->Fetch();
399  ObjectGuid::LowType guid = fields[0].GetUInt64();
400  float x = fields[1].GetFloat();
401  float y = fields[2].GetFloat();
402  float z = fields[3].GetFloat();
403  uint16 mapId = fields[4].GetUInt16();
404  uint32 entry = fields[5].GetUInt32();
405 
406  if (handler->GetSession())
407  handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name.c_str(), x, y, z, mapId);
408  else
409  handler->PSendSysMessage(LANG_GO_LIST_CONSOLE, guid, gInfo->name.c_str(), x, y, z, mapId);
410  }
411  while (result->NextRow());
412  }
413 
414  handler->PSendSysMessage(LANG_COMMAND_LISTOBJMESSAGE, gameObjectId, objectCount);
415 
416  return true;
417  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
uint64 GetUInt64() const
Definition: Field.h:184
float GetFloat() const
Definition: Field.h:222
QueryResult PQuery(Format &&sql, T *conn, Args &&...args)
Definition: DatabaseWorkerPool.h:165
Class used to access individual fields of database query result.
Definition: Field.h:56
Definition: GameObject.h:34
arena_t NULL
Definition: jemalloc_internal.h:624
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Definition: Language.h:441
Definition: Language.h:439
Player * GetPlayer() const
Definition: WorldSession.h:927
uint64 LowType
Definition: ObjectGuid.h:199
#define sObjectMgr
Definition: ObjectMgr.h:1567
unsigned long atoul(char const *str)
Definition: Common.h:90
G3D::int16 z
Definition: Vector3int16.h:46
Definition: Language.h:914
uint32_t uint32
Definition: Define.h:150
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
G3D::int16 y
Definition: Vector2int16.h:38
uint16_t uint16
Definition: Define.h:151
uint16 GetUInt16() const
Definition: Field.h:108
Definition: Language.h:530
std::string name
Definition: GameObject.h:39
uint32 GetUInt32() const
Definition: Field.h:146
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
G3D::int16 x
Definition: Vector2int16.h:37
char * extractKeyFromLink(char *text, char const *linkType, char **something1=NULL)
Definition: Chat.cpp:641

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


The documentation for this class was generated from the following file: