aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/Achievements/AchievementMgr.cpp16
-rw-r--r--src/server/game/Achievements/AchievementMgr.h2
-rw-r--r--src/server/game/AuctionHouse/AuctionHouseMgr.cpp10
-rw-r--r--src/server/game/Entities/Item/Container/Bag.cpp2
-rw-r--r--src/server/game/Entities/Item/Container/Bag.h2
-rw-r--r--src/server/game/Entities/Item/Item.cpp29
-rw-r--r--src/server/game/Entities/Item/Item.h2
-rw-r--r--src/server/game/Entities/Item/ItemPrototype.h58
-rw-r--r--src/server/game/Entities/Player/Player.cpp557
-rw-r--r--src/server/game/Entities/Player/Player.h54
-rw-r--r--src/server/game/Entities/Player/SocialMgr.cpp14
-rw-r--r--src/server/game/Entities/Player/SocialMgr.h2
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp29
-rw-r--r--src/server/game/Globals/ObjectMgr.h2
-rw-r--r--src/server/game/Reputation/ReputationMgr.cpp12
-rw-r--r--src/server/game/Reputation/ReputationMgr.h2
-rw-r--r--src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp172
-rw-r--r--src/server/game/Server/Protocol/Handlers/MiscHandler.cpp2
-rw-r--r--src/server/game/Server/WorldSession.cpp17
-rw-r--r--src/server/game/Server/WorldSession.h2
-rw-r--r--src/server/shared/Database/Implementation/CharacterDatabase.cpp44
-rw-r--r--src/server/shared/Database/Implementation/CharacterDatabase.h34
-rw-r--r--src/server/shared/Database/QueryHolder.cpp20
23 files changed, 602 insertions, 482 deletions
diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp
index d0a5145f4fa..5231bb6e34a 100644
--- a/src/server/game/Achievements/AchievementMgr.cpp
+++ b/src/server/game/Achievements/AchievementMgr.cpp
@@ -555,22 +555,20 @@ void AchievementMgr::SaveToDB(SQLTransaction& trans)
}
}
-void AchievementMgr::LoadFromDB(QueryResult achievementResult, QueryResult criteriaResult)
+void AchievementMgr::LoadFromDB(PreparedQueryResult achievementResult, PreparedQueryResult criteriaResult)
{
if (achievementResult)
{
do
{
- Field *fields = achievementResult->Fetch();
-
- uint32 achievement_id = fields[0].GetUInt32();
+ uint32 achievement_id = achievementResult->GetUInt32(0);
// don't must happen: cleanup at server startup in sAchievementMgr.LoadCompletedAchievements()
if (!sAchievementStore.LookupEntry(achievement_id))
continue;
CompletedAchievementData& ca = m_completedAchievements[achievement_id];
- ca.date = time_t(fields[1].GetUInt64());
+ ca.date = time_t(achievementResult->GetUInt64(1));
ca.changed = false;
} while (achievementResult->NextRow());
}
@@ -579,11 +577,9 @@ void AchievementMgr::LoadFromDB(QueryResult achievementResult, QueryResult crite
{
do
{
- Field *fields = criteriaResult->Fetch();
-
- uint32 id = fields[0].GetUInt32();
- uint32 counter = fields[1].GetUInt32();
- time_t date = time_t(fields[2].GetUInt64());
+ uint32 id = criteriaResult->GetUInt32(0);
+ uint32 counter = criteriaResult->GetUInt32(1);
+ time_t date = time_t(criteriaResult->GetUInt64(2));
AchievementCriteriaEntry const* criteria = sAchievementCriteriaStore.LookupEntry(id);
if (!criteria)
diff --git a/src/server/game/Achievements/AchievementMgr.h b/src/server/game/Achievements/AchievementMgr.h
index 71191553141..e7246a8f977 100644
--- a/src/server/game/Achievements/AchievementMgr.h
+++ b/src/server/game/Achievements/AchievementMgr.h
@@ -243,7 +243,7 @@ class AchievementMgr
void Reset();
static void DeleteFromDB(uint32 lowguid);
- void LoadFromDB(QueryResult achievementResult, QueryResult criteriaResult);
+ void LoadFromDB(PreparedQueryResult achievementResult, PreparedQueryResult criteriaResult);
void SaveToDB(SQLTransaction& trans);
void ResetAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1 = 0, uint32 miscvalue2 = 0, bool evenIfCriteriaComplete = false);
void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1 = 0, uint32 miscvalue2 = 0, Unit *unit = NULL, uint32 time = 0);
diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
index 31fbf2dc73f..5c027e7b00b 100644
--- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
+++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
@@ -305,8 +305,8 @@ void AuctionHouseMgr::SendAuctionCancelledToBidderMail(AuctionEntry* auction, SQ
void AuctionHouseMgr::LoadAuctionItems()
{
// data needs to be at first place for Item::LoadFromDB
- // 0 1 2 3 4 5 6 7 8 9 10 11 12
- QueryResult result = CharacterDatabase.Query("SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text, itemguid, item_template FROM auctionhouse JOIN item_instance ON itemguid = guid");
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_AUCTION_ITEMS);
+ PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (!result)
{
@@ -321,14 +321,12 @@ void AuctionHouseMgr::LoadAuctionItems()
uint32 count = 0;
- Field *fields;
do
{
bar.step();
- fields = result->Fetch();
- uint32 item_guid = fields[11].GetUInt32();
- uint32 item_template = fields[12].GetUInt32();
+ uint32 item_guid = result->GetUInt32(11);
+ uint32 item_template = result->GetUInt32(12);
ItemPrototype const *proto = sObjectMgr.GetItemPrototype(item_template);
diff --git a/src/server/game/Entities/Item/Container/Bag.cpp b/src/server/game/Entities/Item/Container/Bag.cpp
index 85b1a14c934..c92d9681f85 100644
--- a/src/server/game/Entities/Item/Container/Bag.cpp
+++ b/src/server/game/Entities/Item/Container/Bag.cpp
@@ -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;
diff --git a/src/server/game/Entities/Item/Container/Bag.h b/src/server/game/Entities/Item/Container/Bag.h
index d9af3c10708..5192e617696 100644
--- a/src/server/game/Entities/Item/Container/Bag.h
+++ b/src/server/game/Entities/Item/Container/Bag.h
@@ -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);
diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp
index c18c7187db6..ffb830bf709 100644
--- a/src/server/game/Entities/Item/Item.cpp
+++ b/src/server/game/Entities/Item/Item.cpp
@@ -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
diff --git a/src/server/game/Entities/Item/Item.h b/src/server/game/Entities/Item/Item.h
index 3f6f6b58699..d238a23a96c 100644
--- a/src/server/game/Entities/Item/Item.h
+++ b/src/server/game/Entities/Item/Item.h
@@ -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();
diff --git a/src/server/game/Entities/Item/ItemPrototype.h b/src/server/game/Entities/Item/ItemPrototype.h
index b9563e153cc..6b97432dd96 100644
--- a/src/server/game/Entities/Item/ItemPrototype.h
+++ b/src/server/game/Entities/Item/ItemPrototype.h
@@ -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_MAIL_TEXT_MASK = ITEM_FLAG_READABLE | ITEM_FLAG_UNK13 | ITEM_FLAG_UNK14
+ 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,
};
enum ItemFlagsExtra
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 0b972f0f469..6413f82486d 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -3925,7 +3925,7 @@ void Player::RemoveAllSpellCooldown()
}
}
-void Player::_LoadSpellCooldowns(QueryResult result)
+void Player::_LoadSpellCooldowns(PreparedQueryResult result)
{
// some cooldowns can be already set at aura loading...
@@ -3937,11 +3937,9 @@ void Player::_LoadSpellCooldowns(QueryResult result)
do
{
- Field *fields = result->Fetch();
-
- uint32 spell_id = fields[0].GetUInt32();
- uint32 item_id = fields[1].GetUInt32();
- time_t db_time = (time_t)fields[2].GetUInt64();
+ uint32 spell_id = result->GetUInt32(0);
+ uint32 item_id = result->GetUInt32(1);
+ time_t db_time = (time_t)result->GetUInt64(2);
if (!sSpellStore.LookupEntry(spell_id))
{
@@ -4492,15 +4490,15 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
if (has_items)
{
// Data needs to be at first place for Item::LoadFromDB
- QueryResult resultItems = CharacterDatabase.PQuery("SELECT creatorGuid,giftCreatorGuid,count,duration,charges,flags,enchantments,randomPropertyId,durability,playedTime,text,item_guid,item_template FROM mail_items JOIN item_instance ON item_guid = guid WHERE mail_id='%u'", mail_id);
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_MAILITEMS);
+ stmt->setUInt32(0, mail_id);
+ PreparedQueryResult resultItems = CharacterDatabase.Query(stmt);
if (resultItems)
{
do
{
- Field *fields2 = resultItems->Fetch();
-
- uint32 item_guidlow = fields2[11].GetUInt32();
- uint32 item_template = fields2[12].GetUInt32();
+ uint32 item_guidlow = resultItems->GetUInt32(11);
+ uint32 item_template = resultItems->GetUInt32(12);
ItemPrototype const* itemProto = sObjectMgr.GetItemPrototype(item_template);
if (!itemProto)
@@ -6214,7 +6212,7 @@ int16 Player::GetSkillTempBonusValue(uint32 skill) const
if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
return 0;
-return SKILL_TEMP_BONUS(GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos)));
+ return SKILL_TEMP_BONUS(GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos)));
}
void Player::SendActionButtons(uint32 state) const
@@ -6233,8 +6231,8 @@ void Player::SendActionButtons(uint32 state) const
{
for (uint8 button = 0; button < MAX_ACTION_BUTTONS; ++button)
{
- ActionButtonList::const_iterator itr = m_actionButtons.find(button);
- if (itr != m_actionButtons.end() && itr->second.uState != ACTIONBUTTON_DELETED)
+ ActionButtonList::const_iterator itr = m_actionButtons[m_activeSpec].find(button);
+ if (itr != m_actionButtons[m_activeSpec].end() && itr->second.uState != ACTIONBUTTON_DELETED)
data << uint32(itr->second.packedData);
else
data << uint32(0);
@@ -6288,13 +6286,13 @@ bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type)
return true;
}
-ActionButton* Player::addActionButton(uint8 button, uint32 action, uint8 type)
+ActionButton* Player::addActionButton(uint8 button, uint32 action, uint8 type, uint8 spec /*= 0*/)
{
if (!IsActionButtonDataValid(button, action, type))
return NULL;
// it create new button (NEW state) if need or return existed
- ActionButton& ab = m_actionButtons[button];
+ ActionButton& ab = m_actionButtons[spec][button];
// set data and update to CHANGED if not NEW
ab.SetActionAndType(action,ActionButtonType(type));
@@ -6305,12 +6303,12 @@ ActionButton* Player::addActionButton(uint8 button, uint32 action, uint8 type)
void Player::removeActionButton(uint8 button)
{
- ActionButtonList::iterator buttonItr = m_actionButtons.find(button);
- if (buttonItr == m_actionButtons.end() || buttonItr->second.uState == ACTIONBUTTON_DELETED)
+ ActionButtonList::iterator buttonItr = m_actionButtons[m_activeSpec].find(button);
+ if (buttonItr == m_actionButtons[m_activeSpec].end() || buttonItr->second.uState == ACTIONBUTTON_DELETED)
return;
if (buttonItr->second.uState == ACTIONBUTTON_NEW)
- m_actionButtons.erase(buttonItr); // new and not saved
+ m_actionButtons[m_activeSpec].erase(buttonItr); // new and not saved
else
buttonItr->second.uState = ACTIONBUTTON_DELETED; // saved, will deleted at next save
@@ -6319,8 +6317,8 @@ void Player::removeActionButton(uint8 button)
ActionButton const* Player::GetActionButton(uint8 button)
{
- ActionButtonList::iterator buttonItr = m_actionButtons.find(button);
- if (buttonItr == m_actionButtons.end() || buttonItr->second.uState == ACTIONBUTTON_DELETED)
+ ActionButtonList::iterator buttonItr = m_actionButtons[m_activeSpec].find(button);
+ if (buttonItr == m_actionButtons[m_activeSpec].end() || buttonItr->second.uState == ACTIONBUTTON_DELETED)
return NULL;
return &buttonItr->second;
@@ -15683,33 +15681,30 @@ void Player::Initialize(uint32 guid)
Object::_Create(guid, 0, HIGHGUID_PLAYER);
}
-void Player::_LoadDeclinedNames(QueryResult result)
+void Player::_LoadDeclinedNames(PreparedQueryResult result)
{
if (!result)
return;
delete m_declinedname;
m_declinedname = new DeclinedName;
- Field *fields = result->Fetch();
for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
- m_declinedname->name[i] = fields[i].GetCppString();
+ m_declinedname->name[i] = result->GetString(i);
}
-void Player::_LoadArenaTeamInfo(QueryResult result)
+void Player::_LoadArenaTeamInfo(PreparedQueryResult result)
{
- // arenateamid, played_week, played_season, personal_rating, matchmaker_rating
+ // arenateamid, played_week, played_season, personal_rating
memset((void*)&m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1], 0, sizeof(uint32) * MAX_ARENA_SLOT * ARENA_TEAM_END);
if (!result)
return;
do
{
- Field *fields = result->Fetch();
-
- uint32 arenateamid = fields[0].GetUInt32();
- uint32 played_week = fields[1].GetUInt32();
- uint32 played_season = fields[2].GetUInt32();
- uint32 wons_season = fields[3].GetUInt32();
+ uint32 arenateamid = result->GetUInt32(0);
+ uint32 played_week = result->GetUInt32(1);
+ uint32 played_season = result->GetUInt32(2);
+ uint32 wons_season = result->GetUInt32(3);
ArenaTeam* aTeam = sObjectMgr.GetArenaTeamById(arenateamid);
if (!aTeam)
@@ -15717,6 +15712,7 @@ void Player::_LoadArenaTeamInfo(QueryResult result)
sLog.outError("Player::_LoadArenaTeamInfo: couldn't load arenateam %u", arenateamid);
continue;
}
+
uint8 arenaSlot = aTeam->GetSlot();
SetArenaTeamInfoField(arenaSlot, ARENA_TEAM_ID, arenateamid);
@@ -15725,10 +15721,10 @@ void Player::_LoadArenaTeamInfo(QueryResult result)
SetArenaTeamInfoField(arenaSlot, ARENA_TEAM_GAMES_WEEK, played_week);
SetArenaTeamInfoField(arenaSlot, ARENA_TEAM_GAMES_SEASON, played_season);
SetArenaTeamInfoField(arenaSlot, ARENA_TEAM_WINS_SEASON, wons_season);
- }while (result->NextRow());
+ } while (result->NextRow());
}
-void Player::_LoadArenaStatsInfo(QueryResult result)
+void Player::_LoadArenaStatsInfo(PreparedQueryResult result)
{
uint8 slot = 0;
if (!result)
@@ -15741,13 +15737,11 @@ void Player::_LoadArenaStatsInfo(QueryResult result)
return;
}
- bool nextrow = true;
do
{
- Field *fields = result->Fetch();
uint32 personalrating = 0;
uint32 matchmakerrating = 1500;
- if (fields[0].GetUInt8() > slot)
+ if (result->GetUInt8(0) > slot)
{
CharacterDatabase.PExecute("INSERT INTO character_arena_stats (guid, slot, personal_rating, matchmaker_rating) VALUES (%u, %u, %u, %u)", GetGUIDLow(), slot, personalrating, matchmakerrating);
SetArenaTeamInfoField(slot, ARENA_TEAM_PERSONAL_RATING, personalrating);
@@ -15755,15 +15749,14 @@ void Player::_LoadArenaStatsInfo(QueryResult result)
continue;
}
- personalrating = fields[1].GetUInt32();
- matchmakerrating = fields[2].GetUInt32();
+ personalrating = result->GetUInt32(1);
+ matchmakerrating = result->GetUInt32(2);
SetArenaTeamInfoField(slot, ARENA_TEAM_PERSONAL_RATING, personalrating);
slot++;
- nextrow = result->NextRow();
- }while (nextrow);
+ } while (result->NextRow());
}
-void Player::_LoadEquipmentSets(QueryResult result)
+void Player::_LoadEquipmentSets(PreparedQueryResult result)
{
// SetPQuery(PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS, "SELECT setguid, setindex, name, iconname, item0, item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12, item13, item14, item15, item16, item17, item18 FROM character_equipmentsets WHERE guid = '%u' ORDER BY setindex", GUID_LOPART(m_guid));
if (!result)
@@ -15772,18 +15765,16 @@ void Player::_LoadEquipmentSets(QueryResult result)
uint32 count = 0;
do
{
- Field *fields = result->Fetch();
-
EquipmentSet eqSet;
- eqSet.Guid = fields[0].GetUInt64();
- uint32 index = fields[1].GetUInt32();
- eqSet.Name = fields[2].GetCppString();
- eqSet.IconName = fields[3].GetCppString();
+ eqSet.Guid = result->GetUInt64(0);
+ uint32 index = result->GetUInt32(1);
+ eqSet.Name = result->GetString(2);
+ eqSet.IconName = result->GetString(3);
eqSet.state = EQUIPMENT_SET_UNCHANGED;
for (uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i)
- eqSet.Items[i] = fields[4+i].GetUInt32();
+ eqSet.Items[i] = result->GetUInt32(4+i);
m_EquipmentSets[index] = eqSet;
@@ -15794,24 +15785,23 @@ void Player::_LoadEquipmentSets(QueryResult result)
} while (result->NextRow());
}
-void Player::_LoadBGData(QueryResult result)
+void Player::_LoadBGData(PreparedQueryResult result)
{
if (!result)
return;
// Expecting only one row
- Field *fields = result->Fetch();
/* bgInstanceID, bgTeam, x, y, z, o, map, taxi[0], taxi[1], mountSpell */
- m_bgData.bgInstanceID = fields[0].GetUInt32();
- m_bgData.bgTeam = fields[1].GetUInt32();
- m_bgData.joinPos = WorldLocation(fields[6].GetUInt32(), // Map
- fields[2].GetFloat(), // X
- fields[3].GetFloat(), // Y
- fields[4].GetFloat(), // Z
- fields[5].GetFloat()); // Orientation
- m_bgData.taxiPath[0] = fields[7].GetUInt32();
- m_bgData.taxiPath[1] = fields[8].GetUInt32();
- m_bgData.mountSpell = fields[9].GetUInt32();
+ m_bgData.bgInstanceID = result->GetUInt32(0);
+ m_bgData.bgTeam = result->GetUInt32(1);
+ m_bgData.joinPos = WorldLocation(result->GetUInt32(6), // Map
+ result->GetFloat(2), // X
+ result->GetFloat(3), // Y
+ result->GetFloat(4), // Z
+ result->GetFloat(5)); // Orientation
+ m_bgData.taxiPath[0] = result->GetUInt32(7);
+ m_bgData.taxiPath[1] = result->GetUInt32(8);
+ m_bgData.mountSpell = result->GetUInt32(9);
}
bool Player::LoadPositionFromDB(uint32& mapid, float& x,float& y,float& z,float& o, bool& in_flight, uint64 guid)
@@ -15874,7 +15864,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
//"arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk,"
// 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
//"health, power1, power2, power3, power4, power5, power6, power7, instance_id, speccount, activespec, exploredZones, equipmentCache, ammoId, knownTitles, actionBars FROM characters WHERE guid = '%u'", guid);
- QueryResult result = holder->GetResult(PLAYER_LOGIN_QUERY_LOADFROM);
+ PreparedQueryResult result = holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADFROM);
if (!result)
{
@@ -15882,9 +15872,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
return false;
}
- Field *fields = result->Fetch();
-
- uint32 dbAccountId = fields[1].GetUInt32();
+ uint32 dbAccountId = result->GetUInt32(1);
// check if the character's account in the db and the logged in account match.
// player should be able to load/delete character only with correct account!
@@ -15894,7 +15882,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
return false;
}
- if (holder->GetResult(PLAYER_LOGIN_QUERY_LOADBANNED))
+ if (holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADBANNED))
{
sLog.outError("Player (GUID: %u) is banned, can't load.", guid);
return false;
@@ -15902,7 +15890,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
Object::_Create(guid, 0, HIGHGUID_PLAYER);
- m_name = fields[2].GetCppString();
+ m_name = result->GetString(2);
// check name limitations
if (ObjectMgr::CheckPlayerName(m_name) != CHAR_NAME_SUCCESS ||
@@ -15917,38 +15905,38 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
// overwrite some data fields
uint32 bytes0 = 0;
- bytes0 |= fields[3].GetUInt8(); // race
- bytes0 |= fields[4].GetUInt8() << 8; // class
- bytes0 |= fields[5].GetUInt8() << 16; // gender
+ bytes0 |= result->GetUInt8(3); // race
+ bytes0 |= result->GetUInt8(4) << 8; // class
+ bytes0 |= result->GetUInt8(5) << 16; // gender
SetUInt32Value(UNIT_FIELD_BYTES_0, bytes0);
- SetUInt32Value(UNIT_FIELD_LEVEL, fields[6].GetUInt8());
- SetUInt32Value(PLAYER_XP, fields[7].GetUInt32());
+ SetUInt32Value(UNIT_FIELD_LEVEL, result->GetUInt8(6));
+ SetUInt32Value(PLAYER_XP, result->GetUInt32(7));
- _LoadIntoDataField(fields[61].GetString(), PLAYER_EXPLORED_ZONES_1, PLAYER_EXPLORED_ZONES_SIZE);
- _LoadIntoDataField(fields[64].GetString(), PLAYER__FIELD_KNOWN_TITLES, KNOWN_TITLES_SIZE*2);
+ _LoadIntoDataField(result->GetCString(61), PLAYER_EXPLORED_ZONES_1, PLAYER_EXPLORED_ZONES_SIZE);
+ _LoadIntoDataField(result->GetCString(64), PLAYER__FIELD_KNOWN_TITLES, KNOWN_TITLES_SIZE*2);
SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE);
SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f);
SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f);
- uint32 money = fields[8].GetUInt32();
+ uint32 money = result->GetUInt32(8);
if (money > MAX_MONEY_AMOUNT)
money = MAX_MONEY_AMOUNT;
SetMoney(money);
- SetUInt32Value(PLAYER_BYTES, fields[9].GetUInt32());
- SetUInt32Value(PLAYER_BYTES_2, fields[10].GetUInt32());
- SetUInt32Value(PLAYER_BYTES_3, (fields[49].GetUInt16() & 0xFFFE) | fields[5].GetUInt8());
- SetUInt32Value(PLAYER_FLAGS, fields[11].GetUInt32());
- SetInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, fields[48].GetUInt32());
+ SetUInt32Value(PLAYER_BYTES, result->GetUInt32(9));
+ SetUInt32Value(PLAYER_BYTES_2, result->GetUInt32(10));
+ SetUInt32Value(PLAYER_BYTES_3, (result->GetUInt16(49) & 0xFFFE) | result->GetUInt8(5));
+ SetUInt32Value(PLAYER_FLAGS, result->GetUInt32(11));
+ SetInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, result->GetUInt32(48));
- SetUInt64Value(PLAYER_FIELD_KNOWN_CURRENCIES, fields[47].GetUInt64());
+ SetUInt64Value(PLAYER_FIELD_KNOWN_CURRENCIES, result->GetUInt64(47));
- SetUInt32Value(PLAYER_AMMO_ID, fields[63].GetUInt32());
+ SetUInt32Value(PLAYER_AMMO_ID, result->GetUInt32(63));
// set which actionbars the client has active - DO NOT REMOVE EVER AGAIN (can be changed though, if it does change fieldwise)
- SetByteValue(PLAYER_FIELD_BYTES, 2, fields[65].GetUInt8());
+ SetByteValue(PLAYER_FIELD_BYTES, 2, result->GetUInt8(65));
InitDisplayIds();
@@ -15970,36 +15958,36 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
setFactionForRace(getRace());
// load home bind and check in same time class/race pair, it used later for restore broken positions
- if (!_LoadHomeBind(holder->GetResult(PLAYER_LOGIN_QUERY_LOADHOMEBIND)))
+ if (!_LoadHomeBind(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADHOMEBIND)))
return false;
InitPrimaryProfessions(); // to max set before any spell loaded
// init saved position, and fix it later if problematic
- uint32 transGUID = fields[30].GetUInt32();
- Relocate(fields[12].GetFloat(),fields[13].GetFloat(),fields[14].GetFloat(),fields[16].GetFloat());
- uint32 mapId = fields[15].GetUInt32();
- uint32 instanceId = fields[58].GetUInt32();
+ uint32 transGUID = uint32(result->GetUInt64(30)); // field type is uint64 but lowguid is saved
+ Relocate(result->GetFloat(12), result->GetFloat(13), result->GetFloat(14), result->GetFloat(16));
+ uint32 mapId = result->GetUInt32(15);
+ uint32 instanceId = result->GetUInt8(58);
- uint32 dungeonDiff = fields[38].GetUInt32() & 0x0F;
+ uint32 dungeonDiff = result->GetUInt32(38) & 0x0F;
if (dungeonDiff >= MAX_DUNGEON_DIFFICULTY)
dungeonDiff = DUNGEON_DIFFICULTY_NORMAL;
- uint32 raidDiff = (fields[38].GetUInt32() >> 4) & 0x0F;
+ uint32 raidDiff = (result->GetUInt8(38) >> 4) & 0x0F;
if (raidDiff >= MAX_RAID_DIFFICULTY)
raidDiff = RAID_DIFFICULTY_10MAN_NORMAL;
SetDungeonDifficulty(Difficulty(dungeonDiff)); // may be changed in _LoadGroup
SetRaidDifficulty(Difficulty(raidDiff)); // may be changed in _LoadGroup
- std::string taxi_nodes = fields[37].GetCppString();
+ std::string taxi_nodes = result->GetString(37);
#define RelocateToHomebind(){ mapId = m_homebindMapId; instanceId = 0; Relocate(m_homebindX, m_homebindY, m_homebindZ); }
- _LoadGroup(holder->GetResult(PLAYER_LOGIN_QUERY_LOADGROUP));
+ _LoadGroup(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADGROUP));
- _LoadArenaTeamInfo(holder->GetResult(PLAYER_LOGIN_QUERY_LOADARENAINFO));
- _LoadArenaStatsInfo(holder->GetResult(PLAYER_LOGIN_QUERY_LOADARENASTATS));
+ _LoadArenaTeamInfo(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADARENAINFO));
+ _LoadArenaStatsInfo(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADARENASTATS));
- uint32 arena_currency = fields[39].GetUInt32();
+ uint32 arena_currency = result->GetUInt32(39);
if (arena_currency > sWorld.getIntConfig(CONFIG_MAX_ARENA_POINTS))
arena_currency = sWorld.getIntConfig(CONFIG_MAX_ARENA_POINTS);
@@ -16021,15 +16009,15 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
SetArenaTeamInfoField(arena_slot, ArenaTeamInfoType(j), 0);
}
- SetHonorPoints(fields[40].GetUInt32());
- SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, fields[41].GetUInt32());
- SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, fields[42].GetUInt32());
- SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, fields[43].GetUInt32());
- SetUInt16Value(PLAYER_FIELD_KILLS, 0, fields[44].GetUInt16());
- SetUInt16Value(PLAYER_FIELD_KILLS, 1, fields[45].GetUInt16());
+ SetHonorPoints(result->GetUInt32(40));
+ SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, result->GetUInt32(41));
+ SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, result->GetUInt32(42));
+ SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, result->GetUInt32(43));
+ SetUInt16Value(PLAYER_FIELD_KILLS, 0, result->GetUInt16(44));
+ SetUInt16Value(PLAYER_FIELD_KILLS, 1, result->GetUInt16(45));
- _LoadBoundInstances(holder->GetResult(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES));
- _LoadBGData(holder->GetResult(PLAYER_LOGIN_QUERY_LOADBGDATA));
+ _LoadBoundInstances(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES));
+ _LoadBGData(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADBGDATA));
MapEntry const * mapEntry = sMapStore.LookupEntry(mapId);
if (!mapEntry || !IsPositionValid())
@@ -16086,7 +16074,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
else if (transGUID)
{
m_movementInfo.t_guid = MAKE_NEW_GUID(transGUID, 0, HIGHGUID_MO_TRANSPORT);
- m_movementInfo.t_pos.Relocate(fields[26].GetFloat(), fields[27].GetFloat(), fields[28].GetFloat(), fields[29].GetFloat());
+ m_movementInfo.t_pos.Relocate(result->GetFloat(26), result->GetFloat(27), result->GetFloat(28), result->GetFloat(29));
if (!Trinity::IsValidMapCoord(
GetPositionX()+m_movementInfo.t_pos.m_positionX,GetPositionY()+m_movementInfo.t_pos.m_positionY,
@@ -16245,7 +16233,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
SaveRecallPosition();
time_t now = time(NULL);
- time_t logoutTime = time_t(fields[22].GetUInt64());
+ time_t logoutTime = time_t(result->GetUInt64(22));
// since last logout (in seconds)
uint32 time_diff = uint32(now - logoutTime); //uint64 is excessive for a time_diff in seconds.. uint32 allows for 136~ year difference.
@@ -16260,12 +16248,12 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
uint16 newDrunkenValue = uint16(soberFactor*(GetUInt32Value(PLAYER_BYTES_3) & 0xFFFE));
SetDrunkValue(newDrunkenValue);
- m_cinematic = fields[18].GetUInt32();
- m_Played_time[PLAYED_TIME_TOTAL]= fields[19].GetUInt32();
- m_Played_time[PLAYED_TIME_LEVEL]= fields[20].GetUInt32();
+ m_cinematic = result->GetUInt8(18);
+ m_Played_time[PLAYED_TIME_TOTAL]= result->GetUInt32(19);
+ m_Played_time[PLAYED_TIME_LEVEL]= result->GetUInt32(20);
- m_resetTalentsCost = fields[24].GetUInt32();
- m_resetTalentsTime = time_t(fields[25].GetUInt64());
+ m_resetTalentsCost = result->GetUInt32(24);
+ m_resetTalentsTime = time_t(result->GetUInt64(25));
// reserve some flags
uint32 old_safe_flags = GetUInt32Value(PLAYER_FLAGS) & (PLAYER_FLAGS_HIDE_CLOAK | PLAYER_FLAGS_HIDE_HELM);
@@ -16273,25 +16261,25 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM))
SetUInt32Value(PLAYER_FLAGS, 0 | old_safe_flags);
- m_taxi.LoadTaxiMask(fields[17].GetString()); // must be before InitTaxiNodesForLevel
+ m_taxi.LoadTaxiMask(result->GetCString(17)); // must be before InitTaxiNodesForLevel
- uint32 extraflags = fields[31].GetUInt32();
+ uint32 extraflags = result->GetUInt32(31);
- m_stableSlots = fields[32].GetUInt32();
+ m_stableSlots = result->GetUInt8(32);
if (m_stableSlots > MAX_PET_STABLES)
{
sLog.outError("Player can have not more %u stable slots, but have in DB %u",MAX_PET_STABLES,uint32(m_stableSlots));
m_stableSlots = MAX_PET_STABLES;
}
- m_atLoginFlags = fields[33].GetUInt32();
+ m_atLoginFlags = result->GetUInt32(33);
// Honor system
// Update Honor kills data
m_lastHonorUpdateTime = logoutTime;
UpdateHonorFields();
- m_deathExpireTime = (time_t)fields[36].GetUInt64();
+ m_deathExpireTime = (time_t)result->GetUInt64(36);
if (m_deathExpireTime > now+MAX_DEATH_COUNT*DEATH_EXPIRE_STEP)
m_deathExpireTime = now+MAX_DEATH_COUNT*DEATH_EXPIRE_STEP-1;
@@ -16327,7 +16315,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
InitRunes();
// rest bonus can only be calculated after InitStatsForLevel()
- m_rest_bonus = fields[21].GetFloat();
+ m_rest_bonus = result->GetFloat(21);
if (time_diff > 0)
{
@@ -16335,7 +16323,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
float bubble0 = 0.031f;
//speed collect rest bonus in offline, in logout, in tavern, city (section/in hour)
float bubble1 = 0.125f;
- float bubble = fields[23].GetUInt32() > 0
+ float bubble = result->GetUInt32(23) > 0
? bubble1*sWorld.getRate(RATE_REST_OFFLINE_IN_TAVERN_OR_CITY)
: bubble0*sWorld.getRate(RATE_REST_OFFLINE_IN_WILDERNESS);
@@ -16343,16 +16331,16 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
}
// load skills after InitStatsForLevel because it triggering aura apply also
- _LoadSkills(holder->GetResult(PLAYER_LOGIN_QUERY_LOADSKILLS));
- UpdateSkillsForLevel (); //update skills after load, to make sure they are correctly update at player load
+ _LoadSkills(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADSKILLS));
+ UpdateSkillsForLevel(); //update skills after load, to make sure they are correctly update at player load
// apply original stats mods before spell loading or item equipment that call before equip _RemoveStatsMods()
//mails are loaded only when needed ;-) - when player in game click on mailbox.
//_LoadMail();
- m_specsCount = fields[59].GetUInt8();
- m_activeSpec = fields[60].GetUInt8();
+ m_specsCount = result->GetUInt8(59);
+ m_activeSpec = result->GetUInt8(60);
// sanity check
if (m_specsCount > MAX_TALENT_SPECS || m_activeSpec > MAX_TALENT_SPEC ||
@@ -16362,44 +16350,44 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
sLog.outError("Player %s(GUID: %u) has SpecCount = %u and ActiveSpec = %u.", GetName(), GetGUIDLow(), m_specsCount, m_activeSpec);
}
- _LoadTalents(holder->GetResult(PLAYER_LOGIN_QUERY_LOADTALENTS));
- _LoadSpells(holder->GetResult(PLAYER_LOGIN_QUERY_LOADSPELLS));
+ _LoadTalents(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADTALENTS));
+ _LoadSpells(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADSPELLS));
- _LoadGlyphs(holder->GetResult(PLAYER_LOGIN_QUERY_LOADGLYPHS));
- _LoadAuras(holder->GetResult(PLAYER_LOGIN_QUERY_LOADAURAS), time_diff);
+ _LoadGlyphs(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADGLYPHS));
+ _LoadAuras(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADAURAS), time_diff);
_LoadGlyphAuras();
// add ghost flag (must be after aura load: PLAYER_FLAGS_GHOST set in aura)
if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
m_deathState = DEAD;
// after spell load, learn rewarded spell if need also
- _LoadQuestStatus(holder->GetResult(PLAYER_LOGIN_QUERY_LOADQUESTSTATUS));
- _LoadDailyQuestStatus(holder->GetResult(PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS));
- _LoadWeeklyQuestStatus(holder->GetResult(PLAYER_LOGIN_QUERY_LOADWEKLYQUESTSTATUS));
- _LoadRandomBGStatus(holder->GetResult(PLAYER_LOGIN_QUERY_LOADRANDOMBG));
+ _LoadQuestStatus(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADQUESTSTATUS));
+ _LoadDailyQuestStatus(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS));
+ _LoadWeeklyQuestStatus(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADWEKLYQUESTSTATUS));
+ _LoadRandomBGStatus(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADRANDOMBG));
// after spell and quest load
InitTalentForLevel();
learnDefaultSpells();
// must be before inventory (some items required reputation check)
- m_reputationMgr.LoadFromDB(holder->GetResult(PLAYER_LOGIN_QUERY_LOADREPUTATION));
+ m_reputationMgr.LoadFromDB(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADREPUTATION));
- _LoadInventory(holder->GetResult(PLAYER_LOGIN_QUERY_LOADINVENTORY), time_diff);
+ _LoadInventory(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADINVENTORY), time_diff);
// update items with duration and realtime
UpdateItemDuration(time_diff, true);
- _LoadActions(holder->GetResult(PLAYER_LOGIN_QUERY_LOADACTIONS));
+ _LoadActions(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADACTIONS));
// unread mails and next delivery time, actual mails not loaded
- _LoadMailInit(holder->GetResult(PLAYER_LOGIN_QUERY_LOADMAILCOUNT), holder->GetResult(PLAYER_LOGIN_QUERY_LOADMAILDATE));
+ _LoadMailInit(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADMAILCOUNT), holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADMAILDATE));
- m_social = sSocialMgr.LoadFromDB(holder->GetResult(PLAYER_LOGIN_QUERY_LOADSOCIALLIST), GetGUIDLow());
+ m_social = sSocialMgr.LoadFromDB(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADSOCIALLIST), GetGUIDLow());
// check PLAYER_CHOSEN_TITLE compatibility with PLAYER__FIELD_KNOWN_TITLES
// note: PLAYER__FIELD_KNOWN_TITLES updated at quest status loaded
- uint32 curTitle = fields[46].GetUInt32();
+ uint32 curTitle = result->GetUInt32(46);
if (curTitle && !HasTitle(curTitle))
curTitle = 0;
@@ -16408,7 +16396,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
// has to be called after last Relocate() in Player::LoadFromDB
SetFallInformation(0, GetPositionZ());
- _LoadSpellCooldowns(holder->GetResult(PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS));
+ _LoadSpellCooldowns(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS));
// Spell code allow apply any auras to dead character in load time in aura/spell/item loading
// Do now before stats re-calculation cleanup for ghost state unexpected auras
@@ -16422,11 +16410,11 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
UpdateAllStats();
// restore remembered power/health values (but not more max values)
- uint32 savedHealth = fields[50].GetUInt32();
+ uint32 savedHealth = result->GetUInt32(50);
SetHealth(savedHealth > GetMaxHealth() ? GetMaxHealth() : savedHealth);
for (uint8 i = 0; i < MAX_POWERS; ++i)
{
- uint32 savedPower = fields[51+i].GetUInt32();
+ uint32 savedPower = result->GetUInt32(51+i);
SetPower(Powers(i),savedPower > GetMaxPower(Powers(i)) ? GetMaxPower(Powers(i)) : savedPower);
}
@@ -16492,12 +16480,12 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
}
}
- _LoadDeclinedNames(holder->GetResult(PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES));
+ _LoadDeclinedNames(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES));
- m_achievementMgr.LoadFromDB(holder->GetResult(PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS), holder->GetResult(PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS));
+ m_achievementMgr.LoadFromDB(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS), holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS));
m_achievementMgr.CheckAllAchievementCriteria();
- _LoadEquipmentSets(holder->GetResult(PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS));
+ _LoadEquipmentSets(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS));
return true;
}
@@ -16546,35 +16534,37 @@ bool Player::isAllowedToLoot(const Creature* creature)
return false;
}
-void Player::_LoadActions(QueryResult result)
+void Player::_LoadActions(PreparedQueryResult result)
{
- m_actionButtons.clear();
+ m_actionButtons[0].clear();
+ m_actionButtons[1].clear();
if (result)
{
do
{
- Field *fields = result->Fetch();
+ uint8 button = result->GetUInt8(0);
+ uint32 action = result->GetUInt32(1);
+ uint8 type = result->GetUInt8(2);
+ uint8 spec = result->GetUInt8(3);
- uint8 button = fields[0].GetUInt8();
- uint32 action = fields[1].GetUInt32();
- uint8 type = fields[2].GetUInt8();
+ if (spec >= MAX_TALENT_SPECS)
+ continue;
- if (ActionButton* ab = addActionButton(button, action, type))
+ if (ActionButton* ab = addActionButton(button, action, type, spec))
ab->uState = ACTIONBUTTON_UNCHANGED;
else
{
sLog.outError(" ...at loading, and will deleted in DB also");
// Will deleted in DB at next save (it can create data until save but marked as deleted)
- m_actionButtons[button].uState = ACTIONBUTTON_DELETED;
+ m_actionButtons[spec][button].uState = ACTIONBUTTON_DELETED;
}
- }
- while (result->NextRow());
+ } while (result->NextRow());
}
}
-void Player::_LoadAuras(QueryResult result, uint32 timediff)
+void Player::_LoadAuras(PreparedQueryResult result, uint32 timediff)
{
sLog.outDebug("Loading auras for player %u",GetGUIDLow());
@@ -16586,21 +16576,20 @@ void Player::_LoadAuras(QueryResult result, uint32 timediff)
{
int32 damage[3];
int32 baseDamage[3];
- Field *fields = result->Fetch();
- uint64 caster_guid = fields[0].GetUInt64();
- uint32 spellid = fields[1].GetUInt32();
- uint8 effmask = fields[2].GetUInt8();
- uint8 recalculatemask = fields[3].GetUInt8();
- uint8 stackcount = fields[4].GetUInt8();
- damage[0] = fields[5].GetInt32();
- damage[1] = fields[6].GetInt32();
- damage[2] = fields[7].GetInt32();
- baseDamage[0] = fields[8].GetInt32();
- baseDamage[1] = fields[9].GetInt32();
- baseDamage[2] = fields[10].GetInt32();
- int32 maxduration = fields[11].GetInt32();
- int32 remaintime = fields[12].GetInt32();
- uint8 remaincharges = fields[13].GetUInt8();
+ uint64 caster_guid = result->GetUInt64(0);
+ uint32 spellid = result->GetUInt32(1);
+ uint8 effmask = result->GetUInt8(2);
+ uint8 recalculatemask = result->GetUInt8(3);
+ uint8 stackcount = result->GetUInt8(4);
+ damage[0] = result->GetInt32(5);
+ damage[1] = result->GetInt32(6);
+ damage[2] = result->GetInt32(7);
+ baseDamage[0] = result->GetInt32(8);
+ baseDamage[1] = result->GetInt32(9);
+ baseDamage[2] = result->GetInt32(10);
+ int32 maxduration = result->GetInt32(11);
+ int32 remaintime = result->GetInt32(12);
+ uint8 remaincharges = result->GetUInt8(13);
SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid);
if (!spellproto)
@@ -16690,7 +16679,7 @@ void Player::LoadCorpse()
}
}
-void Player::_LoadInventory(QueryResult result, uint32 timediff)
+void Player::_LoadInventory(PreparedQueryResult result, uint32 timediff)
{
//QueryResult *result = CharacterDatabase.PQuery("SELECT data,text,bag,slot,item,item_template FROM character_inventory JOIN item_instance ON character_inventory.item = item_instance.guid WHERE character_inventory.guid = '%u' ORDER BY bag,slot", GetGUIDLow());
std::map<uint64, Bag*> bagMap; // fast guid lookup for bags
@@ -16710,11 +16699,10 @@ void Player::_LoadInventory(QueryResult result, uint32 timediff)
m_itemUpdateQueueBlocked = true;
do
{
- Field *fields = result->Fetch();
- uint32 bag_guid = fields[11].GetUInt32();
- uint8 slot = fields[12].GetUInt8();
- uint32 item_guid = fields[13].GetUInt32();
- uint32 item_id = fields[14].GetUInt32();
+ uint32 bag_guid = result->GetUInt32(11);
+ uint8 slot = result->GetUInt8(12);
+ uint32 item_guid = result->GetUInt32(13);
+ uint32 item_id = result->GetUInt32(14);
ItemPrototype const * proto = sObjectMgr.GetItemPrototype(item_id);
@@ -16738,7 +16726,7 @@ void Player::_LoadInventory(QueryResult result, uint32 timediff)
}
// not allow have in alive state item limited to another map/zone
- if (isAlive() && item->IsLimitedToAnotherMapOrZone(GetMapId(),zone))
+ if (isAlive() && item->IsLimitedToAnotherMapOrZone(GetMapId(), zone))
{
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid);
item->FSetState(ITEM_REMOVED);
@@ -16777,10 +16765,10 @@ void Player::_LoadInventory(QueryResult result, uint32 timediff)
}
else
{
- fields = result2->Fetch();
- item->SetRefundRecipient(fields[0].GetUInt32());
- item->SetPaidMoney(fields[1].GetUInt32());
- item->SetPaidExtendedCost(fields[2].GetUInt32());
+ Field* fields2 = result2->Fetch();
+ item->SetRefundRecipient(fields2[0].GetUInt32());
+ item->SetPaidMoney(fields2[1].GetUInt32());
+ item->SetPaidExtendedCost(fields2[2].GetUInt32());
AddRefundReference(item->GetGUIDLow());
}
}
@@ -16888,16 +16876,17 @@ void Player::_LoadInventory(QueryResult result, uint32 timediff)
void Player::_LoadMailedItems(Mail *mail)
{
// data needs to be at first place for Item::LoadFromDB
- QueryResult result = CharacterDatabase.PQuery("SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text, item_guid, item_template, owner_guid FROM mail_items JOIN item_instance ON item_guid = guid WHERE mail_id='%u'", mail->messageID);
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_MAILITEMS);
+ stmt->setUInt32(0, mail->messageID);
+ PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (!result)
return;
SQLTransaction trans = CharacterDatabase.BeginTransaction();
do
{
- Field *fields = result->Fetch();
- uint32 item_guid_low = fields[11].GetUInt32();
- uint32 item_template = fields[12].GetUInt32();
+ uint32 item_guid_low = result->GetUInt32(11);
+ uint32 item_template = result->GetUInt32(12);
mail->AddItem(item_guid_low, item_template);
@@ -16913,7 +16902,7 @@ void Player::_LoadMailedItems(Mail *mail)
Item *item = NewItemOrBag(proto);
- if (!item->LoadFromDB(item_guid_low, MAKE_NEW_GUID(fields[13].GetUInt32(), 0, HIGHGUID_PLAYER), result, item_template))
+ if (!item->LoadFromDB(item_guid_low, MAKE_NEW_GUID(result->GetUInt32(13), 0, HIGHGUID_PLAYER), result, item_template))
{
sLog.outError("Player::_LoadMailedItems - Item in mail (%u) doesn't exist !!!! - item guid: %u, deleted from mail", mail->messageID, item_guid_low);
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low);
@@ -16928,23 +16917,17 @@ void Player::_LoadMailedItems(Mail *mail)
CharacterDatabase.CommitTransaction(trans);
}
-void Player::_LoadMailInit(QueryResult resultUnread, QueryResult resultDelivery)
+void Player::_LoadMailInit(PreparedQueryResult resultUnread, PreparedQueryResult resultDelivery)
{
//set a count of unread mails
//QueryResult *resultMails = CharacterDatabase.PQuery("SELECT COUNT(id) FROM mail WHERE receiver = '%u' AND (checked & 1)=0 AND deliver_time <= '" UI64FMTD "'", GUID_LOPART(playerGuid),(uint64)cTime);
if (resultUnread)
- {
- Field *fieldMail = resultUnread->Fetch();
- unReadMails = fieldMail[0].GetUInt8();
- }
+ unReadMails = resultUnread->GetUInt8(0);
// store nearest delivery time (it > 0 and if it < current then at next player update SendNewMaill will be called)
//resultMails = CharacterDatabase.PQuery("SELECT MIN(deliver_time) FROM mail WHERE receiver = '%u' AND (checked & 1)=0", GUID_LOPART(playerGuid));
if (resultDelivery)
- {
- Field *fieldMail = resultDelivery->Fetch();
- m_nextMailDelivereTime = (time_t)fieldMail[0].GetUInt64();
- }
+ m_nextMailDelivereTime = (time_t)resultDelivery->GetUInt64(0);
}
void Player::_LoadMail()
@@ -17002,7 +16985,7 @@ void Player::LoadPet()
}
}
-void Player::_LoadQuestStatus(QueryResult result)
+void Player::_LoadQuestStatus(PreparedQueryResult result)
{
mQuestStatus.clear();
@@ -17015,9 +16998,7 @@ void Player::_LoadQuestStatus(QueryResult result)
{
do
{
- Field *fields = result->Fetch();
-
- uint32 quest_id = fields[0].GetUInt32();
+ uint32 quest_id = result->GetUInt32(0);
// used to be new, no delete?
Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest_id);
if (pQuest)
@@ -17025,7 +17006,7 @@ void Player::_LoadQuestStatus(QueryResult result)
// find or create
QuestStatusData& questStatusData = mQuestStatus[quest_id];
- uint32 qstatus = fields[1].GetUInt32();
+ uint32 qstatus = result->GetUInt32(1);
if (qstatus < MAX_QUEST_STATUS)
questStatusData.m_status = QuestStatus(qstatus);
else
@@ -17034,10 +17015,10 @@ void Player::_LoadQuestStatus(QueryResult result)
sLog.outError("Player %s have invalid quest %d status (%d), replaced by QUEST_STATUS_NONE(0).",GetName(),quest_id,qstatus);
}
- questStatusData.m_rewarded = (fields[2].GetUInt8() > 0);
- questStatusData.m_explored = (fields[3].GetUInt8() > 0);
+ questStatusData.m_rewarded = (result->GetUInt8(2) > 0);
+ questStatusData.m_explored = (result->GetUInt8(3) > 0);
- time_t quest_time = time_t(fields[4].GetUInt64());
+ time_t quest_time = time_t(result->GetUInt64(4));
if (pQuest->HasFlag(QUEST_TRINITY_FLAGS_TIMED) && !GetQuestRewardStatus(quest_id) && questStatusData.m_status != QUEST_STATUS_NONE)
{
@@ -17051,14 +17032,14 @@ void Player::_LoadQuestStatus(QueryResult result)
else
quest_time = 0;
- questStatusData.m_creatureOrGOcount[0] = fields[5].GetUInt32();
- questStatusData.m_creatureOrGOcount[1] = fields[6].GetUInt32();
- questStatusData.m_creatureOrGOcount[2] = fields[7].GetUInt32();
- questStatusData.m_creatureOrGOcount[3] = fields[8].GetUInt32();
- questStatusData.m_itemcount[0] = fields[9].GetUInt32();
- questStatusData.m_itemcount[1] = fields[10].GetUInt32();
- questStatusData.m_itemcount[2] = fields[11].GetUInt32();
- questStatusData.m_itemcount[3] = fields[12].GetUInt32();
+ questStatusData.m_creatureOrGOcount[0] = result->GetUInt32(5);
+ questStatusData.m_creatureOrGOcount[1] = result->GetUInt32(6);
+ questStatusData.m_creatureOrGOcount[2] = result->GetUInt32(7);
+ questStatusData.m_creatureOrGOcount[3] = result->GetUInt32(8);
+ questStatusData.m_itemcount[0] = result->GetUInt32(9);
+ questStatusData.m_itemcount[1] = result->GetUInt32(10);
+ questStatusData.m_itemcount[2] = result->GetUInt32(11);
+ questStatusData.m_itemcount[3] = result->GetUInt32(12);
questStatusData.uState = QUEST_UNCHANGED;
@@ -17111,7 +17092,7 @@ void Player::_LoadQuestStatus(QueryResult result)
SetQuestSlot(i, 0);
}
-void Player::_LoadDailyQuestStatus(QueryResult result)
+void Player::_LoadDailyQuestStatus(PreparedQueryResult result)
{
for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx)
SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,0);
@@ -17130,29 +17111,26 @@ void Player::_LoadDailyQuestStatus(QueryResult result)
break;
}
- Field *fields = result->Fetch();
-
- uint32 quest_id = fields[0].GetUInt32();
+ uint32 quest_id = result->GetUInt32(0);
// save _any_ from daily quest times (it must be after last reset anyway)
- m_lastDailyQuestTime = (time_t)fields[1].GetUInt64();
+ m_lastDailyQuestTime = (time_t)result->GetUInt64(1);
Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest_id);
if (!pQuest)
continue;
- SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,quest_id);
+ SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx, quest_id);
++quest_daily_idx;
- sLog.outDebug("Daily quest {%u} cooldown for player (GUID: %u)", quest_id, GetGUIDLow());
- }
- while (result->NextRow());
+ sLog.outDebug("Daily quest (%u) cooldown for player (GUID: %u)", quest_id, GetGUIDLow());
+ } while (result->NextRow());
}
m_DailyQuestChanged = false;
}
-void Player::_LoadWeeklyQuestStatus(QueryResult result)
+void Player::_LoadWeeklyQuestStatus(PreparedQueryResult result)
{
m_weeklyquests.clear();
@@ -17160,47 +17138,37 @@ void Player::_LoadWeeklyQuestStatus(QueryResult result)
{
do
{
- Field *fields = result->Fetch();
-
- uint32 quest_id = fields[0].GetUInt32();
-
+ uint32 quest_id = result->GetUInt32(0);
Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest_id);
-
if (!pQuest)
continue;
m_weeklyquests.insert(quest_id);
-
sLog.outDebug("Weekly quest {%u} cooldown for player (GUID: %u)", quest_id, GetGUIDLow());
- }
- while (result->NextRow());
+ } while (result->NextRow());
}
m_WeeklyQuestChanged = false;
}
-void Player::_LoadSpells(QueryResult result)
+void Player::_LoadSpells(PreparedQueryResult result)
{
//QueryResult *result = CharacterDatabase.PQuery("SELECT spell,active,disabled FROM character_spell WHERE guid = '%u'",GetGUIDLow());
if (result)
{
do
- {
- Field *fields = result->Fetch();
-
- addSpell(fields[0].GetUInt32(), fields[1].GetBool(), false, false, fields[2].GetBool());
- }
+ addSpell(result->GetUInt32(0), result->GetBool(1), false, false, result->GetBool(2));
while (result->NextRow());
}
}
-void Player::_LoadGroup(QueryResult result)
+void Player::_LoadGroup(PreparedQueryResult result)
{
//QueryResult *result = CharacterDatabase.PQuery("SELECT guid FROM group_member WHERE memberGuid=%u", GetGUIDLow());
if (result)
{
- if (Group* group = sObjectMgr.GetGroupByGUID((*result)[0].GetUInt32()))
+ if (Group* group = sObjectMgr.GetGroupByGUID(result->GetUInt32(0)))
{
uint8 subgroup = group->GetMemberGroup(GetGUID());
SetGroup(group, subgroup);
@@ -17214,7 +17182,7 @@ void Player::_LoadGroup(QueryResult result)
}
}
-void Player::_LoadBoundInstances(QueryResult result)
+void Player::_LoadBoundInstances(PreparedQueryResult result)
{
for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
m_boundInstances[i].clear();
@@ -17226,13 +17194,12 @@ void Player::_LoadBoundInstances(QueryResult result)
{
do
{
- Field *fields = result->Fetch();
- bool perm = fields[1].GetBool();
- uint32 mapId = fields[2].GetUInt32();
- uint32 instanceId = fields[0].GetUInt32();
- uint8 difficulty = fields[3].GetUInt8();
+ bool perm = result->GetBool(1);
+ uint32 mapId = result->GetUInt32(2);
+ uint32 instanceId = result->GetUInt32(0);
+ uint8 difficulty = result->GetUInt8(3);
- time_t resetTime = (time_t)fields[4].GetUInt64();
+ time_t resetTime = (time_t)result->GetUInt64(4);
// the resettime for normal instances is only saved when the InstanceSave is unloaded
// so the value read from the DB may be wrong here but only if the InstanceSave is loaded
// and in that case it is not used
@@ -17565,7 +17532,7 @@ bool Player::CheckInstanceLoginValid()
return sMapMgr.CanPlayerEnter(GetMap()->GetId(), this, true);
}
-bool Player::_LoadHomeBind(QueryResult result)
+bool Player::_LoadHomeBind(PreparedQueryResult result)
{
PlayerInfo const *info = sObjectMgr.GetPlayerInfo(getRace(), getClass());
if (!info)
@@ -17578,12 +17545,11 @@ bool Player::_LoadHomeBind(QueryResult result)
//QueryResult *result = CharacterDatabase.PQuery("SELECT map,zone,position_x,position_y,position_z FROM character_homebind WHERE guid = '%u'", GUID_LOPART(playerGuid));
if (result)
{
- Field *fields = result->Fetch();
- m_homebindMapId = fields[0].GetUInt32();
- m_homebindAreaId = fields[1].GetUInt16();
- m_homebindX = fields[2].GetFloat();
- m_homebindY = fields[3].GetFloat();
- m_homebindZ = fields[4].GetFloat();
+ m_homebindMapId = result->GetUInt32(0);
+ m_homebindAreaId = result->GetUInt16(1);
+ m_homebindX = result->GetFloat(2);
+ m_homebindY = result->GetFloat(3);
+ m_homebindZ = result->GetFloat(4);
MapEntry const* bindMapEntry = sMapStore.LookupEntry(m_homebindMapId);
@@ -17685,7 +17651,7 @@ void Player::SaveToDB()
ss << (IsInWorld() ? 1 : 0) << ", ";
- ss << m_cinematic << ", ";
+ ss << uint32(m_cinematic) << ", ";
ss << m_Played_time[PLAYED_TIME_TOTAL] << ", ";
ss << m_Played_time[PLAYED_TIME_LEVEL] << ", ";
@@ -17825,29 +17791,32 @@ void Player::SaveGoldToDB(SQLTransaction& trans)
void Player::_SaveActions(SQLTransaction& trans)
{
- for (ActionButtonList::iterator itr = m_actionButtons.begin(); itr != m_actionButtons.end();)
+ for (uint8 i = 0; i < MAX_TALENT_SPECS; ++i)
{
- switch (itr->second.uState)
+ for (ActionButtonList::iterator itr = m_actionButtons[i].begin(); itr != m_actionButtons[i].end();)
{
- case ACTIONBUTTON_NEW:
- trans->PAppend("INSERT INTO character_action (guid,spec,button,action,type) VALUES ('%u', '%u', '%u', '%u', '%u')",
- GetGUIDLow(), m_activeSpec, (uint32)itr->first, (uint32)itr->second.GetAction(), (uint32)itr->second.GetType());
- itr->second.uState = ACTIONBUTTON_UNCHANGED;
- ++itr;
- break;
- case ACTIONBUTTON_CHANGED:
- trans->PAppend("UPDATE character_action SET action = '%u', type = '%u' WHERE guid = '%u' AND button = '%u' AND spec = '%u'",
- (uint32)itr->second.GetAction(), (uint32)itr->second.GetType(), GetGUIDLow(), (uint32)itr->first, m_activeSpec);
- itr->second.uState = ACTIONBUTTON_UNCHANGED;
- ++itr;
- break;
- case ACTIONBUTTON_DELETED:
- trans->PAppend("DELETE FROM character_action WHERE guid = '%u' and button = '%u' and spec = '%u'", GetGUIDLow(), (uint32)itr->first, m_activeSpec);
- m_actionButtons.erase(itr++);
- break;
- default:
- ++itr;
- break;
+ switch (itr->second.uState)
+ {
+ case ACTIONBUTTON_NEW:
+ trans->PAppend("INSERT INTO character_action (guid,spec,button,action,type) VALUES ('%u', '%u', '%u', '%u', '%u')",
+ GetGUIDLow(), i, (uint32)itr->first, (uint32)itr->second.GetAction(), (uint32)itr->second.GetType());
+ itr->second.uState = ACTIONBUTTON_UNCHANGED;
+ ++itr;
+ break;
+ case ACTIONBUTTON_CHANGED:
+ trans->PAppend("UPDATE character_action SET action = '%u', type = '%u' WHERE guid = '%u' AND button = '%u' AND spec = '%u'",
+ (uint32)itr->second.GetAction(), (uint32)itr->second.GetType(), GetGUIDLow(), (uint32)itr->first, i);
+ itr->second.uState = ACTIONBUTTON_UNCHANGED;
+ ++itr;
+ break;
+ case ACTIONBUTTON_DELETED:
+ trans->PAppend("DELETE FROM character_action WHERE guid = '%u' and button = '%u' and spec = '%u'", GetGUIDLow(), (uint32)itr->first, i);
+ m_actionButtons[i].erase(itr++);
+ break;
+ default:
+ ++itr;
+ break;
+ }
}
}
}
@@ -22827,7 +22796,7 @@ void Player::learnSpellHighRank(uint32 spellid)
learnSpellHighRank(next);
}
-void Player::_LoadSkills(QueryResult result)
+void Player::_LoadSkills(PreparedQueryResult result)
{
// 0 1 2
// SetPQuery(PLAYER_LOGIN_QUERY_LOADSKILLS, "SELECT skill, value, max FROM character_skills WHERE guid = '%u'", GUID_LOPART(m_guid));
@@ -22837,11 +22806,9 @@ void Player::_LoadSkills(QueryResult result)
{
do
{
- Field *fields = result->Fetch();
-
- uint16 skill = fields[0].GetUInt16();
- uint16 value = fields[1].GetUInt16();
- uint16 max = fields[2].GetUInt16();
+ uint16 skill = result->GetUInt16(0);
+ uint16 value = result->GetUInt16(1);
+ uint16 max = result->GetUInt16(2);
SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(skill);
if (!pSkill)
@@ -23737,27 +23704,24 @@ void Player::SetMap(Map * map)
m_mapRef.link(map, this);
}
-void Player::_LoadGlyphs(QueryResult result)
+void Player::_LoadGlyphs(PreparedQueryResult result)
{
- // SetPQuery(PLAYER_LOGIN_QUERY_LOADGLYPHS, "SELECT spec, glyph1, glyph2, glyph3, glyph4, glyph5, glyph6 from character_glyphs WHERE guid = '%u'", GUID_LOPART(m_guid));
+ // SELECT spec, glyph1, glyph2, glyph3, glyph4, glyph5, glyph6 from character_glyphs WHERE guid = '%u'
if (!result)
return;
do
{
- Field *fields = result->Fetch();
-
- uint8 spec = fields[0].GetUInt8();
+ uint8 spec = result->GetUInt8(0);
if (spec >= m_specsCount)
continue;
- m_Glyphs[spec][0] = fields[1].GetUInt32();
- m_Glyphs[spec][1] = fields[2].GetUInt32();
- m_Glyphs[spec][2] = fields[3].GetUInt32();
- m_Glyphs[spec][3] = fields[4].GetUInt32();
- m_Glyphs[spec][4] = fields[5].GetUInt32();
- m_Glyphs[spec][5] = fields[6].GetUInt32();
-
+ m_Glyphs[spec][0] = result->GetUInt32(1);
+ m_Glyphs[spec][1] = result->GetUInt32(2);
+ m_Glyphs[spec][2] = result->GetUInt32(3);
+ m_Glyphs[spec][3] = result->GetUInt32(4);
+ m_Glyphs[spec][4] = result->GetUInt32(5);
+ m_Glyphs[spec][5] = result->GetUInt32(6);
} while (result->NextRow());
}
@@ -23771,17 +23735,13 @@ void Player::_SaveGlyphs(SQLTransaction& trans)
}
}
-void Player::_LoadTalents(QueryResult result)
+void Player::_LoadTalents(PreparedQueryResult result)
{
// SetPQuery(PLAYER_LOGIN_QUERY_LOADTALENTS, "SELECT spell, spec FROM character_talent WHERE guid = '%u'", GUID_LOPART(m_guid));
if (result)
{
do
- {
- Field *fields = result->Fetch();
-
- AddTalent(fields[0].GetUInt32(), fields[1].GetUInt32(), false);
- }
+ AddTalent(result->GetUInt32(0), result->GetUInt32(1), false);
while (result->NextRow());
}
}
@@ -23827,7 +23787,7 @@ void Player::UpdateSpecCount(uint8 count)
if (count > curCount)
{
_SaveActions(trans); // make sure the button list is cleaned up
- for (ActionButtonList::iterator itr = m_actionButtons.begin(); itr != m_actionButtons.end(); ++itr)
+ for (ActionButtonList::iterator itr = m_actionButtons[m_activeSpec].begin(); itr != m_actionButtons[m_activeSpec].end(); ++itr)
trans->PAppend("INSERT INTO character_action (guid,button,action,type,spec) VALUES ('%u', '%u', '%u', '%u', '%u')",
GetGUIDLow(), uint32(itr->first), uint32(itr->second.GetAction()), uint32(itr->second.GetType()), 1);
@@ -23974,11 +23934,6 @@ void Player::ActivateSpec(uint8 spec)
m_usedTalentCount = spentTalents;
InitTalentForLevel();
- if (QueryResult result =
- CharacterDatabase.PQuery("SELECT button,action,type FROM character_action WHERE guid = '%u' AND spec = '%u' ORDER BY button", GetGUIDLow(), m_activeSpec))
- _LoadActions(result);
-
-
ResummonPetTemporaryUnSummonedIfAny();
if (Pet* pPet = GetPet())
pPet->InitTalentForLevel(); // not processed with aura removal because pet was not active
@@ -24222,7 +24177,7 @@ void Player::SetRandomWinner(bool isWinner)
CharacterDatabase.PExecute("INSERT INTO character_battleground_random (guid) VALUES ('%u')", GetGUIDLow());
}
-void Player::_LoadRandomBGStatus(QueryResult result)
+void Player::_LoadRandomBGStatus(PreparedQueryResult result)
{
//QueryResult result = CharacterDatabase.PQuery("SELECT guid FROM character_battleground_random WHERE guid = '%u'", GetGUIDLow());
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index d40077aff4b..dd06afea008 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1632,7 +1632,7 @@ class Player : public Unit, public GridObject<Player>
void RemoveCategoryCooldown(uint32 cat);
void RemoveArenaSpellCooldowns();
void RemoveAllSpellCooldown();
- void _LoadSpellCooldowns(QueryResult result);
+ void _LoadSpellCooldowns(PreparedQueryResult result);
void _SaveSpellCooldowns(SQLTransaction& trans);
void SetLastPotionId(uint32 item_id) { m_lastPotionId = item_id; }
void UpdatePotionCooldown(Spell* spell = NULL);
@@ -1657,16 +1657,16 @@ class Player : public Unit, public GridObject<Player>
bool isRessurectRequested() const { return m_resurrectGUID != 0; }
void ResurectUsingRequestData();
- int getCinematic()
+ uint8 getCinematic()
{
return m_cinematic;
}
- void setCinematic(int cine)
+ void setCinematic(uint8 cine)
{
m_cinematic = cine;
}
- ActionButton* addActionButton(uint8 button, uint32 action, uint8 type);
+ ActionButton* addActionButton(uint8 button, uint32 action, uint8 type, uint8 spec = 0);
void removeActionButton(uint8 button);
ActionButton const* GetActionButton(uint8 button);
void SendInitialActionButtons() const { SendActionButtons(1); }
@@ -2417,30 +2417,30 @@ class Player : public Unit, public GridObject<Player>
/*** LOAD SYSTEM ***/
/*********************************************************/
- void _LoadActions(QueryResult result);
- void _LoadAuras(QueryResult result, uint32 timediff);
+ void _LoadActions(PreparedQueryResult result);
+ void _LoadAuras(PreparedQueryResult result, uint32 timediff);
void _LoadGlyphAuras();
- void _LoadBoundInstances(QueryResult result);
- void _LoadInventory(QueryResult result, uint32 timediff);
- void _LoadMailInit(QueryResult resultUnread, QueryResult resultDelivery);
+ void _LoadBoundInstances(PreparedQueryResult result);
+ void _LoadInventory(PreparedQueryResult result, uint32 timediff);
+ void _LoadMailInit(PreparedQueryResult resultUnread, PreparedQueryResult resultDelivery);
void _LoadMail();
void _LoadMailedItems(Mail *mail);
- void _LoadQuestStatus(QueryResult result);
- void _LoadDailyQuestStatus(QueryResult result);
- void _LoadWeeklyQuestStatus(QueryResult result);
- void _LoadRandomBGStatus(QueryResult result);
- void _LoadGroup(QueryResult result);
- void _LoadSkills(QueryResult result);
- void _LoadSpells(QueryResult result);
- void _LoadFriendList(QueryResult result);
- bool _LoadHomeBind(QueryResult result);
- void _LoadDeclinedNames(QueryResult result);
- void _LoadArenaTeamInfo(QueryResult result);
- void _LoadArenaStatsInfo(QueryResult result);
- void _LoadEquipmentSets(QueryResult result);
- void _LoadBGData(QueryResult result);
- void _LoadGlyphs(QueryResult result);
- void _LoadTalents(QueryResult result);
+ void _LoadQuestStatus(PreparedQueryResult result);
+ void _LoadDailyQuestStatus(PreparedQueryResult result);
+ void _LoadWeeklyQuestStatus(PreparedQueryResult result);
+ void _LoadRandomBGStatus(PreparedQueryResult result);
+ void _LoadGroup(PreparedQueryResult result);
+ void _LoadSkills(PreparedQueryResult result);
+ void _LoadSpells(PreparedQueryResult result);
+ void _LoadFriendList(PreparedQueryResult result);
+ bool _LoadHomeBind(PreparedQueryResult result);
+ void _LoadDeclinedNames(PreparedQueryResult result);
+ void _LoadArenaTeamInfo(PreparedQueryResult result);
+ void _LoadArenaStatsInfo(PreparedQueryResult result);
+ void _LoadEquipmentSets(PreparedQueryResult result);
+ void _LoadBGData(PreparedQueryResult result);
+ void _LoadGlyphs(PreparedQueryResult result);
+ void _LoadTalents(PreparedQueryResult result);
/*********************************************************/
/*** SAVE SYSTEM ***/
@@ -2520,7 +2520,7 @@ class Player : public Unit, public GridObject<Player>
uint32 m_Glyphs[MAX_TALENT_SPECS][MAX_GLYPH_SLOT_INDEX];
- ActionButtonList m_actionButtons;
+ ActionButtonList m_actionButtons[MAX_TALENT_SPECS];
float m_auraBaseMod[BASEMOD_END][MOD_END];
int16 m_baseRatingValue[MAX_COMBAT_RATING];
@@ -2549,7 +2549,7 @@ class Player : public Unit, public GridObject<Player>
typedef std::list<Channel*> JoinedChannelsList;
JoinedChannelsList m_channels;
- int m_cinematic;
+ uint8 m_cinematic;
TradeData* m_trade;
diff --git a/src/server/game/Entities/Player/SocialMgr.cpp b/src/server/game/Entities/Player/SocialMgr.cpp
index a7ff912f2e1..36c750377c9 100644
--- a/src/server/game/Entities/Player/SocialMgr.cpp
+++ b/src/server/game/Entities/Player/SocialMgr.cpp
@@ -289,7 +289,7 @@ void SocialMgr::BroadcastToFriendListers(Player *player, WorldPacket *packet)
}
}
-PlayerSocial *SocialMgr::LoadFromDB(QueryResult result, uint32 guid)
+PlayerSocial *SocialMgr::LoadFromDB(PreparedQueryResult result, uint32 guid)
{
PlayerSocial *social = &m_socialMap[guid];
social->SetPlayerGUID(guid);
@@ -303,19 +303,17 @@ PlayerSocial *SocialMgr::LoadFromDB(QueryResult result, uint32 guid)
do
{
- Field *fields = result->Fetch();
-
- friend_guid = fields[0].GetUInt32();
- flags = fields[1].GetUInt32();
- note = fields[2].GetCppString();
+ friend_guid = result->GetUInt32(0);
+ flags = result->GetUInt32(1);
+ note = result->GetString(2);
social->m_playerSocialMap[friend_guid] = FriendInfo(flags, note);
// client's friends list and ignore list limit
if (social->m_playerSocialMap.size() >= (SOCIALMGR_FRIEND_LIMIT + SOCIALMGR_IGNORE_LIMIT))
break;
- }
- while (result->NextRow());
+ } while (result->NextRow());
+
return social;
}
diff --git a/src/server/game/Entities/Player/SocialMgr.h b/src/server/game/Entities/Player/SocialMgr.h
index 44b4fd8c2ab..c5e7db50f67 100644
--- a/src/server/game/Entities/Player/SocialMgr.h
+++ b/src/server/game/Entities/Player/SocialMgr.h
@@ -153,7 +153,7 @@ class SocialMgr
void SendFriendStatus(Player *player, FriendsResult result, uint32 friend_guid, bool broadcast);
void BroadcastToFriendListers(Player *player, WorldPacket *packet);
// Loading
- PlayerSocial *LoadFromDB(QueryResult result, uint32 guid);
+ PlayerSocial *LoadFromDB(PreparedQueryResult result, uint32 guid);
private:
SocialMap m_socialMap;
};
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 989f7a1a8ed..eef8d4b6a85 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -3540,8 +3540,9 @@ void ObjectMgr::LoadGuilds()
// 0 1 2 3 4
QueryResult guildBankTabResult = CharacterDatabase.Query("SELECT TabId, TabName, TabIcon, TabText, guildid FROM guild_bank_tab ORDER BY TabId");
- // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
- QueryResult guildBankItemResult = CharacterDatabase.Query("SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text, TabId, SlotId, item_guid, item_entry, guildid FROM guild_bank_item JOIN item_instance ON item_guid = guid");
+
+ PreparedStatement* guildBankItemStmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_GUILD_BANK_ITEMS);
+ PreparedQueryResult guildBankItemResult = CharacterDatabase.Query(guildBankItemStmt);
LoadGuildEvents(GuildVector, guildEventResult);
LoadGuildBankEvents(GuildVector, guildBankEventResult);
@@ -3660,7 +3661,7 @@ void ObjectMgr::LoadGuildBankEvents(std::vector<Guild*>& GuildVector, QueryResul
}
}
-void ObjectMgr::LoadGuildBanks(std::vector<Guild*>& GuildVector, QueryResult& result, QueryResult& itemResult)
+void ObjectMgr::LoadGuildBanks(std::vector<Guild*>& GuildVector, QueryResult& result, PreparedQueryResult& itemResult)
{
if (result)
{
@@ -3690,38 +3691,36 @@ void ObjectMgr::LoadGuildBanks(std::vector<Guild*>& GuildVector, QueryResult& re
{
do
{
- Field *itemfields = itemResult->Fetch();
-
- uint8 TabId = itemfields[11].GetUInt8();
- uint8 SlotId = itemfields[12].GetUInt8();
- uint32 ItemGuid = itemfields[13].GetUInt32();
- uint32 ItemEntry = itemfields[14].GetUInt32();
- uint32 guildid = itemfields[15].GetUInt32();
+ uint8 TabId = itemResult->GetUInt8(11);
+ uint8 SlotId = itemResult->GetUInt8(12);
+ uint32 ItemGuid = itemResult->GetUInt32(13);
+ uint32 ItemId = itemResult->GetUInt32(14);
+ uint32 guildid = itemResult->GetUInt32(15);
if (guildid >= GuildVector.size() || GuildVector[guildid] == NULL)
return;
if (TabId >= GuildVector[guildid]->GetPurchasedTabs())
{
- sLog.outError("Guild::LoadGuildBankFromDB: Invalid tab for item (GUID: %u id: #%u) in guild bank, skipped.", ItemGuid,ItemEntry);
+ sLog.outError("Guild::LoadGuildBankFromDB: Invalid tab for item (GUID: %u id: #%u) in guild bank, skipped.", ItemGuid, ItemId);
continue;
}
if (SlotId >= GUILD_BANK_MAX_SLOTS)
{
- sLog.outError("Guild::LoadGuildBankFromDB: Invalid slot for item (GUID: %u id: #%u) in guild bank, skipped.", ItemGuid,ItemEntry);
+ sLog.outError("Guild::LoadGuildBankFromDB: Invalid slot for item (GUID: %u id: #%u) in guild bank, skipped.", ItemGuid, ItemId);
continue;
}
- ItemPrototype const *proto = sObjectMgr.GetItemPrototype(ItemEntry);
+ ItemPrototype const *proto = sObjectMgr.GetItemPrototype(ItemId);
if (!proto)
{
- sLog.outError("Guild::LoadGuildBankFromDB: Unknown item (GUID: %u id: #%u) in guild bank, skipped.", ItemGuid,ItemEntry);
+ sLog.outError("Guild::LoadGuildBankFromDB: Unknown item (GUID: %u id: #%u) in guild bank, skipped.", ItemGuid, ItemId);
continue;
}
Item *pItem = NewItemOrBag(proto);
- if (!pItem->LoadFromDB(ItemGuid, 0, itemResult, ItemEntry))
+ if (!pItem->LoadFromDB(ItemGuid, 0, itemResult, ItemId))
{
PreparedStatement *stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_NONEXISTENT_GUILD_BANK_ITEM);
stmt->setUInt32(0, guildid);
diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
index 2ad56e8c2c1..2520b2399d2 100644
--- a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -596,7 +596,7 @@ class ObjectMgr
void LoadGuilds();
void LoadGuildEvents(std::vector<Guild*>& GuildVector, QueryResult& result);
void LoadGuildBankEvents(std::vector<Guild*>& GuildVector, QueryResult& result);
- void LoadGuildBanks(std::vector<Guild*>& GuildVector, QueryResult& result, QueryResult& itemResult);
+ void LoadGuildBanks(std::vector<Guild*>& GuildVector, QueryResult& result, PreparedQueryResult& itemResult);
void LoadArenaTeams();
void LoadGroups();
void LoadQuests();
diff --git a/src/server/game/Reputation/ReputationMgr.cpp b/src/server/game/Reputation/ReputationMgr.cpp
index 79afb239bbe..7e91191f413 100644
--- a/src/server/game/Reputation/ReputationMgr.cpp
+++ b/src/server/game/Reputation/ReputationMgr.cpp
@@ -452,7 +452,7 @@ void ReputationMgr::SetInactive(FactionState* faction, bool inactive)
faction->Changed = true;
}
-void ReputationMgr::LoadFromDB(QueryResult result)
+void ReputationMgr::LoadFromDB(PreparedQueryResult result)
{
// Set initial reputations (so everything is nifty before DB data load)
Initialize();
@@ -463,23 +463,21 @@ void ReputationMgr::LoadFromDB(QueryResult result)
{
do
{
- Field *fields = result->Fetch();
-
- FactionEntry const *factionEntry = sFactionStore.LookupEntry(fields[0].GetUInt32());
+ FactionEntry const *factionEntry = sFactionStore.LookupEntry(result->GetUInt32(0));
if (factionEntry && (factionEntry->reputationListID >= 0))
{
FactionState* faction = &m_factions[factionEntry->reputationListID];
// update standing to current
- faction->Standing = int32(fields[1].GetUInt32());
+ faction->Standing = int32(result->GetUInt32(1));
// update counters
int32 BaseRep = GetBaseReputation(factionEntry);
ReputationRank old_rank = ReputationToRank(BaseRep);
ReputationRank new_rank = ReputationToRank(BaseRep + faction->Standing);
- UpdateRankCounters(old_rank,new_rank);
+ UpdateRankCounters(old_rank, new_rank);
- uint32 dbFactionFlags = fields[2].GetUInt32();
+ uint32 dbFactionFlags = result->GetUInt32(2);
if (dbFactionFlags & FACTION_FLAG_VISIBLE)
SetVisible(faction); // have internal checks for forced invisibility
diff --git a/src/server/game/Reputation/ReputationMgr.h b/src/server/game/Reputation/ReputationMgr.h
index 572a01996d0..1731e3effca 100644
--- a/src/server/game/Reputation/ReputationMgr.h
+++ b/src/server/game/Reputation/ReputationMgr.h
@@ -68,7 +68,7 @@ class ReputationMgr
~ReputationMgr() {}
void SaveToDB(SQLTransaction& trans);
- void LoadFromDB(QueryResult result);
+ void LoadFromDB(PreparedQueryResult result);
public: // statics
static const int32 PointsInRank[MAX_REPUTATION_RANK];
static const int32 Reputation_Cap = 42999;
diff --git a/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp b/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp
index d5cab5458c5..f8615510daf 100644
--- a/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp
@@ -62,45 +62,132 @@ bool LoginQueryHolder::Initialize()
SetSize(MAX_PLAYER_LOGIN_QUERY);
bool res = true;
+ uint32 lowGuid = GUID_LOPART(m_guid);
+ PreparedStatement* stmt = NULL;
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADFROM, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_GROUP);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADGROUP, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_BOUNDINSTANCES);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_AURAS);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADAURAS, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_SPELLS);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADSPELLS, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_QUESTSTATUS);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADQUESTSTATUS, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_DAILYQUESTSTATUS);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_WEKLYQUESTSTATUS);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADWEKLYQUESTSTATUS, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_REPUTATION);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADREPUTATION, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_INVENTORY);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADINVENTORY, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_ACTIONS);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADACTIONS, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_MAILCOUNT);
+ stmt->setUInt32(0, lowGuid);
+ stmt->setUInt64(1, uint64(time(NULL)));
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADMAILCOUNT, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_MAILDATE);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADMAILDATE, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_SOCIALLIST);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADSOCIALLIST, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_HOMEBIND);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADHOMEBIND, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_SPELLCOOLDOWNS);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS, stmt);
- // NOTE: all fields in `characters` must be read to prevent lost character data at next save in case wrong DB structure.
- // !!! NOTE: including unused `zone`,`online`
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADFROM, "SELECT guid, account, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags,"
- "position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost,"
- "resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, instance_mode_mask,"
- "arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk,"
- "health, power1, power2, power3, power4, power5, power6, power7, instance_id, speccount, activespec, exploredZones, equipmentCache, ammoId, knownTitles, actionBars FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGROUP, "SELECT guid FROM group_member WHERE memberGuid =%u", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES, "SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS, "SELECT caster_guid,spell,effect_mask,recalculate_mask,stackcount,amount0,amount1,amount2,base_amount0,base_amount1,base_amount2,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSPELLS, "SELECT spell,active,disabled FROM character_spell WHERE guid = '%u'", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADQUESTSTATUS, "SELECT quest,status,rewarded,explored,timer,mobcount1,mobcount2,mobcount3,mobcount4,itemcount1,itemcount2,itemcount3,itemcount4 FROM character_queststatus WHERE guid = '%u'", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS,"SELECT quest,time FROM character_queststatus_daily WHERE guid = '%u'", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADWEKLYQUESTSTATUS,"SELECT quest FROM character_queststatus_weekly WHERE guid = '%u'", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADREPUTATION, "SELECT faction,standing,flags FROM character_reputation WHERE guid = '%u'", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADINVENTORY, "SELECT creatorGuid,giftCreatorGuid,count,duration,charges,flags,enchantments,randomPropertyId,durability,playedTime,text,bag,slot,item,item_template FROM character_inventory JOIN item_instance ON character_inventory.item = item_instance.guid WHERE character_inventory.guid = '%u' ORDER BY bag,slot", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADACTIONS, "SELECT a.button,a.action,a.type FROM character_action as a, characters as c WHERE a.guid = c.guid AND a.spec = c.activespec AND a.guid = '%u' ORDER BY button", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMAILCOUNT, "SELECT COUNT(id) FROM mail WHERE receiver = '%u' AND (checked & 1)=0 AND deliver_time <= '" UI64FMTD "'", GUID_LOPART(m_guid),(uint64)time(NULL));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMAILDATE, "SELECT MIN(deliver_time) FROM mail WHERE receiver = '%u' AND (checked & 1)=0", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSOCIALLIST, "SELECT friend,flags,note FROM character_social WHERE guid = '%u' LIMIT 255", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADHOMEBIND, "SELECT map,zone,position_x,position_y,position_z FROM character_homebind WHERE guid = '%u'", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS, "SELECT spell,item,time FROM character_spell_cooldown WHERE guid = '%u'", GUID_LOPART(m_guid));
if (sWorld.getBoolConfig(CONFIG_DECLINED_NAMES_USED))
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES, "SELECT genitive, dative, accusative, instrumental, prepositional FROM character_declinedname WHERE guid = '%u'",GUID_LOPART(m_guid));
- // in other case still be dummy query
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGUILD, "SELECT guildid,rank FROM guild_member WHERE guid = '%u'", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADARENAINFO, "SELECT arenateamid, played_week, played_season, wons_season FROM arena_team_member WHERE guid='%u'", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS, "SELECT achievement, date FROM character_achievement WHERE guid = '%u'", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS,"SELECT criteria, counter, date FROM character_achievement_progress WHERE guid = '%u'", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS, "SELECT setguid, setindex, name, iconname, item0, item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12, item13, item14, item15, item16, item17, item18 FROM character_equipmentsets WHERE guid = '%u' ORDER BY setindex", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBGDATA, "SELECT instance_id, team, join_x, join_y, join_z, join_o, join_map, taxi_start, taxi_end, mount_spell FROM character_battleground_data WHERE guid = '%u'", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGLYPHS, "SELECT spec, glyph1, glyph2, glyph3, glyph4, glyph5, glyph6 FROM character_glyphs WHERE guid='%u'", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADTALENTS, "SELECT spell, spec FROM character_talent WHERE guid='%u'", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADACCOUNTDATA, "SELECT type, time, data FROM character_account_data WHERE guid='%u'", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSKILLS, "SELECT skill, value, max FROM character_skills WHERE guid = '%u'", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADRANDOMBG, "SELECT guid FROM character_battleground_random WHERE guid = '%u'", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADARENASTATS, "SELECT slot, personal_rating, matchmaker_rating FROM character_arena_stats WHERE guid = '%u' ORDER BY slot ASC", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBANNED, "SELECT guid FROM character_banned WHERE guid = %u AND active = 1", GUID_LOPART(m_guid));
+ {
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_DECLINEDNAMES);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES, stmt);
+ }
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_GUILD);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADGUILD, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_ARENAINFO);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADARENAINFO, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_ACHIEVEMENTS);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_CRITERIAPROGRESS);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_EQUIPMENTSETS);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_BGDATA);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADBGDATA, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_GLYPHS);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADGLYPHS, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_TALENTS);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADTALENTS, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_ACCOUNTDATA);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADACCOUNTDATA, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_SKILLS);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADSKILLS, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_RANDOMBG);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADRANDOMBG, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_ARENASTATS);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADARENASTATS, stmt);
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_BANNED);
+ stmt->setUInt32(0, lowGuid);
+ res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADBANNED, stmt);
return res;
}
@@ -605,7 +692,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
SendPacket(&data);
// load player specific part before send times
- LoadAccountData(holder->GetResult(PLAYER_LOGIN_QUERY_LOADACCOUNTDATA),PER_CHARACTER_CACHE_MASK);
+ LoadAccountData(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADACCOUNTDATA), PER_CHARACTER_CACHE_MASK);
SendAccountDataTimes(PER_CHARACTER_CACHE_MASK);
data.Initialize(SMSG_FEATURE_SYSTEM_STATUS, 2); // added in 2.2.0
@@ -652,13 +739,10 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
}
//QueryResult *result = CharacterDatabase.PQuery("SELECT guildid,rank FROM guild_member WHERE guid = '%u'",pCurrChar->GetGUIDLow());
- QueryResult resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD);
-
- if (resultGuild)
+ if (PreparedQueryResult resultGuild = holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADGUILD))
{
- Field *fields = resultGuild->Fetch();
- pCurrChar->SetInGuild(fields[0].GetUInt32());
- pCurrChar->SetRank(fields[1].GetUInt32());
+ pCurrChar->SetInGuild(resultGuild->GetUInt32(0));
+ pCurrChar->SetRank(resultGuild->GetUInt32(1));
}
else if (pCurrChar->GetGuildId()) // clear guild related fields in case wrong data about non existed membership
{
diff --git a/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp b/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp
index 63d5cff8cb4..0ed2a90b25c 100644
--- a/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp
@@ -1071,7 +1071,7 @@ void WorldSession::HandleSetActionButtonOpcode(WorldPacket& recv_data)
sLog.outError("MISC: Unknown action button type %u for action %u into button %u", type, action, button);
return;
}
- GetPlayer()->addActionButton(button, action, type);
+ GetPlayer()->addActionButton(button, action, type, uint8(GetPlayer()->GetActiveSpec()));
}
}
diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp
index b5ce7dae24c..9c448825f61 100644
--- a/src/server/game/Server/WorldSession.cpp
+++ b/src/server/game/Server/WorldSession.cpp
@@ -583,13 +583,12 @@ void WorldSession::SendAuthWaitQue(uint32 position)
void WorldSession::LoadGlobalAccountData()
{
- LoadAccountData(
- CharacterDatabase.PQuery("SELECT type, time, data FROM account_data WHERE account='%u'", GetAccountId()),
- GLOBAL_CACHE_MASK
-);
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_ACCOUNT_DATA);
+ stmt->setUInt32(0, GetAccountId());
+ LoadAccountData(CharacterDatabase.Query(stmt), GLOBAL_CACHE_MASK);
}
-void WorldSession::LoadAccountData(QueryResult result, uint32 mask)
+void WorldSession::LoadAccountData(PreparedQueryResult result, uint32 mask)
{
for (uint32 i = 0; i < NUM_ACCOUNT_DATA_TYPES; ++i)
if (mask & (1 << i))
@@ -600,9 +599,7 @@ void WorldSession::LoadAccountData(QueryResult result, uint32 mask)
do
{
- Field *fields = result->Fetch();
-
- uint32 type = fields[0].GetUInt32();
+ uint32 type = result->GetUInt32(0);
if (type >= NUM_ACCOUNT_DATA_TYPES)
{
sLog.outError("Table `%s` have invalid account data type (%u), ignore.",
@@ -617,8 +614,8 @@ void WorldSession::LoadAccountData(QueryResult result, uint32 mask)
continue;
}
- m_accountData[type].Time = fields[1].GetUInt32();
- m_accountData[type].Data = fields[2].GetCppString();
+ m_accountData[type].Time = result->GetUInt32(1);
+ m_accountData[type].Data = result->GetString(2);
} while (result->NextRow());
}
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index 14ab8585796..965b398563b 100644
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -234,7 +234,7 @@ class WorldSession
void SetAccountData(AccountDataType type, time_t time_, std::string data);
void SendAccountDataTimes(uint32 mask);
void LoadGlobalAccountData();
- void LoadAccountData(QueryResult result, uint32 mask);
+ void LoadAccountData(PreparedQueryResult result, uint32 mask);
void LoadTutorialsData();
void SendTutorialsData();
void SaveTutorialsData(SQLTransaction& trans);
diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.cpp b/src/server/shared/Database/Implementation/CharacterDatabase.cpp
index 9a8157ad9f1..0d792848197 100644
--- a/src/server/shared/Database/Implementation/CharacterDatabase.cpp
+++ b/src/server/shared/Database/Implementation/CharacterDatabase.cpp
@@ -44,9 +44,51 @@ bool CharacterDatabaseConnection::Open(const std::string& infoString)
PrepareStatement(CHAR_ADD_BAN, "INSERT INTO character_banned VALUES (?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+?, ?, ?, 1)");
PrepareStatement(CHAR_SET_NOT_BANNED, "UPDATE character_banned SET active = 0 WHERE guid = ?");
PrepareStatement(CHAR_GET_BANINFO, "SELECT FROM_UNIXTIME(bandate), unbandate-bandate, active, unbandate, banreason, bannedby FROM character_banned WHERE guid = ? ORDER BY bandate ASC");
- PrepareStatement(CHAR_GET_GUID_BY_NAME_FILTER, "SELECT guid, name FROM characters WHERE name LIKE CONCAT('%%', ?, '%%')");
+ PrepareStatement(CHAR_GET_GUID_BY_NAME_FILTER, "SELECT guid, name FROM characters WHERE name LIKE CONCAT('%', ?, '%')");
PrepareStatement(CHAR_GET_BANINFO_LIST, "SELECT bandate, unbandate, bannedby, banreason FROM character_banned WHERE guid = ? ORDER BY unbandate");
PrepareStatement(CHAR_GET_BANNED_NAME, "SELECT characters.name FROM characters, character_banned WHERE character_banned.guid = ? AND character_banned.guid = characters.guid");
+ PrepareStatement(CHAR_LOAD_PLAYER, "SELECT guid, account, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags,"
+ "position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost,"
+ "resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, instance_mode_mask,"
+ "arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk,"
+ "health, power1, power2, power3, power4, power5, power6, power7, instance_id, speccount, activespec, exploredZones, equipmentCache, ammoId, knownTitles, actionBars FROM characters WHERE guid = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_GROUP, "SELECT guid FROM group_member WHERE memberGuid = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_BOUNDINSTANCES, "SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_AURAS, "SELECT caster_guid, spell, effect_mask, recalculate_mask, stackcount, amount0, amount1, amount2, "
+ "base_amount0, base_amount1, base_amount2, maxduration, remaintime, remaincharges FROM character_aura WHERE guid = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_SPELLS, "SELECT spell, active, disabled FROM character_spell WHERE guid = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_QUESTSTATUS, "SELECT quest, status, rewarded, explored, timer, mobcount1, mobcount2, mobcount3, mobcount4, "
+ "itemcount1, itemcount2, itemcount3, itemcount4 FROM character_queststatus WHERE guid = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_DAILYQUESTSTATUS, "SELECT quest, time FROM character_queststatus_daily WHERE guid = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_WEKLYQUESTSTATUS, "SELECT quest FROM character_queststatus_weekly WHERE guid = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_REPUTATION, "SELECT faction,standing,flags FROM character_reputation WHERE guid = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_INVENTORY, "SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text, bag, slot, "
+ "item, item_template FROM character_inventory JOIN item_instance ON character_inventory.item = item_instance.guid WHERE character_inventory.guid = ? ORDER BY bag, slot");
+ PrepareStatement(CHAR_LOAD_PLAYER_ACTIONS, "SELECT a.button, a.action, a.type, a.spec FROM character_action as a WHERE a.guid = ? ORDER BY button");
+ PrepareStatement(CHAR_LOAD_PLAYER_MAILCOUNT, "SELECT COUNT(id) FROM mail WHERE receiver = ? AND (checked & 1) = 0 AND deliver_time <= ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_MAILDATE, "SELECT MIN(deliver_time) FROM mail WHERE receiver = ? AND (checked & 1) = 0");
+ PrepareStatement(CHAR_LOAD_PLAYER_SOCIALLIST, "SELECT friend, flags, note FROM character_social WHERE guid = ? LIMIT 255");
+ PrepareStatement(CHAR_LOAD_PLAYER_HOMEBIND, "SELECT map, zone, position_x, position_y, position_z FROM character_homebind WHERE guid = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_SPELLCOOLDOWNS, "SELECT spell, item, time FROM character_spell_cooldown WHERE guid = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_DECLINEDNAMES, "SELECT genitive, dative, accusative, instrumental, prepositional FROM character_declinedname WHERE guid = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_GUILD, "SELECT guildid,rank FROM guild_member WHERE guid = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_ARENAINFO, "SELECT arenateamid, played_week, played_season, wons_season FROM arena_team_member WHERE guid = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_ACHIEVEMENTS, "SELECT achievement, date FROM character_achievement WHERE guid = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_CRITERIAPROGRESS, "SELECT criteria, counter, date FROM character_achievement_progress WHERE guid = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_EQUIPMENTSETS, "SELECT setguid, setindex, name, iconname, item0, item1, item2, item3, item4, item5, item6, item7, item8, "
+ "item9, item10, item11, item12, item13, item14, item15, item16, item17, item18 FROM character_equipmentsets WHERE guid = ? ORDER BY setindex");
+ PrepareStatement(CHAR_LOAD_PLAYER_BGDATA, "SELECT instance_id, team, join_x, join_y, join_z, join_o, join_map, taxi_start, taxi_end, mount_spell FROM character_battleground_data WHERE guid = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_GLYPHS, "SELECT spec, glyph1, glyph2, glyph3, glyph4, glyph5, glyph6 FROM character_glyphs WHERE guid = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_TALENTS, "SELECT spell, spec FROM character_talent WHERE guid = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_ACCOUNTDATA, "SELECT type, time, data FROM character_account_data WHERE guid = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_SKILLS, "SELECT skill, value, max FROM character_skills WHERE guid = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_RANDOMBG, "SELECT guid FROM character_battleground_random WHERE guid = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_ARENASTATS, "SELECT slot, personal_rating, matchmaker_rating FROM character_arena_stats WHERE guid = ? ORDER BY slot ASC");
+ PrepareStatement(CHAR_LOAD_PLAYER_BANNED, "SELECT guid FROM character_banned WHERE guid = ? AND active = 1");
+ PrepareStatement(CHAR_LOAD_ACCOUNT_DATA, "SELECT type, time, data FROM account_data WHERE account = ?");
+ PrepareStatement(CHAR_LOAD_PLAYER_MAILITEMS, "SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text, item_guid, item_template, owner_guid FROM mail_items JOIN item_instance ON item_guid = guid WHERE mail_id = ?");
+ PrepareStatement(CHAR_LOAD_AUCTION_ITEMS, "SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text, itemguid, item_template FROM auctionhouse JOIN item_instance ON itemguid = guid");
+ PrepareStatement(CHAR_LOAD_GUILD_BANK_ITEMS, "SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text, TabId, SlotId, item_guid, item_entry, guildid FROM guild_bank_item JOIN item_instance ON item_guid = guid");
return true;
}
diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.h b/src/server/shared/Database/Implementation/CharacterDatabase.h
index 1e855f135b4..3df4c9c0d35 100644
--- a/src/server/shared/Database/Implementation/CharacterDatabase.h
+++ b/src/server/shared/Database/Implementation/CharacterDatabase.h
@@ -61,6 +61,40 @@ enum CharacterDatabaseStatements
CHAR_GET_GUID_BY_NAME_FILTER,
CHAR_GET_BANINFO_LIST,
CHAR_GET_BANNED_NAME,
+ CHAR_LOAD_PLAYER,
+ CHAR_LOAD_PLAYER_GROUP,
+ CHAR_LOAD_PLAYER_BOUNDINSTANCES,
+ CHAR_LOAD_PLAYER_AURAS,
+ CHAR_LOAD_PLAYER_SPELLS,
+ CHAR_LOAD_PLAYER_QUESTSTATUS,
+ CHAR_LOAD_PLAYER_DAILYQUESTSTATUS,
+ CHAR_LOAD_PLAYER_WEKLYQUESTSTATUS,
+ CHAR_LOAD_PLAYER_REPUTATION,
+ CHAR_LOAD_PLAYER_INVENTORY,
+ CHAR_LOAD_PLAYER_ACTIONS,
+ CHAR_LOAD_PLAYER_MAILCOUNT,
+ CHAR_LOAD_PLAYER_MAILDATE,
+ CHAR_LOAD_PLAYER_SOCIALLIST,
+ CHAR_LOAD_PLAYER_HOMEBIND,
+ CHAR_LOAD_PLAYER_SPELLCOOLDOWNS,
+ CHAR_LOAD_PLAYER_DECLINEDNAMES,
+ CHAR_LOAD_PLAYER_GUILD,
+ CHAR_LOAD_PLAYER_ARENAINFO,
+ CHAR_LOAD_PLAYER_ACHIEVEMENTS,
+ CHAR_LOAD_PLAYER_CRITERIAPROGRESS,
+ CHAR_LOAD_PLAYER_EQUIPMENTSETS,
+ CHAR_LOAD_PLAYER_BGDATA,
+ CHAR_LOAD_PLAYER_GLYPHS,
+ CHAR_LOAD_PLAYER_TALENTS,
+ CHAR_LOAD_PLAYER_ACCOUNTDATA,
+ CHAR_LOAD_PLAYER_SKILLS,
+ CHAR_LOAD_PLAYER_RANDOMBG,
+ CHAR_LOAD_PLAYER_ARENASTATS,
+ CHAR_LOAD_PLAYER_BANNED,
+ CHAR_LOAD_ACCOUNT_DATA,
+ CHAR_LOAD_PLAYER_MAILITEMS,
+ CHAR_LOAD_AUCTION_ITEMS,
+ CHAR_LOAD_GUILD_BANK_ITEMS,
MAX_CHARACTERDATABASE_STATEMENTS,
};
diff --git a/src/server/shared/Database/QueryHolder.cpp b/src/server/shared/Database/QueryHolder.cpp
index e0411d242c3..26ccce3853c 100644
--- a/src/server/shared/Database/QueryHolder.cpp
+++ b/src/server/shared/Database/QueryHolder.cpp
@@ -64,6 +64,26 @@ bool SQLQueryHolder::SetPQuery(size_t index, const char *format, ...)
return SetQuery(index, szQuery);
}
+bool SQLQueryHolder::SetPreparedQuery(size_t index, PreparedStatement* stmt)
+{
+ if (m_queries.size() <= index)
+ {
+ sLog.outError("Query index (%zu) out of range (size: %u) for prepared statement", index, (uint32)m_queries.size());
+ return false;
+ }
+
+ /// not executed yet, just stored (it's not called a holder for nothing)
+ SQLElementData element;
+ element.type = SQL_ELEMENT_PREPARED;
+ element.element.stmt = stmt;
+
+ SQLResultSetUnion result;
+ result.presult = NULL;
+
+ m_queries[index] = SQLResultPair(element, result);
+ return true;
+}
+
QueryResult SQLQueryHolder::GetResult(size_t index)
{
// Don't call to this function if the index is of an ad-hoc statement