Implement QueryResult_AutoPtr type which is ACE's reference counted auto_ptr(ACE_Refcounted_Auto_Ptr) for QueryResult pointers.
Use this auto_ptr for every DB queries(except QueryNamedResult yet). This patch guarantees NO memory leaks from QueryResult pointers. Thanks to raczman for the idea and for the helping to make this patch. --HG-- branch : trunk
This commit is contained in:
+38
-107
@@ -1468,7 +1468,7 @@ void Player::setDeathState(DeathState s)
|
||||
}
|
||||
}
|
||||
|
||||
bool Player::BuildEnumData( QueryResult * result, WorldPacket * p_data )
|
||||
bool Player::BuildEnumData( QueryResult_AutoPtr result, WorldPacket * p_data )
|
||||
{
|
||||
// 0 1 2 3 4 5 6 7
|
||||
// "SELECT characters.guid, characters.name, characters.race, characters.class, characters.gender, characters.playerBytes, characters.playerBytes2, characters.level, "
|
||||
@@ -3690,7 +3690,7 @@ void Player::RemoveAllSpellCooldown()
|
||||
}
|
||||
}
|
||||
|
||||
void Player::_LoadSpellCooldowns(QueryResult *result)
|
||||
void Player::_LoadSpellCooldowns(QueryResult_AutoPtr result)
|
||||
{
|
||||
// some cooldowns can be already set at aura loading...
|
||||
|
||||
@@ -3723,8 +3723,6 @@ void Player::_LoadSpellCooldowns(QueryResult *result)
|
||||
sLog.outDebug("Player (GUID: %u) spell %u, item %u cooldown loaded (%u secs).", GetGUIDLow(), spell_id, item_id, uint32(db_time-curTime));
|
||||
}
|
||||
while( result->NextRow() );
|
||||
|
||||
delete result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4166,11 +4164,10 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
|
||||
LeaveAllArenaTeams(playerguid);
|
||||
|
||||
// the player was uninvited already on logout so just remove from group
|
||||
QueryResult *resultGroup = CharacterDatabase.PQuery("SELECT leaderGuid FROM group_member WHERE memberGuid='%u'", guid);
|
||||
QueryResult_AutoPtr resultGroup = CharacterDatabase.PQuery("SELECT leaderGuid FROM group_member WHERE memberGuid='%u'", guid);
|
||||
if(resultGroup)
|
||||
{
|
||||
uint64 leaderGuid = MAKE_NEW_GUID((*resultGroup)[0].GetUInt32(), 0, HIGHGUID_PLAYER);
|
||||
delete resultGroup;
|
||||
Group* group = objmgr.GetGroupByLeader(leaderGuid);
|
||||
if(group)
|
||||
{
|
||||
@@ -4182,7 +4179,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
|
||||
RemovePetitionsAndSigns(playerguid, 10);
|
||||
|
||||
// return back all mails with COD and Item 0 1 2 3 4 5 6 7
|
||||
QueryResult *resultMail = CharacterDatabase.PQuery("SELECT id,messageType,mailTemplateId,sender,subject,itemTextId,money,has_items FROM mail WHERE receiver='%u' AND has_items<>0 AND cod<>0", guid);
|
||||
QueryResult_AutoPtr resultMail = CharacterDatabase.PQuery("SELECT id,messageType,mailTemplateId,sender,subject,itemTextId,money,has_items FROM mail WHERE receiver='%u' AND has_items<>0 AND cod<>0", guid);
|
||||
if(resultMail)
|
||||
{
|
||||
do
|
||||
@@ -4217,7 +4214,7 @@ 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 data,item_guid,item_template FROM mail_items JOIN item_instance ON item_guid = guid WHERE mail_id='%u'", mail_id);
|
||||
QueryResult_AutoPtr resultItems = CharacterDatabase.PQuery("SELECT data,item_guid,item_template FROM mail_items JOIN item_instance ON item_guid = guid WHERE mail_id='%u'", mail_id);
|
||||
if(resultItems)
|
||||
{
|
||||
do
|
||||
@@ -4245,8 +4242,6 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
|
||||
draft.AddItem(pItem);
|
||||
}
|
||||
while (resultItems->NextRow());
|
||||
|
||||
delete resultItems;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4257,13 +4252,11 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
|
||||
draft.AddMoney(money).SendReturnToSender(pl_account, guid, sender);
|
||||
}
|
||||
while (resultMail->NextRow());
|
||||
|
||||
delete resultMail;
|
||||
}
|
||||
|
||||
// unsummon and delete for pets in world is not required: player deleted from CLI or character list with not loaded pet.
|
||||
// Get guids of character's pets, will deleted in transaction
|
||||
QueryResult *resultPets = CharacterDatabase.PQuery("SELECT id FROM character_pet WHERE owner = '%u'",guid);
|
||||
QueryResult_AutoPtr resultPets = CharacterDatabase.PQuery("SELECT id FROM character_pet WHERE owner = '%u'",guid);
|
||||
|
||||
// NOW we can finally clear other DB data related to character
|
||||
CharacterDatabase.BeginTransaction();
|
||||
@@ -4275,7 +4268,6 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
|
||||
uint32 petguidlow = fields3[0].GetUInt32();
|
||||
Pet::DeleteFromDB(petguidlow);
|
||||
} while (resultPets->NextRow());
|
||||
delete resultPets;
|
||||
}
|
||||
|
||||
CharacterDatabase.PExecute("DELETE FROM characters WHERE guid = '%u'",guid);
|
||||
@@ -6545,22 +6537,20 @@ void Player::ModifyArenaPoints(int32 value)
|
||||
|
||||
uint32 Player::GetGuildIdFromDB(uint64 guid)
|
||||
{
|
||||
QueryResult* result = CharacterDatabase.PQuery("SELECT guildid FROM guild_member WHERE guid='%u'", GUID_LOPART(guid));
|
||||
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT guildid FROM guild_member WHERE guid='%u'", GUID_LOPART(guid));
|
||||
if(!result)
|
||||
return 0;
|
||||
|
||||
uint32 id = result->Fetch()[0].GetUInt32();
|
||||
delete result;
|
||||
return id;
|
||||
}
|
||||
|
||||
uint32 Player::GetRankFromDB(uint64 guid)
|
||||
{
|
||||
QueryResult *result = CharacterDatabase.PQuery( "SELECT rank FROM guild_member WHERE guid='%u'", GUID_LOPART(guid) );
|
||||
QueryResult_AutoPtr result = CharacterDatabase.PQuery( "SELECT rank FROM guild_member WHERE guid='%u'", GUID_LOPART(guid) );
|
||||
if( result )
|
||||
{
|
||||
uint32 v = result->Fetch()[0].GetUInt32();
|
||||
delete result;
|
||||
return v;
|
||||
}
|
||||
else
|
||||
@@ -6569,24 +6559,22 @@ uint32 Player::GetRankFromDB(uint64 guid)
|
||||
|
||||
uint32 Player::GetArenaTeamIdFromDB(uint64 guid, uint8 type)
|
||||
{
|
||||
QueryResult *result = CharacterDatabase.PQuery("SELECT arena_team_member.arenateamid FROM arena_team_member JOIN arena_team ON arena_team_member.arenateamid = arena_team.arenateamid WHERE guid='%u' AND type='%u' LIMIT 1", GUID_LOPART(guid), type);
|
||||
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT arena_team_member.arenateamid FROM arena_team_member JOIN arena_team ON arena_team_member.arenateamid = arena_team.arenateamid WHERE guid='%u' AND type='%u' LIMIT 1", GUID_LOPART(guid), type);
|
||||
if(!result)
|
||||
return 0;
|
||||
|
||||
uint32 id = (*result)[0].GetUInt32();
|
||||
delete result;
|
||||
return id;
|
||||
}
|
||||
|
||||
uint32 Player::GetZoneIdFromDB(uint64 guid)
|
||||
{
|
||||
uint32 guidLow = GUID_LOPART(guid);
|
||||
QueryResult *result = CharacterDatabase.PQuery( "SELECT zone FROM characters WHERE guid='%u'", guidLow );
|
||||
QueryResult_AutoPtr result = CharacterDatabase.PQuery( "SELECT zone FROM characters WHERE guid='%u'", guidLow );
|
||||
if (!result)
|
||||
return 0;
|
||||
Field* fields = result->Fetch();
|
||||
uint32 zone = fields[0].GetUInt32();
|
||||
delete result;
|
||||
|
||||
if (!zone)
|
||||
{
|
||||
@@ -6599,7 +6587,6 @@ uint32 Player::GetZoneIdFromDB(uint64 guid)
|
||||
float posx = fields[1].GetFloat();
|
||||
float posy = fields[2].GetFloat();
|
||||
float posz = fields[3].GetFloat();
|
||||
delete result;
|
||||
|
||||
zone = MapManager::Instance().GetZoneId(map,posx,posy,posz);
|
||||
|
||||
@@ -6612,13 +6599,12 @@ uint32 Player::GetZoneIdFromDB(uint64 guid)
|
||||
|
||||
uint32 Player::GetLevelFromDB(uint64 guid)
|
||||
{
|
||||
QueryResult *result = CharacterDatabase.PQuery("SELECT level FROM characters WHERE guid='%u'", GUID_LOPART(guid));
|
||||
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT level FROM characters WHERE guid='%u'", GUID_LOPART(guid));
|
||||
if (!result)
|
||||
return 0;
|
||||
|
||||
Field* fields = result->Fetch();
|
||||
uint8 level = fields[0].GetUInt8();
|
||||
delete result;
|
||||
|
||||
return level;
|
||||
}
|
||||
@@ -15158,9 +15144,8 @@ void Player::SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, uint64 guid, u
|
||||
/*** LOAD SYSTEM ***/
|
||||
/*********************************************************/
|
||||
|
||||
bool Player::MinimalLoadFromDB( QueryResult *result, uint32 guid )
|
||||
bool Player::MinimalLoadFromDB( QueryResult_AutoPtr result, uint32 guid )
|
||||
{
|
||||
bool delete_result = true;
|
||||
if (!result)
|
||||
{
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11
|
||||
@@ -15168,16 +15153,12 @@ bool Player::MinimalLoadFromDB( QueryResult *result, uint32 guid )
|
||||
if (!result)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
delete_result = false;
|
||||
|
||||
Field *fields = result->Fetch();
|
||||
|
||||
if (!LoadValues( fields[1].GetString()))
|
||||
{
|
||||
sLog.outError("Player #%d have broken data in `data` field. Can't be loaded for character list.",GUID_LOPART(guid));
|
||||
if (delete_result)
|
||||
delete result;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -15206,9 +15187,6 @@ bool Player::MinimalLoadFromDB( QueryResult *result, uint32 guid )
|
||||
|
||||
_LoadBoundInstances();*/
|
||||
|
||||
if (delete_result)
|
||||
delete result;
|
||||
|
||||
for (uint8 i = 0; i < PLAYER_SLOTS_COUNT; i++)
|
||||
m_items[i] = NULL;
|
||||
|
||||
@@ -15218,7 +15196,7 @@ bool Player::MinimalLoadFromDB( QueryResult *result, uint32 guid )
|
||||
return true;
|
||||
}
|
||||
|
||||
void Player::_LoadDeclinedNames(QueryResult* result)
|
||||
void Player::_LoadDeclinedNames(QueryResult_AutoPtr result)
|
||||
{
|
||||
if(!result)
|
||||
return;
|
||||
@@ -15230,11 +15208,9 @@ void Player::_LoadDeclinedNames(QueryResult* result)
|
||||
Field *fields = result->Fetch();
|
||||
for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
|
||||
m_declinedname->name[i] = fields[i].GetCppString();
|
||||
|
||||
delete result;
|
||||
}
|
||||
|
||||
void Player::_LoadArenaTeamInfo(QueryResult *result)
|
||||
void Player::_LoadArenaTeamInfo(QueryResult_AutoPtr result)
|
||||
{
|
||||
// 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);
|
||||
@@ -15268,10 +15244,9 @@ void Player::_LoadArenaTeamInfo(QueryResult *result)
|
||||
m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (arenaSlot * ARENA_TEAM_END) + ARENA_TEAM_PERSONAL_RATING] = personal_rating; // Personal Rating
|
||||
|
||||
}while (result->NextRow());
|
||||
delete result;
|
||||
}
|
||||
|
||||
void Player::_LoadEquipmentSets(QueryResult *result)
|
||||
void Player::_LoadEquipmentSets(QueryResult_AutoPtr 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)
|
||||
@@ -15300,10 +15275,9 @@ void Player::_LoadEquipmentSets(QueryResult *result)
|
||||
if(count >= MAX_EQUIPMENT_SET_INDEX) // client limit
|
||||
break;
|
||||
} while (result->NextRow());
|
||||
delete result;
|
||||
}
|
||||
|
||||
void Player::_LoadBGData(QueryResult* result)
|
||||
void Player::_LoadBGData(QueryResult_AutoPtr result)
|
||||
{
|
||||
if (!result)
|
||||
return;
|
||||
@@ -15321,13 +15295,11 @@ void Player::_LoadBGData(QueryResult* result)
|
||||
m_bgData.taxiPath[0] = fields[7].GetUInt32();
|
||||
m_bgData.taxiPath[1] = fields[8].GetUInt32();
|
||||
m_bgData.mountSpell = fields[9].GetUInt32();
|
||||
|
||||
delete result;
|
||||
}
|
||||
|
||||
bool Player::LoadPositionFromDB(uint32& mapid, float& x,float& y,float& z,float& o, bool& in_flight, uint64 guid)
|
||||
{
|
||||
QueryResult *result = CharacterDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map,taxi_path FROM characters WHERE guid = '%u'",GUID_LOPART(guid));
|
||||
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map,taxi_path FROM characters WHERE guid = '%u'",GUID_LOPART(guid));
|
||||
if(!result)
|
||||
return false;
|
||||
|
||||
@@ -15340,13 +15312,12 @@ bool Player::LoadPositionFromDB(uint32& mapid, float& x,float& y,float& z,float&
|
||||
mapid = fields[4].GetUInt32();
|
||||
in_flight = !fields[5].GetCppString().empty();
|
||||
|
||||
delete result;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Player::LoadValuesArrayFromDB(Tokens& data, uint64 guid)
|
||||
{
|
||||
QueryResult *result = CharacterDatabase.PQuery("SELECT data FROM characters WHERE guid='%u'",GUID_LOPART(guid));
|
||||
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT data FROM characters WHERE guid='%u'",GUID_LOPART(guid));
|
||||
if( !result )
|
||||
return false;
|
||||
|
||||
@@ -15354,8 +15325,6 @@ bool Player::LoadValuesArrayFromDB(Tokens& data, uint64 guid)
|
||||
|
||||
data = StrSplit(fields[0].GetCppString(), " ");
|
||||
|
||||
delete result;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -15398,7 +15367,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
||||
{
|
||||
//// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
||||
//QueryResult *result = CharacterDatabase.PQuery("SELECT guid, account, data, 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, dungeon_difficulty, arena_pending_points, instance_id, speccount, activespec FROM characters WHERE guid = '%u'", guid);
|
||||
QueryResult *result = holder->GetResult(PLAYER_LOGIN_QUERY_LOADFROM);
|
||||
QueryResult_AutoPtr result = holder->GetResult(PLAYER_LOGIN_QUERY_LOADFROM);
|
||||
|
||||
if(!result)
|
||||
{
|
||||
@@ -15415,7 +15384,6 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
||||
if( dbAccountId != GetSession()->GetAccountId() )
|
||||
{
|
||||
sLog.outError("Player (GUID: %u) loading from wrong account (is: %u, should be: %u)",guid,GetSession()->GetAccountId(),dbAccountId);
|
||||
delete result;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -15427,7 +15395,6 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
||||
if (ObjectMgr::CheckPlayerName(m_name) != CHAR_NAME_SUCCESS ||
|
||||
(GetSession()->GetSecurity() == SEC_PLAYER && objmgr.IsReservedName(m_name)))
|
||||
{
|
||||
delete result;
|
||||
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid ='%u'", uint32(AT_LOGIN_RENAME),guid);
|
||||
return false;
|
||||
}
|
||||
@@ -15435,7 +15402,6 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
||||
if(!LoadValues( fields[2].GetString()))
|
||||
{
|
||||
sLog.outError("Player #%d have broken data in `data` field. Can't be loaded.", GUID_LOPART(guid));
|
||||
delete result;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -15485,10 +15451,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
||||
|
||||
// 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)))
|
||||
{
|
||||
delete result;
|
||||
return false;
|
||||
}
|
||||
|
||||
InitPrimaryProfessions(); // to max set before any spell loaded
|
||||
|
||||
@@ -15720,7 +15683,6 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
||||
if (!map)
|
||||
{
|
||||
sLog.outError("ERROR: Player (guidlow %d) has invalid default map coordinates (X: %f Y: %f Z: %f O: %f). or instance couldn't be created",guid,GetPositionX(),GetPositionY(),GetPositionZ(),GetOrientation());
|
||||
delete result;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -15860,7 +15822,6 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
||||
|
||||
m_specsCount = fields[42].GetUInt8();
|
||||
m_activeSpec = fields[43].GetUInt8();
|
||||
delete result;
|
||||
|
||||
// sanity check
|
||||
if (m_specsCount > MAX_TALENT_SPECS || m_activeSpec > MAX_TALENT_SPEC ||
|
||||
@@ -16023,7 +15984,7 @@ bool Player::isAllowedToLoot(Creature* creature)
|
||||
return !creature->hasLootRecipient();
|
||||
}
|
||||
|
||||
void Player::_LoadActions(QueryResult *result, bool startup)
|
||||
void Player::_LoadActions(QueryResult_AutoPtr result, bool startup)
|
||||
{
|
||||
if (result)
|
||||
{
|
||||
@@ -16050,12 +16011,10 @@ void Player::_LoadActions(QueryResult *result, bool startup)
|
||||
}
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
delete result;
|
||||
}
|
||||
}
|
||||
|
||||
void Player::_LoadAuras(QueryResult *result, uint32 timediff)
|
||||
void Player::_LoadAuras(QueryResult_AutoPtr result, uint32 timediff)
|
||||
{
|
||||
sLog.outDebug("Loading auras for player %u",GetGUIDLow());
|
||||
|
||||
@@ -16121,8 +16080,6 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff)
|
||||
}
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
delete result;
|
||||
}
|
||||
|
||||
if(getClass() == CLASS_WARRIOR && !HasAuraType(SPELL_AURA_MOD_SHAPESHIFT))
|
||||
@@ -16173,7 +16130,7 @@ void Player::LoadCorpse()
|
||||
}
|
||||
}
|
||||
|
||||
void Player::_LoadInventory(QueryResult *result, uint32 timediff)
|
||||
void Player::_LoadInventory(QueryResult_AutoPtr result, uint32 timediff)
|
||||
{
|
||||
//QueryResult *result = CharacterDatabase.PQuery("SELECT data,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
|
||||
@@ -16309,7 +16266,6 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff)
|
||||
}
|
||||
} while (result->NextRow());
|
||||
|
||||
delete result;
|
||||
m_itemUpdateQueueBlocked = false;
|
||||
|
||||
// send by mail problematic items
|
||||
@@ -16339,7 +16295,7 @@ 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 data, item_guid, item_template FROM mail_items JOIN item_instance ON item_guid = guid WHERE mail_id='%u'", mail->messageID);
|
||||
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT data, item_guid, item_template FROM mail_items JOIN item_instance ON item_guid = guid WHERE mail_id='%u'", mail->messageID);
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
@@ -16374,11 +16330,9 @@ void Player::_LoadMailedItems(Mail *mail)
|
||||
|
||||
AddMItem(item);
|
||||
} while (result->NextRow());
|
||||
|
||||
delete result;
|
||||
}
|
||||
|
||||
void Player::_LoadMailInit(QueryResult *resultUnread, QueryResult *resultDelivery)
|
||||
void Player::_LoadMailInit(QueryResult_AutoPtr resultUnread, QueryResult_AutoPtr 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);
|
||||
@@ -16386,7 +16340,6 @@ void Player::_LoadMailInit(QueryResult *resultUnread, QueryResult *resultDeliver
|
||||
{
|
||||
Field *fieldMail = resultUnread->Fetch();
|
||||
unReadMails = fieldMail[0].GetUInt8();
|
||||
delete resultUnread;
|
||||
}
|
||||
|
||||
// store nearest delivery time (it > 0 and if it < current then at next player update SendNewMaill will be called)
|
||||
@@ -16395,7 +16348,6 @@ void Player::_LoadMailInit(QueryResult *resultUnread, QueryResult *resultDeliver
|
||||
{
|
||||
Field *fieldMail = resultDelivery->Fetch();
|
||||
m_nextMailDelivereTime = (time_t)fieldMail[0].GetUInt64();
|
||||
delete resultDelivery;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16403,7 +16355,7 @@ void Player::_LoadMail()
|
||||
{
|
||||
m_mail.clear();
|
||||
//mails are in right order 0 1 2 3 4 5 6 7 8 9 10 11 12 13
|
||||
QueryResult *result = CharacterDatabase.PQuery("SELECT id,messageType,sender,receiver,subject,itemTextId,has_items,expire_time,deliver_time,money,cod,checked,stationery,mailTemplateId FROM mail WHERE receiver = '%u' ORDER BY id DESC",GetGUIDLow());
|
||||
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT id,messageType,sender,receiver,subject,itemTextId,has_items,expire_time,deliver_time,money,cod,checked,stationery,mailTemplateId FROM mail WHERE receiver = '%u' ORDER BY id DESC",GetGUIDLow());
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
@@ -16438,7 +16390,6 @@ void Player::_LoadMail()
|
||||
|
||||
m_mail.push_back(m);
|
||||
} while (result->NextRow());
|
||||
delete result;
|
||||
}
|
||||
m_mailsLoaded = true;
|
||||
}
|
||||
@@ -16455,7 +16406,7 @@ void Player::LoadPet()
|
||||
}
|
||||
}
|
||||
|
||||
void Player::_LoadQuestStatus(QueryResult *result)
|
||||
void Player::_LoadQuestStatus(QueryResult_AutoPtr result)
|
||||
{
|
||||
mQuestStatus.clear();
|
||||
|
||||
@@ -16557,8 +16508,6 @@ void Player::_LoadQuestStatus(QueryResult *result)
|
||||
}
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
delete result;
|
||||
}
|
||||
|
||||
// clear quest log tail
|
||||
@@ -16566,7 +16515,7 @@ void Player::_LoadQuestStatus(QueryResult *result)
|
||||
SetQuestSlot(i, 0);
|
||||
}
|
||||
|
||||
void Player::_LoadDailyQuestStatus(QueryResult *result)
|
||||
void Player::_LoadDailyQuestStatus(QueryResult_AutoPtr 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);
|
||||
@@ -16602,14 +16551,12 @@ void Player::_LoadDailyQuestStatus(QueryResult *result)
|
||||
sLog.outDebug("Daily quest {%u} cooldown for player (GUID: %u)", quest_id, GetGUIDLow());
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
delete result;
|
||||
}
|
||||
|
||||
m_DailyQuestChanged = false;
|
||||
}
|
||||
|
||||
void Player::_LoadSpells(QueryResult *result)
|
||||
void Player::_LoadSpells(QueryResult_AutoPtr result)
|
||||
{
|
||||
//QueryResult *result = CharacterDatabase.PQuery("SELECT spell,active,disabled FROM character_spell WHERE guid = '%u'",GetGUIDLow());
|
||||
|
||||
@@ -16622,18 +16569,15 @@ void Player::_LoadSpells(QueryResult *result)
|
||||
addSpell(fields[0].GetUInt32(), fields[1].GetBool(), false, false, fields[2].GetBool());
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
delete result;
|
||||
}
|
||||
}
|
||||
|
||||
void Player::_LoadGroup(QueryResult *result)
|
||||
void Player::_LoadGroup(QueryResult_AutoPtr result)
|
||||
{
|
||||
//QueryResult *result = CharacterDatabase.PQuery("SELECT leaderGuid FROM group_member WHERE memberGuid='%u'", GetGUIDLow());
|
||||
if (result)
|
||||
{
|
||||
uint64 leaderGuid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER);
|
||||
delete result;
|
||||
if (Group* group = objmgr.GetGroupByLeader(leaderGuid))
|
||||
{
|
||||
uint8 subgroup = group->GetMemberGroup(GetGUID());
|
||||
@@ -16648,7 +16592,7 @@ void Player::_LoadGroup(QueryResult *result)
|
||||
}
|
||||
}
|
||||
|
||||
void Player::_LoadBoundInstances(QueryResult *result)
|
||||
void Player::_LoadBoundInstances(QueryResult_AutoPtr result)
|
||||
{
|
||||
for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
|
||||
m_boundInstances[i].clear();
|
||||
@@ -16706,7 +16650,6 @@ void Player::_LoadBoundInstances(QueryResult *result)
|
||||
if (InstanceSave *save = sInstanceSaveManager.AddInstanceSave(mapId, instanceId, Difficulty(difficulty), resetTime, !perm, true))
|
||||
BindToInstance(save, perm, true);
|
||||
} while (result->NextRow());
|
||||
delete result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16986,7 +16929,7 @@ bool Player::Satisfy(AccessRequirement const *ar, uint32 target_map, bool report
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Player::_LoadHomeBind(QueryResult *result)
|
||||
bool Player::_LoadHomeBind(QueryResult_AutoPtr result)
|
||||
{
|
||||
PlayerInfo const *info = objmgr.GetPlayerInfo(getRace(), getClass());
|
||||
if (!info)
|
||||
@@ -17005,7 +16948,6 @@ bool Player::_LoadHomeBind(QueryResult *result)
|
||||
m_homebindX = fields[2].GetFloat();
|
||||
m_homebindY = fields[3].GetFloat();
|
||||
m_homebindZ = fields[4].GetFloat();
|
||||
delete result;
|
||||
|
||||
MapEntry const* bindMapEntry = sMapStore.LookupEntry(m_homebindMapId);
|
||||
|
||||
@@ -17638,7 +17580,7 @@ void Player::SetFloatValueInDB(uint16 index, float value, uint64 guid)
|
||||
void Player::Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair)
|
||||
{
|
||||
// 0
|
||||
QueryResult* result = CharacterDatabase.PQuery("SELECT playerBytes2 FROM characters WHERE guid = '%u'", GUID_LOPART(guid));
|
||||
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT playerBytes2 FROM characters WHERE guid = '%u'", GUID_LOPART(guid));
|
||||
if(!result)
|
||||
return;
|
||||
|
||||
@@ -17649,8 +17591,6 @@ void Player::Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8
|
||||
player_bytes2 |= facialHair;
|
||||
|
||||
CharacterDatabase.PExecute("UPDATE characters SET gender = '%u', playerBytes = '%u', playerBytes2 = '%u' WHERE guid = '%u'", gender, skin | (face << 8) | (hairStyle << 16) | (hairColor << 24), player_bytes2, GUID_LOPART(guid));
|
||||
|
||||
delete result;
|
||||
}
|
||||
|
||||
void Player::SendAttackSwingDeadTarget()
|
||||
@@ -18448,7 +18388,7 @@ void Player::SendProficiency(uint8 pr1, uint32 pr2)
|
||||
|
||||
void Player::RemovePetitionsAndSigns(uint64 guid, uint32 type)
|
||||
{
|
||||
QueryResult *result = NULL;
|
||||
QueryResult_AutoPtr result = QueryResult_AutoPtr(NULL);
|
||||
if(type==10)
|
||||
result = CharacterDatabase.PQuery("SELECT ownerguid,petitionguid FROM petition_sign WHERE playerguid = '%u'", GUID_LOPART(guid));
|
||||
else
|
||||
@@ -18468,8 +18408,6 @@ void Player::RemovePetitionsAndSigns(uint64 guid, uint32 type)
|
||||
|
||||
} while ( result->NextRow() );
|
||||
|
||||
delete result;
|
||||
|
||||
if(type==10)
|
||||
CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE playerguid = '%u'", GUID_LOPART(guid));
|
||||
else
|
||||
@@ -18492,7 +18430,7 @@ void Player::RemovePetitionsAndSigns(uint64 guid, uint32 type)
|
||||
|
||||
void Player::LeaveAllArenaTeams(uint64 guid)
|
||||
{
|
||||
QueryResult *result = CharacterDatabase.PQuery("SELECT arena_team_member.arenateamid FROM arena_team_member JOIN arena_team ON arena_team_member.arenateamid = arena_team.arenateamid WHERE guid='%u'", GUID_LOPART(guid));
|
||||
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT arena_team_member.arenateamid FROM arena_team_member JOIN arena_team ON arena_team_member.arenateamid = arena_team.arenateamid WHERE guid='%u'", GUID_LOPART(guid));
|
||||
if(!result)
|
||||
return;
|
||||
|
||||
@@ -18507,8 +18445,6 @@ void Player::LeaveAllArenaTeams(uint64 guid)
|
||||
at->DelMember(guid);
|
||||
}
|
||||
} while (result->NextRow());
|
||||
|
||||
delete result;
|
||||
}
|
||||
|
||||
void Player::SetRestBonus (float rest_bonus_new)
|
||||
@@ -21906,7 +21842,7 @@ void Player::learnSpellHighRank(uint32 spellid)
|
||||
learnSpellHighRank(next);
|
||||
}
|
||||
|
||||
void Player::_LoadSkills(QueryResult *result)
|
||||
void Player::_LoadSkills(QueryResult_AutoPtr result)
|
||||
{
|
||||
// 0 1 2
|
||||
// SetPQuery(PLAYER_LOGIN_QUERY_LOADSKILLS, "SELECT skill, value, max FROM character_skills WHERE guid = '%u'", GUID_LOPART(m_guid));
|
||||
@@ -21969,7 +21905,6 @@ void Player::_LoadSkills(QueryResult *result)
|
||||
break;
|
||||
}
|
||||
} while (result->NextRow());
|
||||
delete result;
|
||||
}
|
||||
|
||||
for (; count < PLAYER_MAX_SKILLS; ++count)
|
||||
@@ -22813,7 +22748,7 @@ void Player::SetMap(Map * map)
|
||||
m_mapRef.link(map, this);
|
||||
}
|
||||
|
||||
void Player::_LoadGlyphs(QueryResult *result)
|
||||
void Player::_LoadGlyphs(QueryResult_AutoPtr result)
|
||||
{
|
||||
// SetPQuery(PLAYER_LOGIN_QUERY_LOADGLYPHS, "SELECT spec, glyph1, glyph2, glyph3, glyph4, glyph5, glyph6 from character_glyphs WHERE guid = '%u'", GUID_LOPART(m_guid));
|
||||
if (!result)
|
||||
@@ -22835,8 +22770,6 @@ void Player::_LoadGlyphs(QueryResult *result)
|
||||
m_Glyphs[spec][5] = fields[6].GetUInt32();
|
||||
|
||||
} while (result->NextRow());
|
||||
|
||||
delete result;
|
||||
}
|
||||
|
||||
void Player::_SaveGlyphs()
|
||||
@@ -22849,7 +22782,7 @@ void Player::_SaveGlyphs()
|
||||
}
|
||||
}
|
||||
|
||||
void Player::_LoadTalents(QueryResult *result)
|
||||
void Player::_LoadTalents(QueryResult_AutoPtr result)
|
||||
{
|
||||
// SetPQuery(PLAYER_LOGIN_QUERY_LOADTALENTS, "SELECT spell, spec FROM character_talent WHERE guid = '%u'", GUID_LOPART(m_guid));
|
||||
if (result)
|
||||
@@ -22861,8 +22794,6 @@ void Player::_LoadTalents(QueryResult *result)
|
||||
AddTalent(fields[0].GetUInt32(), fields[1].GetUInt32(), false);
|
||||
}
|
||||
while( result->NextRow() );
|
||||
|
||||
delete result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23046,7 +22977,7 @@ void Player::ActivateSpec(uint8 spec)
|
||||
// Let client clear his current Actions
|
||||
SendActionButtons(2);
|
||||
m_actionButtons.clear();
|
||||
if (QueryResult *result = CharacterDatabase.PQuery("SELECT button,action,type FROM character_action WHERE guid = '%u' AND spec = '%u' ORDER BY button", GetGUIDLow(), m_activeSpec))
|
||||
if (QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT button,action,type FROM character_action WHERE guid = '%u' AND spec = '%u' ORDER BY button", GetGUIDLow(), m_activeSpec))
|
||||
_LoadActions(result, false);
|
||||
|
||||
ResummonPetTemporaryUnSummonedIfAny();
|
||||
|
||||
Reference in New Issue
Block a user