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

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

View file

@ -70,7 +70,7 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accid)
{
Field *fields = result->Fetch();
uint32 guidlo = fields[0].GetUInt32();
uint64 guid = MAKE_NEW_GUID(guidlo, 0, HIGHGUID_PLAYER);
ObjectGuid guid = ObjectGuid(HIGHGUID_PLAYER, guidlo);
// kick if player currently
ObjectAccessor::KickPlayer(guid);

View file

@ -79,12 +79,12 @@ void WorldSession::SendAuctionCommandResult(uint32 auctionId, uint32 Action, uin
}
// this function sends notification, if bidder is online
void WorldSession::SendAuctionBidderNotification( uint32 location, uint32 auctionId, uint64 bidder, uint32 bidSum, uint32 diff, uint32 item_template)
void WorldSession::SendAuctionBidderNotification( uint32 location, uint32 auctionId, ObjectGuid bidderGuid, uint32 bidSum, uint32 diff, uint32 item_template)
{
WorldPacket data(SMSG_AUCTION_BIDDER_NOTIFICATION, (8*4));
data << uint32(location);
data << uint32(auctionId);
data << uint64(bidder);
data << bidderGuid;
data << uint32(bidSum);
data << uint32(diff);
data << uint32(item_template);
@ -109,7 +109,7 @@ void WorldSession::SendAuctionOwnerNotification( AuctionEntry* auction)
// this function sends mail to old bidder
void WorldSession::SendAuctionOutbiddedMail(AuctionEntry *auction, uint32 newPrice)
{
uint64 oldBidder_guid = MAKE_NEW_GUID(auction->bidder,0, HIGHGUID_PLAYER);
ObjectGuid oldBidder_guid = ObjectGuid(HIGHGUID_PLAYER, auction->bidder);
Player *oldBidder = sObjectMgr.GetPlayer(oldBidder_guid);
uint32 oldBidder_accId = 0;
@ -123,7 +123,9 @@ void WorldSession::SendAuctionOutbiddedMail(AuctionEntry *auction, uint32 newPri
msgAuctionOutbiddedSubject << auction->item_template << ":0:" << AUCTION_OUTBIDDED << ":0:0";
if (oldBidder)
oldBidder->GetSession()->SendAuctionBidderNotification( auction->GetHouseId(), auction->Id, _player->GetGUID(), newPrice, auction->GetAuctionOutBid(), auction->item_template);
oldBidder->GetSession()->SendAuctionBidderNotification(
auction->GetHouseId(), auction->Id, _player->GetObjectGuid(),
newPrice, auction->GetAuctionOutBid(), auction->item_template);
MailDraft(msgAuctionOutbiddedSubject.str(), "") // TODO: fix body
.AddMoney(auction->bid)
@ -134,7 +136,7 @@ void WorldSession::SendAuctionOutbiddedMail(AuctionEntry *auction, uint32 newPri
// this function sends mail, when auction is cancelled to old bidder
void WorldSession::SendAuctionCancelledToBidderMail( AuctionEntry* auction )
{
uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER);
ObjectGuid bidder_guid = ObjectGuid(HIGHGUID_PLAYER, auction->bidder);
Player *bidder = sObjectMgr.GetPlayer(bidder_guid);
uint32 bidder_accId = 0;
@ -344,9 +346,11 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
return;
}
ObjectGuid ownerGuid = ObjectGuid(HIGHGUID_PLAYER, auction->owner);
// impossible have online own another character (use this for speedup check in case online owner)
Player* auction_owner = sObjectMgr.GetPlayer(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER));
if( !auction_owner && sObjectMgr.GetPlayerAccountIdByGUID(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER)) == pl->GetSession()->GetAccountId())
Player* auction_owner = sObjectMgr.GetPlayer(ownerGuid);
if (!auction_owner && sObjectMgr.GetPlayerAccountIdByGUID(ownerGuid) == pl->GetSession()->GetAccountId())
{
// you cannot bid your another character auction:
SendAuctionCommandResult( 0, AUCTION_PLACE_BID, CANNOT_BID_YOUR_AUCTION_ERROR );

View file

@ -84,7 +84,7 @@ void AuctionHouseMgr::SendAuctionWonMail( AuctionEntry *auction )
if(!pItem)
return;
uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER);
ObjectGuid bidder_guid = ObjectGuid(HIGHGUID_PLAYER, auction->bidder);
Player *bidder = sObjectMgr.GetPlayer(bidder_guid);
uint32 bidder_accId = 0;
@ -114,11 +114,12 @@ void AuctionHouseMgr::SendAuctionWonMail( AuctionEntry *auction )
if (bidder_security > SEC_PLAYER)
{
ObjectGuid owner_guid = ObjectGuid(HIGHGUID_PLAYER, auction->owner);
std::string owner_name;
if(!sObjectMgr.GetPlayerNameByGUID(auction->owner,owner_name))
if(!sObjectMgr.GetPlayerNameByGUID(owner_guid, owner_name))
owner_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN);
uint32 owner_accid = sObjectMgr.GetPlayerAccountIdByGUID(auction->owner);
uint32 owner_accid = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid);
sLog.outCommand(bidder_accId,"GM %s (Account: %u) won item in auction: %s (Entry: %u Count: %u) and pay money: %u. Original owner %s (Account: %u)",
bidder_name.c_str(),bidder_accId,pItem->GetProto()->Name1,pItem->GetEntry(),pItem->GetCount(),auction->bid,owner_name.c_str(),owner_accid);
@ -169,7 +170,7 @@ void AuctionHouseMgr::SendAuctionWonMail( AuctionEntry *auction )
void AuctionHouseMgr::SendAuctionSalePendingMail( AuctionEntry * auction )
{
uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER);
ObjectGuid owner_guid = ObjectGuid(HIGHGUID_PLAYER, auction->owner);
Player *owner = sObjectMgr.GetPlayer(owner_guid);
// owner exist (online or offline)
@ -199,7 +200,7 @@ void AuctionHouseMgr::SendAuctionSalePendingMail( AuctionEntry * auction )
//call this method to send mail to auction owner, when auction is successful, it does not clear ram
void AuctionHouseMgr::SendAuctionSuccessfulMail( AuctionEntry * auction )
{
uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER);
ObjectGuid owner_guid = ObjectGuid(HIGHGUID_PLAYER, auction->owner);
Player *owner = sObjectMgr.GetPlayer(owner_guid);
uint32 owner_accId = 0;
@ -249,7 +250,7 @@ void AuctionHouseMgr::SendAuctionExpiredMail( AuctionEntry * auction )
return;
}
uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER);
ObjectGuid owner_guid = ObjectGuid(HIGHGUID_PLAYER, auction->owner);
Player *owner = sObjectMgr.GetPlayer(owner_guid);
uint32 owner_accId = 0;

View file

@ -1757,8 +1757,7 @@ void BattleGroundMgr::DistributeArenaPoints()
//update to database
CharacterDatabase.PExecute("UPDATE characters SET arenaPoints = arenaPoints + '%u' WHERE guid = '%u'", plr_itr->second, plr_itr->first);
//add points if player is online
Player* pl = sObjectMgr.GetPlayer(plr_itr->first);
if (pl)
if (Player* pl = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, plr_itr->first)))
pl->ModifyArenaPoints(plr_itr->second);
}

View file

@ -486,7 +486,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
void WorldSession::HandleCharDeleteOpcode( WorldPacket & recv_data )
{
uint64 guid;
ObjectGuid guid;
recv_data >> guid;
// can't delete loaded character
@ -514,7 +514,9 @@ void WorldSession::HandleCharDeleteOpcode( WorldPacket & recv_data )
return;
}
QueryResult *result = CharacterDatabase.PQuery("SELECT account,name FROM characters WHERE guid='%u'", GUID_LOPART(guid));
uint32 lowguid = guid.GetCounter();
QueryResult *result = CharacterDatabase.PQuery("SELECT account,name FROM characters WHERE guid='%u'", lowguid);
if(result)
{
Field *fields = result->Fetch();
@ -528,13 +530,13 @@ void WorldSession::HandleCharDeleteOpcode( WorldPacket & recv_data )
return;
std::string IP_str = GetRemoteAddress();
BASIC_LOG("Account: %d (IP: %s) Delete Character:[%s] (guid: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), GUID_LOPART(guid));
sLog.outChar("Account: %d (IP: %s) Delete Character:[%s] (guid: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), GUID_LOPART(guid));
BASIC_LOG("Account: %d (IP: %s) Delete Character:[%s] (guid: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), lowguid);
sLog.outChar("Account: %d (IP: %s) Delete Character:[%s] (guid: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), lowguid);
if(sLog.IsOutCharDump()) // optimize GetPlayerDump call
{
std::string dump = PlayerDumpWriter().GetDump(GUID_LOPART(guid));
sLog.outCharDump(dump.c_str(), GetAccountId(), GUID_LOPART(guid), name.c_str());
std::string dump = PlayerDumpWriter().GetDump(lowguid);
sLog.outCharDump(dump.c_str(), GetAccountId(), lowguid, name.c_str());
}
Player::DeleteFromDB(guid, GetAccountId());
@ -942,7 +944,7 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult *result, uin
}
uint32 guidLow = result->Fetch()[0].GetUInt32();
uint64 guid = MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER);
ObjectGuid guid = ObjectGuid(HIGHGUID_PLAYER, guidLow);
std::string oldname = result->Fetch()[1].GetCppString();
delete result;
@ -954,7 +956,7 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult *result, uin
WorldPacket data(SMSG_CHAR_RENAME, 1+8+(newname.size()+1));
data << uint8(RESPONSE_SUCCESS);
data << uint64(guid);
data << guid;
data << newname;
session->SendPacket(&data);
}

View file

@ -2658,7 +2658,7 @@ GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid
Player* pl = m_session->GetPlayer();
GameObject* obj = pl->GetMap()->GetGameObject(MAKE_NEW_GUID(lowguid, entry, HIGHGUID_GAMEOBJECT));
GameObject* obj = pl->GetMap()->GetGameObject(ObjectGuid(HIGHGUID_GAMEOBJECT, entry, lowguid));
if(!obj && sObjectMgr.GetGOData(lowguid)) // guid is DB guid of object
{

View file

@ -147,20 +147,20 @@ void Corpse::DeleteFromDB()
CharacterDatabase.PExecute("DELETE FROM corpse WHERE player = '%d' AND corpse_type <> '0'", GUID_LOPART(GetOwnerGUID()));
}
bool Corpse::LoadFromDB(uint32 guid, Field *fields)
bool Corpse::LoadFromDB(uint32 lowguid, Field *fields)
{
//// 0 1 2 3 4 5 6
//QueryResult *result = CharacterDatabase.Query("SELECT corpse.guid, player, corpse.position_x, corpse.position_y, corpse.position_z, corpse.orientation, corpse.map,"
//// 7 8 9 10 11 12 13 14 15 16 17 18
// "time, corpse_type, instance, phaseMask, gender, race, class, playerBytes, playerBytes2, equipmentCache, guildId, playerFlags FROM corpse"
uint32 playerGuid = fields[1].GetUInt32();
uint32 playerLowGuid= fields[1].GetUInt32();
float positionX = fields[2].GetFloat();
float positionY = fields[3].GetFloat();
float positionZ = fields[4].GetFloat();
float orientation = fields[5].GetFloat();
uint32 mapid = fields[6].GetUInt32();
Object::_Create(guid, 0, HIGHGUID_CORPSE);
Object::_Create(lowguid, 0, HIGHGUID_CORPSE);
m_time = time_t(fields[7].GetUInt64());
m_type = CorpseType(fields[8].GetUInt32());
@ -181,9 +181,12 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields)
uint32 guildId = fields[17].GetUInt32();
uint32 playerFlags = fields[18].GetUInt32();
ObjectGuid guid = ObjectGuid(HIGHGUID_CORPSE, lowguid);
ObjectGuid playerGuid = ObjectGuid(HIGHGUID_PLAYER, playerLowGuid);
// overwrite possible wrong/corrupted guid
SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid, 0, HIGHGUID_CORPSE));
SetUInt64Value(CORPSE_FIELD_OWNER, MAKE_NEW_GUID(playerGuid, 0, HIGHGUID_PLAYER));
SetGuidValue(OBJECT_FIELD_GUID, guid);
SetGuidValue(CORPSE_FIELD_OWNER, playerGuid);
SetObjectScale(DEFAULT_OBJECT_SCALE);

View file

@ -1183,31 +1183,31 @@ bool Creature::CreateFromProto(uint32 guidlow, uint32 Entry, uint32 team, const
return true;
}
bool Creature::LoadFromDB(uint32 guid, Map *map)
bool Creature::LoadFromDB(uint32 guidlow, Map *map)
{
CreatureData const* data = sObjectMgr.GetCreatureData(guid);
CreatureData const* data = sObjectMgr.GetCreatureData(guidlow);
if(!data)
{
sLog.outErrorDb("Creature (GUID: %u) not found in table `creature`, can't load. ",guid);
sLog.outErrorDb("Creature (GUID: %u) not found in table `creature`, can't load. ", guidlow);
return false;
}
m_DBTableGuid = guid;
m_DBTableGuid = guidlow;
if (map->GetInstanceId() == 0)
{
// Creature can be loaded already in map if grid has been unloaded while creature walk to another grid
// FIXME: until creature guids is global and for instances used dynamic generated guids
// in instance possible load creature duplicates with same DB guid but different in game guids
// This will be until implementing per-map creature guids
if (map->GetCreature(MAKE_NEW_GUID(guid, data->id, HIGHGUID_UNIT)))
if (map->GetCreature(ObjectGuid(HIGHGUID_UNIT, data->id, guidlow)))
return false;
}
else
guid = sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT);
guidlow = sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT);
uint16 team = 0;
if(!Create(guid, map, data->phaseMask, data->id, team, data))
if (!Create(guidlow, map, data->phaseMask, data->id, team, data))
return false;
Relocate(data->posX, data->posY, data->posZ, data->orientation);

View file

@ -81,7 +81,7 @@ void GMTicketMgr::DeleteAll()
{
for(GMTicketMap::const_iterator itr = m_GMTicketMap.begin(); itr != m_GMTicketMap.end(); ++itr)
{
if(Player* owner = sObjectMgr.GetPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)))
if(Player* owner = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first)))
owner->GetSession()->SendGMTicketGetTicket(0x0A, 0);
}
CharacterDatabase.Execute("DELETE FROM character_ticket");

View file

@ -372,7 +372,8 @@ bool Guild::LoadMembersFromDB(QueryResult *guildMembersResult)
break;
MemberSlot newmember;
uint64 guid = MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER);
uint32 lowguid = fields[1].GetUInt32();
ObjectGuid guid = ObjectGuid(HIGHGUID_PLAYER, lowguid);
newmember.RankId = fields[2].GetUInt32();
// don't allow member to have not existing rank!
if (newmember.RankId >= m_Ranks.size())
@ -398,25 +399,25 @@ bool Guild::LoadMembersFromDB(QueryResult *guildMembersResult)
// this code will remove not existing character guids from guild
if (newmember.Level < 1 || newmember.Level > STRONG_MAX_LEVEL) // can be at broken `data` field
{
sLog.outError("Player (GUID: %u) has a broken data in field `characters`.`data`, deleting him from guild!",GUID_LOPART(guid));
CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guid = '%u'", GUID_LOPART(guid));
sLog.outError("%s has a broken data in field `characters`.`data`, deleting him from guild!", guid.GetString().c_str());
CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guid = '%u'", lowguid);
continue;
}
if (!newmember.ZoneId)
{
sLog.outError("Player (GUID: %u) has broken zone-data", GUID_LOPART(guid));
sLog.outError("%s has broken zone-data", guid.GetString().c_str());
// here it will also try the same, to get the zone from characters-table, but additional it tries to find
// the zone through xy coords .. this is a bit redundant, but shouldn't be called often
newmember.ZoneId = Player::GetZoneIdFromDB(guid);
}
if (newmember.Class < CLASS_WARRIOR || newmember.Class >= MAX_CLASSES) // can be at broken `class` field
{
sLog.outError("Player (GUID: %u) has a broken data in field `characters`.`class`, deleting him from guild!",GUID_LOPART(guid));
CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guid = '%u'", GUID_LOPART(guid));
sLog.outError("%s has a broken data in field `characters`.`class`, deleting him from guild!", guid.GetString().c_str());
CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guid = '%u'", lowguid);
continue;
}
members[GUID_LOPART(guid)] = newmember;
members[lowguid] = newmember;
} while (guildMembersResult->NextRow());
@ -1538,7 +1539,7 @@ void Guild::DisplayGuildBankLogs(WorldSession *session, uint8 TabId)
for (GuildBankEventLog::const_iterator itr = m_GuildBankEventLog_Money.begin(); itr != m_GuildBankEventLog_Money.end(); ++itr)
{
data << uint8(itr->EventType);
data << uint64(MAKE_NEW_GUID(itr->PlayerGuid,0,HIGHGUID_PLAYER));
data << ObjectGuid(HIGHGUID_PLAYER, itr->PlayerGuid);
if (itr->EventType == GUILD_BANK_LOG_DEPOSIT_MONEY ||
itr->EventType == GUILD_BANK_LOG_WITHDRAW_MONEY ||
itr->EventType == GUILD_BANK_LOG_REPAIR_MONEY ||
@ -1568,7 +1569,7 @@ void Guild::DisplayGuildBankLogs(WorldSession *session, uint8 TabId)
for (GuildBankEventLog::const_iterator itr = m_GuildBankEventLog_Item[TabId].begin(); itr != m_GuildBankEventLog_Item[TabId].end(); ++itr)
{
data << uint8(itr->EventType);
data << uint64(MAKE_NEW_GUID(itr->PlayerGuid,0,HIGHGUID_PLAYER));
data << ObjectGuid(HIGHGUID_PLAYER, itr->PlayerGuid);
if (itr->EventType == GUILD_BANK_LOG_DEPOSIT_MONEY ||
itr->EventType == GUILD_BANK_LOG_WITHDRAW_MONEY ||
itr->EventType == GUILD_BANK_LOG_REPAIR_MONEY ||

View file

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

View file

@ -862,7 +862,7 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args)
return false;
}
GameObject* target = m_session->GetPlayer()->GetMap()->GetGameObject(MAKE_NEW_GUID(lowguid,id,HIGHGUID_GAMEOBJECT));
GameObject* target = m_session->GetPlayer()->GetMap()->GetGameObject(ObjectGuid(HIGHGUID_GAMEOBJECT, id, lowguid));
PSendSysMessage(LANG_GAMEOBJECT_DETAIL, lowguid, goI->name, lowguid, id, x, y, z, mapid, o);
@ -1799,8 +1799,8 @@ bool ChatHandler::HandleNpcDeleteCommand(char* args)
if (!lowguid)
return false;
if (CreatureData const* cr_data = sObjectMgr.GetCreatureData(lowguid))
unit = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(lowguid, cr_data->id, HIGHGUID_UNIT));
if (CreatureData const* data = sObjectMgr.GetCreatureData(lowguid))
unit = m_session->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HIGHGUID_UNIT, data->id, lowguid));
}
else
unit = getSelectedCreature();
@ -2594,7 +2594,7 @@ void ChatHandler::ShowTicket(GMTicket const* ticket)
std::string lastupdated = TimeToTimestampStr(ticket->GetLastUpdate());
std::string name;
if (!sObjectMgr.GetPlayerNameByGUID(MAKE_NEW_GUID(ticket->GetPlayerLowGuid(), 0, HIGHGUID_PLAYER), name))
if (!sObjectMgr.GetPlayerNameByGUID(ObjectGuid(HIGHGUID_PLAYER, ticket->GetPlayerLowGuid()), name))
name = GetMangosString(LANG_UNKNOWN);
std::string nameLink = playerLink(name);
@ -2910,7 +2910,7 @@ bool ChatHandler::HandleWpAddCommand(char* args)
return false;
}
target = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(lowguid,data->id,HIGHGUID_UNIT));
target = m_session->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HIGHGUID_UNIT, data->id, lowguid));
if (!target)
{
PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, lowguid);
@ -2944,7 +2944,7 @@ bool ChatHandler::HandleWpAddCommand(char* args)
return false;
}
target = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(lowguid,data->id,HIGHGUID_UNIT));
target = m_session->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HIGHGUID_UNIT, data->id, lowguid));
if (!target || target->isPet())
{
PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid);
@ -3159,7 +3159,7 @@ bool ChatHandler::HandleWpModifyCommand(char* args)
return false;
}
Creature* npcCreature = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(lowguid, data->id, HIGHGUID_UNIT));
Creature* npcCreature = m_session->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HIGHGUID_UNIT, data->id, lowguid));
if (!npcCreature)
{
@ -3238,13 +3238,13 @@ bool ChatHandler::HandleWpModifyCommand(char* args)
return false;
}
Creature* npcCreature = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(lowguid, data->id, HIGHGUID_UNIT));
Creature* npcCreature = m_session->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HIGHGUID_UNIT, data->id, lowguid));
// wpCreature
Creature* wpCreature = NULL;
if (wpGuid != 0)
{
wpCreature = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT));
wpCreature = m_session->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HIGHGUID_UNIT, VISUAL_WAYPOINT, wpGuid));
wpCreature->DeleteFromDB();
wpCreature->AddObjectToRemoveList();
}
@ -3298,7 +3298,7 @@ bool ChatHandler::HandleWpModifyCommand(char* args)
return false;
}
Creature* npcCreature = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(lowguid, data->id, HIGHGUID_UNIT));
Creature* npcCreature = m_session->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HIGHGUID_UNIT, data->id, lowguid));
// wpCreature
Creature* wpCreature = NULL;
@ -3307,7 +3307,7 @@ bool ChatHandler::HandleWpModifyCommand(char* args)
// Respawn the owner of the waypoints
if (wpGuid != 0)
{
wpCreature = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT));
wpCreature = m_session->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HIGHGUID_UNIT, VISUAL_WAYPOINT, wpGuid));
wpCreature->DeleteFromDB();
wpCreature->AddObjectToRemoveList();
// re-create
@ -3369,7 +3369,7 @@ bool ChatHandler::HandleWpModifyCommand(char* args)
sWaypointMgr.SetNodeText(lowguid, point, show_str, arg_str);
Creature* npcCreature = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(lowguid, data->id, HIGHGUID_UNIT));
Creature* npcCreature = m_session->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HIGHGUID_UNIT, data->id, lowguid));
if (npcCreature)
{
npcCreature->SetDefaultMovementType(WAYPOINT_MOTION_TYPE);
@ -3469,7 +3469,7 @@ bool ChatHandler::HandleWpShowCommand(char* args)
return false;
}
target = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(lowguid,data->id,HIGHGUID_UNIT));
target = m_session->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HIGHGUID_UNIT, data->id, lowguid));
if (!target)
{
@ -3528,7 +3528,7 @@ bool ChatHandler::HandleWpShowCommand(char* args)
do
{
Field *fields = result->Fetch();
uint32 creGUID = fields[0].GetUInt32();
uint32 wpGuid = fields[0].GetUInt32();
uint32 point = fields[1].GetUInt32();
int waittime = fields[2].GetUInt32();
uint32 emote = fields[3].GetUInt32();
@ -3540,9 +3540,9 @@ bool ChatHandler::HandleWpShowCommand(char* args)
uint32 model2 = fields[11].GetUInt32();
// Get the creature for which we read the waypoint
Creature* wpCreature = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(creGUID,VISUAL_WAYPOINT,HIGHGUID_UNIT));
Creature* wpCreature = m_session->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HIGHGUID_UNIT, VISUAL_WAYPOINT, wpGuid));
PSendSysMessage(LANG_WAYPOINT_INFO_TITLE, point, (wpCreature ? wpCreature->GetName() : "<not found>"), creGUID);
PSendSysMessage(LANG_WAYPOINT_INFO_TITLE, point, (wpCreature ? wpCreature->GetName() : "<not found>"), wpGuid);
PSendSysMessage(LANG_WAYPOINT_INFO_WAITTIME, waittime);
PSendSysMessage(LANG_WAYPOINT_INFO_MODEL, 1, model1);
PSendSysMessage(LANG_WAYPOINT_INFO_MODEL, 2, model2);
@ -3576,14 +3576,14 @@ bool ChatHandler::HandleWpShowCommand(char* args)
do
{
Field *fields = result2->Fetch();
uint32 wpguid = fields[0].GetUInt32();
Creature* pCreature = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpguid,VISUAL_WAYPOINT,HIGHGUID_UNIT));
uint32 wpGuid = fields[0].GetUInt32();
Creature* pCreature = m_session->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HIGHGUID_UNIT, VISUAL_WAYPOINT, wpGuid));
if (!pCreature)
{
PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, wpguid);
PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, wpGuid);
hasError = true;
WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid = '%u'", wpguid);
WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid = '%u'", wpGuid);
}
else
{
@ -3774,13 +3774,13 @@ bool ChatHandler::HandleWpShowCommand(char* args)
do
{
Field *fields = result->Fetch();
uint32 guid = fields[0].GetUInt32();
Creature* pCreature = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(guid,VISUAL_WAYPOINT,HIGHGUID_UNIT));
uint32 wpGuid = fields[0].GetUInt32();
Creature* pCreature = m_session->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HIGHGUID_UNIT, VISUAL_WAYPOINT, wpGuid));
if (!pCreature)
{
PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, guid);
PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, wpGuid);
hasError = true;
WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid = '%u'", guid);
WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid = '%u'", wpGuid);
}
else
{

View file

@ -5694,7 +5694,7 @@ bool ChatHandler::HandlePDumpLoadCommand(char *args)
char* name_str = ExtractLiteralArg(&args);
uint32 guid = 0;
uint32 lowguid = 0;
std::string name;
if (name_str)
@ -5717,26 +5717,28 @@ bool ChatHandler::HandlePDumpLoadCommand(char *args)
if (*args)
{
if (!ExtractUInt32(&args, guid))
if (!ExtractUInt32(&args, lowguid))
return false;
if (!guid)
if (!lowguid)
{
PSendSysMessage(LANG_INVALID_CHARACTER_GUID);
SetSentErrorMessage(true);
return false;
}
ObjectGuid guid = ObjectGuid(HIGHGUID_PLAYER, lowguid);
if (sObjectMgr.GetPlayerAccountIdByGUID(guid))
{
PSendSysMessage(LANG_CHARACTER_GUID_IN_USE,guid);
PSendSysMessage(LANG_CHARACTER_GUID_IN_USE, lowguid);
SetSentErrorMessage(true);
return false;
}
}
}
switch(PlayerDumpReader().LoadDump(file, account_id, name, guid))
switch(PlayerDumpReader().LoadDump(file, account_id, name, lowguid))
{
case DUMP_SUCCESS:
PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS);
@ -5773,9 +5775,10 @@ bool ChatHandler::HandlePDumpWriteCommand(char *args)
char* p2 = ExtractLiteralArg(&args);
uint32 guid;
uint32 lowguid;
ObjectGuid guid;
// character name can't start from number
if (!ExtractUInt32(&args, guid))
if (!ExtractUInt32(&p2, lowguid))
{
std::string name = ExtractPlayerNameFromLink(&p2);
if (name.empty())
@ -5785,9 +5788,19 @@ bool ChatHandler::HandlePDumpWriteCommand(char *args)
return false;
}
guid = GUID_LOPART(sObjectMgr.GetPlayerGUIDByName(name));
guid = sObjectMgr.GetPlayerGUIDByName(name);
if (guid.IsEmpty())
{
PSendSysMessage(LANG_PLAYER_NOT_FOUND);
SetSentErrorMessage(true);
return false;
}
lowguid = guid.GetCounter();
}
else
guid = ObjectGuid(HIGHGUID_PLAYER, lowguid);
if (!sObjectMgr.GetPlayerAccountIdByGUID(guid))
{
PSendSysMessage(LANG_PLAYER_NOT_FOUND);
@ -5795,7 +5808,7 @@ bool ChatHandler::HandlePDumpWriteCommand(char *args)
return false;
}
switch(PlayerDumpWriter().WriteDump(file, guid))
switch(PlayerDumpWriter().WriteDump(file, lowguid))
{
case DUMP_SUCCESS:
PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS);

View file

@ -291,7 +291,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid)
Player *player = GetPlayer();
Loot *loot;
player->SetLootGUID(0);
player->SetLootGUID(ObjectGuid());
player->SendLootRelease(lguid);
player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING);

View file

@ -452,7 +452,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data )
if (m->COD > 0) // if there is COD, take COD money from player and send them to sender by mail
{
uint64 sender_guid = MAKE_NEW_GUID(m->sender, 0, HIGHGUID_PLAYER);
ObjectGuid sender_guid = ObjectGuid(HIGHGUID_PLAYER, m->sender);
Player *receive = sObjectMgr.GetPlayer(sender_guid);
uint32 sender_accId = 0;
@ -596,7 +596,7 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data )
switch((*itr)->messageType)
{
case MAIL_NORMAL: // sender guid
data << uint64(MAKE_NEW_GUID((*itr)->sender, 0, HIGHGUID_PLAYER));
data << ObjectGuid(HIGHGUID_PLAYER, (*itr)->sender);
break;
case MAIL_CREATURE:
case MAIL_GAMEOBJECT:
@ -921,13 +921,14 @@ void MailDraft::deleteIncludedItems( bool inDB /**= false*/ )
* @param sender_guid The low part of the GUID of the sender.
* @param receiver_guid The low part of the GUID of the receiver.
*/
void MailDraft::SendReturnToSender(uint32 sender_acc, uint32 sender_guid, uint32 receiver_guid )
void MailDraft::SendReturnToSender(uint32 sender_acc, uint32 sender_lowguid, uint32 receiver_lowguid)
{
Player *receiver = sObjectMgr.GetPlayer(MAKE_NEW_GUID(receiver_guid, 0, HIGHGUID_PLAYER));
ObjectGuid receiver_guid = ObjectGuid(HIGHGUID_PLAYER, receiver_lowguid);
Player *receiver = sObjectMgr.GetPlayer(receiver_guid);
uint32 rc_account = 0;
if(!receiver)
rc_account = sObjectMgr.GetPlayerAccountIdByGUID(MAKE_NEW_GUID(receiver_guid, 0, HIGHGUID_PLAYER));
rc_account = sObjectMgr.GetPlayerAccountIdByGUID(receiver_guid);
if(!receiver && !rc_account) // sender not exist
{
@ -950,7 +951,7 @@ void MailDraft::SendReturnToSender(uint32 sender_acc, uint32 sender_guid, uint32
Item* item = mailItemIter->second;
item->SaveToDB(); // item not in inventory and can be save standalone
// owner in data will set at mail receive and item extracting
CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'", receiver_guid, item->GetGUIDLow());
CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'", receiver_lowguid, item->GetGUIDLow());
}
CharacterDatabase.CommitTransaction();
}
@ -959,7 +960,7 @@ void MailDraft::SendReturnToSender(uint32 sender_acc, uint32 sender_guid, uint32
uint32 deliver_delay = needItemDelay ? sWorld.getConfig(CONFIG_UINT32_MAIL_DELIVERY_DELAY) : 0;
// will delete item or place to receiver mail list
SendMailTo(MailReceiver(receiver,receiver_guid), MailSender(MAIL_NORMAL, sender_guid), MAIL_CHECK_MASK_RETURNED, deliver_delay);
SendMailTo(MailReceiver(receiver,receiver_lowguid), MailSender(MAIL_NORMAL, sender_lowguid), MAIL_CHECK_MASK_RETURNED, deliver_delay);
}
/**
* Sends a mail.

View file

@ -221,7 +221,7 @@ class MailDraft
*/
MailDraft& AddCOD(uint32 COD) { m_COD = COD; return *this; }
public: // finishers
void SendReturnToSender(uint32 sender_acc, uint32 sender_guid, uint32 receiver_guid);
void SendReturnToSender(uint32 sender_acc, uint32 sender_lowguid, uint32 receiver_lowguid);
void SendMailTo(MailReceiver const& receiver, MailSender const& sender, MailCheckMask checked = MAIL_CHECK_MASK_NONE, uint32 deliver_delay = 0);
private:
void deleteIncludedItems(bool inDB = false);

View file

@ -2414,7 +2414,7 @@ void Map::ScriptsProcess()
}
else
{
pSource->KilledMonsterCredit(step.script->datalong, 0);
pSource->KilledMonsterCredit(step.script->datalong);
}
break;

View file

@ -458,7 +458,8 @@ void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 acc
if(!result)
return;
uint64 friendGuid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER);
uint32 friendLowGuid = (*result)[0].GetUInt32();
ObjectGuid friendGuid = ObjectGuid(HIGHGUID_PLAYER, friendLowGuid);
uint32 team = Player::TeamForRace((*result)[1].GetUInt8());
delete result;
@ -468,13 +469,13 @@ void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 acc
return;
FriendsResult friendResult = FRIEND_NOT_FOUND;
if(friendGuid)
if (!friendGuid.IsEmpty())
{
if(friendGuid==session->GetPlayer()->GetGUID())
if (friendGuid == session->GetPlayer()->GetObjectGuid())
friendResult = FRIEND_SELF;
else if(session->GetPlayer()->GetTeam() != team && !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_ADD_FRIEND) && session->GetSecurity() < SEC_MODERATOR)
friendResult = FRIEND_ENEMY;
else if(session->GetPlayer()->GetSocial()->HasFriend(GUID_LOPART(friendGuid)))
else if(session->GetPlayer()->GetSocial()->HasFriend(friendLowGuid))
friendResult = FRIEND_ALREADY;
else
{
@ -484,17 +485,17 @@ void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 acc
else
friendResult = FRIEND_ADDED_OFFLINE;
if(!session->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(friendGuid), false))
if(!session->GetPlayer()->GetSocial()->AddToSocialList(friendLowGuid, false))
{
friendResult = FRIEND_LIST_FULL;
DEBUG_LOG( "WORLD: %s's friend list is full.", session->GetPlayer()->GetName());
}
session->GetPlayer()->GetSocial()->SetFriendNote(GUID_LOPART(friendGuid), friendNote);
session->GetPlayer()->GetSocial()->SetFriendNote(friendLowGuid, friendNote);
}
}
sSocialMgr.SendFriendStatus(session->GetPlayer(), friendResult, GUID_LOPART(friendGuid), false);
sSocialMgr.SendFriendStatus(session->GetPlayer(), friendResult, friendLowGuid, false);
DEBUG_LOG( "WORLD: Sent (SMSG_FRIEND_STATUS)" );
}
@ -538,7 +539,8 @@ void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResult *result, uint32 acc
if(!result)
return;
uint64 IgnoreGuid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER);
uint32 ignoreLowGuid = (*result)[0].GetUInt32();
ObjectGuid ignoreGuid = ObjectGuid(HIGHGUID_PLAYER, ignoreLowGuid);
delete result;
@ -547,23 +549,23 @@ void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResult *result, uint32 acc
return;
FriendsResult ignoreResult = FRIEND_IGNORE_NOT_FOUND;
if(IgnoreGuid)
if (!ignoreGuid.IsEmpty())
{
if(IgnoreGuid == session->GetPlayer()->GetGUID()) //not add yourself
if (ignoreGuid == session->GetPlayer()->GetObjectGuid())
ignoreResult = FRIEND_IGNORE_SELF;
else if( session->GetPlayer()->GetSocial()->HasIgnore(GUID_LOPART(IgnoreGuid)) )
else if (session->GetPlayer()->GetSocial()->HasIgnore(ignoreLowGuid))
ignoreResult = FRIEND_IGNORE_ALREADY;
else
{
ignoreResult = FRIEND_IGNORE_ADDED;
// ignore list full
if(!session->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(IgnoreGuid), true))
if(!session->GetPlayer()->GetSocial()->AddToSocialList(ignoreLowGuid, true))
ignoreResult = FRIEND_IGNORE_FULL;
}
}
sSocialMgr.SendFriendStatus(session->GetPlayer(), ignoreResult, GUID_LOPART(IgnoreGuid), false);
sSocialMgr.SendFriendStatus(session->GetPlayer(), ignoreResult, ignoreLowGuid, false);
DEBUG_LOG( "WORLD: Sent (SMSG_FRIEND_STATUS)" );
}

View file

@ -116,8 +116,8 @@ void Object::_Create( uint32 guidlow, uint32 entry, HighGuid guidhigh )
if(!m_uint32Values)
_InitValues();
uint64 guid = MAKE_NEW_GUID(guidlow, entry, guidhigh);
SetUInt64Value(OBJECT_FIELD_GUID, guid);
ObjectGuid guid = ObjectGuid(guidhigh, entry, guidlow);
SetGuidValue(OBJECT_FIELD_GUID, guid);
SetUInt32Value(OBJECT_FIELD_TYPE, m_objectType);
m_PackGUID.Set(guid);
}

View file

@ -110,7 +110,7 @@ ObjectAccessor::SaveAllPlayers()
itr->second->SaveToDB();
}
void ObjectAccessor::KickPlayer(uint64 guid)
void ObjectAccessor::KickPlayer(ObjectGuid guid)
{
if (Player* p = HashMapHolder<Player>::Find(guid))
{

View file

@ -110,7 +110,7 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor,
// Player access
static Player* FindPlayer(ObjectGuid guid); // if need player at specific map better use Map::GetPlayer
static Player* FindPlayerByName(const char *name);
static void KickPlayer(uint64 guid);
static void KickPlayer(ObjectGuid guid);
HashMapHolder<Player>::MapType& GetPlayers()
{

View file

@ -149,9 +149,9 @@ void LoadHelper(CellCorpseSet const& cell_corpses, CellPair &cell, CorpseMapType
if(itr->second != map->GetInstanceId())
continue;
uint32 player_guid = itr->first;
uint32 player_lowguid = itr->first;
Corpse *obj = sObjectAccessor.GetCorpseForPlayerGUID(player_guid);
Corpse *obj = sObjectAccessor.GetCorpseForPlayerGUID(ObjectGuid(HIGHGUID_PLAYER, player_lowguid));
if (!obj)
continue;

View file

@ -123,8 +123,10 @@ class MANGOS_DLL_SPEC ObjectGuid
public: // constructors
ObjectGuid() : m_guid(0) {}
ObjectGuid(uint64 const& guid) : m_guid(guid) {} // NOTE: must be explicit in future for more strict control type conversions
ObjectGuid(HighGuid hi, uint32 entry, uint32 counter) : m_guid(uint64(counter) | (uint64(entry) << 24) | (uint64(hi) << 48)) {}
ObjectGuid(HighGuid hi, uint32 counter) : m_guid(uint64(counter) | (uint64(hi) << 48)) {}
ObjectGuid(HighGuid hi, uint32 entry, uint32 counter) : m_guid(counter ? uint64(counter) | (uint64(entry) << 24) | (uint64(hi) << 48) : 0) {}
ObjectGuid(HighGuid hi, uint32 counter) : m_guid(counter ? uint64(counter) | (uint64(hi) << 48) : 0) {}
private:
ObjectGuid(uint32 const&); // no implementation, used for catch wrong type assign
public: // modifiers
PackedGuidReader ReadAsPacked() { return PackedGuidReader(*this); }

View file

@ -230,10 +230,10 @@ std::string ObjectMgr::GetGuildNameById(uint32 GuildId) const
return "";
}
Guild* ObjectMgr::GetGuildByLeader(const uint64 &guid) const
Guild* ObjectMgr::GetGuildByLeader(ObjectGuid guid) const
{
for(GuildMap::const_iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr)
if (itr->second->GetLeader() == guid)
if (itr->second->GetLeader() == guid.GetRawValue())
return itr->second;
return NULL;
@ -257,10 +257,10 @@ ArenaTeam* ObjectMgr::GetArenaTeamByName(const std::string& arenateamname) const
return NULL;
}
ArenaTeam* ObjectMgr::GetArenaTeamByCaptain(uint64 const& guid) const
ArenaTeam* ObjectMgr::GetArenaTeamByCaptain(ObjectGuid guid) const
{
for(ArenaTeamMap::const_iterator itr = mArenaTeamMap.begin(); itr != mArenaTeamMap.end(); ++itr)
if (itr->second->GetCaptain() == guid)
if (itr->second->GetCaptain() == guid.GetRawValue())
return itr->second;
return NULL;
@ -1523,7 +1523,7 @@ uint64 ObjectMgr::GetPlayerGUIDByName(std::string name) const
QueryResult *result = CharacterDatabase.PQuery("SELECT guid FROM characters WHERE name = '%s'", name.c_str());
if(result)
{
guid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER);
guid = ObjectGuid(HIGHGUID_PLAYER, (*result)[0].GetUInt32()).GetRawValue();
delete result;
}
@ -1531,7 +1531,7 @@ uint64 ObjectMgr::GetPlayerGUIDByName(std::string name) const
return guid;
}
bool ObjectMgr::GetPlayerNameByGUID(const uint64 &guid, std::string &name) const
bool ObjectMgr::GetPlayerNameByGUID(ObjectGuid guid, std::string &name) const
{
// prevent DB access for online player
if(Player* player = GetPlayer(guid))
@ -1540,7 +1540,9 @@ bool ObjectMgr::GetPlayerNameByGUID(const uint64 &guid, std::string &name) const
return true;
}
QueryResult *result = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = '%u'", GUID_LOPART(guid));
uint32 lowguid = guid.GetCounter();
QueryResult *result = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = '%u'", lowguid);
if(result)
{
@ -1552,15 +1554,15 @@ bool ObjectMgr::GetPlayerNameByGUID(const uint64 &guid, std::string &name) const
return false;
}
uint32 ObjectMgr::GetPlayerTeamByGUID(const uint64 &guid) const
uint32 ObjectMgr::GetPlayerTeamByGUID(ObjectGuid guid) const
{
// prevent DB access for online player
if (Player* player = GetPlayer(guid))
{
return Player::TeamForRace(player->getRace());
}
QueryResult *result = CharacterDatabase.PQuery("SELECT race FROM characters WHERE guid = '%u'", GUID_LOPART(guid));
uint32 lowguid = guid.GetCounter();
QueryResult *result = CharacterDatabase.PQuery("SELECT race FROM characters WHERE guid = '%u'", lowguid);
if (result)
{
@ -1572,15 +1574,15 @@ uint32 ObjectMgr::GetPlayerTeamByGUID(const uint64 &guid) const
return 0;
}
uint32 ObjectMgr::GetPlayerAccountIdByGUID(const uint64 &guid) const
uint32 ObjectMgr::GetPlayerAccountIdByGUID(ObjectGuid guid) const
{
// prevent DB access for online player
if(Player* player = GetPlayer(guid))
{
return player->GetSession()->GetAccountId();
}
QueryResult *result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE guid = '%u'", GUID_LOPART(guid));
uint32 lowguid = guid.GetCounter();
QueryResult *result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE guid = '%u'", lowguid);
if (result)
{
uint32 acc = (*result)[0].GetUInt32();

View file

@ -501,7 +501,7 @@ class ObjectMgr
void AddGroup(Group* group);
void RemoveGroup(Group* group);
Guild* GetGuildByLeader(uint64 const&guid) const;
Guild* GetGuildByLeader(ObjectGuid guid) const;
Guild* GetGuildById(uint32 GuildId) const;
Guild* GetGuildByName(const std::string& guildname) const;
std::string GetGuildNameById(uint32 GuildId) const;
@ -510,7 +510,7 @@ class ObjectMgr
ArenaTeam* GetArenaTeamById(uint32 arenateamid) const;
ArenaTeam* GetArenaTeamByName(const std::string& arenateamname) const;
ArenaTeam* GetArenaTeamByCaptain(uint64 const& guid) const;
ArenaTeam* GetArenaTeamByCaptain(ObjectGuid guid) const;
void AddArenaTeam(ArenaTeam* arenaTeam);
void RemoveArenaTeam(uint32 Id);
ArenaTeamMap::iterator GetArenaTeamMapBegin() { return mArenaTeamMap.begin(); }
@ -560,9 +560,9 @@ class ObjectMgr
void GetPlayerLevelInfo(uint32 race, uint32 class_,uint32 level, PlayerLevelInfo* info) const;
uint64 GetPlayerGUIDByName(std::string name) const;
bool GetPlayerNameByGUID(const uint64 &guid, std::string &name) const;
uint32 GetPlayerTeamByGUID(const uint64 &guid) const;
uint32 GetPlayerAccountIdByGUID(const uint64 &guid) const;
bool GetPlayerNameByGUID(ObjectGuid guid, std::string &name) const;
uint32 GetPlayerTeamByGUID(ObjectGuid guid) const;
uint32 GetPlayerAccountIdByGUID(ObjectGuid guid) const;
uint32 GetPlayerAccountIdByPlayerName(const std::string& name) const;
uint32 GetNearestTaxiNode( float x, float y, float z, uint32 mapid, uint32 team );

View file

@ -1214,7 +1214,7 @@ void Pet::_LoadAuras(uint32 timediff)
if (!holder->IsEmptyHolder())
{
holder->SetLoadedState(caster_guid, item_lowguid ? MAKE_NEW_GUID(item_lowguid, 0, HIGHGUID_ITEM) : 0, stackcount, remaincharges);
holder->SetLoadedState(caster_guid, ObjectGuid(HIGHGUID_ITEM, item_lowguid), stackcount, remaincharges);
AddSpellAuraHolder(holder);
}
else

View file

@ -245,7 +245,7 @@ void PetAI::UpdateAI(const uint32 diff)
continue;
}
Spell *spell = new Spell(m_creature, spellInfo, false, 0);
Spell *spell = new Spell(m_creature, spellInfo, false);
if (inCombat && !m_creature->hasUnitState(UNIT_STAT_FOLLOW) && spell->CanAutoCast(m_creature->getVictim()))
{

View file

@ -291,21 +291,23 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket & recv_data)
void WorldSession::HandlePetitionQueryOpcode(WorldPacket & recv_data)
{
DEBUG_LOG("Received opcode CMSG_PETITION_QUERY"); // ok
DEBUG_LOG("Received opcode CMSG_PETITION_QUERY");
//recv_data.hexlike();
uint32 guildguid;
uint64 petitionguid;
ObjectGuid petitionguid;
recv_data >> guildguid; // in mangos always same as GUID_LOPART(petitionguid)
recv_data >> petitionguid; // petition guid
DEBUG_LOG("CMSG_PETITION_QUERY Petition GUID %u Guild GUID %u", GUID_LOPART(petitionguid), guildguid);
DEBUG_LOG("CMSG_PETITION_QUERY Petition %s Guild GUID %u", petitionguid.GetString().c_str(), guildguid);
SendPetitionQueryOpcode(petitionguid);
}
void WorldSession::SendPetitionQueryOpcode(uint64 petitionguid)
void WorldSession::SendPetitionQueryOpcode(ObjectGuid petitionguid)
{
uint64 ownerguid = 0;
uint32 petitionLowGuid = petitionguid.GetCounter();
ObjectGuid ownerguid;
uint32 type;
std::string name = "NO_NAME_FOR_GUID";
uint8 signs = 0;
@ -314,12 +316,12 @@ void WorldSession::SendPetitionQueryOpcode(uint64 petitionguid)
"SELECT ownerguid, name, "
" (SELECT COUNT(playerguid) FROM petition_sign WHERE petition_sign.petitionguid = '%u') AS signs, "
" type "
"FROM petition WHERE petitionguid = '%u'", GUID_LOPART(petitionguid), GUID_LOPART(petitionguid));
"FROM petition WHERE petitionguid = '%u'", petitionLowGuid, petitionLowGuid);
if(result)
{
Field* fields = result->Fetch();
ownerguid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER);
ownerguid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32());
name = fields[1].GetCppString();
signs = fields[2].GetUInt8();
type = fields[3].GetUInt32();
@ -327,13 +329,13 @@ void WorldSession::SendPetitionQueryOpcode(uint64 petitionguid)
}
else
{
DEBUG_LOG("CMSG_PETITION_QUERY failed for petition (GUID: %u)", GUID_LOPART(petitionguid));
DEBUG_LOG("CMSG_PETITION_QUERY failed for petition (GUID: %u)", petitionLowGuid);
return;
}
WorldPacket data(SMSG_PETITION_QUERY_RESPONSE, (4+8+name.size()+1+1+4*12+2+10));
data << uint32(GUID_LOPART(petitionguid)); // guild/team guid (in mangos always same as GUID_LOPART(petition guid)
data << uint64(ownerguid); // charter owner guid
data << uint32(petitionLowGuid); // guild/team guid (in mangos always same as GUID_LOPART(petition guid)
data << ownerguid; // charter owner guid
data << name; // name (guild/arena team)
data << uint8(0); // some string
if(type == 9)
@ -446,16 +448,18 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data)
//recv_data.hexlike();
Field *fields;
uint64 petitionguid;
ObjectGuid petitionGuid;
uint8 unk;
recv_data >> petitionguid; // petition guid
recv_data >> petitionGuid; // petition guid
recv_data >> unk;
uint32 petitionLowGuid = petitionGuid.GetCounter();
QueryResult *result = CharacterDatabase.PQuery(
"SELECT ownerguid, "
" (SELECT COUNT(playerguid) FROM petition_sign WHERE petition_sign.petitionguid = '%u') AS signs, "
" type "
"FROM petition WHERE petitionguid = '%u'", GUID_LOPART(petitionguid), GUID_LOPART(petitionguid));
"FROM petition WHERE petitionguid = '%u'", petitionLowGuid, petitionLowGuid);
if(!result)
{
@ -464,18 +468,19 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data)
}
fields = result->Fetch();
uint64 ownerguid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER);
uint32 ownerLowGuid = fields[0].GetUInt32();
ObjectGuid ownerguid = ObjectGuid(HIGHGUID_PLAYER, ownerLowGuid);
uint8 signs = fields[1].GetUInt8();
uint32 type = fields[2].GetUInt32();
delete result;
uint32 plguidlo = _player->GetGUIDLow();
if(GUID_LOPART(ownerguid) == plguidlo)
if (ownerguid == _player->GetObjectGuid())
return;
// not let enemies sign guild charter
if(!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeam() != sObjectMgr.GetPlayerTeamByGUID(ownerguid))
if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GUILD) &&
GetPlayer()->GetTeam() != sObjectMgr.GetPlayerTeamByGUID(ownerguid))
{
if(type != 9)
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_NOT_ALLIED);
@ -527,14 +532,14 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data)
//client doesn't allow to sign petition two times by one character, but not check sign by another character from same account
//not allow sign another player from already sign player account
result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE player_account = '%u' AND petitionguid = '%u'", GetAccountId(), GUID_LOPART(petitionguid));
result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE player_account = '%u' AND petitionguid = '%u'", GetAccountId(), petitionLowGuid);
if(result)
{
delete result;
WorldPacket data(SMSG_PETITION_SIGN_RESULTS, (8+8+4));
data << uint64(petitionguid);
data << uint64(_player->GetGUID());
data << petitionGuid;
data << _player->GetObjectGuid();
data << uint32(PETITION_SIGN_ALREADY_SIGNED);
// close at signer side
@ -546,13 +551,15 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data)
return;
}
CharacterDatabase.PExecute("INSERT INTO petition_sign (ownerguid,petitionguid, playerguid, player_account) VALUES ('%u', '%u', '%u','%u')", GUID_LOPART(ownerguid),GUID_LOPART(petitionguid), plguidlo,GetAccountId());
CharacterDatabase.PExecute("INSERT INTO petition_sign (ownerguid,petitionguid, playerguid, player_account) VALUES ('%u', '%u', '%u','%u')",
ownerLowGuid, petitionLowGuid, _player->GetGUIDLow(), GetAccountId());
DEBUG_LOG("PETITION SIGN: GUID %u by player: %s (GUID: %u Account: %u)", GUID_LOPART(petitionguid), _player->GetName(),plguidlo,GetAccountId());
DEBUG_LOG("PETITION SIGN: GUID %u by player: %s (GUID: %u Account: %u)",
petitionLowGuid, _player->GetName(), _player->GetGUIDLow(), GetAccountId());
WorldPacket data(SMSG_PETITION_SIGN_RESULTS, (8+8+4));
data << uint64(petitionguid);
data << uint64(_player->GetGUID());
data << petitionGuid;
data << _player->GetObjectGuid();
data << uint32(PETITION_SIGN_OK);
// close at signer side
@ -573,24 +580,26 @@ void WorldSession::HandlePetitionDeclineOpcode(WorldPacket & recv_data)
DEBUG_LOG("Received opcode MSG_PETITION_DECLINE"); // ok
//recv_data.hexlike();
uint64 petitionguid;
uint64 ownerguid;
recv_data >> petitionguid; // petition guid
DEBUG_LOG("Petition %u declined by %u", GUID_LOPART(petitionguid), _player->GetGUIDLow());
ObjectGuid petitionGuid;
recv_data >> petitionGuid; // petition guid
QueryResult *result = CharacterDatabase.PQuery("SELECT ownerguid FROM petition WHERE petitionguid = '%u'", GUID_LOPART(petitionguid));
DEBUG_LOG("Petition %s declined by %s", petitionGuid.GetString().c_str(), _player->GetObjectGuid().GetString().c_str());
uint32 petitionLowGuid = petitionGuid.GetCounter();
QueryResult *result = CharacterDatabase.PQuery("SELECT ownerguid FROM petition WHERE petitionguid = '%u'", petitionLowGuid);
if (!result)
return;
Field *fields = result->Fetch();
ownerguid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER);
ObjectGuid ownerguid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32());
delete result;
Player *owner = sObjectMgr.GetPlayer(ownerguid);
if(owner) // petition owner online
{
WorldPacket data(MSG_PETITION_DECLINE, 8);
data << uint64(_player->GetGUID());
data << _player->GetObjectGuid();
owner->GetSession()->SendPacket(&data);
}
}

View file

@ -1552,7 +1552,7 @@ bool Player::BuildEnumData( QueryResult * result, WorldPacket * p_data )
return false;
}
*p_data << uint64(MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER));
*p_data << ObjectGuid(HIGHGUID_PLAYER, guid);
*p_data << fields[1].GetString(); // name
*p_data << uint8(pRace); // race
*p_data << uint8(pClass); // class
@ -2478,11 +2478,11 @@ void Player::UninviteFromGroup()
}
}
void Player::RemoveFromGroup(Group* group, uint64 guid)
void Player::RemoveFromGroup(Group* group, ObjectGuid guid)
{
if(group)
{
if (group->RemoveMember(guid, 0) <= 1)
if (group->RemoveMember(guid.GetRawValue(), 0) <= 1)
{
// group->Disband(); already disbanded in RemoveMember
sObjectMgr.RemoveGroup(group);
@ -4151,7 +4151,7 @@ TrainerSpellState Player::GetTrainerSpellState(TrainerSpell const* trainer_spell
* @param updateRealmChars when this flag is set, the amount of characters on that realm will be updated in the realmlist
* @param deleteFinally if this flag is set, the config option will be ignored and the character will be permanently removed from the database
*/
void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmChars, bool deleteFinally)
void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRealmChars, bool deleteFinally)
{
// for nonexistent account avoid update realm
if (accountId == 0)
@ -4164,7 +4164,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
if (deleteFinally || Player::GetLevelFromDB(playerguid) < charDelete_minLvl)
charDelete_method = 0;
uint32 guid = GUID_LOPART(playerguid);
uint32 lowguid = playerguid.GetCounter();
// convert corpse to bones if exist (to prevent exiting Corpse in World without DB entry)
// bones will be deleted by corpse/bones deleting thread shortly
@ -4173,13 +4173,13 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
// remove from guild
if (uint32 guildId = GetGuildIdFromDB(playerguid))
if (Guild* guild = sObjectMgr.GetGuildById(guildId))
guild->DelMember(guid);
guild->DelMember(playerguid.GetRawValue());
// remove from arena teams
LeaveAllArenaTeams(playerguid);
// the player was uninvited already on logout so just remove from group
QueryResult *resultGroup = CharacterDatabase.PQuery("SELECT groupId FROM group_member WHERE memberGuid='%u'", guid);
QueryResult *resultGroup = CharacterDatabase.PQuery("SELECT groupId FROM group_member WHERE memberGuid='%u'", lowguid);
if (resultGroup)
{
uint32 groupId = (*resultGroup)[0].GetUInt32();
@ -4197,7 +4197,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
case 0:
{
// return back all mails with COD and Item 0 1 2 3 4 5 6 7
QueryResult *resultMail = CharacterDatabase.PQuery("SELECT id,messageType,mailTemplateId,sender,subject,body,money,has_items FROM mail WHERE receiver='%u' AND has_items<>0 AND cod<>0", guid);
QueryResult *resultMail = CharacterDatabase.PQuery("SELECT id,messageType,mailTemplateId,sender,subject,body,money,has_items FROM mail WHERE receiver='%u' AND has_items<>0 AND cod<>0", lowguid);
if (resultMail)
{
do
@ -4251,7 +4251,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
}
Item *pItem = NewItemOrBag(itemProto);
if (!pItem->LoadFromDB(item_guidlow, MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER),resultItems))
if (!pItem->LoadFromDB(item_guidlow, playerguid.GetRawValue(), resultItems))
{
pItem->FSetState(ITEM_REMOVED);
pItem->SaveToDB(); // it also deletes item object !
@ -4268,9 +4268,9 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE mail_id = '%u'", mail_id);
uint32 pl_account = sObjectMgr.GetPlayerAccountIdByGUID(MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER));
uint32 pl_account = sObjectMgr.GetPlayerAccountIdByGUID(playerguid);
draft.AddMoney(money).SendReturnToSender(pl_account, guid, sender);
draft.AddMoney(money).SendReturnToSender(pl_account, lowguid, sender);
}
while (resultMail->NextRow());
@ -4279,7 +4279,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
// unsummon and delete for pets in world is not required: player deleted from CLI or character list with not loaded pet.
// Get guids of character's pets, will deleted in transaction
QueryResult *resultPets = CharacterDatabase.PQuery("SELECT id FROM character_pet WHERE owner = '%u'",guid);
QueryResult *resultPets = CharacterDatabase.PQuery("SELECT id FROM character_pet WHERE owner = '%u'",lowguid);
// NOW we can finally clear other DB data related to character
CharacterDatabase.BeginTransaction();
@ -4294,43 +4294,43 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
delete resultPets;
}
CharacterDatabase.PExecute("DELETE FROM characters WHERE guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_account_data WHERE guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_declinedname WHERE guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_action WHERE guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_aura WHERE guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_glyphs WHERE guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_homebind WHERE guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM group_instance WHERE leaderGuid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_queststatus WHERE guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_queststatus_daily WHERE guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_queststatus_weekly WHERE guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_reputation WHERE guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_skills WHERE guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_spell WHERE guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_spell_cooldown WHERE guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_talent WHERE guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_ticket WHERE guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE owner_guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_social WHERE guid = '%u' OR friend='%u'",guid,guid);
CharacterDatabase.PExecute("DELETE FROM mail WHERE receiver = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE receiver = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_pet WHERE owner = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_pet_declinedname WHERE owner = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_achievement WHERE guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_achievement_progress WHERE guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM character_equipmentsets WHERE guid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM guild_eventlog WHERE PlayerGuid1 = '%u' OR PlayerGuid2 = '%u'",guid, guid);
CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE PlayerGuid = '%u'",guid);
CharacterDatabase.PExecute("DELETE FROM characters WHERE guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_account_data WHERE guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_declinedname WHERE guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_action WHERE guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_aura WHERE guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_glyphs WHERE guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_homebind WHERE guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM group_instance WHERE leaderGuid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_queststatus WHERE guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_queststatus_daily WHERE guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_queststatus_weekly WHERE guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_reputation WHERE guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_skills WHERE guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_spell WHERE guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_spell_cooldown WHERE guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_talent WHERE guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_ticket WHERE guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE owner_guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_social WHERE guid = '%u' OR friend='%u'",lowguid,lowguid);
CharacterDatabase.PExecute("DELETE FROM mail WHERE receiver = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE receiver = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_pet WHERE owner = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_pet_declinedname WHERE owner = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_achievement WHERE guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_achievement_progress WHERE guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM character_equipmentsets WHERE guid = '%u'",lowguid);
CharacterDatabase.PExecute("DELETE FROM guild_eventlog WHERE PlayerGuid1 = '%u' OR PlayerGuid2 = '%u'",lowguid, lowguid);
CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE PlayerGuid = '%u'",lowguid);
CharacterDatabase.CommitTransaction();
break;
}
// The character gets unlinked from the account, the name gets freed up and appears as deleted ingame
case 1:
CharacterDatabase.PExecute("UPDATE characters SET deleteInfos_Name=name, deleteInfos_Account=account, deleteDate='" UI64FMTD "', name='', account=0 WHERE guid=%u", uint64(time(NULL)), guid);
CharacterDatabase.PExecute("UPDATE characters SET deleteInfos_Name=name, deleteInfos_Account=account, deleteDate='" UI64FMTD "', name='', account=0 WHERE guid=%u", uint64(time(NULL)), lowguid);
break;
default:
sLog.outError("Player::DeleteFromDB: Unsupported delete method: %u.", charDelete_method);
@ -4372,7 +4372,8 @@ void Player::DeleteOldCharacters(uint32 keepDays)
do
{
Field *charFields = resultChars->Fetch();
Player::DeleteFromDB(charFields[0].GetUInt64(), charFields[1].GetUInt32(), true, true);
ObjectGuid guid = ObjectGuid(HIGHGUID_PLAYER, charFields[0].GetUInt32());
Player::DeleteFromDB(guid, charFields[1].GetUInt32(), true, true);
} while(resultChars->NextRow());
delete resultChars;
}
@ -4620,7 +4621,7 @@ Corpse* Player::CreateCorpse()
void Player::SpawnCorpseBones()
{
if(sObjectAccessor.ConvertCorpseForPlayer(GetGUID()))
if(sObjectAccessor.ConvertCorpseForPlayer(GetObjectGuid()))
if (!GetSession()->PlayerLogoutWithSave()) // at logout we will already store the player
SaveToDB(); // prevent loading as ghost without corpse
}
@ -6591,9 +6592,11 @@ void Player::ModifyArenaPoints( int32 value )
SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, GetArenaPoints() < sWorld.getConfig(CONFIG_UINT32_MAX_ARENA_POINTS) - value ? GetArenaPoints() + value : sWorld.getConfig(CONFIG_UINT32_MAX_ARENA_POINTS));
}
uint32 Player::GetGuildIdFromDB(uint64 guid)
uint32 Player::GetGuildIdFromDB(ObjectGuid guid)
{
QueryResult* result = CharacterDatabase.PQuery("SELECT guildid FROM guild_member WHERE guid='%u'", GUID_LOPART(guid));
uint32 lowguid = guid.GetCounter();
QueryResult* result = CharacterDatabase.PQuery("SELECT guildid FROM guild_member WHERE guid='%u'", lowguid);
if (!result)
return 0;
@ -6626,10 +6629,10 @@ uint32 Player::GetArenaTeamIdFromDB(uint64 guid, uint8 type)
return id;
}
uint32 Player::GetZoneIdFromDB(uint64 guid)
uint32 Player::GetZoneIdFromDB(ObjectGuid guid)
{
uint32 guidLow = GUID_LOPART(guid);
QueryResult *result = CharacterDatabase.PQuery( "SELECT zone FROM characters WHERE guid='%u'", guidLow );
uint32 lowguid = guid.GetCounter();
QueryResult *result = CharacterDatabase.PQuery("SELECT zone FROM characters WHERE guid='%u'", lowguid);
if (!result)
return 0;
Field* fields = result->Fetch();
@ -6639,7 +6642,7 @@ uint32 Player::GetZoneIdFromDB(uint64 guid)
if (!zone)
{
// stored zone is zero, use generic and slow zone detection
result = CharacterDatabase.PQuery("SELECT map,position_x,position_y,position_z FROM characters WHERE guid='%u'", guidLow);
result = CharacterDatabase.PQuery("SELECT map,position_x,position_y,position_z FROM characters WHERE guid='%u'", lowguid);
if( !result )
return 0;
fields = result->Fetch();
@ -6652,15 +6655,17 @@ uint32 Player::GetZoneIdFromDB(uint64 guid)
zone = sMapMgr.GetZoneId(map,posx,posy,posz);
if (zone > 0)
CharacterDatabase.PExecute("UPDATE characters SET zone='%u' WHERE guid='%u'", zone, guidLow);
CharacterDatabase.PExecute("UPDATE characters SET zone='%u' WHERE guid='%u'", zone, lowguid);
}
return zone;
}
uint32 Player::GetLevelFromDB(uint64 guid)
uint32 Player::GetLevelFromDB(ObjectGuid guid)
{
QueryResult *result = CharacterDatabase.PQuery( "SELECT level FROM characters WHERE guid='%u'", GUID_LOPART(guid) );
uint32 lowguid = guid.GetCounter();
QueryResult *result = CharacterDatabase.PQuery("SELECT level FROM characters WHERE guid='%u'", lowguid);
if (!result)
return 0;
@ -7799,7 +7804,7 @@ void Player::RemovedInsignia(Player* looterPlr)
// We have to convert player corpse to bones, not to be able to resurrect there
// SpawnCorpseBones isn't handy, 'cos it saves player while he in BG
Corpse *bones = sObjectAccessor.ConvertCorpseForPlayer(GetGUID(),true);
Corpse *bones = sObjectAccessor.ConvertCorpseForPlayer(GetObjectGuid(), true);
if (!bones)
return;
@ -15043,7 +15048,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
}
// overwrite possible wrong/corrupted guid
SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER));
SetGuidValue(OBJECT_FIELD_GUID, ObjectGuid(HIGHGUID_PLAYER, guid));
// overwrite some data fields
uint32 bytes0 = 0;
@ -15449,7 +15454,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
_LoadActions(holder->GetResult(PLAYER_LOGIN_QUERY_LOADACTIONS));
m_social = sSocialMgr.LoadFromDB(holder->GetResult(PLAYER_LOGIN_QUERY_LOADSOCIALLIST), GetGUIDLow());
m_social = sSocialMgr.LoadFromDB(holder->GetResult(PLAYER_LOGIN_QUERY_LOADSOCIALLIST), GetObjectGuid());
// check PLAYER_CHOSEN_TITLE compatibility with PLAYER__FIELD_KNOWN_TITLES
// note: PLAYER__FIELD_KNOWN_TITLES updated at quest status loaded
@ -15734,7 +15739,7 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff)
if (caster_guid != GetGUID() && holder->IsSingleTarget())
holder->SetIsSingleTarget(false);
holder->SetLoadedState(caster_guid, item_lowguid ? MAKE_NEW_GUID(item_lowguid, 0, HIGHGUID_ITEM) : 0, stackcount, remaincharges);
holder->SetLoadedState(caster_guid, ObjectGuid(HIGHGUID_ITEM, item_lowguid), stackcount, remaincharges);
AddSpellAuraHolder(holder);
DETAIL_LOG("Added auras from spellid %u", spellproto->Id);
}
@ -15797,7 +15802,7 @@ void Player::LoadCorpse()
{
if( isAlive() )
{
sObjectAccessor.ConvertCorpseForPlayer(GetGUID());
sObjectAccessor.ConvertCorpseForPlayer(GetObjectGuid());
}
else
{
@ -18037,20 +18042,22 @@ void Player::SendProficiency(uint8 pr1, uint32 pr2)
GetSession()->SendPacket (&data);
}
void Player::RemovePetitionsAndSigns(uint64 guid, uint32 type)
void Player::RemovePetitionsAndSigns(ObjectGuid guid, uint32 type)
{
uint32 lowguid = guid.GetCounter();
QueryResult *result = NULL;
if(type == 10)
result = CharacterDatabase.PQuery("SELECT ownerguid,petitionguid FROM petition_sign WHERE playerguid = '%u'", GUID_LOPART(guid));
result = CharacterDatabase.PQuery("SELECT ownerguid,petitionguid FROM petition_sign WHERE playerguid = '%u'", lowguid);
else
result = CharacterDatabase.PQuery("SELECT ownerguid,petitionguid FROM petition_sign WHERE playerguid = '%u' AND type = '%u'", GUID_LOPART(guid), type);
result = CharacterDatabase.PQuery("SELECT ownerguid,petitionguid FROM petition_sign WHERE playerguid = '%u' AND type = '%u'", lowguid, type);
if(result)
{
do // this part effectively does nothing, since the deletion / modification only takes place _after_ the PetitionQuery. Though I don't know if the result remains intact if I execute the delete query beforehand.
{ // and SendPetitionQueryOpcode reads data from the DB
Field *fields = result->Fetch();
uint64 ownerguid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER);
uint64 petitionguid = MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_ITEM);
ObjectGuid ownerguid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32());
ObjectGuid petitionguid = ObjectGuid(HIGHGUID_ITEM, fields[1].GetUInt32());
// send update if charter owner in game
Player* owner = sObjectMgr.GetPlayer(ownerguid);
@ -18062,28 +18069,29 @@ void Player::RemovePetitionsAndSigns(uint64 guid, uint32 type)
delete result;
if(type==10)
CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE playerguid = '%u'", GUID_LOPART(guid));
CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE playerguid = '%u'", lowguid);
else
CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE playerguid = '%u' AND type = '%u'", GUID_LOPART(guid), type);
CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE playerguid = '%u' AND type = '%u'", lowguid, type);
}
CharacterDatabase.BeginTransaction();
if(type == 10)
{
CharacterDatabase.PExecute("DELETE FROM petition WHERE ownerguid = '%u'", GUID_LOPART(guid));
CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE ownerguid = '%u'", GUID_LOPART(guid));
CharacterDatabase.PExecute("DELETE FROM petition WHERE ownerguid = '%u'", lowguid);
CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE ownerguid = '%u'", lowguid);
}
else
{
CharacterDatabase.PExecute("DELETE FROM petition WHERE ownerguid = '%u' AND type = '%u'", GUID_LOPART(guid), type);
CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE ownerguid = '%u' AND type = '%u'", GUID_LOPART(guid), type);
CharacterDatabase.PExecute("DELETE FROM petition WHERE ownerguid = '%u' AND type = '%u'", lowguid, type);
CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE ownerguid = '%u' AND type = '%u'", lowguid, type);
}
CharacterDatabase.CommitTransaction();
}
void Player::LeaveAllArenaTeams(uint64 guid)
void Player::LeaveAllArenaTeams(ObjectGuid guid)
{
QueryResult *result = CharacterDatabase.PQuery("SELECT arena_team_member.arenateamid FROM arena_team_member JOIN arena_team ON arena_team_member.arenateamid = arena_team.arenateamid WHERE guid='%u'", GUID_LOPART(guid));
uint32 lowguid = guid.GetCounter();
QueryResult *result = CharacterDatabase.PQuery("SELECT arena_team_member.arenateamid FROM arena_team_member JOIN arena_team ON arena_team_member.arenateamid = arena_team.arenateamid WHERE guid='%u'", lowguid);
if (!result)
return;
@ -18095,7 +18103,7 @@ void Player::LeaveAllArenaTeams(uint64 guid)
{
ArenaTeam * at = sObjectMgr.GetArenaTeamById(at_id);
if(at)
at->DelMember(guid);
at->DelMember(guid.GetRawValue());
}
} while (result->NextRow());
@ -21828,7 +21836,7 @@ void Player::SendEquipmentSetList()
data << itr->second.Name;
data << itr->second.IconName;
for(uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i)
data.appendPackGUID(MAKE_NEW_GUID(itr->second.Items[i], 0, HIGHGUID_ITEM));
data << ObjectGuid(HIGHGUID_ITEM, itr->second.Items[i]).WriteAsPacked();
++count; // client have limit but it checked at loading and set
}

View file

@ -1486,7 +1486,7 @@ class MANGOS_DLL_SPEC Player : public Unit
void ItemAddedQuestCheck( uint32 entry, uint32 count );
void ItemRemovedQuestCheck( uint32 entry, uint32 count );
void KilledMonster( CreatureInfo const* cInfo, ObjectGuid guid );
void KilledMonsterCredit( uint32 entry, ObjectGuid guid );
void KilledMonsterCredit( uint32 entry, ObjectGuid guid = ObjectGuid());
void CastedCreatureOrGO( uint32 entry, ObjectGuid guid, uint32 spell_id, bool original_caster = true );
void TalkedToCreature( uint32 entry, ObjectGuid guid );
void MoneyChanged( uint32 value );
@ -1522,8 +1522,8 @@ class MANGOS_DLL_SPEC Player : public Unit
bool LoadFromDB(uint32 guid, SqlQueryHolder *holder);
static uint32 GetZoneIdFromDB(uint64 guid);
static uint32 GetLevelFromDB(uint64 guid);
static uint32 GetZoneIdFromDB(ObjectGuid guid);
static uint32 GetLevelFromDB(ObjectGuid guid);
static bool LoadPositionFromDB(uint32& mapid, float& x,float& y,float& z,float& o, bool& in_flight, uint64 guid);
/*********************************************************/
@ -1538,7 +1538,7 @@ class MANGOS_DLL_SPEC Player : public Unit
static void Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair);
static void SavePositionInDB(uint32 mapid, float x,float y,float z,float o,uint32 zone,uint64 guid);
static void DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmChars = true, bool deleteFinally = false);
static void DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRealmChars = true, bool deleteFinally = false);
static void DeleteOldCharacters();
static void DeleteOldCharacters(uint32 keepDays);
@ -1791,19 +1791,19 @@ class MANGOS_DLL_SPEC Player : public Unit
bool IsInSameGroupWith(Player const* p) const;
bool IsInSameRaidWith(Player const* p) const { return p==this || (GetGroup() != NULL && GetGroup() == p->GetGroup()); }
void UninviteFromGroup();
static void RemoveFromGroup(Group* group, uint64 guid);
void RemoveFromGroup() { RemoveFromGroup(GetGroup(),GetGUID()); }
static void RemoveFromGroup(Group* group, ObjectGuid guid);
void RemoveFromGroup() { RemoveFromGroup(GetGroup(), GetObjectGuid()); }
void SendUpdateToOutOfRangeGroupMembers();
void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); }
void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); }
void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; }
uint32 GetGuildId() { return GetUInt32Value(PLAYER_GUILDID); }
static uint32 GetGuildIdFromDB(uint64 guid);
static uint32 GetGuildIdFromDB(ObjectGuid guid);
uint32 GetRank(){ return GetUInt32Value(PLAYER_GUILDRANK); }
static uint32 GetRankFromDB(uint64 guid);
int GetGuildIdInvited() { return m_GuildIdInvited; }
static void RemovePetitionsAndSigns(uint64 guid, uint32 type);
static void RemovePetitionsAndSigns(ObjectGuid guid, uint32 type);
// Arena Team
void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot, uint8 type)
@ -1820,7 +1820,7 @@ class MANGOS_DLL_SPEC Player : public Unit
static uint32 GetArenaTeamIdFromDB(uint64 guid, uint8 slot);
void SetArenaTeamIdInvited(uint32 ArenaTeamId) { m_ArenaTeamIdInvited = ArenaTeamId; }
uint32 GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited; }
static void LeaveAllArenaTeams(uint64 guid);
static void LeaveAllArenaTeams(ObjectGuid guid);
Difficulty GetDifficulty(bool isRaid) const { return isRaid ? m_raidDifficulty : m_dungeonDifficulty; }
Difficulty GetDungeonDifficulty() const { return m_dungeonDifficulty; }

View file

@ -457,7 +457,7 @@ template <>
void PoolGroup<Creature>::ReSpawn1Object(PoolObject* obj)
{
if (CreatureData const* data = sObjectMgr.GetCreatureData(obj->guid))
if (Creature* pCreature = ObjectAccessor::GetCreatureInWorld(MAKE_NEW_GUID(obj->guid, data->id, HIGHGUID_UNIT)))
if (Creature* pCreature = ObjectAccessor::GetCreatureInWorld(ObjectGuid(HIGHGUID_UNIT, data->id, obj->guid)))
pCreature->GetMap()->Add(pCreature);
}

View file

@ -89,7 +89,7 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32
}
Field *fields = result->Fetch();
uint32 guid = fields[0].GetUInt32();
uint32 lowguid = fields[0].GetUInt32();
std::string name = fields[1].GetCppString();
uint8 pRace = 0, pGender = 0, pClass = 0;
if(name == "")
@ -102,7 +102,7 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32
}
// guess size
WorldPacket data( SMSG_NAME_QUERY_RESPONSE, (8+1+1+1+1+1+1+10) );
data.appendPackGUID(MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER));
data << ObjectGuid(HIGHGUID_PLAYER, lowguid).WriteAsPacked();
data << uint8(0); // added in 3.1; if > 1, then end of packet
data << name;
data << uint8(0); // realm name for cross realm BG usage

View file

@ -31,7 +31,6 @@ INSTANTIATE_SINGLETON_1( SocialMgr );
PlayerSocial::PlayerSocial()
{
m_playerGUID = 0;
}
PlayerSocial::~PlayerSocial()
@ -50,7 +49,7 @@ uint32 PlayerSocial::GetNumberOfSocialsWithFlag(SocialFlag flag)
return counter;
}
bool PlayerSocial::AddToSocialList(uint32 friend_guid, bool ignore)
bool PlayerSocial::AddToSocialList(uint32 friend_lowguid, bool ignore)
{
// check client limits
if(ignore)
@ -68,25 +67,25 @@ bool PlayerSocial::AddToSocialList(uint32 friend_guid, bool ignore)
if(ignore)
flag = SOCIAL_FLAG_IGNORED;
PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friend_guid);
PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friend_lowguid);
if(itr != m_playerSocialMap.end())
{
CharacterDatabase.PExecute("UPDATE character_social SET flags = (flags | %u) WHERE guid = '%u' AND friend = '%u'", flag, GetPlayerGUID(), friend_guid);
m_playerSocialMap[friend_guid].Flags |= flag;
CharacterDatabase.PExecute("UPDATE character_social SET flags = (flags | %u) WHERE guid = '%u' AND friend = '%u'", flag, m_playerLowGuid, friend_lowguid);
m_playerSocialMap[friend_lowguid].Flags |= flag;
}
else
{
CharacterDatabase.PExecute("INSERT INTO character_social (guid, friend, flags) VALUES ('%u', '%u', '%u')", GetPlayerGUID(), friend_guid, flag);
CharacterDatabase.PExecute("INSERT INTO character_social (guid, friend, flags) VALUES ('%u', '%u', '%u')", m_playerLowGuid, friend_lowguid, flag);
FriendInfo fi;
fi.Flags |= flag;
m_playerSocialMap[friend_guid] = fi;
m_playerSocialMap[friend_lowguid] = fi;
}
return true;
}
void PlayerSocial::RemoveFromSocialList(uint32 friend_guid, bool ignore)
void PlayerSocial::RemoveFromSocialList(uint32 friend_lowguid, bool ignore)
{
PlayerSocialMap::iterator itr = m_playerSocialMap.find(friend_guid);
PlayerSocialMap::iterator itr = m_playerSocialMap.find(friend_lowguid);
if(itr == m_playerSocialMap.end()) // not exist
return;
@ -97,18 +96,18 @@ void PlayerSocial::RemoveFromSocialList(uint32 friend_guid, bool ignore)
itr->second.Flags &= ~flag;
if(itr->second.Flags == 0)
{
CharacterDatabase.PExecute("DELETE FROM character_social WHERE guid = '%u' AND friend = '%u'", GetPlayerGUID(), friend_guid);
CharacterDatabase.PExecute("DELETE FROM character_social WHERE guid = '%u' AND friend = '%u'", m_playerLowGuid, friend_lowguid);
m_playerSocialMap.erase(itr);
}
else
{
CharacterDatabase.PExecute("UPDATE character_social SET flags = (flags & ~%u) WHERE guid = '%u' AND friend = '%u'", flag, GetPlayerGUID(), friend_guid);
CharacterDatabase.PExecute("UPDATE character_social SET flags = (flags & ~%u) WHERE guid = '%u' AND friend = '%u'", flag, m_playerLowGuid, friend_lowguid);
}
}
void PlayerSocial::SetFriendNote(uint32 friend_guid, std::string note)
void PlayerSocial::SetFriendNote(uint32 friend_lowguid, std::string note)
{
PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friend_guid);
PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friend_lowguid);
if(itr == m_playerSocialMap.end()) // not exist
return;
@ -116,13 +115,13 @@ void PlayerSocial::SetFriendNote(uint32 friend_guid, std::string note)
std::string safe_note = note;
CharacterDatabase.escape_string(safe_note);
CharacterDatabase.PExecute("UPDATE character_social SET note = '%s' WHERE guid = '%u' AND friend = '%u'", safe_note.c_str(), GetPlayerGUID(), friend_guid);
m_playerSocialMap[friend_guid].Note = note;
CharacterDatabase.PExecute("UPDATE character_social SET note = '%s' WHERE guid = '%u' AND friend = '%u'", safe_note.c_str(), m_playerLowGuid, friend_lowguid);
m_playerSocialMap[friend_lowguid].Note = note;
}
void PlayerSocial::SendSocialList()
{
Player *plr = sObjectMgr.GetPlayer(GetPlayerGUID());
Player *plr = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, m_playerLowGuid));
if(!plr)
return;
@ -136,7 +135,7 @@ void PlayerSocial::SendSocialList()
{
sSocialMgr.GetFriendInfo(plr, itr->first, itr->second);
data << uint64(itr->first); // player guid
data << ObjectGuid(HIGHGUID_PLAYER, itr->first); // player guid
data << uint32(itr->second.Flags); // player flag (0x1-friend?, 0x2-ignored?, 0x4-muted?)
data << itr->second.Note; // string note
if(itr->second.Flags & SOCIAL_FLAG_FRIEND) // if IsFriend()
@ -181,19 +180,19 @@ SocialMgr::~SocialMgr()
}
void SocialMgr::GetFriendInfo(Player *player, uint32 friendGUID, FriendInfo &friendInfo)
void SocialMgr::GetFriendInfo(Player *player, uint32 friend_lowguid, FriendInfo &friendInfo)
{
if(!player)
return;
Player *pFriend = ObjectAccessor::FindPlayer(friendGUID);
Player *pFriend = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, friend_lowguid));
uint32 team = player->GetTeam();
AccountTypes security = player->GetSession()->GetSecurity();
bool allowTwoSideWhoList = sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_WHO_LIST);
AccountTypes gmLevelInWhoList = AccountTypes (sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST));
PlayerSocialMap::iterator itr = player->GetSocial()->m_playerSocialMap.find(friendGUID);
PlayerSocialMap::iterator itr = player->GetSocial()->m_playerSocialMap.find(friend_lowguid);
if(itr != player->GetSocial()->m_playerSocialMap.end())
friendInfo.Note = itr->second.Note;
@ -226,16 +225,16 @@ void SocialMgr::MakeFriendStatusPacket(FriendsResult result, uint32 guid, WorldP
{
data->Initialize(SMSG_FRIEND_STATUS, 5);
*data << uint8(result);
*data << uint64(guid);
*data << ObjectGuid(HIGHGUID_PLAYER, guid);
}
void SocialMgr::SendFriendStatus(Player *player, FriendsResult result, uint32 friend_guid, bool broadcast)
void SocialMgr::SendFriendStatus(Player *player, FriendsResult result, uint32 friend_lowguid, bool broadcast)
{
FriendInfo fi;
WorldPacket data;
MakeFriendStatusPacket(result, friend_guid, &data);
GetFriendInfo(player, friend_guid, fi);
MakeFriendStatusPacket(result, friend_lowguid, &data);
GetFriendInfo(player, friend_lowguid, fi);
switch(result)
{
case FRIEND_ADDED_OFFLINE:
@ -296,10 +295,10 @@ void SocialMgr::BroadcastToFriendListers(Player *player, WorldPacket *packet)
}
}
PlayerSocial *SocialMgr::LoadFromDB(QueryResult *result, uint32 guid)
PlayerSocial *SocialMgr::LoadFromDB(QueryResult *result, ObjectGuid guid)
{
PlayerSocial *social = &m_socialMap[guid];
social->SetPlayerGUID(guid);
PlayerSocial *social = &m_socialMap[guid.GetCounter()];
social->SetPlayerGuid(guid);
if(!result)
return social;

View file

@ -128,12 +128,11 @@ class PlayerSocial
// Misc
bool HasFriend(uint32 friend_guid);
bool HasIgnore(uint32 ignore_guid);
uint32 GetPlayerGUID() { return m_playerGUID; }
void SetPlayerGUID(uint32 guid) { m_playerGUID = guid; }
void SetPlayerGuid(ObjectGuid guid) { m_playerLowGuid = guid.GetCounter(); }
uint32 GetNumberOfSocialsWithFlag(SocialFlag flag);
private:
PlayerSocialMap m_playerSocialMap;
uint32 m_playerGUID;
uint32 m_playerLowGuid;
};
class SocialMgr
@ -150,7 +149,7 @@ class SocialMgr
void SendFriendStatus(Player *player, FriendsResult result, uint32 friend_guid, bool broadcast);
void BroadcastToFriendListers(Player *player, WorldPacket *packet);
// Loading
PlayerSocial *LoadFromDB(QueryResult *result, uint32 guid);
PlayerSocial *LoadFromDB(QueryResult *result, ObjectGuid guid);
private:
SocialMap m_socialMap;
};

View file

@ -142,10 +142,10 @@ class MANGOS_DLL_SPEC SpellAuraHolder
void SetVisibleAura(bool remove) { m_target->SetVisibleAura(m_auraSlot, remove ? 0 : GetId()); }
void SetRemoveMode(AuraRemoveMode mode) { m_removeMode = mode; }
void SetLoadedState(uint64 casterGUID, uint64 itemGUID, int32 stackAmount, int32 charges)
void SetLoadedState(uint64 casterGUID, ObjectGuid itemGUID, int32 stackAmount, int32 charges)
{
m_caster_guid = casterGUID;
m_castItemGuid = itemGUID;
m_castItemGuid = itemGUID.GetRawValue();
m_procCharges = charges;
m_stackAmount = stackAmount;
}

View file

@ -1293,7 +1293,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx)
if (const SpellEntry *pSpell = sSpellStore.LookupEntry(46022))
{
m_caster->CastSpell(unitTarget, pSpell, true);
((Player*)m_caster)->KilledMonsterCredit(pSpell->EffectMiscValue[EFFECT_INDEX_0], 0);
((Player*)m_caster)->KilledMonsterCredit(pSpell->EffectMiscValue[EFFECT_INDEX_0]);
}
if (unitTarget->GetTypeId() == TYPEID_UNIT)
@ -1369,7 +1369,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx)
m_caster->CastSpell(unitTarget, pSpell, true);
if (const SpellEntry *pSpellCredit = sSpellStore.LookupEntry(pSpell->EffectMiscValue[EFFECT_INDEX_0]))
((Player*)m_caster)->KilledMonsterCredit(pSpellCredit->EffectMiscValue[EFFECT_INDEX_0], 0);
((Player*)m_caster)->KilledMonsterCredit(pSpellCredit->EffectMiscValue[EFFECT_INDEX_0]);
((Creature*)unitTarget)->ForcedDespawn();
}
@ -6733,7 +6733,7 @@ void Spell::EffectStuck(SpellEffectIndex /*eff_idx*/)
SpellEntry const *spellInfo = sSpellStore.LookupEntry(8690);
if(!spellInfo)
return;
Spell spell(pTarget, spellInfo, true, 0);
Spell spell(pTarget, spellInfo, true);
spell.SendSpellCooldown();
}
@ -7830,7 +7830,7 @@ void Spell::EffectKillCreditPersonal(SpellEffectIndex eff_idx)
if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
((Player*)unitTarget)->KilledMonsterCredit(m_spellInfo->EffectMiscValue[eff_idx], 0);
((Player*)unitTarget)->KilledMonsterCredit(m_spellInfo->EffectMiscValue[eff_idx]);
}
void Spell::EffectKillCredit(SpellEffectIndex eff_idx)

View file

@ -3404,7 +3404,7 @@ void Unit::_UpdateAutoRepeatSpell()
}
// we want to shoot
Spell* spell = new Spell(this, m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo, true, 0);
Spell* spell = new Spell(this, m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo, true);
spell->prepare(&(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_targets));
// all went good, reset attack

View file

@ -229,7 +229,7 @@ class MANGOS_DLL_SPEC WorldSession
void SendUpdateTrade(bool trader_state = true);
void SendCancelTrade();
void SendPetitionQueryOpcode( uint64 petitionguid);
void SendPetitionQueryOpcode(ObjectGuid petitionguid);
//pet
void SendPetNameQuery(uint64 guid, uint32 petnumber);
@ -266,7 +266,7 @@ class MANGOS_DLL_SPEC WorldSession
//auction
void SendAuctionHello(Unit * unit);
void SendAuctionCommandResult( uint32 auctionId, uint32 Action, uint32 ErrorCode, uint32 bidError = 0);
void SendAuctionBidderNotification( uint32 location, uint32 auctionId, uint64 bidder, uint32 bidSum, uint32 diff, uint32 item_template);
void SendAuctionBidderNotification( uint32 location, uint32 auctionId, ObjectGuid bidderGuid, uint32 bidSum, uint32 diff, uint32 item_template);
void SendAuctionOwnerNotification( AuctionEntry * auction );
void SendAuctionOutbiddedMail( AuctionEntry * auction, uint32 newPrice );
void SendAuctionCancelledToBidderMail( AuctionEntry* auction );

View file

@ -377,7 +377,7 @@ bool ChatHandler::HandleCharacterDeletedDeleteCommand(char* args)
// Call the appropriate function to delete them (current account for deleted characters is 0)
for(DeletedInfoList::const_iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
Player::DeleteFromDB(itr->lowguid, 0, false, true);
Player::DeleteFromDB(ObjectGuid(HIGHGUID_PLAYER, itr->lowguid), 0, false, true);
return true;
}

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10362"
#define REVISION_NR "10363"
#endif // __REVISION_NR_H__