Core/DBLayer: Converted player login queries into prepared statements

Core/DBLayer: Added missing implementation for SQLQueryHolder::SetPreparedQuery

--HG--
branch : trunk
This commit is contained in:
Shauren
2010-09-20 18:20:40 +02:00
parent cd40ab6776
commit a509976369
23 changed files with 601 additions and 481 deletions
@@ -107,7 +107,7 @@ void Bag::SaveToDB(SQLTransaction& trans)
Item::SaveToDB(trans);
}
bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult result, uint32 entry)
bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, PreparedQueryResult result, uint32 entry)
{
if (!Item::LoadFromDB(guid, owner_guid, result, entry))
return false;
@@ -56,7 +56,7 @@ class Bag : public Item
// overwrite virtual Item::SaveToDB
void SaveToDB(SQLTransaction& trans);
// overwrite virtual Item::LoadFromDB
bool LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult result, uint32 entry);
bool LoadFromDB(uint32 guid, uint64 owner_guid, PreparedQueryResult result, uint32 entry);
// overwrite virtual Item::DeleteFromDB
void DeleteFromDB(SQLTransaction& trans);
+14 -15
View File
@@ -383,7 +383,7 @@ void Item::SaveToDB(SQLTransaction& trans)
SetState(ITEM_UNCHANGED);
}
bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult result, uint32 entry)
bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, PreparedQueryResult result, uint32 entry)
{
// 0 1 2 3 4 5 6 7 8 9 10
//result = CharacterDatabase.PQuery("SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text FROM item_instance WHERE guid = '%u'", guid);
@@ -410,13 +410,12 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult result, uint32
if (owner_guid != 0)
SetOwnerGUID(owner_guid);
Field *fields = result->Fetch();
bool need_save = false; // need explicit save data at load fixes
SetUInt64Value(ITEM_FIELD_CREATOR, MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER));
SetUInt64Value(ITEM_FIELD_GIFTCREATOR, MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER));
SetCount(fields[2].GetUInt32());
SetUInt64Value(ITEM_FIELD_CREATOR, MAKE_NEW_GUID(result->GetUInt32(0), 0, HIGHGUID_PLAYER));
SetUInt64Value(ITEM_FIELD_GIFTCREATOR, MAKE_NEW_GUID(result->GetUInt32(1), 0, HIGHGUID_PLAYER));
SetCount(result->GetUInt32(2));
uint32 duration = fields[3].GetUInt32();
uint32 duration = result->GetUInt32(3);
SetUInt32Value(ITEM_FIELD_DURATION, duration);
// update duration if need, and remove if not need
if ((proto->Duration == 0) != (duration == 0))
@@ -425,12 +424,12 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult result, uint32
need_save = true;
}
Tokens tokens = StrSplit(fields[4].GetCppString(), " ");
Tokens tokens = StrSplit(result->GetString(4), " ");
if (tokens.size() == MAX_ITEM_PROTO_SPELLS)
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
SetSpellCharges(i, atoi(tokens[i].c_str()));
SetUInt32Value(ITEM_FIELD_FLAGS, fields[5].GetUInt32());
SetUInt32Value(ITEM_FIELD_FLAGS, result->GetUInt32(5));
// Remove bind flag for items vs NO_BIND set
if (IsSoulBound() && proto->Bonding == NO_BIND)
{
@@ -438,13 +437,13 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult result, uint32
need_save = true;
}
_LoadIntoDataField(fields[6].GetString(), ITEM_FIELD_ENCHANTMENT_1_1, MAX_ENCHANTMENT_SLOT * MAX_ENCHANTMENT_OFFSET);
SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID, fields[7].GetInt32());
_LoadIntoDataField(result->GetCString(6), ITEM_FIELD_ENCHANTMENT_1_1, MAX_ENCHANTMENT_SLOT * MAX_ENCHANTMENT_OFFSET);
SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID, result->GetInt32(7));
// recalculate suffix factor
if (GetItemRandomPropertyId() < 0)
UpdateItemSuffixFactor();
uint32 durability = fields[8].GetUInt32();
uint32 durability = result->GetUInt32(8);
SetUInt32Value(ITEM_FIELD_DURABILITY, durability);
// update max durability (and durability) if need
SetUInt32Value(ITEM_FIELD_MAXDURABILITY, proto->MaxDurability);
@@ -454,8 +453,8 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult result, uint32
need_save = true;
}
SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, fields[9].GetUInt32());
SetText(fields[10].GetCppString());
SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, result->GetUInt32(9));
SetText(result->GetString(10));
if (need_save) // normal item changed state set not work at loading
{
@@ -473,12 +472,12 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult result, uint32
void Item::DeleteFromDB(SQLTransaction& trans)
{
trans->PAppend("DELETE FROM item_instance WHERE guid = '%u'",GetGUIDLow());
trans->PAppend("DELETE FROM item_instance WHERE guid = '%u'", GetGUIDLow());
}
void Item::DeleteFromInventoryDB(SQLTransaction& trans)
{
trans->PAppend("DELETE FROM character_inventory WHERE item = '%u'",GetGUIDLow());
trans->PAppend("DELETE FROM character_inventory WHERE item = '%u'", GetGUIDLow());
}
ItemPrototype const *Item::GetProto() const
+1 -1
View File
@@ -245,7 +245,7 @@ class Item : public Object
bool IsBindedNotWith(Player const* player) const;
bool IsBoundByEnchant() const;
virtual void SaveToDB(SQLTransaction& trans);
virtual bool LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult result, uint32 entry);
virtual bool LoadFromDB(uint32 guid, uint64 owner_guid, PreparedQueryResult result, uint32 entry);
virtual void DeleteFromDB(SQLTransaction& trans);
void DeleteFromInventoryDB(SQLTransaction& trans);
void SaveRefundDataToDB();
+28 -28
View File
@@ -150,40 +150,40 @@ enum ItemProtoFlags
enum ItemFieldFlags
{
ITEM_FLAG_SOULBOUND = 0x00000001, // Item is soulbound and cannot be traded
ITEM_FLAG_SOULBOUND = 0x00000001, // Item is soulbound and cannot be traded <<--
ITEM_FLAG_UNK1 = 0x00000002, // ?
ITEM_FLAG_UNLOCKED = 0x00000004, // Item had lock but can be opened now
ITEM_FLAG_WRAPPED = 0x00000008, // Item is wrapped and contains another item
ITEM_FLAG_UNK3 = 0x00000010, // ?
ITEM_FLAG_UNK4 = 0x00000020, // ?
ITEM_FLAG_UNK5 = 0x00000040, // ?
ITEM_FLAG_UNK6 = 0x00000080, // ?
ITEM_FLAG_UNK7 = 0x00000100, // ?
ITEM_FLAG_UNK2 = 0x00000010, // ?
ITEM_FLAG_UNK3 = 0x00000020, // ?
ITEM_FLAG_UNK4 = 0x00000040, // ?
ITEM_FLAG_UNK5 = 0x00000080, // ?
ITEM_FLAG_BOP_TRADEABLE = 0x00000100, // Allows trading soulbound items
ITEM_FLAG_READABLE = 0x00000200, // Opens text page when right clicked
ITEM_FLAG_UNK9 = 0x00000400, // ?
ITEM_FLAG_UNK10 = 0x00000800, // ?
ITEM_FLAG_UNK6 = 0x00000400, // ?
ITEM_FLAG_UNK7 = 0x00000800, // ?
ITEM_FLAG_REFUNDABLE = 0x00001000, // Item can be returned to vendor for its original cost (extended cost)
ITEM_FLAG_UNK11 = 0x00002000, // ?
ITEM_FLAG_UNK12 = 0x00004000, // ?
ITEM_FLAG_UNK13 = 0x00008000, // ?
ITEM_FLAG_UNK14 = 0x00010000, // ?
ITEM_FLAG_UNK15 = 0x00020000, // ?
ITEM_FLAG_UNK16 = 0x00040000, // ?
ITEM_FLAG_UNK17 = 0x00080000, // ?
ITEM_FLAG_UNK18 = 0x00100000, // ?
ITEM_FLAG_UNK19 = 0x00200000, // ?
ITEM_FLAG_UNK20 = 0x00400000, // ?
ITEM_FLAG_UNK21 = 0x00800000, // ?
ITEM_FLAG_UNK22 = 0x01000000, // ?
ITEM_FLAG_UNK23 = 0x02000000, // ?
ITEM_FLAG_UNK24 = 0x04000000, // ?
ITEM_FLAG_UNK25 = 0x08000000, // ?
ITEM_FLAG_UNK26 = 0x10000000, // ?
ITEM_FLAG_UNK27 = 0x20000000, // ?
ITEM_FLAG_UNK28 = 0x40000000, // ?
ITEM_FLAG_BOP_TRADEABLE = 0x80000000, // ?
ITEM_FLAG_UNK8 = 0x00002000, // ?
ITEM_FLAG_UNK9 = 0x00004000, // ?
ITEM_FLAG_UNK10 = 0x00008000, // ?
ITEM_FLAG_UNK11 = 0x00010000, // ?
ITEM_FLAG_UNK12 = 0x00020000, // ?
ITEM_FLAG_UNK13 = 0x00040000, // ?
ITEM_FLAG_UNK14 = 0x00080000, // ?
ITEM_FLAG_UNK15 = 0x00100000, // ?
ITEM_FLAG_UNK16 = 0x00200000, // ?
ITEM_FLAG_UNK17 = 0x00400000, // ?
ITEM_FLAG_UNK18 = 0x00800000, // ?
ITEM_FLAG_UNK19 = 0x01000000, // ?
ITEM_FLAG_UNK20 = 0x02000000, // ?
ITEM_FLAG_UNK21 = 0x04000000, // ?
ITEM_FLAG_UNK22 = 0x08000000, // ?
ITEM_FLAG_UNK23 = 0x10000000, // ?
ITEM_FLAG_UNK24 = 0x20000000, // ?
ITEM_FLAG_UNK25 = 0x40000000, // ?
ITEM_FLAG_UNK26 = 0x80000000, // ?
ITEM_FLAG_MAIL_TEXT_MASK = ITEM_FLAG_READABLE | ITEM_FLAG_UNK13 | ITEM_FLAG_UNK14
ITEM_FLAG_MAIL_TEXT_MASK = ITEM_FLAG_READABLE | ITEM_FLAG_UNK13 | ITEM_FLAG_UNK14,
};
enum ItemFlagsExtra