feat(Core/Misc): implement ObjectGuid class (port from TC) (#4885)

This commit is contained in:
UltraNix
2021-04-25 22:18:03 +02:00
committed by GitHub
parent 91081f4ad8
commit f4c226423d
568 changed files with 10655 additions and 11019 deletions

View File

@@ -104,9 +104,9 @@ public:
handler->PSendSysMessage(LANG_ACCOUNT_CREATED, accountName);
if (handler->GetSession())
{
LOG_DEBUG("warden", "Account: %d (IP: %s) Character:[%s] (GUID: %u) Change Password.",
LOG_DEBUG("warden", "Account: %d (IP: %s) Character:[%s] (%s) Change Password.",
handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow());
handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().ToString().c_str());
}
break;
case AOR_NAME_TOO_LONG:

View File

@@ -209,7 +209,7 @@ public:
return false;
Player* target;
uint64 targetGuid;
ObjectGuid targetGuid;
if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid))
return false;
@@ -251,7 +251,7 @@ public:
}
std::string oldCaptainName;
sObjectMgr->GetPlayerNameByGUID(arena->GetCaptain(), oldCaptainName);
sObjectMgr->GetPlayerNameByGUID(arena->GetCaptain().GetCounter(), oldCaptainName);
arena->SetCaptain(targetGuid);
handler->PSendSysMessage(LANG_ARENA_CAPTAIN, arena->GetName().c_str(), arena->GetId(), oldCaptainName.c_str(), target->GetName().c_str());
@@ -279,7 +279,7 @@ public:
handler->PSendSysMessage(LANG_ARENA_INFO_HEADER, arena->GetName().c_str(), arena->GetId(), arena->GetRating(), arena->GetType(), arena->GetType());
for (ArenaTeam::MemberList::iterator itr = arena->m_membersBegin(); itr != arena->m_membersEnd(); ++itr)
handler->PSendSysMessage(LANG_ARENA_INFO_MEMBERS, itr->Name.c_str(), GUID_LOPART(itr->Guid), itr->PersonalRating, (arena->GetCaptain() == itr->Guid ? "- Captain" : ""));
handler->PSendSysMessage(LANG_ARENA_INFO_MEMBERS, itr->Name.c_str(), itr->Guid.GetCounter(), itr->PersonalRating, (arena->GetCaptain() == itr->Guid ? "- Captain" : ""));
return true;
}

View File

@@ -304,7 +304,7 @@ public:
return false;
Player* target = ObjectAccessor::FindPlayerByName(args, false);
uint32 targetGuid = 0;
ObjectGuid targetGuid;
std::string name(args);
if (!target)
@@ -317,10 +317,10 @@ public:
}
}
else
targetGuid = target->GetGUIDLow();
targetGuid = target->GetGUID();
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_BANINFO);
stmt->setUInt32(0, targetGuid);
stmt->setUInt32(0, targetGuid.GetCounter());
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (!result)
{

View File

@@ -74,7 +74,7 @@ public:
// Stores informations about a deleted character
struct DeletedInfo
{
uint32 lowGuid; ///< the low GUID from the character
ObjectGuid::LowType lowGuid; ///< the low GUID from the character
std::string name; ///< the character name
uint32 accountId; ///< the account id
std::string accountName; ///< the account name
@@ -223,7 +223,7 @@ public:
sWorld->AddGlobalPlayerData(delInfo.lowGuid, delInfo.accountId, delInfo.name, (*result)[2].GetUInt8(), (*result)[0].GetUInt8(), (*result)[1].GetUInt8(), (*result)[3].GetUInt8(), 0, 0);
}
static void HandleCharacterLevel(Player* player, uint64 playerGuid, uint32 oldLevel, uint32 newLevel, ChatHandler* handler)
static void HandleCharacterLevel(Player* player, ObjectGuid playerGuid, uint32 oldLevel, uint32 newLevel, ChatHandler* handler)
{
if (player)
{
@@ -246,11 +246,11 @@ public:
// Update level and reset XP, everything else will be updated at login
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_LEVEL);
stmt->setUInt8(0, uint8(newLevel));
stmt->setUInt32(1, GUID_LOPART(playerGuid));
stmt->setUInt32(1, playerGuid.GetCounter());
CharacterDatabase.Execute(stmt);
// xinef: update global storage
sWorld->UpdateGlobalPlayerData(GUID_LOPART(playerGuid), PLAYER_UPDATE_DATA_LEVEL, "", newLevel);
sWorld->UpdateGlobalPlayerData(playerGuid.GetCounter(), PLAYER_UPDATE_DATA_LEVEL, "", newLevel);
}
}
@@ -303,7 +303,7 @@ public:
static bool HandleCharacterRenameCommand(ChatHandler* handler, char const* args)
{
Player* target;
uint64 targetGuid;
ObjectGuid targetGuid;
std::string targetName;
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
return false;
@@ -311,7 +311,7 @@ public:
if (target)
{
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
handler->PSendSysMessage(LANG_RENAME_PLAYER, handler->GetNameLink(target).c_str());
@@ -324,11 +324,11 @@ public:
return false;
std::string oldNameLink = handler->playerLink(targetName);
handler->PSendSysMessage(LANG_RENAME_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGuid));
handler->PSendSysMessage(LANG_RENAME_PLAYER_GUID, oldNameLink.c_str(), targetGuid.GetCounter());
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
stmt->setUInt16(0, uint16(AT_LOGIN_RENAME));
stmt->setUInt32(1, GUID_LOPART(targetGuid));
stmt->setUInt32(1, targetGuid.GetCounter());
CharacterDatabase.Execute(stmt);
}
@@ -351,12 +351,12 @@ public:
}
Player* target;
uint64 targetGuid;
ObjectGuid targetGuid;
std::string targetName;
if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName))
return false;
int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromStorage(targetGuid);
int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromStorage(targetGuid.GetCounter());
int32 newlevel = levelStr ? atoi(levelStr) : oldlevel;
if (newlevel < 1)
@@ -379,7 +379,7 @@ public:
static bool HandleCharacterCustomizeCommand(ChatHandler* handler, char const* args)
{
Player* target;
uint64 targetGuid;
ObjectGuid targetGuid;
std::string targetName;
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
return false;
@@ -390,13 +390,13 @@ public:
{
handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER, handler->GetNameLink(target).c_str());
target->SetAtLoginFlag(AT_LOGIN_CUSTOMIZE);
stmt->setUInt32(1, target->GetGUIDLow());
stmt->setUInt32(1, target->GetGUID().GetCounter());
}
else
{
std::string oldNameLink = handler->playerLink(targetName);
stmt->setUInt32(1, GUID_LOPART(targetGuid));
handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGuid));
stmt->setUInt32(1, targetGuid.GetCounter());
handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), targetGuid.GetCounter());
}
CharacterDatabase.Execute(stmt);
@@ -406,7 +406,7 @@ public:
static bool HandleCharacterChangeFactionCommand(ChatHandler* handler, char const* args)
{
Player* target;
uint64 targetGuid;
ObjectGuid targetGuid;
std::string targetName;
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
@@ -418,13 +418,13 @@ public:
{
handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER, handler->GetNameLink(target).c_str());
target->SetAtLoginFlag(AT_LOGIN_CHANGE_FACTION);
stmt->setUInt32(1, target->GetGUIDLow());
stmt->setUInt32(1, target->GetGUID().GetCounter());
}
else
{
std::string oldNameLink = handler->playerLink(targetName);
handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGuid));
stmt->setUInt32(1, GUID_LOPART(targetGuid));
handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), targetGuid.GetCounter());
stmt->setUInt32(1, targetGuid.GetCounter());
}
CharacterDatabase.Execute(stmt);
@@ -434,7 +434,7 @@ public:
static bool HandleCharacterChangeRaceCommand(ChatHandler* handler, char const* args)
{
Player* target;
uint64 targetGuid;
ObjectGuid targetGuid;
std::string targetName;
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
return false;
@@ -446,14 +446,14 @@ public:
// TODO : add text into database
handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER, handler->GetNameLink(target).c_str());
target->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE);
stmt->setUInt32(1, target->GetGUIDLow());
stmt->setUInt32(1, target->GetGUID().GetCounter());
}
else
{
std::string oldNameLink = handler->playerLink(targetName);
// TODO : add text into database
handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGuid));
stmt->setUInt32(1, GUID_LOPART(targetGuid));
handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), targetGuid.GetCounter());
stmt->setUInt32(1, targetGuid.GetCounter());
}
CharacterDatabase.Execute(stmt);
@@ -688,7 +688,7 @@ public:
if (!normalizePlayerName(characterName))
return false;
uint32 characterGuid;
ObjectGuid characterGuid;
uint32 accountId;
Player* player = ObjectAccessor::FindPlayerByName(characterName);
@@ -707,14 +707,14 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
accountId = sObjectMgr->GetPlayerAccountIdByGUID(characterGuid);
accountId = sObjectMgr->GetPlayerAccountIdByGUID(characterGuid.GetCounter());
}
std::string accountName;
AccountMgr::GetName(accountId, accountName);
Player::DeleteFromDB(characterGuid, accountId, true, true);
handler->PSendSysMessage(LANG_CHARACTER_DELETED, characterName.c_str(), characterGuid, accountName.c_str(), accountId);
Player::DeleteFromDB(characterGuid.GetCounter(), accountId, true, true);
handler->PSendSysMessage(LANG_CHARACTER_DELETED, characterName.c_str(), characterGuid.GetCounter(), accountName.c_str(), accountId);
return true;
}
@@ -733,12 +733,12 @@ public:
}
Player* target;
uint64 targetGuid;
ObjectGuid targetGuid;
std::string targetName;
if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName))
return false;
int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromStorage(targetGuid);
int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromStorage(targetGuid.GetCounter());
int32 addlevel = levelStr ? atoi(levelStr) : 1;
int32 newlevel = oldlevel + addlevel;
@@ -824,7 +824,7 @@ public:
guidStr = strtok(nullptr, " ");
}
uint32 guid = 0;
ObjectGuid::LowType guid = 0;
if (guidStr)
{
@@ -912,10 +912,10 @@ public:
if (!fileStr || !playerStr)
return false;
uint64 guid;
ObjectGuid guid;
// character name can't start from number
if (isNumeric(playerStr))
guid = MAKE_NEW_GUID(atoi(playerStr), 0, HIGHGUID_PLAYER);
guid = ObjectGuid::Create<HighGuid::Player>(atoi(playerStr));
else
{
std::string name = handler->extractPlayerNameFromLink(playerStr);
@@ -929,14 +929,14 @@ public:
guid = sObjectMgr->GetPlayerGUIDByName(name);
}
if (!sObjectMgr->GetPlayerAccountIdByGUID(guid))
if (!sObjectMgr->GetPlayerAccountIdByGUID(guid.GetCounter()))
{
handler->PSendSysMessage(LANG_PLAYER_NOT_FOUND);
handler->SetSentErrorMessage(true);
return false;
}
switch (PlayerDumpWriter().WriteDump(fileStr, uint32(guid)))
switch (PlayerDumpWriter().WriteDump(fileStr, guid.GetCounter()))
{
case DUMP_SUCCESS:
handler->PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS);

View File

@@ -139,7 +139,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(player, 0))
if (handler->HasLowerSecurity(player))
return false;
if (strncmp(args, "on", 3) == 0)
@@ -190,7 +190,7 @@ public:
if (!chr)
chr = handler->GetSession()->GetPlayer();
else if (handler->HasLowerSecurity(chr, 0)) // check online security
else if (handler->HasLowerSecurity(chr)) // check online security
return false;
if (!*args)

View File

@@ -239,7 +239,7 @@ public:
return false;
SellResult msg = SellResult(atoi(args));
handler->GetSession()->GetPlayer()->SendSellError(msg, 0, 0, 0);
handler->GetSession()->GetPlayer()->SendSellError(msg, 0, ObjectGuid::Empty, 0);
return true;
}
@@ -365,11 +365,11 @@ public:
}
else if (type == "appitsguid")
{
data.append(unit->GetPackGUID());
data << unit->GetPackGUID();
}
else if (type == "appmyguid")
{
data.append(player->GetPackGUID());
data << player->GetPackGUID();
}
else if (type == "appgoguid")
{
@@ -381,7 +381,7 @@ public:
ifs.close();
return false;
}
data.append(obj->GetPackGUID());
data << obj->GetPackGUID();
}
else if (type == "goguid")
{
@@ -393,15 +393,15 @@ public:
ifs.close();
return false;
}
data << uint64(obj->GetGUID());
data << obj->GetGUID();
}
else if (type == "myguid")
{
data << uint64(player->GetGUID());
data << player->GetGUID();
}
else if (type == "itsguid")
{
data << uint64(unit->GetGUID());
data << unit->GetGUID();
}
else if (type == "itspos")
{
@@ -503,7 +503,8 @@ public:
if (!target)
return false;
handler->PSendSysMessage("Loot recipient for creature %s (GUID %u, DB GUID %u) is %s", target->GetName().c_str(), target->GetGUIDLow(), target->GetDBTableGUIDLow(), target->hasLootRecipient() ? (target->GetLootRecipient() ? target->GetLootRecipient()->GetName().c_str() : "offline") : "no loot recipient");
handler->PSendSysMessage("Loot recipient for creature %s (%s, SpawnId %u) is %s",
target->GetName().c_str(), target->GetGUID().ToString().c_str(), target->GetSpawnId(), target->hasLootRecipient() ? (target->GetLootRecipient() ? target->GetLootRecipient()->GetName().c_str() : "offline") : "no loot recipient");
return true;
}
@@ -560,10 +561,12 @@ public:
for (uint8 j = 0; j < bag->GetBagSize(); ++j)
if (Item* item2 = bag->GetItemByPos(j))
if (item2->GetState() == state)
handler->PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID()));
handler->PSendSysMessage("bag: 255 slot: %d %s, owner: %s",
item2->GetSlot(), item2->GetGUID().ToString().c_str(), item2->GetOwnerGUID().ToString().c_str());
}
else if (item->GetState() == state)
handler->PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()));
handler->PSendSysMessage("bag: 255 slot: %d %s, owner: %s",
item->GetSlot(), item->GetGUID().ToString().c_str(), item->GetOwnerGUID().ToString().c_str());
}
}
}
@@ -597,7 +600,7 @@ public:
break;
}
handler->PSendSysMessage("bag: %d slot: %d guid: %d - state: %s", bagSlot, item->GetSlot(), item->GetGUIDLow(), st.c_str());
handler->PSendSysMessage("bag: %d slot: %d %s - state: %s", bagSlot, item->GetSlot(), item->GetGUID().ToString().c_str(), st.c_str());
}
if (updateQueue.empty())
handler->PSendSysMessage("The player's updatequeue is empty");
@@ -618,21 +621,23 @@ public:
if (item->GetSlot() != i)
{
handler->PSendSysMessage("Item with slot %d and guid %d has an incorrect slot value: %d", i, item->GetGUIDLow(), item->GetSlot());
handler->PSendSysMessage("Item with slot %d %s has an incorrect slot value: %d", i, item->GetGUID().ToString().c_str(), item->GetSlot());
error = true;
continue;
}
if (item->GetOwnerGUID() != player->GetGUID())
{
handler->PSendSysMessage("The item with slot %d and itemguid %d does have non-matching owner guid (%d) and player guid (%d) !", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow());
handler->PSendSysMessage("The item with slot %d (%s) does have non-matching owner (%s) and player (%sd) !",
item->GetSlot(), item->GetGUID().ToString().c_str(), item->GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str());
error = true;
continue;
}
if (Bag* container = item->GetContainer())
{
handler->PSendSysMessage("The item with slot %d and guid %d has a container (slot: %d, guid: %d) but shouldn't!", item->GetSlot(), item->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow());
handler->PSendSysMessage("The item with slot %d (%s) has a container (slot: %d, %s) but shouldn't!",
item->GetSlot(), item->GetGUID().ToString().c_str(), container->GetSlot(), container->GetGUID().ToString().c_str());
error = true;
continue;
}
@@ -642,28 +647,32 @@ public:
uint16 qp = item->GetQueuePos();
if (qp > updateQueue.size())
{
handler->PSendSysMessage("The item with slot %d and guid %d has its queuepos (%d) larger than the update queue size! ", item->GetSlot(), item->GetGUIDLow(), qp);
handler->PSendSysMessage("The item with slot %d (%s) has its queuepos (%d) larger than the update queue size! ",
item->GetSlot(), item->GetGUID().ToString().c_str(), qp);
error = true;
continue;
}
if (updateQueue[qp] == nullptr)
{
handler->PSendSysMessage("The item with slot %d and guid %d has its queuepos (%d) pointing to nullptr in the queue!", item->GetSlot(), item->GetGUIDLow(), qp);
handler->PSendSysMessage("The item with slot %d (%s) has its queuepos (%d) pointing to nullptr in the queue!",
item->GetSlot(), item->GetGUID().ToString().c_str(), qp);
error = true;
continue;
}
if (updateQueue[qp] != item)
{
handler->PSendSysMessage("The item with slot %d and guid %d has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", item->GetSlot(), item->GetGUIDLow(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUIDLow());
handler->PSendSysMessage("The item with slot %d (%s) has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, %s)",
item->GetSlot(), item->GetGUID().ToString().c_str(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUID().ToString().c_str());
error = true;
continue;
}
}
else if (item->GetState() != ITEM_UNCHANGED)
{
handler->PSendSysMessage("The item with slot %d and guid %d is not in queue but should be (state: %d)!", item->GetSlot(), item->GetGUIDLow(), item->GetState());
handler->PSendSysMessage("The item with slot %d (%s) is not in queue but should be (state: %d)!",
item->GetSlot(), item->GetGUID().ToString().c_str(), item->GetState());
error = true;
continue;
}
@@ -678,14 +687,16 @@ public:
if (item2->GetSlot() != j)
{
handler->PSendSysMessage("The item in bag %d and slot %d (guid: %d) has an incorrect slot value: %d", bag->GetSlot(), j, item2->GetGUIDLow(), item2->GetSlot());
handler->PSendSysMessage("The item in bag %d and slot %d (%s) has an incorrect slot value: %d",
bag->GetSlot(), j, item2->GetGUID().ToString().c_str(), item2->GetSlot());
error = true;
continue;
}
if (item2->GetOwnerGUID() != player->GetGUID())
{
handler->PSendSysMessage("The item in bag %d at slot %d and with itemguid %d, the owner's guid (%d) and the player's guid (%d) don't match!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID()), player->GetGUIDLow());
handler->PSendSysMessage("The item in bag %d at slot %d and with item %s, the owner (%s) and the player (%s) don't match!",
bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), item2->GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str());
error = true;
continue;
}
@@ -693,14 +704,16 @@ public:
Bag* container = item2->GetContainer();
if (!container)
{
handler->PSendSysMessage("The item in bag %d at slot %d with guid %d has no container!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow());
handler->PSendSysMessage("The item in bag %d at slot %d (%s) has no container!",
bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str());
error = true;
continue;
}
if (container != bag)
{
handler->PSendSysMessage("The item in bag %d at slot %d with guid %d has a different container(slot %d guid %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow());
handler->PSendSysMessage("The item in bag %d at slot %d (%s) has a different container(slot %d %s)!",
bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), container->GetSlot(), container->GetGUID().ToString().c_str());
error = true;
continue;
}
@@ -710,28 +723,32 @@ public:
uint16 qp = item2->GetQueuePos();
if (qp > updateQueue.size())
{
handler->PSendSysMessage("The item in bag %d at slot %d having guid %d has a queuepos (%d) larger than the update queue size! ", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp);
handler->PSendSysMessage("The item in bag %d at slot %d (%s) has a queuepos (%d) larger than the update queue size! ",
bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), qp);
error = true;
continue;
}
if (updateQueue[qp] == nullptr)
{
handler->PSendSysMessage("The item in bag %d at slot %d having guid %d has a queuepos (%d) that points to nullptr in the queue!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp);
handler->PSendSysMessage("The item in bag %d at slot %d (%s) has a queuepos (%d) that points to nullptr in the queue!",
bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), qp);
error = true;
continue;
}
if (updateQueue[qp] != item2)
{
handler->PSendSysMessage("The item in bag %d at slot %d having guid %d has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUIDLow());
handler->PSendSysMessage("The item in bag %d at slot %d (%s) has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, %s)",
bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUID().ToString().c_str());
error = true;
continue;
}
}
else if (item2->GetState() != ITEM_UNCHANGED)
{
handler->PSendSysMessage("The item in bag %d at slot %d having guid %d is not in queue but should be (state: %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), item2->GetState());
handler->PSendSysMessage("The item in bag %d at slot %d (%s) is not in queue but should be (state: %d)!",
bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), item2->GetState());
error = true;
continue;
}
@@ -747,14 +764,15 @@ public:
if (item->GetOwnerGUID() != player->GetGUID())
{
handler->PSendSysMessage("queue(" SZFMTD "): For the item with guid %d, the owner's guid (%d) and the player's guid (%d) don't match!", i, item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow());
handler->PSendSysMessage("queue(" SZFMTD "): For the item (%s), the owner (%s) and the player (%s) don't match!",
i, item->GetGUID().ToString().c_str(), item->GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str());
error = true;
continue;
}
if (item->GetQueuePos() != i)
{
handler->PSendSysMessage("queue(" SZFMTD "): For the item with guid %d, the queuepos doesn't match it's position in the queue!", i, item->GetGUIDLow());
handler->PSendSysMessage("queue(" SZFMTD "): For the item (%s), the queuepos doesn't match it's position in the queue!", i, item->GetGUID().ToString().c_str());
error = true;
continue;
}
@@ -766,14 +784,16 @@ public:
if (test == nullptr)
{
handler->PSendSysMessage("queue(" SZFMTD "): The bag(%d) and slot(%d) values for the item with guid %d are incorrect, the player doesn't have any item at that position!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow());
handler->PSendSysMessage("queue(" SZFMTD "): The bag(%d) and slot(%d) values for the item (%s) are incorrect, the player doesn't have any item at that position!",
i, item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString().c_str());
error = true;
continue;
}
if (test != item)
{
handler->PSendSysMessage("queue(" SZFMTD "): The bag(%d) and slot(%d) values for the item with guid %d are incorrect, an item which guid is %d is there instead!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), test->GetGUIDLow());
handler->PSendSysMessage("queue(" SZFMTD "): The bag(%d) and slot(%d) values for the item (%s) are incorrect, an item (%s) is there instead!",
i, item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString().c_str(), test->GetGUID().ToString().c_str());
error = true;
continue;
}
@@ -806,7 +826,7 @@ public:
ThreatContainer::StorageType const& threatList = target->getThreatManager().getThreatList();
ThreatContainer::StorageType::const_iterator itr;
uint32 count = 0;
handler->PSendSysMessage("Threat list of %s (guid %u)", target->GetName().c_str(), target->GetGUIDLow());
handler->PSendSysMessage("Threat list of %s (%s)", target->GetName().c_str(), target->GetGUID().ToString().c_str());
for (itr = threatList.begin(); itr != threatList.end(); ++itr)
{
Unit* unit = (*itr)->getTarget();
@@ -815,7 +835,7 @@ public:
handler->PSendSysMessage(" %u. No Unit - threat %f", ++count, (*itr)->getThreat());
continue;
}
handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", ++count, unit->GetName().c_str(), unit->GetGUIDLow(), (*itr)->getThreat());
handler->PSendSysMessage(" %u. %s (%s) - threat %f", ++count, unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), (*itr)->getThreat());
}
ThreatContainer::StorageType const& threatList2 = target->getThreatManager().getOfflineThreatList();
for (itr = threatList2.begin(); itr != threatList2.end(); ++itr)
@@ -826,7 +846,7 @@ public:
handler->PSendSysMessage(" %u. [offline] No Unit - threat %f", ++count, (*itr)->getThreat());
continue;
}
handler->PSendSysMessage(" %u. [offline] %s (guid %u) - threat %f", ++count, unit->GetName().c_str(), unit->GetGUIDLow(), (*itr)->getThreat());
handler->PSendSysMessage(" %u. [offline] %s (%s) - threat %f", ++count, unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), (*itr)->getThreat());
}
handler->SendSysMessage("End of threat list.");
@@ -840,11 +860,12 @@ public:
target = handler->GetSession()->GetPlayer();
HostileReference* ref = target->getHostileRefManager().getFirst();
uint32 count = 0;
handler->PSendSysMessage("Hostil reference list of %s (guid %u)", target->GetName().c_str(), target->GetGUIDLow());
handler->PSendSysMessage("Hostil reference list of %s (%s)", target->GetName().c_str(), target->GetGUID().ToString().c_str());
while (ref)
{
if (Unit* unit = ref->GetSource()->GetOwner())
handler->PSendSysMessage(" %u. %s %s (guid %u) - threat %f", ++count, (ref->isOnline() ? "" : "[offline]"), unit->GetName().c_str(), unit->GetGUIDLow(), ref->getThreat());
handler->PSendSysMessage(" %u. %s %s (%s) - threat %f", ++count, (ref->isOnline() ? "" : "[offline]"),
unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), ref->getThreat());
else
handler->PSendSysMessage(" %u. No Owner - threat %f", ++count, ref->getThreat());
ref = ref->next();
@@ -942,7 +963,7 @@ public:
Map* map = handler->GetSession()->GetPlayer()->GetMap();
if (!v->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_VEHICLE), map, handler->GetSession()->GetPlayer()->GetPhaseMask(), entry, id, x, y, z, o))
if (!v->Create(map->GenerateLowGuid<HighGuid::Vehicle>(), map, handler->GetSession()->GetPlayer()->GetPhaseMask(), entry, id, x, y, z, o))
{
delete v;
return false;
@@ -984,10 +1005,10 @@ public:
if (!e || !f)
return false;
uint32 guid = (uint32)atoi(e);
ObjectGuid::LowType guid = (uint32)atoi(e);
uint32 index = (uint32)atoi(f);
Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM));
Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(ObjectGuid::Create<HighGuid::Item>(guid));
if (!i)
return false;
@@ -1014,11 +1035,11 @@ public:
if (!e || !f || !g)
return false;
uint32 guid = (uint32)atoi(e);
ObjectGuid::LowType guid = (uint32)atoi(e);
uint32 index = (uint32)atoi(f);
uint32 value = (uint32)atoi(g);
Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM));
Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(ObjectGuid::Create<HighGuid::Item>(guid));
if (!i)
return false;
@@ -1040,9 +1061,9 @@ public:
if (!e)
return false;
uint32 guid = (uint32)atoi(e);
ObjectGuid::LowType guid = (uint32)atoi(e);
Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM));
Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(ObjectGuid::Create<HighGuid::Item>(guid));
if (!i)
return false;
@@ -1128,12 +1149,12 @@ public:
return false;
}
uint64 guid = target->GetGUID();
ObjectGuid guid = target->GetGUID();
uint32 opcode = (uint32)atoi(x);
if (opcode >= target->GetValuesCount())
{
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, GUID_LOPART(guid), target->GetValuesCount());
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, guid.GetCounter(), target->GetValuesCount());
return false;
}
@@ -1145,13 +1166,13 @@ public:
{
uint32 value = (uint32)atoi(y);
target->SetUInt32Value(opcode, value);
handler->PSendSysMessage(LANG_SET_UINT_FIELD, GUID_LOPART(guid), opcode, value);
handler->PSendSysMessage(LANG_SET_UINT_FIELD, guid.GetCounter(), opcode, value);
}
else
{
float value = (float)atof(y);
target->SetFloatValue(opcode, value);
handler->PSendSysMessage(LANG_SET_FLOAT_FIELD, GUID_LOPART(guid), opcode, value);
handler->PSendSysMessage(LANG_SET_FLOAT_FIELD, guid.GetCounter(), opcode, value);
}
return true;
@@ -1176,12 +1197,12 @@ public:
return false;
}
uint64 guid = target->GetGUID();
ObjectGuid guid = target->GetGUID();
uint32 opcode = (uint32)atoi(x);
if (opcode >= target->GetValuesCount())
{
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, GUID_LOPART(guid), target->GetValuesCount());
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, guid.GetCounter(), target->GetValuesCount());
return false;
}
@@ -1192,12 +1213,12 @@ public:
if (isInt32)
{
uint32 value = target->GetUInt32Value(opcode);
handler->PSendSysMessage(LANG_GET_UINT_FIELD, GUID_LOPART(guid), opcode, value);
handler->PSendSysMessage(LANG_GET_UINT_FIELD, guid.GetCounter(), opcode, value);
}
else
{
float value = target->GetFloatValue(opcode);
handler->PSendSysMessage(LANG_GET_FLOAT_FIELD, GUID_LOPART(guid), opcode, value);
handler->PSendSysMessage(LANG_GET_FLOAT_FIELD, guid.GetCounter(), opcode, value);
}
return true;
@@ -1219,7 +1240,7 @@ public:
if (opcode >= handler->GetSession()->GetPlayer()->GetValuesCount())
{
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, handler->GetSession()->GetPlayer()->GetGUIDLow(), handler->GetSession()->GetPlayer()->GetValuesCount());
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, handler->GetSession()->GetPlayer()->GetGUID().GetCounter(), handler->GetSession()->GetPlayer()->GetValuesCount());
return false;
}
@@ -1269,13 +1290,13 @@ public:
{
value = unit->GetUInt32Value(updateIndex);
handler->PSendSysMessage(LANG_UPDATE, unit->GetGUIDLow(), updateIndex, value);
handler->PSendSysMessage(LANG_UPDATE, unit->GetGUID().GetCounter(), updateIndex, value);
return true;
}
value = atoi(val);
handler->PSendSysMessage(LANG_UPDATE_CHANGE, unit->GetGUIDLow(), updateIndex, value);
handler->PSendSysMessage(LANG_UPDATE_CHANGE, unit->GetGUID().GetCounter(), updateIndex, value);
unit->SetUInt32Value(updateIndex, value);

View File

@@ -96,7 +96,7 @@ public:
handler->SendSysMessage(LANG_USE_BOL);
return false;
}
data.append(target->GetPackGUID());
data << target->GetPackGUID();
data << uint32(0); // unknown
target->SendMessageToSet(&data, true);
handler->PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, handler->GetNameLink(target).c_str(), args);
@@ -110,8 +110,7 @@ public:
bool footer = false;
std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers();
HashMapHolder<Player>::MapType const& m = ObjectAccessor::GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
{
AccountTypes itrSec = itr->second->GetSession()->GetSecurity();

View File

@@ -123,11 +123,11 @@ public:
float z = fields[2].GetFloat();
float ort = fields[3].GetFloat();
int mapId = fields[4].GetUInt16();
uint32 guid = fields[5].GetUInt32();
ObjectGuid::LowType guid = fields[5].GetUInt32();
uint32 id = fields[6].GetUInt32();
// if creature is in same map with caster go at its current location
if (Creature* creature = ObjectAccessor::GetCreature(*player, MAKE_NEW_GUID(guid, id, HIGHGUID_UNIT)))
if (Creature* creature = ObjectAccessor::GetCreature(*player, ObjectGuid::Create<HighGuid::Unit>(id, guid)))
{
x = creature->GetPositionX();
y = creature->GetPositionY();

View File

@@ -68,16 +68,11 @@ public:
if (!id)
return false;
uint32 guidLow = atoi(id);
ObjectGuid::LowType guidLow = atoi(id);
if (!guidLow)
return false;
GameObject* object = nullptr;
// by DB guid
if (GameObjectData const* goData = sObjectMgr->GetGOData(guidLow))
object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, goData->id);
GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
@@ -137,7 +132,7 @@ public:
Map* map = player->GetMap();
GameObject* object = sObjectMgr->IsGameObjectStaticTransport(objectInfo->entry) ? new StaticTransport() : new GameObject();
uint32 guidLow = sObjectMgr->GenerateRecycledLowGuid(HIGHGUID_GAMEOBJECT);
ObjectGuid::LowType guidLow = map->GenerateLowGuid<HighGuid::GameObject>();
if (!object->Create(guidLow, objectInfo->entry, map, player->GetPhaseMaskForSpawn(), x, y, z, o, G3D::Quat(), 0, GO_STATE_READY))
{
@@ -270,7 +265,8 @@ public:
bool found = false;
float x, y, z, o;
uint32 guidLow, id, phase;
ObjectGuid::LowType guidLow;
uint32 id, phase;
uint16 mapId;
uint32 poolId;
@@ -304,7 +300,7 @@ public:
return false;
}
GameObject* target = handler->GetSession()->GetPlayer()->GetMap()->GetGameObject(MAKE_NEW_GUID(guidLow, id, HIGHGUID_GAMEOBJECT));
GameObject* target = handler->GetSession()->GetPlayer()->GetMap()->GetGameObject(ObjectGuid::Create<HighGuid::GameObject>(id, guidLow));
handler->PSendSysMessage(LANG_GAMEOBJECT_DETAIL, guidLow, objectInfo->name.c_str(), guidLow, id, x, y, z, mapId, o, phase);
@@ -330,16 +326,11 @@ public:
if (!id)
return false;
uint32 guidLow = atoi(id);
ObjectGuid::LowType guidLow = atoi(id);
if (!guidLow)
return false;
GameObject* object = nullptr;
// by DB guid
if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);
GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
@@ -347,13 +338,13 @@ public:
return false;
}
uint64 ownerGuid = object->GetOwnerGUID();
ObjectGuid ownerGuid = object->GetOwnerGUID();
if (ownerGuid)
{
Unit* owner = ObjectAccessor::GetUnit(*handler->GetSession()->GetPlayer(), ownerGuid);
if (!owner || !IS_PLAYER_GUID(ownerGuid))
if (!owner || !ownerGuid.IsPlayer())
{
handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(ownerGuid), object->GetGUIDLow());
handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, ownerGuid.GetCounter(), object->GetSpawnId());
handler->SetSentErrorMessage(true);
return false;
}
@@ -365,7 +356,7 @@ public:
object->Delete();
object->DeleteFromDB();
handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, object->GetGUIDLow());
handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, object->GetSpawnId());
return true;
}
@@ -378,16 +369,11 @@ public:
if (!id)
return false;
uint32 guidLow = atoi(id);
ObjectGuid::LowType guidLow = atoi(id);
if (!guidLow)
return false;
GameObject* object = nullptr;
// by DB guid
if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);
GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
@@ -423,7 +409,7 @@ public:
object->SaveToDB();
object->Refresh();
handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, object->GetGUIDLow(), object->GetGOInfo()->name.c_str(), object->GetGUIDLow(), oz, oy, ox);
handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, object->GetSpawnId(), object->GetGOInfo()->name.c_str(), object->GetSpawnId(), oz, oy, ox);
return true;
}
@@ -436,16 +422,11 @@ public:
if (!id)
return false;
uint32 guidLow = atoi(id);
ObjectGuid::LowType guidLow = atoi(id);
if (!guidLow)
return false;
GameObject* object = nullptr;
// by DB guid
if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);
GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
@@ -488,7 +469,7 @@ public:
object->SaveToDB();
object->Refresh();
handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, object->GetGUIDLow(), object->GetGOInfo()->name.c_str(), object->GetGUIDLow());
handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, object->GetSpawnId(), object->GetGOInfo()->name.c_str(), object->GetSpawnId());
return true;
}
@@ -501,16 +482,11 @@ public:
if (!id)
return false;
uint32 guidLow = atoi(id);
ObjectGuid::LowType guidLow = atoi(id);
if (!guidLow)
return false;
GameObject* object = nullptr;
// by DB guid
if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);
GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
@@ -556,7 +532,7 @@ public:
do
{
Field* fields = result->Fetch();
uint32 guid = fields[0].GetUInt32();
ObjectGuid::LowType guid = fields[0].GetUInt32();
uint32 entry = fields[1].GetUInt32();
float x = fields[2].GetFloat();
float y = fields[3].GetFloat();
@@ -647,8 +623,7 @@ public:
if (guidLow > 0)
{
if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);
object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
}
else
object = handler->GetSession()->GetPlayer()->FindNearestGameObject(-guidLow, 30.0f);

View File

@@ -131,7 +131,7 @@ public:
return false;
// if not guild name only (in "") then player name
uint64 targetGuid;
ObjectGuid targetGuid;
if (!handler->extractPlayerTarget(*args != '"' ? (char*)args : nullptr, nullptr, &targetGuid))
return false;
@@ -155,11 +155,11 @@ public:
static bool HandleGuildUninviteCommand(ChatHandler* handler, char const* args)
{
Player* target;
uint64 targetGuid;
ObjectGuid targetGuid;
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid))
return false;
uint32 guildId = target ? target->GetGuildId() : Player::GetGuildIdFromStorage(GUID_LOPART(targetGuid));
uint32 guildId = target ? target->GetGuildId() : Player::GetGuildIdFromStorage(targetGuid.GetCounter());
if (!guildId)
return false;
@@ -180,12 +180,12 @@ public:
return false;
Player* target;
uint64 targetGuid;
ObjectGuid targetGuid;
std::string target_name;
if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &target_name))
return false;
uint32 guildId = target ? target->GetGuildId() : Player::GetGuildIdFromStorage(GUID_LOPART(targetGuid));
uint32 guildId = target ? target->GetGuildId() : Player::GetGuildIdFromStorage(targetGuid.GetCounter());
if (!guildId)
return false;
@@ -217,8 +217,8 @@ public:
// Display Guild Information
handler->PSendSysMessage(LANG_GUILD_INFO_NAME, guild->GetName().c_str(), guild->GetId()); // Guild Id + Name
std::string guildMasterName;
if (sObjectMgr->GetPlayerNameByGUID(guild->GetLeaderGUID(), guildMasterName))
handler->PSendSysMessage(LANG_GUILD_INFO_GUILD_MASTER, guildMasterName.c_str(), GUID_LOPART(guild->GetLeaderGUID())); // Guild Master
if (sObjectMgr->GetPlayerNameByGUID(guild->GetLeaderGUID().GetCounter(), guildMasterName))
handler->PSendSysMessage(LANG_GUILD_INFO_GUILD_MASTER, guildMasterName.c_str(), guild->GetLeaderGUID().GetCounter()); // Guild Master
// Format creation date
char createdDateStr[20];

View File

@@ -57,7 +57,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
uint32 amount = (uint32)atoi(args);
@@ -76,7 +76,7 @@ public:
}
// check online security
if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer(), 0))
if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer()))
return false;
handler->GetSession()->GetPlayer()->RewardHonor(target, 1);
@@ -94,7 +94,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
target->UpdateHonorFields();

View File

@@ -66,7 +66,7 @@ public:
uint32 counter = 0;
for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
{
BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(player->GetGUIDLow(), Difficulty(i));
BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(player->GetGUID(), Difficulty(i));
for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end(); ++itr)
{
InstanceSave* save = itr->second.save;
@@ -108,7 +108,7 @@ public:
for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
{
BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(player->GetGUIDLow(), Difficulty(i));
BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(player->GetGUID(), Difficulty(i));
for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end();)
{
InstanceSave* save = itr->second.save;
@@ -118,7 +118,7 @@ public:
uint32 ttr = (resetTime >= time(nullptr) ? resetTime - time(nullptr) : 0);
std::string timeleft = GetTimeString(ttr);
handler->PSendSysMessage("unbinding map: %d, inst: %d, perm: %s, diff: %d, canReset: %s, TTR: %s%s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str(), (itr->second.extended ? " (extended)" : ""));
sInstanceSaveMgr->PlayerUnbindInstance(player->GetGUIDLow(), itr->first, Difficulty(i), true, player);
sInstanceSaveMgr->PlayerUnbindInstance(player->GetGUID(), itr->first, Difficulty(i), true, player);
itr = m_boundInstances.begin();
counter++;
}

View File

@@ -16,7 +16,7 @@ void GetPlayerInfo(ChatHandler* handler, Player* player)
if (!player)
return;
uint64 guid = player->GetGUID();
ObjectGuid guid = player->GetGUID();
lfg::LfgDungeonSet dungeons = sLFGMgr->GetSelectedDungeons(guid);
std::string const& state = lfg::GetStateString(sLFGMgr->GetState(guid));
@@ -73,7 +73,7 @@ public:
return true;
}
uint64 guid = grp->GetGUID();
ObjectGuid guid = grp->GetGUID();
std::string const& state = lfg::GetStateString(sLFGMgr->GetState(guid));
handler->PSendSysMessage(LANG_LFG_GROUP_INFO, grp->isLFGGroup(),
state.c_str(), sLFGMgr->GetDungeon(guid));

View File

@@ -94,12 +94,12 @@ public:
{
do
{
Field* fields = result->Fetch();
uint32 guid = fields[0].GetUInt32();
float x = fields[1].GetFloat();
float y = fields[2].GetFloat();
float z = fields[3].GetFloat();
uint16 mapId = fields[4].GetUInt16();
Field* fields = result->Fetch();
ObjectGuid::LowType guid = fields[0].GetUInt32();
float x = fields[1].GetFloat();
float y = fields[2].GetFloat();
float z = fields[3].GetFloat();
uint16 mapId = fields[4].GetUInt16();
if (handler->GetSession())
handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, cInfo->Name.c_str(), x, y, z, mapId);
@@ -378,13 +378,13 @@ public:
{
do
{
Field* fields = result->Fetch();
uint32 guid = fields[0].GetUInt32();
float x = fields[1].GetFloat();
float y = fields[2].GetFloat();
float z = fields[3].GetFloat();
uint16 mapId = fields[4].GetUInt16();
uint32 entry = fields[5].GetUInt32();
Field* fields = result->Fetch();
ObjectGuid::LowType guid = fields[0].GetUInt32();
float x = fields[1].GetFloat();
float y = fields[2].GetFloat();
float z = fields[3].GetFloat();
uint16 mapId = fields[4].GetUInt16();
uint32 entry = fields[5].GetUInt32();
if (handler->GetSession())
handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name.c_str(), x, y, z, mapId);
@@ -427,8 +427,8 @@ public:
handler->PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, aura->GetId(), (handler->GetSession() ? ss_name.str().c_str() : name),
aurApp->GetEffectMask(), aura->GetCharges(), aura->GetStackAmount(), aurApp->GetSlot(),
aura->GetDuration(), aura->GetMaxDuration(), (aura->IsPassive() ? passiveStr : ""),
(talent ? talentStr : ""), IS_PLAYER_GUID(aura->GetCasterGUID()) ? "player" : "creature",
GUID_LOPART(aura->GetCasterGUID()));
(talent ? talentStr : ""), aura->GetCasterGUID().IsPlayer() ? "player" : "creature",
aura->GetCasterGUID().GetCounter());
}
if (!args || std::string(args) != "all")

View File

@@ -1414,11 +1414,11 @@ public:
do
{
Field* characterFields = result2->Fetch();
uint32 guid = characterFields[0].GetUInt32();
std::string name = characterFields[1].GetString();
Field* characterFields = result2->Fetch();
ObjectGuid::LowType guid = characterFields[0].GetUInt32();
std::string name = characterFields[1].GetString();
uint8 plevel = 0, prace = 0, pclass = 0;
bool online = (ObjectAccessor::FindPlayerInOrOutOfWorld(MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER)) != nullptr);
bool online = ObjectAccessor::FindPlayerByLowGUID(guid) != nullptr;
if (const GlobalPlayerData* gpd = sWorld->GetGlobalPlayerData(guid))
{

View File

@@ -368,16 +368,48 @@ public:
WorldObject* object = nullptr;
if (*args)
{
uint64 guid = handler->extractGuidFromLink((char*)args);
if (guid)
object = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT);
if (!object)
{
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
handler->SetSentErrorMessage(true);
HighGuid guidHigh;
ObjectGuid::LowType guidLow = handler->extractLowGuidFromLink((char*)args, guidHigh);
if (!guidLow)
return false;
switch (guidHigh)
{
case HighGuid::Player:
{
object = ObjectAccessor::FindPlayerByLowGUID(guidLow);
if (!object)
{
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
handler->SetSentErrorMessage(true);
}
break;
}
case HighGuid::Unit:
{
object = handler->GetCreatureFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->SendSysMessage(LANG_COMMAND_NOCREATUREFOUND);
handler->SetSentErrorMessage(true);
}
break;
}
case HighGuid::GameObject:
{
object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND);
handler->SetSentErrorMessage(true);
}
break;
}
default:
return false;
}
if (!object)
return false;
}
else
{
@@ -514,7 +546,7 @@ public:
static bool HandleAppearCommand(ChatHandler* handler, char const* args)
{
Player* target;
uint64 targetGuid;
ObjectGuid targetGuid;
std::string targetName;
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
return false;
@@ -530,7 +562,7 @@ public:
if (target)
{
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
std::string chrNameLink = handler->playerLink(targetName);
@@ -578,10 +610,10 @@ public:
}
// if the GM is bound to another instance, he will not be bound to another one
InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(_player->GetGUIDLow(), target->GetMapId(), target->GetDifficulty(map->IsRaid()));
InstancePlayerBind* bind = sInstanceSaveMgr->PlayerGetBoundInstance(_player->GetGUID(), target->GetMapId(), target->GetDifficulty(map->IsRaid()));
if (!bind)
if (InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(target->GetInstanceId()))
sInstanceSaveMgr->PlayerBindToInstance(_player->GetGUIDLow(), save, !save->CanReset(), _player);
sInstanceSaveMgr->PlayerBindToInstance(_player->GetGUID(), save, !save->CanReset(), _player);
if (map->IsRaid())
_player->SetRaidDifficulty(target->GetRaidDifficulty());
@@ -618,7 +650,7 @@ public:
float x, y, z, o;
uint32 map;
bool in_flight;
if (!Player::LoadPositionFromDB(map, x, y, z, o, in_flight, targetGuid))
if (!Player::LoadPositionFromDB(map, x, y, z, o, in_flight, targetGuid.GetCounter()))
return false;
// stop flight if need
@@ -640,7 +672,7 @@ public:
static bool HandleSummonCommand(ChatHandler* handler, char const* args)
{
Player* target;
uint64 targetGuid;
ObjectGuid targetGuid;
std::string targetName;
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
return false;
@@ -657,7 +689,7 @@ public:
{
std::string nameLink = handler->playerLink(targetName);
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
if (target->IsBeingTeleported())
@@ -692,7 +724,7 @@ public:
Map* destMap = target->GetMap();
if (destMap->Instanceable() && destMap->GetInstanceId() != map->GetInstanceId())
sInstanceSaveMgr->PlayerUnbindInstance(target->GetGUIDLow(), map->GetInstanceId(), target->GetDungeonDifficulty(), true, target);
sInstanceSaveMgr->PlayerUnbindInstance(target->GetGUID(), map->GetInstanceId(), target->GetDungeonDifficulty(), true, target);
// we are in an instance, and can only summon players in our group with us as leader
if (!handler->GetSession()->GetPlayer()->GetGroup() || !target->GetGroup() ||
@@ -755,7 +787,7 @@ public:
return false;
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
Group* group = target->GetGroup();
@@ -791,7 +823,7 @@ public:
continue;
// check online security
if (handler->HasLowerSecurity(player, 0))
if (handler->HasLowerSecurity(player))
return false;
std::string plNameLink = handler->GetNameLink(player);
@@ -858,7 +890,7 @@ public:
if (target->GetTypeId() == TYPEID_PLAYER)
{
if (handler->HasLowerSecurity(target->ToPlayer(), 0, false))
if (handler->HasLowerSecurity(target->ToPlayer()))
return false;
}
@@ -880,7 +912,7 @@ public:
static bool HandleReviveCommand(ChatHandler* handler, char const* args)
{
Player* target;
uint64 targetGuid;
ObjectGuid targetGuid;
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid))
return false;
@@ -891,8 +923,10 @@ public:
target->SaveToDB(false, false);
}
else
// will resurrected at login without corpse
sObjectAccessor->ConvertCorpseForPlayer(targetGuid);
{
SQLTransaction trans(nullptr);
Player::OfflineResurrect(targetGuid, trans);
}
return true;
}
@@ -923,16 +957,16 @@ public:
static bool HandleGUIDCommand(ChatHandler* handler, char const* /*args*/)
{
uint64 guid = handler->GetSession()->GetPlayer()->GetTarget();
ObjectGuid guid = handler->GetSession()->GetPlayer()->GetTarget();
if (guid == 0)
if (!guid)
{
handler->SendSysMessage(LANG_NO_SELECTION);
handler->SetSentErrorMessage(true);
return false;
}
handler->PSendSysMessage(LANG_OBJECT_GUID, GUID_LOPART(guid), GUID_HIPART(guid));
handler->PSendSysMessage(LANG_OBJECT_GUID, guid.ToString().c_str());
return true;
}
@@ -1026,19 +1060,50 @@ public:
static bool HandleGetDistanceCommand(ChatHandler* handler, char const* args)
{
WorldObject* obj = nullptr;
if (*args)
{
uint64 guid = handler->extractGuidFromLink((char*)args);
if (guid)
obj = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT);
if (!obj)
{
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
handler->SetSentErrorMessage(true);
HighGuid guidHigh;
ObjectGuid::LowType guidLow = handler->extractLowGuidFromLink((char*)args, guidHigh);
if (!guidLow)
return false;
switch (guidHigh)
{
case HighGuid::Player:
{
obj = ObjectAccessor::FindPlayerByLowGUID(guidLow);
if (!obj)
{
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
handler->SetSentErrorMessage(true);
}
break;
}
case HighGuid::Unit:
{
obj = handler->GetCreatureFromPlayerMapByDbGuid(guidLow);
if (!obj)
{
handler->SendSysMessage(LANG_COMMAND_NOCREATUREFOUND);
handler->SetSentErrorMessage(true);
}
break;
}
case HighGuid::GameObject:
{
obj = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!obj)
{
handler->SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND);
handler->SetSentErrorMessage(true);
}
break;
}
default:
return false;
}
if (!obj)
return false;
}
else
{
@@ -1063,7 +1128,7 @@ public:
return false;
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
if (target->IsBeingTeleported())
@@ -1116,7 +1181,7 @@ public:
// Save all players in the world
static bool HandleSaveAllCommand(ChatHandler* handler, char const* /*args*/)
{
sObjectAccessor->SaveAllPlayers();
ObjectAccessor::SaveAllPlayers();
handler->SendSysMessage(LANG_PLAYERS_SAVED);
return true;
}
@@ -1137,7 +1202,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
std::string kickReasonStr = handler->GetAcoreString(LANG_NO_REASON);
@@ -1725,15 +1790,15 @@ public:
static bool HandlePInfoCommand(ChatHandler* handler, char const* args)
{
Player* target;
uint64 targetGuid;
ObjectGuid targetGuid;
std::string targetName;
PreparedStatement* stmt = nullptr;
uint32 parseGUID = MAKE_NEW_GUID(atol((char*)args), 0, HIGHGUID_PLAYER);
ObjectGuid parseGUID = ObjectGuid::Create<HighGuid::Player>(atol((char*)args));
if (sObjectMgr->GetPlayerNameByGUID(parseGUID, targetName))
if (sObjectMgr->GetPlayerNameByGUID(parseGUID.GetCounter(), targetName))
{
target = ObjectAccessor::FindPlayerInOrOutOfWorld(MAKE_NEW_GUID(parseGUID, 0, HIGHGUID_PLAYER));
target = ObjectAccessor::FindConnectedPlayer(parseGUID);
targetGuid = parseGUID;
}
else if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
@@ -1741,7 +1806,7 @@ public:
// Account data print variables
std::string userName = handler->GetAcoreString(LANG_ERROR);
uint32 lowguid = GUID_LOPART(targetGuid);
ObjectGuid::LowType lowguid = targetGuid.GetCounter();
uint32 accId = 0;
std::string eMail = handler->GetAcoreString(LANG_ERROR);
std::string regMail = handler->GetAcoreString(LANG_ERROR);
@@ -1795,7 +1860,7 @@ public:
if (target)
{
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
accId = target->GetSession()->GetAccountId();
@@ -1821,7 +1886,7 @@ public:
// Query informations from the DB
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PINFO);
stmt->setUInt32(0, GUID_LOPART(targetGuid));
stmt->setUInt32(0, lowguid);
PreparedQueryResult charInfoResult = CharacterDatabase.Query(stmt);
if (!charInfoResult)
@@ -1917,7 +1982,7 @@ public:
{
banType = handler->GetAcoreString(LANG_CHARACTER);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_BANS);
stmt->setUInt32(0, GUID_LOPART(targetGuid));
stmt->setUInt32(0, lowguid);
accBannedResult = CharacterDatabase.Query(stmt);
}
@@ -1948,8 +2013,8 @@ public:
if (charXpResult)
{
Field* fields = charXpResult->Fetch();
xp = fields[0].GetUInt32();
uint32 gguid = fields[1].GetUInt32();
xp = fields[0].GetUInt32();
ObjectGuid::LowType gguid = fields[1].GetUInt32();
if (gguid != 0)
{
@@ -1970,7 +2035,7 @@ public:
// Initiate output
// Output I. LANG_PINFO_PLAYER
handler->PSendSysMessage(LANG_PINFO_PLAYER, target ? "" : handler->GetAcoreString(LANG_OFFLINE), nameLink.c_str(), GUID_LOPART(targetGuid));
handler->PSendSysMessage(LANG_PINFO_PLAYER, target ? "" : handler->GetAcoreString(LANG_OFFLINE), nameLink.c_str(), targetGuid.GetCounter());
// Output II. LANG_PINFO_GM_ACTIVE if character is gamemaster
if (target && target->IsGameMaster())
@@ -2129,7 +2194,7 @@ public:
// Mail Data - an own query, because it may or may not be useful.
// SQL: "SELECT SUM(CASE WHEN (checked & 1) THEN 1 ELSE 0 END) AS 'readmail', COUNT(*) AS 'totalmail' FROM mail WHERE `receiver` = ?"
PreparedStatement* mailQuery = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_MAILS);
mailQuery->setUInt32(0, GUID_LOPART(targetGuid));
mailQuery->setUInt32(0, lowguid);
PreparedQueryResult mailInfoResult = CharacterDatabase.Query(mailQuery);
if (mailInfoResult)
{
@@ -2192,12 +2257,12 @@ public:
muteReasonStr = muteReason;
Player* target;
uint64 targetGuid;
ObjectGuid targetGuid;
std::string targetName;
if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName))
return false;
uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(targetGuid);
uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(targetGuid.GetCounter());
// find only player from same account if any
if (!target)
@@ -2255,7 +2320,7 @@ public:
{
// pussywizard: notify all online GMs
std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers();
HashMapHolder<Player>::MapType const& m = ObjectAccessor::GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
if (itr->second->GetSession()->GetSecurity())
ChatHandler(itr->second->GetSession()).PSendSysMessage(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : handler->GetAcoreString(LANG_CONSOLE)), nameLink.c_str(), notSpeakTime, muteReasonStr.c_str());
@@ -2268,12 +2333,12 @@ public:
static bool HandleUnmuteCommand(ChatHandler* handler, char const* args)
{
Player* target;
uint64 targetGuid;
ObjectGuid targetGuid;
std::string targetName;
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
return false;
uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(targetGuid);
uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(targetGuid.GetCounter());
// find only player from same account if any
if (!target)
@@ -2383,7 +2448,7 @@ public:
return false;
}
handler->PSendSysMessage(LANG_MOVEGENS_LIST, (unit->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), unit->GetGUIDLow());
handler->PSendSysMessage(LANG_MOVEGENS_LIST, (unit->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), unit->GetGUID().GetCounter());
MotionMaster* motionMaster = unit->GetMotionMaster();
float x, y, z;
@@ -2426,9 +2491,9 @@ public:
if (!target)
handler->SendSysMessage(LANG_MOVEGENS_CHASE_NULL);
else if (target->GetTypeId() == TYPEID_PLAYER)
handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName().c_str(), target->GetGUIDLow());
handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName().c_str(), target->GetGUID().GetCounter());
else
handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName().c_str(), target->GetGUIDLow());
handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName().c_str(), target->GetGUID().GetCounter());
break;
}
case FOLLOW_MOTION_TYPE:
@@ -2442,9 +2507,9 @@ public:
if (!target)
handler->SendSysMessage(LANG_MOVEGENS_FOLLOW_NULL);
else if (target->GetTypeId() == TYPEID_PLAYER)
handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName().c_str(), target->GetGUIDLow());
handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName().c_str(), target->GetGUID().GetCounter());
else
handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName().c_str(), target->GetGUIDLow());
handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName().c_str(), target->GetGUID().GetCounter());
break;
}
case HOME_MOTION_TYPE:
@@ -2520,7 +2585,7 @@ public:
if (target->GetTypeId() == TYPEID_PLAYER)
{
if (handler->HasLowerSecurity(target->ToPlayer(), 0, false))
if (handler->HasLowerSecurity(target->ToPlayer()))
return false;
}
@@ -2563,7 +2628,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
target->CombatStop();
@@ -2584,7 +2649,7 @@ public:
return false;
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
// Repair items
@@ -2602,7 +2667,7 @@ public:
{
// format: name "subject text" "mail text"
Player* target;
uint64 targetGuid;
ObjectGuid targetGuid;
std::string targetName;
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
return false;
@@ -2628,12 +2693,12 @@ public:
std::string text = msgText;
// from console show not existed sender
MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM);
MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUID().GetCounter() : 0, MAIL_STATIONERY_GM);
//- TODO: Fix poor design
SQLTransaction trans = CharacterDatabase.BeginTransaction();
MailDraft(subject, text)
.SendMailTo(trans, MailReceiver(target, GUID_LOPART(targetGuid)), sender);
.SendMailTo(trans, MailReceiver(target, targetGuid.GetCounter()), sender);
CharacterDatabase.CommitTransaction(trans);
@@ -2646,7 +2711,7 @@ public:
{
// format: name "subject text" "mail text" item1[:count1] item2[:count2] ... item12[:count12]
Player* receiver;
uint64 receiverGuid;
ObjectGuid receiverGuid;
std::string receiverName;
if (!handler->extractPlayerTarget((char*)args, &receiver, &receiverGuid, &receiverName))
return false;
@@ -2726,7 +2791,7 @@ public:
}
// from console show not existed sender
MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM);
MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUID().GetCounter() : 0, MAIL_STATIONERY_GM);
// fill mail
MailDraft draft(subject, text);
@@ -2742,7 +2807,7 @@ public:
}
}
draft.SendMailTo(trans, MailReceiver(receiver, GUID_LOPART(receiverGuid)), sender);
draft.SendMailTo(trans, MailReceiver(receiver, receiverGuid.GetCounter()), sender);
CharacterDatabase.CommitTransaction(trans);
std::string nameLink = handler->playerLink(receiverName);
@@ -2755,7 +2820,7 @@ public:
/// format: name "subject text" "mail text" money
Player* receiver;
uint64 receiverGuid;
ObjectGuid receiverGuid;
std::string receiverName;
if (!handler->extractPlayerTarget((char*)args, &receiver, &receiverGuid, &receiverName))
return false;
@@ -2786,13 +2851,13 @@ public:
std::string text = msgText;
// from console show not existed sender
MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM);
MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUID().GetCounter() : 0, MAIL_STATIONERY_GM);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
MailDraft(subject, text)
.AddMoney(money)
.SendMailTo(trans, MailReceiver(receiver, GUID_LOPART(receiverGuid)), sender);
.SendMailTo(trans, MailReceiver(receiver, receiverGuid.GetCounter()), sender);
CharacterDatabase.CommitTransaction(trans);
@@ -2868,7 +2933,7 @@ public:
creatureTarget->RemoveCorpse();
creatureTarget->SetHealth(0); // just for nice GM-mode view
pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, player->GetGUID());
pet->SetGuidValue(UNIT_FIELD_CREATEDBY, player->GetGUID());
pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, player->getFaction());
if (!pet->InitStatsForLevel(creatureTarget->getLevel()))
@@ -3050,10 +3115,10 @@ public:
}
else if (targetName)
{
if (uint64 playerGUID = sWorld->GetGlobalPlayerGUID(name))
if (ObjectGuid playerGUID = sWorld->GetGlobalPlayerGUID(name))
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_AURA_FROZEN);
stmt->setUInt32(0, GUID_LOPART(playerGUID));
stmt->setUInt32(0, playerGUID.GetCounter());
CharacterDatabase.Execute(stmt);
handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, name.c_str());
return true;
@@ -3068,7 +3133,7 @@ public:
{
Player* player = nullptr;
Group* group = nullptr;
uint64 guid = 0;
ObjectGuid guid;
char* nameStr = strtok((char*)args, " ");
if (handler->GetPlayerGroupAndGUIDByName(nameStr, player, group, guid))
@@ -3085,7 +3150,7 @@ public:
{
Player* player = nullptr;
Group* group = nullptr;
uint64 guid = 0;
ObjectGuid guid;
char* nameStr = strtok((char*)args, " ");
if (handler->GetPlayerGroupAndGUIDByName(nameStr, player, group, guid))
@@ -3099,7 +3164,7 @@ public:
{
Player* player = nullptr;
Group* group = nullptr;
uint64 guid = 0;
ObjectGuid guid;
char* nameStr = strtok((char*)args, " ");
if (handler->GetPlayerGroupAndGUIDByName(nameStr, player, group, guid, true))
@@ -3116,8 +3181,8 @@ public:
Player* playerSource = nullptr;
Group* groupSource = nullptr;
uint64 guidSource = 0;
uint64 guidTarget = 0;
ObjectGuid guidSource;
ObjectGuid guidTarget;
char* nameplgrStr = strtok((char*)args, " ");
char* nameplStr = strtok(nullptr, " ");
@@ -3167,14 +3232,14 @@ public:
static bool HandleGroupListCommand(ChatHandler* handler, char const* args)
{
Player* playerTarget;
uint64 guidTarget = 0;
ObjectGuid guidTarget;
std::string nameTarget;
uint32 parseGUID = MAKE_NEW_GUID(atol((char*)args), 0, HIGHGUID_PLAYER);
ObjectGuid parseGUID = ObjectGuid::Create<HighGuid::Player>(atol((char*)args));
if (sObjectMgr->GetPlayerNameByGUID(parseGUID, nameTarget))
if (sObjectMgr->GetPlayerNameByGUID(parseGUID.GetCounter(), nameTarget))
{
playerTarget = ObjectAccessor::FindPlayerInOrOutOfWorld(MAKE_NEW_GUID(parseGUID, 0, HIGHGUID_PLAYER));
playerTarget = ObjectAccessor::FindConnectedPlayer(parseGUID);
guidTarget = parseGUID;
}
else if (!handler->extractPlayerTarget((char*)args, &playerTarget, &guidTarget, &nameTarget))
@@ -3185,8 +3250,8 @@ public:
groupTarget = playerTarget->GetGroup();
if (!groupTarget && guidTarget)
if (uint32 groupId = Player::GetGroupIdFromStorage(GUID_LOPART(guidTarget)))
groupTarget = sGroupMgr->GetGroupByGUID(groupId);
if (uint32 groupGUID = Player::GetGroupIdFromStorage(guidTarget.GetCounter()))
groupTarget = sGroupMgr->GetGroupByGUID(groupGUID);
if (groupTarget)
{
@@ -3217,11 +3282,11 @@ public:
if (flags.empty())
flags = "None";
/*Player* p = ObjectAccessor::FindPlayerInOrOutOfWorld((*itr).guid);
/*Player* p = ObjectAccessor::FindConnectedPlayer((*itr).guid);
const char* onlineState = p ? "online" : "offline";
handler->PSendSysMessage(LANG_GROUP_PLAYER_NAME_GUID, slot.name.c_str(), onlineState,
GUID_LOPART(slot.guid), flags.c_str(), lfg::GetRolesString(slot.roles).c_str());*/
slot.guid.GetCounter(), flags.c_str(), lfg::GetRolesString(slot.roles).c_str());*/
}
}
else

View File

@@ -99,7 +99,7 @@ public:
return false;
}
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
handler->PSendSysMessage(LANG_YOU_CHANGE_HP, handler->GetNameLink(target).c_str(), hp, hpm);
@@ -137,7 +137,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
handler->PSendSysMessage(LANG_YOU_CHANGE_MANA, handler->GetNameLink(target).c_str(), mana, manam);
@@ -186,7 +186,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
handler->PSendSysMessage(LANG_YOU_CHANGE_ENERGY, handler->GetNameLink(target).c_str(), energy / 10, energym / 10);
@@ -239,7 +239,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
handler->PSendSysMessage(LANG_YOU_CHANGE_RAGE, handler->GetNameLink(target).c_str(), rage / 10, ragem / 10);
@@ -308,7 +308,7 @@ public:
uint32 flag = target->GetUInt32Value(UNIT_FIELD_FLAGS);
uint32 npcflag = target->GetUInt32Value(UNIT_NPC_FLAGS);
uint32 dyflag = target->GetUInt32Value(UNIT_DYNAMIC_FLAGS);
handler->PSendSysMessage(LANG_CURRENT_FACTION, target->GetGUIDLow(), factionid, flag, npcflag, dyflag);
handler->PSendSysMessage(LANG_CURRENT_FACTION, target->GetGUID().GetCounter(), factionid, flag, npcflag, dyflag);
return true;
}
@@ -344,7 +344,7 @@ public:
return false;
}
handler->PSendSysMessage(LANG_YOU_CHANGE_FACTION, target->GetGUIDLow(), factionid, flag, npcflag, dyflag);
handler->PSendSysMessage(LANG_YOU_CHANGE_FACTION, target->GetGUID().GetCounter(), factionid, flag, npcflag, dyflag);
target->setFaction(factionid);
target->SetUInt32Value(UNIT_FIELD_FLAGS, flag);
@@ -393,7 +393,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
handler->PSendSysMessage(LANG_YOU_CHANGE_SPELLFLATID, spellflatid, val, mark, handler->GetNameLink(target).c_str());
@@ -431,7 +431,7 @@ public:
if (target->GetTypeId() == TYPEID_PLAYER)
{
// check online security
if (handler->HasLowerSecurity(target->ToPlayer(), 0))
if (handler->HasLowerSecurity(target->ToPlayer()))
return false;
target->ToPlayer()->SetFreeTalentPoints(tp);
target->ToPlayer()->SendTalentsInfoData(false);
@@ -443,7 +443,7 @@ public:
if (owner && owner->GetTypeId() == TYPEID_PLAYER && ((Pet*)target)->IsPermanentPetFor(owner->ToPlayer()))
{
// check online security
if (handler->HasLowerSecurity(owner->ToPlayer(), 0))
if (handler->HasLowerSecurity(owner->ToPlayer()))
return false;
((Pet*)target)->SetFreeTalentPoints(tp);
owner->ToPlayer()->SendTalentsInfoData(true);
@@ -482,7 +482,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
std::string targetNameLink = handler->GetNameLink(target);
@@ -532,7 +532,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
std::string targetNameLink = handler->GetNameLink(target);
@@ -579,7 +579,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
std::string targetNameLink = handler->GetNameLink(target);
@@ -626,7 +626,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
std::string targetNameLink = handler->GetNameLink(target);
@@ -673,7 +673,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
handler->PSendSysMessage(LANG_YOU_CHANGE_FLY_SPEED, FSpeed, handler->GetNameLink(target).c_str());
@@ -710,7 +710,7 @@ public:
if (Player* player = target->ToPlayer())
{
// check online security
if (handler->HasLowerSecurity(player, 0))
if (handler->HasLowerSecurity(player))
return false;
handler->PSendSysMessage(LANG_YOU_CHANGE_SIZE, Scale, handler->GetNameLink(player).c_str());
@@ -958,7 +958,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
handler->PSendSysMessage(LANG_YOU_GIVE_MOUNT, handler->GetNameLink(target).c_str());
@@ -969,14 +969,14 @@ public:
target->Mount(mId);
WorldPacket data(SMSG_FORCE_RUN_SPEED_CHANGE, (8 + 4 + 1 + 4));
data.append(target->GetPackGUID());
data << target->GetPackGUID();
data << (uint32)0;
data << (uint8)0; //new 2.1.0
data << float(speed);
target->SendMessageToSet(&data, true);
data.Initialize(SMSG_FORCE_SWIM_SPEED_CHANGE, (8 + 4 + 4));
data.append(target->GetPackGUID());
data << target->GetPackGUID();
data << (uint32)0;
data << float(speed);
target->SendMessageToSet(&data, true);
@@ -999,7 +999,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
int32 moneyToAdd = 0;
@@ -1073,7 +1073,7 @@ public:
}
// check online security
if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer(), 0))
if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer()))
return false;
char* pField = strtok((char*)args, " ");
@@ -1127,7 +1127,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
int32 amount = (uint32)atoi(args);
@@ -1168,7 +1168,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
char* factionTxt = handler->extractKeyFromLink((char*)args, "Hfaction");
@@ -1264,7 +1264,7 @@ public:
target = handler->GetSession()->GetPlayer();
// check online security
else if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer(), 0))
else if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer()))
return false;
target->SetDisplayId(display_id);
@@ -1280,7 +1280,7 @@ public:
target = handler->GetSession()->GetPlayer();
// check online security
else if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer(), 0))
else if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer()))
return false;
target->DeMorph();
@@ -1300,7 +1300,7 @@ public:
target = handler->GetSession()->GetPlayer();
// check online security
else if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer(), 0))
else if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer()))
return false;
target->SetPhaseMask(phasemask, true);

View File

@@ -213,7 +213,7 @@ public:
if (Transport* tt = chr->GetTransport())
if (MotionTransport* trans = tt->ToMotionTransport())
{
uint32 guid = sObjectMgr->GenerateRecycledLowGuid(HIGHGUID_UNIT);
ObjectGuid::LowType guid = sObjectMgr->GenerateCreatureSpawnId();
CreatureData& data = sObjectMgr->NewOrExistCreatureData(guid);
data.id = id;
data.phaseMask = chr->GetPhaseMaskForSpawn();
@@ -231,7 +231,7 @@ public:
}
Creature* creature = new Creature();
if (!creature->Create(sObjectMgr->GenerateRecycledLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
{
delete creature;
return false;
@@ -239,20 +239,20 @@ public:
creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
uint32 db_guid = creature->GetDBTableGUIDLow();
ObjectGuid::LowType spawnId = creature->GetSpawnId();
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells()
// current "creature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior
creature->CleanupsBeforeDelete();
delete creature;
creature = new Creature();
if (!creature->LoadCreatureFromDB(db_guid, map))
if (!creature->LoadCreatureFromDB(spawnId, map, true, false, true))
{
delete creature;
return false;
}
sObjectMgr->AddCreatureToGrid(db_guid, sObjectMgr->GetCreatureData(db_guid));
sObjectMgr->AddCreatureToGrid(spawnId, sObjectMgr->GetCreatureData(spawnId));
return true;
}
@@ -322,22 +322,22 @@ public:
char* guidStr = strtok((char*)args, " ");
char* waitStr = strtok((char*)nullptr, " ");
uint32 lowGuid = atoi((char*)guidStr);
ObjectGuid::LowType spawnId = atoi((char*)guidStr);
Creature* creature = nullptr;
/* FIXME: impossible without entry
if (lowguid)
creature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), MAKE_GUID(lowguid, HIGHGUID_UNIT));
creature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), MAKE_GUID(lowguid, HighGuid::Unit));
*/
// attempt check creature existence by DB data
if (!creature)
{
CreatureData const* data = sObjectMgr->GetCreatureData(lowGuid);
CreatureData const* data = sObjectMgr->GetCreatureData(spawnId);
if (!data)
{
handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowGuid);
handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, spawnId);
handler->SetSentErrorMessage(true);
return false;
}
@@ -345,7 +345,7 @@ public:
else
{
// obtain real GUID for DB operations
lowGuid = creature->GetDBTableGUIDLow();
spawnId = creature->GetSpawnId();
}
int wait = waitStr ? atoi(waitStr) : 0;
@@ -357,7 +357,7 @@ public:
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_MOVEMENT_TYPE);
stmt->setUInt8(0, uint8(WAYPOINT_MOTION_TYPE));
stmt->setUInt32(1, lowGuid);
stmt->setUInt32(1, spawnId);
WorldDatabase.Execute(stmt);
@@ -470,12 +470,12 @@ public:
if (!cId)
return false;
uint32 lowguid = atoi(cId);
ObjectGuid::LowType lowguid = atoi(cId);
if (!lowguid)
return false;
if (CreatureData const* cr_data = sObjectMgr->GetCreatureData(lowguid))
unit = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(lowguid, cr_data->id, HIGHGUID_UNIT));
unit = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid::Create<HighGuid::Unit>(cr_data->id, lowguid));
}
else
unit = handler->getSelectedCreature();
@@ -729,7 +729,7 @@ public:
std::string curRespawnDelayStr = secsToTimeString(uint64(curRespawnDelay), true);
std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(), true);
handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetDBTableGUIDLow(), target->GetGUIDLow(), faction, npcflags, Entry, displayid, nativeid);
handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetSpawnId(), target->GetGUID().GetCounter(), faction, npcflags, Entry, displayid, nativeid);
handler->PSendSysMessage(LANG_NPCINFO_LEVEL, target->getLevel());
handler->PSendSysMessage(LANG_NPCINFO_EQUIPMENT, target->GetCurrentEquipmentId(), target->GetOriginalEquipmentId());
handler->PSendSysMessage(LANG_NPCINFO_HEALTH, target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth());
@@ -778,7 +778,7 @@ public:
do
{
Field* fields = result->Fetch();
uint32 guid = fields[0].GetUInt32();
ObjectGuid::LowType guid = fields[0].GetUInt32();
uint32 entry = fields[1].GetUInt32();
float x = fields[2].GetFloat();
float y = fields[3].GetFloat();
@@ -803,7 +803,7 @@ public:
//move selected creature
static bool HandleNpcMoveCommand(ChatHandler* handler, const char* args)
{
uint32 lowguid = 0;
ObjectGuid::LowType lowguid = 0;
Creature* creature = handler->getSelectedCreature();
@@ -818,7 +818,7 @@ public:
/* FIXME: impossible without entry
if (lowguid)
creature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), MAKE_GUID(lowguid, HIGHGUID_UNIT));
creature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), MAKE_GUID(lowguid, HighGuid::Unit));
*/
// Attempting creature load from DB data
@@ -843,12 +843,12 @@ public:
}
else
{
lowguid = creature->GetDBTableGUIDLow();
lowguid = creature->GetSpawnId();
}
}
else
{
lowguid = creature->GetDBTableGUIDLow();
lowguid = creature->GetSpawnId();
}
float x = handler->GetSession()->GetPlayer()->GetPositionX();
@@ -858,7 +858,7 @@ public:
if (creature)
{
if (CreatureData const* data = sObjectMgr->GetCreatureData(creature->GetDBTableGUIDLow()))
if (CreatureData const* data = sObjectMgr->GetCreatureData(creature->GetSpawnId()))
{
const_cast<CreatureData*>(data)->posX = x;
const_cast<CreatureData*>(data)->posY = y;
@@ -971,7 +971,7 @@ public:
if (!guid_str)
return false;
uint32 lowguid = 0;
ObjectGuid::LowType lowguid = 0;
Creature* creature = nullptr;
if (dontdel_str)
@@ -1009,16 +1009,15 @@ public:
creature = handler->getSelectedCreature();
if (!creature || creature->IsPet())
return false;
lowguid = creature->GetDBTableGUIDLow();
lowguid = creature->GetSpawnId();
}
else // case .setmovetype #creature_guid $move_type (with selected creature)
{
lowguid = atoi((char*)guid_str);
/* impossible without entry
if (lowguid)
creature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), MAKE_GUID(lowguid, HIGHGUID_UNIT));
*/
creature = handler->GetCreatureFromPlayerMapByDbGuid(lowguid);
// attempt check creature existence by DB data
if (!creature)
@@ -1033,7 +1032,7 @@ public:
}
else
{
lowguid = creature->GetDBTableGUIDLow();
lowguid = creature->GetSpawnId();
}
}
@@ -1133,10 +1132,10 @@ public:
mtype = RANDOM_MOTION_TYPE;
Creature* creature = handler->getSelectedCreature();
uint32 guidLow = 0;
ObjectGuid::LowType guidLow = 0;
if (creature)
guidLow = creature->GetDBTableGUIDLow();
guidLow = creature->GetSpawnId();
else
return false;
@@ -1182,10 +1181,10 @@ public:
}
Creature* creature = handler->getSelectedCreature();
uint32 guidLow = 0;
ObjectGuid::LowType guidLow = 0;
if (creature)
guidLow = creature->GetDBTableGUIDLow();
guidLow = creature->GetSpawnId();
else
return false;
@@ -1305,11 +1304,11 @@ public:
if (!creature || !receiver_str || !text)
return false;
uint64 receiver_guid = atol(receiver_str);
ObjectGuid receiver_guid = ObjectGuid::Create<HighGuid::Player>(atol(receiver_str));
// check online security
Player* receiver = ObjectAccessor::FindPlayer(receiver_guid);
if (handler->HasLowerSecurity(receiver, 0))
if (handler->HasLowerSecurity(receiver, ObjectGuid::Empty))
return false;
creature->MonsterWhisper(text, receiver);
@@ -1430,17 +1429,17 @@ public:
if (!*args)
return false;
uint32 leaderGUID = (uint32) atoi((char*)args);
ObjectGuid::LowType leaderGUID = (uint32) atoi((char*)args);
Creature* creature = handler->getSelectedCreature();
if (!creature || !creature->GetDBTableGUIDLow())
if (!creature || !creature->GetSpawnId())
{
handler->SendSysMessage(LANG_SELECT_CREATURE);
handler->SetSentErrorMessage(true);
return false;
}
uint32 lowguid = creature->GetDBTableGUIDLow();
ObjectGuid::LowType lowguid = creature->GetSpawnId();
if (creature->GetFormation())
{
handler->PSendSysMessage("Selected creature is already member of group %u", creature->GetFormation()->GetId());
@@ -1482,7 +1481,7 @@ public:
if (!*args)
return false;
uint32 linkguid = (uint32) atoi((char*)args);
ObjectGuid::LowType linkguid = (uint32) atoi((char*)args);
Creature* creature = handler->getSelectedCreature();
@@ -1493,21 +1492,21 @@ public:
return false;
}
if (!creature->GetDBTableGUIDLow())
if (!creature->GetSpawnId())
{
handler->PSendSysMessage("Selected creature %u isn't in creature table", creature->GetGUIDLow());
handler->PSendSysMessage("Selected creature %s isn't in creature table", creature->GetGUID().ToString().c_str());
handler->SetSentErrorMessage(true);
return false;
}
if (!sObjectMgr->SetCreatureLinkedRespawn(creature->GetDBTableGUIDLow(), linkguid))
if (!sObjectMgr->SetCreatureLinkedRespawn(creature->GetSpawnId(), linkguid))
{
handler->PSendSysMessage("Selected creature can't link with guid '%u'", linkguid);
handler->SetSentErrorMessage(true);
return false;
}
handler->PSendSysMessage("LinkGUID '%u' added to creature with DBTableGUID: '%u'", linkguid, creature->GetDBTableGUIDLow());
handler->PSendSysMessage("LinkGUID '%u' added to creature with SpawnId: '%u'", linkguid, creature->GetSpawnId());
return true;
}
@@ -1517,7 +1516,7 @@ public:
/*if (!*args)
return false;
uint64 guid = handler->GetSession()->GetPlayer()->GetSelection();
ObjectGuid guid = handler->GetSession()->GetPlayer()->GetSelection();
if (guid == 0)
{
handler->SendSysMessage(LANG_NO_SELECTION);
@@ -1601,7 +1600,7 @@ public:
}
}
uint64 guid;
ObjectGuid guid;
guid = handler->GetSession()->GetPlayer()->GetSelection();
if (guid == 0)
{
@@ -1648,7 +1647,7 @@ public:
return false;
}
}
uint64 guid;
ObjectGuid guid;
guid = handler->GetSession()->GetPlayer()->GetSelection();
if (guid == 0)
{

View File

@@ -199,11 +199,11 @@ public:
{
if (CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creature))
for (uint16 z = 0; z < creatureCount; ++z)
player->KilledMonster(creatureInfo, 0);
player->KilledMonster(creatureInfo, ObjectGuid::Empty);
}
else if (creature < 0)
for (uint16 z = 0; z < creatureCount; ++z)
player->KillCreditGO(creature, 0);
player->KillCreditGO(creature);
}
// If the quest requires reputation to complete
@@ -237,7 +237,7 @@ public:
// prepare Quest Tracker datas
auto stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_QUEST_TRACK_GM_COMPLETE);
stmt->setUInt32(0, quest->GetQuestId());
stmt->setUInt32(1, player->GetGUIDLow());
stmt->setUInt32(1, player->GetGUID().GetCounter());
// add to Quest Tracker
CharacterDatabase.Execute(stmt);

View File

@@ -46,14 +46,14 @@ public:
static bool HandleResetAchievementsCommand(ChatHandler* handler, char const* args)
{
Player* target;
uint64 targetGuid;
ObjectGuid targetGuid;
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid))
return false;
if (target)
target->ResetAchievements();
else
AchievementMgr::DeleteFromDB(GUID_LOPART(targetGuid));
AchievementMgr::DeleteFromDB(targetGuid.GetCounter());
return true;
}
@@ -145,7 +145,7 @@ public:
static bool HandleResetSpellsCommand(ChatHandler* handler, char const* args)
{
Player* target;
uint64 targetGuid;
ObjectGuid targetGuid;
std::string targetName;
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
return false;
@@ -162,7 +162,7 @@ public:
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
stmt->setUInt16(0, uint16(AT_LOGIN_RESET_SPELLS));
stmt->setUInt32(1, GUID_LOPART(targetGuid));
stmt->setUInt32(1, targetGuid.GetCounter());
CharacterDatabase.Execute(stmt);
handler->PSendSysMessage(LANG_RESET_SPELLS_OFFLINE, targetName.c_str());
@@ -192,7 +192,7 @@ public:
static bool HandleResetTalentsCommand(ChatHandler* handler, char const* args)
{
Player* target;
uint64 targetGuid;
ObjectGuid targetGuid;
std::string targetName;
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
{
@@ -236,7 +236,7 @@ public:
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
stmt->setUInt16(0, uint16(AT_LOGIN_NONE | AT_LOGIN_RESET_PET_TALENTS));
stmt->setUInt32(1, GUID_LOPART(targetGuid));
stmt->setUInt32(1, targetGuid.GetCounter());
CharacterDatabase.Execute(stmt);
std::string nameLink = handler->playerLink(targetName);
@@ -285,7 +285,7 @@ public:
CharacterDatabase.Execute(stmt);
std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
HashMapHolder<Player>::MapType const& plist = sObjectAccessor->GetPlayers();
HashMapHolder<Player>::MapType const& plist = ObjectAccessor::GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator itr = plist.begin(); itr != plist.end(); ++itr)
itr->second->SetAtLoginFlag(atLogin);

View File

@@ -85,7 +85,7 @@ public:
// Triggering corpses expire check in world
static bool HandleServerCorpsesCommand(ChatHandler* /*handler*/, char const* /*args*/)
{
sObjectAccessor->RemoveOldCorpses();
sWorld->RemoveOldCorpses();
return true;
}

View File

@@ -239,7 +239,7 @@ bool ArenaSpectator::HandleSpectatorWatchCommand(ChatHandler* handler, char cons
return true;
}
if (player->GetUInt64Value(PLAYER_FARSIGHT) || player->m_seer != player) // pussywizard: below this point we must not have a viewpoint!
if (player->GetGuidValue(PLAYER_FARSIGHT) || player->m_seer != player) // pussywizard: below this point we must not have a viewpoint!
return true;
if (player->HaveAtClient(spectate))

View File

@@ -110,7 +110,7 @@ public:
return false;
Player* target;
uint64 target_guid;
ObjectGuid target_guid;
std::string target_name;
if (!handler->extractPlayerTarget(nameStr, &target, &target_guid, &target_name))
return false;
@@ -122,7 +122,7 @@ public:
else
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_HOMEBIND);
stmt->setUInt32(0, target_guid);
stmt->setUInt32(0, target_guid.GetCounter());
PreparedQueryResult resultDB = CharacterDatabase.Query(stmt);
if (resultDB)
@@ -153,7 +153,7 @@ public:
if (target)
{
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
std::string chrNameLink = handler->playerLink(target_name);
@@ -212,7 +212,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
@@ -250,7 +250,7 @@ public:
continue;
// check online security
if (handler->HasLowerSecurity(player, 0))
if (handler->HasLowerSecurity(player))
return false;
std::string plNameLink = handler->GetNameLink(player);

View File

@@ -82,8 +82,8 @@ public:
}
// Get target information
uint64 targetGuid = sObjectMgr->GetPlayerGUIDByName(target.c_str());
uint64 targetAccountId = sObjectMgr->GetPlayerAccountIdByGUID(targetGuid);
ObjectGuid targetGuid = sObjectMgr->GetPlayerGUIDByName(target.c_str());
uint32 targetAccountId = sObjectMgr->GetPlayerAccountIdByGUID(targetGuid.GetCounter());
uint32 targetGmLevel = AccountMgr::GetSecurity(targetAccountId, realmID);
// Target must exist and have administrative rights
@@ -142,7 +142,7 @@ public:
return true;
}
sTicketMgr->ResolveAndCloseTicket(ticket->GetId(), player ? player->GetGUID() : -1);
sTicketMgr->ResolveAndCloseTicket(ticket->GetId(), player ? player->GetGUID() : ObjectGuid::Empty);
sTicketMgr->UpdateLastChange();
std::string msg = ticket->FormatMessageString(*handler, player ? player->GetName().c_str() : "Console", nullptr, nullptr, nullptr);
@@ -244,7 +244,7 @@ public:
SQLTransaction trans = SQLTransaction(nullptr);
ticket->SetCompleted();
ticket->SetResolvedBy(gm ? gm->GetGUID() : -1);
ticket->SetResolvedBy(gm ? gm->GetGUID() : ObjectGuid::Empty);
ticket->SaveToDB(trans);
std::string msg = ticket->FormatMessageString(*handler, nullptr, nullptr, nullptr, nullptr);
@@ -380,8 +380,8 @@ public:
security = assignedPlayer->GetSession()->GetSecurity();
else
{
uint64 guid = ticket->GetAssignedToGUID();
uint32 accountId = sObjectMgr->GetPlayerAccountIdByGUID(guid);
ObjectGuid guid = ticket->GetAssignedToGUID();
uint32 accountId = sObjectMgr->GetPlayerAccountIdByGUID(guid.GetCounter());
security = AccountMgr::GetSecurity(accountId, realmID);
}
@@ -438,7 +438,7 @@ public:
return false;
// Detect target's GUID
uint64 guid = 0;
ObjectGuid guid;
if (Player* player = ObjectAccessor::FindPlayerByName(name, false))
guid = player->GetGUID();
else

View File

@@ -66,7 +66,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id);
@@ -111,7 +111,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id);
@@ -157,7 +157,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id);
@@ -205,7 +205,7 @@ public:
}
// check online security
if (handler->HasLowerSecurity(target, 0))
if (handler->HasLowerSecurity(target))
return false;
uint64 titles2 = titles;

View File

@@ -137,7 +137,7 @@ public:
path_number = strtok((char*)args, " ");
uint32 pathid = 0;
uint32 guidLow = 0;
ObjectGuid::LowType guidLow = 0;
Creature* target = handler->getSelectedCreature();
// Did player provide a path_id?
@@ -166,7 +166,7 @@ public:
return true;
}
guidLow = target->GetDBTableGUIDLow();
guidLow = target->GetSpawnId();
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_ADDON_BY_GUID);
@@ -231,7 +231,7 @@ public:
return true;
}
uint32 guildLow = target->GetDBTableGUIDLow();
uint32 guildLow = target->GetSpawnId();
if (target->GetCreatureAddon())
{
@@ -566,7 +566,6 @@ public:
// -> variable lowguid is filled with the GUID of the NPC
uint32 pathid = 0;
uint32 point = 0;
uint32 wpGuid = 0;
Creature* target = handler->getSelectedCreature();
if (!target || target->GetEntry() != VISUAL_WAYPOINT)
@@ -576,18 +575,18 @@ public:
}
// The visual waypoint
wpGuid = target->GetGUIDLow();
ObjectGuid::LowType wpSpawnId = target->GetSpawnId();
// User did select a visual waypoint?
// Check the creature
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_BY_WPGUID);
stmt->setUInt32(0, wpGuid);
stmt->setUInt32(0, wpSpawnId);
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
{
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUIDLow());
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, wpSpawnId);
// Select waypoint number from database
// Since we compare float values, we have to deal with
// some difficulties.
@@ -607,7 +606,7 @@ public:
if (!result)
{
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpGuid);
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpSpawnId);
return true;
}
}
@@ -634,8 +633,8 @@ public:
{
handler->PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid);
if (wpGuid != 0)
if (Creature* wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)))
if (wpSpawnId != 0)
if (Creature* wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(target->GetGUID()))
{
wpCreature->CombatStop();
wpCreature->DeleteFromDB();
@@ -670,9 +669,9 @@ public:
// What to do:
// Move the visual spawnpoint
// Respawn the owner of the waypoints
if (wpGuid != 0)
if (wpSpawnId != 0)
{
if (Creature* wpCreature = map->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)))
if (Creature* wpCreature = map->GetCreature(target->GetGUID()))
{
wpCreature->CombatStop();
wpCreature->DeleteFromDB();
@@ -680,7 +679,7 @@ public:
}
// re-create
Creature* wpCreature2 = new Creature;
if (!wpCreature2->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, 0, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()))
if (!wpCreature2->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, 0, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()))
{
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
delete wpCreature2;
@@ -691,7 +690,7 @@ public:
wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
//TODO: Should we first use "Create" then use "LoadFromDB"?
if (!wpCreature2->LoadCreatureFromDB(wpCreature2->GetDBTableGUIDLow(), map))
if (!wpCreature2->LoadCreatureFromDB(wpCreature2->GetSpawnId(), map, true, false, true))
{
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
delete wpCreature2;
@@ -795,7 +794,7 @@ public:
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_ALL_BY_WPGUID);
stmt->setUInt32(0, target->GetGUIDLow());
stmt->setUInt32(0, target->GetSpawnId());
PreparedQueryResult result = WorldDatabase.Query(stmt);
@@ -857,7 +856,7 @@ public:
{
Field* fields = result2->Fetch();
uint32 wpguid = fields[0].GetUInt32();
Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpguid, VISUAL_WAYPOINT, HIGHGUID_UNIT));
Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid::Create<HighGuid::Unit>(VISUAL_WAYPOINT, wpguid));
if (!creature)
{
@@ -901,7 +900,7 @@ public:
float o = chr->GetOrientation();
Creature* wpCreature = new Creature;
if (!wpCreature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
if (!wpCreature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
{
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
delete wpCreature;
@@ -911,7 +910,7 @@ public:
// Set "wpguid" column to the visual waypoint
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_WPGUID);
stmt->setInt32(0, int32(wpCreature->GetGUIDLow()));
stmt->setInt32(0, int32(wpCreature->GetSpawnId()));
stmt->setUInt32(1, pathid);
stmt->setUInt32(2, point);
@@ -919,7 +918,7 @@ public:
wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
if (!wpCreature->LoadCreatureFromDB(wpCreature->GetDBTableGUIDLow(), map))
if (!wpCreature->LoadCreatureFromDB(wpCreature->GetSpawnId(), map, true, false, true))
{
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
delete wpCreature;
@@ -964,7 +963,7 @@ public:
Map* map = chr->GetMap();
Creature* creature = new Creature;
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
{
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
delete creature;
@@ -972,7 +971,7 @@ public:
}
creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
if (!creature->LoadCreatureFromDB(creature->GetDBTableGUIDLow(), map))
if (!creature->LoadCreatureFromDB(creature->GetSpawnId(), map, true, false, true))
{
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
delete creature;
@@ -1013,7 +1012,7 @@ public:
Map* map = chr->GetMap();
Creature* creature = new Creature;
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
{
handler->PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id);
delete creature;
@@ -1021,7 +1020,7 @@ public:
}
creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
if (!creature->LoadCreatureFromDB(creature->GetDBTableGUIDLow(), map))
if (!creature->LoadCreatureFromDB(creature->GetSpawnId(), map, true, false, true))
{
handler->PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id);
delete creature;
@@ -1053,8 +1052,8 @@ public:
do
{
Field* fields = result->Fetch();
uint32 guid = fields[0].GetUInt32();
Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(guid, VISUAL_WAYPOINT, HIGHGUID_UNIT));
ObjectGuid::LowType guid = fields[0].GetUInt32();
Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid::Create<HighGuid::Unit>(VISUAL_WAYPOINT, guid));
if (!creature)
{
handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, guid);