mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 17:19:07 +00:00
feat(Core/Misc): implement ObjectGuid class (port from TC) (#4885)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user