mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 05:06:24 +00:00
feat(Core/Misc): implement ObjectGuid class (port from TC) (#4885)
This commit is contained in:
@@ -415,18 +415,19 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
|
||||
|
||||
// make sure the same guid doesn't already exist and is safe to use
|
||||
bool incHighest = true;
|
||||
if (guid != 0 && guid < sObjectMgr->_hiCharGuid)
|
||||
if (guid != 0 && guid < sObjectMgr->GetGenerator<HighGuid::Player>().GetNextAfterMaxUsed())
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHECK_GUID);
|
||||
stmt->setUInt32(0, guid);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (result)
|
||||
guid = sObjectMgr->_hiCharGuid; // use first free if exists
|
||||
else incHighest = false;
|
||||
guid = sObjectMgr->GetGenerator<HighGuid::Player>().GetNextAfterMaxUsed(); // use first free if exists
|
||||
else
|
||||
incHighest = false;
|
||||
}
|
||||
else
|
||||
guid = sObjectMgr->_hiCharGuid;
|
||||
guid = sObjectMgr->GetGenerator<HighGuid::Player>().GetNextAfterMaxUsed();
|
||||
|
||||
// normalize the name if specified and check if it exists
|
||||
if (!normalizePlayerName(name))
|
||||
@@ -586,9 +587,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
|
||||
if (!changenth(line, 1, newguid)) // character_inventory.guid update
|
||||
ROLLBACK(DUMP_FILE_BROKEN);
|
||||
|
||||
if (!changeGuid(line, 2, items, sObjectMgr->_hiItemGuid, true))
|
||||
if (!changeGuid(line, 2, items, sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed(), true))
|
||||
ROLLBACK(DUMP_FILE_BROKEN); // character_inventory.bag update
|
||||
if (!changeGuid(line, 4, items, sObjectMgr->_hiItemGuid))
|
||||
if (!changeGuid(line, 4, items, sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed()))
|
||||
ROLLBACK(DUMP_FILE_BROKEN); // character_inventory.item update
|
||||
break;
|
||||
}
|
||||
@@ -604,7 +605,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
|
||||
{
|
||||
if (!changeGuid(line, 1, mails, sObjectMgr->_mailId))
|
||||
ROLLBACK(DUMP_FILE_BROKEN); // mail_items.id
|
||||
if (!changeGuid(line, 2, items, sObjectMgr->_hiItemGuid))
|
||||
if (!changeGuid(line, 2, items, sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed()))
|
||||
ROLLBACK(DUMP_FILE_BROKEN); // mail_items.item_guid
|
||||
if (!changenth(line, 3, newguid)) // mail_items.receiver
|
||||
ROLLBACK(DUMP_FILE_BROKEN);
|
||||
@@ -613,7 +614,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
|
||||
case DTT_ITEM:
|
||||
{
|
||||
// item, owner, data field:item, owner guid
|
||||
if (!changeGuid(line, 1, items, sObjectMgr->_hiItemGuid))
|
||||
if (!changeGuid(line, 1, items, sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed()))
|
||||
ROLLBACK(DUMP_FILE_BROKEN); // item_instance.guid update
|
||||
if (!changenth(line, 3, newguid)) // item_instance.owner_guid update
|
||||
ROLLBACK(DUMP_FILE_BROKEN);
|
||||
@@ -623,7 +624,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
|
||||
{
|
||||
if (!changenth(line, 1, newguid)) // character_gifts.guid update
|
||||
ROLLBACK(DUMP_FILE_BROKEN);
|
||||
if (!changeGuid(line, 2, items, sObjectMgr->_hiItemGuid))
|
||||
if (!changeGuid(line, 2, items, sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed()))
|
||||
ROLLBACK(DUMP_FILE_BROKEN); // character_gifts.item_guid update
|
||||
break;
|
||||
}
|
||||
@@ -684,11 +685,11 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
|
||||
// in case of name conflict player has to rename at login anyway
|
||||
sWorld->AddGlobalPlayerData(guid, account, name, gender, race, playerClass, level, mails.size(), 0);
|
||||
|
||||
sObjectMgr->_hiItemGuid += items.size();
|
||||
sObjectMgr->GetGenerator<HighGuid::Item>().Set(sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed() + items.size());
|
||||
sObjectMgr->_mailId += mails.size();
|
||||
|
||||
if (incHighest)
|
||||
++sObjectMgr->_hiCharGuid;
|
||||
sObjectMgr->GetGenerator<HighGuid::Player>().Generate();
|
||||
|
||||
fclose(fin);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user