Core/DBLayer: Converted player login queries into prepared statements
Core/DBLayer: Added missing implementation for SQLQueryHolder::SetPreparedQuery --HG-- branch : trunk
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ void Bag::SaveToDB(SQLTransaction& trans)
|
||||
Item::SaveToDB(trans);
|
||||
}
|
||||
|
||||
bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult result, uint32 entry)
|
||||
bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, PreparedQueryResult result, uint32 entry)
|
||||
{
|
||||
if (!Item::LoadFromDB(guid, owner_guid, result, entry))
|
||||
return false;
|
||||
|
||||
@@ -56,7 +56,7 @@ class Bag : public Item
|
||||
// overwrite virtual Item::SaveToDB
|
||||
void SaveToDB(SQLTransaction& trans);
|
||||
// overwrite virtual Item::LoadFromDB
|
||||
bool LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult result, uint32 entry);
|
||||
bool LoadFromDB(uint32 guid, uint64 owner_guid, PreparedQueryResult result, uint32 entry);
|
||||
// overwrite virtual Item::DeleteFromDB
|
||||
void DeleteFromDB(SQLTransaction& trans);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -150,40 +150,40 @@ enum ItemProtoFlags
|
||||
|
||||
enum ItemFieldFlags
|
||||
{
|
||||
ITEM_FLAG_SOULBOUND = 0x00000001, // Item is soulbound and cannot be traded
|
||||
ITEM_FLAG_SOULBOUND = 0x00000001, // Item is soulbound and cannot be traded <<--
|
||||
ITEM_FLAG_UNK1 = 0x00000002, // ?
|
||||
ITEM_FLAG_UNLOCKED = 0x00000004, // Item had lock but can be opened now
|
||||
ITEM_FLAG_WRAPPED = 0x00000008, // Item is wrapped and contains another item
|
||||
ITEM_FLAG_UNK3 = 0x00000010, // ?
|
||||
ITEM_FLAG_UNK4 = 0x00000020, // ?
|
||||
ITEM_FLAG_UNK5 = 0x00000040, // ?
|
||||
ITEM_FLAG_UNK6 = 0x00000080, // ?
|
||||
ITEM_FLAG_UNK7 = 0x00000100, // ?
|
||||
ITEM_FLAG_UNK2 = 0x00000010, // ?
|
||||
ITEM_FLAG_UNK3 = 0x00000020, // ?
|
||||
ITEM_FLAG_UNK4 = 0x00000040, // ?
|
||||
ITEM_FLAG_UNK5 = 0x00000080, // ?
|
||||
ITEM_FLAG_BOP_TRADEABLE = 0x00000100, // Allows trading soulbound items
|
||||
ITEM_FLAG_READABLE = 0x00000200, // Opens text page when right clicked
|
||||
ITEM_FLAG_UNK9 = 0x00000400, // ?
|
||||
ITEM_FLAG_UNK10 = 0x00000800, // ?
|
||||
ITEM_FLAG_UNK6 = 0x00000400, // ?
|
||||
ITEM_FLAG_UNK7 = 0x00000800, // ?
|
||||
ITEM_FLAG_REFUNDABLE = 0x00001000, // Item can be returned to vendor for its original cost (extended cost)
|
||||
ITEM_FLAG_UNK11 = 0x00002000, // ?
|
||||
ITEM_FLAG_UNK12 = 0x00004000, // ?
|
||||
ITEM_FLAG_UNK13 = 0x00008000, // ?
|
||||
ITEM_FLAG_UNK14 = 0x00010000, // ?
|
||||
ITEM_FLAG_UNK15 = 0x00020000, // ?
|
||||
ITEM_FLAG_UNK16 = 0x00040000, // ?
|
||||
ITEM_FLAG_UNK17 = 0x00080000, // ?
|
||||
ITEM_FLAG_UNK18 = 0x00100000, // ?
|
||||
ITEM_FLAG_UNK19 = 0x00200000, // ?
|
||||
ITEM_FLAG_UNK20 = 0x00400000, // ?
|
||||
ITEM_FLAG_UNK21 = 0x00800000, // ?
|
||||
ITEM_FLAG_UNK22 = 0x01000000, // ?
|
||||
ITEM_FLAG_UNK23 = 0x02000000, // ?
|
||||
ITEM_FLAG_UNK24 = 0x04000000, // ?
|
||||
ITEM_FLAG_UNK25 = 0x08000000, // ?
|
||||
ITEM_FLAG_UNK26 = 0x10000000, // ?
|
||||
ITEM_FLAG_UNK27 = 0x20000000, // ?
|
||||
ITEM_FLAG_UNK28 = 0x40000000, // ?
|
||||
ITEM_FLAG_BOP_TRADEABLE = 0x80000000, // ?
|
||||
ITEM_FLAG_UNK8 = 0x00002000, // ?
|
||||
ITEM_FLAG_UNK9 = 0x00004000, // ?
|
||||
ITEM_FLAG_UNK10 = 0x00008000, // ?
|
||||
ITEM_FLAG_UNK11 = 0x00010000, // ?
|
||||
ITEM_FLAG_UNK12 = 0x00020000, // ?
|
||||
ITEM_FLAG_UNK13 = 0x00040000, // ?
|
||||
ITEM_FLAG_UNK14 = 0x00080000, // ?
|
||||
ITEM_FLAG_UNK15 = 0x00100000, // ?
|
||||
ITEM_FLAG_UNK16 = 0x00200000, // ?
|
||||
ITEM_FLAG_UNK17 = 0x00400000, // ?
|
||||
ITEM_FLAG_UNK18 = 0x00800000, // ?
|
||||
ITEM_FLAG_UNK19 = 0x01000000, // ?
|
||||
ITEM_FLAG_UNK20 = 0x02000000, // ?
|
||||
ITEM_FLAG_UNK21 = 0x04000000, // ?
|
||||
ITEM_FLAG_UNK22 = 0x08000000, // ?
|
||||
ITEM_FLAG_UNK23 = 0x10000000, // ?
|
||||
ITEM_FLAG_UNK24 = 0x20000000, // ?
|
||||
ITEM_FLAG_UNK25 = 0x40000000, // ?
|
||||
ITEM_FLAG_UNK26 = 0x80000000, // ?
|
||||
|
||||
ITEM_FLAG_MAIL_TEXT_MASK = ITEM_FLAG_READABLE | ITEM_FLAG_UNK13 | ITEM_FLAG_UNK14
|
||||
ITEM_FLAG_MAIL_TEXT_MASK = ITEM_FLAG_READABLE | ITEM_FLAG_UNK13 | ITEM_FLAG_UNK14,
|
||||
};
|
||||
|
||||
enum ItemFlagsExtra
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user