mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[11730] Move empty guid check into GetPlayerAccountIdByGUID code.
This cleanup small code and let catch some missing check cases when 0 guid attempt searched by real DB query. This also make function call more safe if it used with non-player guid by some reason.
This commit is contained in:
parent
35e8af7195
commit
8e48e44c22
5 changed files with 13 additions and 10 deletions
|
|
@ -155,7 +155,7 @@ void WorldSession::SendAuctionOutbiddedMail(AuctionEntry *auction)
|
||||||
Player *oldBidder = sObjectMgr.GetPlayer(oldBidder_guid);
|
Player *oldBidder = sObjectMgr.GetPlayer(oldBidder_guid);
|
||||||
|
|
||||||
uint32 oldBidder_accId = 0;
|
uint32 oldBidder_accId = 0;
|
||||||
if(!oldBidder && oldBidder_guid)
|
if(!oldBidder)
|
||||||
oldBidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(oldBidder_guid);
|
oldBidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(oldBidder_guid);
|
||||||
|
|
||||||
// old bidder exist
|
// old bidder exist
|
||||||
|
|
@ -180,7 +180,7 @@ void WorldSession::SendAuctionCancelledToBidderMail(AuctionEntry* auction)
|
||||||
Player *bidder = sObjectMgr.GetPlayer(bidder_guid);
|
Player *bidder = sObjectMgr.GetPlayer(bidder_guid);
|
||||||
|
|
||||||
uint32 bidder_accId = 0;
|
uint32 bidder_accId = 0;
|
||||||
if (!bidder && bidder_guid)
|
if (!bidder)
|
||||||
bidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(bidder_guid);
|
bidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(bidder_guid);
|
||||||
|
|
||||||
// bidder exist
|
// bidder exist
|
||||||
|
|
@ -409,7 +409,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
|
||||||
|
|
||||||
// impossible have online own another character (use this for speedup check in case online owner)
|
// impossible have online own another character (use this for speedup check in case online owner)
|
||||||
Player* auction_owner = sObjectMgr.GetPlayer(ownerGuid);
|
Player* auction_owner = sObjectMgr.GetPlayer(ownerGuid);
|
||||||
if (!auction_owner && ownerGuid && sObjectMgr.GetPlayerAccountIdByGUID(ownerGuid) == pl->GetSession()->GetAccountId())
|
if (!auction_owner && sObjectMgr.GetPlayerAccountIdByGUID(ownerGuid) == pl->GetSession()->GetAccountId())
|
||||||
{
|
{
|
||||||
// you cannot bid your another character auction:
|
// you cannot bid your another character auction:
|
||||||
SendAuctionCommandResult(NULL, AUCTION_BID_PLACED, AUCTION_ERR_BID_OWN);
|
SendAuctionCommandResult(NULL, AUCTION_BID_PLACED, AUCTION_ERR_BID_OWN);
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry *auction)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bidder_accId = bidder_guid ? sObjectMgr.GetPlayerAccountIdByGUID(bidder_guid) : 0;
|
bidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(bidder_guid);
|
||||||
bidder_security = bidder_accId ? sAccountMgr.GetSecurity(bidder_accId) : SEC_PLAYER;
|
bidder_security = bidder_accId ? sAccountMgr.GetSecurity(bidder_accId) : SEC_PLAYER;
|
||||||
|
|
||||||
if (bidder_security > SEC_PLAYER) // not do redundant DB requests
|
if (bidder_security > SEC_PLAYER) // not do redundant DB requests
|
||||||
|
|
@ -122,13 +122,13 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry *auction)
|
||||||
else if (ownerGuid && !sObjectMgr.GetPlayerNameByGUID(ownerGuid, owner_name))
|
else if (ownerGuid && !sObjectMgr.GetPlayerNameByGUID(ownerGuid, owner_name))
|
||||||
owner_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN);
|
owner_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN);
|
||||||
|
|
||||||
uint32 owner_accid = ownerGuid ? sObjectMgr.GetPlayerAccountIdByGUID(ownerGuid) : 0;
|
uint32 owner_accid = sObjectMgr.GetPlayerAccountIdByGUID(ownerGuid);
|
||||||
|
|
||||||
sLog.outCommand(bidder_accId,"GM %s (Account: %u) won item in auction (Entry: %u Count: %u) and pay money: %u. Original owner %s (Account: %u)",
|
sLog.outCommand(bidder_accId,"GM %s (Account: %u) won item in auction (Entry: %u Count: %u) and pay money: %u. Original owner %s (Account: %u)",
|
||||||
bidder_name.c_str(), bidder_accId, auction->itemTemplate, auction->itemCount, auction->bid, owner_name.c_str(), owner_accid);
|
bidder_name.c_str(), bidder_accId, auction->itemTemplate, auction->itemCount, auction->bid, owner_name.c_str(), owner_accid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!bidder && bidder_guid)
|
else if (!bidder)
|
||||||
bidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(bidder_guid);
|
bidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(bidder_guid);
|
||||||
|
|
||||||
if (auction_owner)
|
if (auction_owner)
|
||||||
|
|
@ -183,7 +183,7 @@ void AuctionHouseMgr::SendAuctionSuccessfulMail(AuctionEntry * auction)
|
||||||
Player *owner = sObjectMgr.GetPlayer(owner_guid);
|
Player *owner = sObjectMgr.GetPlayer(owner_guid);
|
||||||
|
|
||||||
uint32 owner_accId = 0;
|
uint32 owner_accId = 0;
|
||||||
if (!owner && owner_guid)
|
if (!owner)
|
||||||
owner_accId = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid);
|
owner_accId = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid);
|
||||||
|
|
||||||
// owner exist
|
// owner exist
|
||||||
|
|
|
||||||
|
|
@ -514,7 +514,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data )
|
||||||
sender_accId = sender->GetSession()->GetAccountId();
|
sender_accId = sender->GetSession()->GetAccountId();
|
||||||
sender_name = sender->GetName();
|
sender_name = sender->GetName();
|
||||||
}
|
}
|
||||||
else
|
else if (sender_guid)
|
||||||
{
|
{
|
||||||
// can be calculated early
|
// can be calculated early
|
||||||
sender_accId = sObjectMgr.GetPlayerAccountIdByGUID(sender_guid);
|
sender_accId = sObjectMgr.GetPlayerAccountIdByGUID(sender_guid);
|
||||||
|
|
@ -525,7 +525,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data )
|
||||||
sLog.outCommand(GetAccountId(), "GM %s (Account: %u) receive mail item: %s (Entry: %u Count: %u) and send COD money: %u to player: %s (Account: %u)",
|
sLog.outCommand(GetAccountId(), "GM %s (Account: %u) receive mail item: %s (Entry: %u Count: %u) and send COD money: %u to player: %s (Account: %u)",
|
||||||
GetPlayerName(), GetAccountId(), it->GetProto()->Name1, it->GetEntry(), it->GetCount(), m->COD, sender_name.c_str(), sender_accId);
|
GetPlayerName(), GetAccountId(), it->GetProto()->Name1, it->GetEntry(), it->GetCount(), m->COD, sender_name.c_str(), sender_accId);
|
||||||
}
|
}
|
||||||
else if(!sender)
|
else if (!sender)
|
||||||
sender_accId = sObjectMgr.GetPlayerAccountIdByGUID(sender_guid);
|
sender_accId = sObjectMgr.GetPlayerAccountIdByGUID(sender_guid);
|
||||||
|
|
||||||
// check player existence
|
// check player existence
|
||||||
|
|
|
||||||
|
|
@ -1657,6 +1657,9 @@ Team ObjectMgr::GetPlayerTeamByGUID(ObjectGuid guid) const
|
||||||
|
|
||||||
uint32 ObjectMgr::GetPlayerAccountIdByGUID(ObjectGuid guid) const
|
uint32 ObjectMgr::GetPlayerAccountIdByGUID(ObjectGuid guid) const
|
||||||
{
|
{
|
||||||
|
if (!guid.IsPlayer())
|
||||||
|
return 0;
|
||||||
|
|
||||||
// prevent DB access for online player
|
// prevent DB access for online player
|
||||||
if(Player* player = GetPlayer(guid))
|
if(Player* player = GetPlayer(guid))
|
||||||
return player->GetSession()->GetAccountId();
|
return player->GetSession()->GetAccountId();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11729"
|
#define REVISION_NR "11730"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue