[10363] More wide use ObjectGuid in way remove MAKE_NEW_GUID uses.

Also
* Fixed some amount wrong uses low guids as full player guids.
* Add private without body ObjectGuid(uint32 const&) for catch wrong assigns low guids to ObjectGuid.
  In some cases need assign "0" guid, then use ObjectGuid() instead.
* Fixed .pdump commands work.
This commit is contained in:
VladimirMangos 2010-08-17 02:16:15 +04:00
parent db7db6382a
commit 5f44c4da21
41 changed files with 369 additions and 323 deletions

View file

@ -337,30 +337,30 @@ void Item::SaveToDB()
SetState(ITEM_UNCHANGED);
}
bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult *result)
bool Item::LoadFromDB(uint32 guidLow, uint64 owner_guid, QueryResult *result)
{
// create item before any checks for store correct guid
// and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB
Object::_Create(guid, 0, HIGHGUID_ITEM);
Object::_Create(guidLow, 0, HIGHGUID_ITEM);
bool delete_result = false;
if(!result)
{
result = CharacterDatabase.PQuery("SELECT data FROM item_instance WHERE guid = '%u'", guid);
result = CharacterDatabase.PQuery("SELECT data FROM item_instance WHERE guid = '%u'", guidLow);
delete_result = true;
}
if (!result)
{
sLog.outError("Item (GUID: %u owner: %u) not found in table `item_instance`, can't load. ",guid,GUID_LOPART(owner_guid));
sLog.outError("Item (GUID: %u owner: %u) not found in table `item_instance`, can't load. ", guidLow, GUID_LOPART(owner_guid));
return false;
}
Field *fields = result->Fetch();
if(!LoadValues(fields[0].GetString()))
if (!LoadValues(fields[0].GetString()))
{
sLog.outError("Item #%d have broken data in `data` field. Can't be loaded.",guid);
sLog.outError("Item #%d have broken data in `data` field. Can't be loaded.", guidLow);
if (delete_result) delete result;
return false;
}
@ -368,14 +368,15 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult *result)
bool need_save = false; // need explicit save data at load fixes
// overwrite possible wrong/corrupted guid
uint64 new_item_guid = MAKE_NEW_GUID(guid,0, HIGHGUID_ITEM);
if(GetUInt64Value(OBJECT_FIELD_GUID) != new_item_guid)
ObjectGuid new_item_guid = ObjectGuid(HIGHGUID_ITEM, guidLow);
if (GetGuidValue(OBJECT_FIELD_GUID) != new_item_guid)
{
SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid,0, HIGHGUID_ITEM));
SetGuidValue(OBJECT_FIELD_GUID, new_item_guid);
need_save = true;
}
if (delete_result) delete result;
if (delete_result)
delete result;
ItemPrototype const* proto = GetProto();
if(!proto)
@ -425,7 +426,7 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult *result)
ss << "UPDATE item_instance SET data = '";
for(uint16 i = 0; i < m_valuesCount; ++i )
ss << GetUInt32Value(i) << " ";
ss << "', owner_guid = '" << GUID_LOPART(GetOwnerGUID()) << "' WHERE guid = '" << guid << "'";
ss << "', owner_guid = '" << GUID_LOPART(GetOwnerGUID()) << "' WHERE guid = '" << guidLow << "'";
CharacterDatabase.Execute( ss.str().c_str() );
}