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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user