[10803] Use ObjectGuid in player loading code.

This commit is contained in:
VladimirMangos 2010-12-01 15:25:45 +03:00
parent 938622bedc
commit 090bdf1dc7
4 changed files with 54 additions and 51 deletions

View file

@ -15072,7 +15072,7 @@ void Player::_LoadIntoDataField(const char* data, uint32 startOffset, uint32 cou
}
}
bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder )
{
// 0 1 2 3 4 5 6 7 8 9 10 11
//SELECT guid, account, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags,"
@ -15088,7 +15088,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
if(!result)
{
sLog.outError("Player (GUID: %u) not found in table `characters`, can't load. ",guid);
sLog.outError("%s not found in table `characters`, can't load. ", guid.GetString().c_str());
return false;
}
@ -15100,12 +15100,13 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
// player should be able to load/delete character only with correct account!
if( dbAccountId != GetSession()->GetAccountId() )
{
sLog.outError("Player (GUID: %u) loading from wrong account (is: %u, should be: %u)",guid,GetSession()->GetAccountId(),dbAccountId);
sLog.outError("%s loading from wrong account (is: %u, should be: %u)",
guid.GetString().c_str(), GetSession()->GetAccountId(), dbAccountId);
delete result;
return false;
}
Object::_Create( guid, 0, HIGHGUID_PLAYER );
Object::_Create(guid.GetCounter(), 0, HIGHGUID_PLAYER );
m_name = fields[2].GetCppString();
@ -15114,12 +15115,13 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
(GetSession()->GetSecurity() == SEC_PLAYER && sObjectMgr.IsReservedName(m_name)))
{
delete result;
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid ='%u'", uint32(AT_LOGIN_RENAME),guid);
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid ='%u'",
uint32(AT_LOGIN_RENAME), guid.GetCounter());
return false;
}
// overwrite possible wrong/corrupted guid
SetGuidValue(OBJECT_FIELD_GUID, ObjectGuid(HIGHGUID_PLAYER, guid));
SetGuidValue(OBJECT_FIELD_GUID, guid);
// overwrite some data fields
uint32 bytes0 = 0;
@ -15235,7 +15237,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
if(!IsPositionValid())
{
sLog.outError("Player (guidlow %d) have invalid coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.",guid,GetPositionX(),GetPositionY(),GetPositionZ(),GetOrientation());
sLog.outError("%s have invalid coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.",
guid.GetString().c_str(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
RelocateToHomebind();
transGUID = 0;
@ -15302,8 +15305,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
// transport size limited
m_movementInfo.GetTransportPos()->x > 50 || m_movementInfo.GetTransportPos()->y > 50 || m_movementInfo.GetTransportPos()->z > 50 )
{
sLog.outError("Player (guidlow %d) have invalid transport coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.",
guid, GetPositionX() + m_movementInfo.GetTransportPos()->x, GetPositionY() + m_movementInfo.GetTransportPos()->y,
sLog.outError("%s have invalid transport coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.",
guid.GetString().c_str(), GetPositionX() + m_movementInfo.GetTransportPos()->x, GetPositionY() + m_movementInfo.GetTransportPos()->y,
GetPositionZ() + m_movementInfo.GetTransportPos()->z, GetOrientation() + m_movementInfo.GetTransportPos()->o);
RelocateToHomebind();
@ -15337,8 +15340,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
if(!m_transport)
{
sLog.outError("Player (guidlow %d) have problems with transport guid (%u). Teleport to default race/class locations.",
guid,transGUID);
sLog.outError("%s have problems with transport guid (%u). Teleport to default race/class locations.",
guid.GetString().c_str(), transGUID);
RelocateToHomebind();