Use characters.guid instead low guid value from characters.data in charcter enum data prepering for client.

This commit is contained in:
VladimirMangos 2008-10-30 21:00:19 +03:00
parent 8d02b5c7f2
commit a26b72411a
2 changed files with 24 additions and 23 deletions

View file

@ -128,9 +128,10 @@ void WorldSession::HandleCharEnum(QueryResult * result)
Player *plr = new Player(this); Player *plr = new Player(this);
do do
{ {
sLog.outDetail("Loading char guid %u from account %u.",(*result)[0].GetUInt32(),GetAccountId()); uint32 guidlow = (*result)[0].GetUInt32();
sLog.outDetail("Loading char guid %u from account %u.",guidlow,GetAccountId());
if(plr->MinimalLoadFromDB( result, (*result)[0].GetUInt32() )) if(plr->MinimalLoadFromDB( result, guidlow ))
{ {
plr->BuildEnumData( result, &data ); plr->BuildEnumData( result, &data );
++num; ++num;
@ -154,17 +155,17 @@ void WorldSession::HandleCharEnumOpcode( WorldPacket & /*recv_data*/ )
!sWorld.getConfig(CONFIG_DECLINED_NAMES_USED) ? !sWorld.getConfig(CONFIG_DECLINED_NAMES_USED) ?
// ------- Query Without Declined Names -------- // ------- Query Without Declined Names --------
// 0 1 2 3 4 5 6 7 8 // 0 1 2 3 4 5 6 7 8
"SELECT characters.data, characters.name, characters.position_x, characters.position_y, characters.position_z, characters.map, characters.totaltime, characters.leveltime, characters.at_login, " "SELECT characters.guid, characters.data, characters.name, characters.position_x, characters.position_y, characters.position_z, characters.map, characters.totaltime, characters.leveltime, "
// 9 10 11 // 9 10 11 12
"character_pet.entry, character_pet.modelid, character_pet.level " "characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level "
"FROM characters LEFT JOIN character_pet ON characters.guid=character_pet.owner AND character_pet.slot='0' " "FROM characters LEFT JOIN character_pet ON characters.guid=character_pet.owner AND character_pet.slot='0' "
"WHERE characters.account = '%u' ORDER BY characters.guid" "WHERE characters.account = '%u' ORDER BY characters.guid"
: :
// --------- Query With Declined Names --------- // --------- Query With Declined Names ---------
// 0 1 2 3 4 5 6 7 8 // 0 1 2 3 4 5 6 7 8
"SELECT characters.data, characters.name, characters.position_x, characters.position_y, characters.position_z, characters.map, characters.totaltime, characters.leveltime, characters.at_login, " "SELECT characters.guid, characters.data, characters.name, characters.position_x, characters.position_y, characters.position_z, characters.map, characters.totaltime, characters.leveltime, "
// 9 10 11 12 // 9 10 11 12 13
"character_pet.entry, character_pet.modelid, character_pet.level, genitive " "characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level, genitive "
"FROM characters LEFT JOIN character_pet ON characters.guid = character_pet.owner AND character_pet.slot='0' " "FROM characters LEFT JOIN character_pet ON characters.guid = character_pet.owner AND character_pet.slot='0' "
"LEFT JOIN character_declinedname ON characters.guid = character_declinedname.guid " "LEFT JOIN character_declinedname ON characters.guid = character_declinedname.guid "
"WHERE characters.account = '%u' ORDER BY characters.guid", "WHERE characters.account = '%u' ORDER BY characters.guid",

View file

@ -1296,7 +1296,7 @@ void Player::BuildEnumData( QueryResult * result, WorldPacket * p_data )
char_flags |= CHARACTER_FLAG_RENAME; char_flags |= CHARACTER_FLAG_RENAME;
// always send the flag if declined names aren't used // always send the flag if declined names aren't used
// to let the client select a default method of declining the name // to let the client select a default method of declining the name
if(!sWorld.getConfig(CONFIG_DECLINED_NAMES_USED) || (result && result->Fetch()[12].GetCppString() != "")) if(!sWorld.getConfig(CONFIG_DECLINED_NAMES_USED) || (result && result->Fetch()[13].GetCppString() != ""))
char_flags |= CHARACTER_FLAG_DECLINED; char_flags |= CHARACTER_FLAG_DECLINED;
*p_data << (uint32)char_flags; // character flags *p_data << (uint32)char_flags; // character flags
@ -1314,12 +1314,12 @@ void Player::BuildEnumData( QueryResult * result, WorldPacket * p_data )
{ {
Field* fields = result->Fetch(); Field* fields = result->Fetch();
uint32 entry = fields[9].GetUInt32(); uint32 entry = fields[10].GetUInt32();
CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(entry); CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(entry);
if(cInfo) if(cInfo)
{ {
petDisplayId = fields[10].GetUInt32(); petDisplayId = fields[11].GetUInt32();
petLevel = fields[11].GetUInt32(); petLevel = fields[12].GetUInt32();
petFamily = cInfo->family; petFamily = cInfo->family;
} }
} }
@ -13184,15 +13184,15 @@ bool Player::MinimalLoadFromDB( QueryResult *result, uint32 guid )
bool delete_result = true; bool delete_result = true;
if(!result) if(!result)
{ {
// 0 1 2 3 4 5 6 7 8 // 0 1 2 3 4 5 6 7 8 9
result = CharacterDatabase.PQuery("SELECT data, name, position_x, position_y, position_z, map, totaltime, leveltime, at_login FROM characters WHERE guid = '%u'",guid); result = CharacterDatabase.PQuery("SELECT guid, data, name, position_x, position_y, position_z, map, totaltime, leveltime, at_login FROM characters WHERE guid = '%u'",guid);
if(!result) return false; if(!result) return false;
} }
else delete_result = false; else delete_result = false;
Field *fields = result->Fetch(); Field *fields = result->Fetch();
if(!LoadValues( fields[0].GetString())) if(!LoadValues( fields[1].GetString()))
{ {
sLog.outError("ERROR: Player #%d have broken data in `data` field. Can't be loaded.",GUID_LOPART(guid)); sLog.outError("ERROR: Player #%d have broken data in `data` field. Can't be loaded.",GUID_LOPART(guid));
if(delete_result) delete result; if(delete_result) delete result;
@ -13202,16 +13202,16 @@ bool Player::MinimalLoadFromDB( QueryResult *result, uint32 guid )
// overwrite possible wrong/corrupted guid // overwrite possible wrong/corrupted guid
SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER)); SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER));
m_name = fields[1].GetCppString(); m_name = fields[2].GetCppString();
Relocate(fields[2].GetFloat(),fields[3].GetFloat(),fields[4].GetFloat()); Relocate(fields[3].GetFloat(),fields[4].GetFloat(),fields[5].GetFloat());
SetMapId(fields[5].GetUInt32()); SetMapId(fields[6].GetUInt32());
// the instance id is not needed at character enum // the instance id is not needed at character enum
m_Played_time[0] = fields[6].GetUInt32(); m_Played_time[0] = fields[7].GetUInt32();
m_Played_time[1] = fields[7].GetUInt32(); m_Played_time[1] = fields[8].GetUInt32();
m_atLoginFlags = fields[8].GetUInt32(); m_atLoginFlags = fields[9].GetUInt32();
// I don't see these used anywhere .. // I don't see these used anywhere ..
/*_LoadGroup(); /*_LoadGroup();