aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Chat/Commands
diff options
context:
space:
mode:
authorazazel <none@none>2010-12-15 14:08:12 +0600
committerazazel <none@none>2010-12-15 14:08:12 +0600
commitb39b8fdd0dd219b78cced60d746f2eb0d0cacdf7 (patch)
tree0448fb375ecd1ca73de28b0bf610d6a8078dce61 /src/server/game/Chat/Commands
parent58a9b15443aea65e78169b7078b3c00ae9004ac5 (diff)
DB Schema/Characters: removed columns auctionhouse.item_template, character_inventory.item_template, guild_bank_item.item_entry and mail_items.item_template and created item_instance.itemEntry column instead of them.
As a side effect moved related queries to prepared statements. As one more side effect fixed not shown and lost mail items in returned expired mail (patch by Quriq14). --HG-- branch : trunk
Diffstat (limited to 'src/server/game/Chat/Commands')
-rwxr-xr-xsrc/server/game/Chat/Commands/Level3.cpp89
1 files changed, 49 insertions, 40 deletions
diff --git a/src/server/game/Chat/Commands/Level3.cpp b/src/server/game/Chat/Commands/Level3.cpp
index d1cb5c98bc0..d765b9e2a17 100755
--- a/src/server/game/Chat/Commands/Level3.cpp
+++ b/src/server/game/Chat/Commands/Level3.cpp
@@ -419,15 +419,17 @@ bool ChatHandler::HandleListItemCommand(const char *args)
// inventory case
uint32 inv_count = 0;
- result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM character_inventory WHERE item_template='%u'",item_id);
+ result = CharacterDatabase.PQuery("SELECT COUNT(itemEntry) FROM character_inventory ci INNER JOIN item_instance ii ON ii.guid = ci.item WHERE itemEntry = '%u'", item_id);
if (result)
inv_count = (*result)[0].GetUInt32();
result=CharacterDatabase.PQuery(
- // 0 1 2 3 4 5
- "SELECT ci.item, cibag.slot AS bag, ci.slot, ci.guid, characters.account,characters.name "
- "FROM character_inventory AS ci LEFT JOIN character_inventory AS cibag ON (cibag.item=ci.bag),characters "
- "WHERE ci.item_template='%u' AND ci.guid = characters.guid LIMIT %u ",
+ // 0 1 2 3 4 5
+ "SELECT ci.item, cb.slot AS bag, ci.slot, ci.guid, c.account, c.name FROM characters c "
+ "INNER JOIN character_inventory ci ON ci.guid = c.guid "
+ "INNER JOIN item_instance ii ON ii.guid = ci.item "
+ "LEFT JOIN character_inventory cb ON cb.item = ci.bag "
+ "WHERE ii.itemEntry = '%u' LIMIT %u ",
item_id, count);
if (result)
@@ -443,40 +445,43 @@ bool ChatHandler::HandleListItemCommand(const char *args)
std::string owner_name = fields[5].GetString();
char const* item_pos = 0;
- if (Player::IsEquipmentPos(item_bag,item_slot))
+ if (Player::IsEquipmentPos(item_bag, item_slot))
item_pos = "[equipped]";
- else if (Player::IsInventoryPos(item_bag,item_slot))
+ else if (Player::IsInventoryPos(item_bag, item_slot))
item_pos = "[in inventory]";
- else if (Player::IsBankPos(item_bag,item_slot))
+ 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());
+ 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;
+ count -= res_count;
else if (count)
count = 0;
}
// mail case
uint32 mail_count = 0;
- result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM mail_items WHERE item_template='%u'", item_id);
+ result = CharacterDatabase.PQuery("SELECT COUNT(itemEntry) FROM mail_items mi INNER JOIN item_instance ii ON ii.guid = mi.item_guid WHERE itemEntry = '%u'", item_id);
if (result)
mail_count = (*result)[0].GetUInt32();
if (count > 0)
{
- result=CharacterDatabase.PQuery(
- // 0 1 2 3 4 5 6
- "SELECT mail_items.item_guid, mail.sender, mail.receiver, char_s.account, char_s.name, char_r.account, char_r.name "
- "FROM mail,mail_items,characters as char_s,characters as char_r "
- "WHERE mail_items.item_template='%u' AND char_s.guid = mail.sender AND char_r.guid = mail.receiver AND mail.id=mail_items.mail_id LIMIT %u",
+ result = CharacterDatabase.PQuery(
+ // 0 1 2 3 4 5 6
+ "SELECT mi.item_guid, m.sender, m.receiver, cs.account, cs.name, cr.account, cr.name FROM mail m "
+ "INNER JOIN mail_items mi ON mi.mail_id = m.id "
+ "INNER JOIN item_instance ii ON ii.guid = mi.item_guid "
+ "INNER JOIN characters cs ON cs.guid = m.sender "
+ "INNER JOIN characters cr ON cr.guid = m.receiver "
+ "WHERE ii.itemEntry = '%u' LIMIT %u",
item_id, count);
}
else
@@ -497,31 +502,32 @@ bool ChatHandler::HandleListItemCommand(const char *args)
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());
+ 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;
+ count -= res_count;
else if (count)
count = 0;
}
// auction case
uint32 auc_count = 0;
- result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM auctionhouse WHERE item_template='%u'",item_id);
+ result=CharacterDatabase.PQuery("SELECT COUNT(itemEntry) FROM auctionhouse ah INNER JOIN item_instance ii ON ii.guid = ah.itemguid WHERE itemEntry = '%u'",item_id);
if (result)
auc_count = (*result)[0].GetUInt32();
if (count > 0)
{
- result=CharacterDatabase.PQuery(
- // 0 1 2 3
- "SELECT auctionhouse.itemguid, auctionhouse.itemowner, characters.account, characters.name "
- "FROM auctionhouse,characters WHERE auctionhouse.item_template='%u' AND characters.guid = auctionhouse.itemowner LIMIT %u",
- item_id, count);
+ result = CharacterDatabase.PQuery(
+ // 0 1 2 3
+ "SELECT ah.itemguid, ah.itemowner, c.account, c.name FROM auctionhouse ah "
+ "INNER JOIN characters c ON c.guid = ah.itemowner "
+ "INNER JOIN item_instance ii ON ii.guid = ah.itemguid "
+ "WHERE ii.itemEntry = '%u' AND LIMIT %u", item_id, count);
}
else
result = QueryResult(NULL);
@@ -538,20 +544,23 @@ bool ChatHandler::HandleListItemCommand(const char *args)
char const* item_pos = "[in auction]";
- PSendSysMessage(LANG_ITEMLIST_AUCTION, item_guid, owner_name.c_str(), owner, owner_acc,item_pos);
- } while (result->NextRow());
+ 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;
- result=CharacterDatabase.PQuery("SELECT COUNT(item_entry) FROM guild_bank_item WHERE item_entry='%u'",item_id);
+ result = CharacterDatabase.PQuery("SELECT COUNT(itemEntry) FROM guild_bank_item gbi INNER JOIN item_instance ii ON ii.guid = gbi.item_guid WHERE itemEntry = '%u'", item_id);
if (result)
guild_count = (*result)[0].GetUInt32();
- result=CharacterDatabase.PQuery(
+ result = CharacterDatabase.PQuery(
// 0 1 2
- "SELECT gi.item_guid, gi.guildid, guild.name "
- "FROM guild_bank_item AS gi, guild WHERE gi.item_entry='%u' AND gi.guildid = guild.guildid LIMIT %u ",
+ "SELECT gi.item_guid, gi.guildid, g.name FROM guild_bank_item gi "
+ "INNER JOIN guild g ON g.guildid = gi.guildid "
+ "INNER JOIN item_instance ii ON ii.guid = gi.item_guid "
+ "WHERE ii.itemEntry = '%u' LIMIT %u ",
item_id, count);
if (result)
@@ -565,26 +574,26 @@ bool ChatHandler::HandleListItemCommand(const char *args)
char const* item_pos = "[in guild bank]";
- PSendSysMessage(LANG_ITEMLIST_GUILD,item_guid,guild_name.c_str(),guild_guid,item_pos);
- } while (result->NextRow());
+ 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;
+ count -= res_count;
else if (count)
count = 0;
}
- if (inv_count+mail_count+auc_count+guild_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);
-
+ PSendSysMessage(LANG_COMMAND_LISTITEMMESSAGE, item_id, inv_count + mail_count + auc_count + guild_count, inv_count, mail_count, auc_count, guild_count);
return true;
}