本文整理汇总了C++中GetAccountId函数的典型用法代码示例。如果您正苦于以下问题:C++ GetAccountId函数的具体用法?C++ GetAccountId怎么用?C++ GetAccountId使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetAccountId函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: UpdateTimeOutTime
//.........这里部分代码省略.........
LogUnexpectedOpcode(packet, "STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT",
"the player has not logged in yet and not recently logout");
else
{
// not expected _player or must checked in packet handler
sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
(this->*opHandle.handler)(*packet);
if (sLog->IsOutDebug() && packet->rpos() < packet->wpos())
LogUnprocessedTail(packet);
}
break;
case STATUS_TRANSFER:
if (!_player)
LogUnexpectedOpcode(packet, "STATUS_TRANSFER", "the player has not logged in yet");
else if (_player->IsInWorld())
LogUnexpectedOpcode(packet, "STATUS_TRANSFER", "the player is still in world");
else
{
sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
(this->*opHandle.handler)(*packet);
if (sLog->IsOutDebug() && packet->rpos() < packet->wpos())
LogUnprocessedTail(packet);
}
break;
case STATUS_AUTHED:
// prevent cheating with skip queue wait
if (m_inQueue)
{
LogUnexpectedOpcode(packet, "STATUS_AUTHED", "the player not pass queue yet");
break;
}
// single from authed time opcodes send in to after logout time
// and before other STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT opcodes.
if (packet->GetOpcode() != CMSG_SET_ACTIVE_VOICE_CHANNEL)
m_playerRecentlyLogout = false;
sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
(this->*opHandle.handler)(*packet);
if (sLog->IsOutDebug() && packet->rpos() < packet->wpos())
LogUnprocessedTail(packet);
break;
case STATUS_NEVER:
sLog->outError("SESSION (account: %u, guidlow: %u, char: %s): received not allowed opcode %s (0x%.4X)",
GetAccountId(), m_GUIDLow, _player ? _player->GetName() : "<none>",
LookupOpcodeName(packet->GetOpcode()), packet->GetOpcode());
break;
case STATUS_UNHANDLED:
sLog->outDebug(LOG_FILTER_NETWORKIO, "SESSION (account: %u, guidlow: %u, char: %s): received not handled opcode %s (0x%.4X)",
GetAccountId(), m_GUIDLow, _player ? _player->GetName() : "<none>",
LookupOpcodeName(packet->GetOpcode()), packet->GetOpcode());
break;
}
}
catch(ByteBufferException &)
{
sLog->outError("WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i. Skipped packet.",
packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
if (sLog->IsOutDebug())
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "Dumping error causing packet:");
packet->hexlike();
}
}
}
if (deletePacket)
delete packet;
}
if (m_Socket && !m_Socket->IsClosed() && _warden)
_warden->Update();
ProcessQueryCallbacks();
//check if we are safe to proceed with logout
//logout procedure should happen only in World::UpdateSessions() method!!!
if (updater.ProcessLogout())
{
time_t currTime = time(NULL);
///- If necessary, log the player out
if (ShouldLogOut(currTime) && !m_playerLoading)
LogoutPlayer(true);
if (m_Socket && GetPlayer() && _warden)
_warden->Update();
///- Cleanup socket pointer if need
if (m_Socket && m_Socket->IsClosed())
{
m_Socket->RemoveReference();
m_Socket = NULL;
}
if (!m_Socket)
return false; //Will remove this session from the world session map
}
return true;
}
开发者ID:Bulbucan,项目名称:TrinityCore,代码行数:101,代码来源:WorldSession.cpp
示例2: GetPlayer
//this void creates new auction and adds auction to some auctionhouse
void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
{
uint64 auctioneer, item;
uint32 etime, bid, buyout;
recv_data >> auctioneer;
recv_data.read_skip<uint32>(); // const 1?
recv_data >> item;
recv_data.read_skip<uint32>(); // unk 3.2.2, const 1?
recv_data >> bid;
recv_data >> buyout;
recv_data >> etime;
Player *pl = GetPlayer();
if (!item || !bid || !etime)
return; //check for cheaters
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer,UNIT_NPC_FLAG_AUCTIONEER);
if (!pCreature)
{
sLog.outDebug("WORLD: HandleAuctionSellItem - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer)));
return;
}
AuctionHouseEntry const* auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(pCreature->getFaction());
if (!auctionHouseEntry)
{
sLog.outDebug("WORLD: HandleAuctionSellItem - Unit (GUID: %u) has wrong faction.", uint32(GUID_LOPART(auctioneer)));
return;
}
sLog.outDebug("WORLD: HandleAuctionSellItem - ETIME: %u", etime);
// client send time in minutes, convert to common used sec time
etime *= MINUTE;
sLog.outDebug("WORLD: HandleAuctionSellItem - ETIME: %u", etime);
// client understand only 3 auction time
switch(etime)
{
case 1*MIN_AUCTION_TIME:
case 2*MIN_AUCTION_TIME:
case 4*MIN_AUCTION_TIME:
break;
default:
return;
}
// remove fake death
if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
Item *it = pl->GetItemByGuid(item);
//do not allow to sell already auctioned items
if (sAuctionMgr.GetAItem(GUID_LOPART(item)))
{
sLog.outError("AuctionError, player %s is sending item id: %u, but item is already in another auction", pl->GetName(), GUID_LOPART(item));
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
return;
}
// prevent sending bag with items (cheat: can be placed in bag after adding equiped empty bag to auction)
if (!it)
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_ITEM_NOT_FOUND);
return;
}
if (!it->CanBeTraded())
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
return;
}
if (it->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_CONJURED) || it->GetUInt32Value(ITEM_FIELD_DURATION))
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
return;
}
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(pCreature->getFaction());
//we have to take deposit :
uint32 deposit = AuctionHouseMgr::GetAuctionDeposit(auctionHouseEntry, etime, it);
if (pl->GetMoney() < deposit)
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_NOT_ENOUGHT_MONEY);
return;
}
if (GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE))
{
sLog.outCommand(GetAccountId(),"GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)",
GetPlayerName(),GetAccountId(),it->GetProto()->Name1,it->GetEntry(),it->GetCount());
}
pl->ModifyMoney(-int32(deposit));
uint32 auction_time = uint32(etime * sWorld.getRate(RATE_AUCTION_TIME));
//.........这里部分代码省略.........
开发者ID:Sanzzes,项目名称:wopc-core,代码行数:101,代码来源:AuctionHouseHandler.cpp
示例3: CHECK_PACKET_SIZE
//.........这里部分代码省略.........
}
if ((item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_CONJURED) || item->GetUInt32Value(ITEM_FIELD_DURATION)))
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM);
return;
}
if (COD && item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED))
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_CANT_SEND_WRAPPED_COD);
return;
}
if (item->IsBag() && !((Bag*)item)->IsEmpty())
{
pl->SendMailResult(0, 0, MAIL_ERR_INTERNAL_ERROR);
return;
}
items[i] = item;
}
pl->SendMailResult(0, MAIL_SEND, MAIL_OK);
pl->ModifyMoney(-int32(reqmoney));
bool needItemDelay = false;
MailDraft draft(subject, body);
uint32 rc_account = 0;
if (receive)
rc_account = receive->GetSession()->GetAccountId();
else
rc_account = sObjectMgr.GetPlayerAccountIdByGUID(rc);
if (items_count > 0 || money > 0)
{
if (items_count > 0)
{
for(uint8 i = 0; i < items_count; ++i)
{
Item* item = items[i];
if (!item)
continue;
if (HasPermissions(PERM_GMT) && sWorld.getConfig(CONFIG_GM_LOG_TRADE))
{
sLog.outCommand(GetAccountId(), "GM %s (Account: %u) mail item: %s (Entry: %u Count: %u) to player: %s (Account: %u)",
GetPlayerName(), GetAccountId(), item->GetProto()->Name1, item->GetEntry(), item->GetCount(), receiver.c_str(), rc_account);
}
sLog.outLog(LOG_TRADE, "Player %s (Account: %u) mail item: %s (Entry: %u Count: %u) to player: %s (Account: %u)",
GetPlayerName(), GetAccountId(), item->GetProto()->Name1, item->GetEntry(), item->GetCount(), receiver.c_str(), rc_account);
pl->MoveItemFromInventory(item->GetBagSlot(), item->GetSlot(), true);
RealmDataDatabase.BeginTransaction();
item->DeleteFromInventoryDB(); //deletes item from character's inventory
item->SaveToDB(); // recursive and not have transaction guard into self, item not in inventory and can be save standalone
// owner in data will set at mail receive and item extracting
RealmDataDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'", rc.GetCounter(), item->GetGUIDLow());
RealmDataDatabase.CommitTransaction();
draft.AddItem(item);
}
开发者ID:Xadras,项目名称:looking4group-core,代码行数:67,代码来源:MailHandler.cpp
示例4: GetPlayer
void WorldSession::HandleSendMail(WorldPackets::Mail::SendMail& packet)
{
if (packet.Info.Attachments.size() > MAX_MAIL_ITEMS) // client limit
{
GetPlayer()->SendMailResult(0, MAIL_SEND, MAIL_ERR_TOO_MANY_ATTACHMENTS);
return;
}
if (!CanOpenMailBox(packet.Info.Mailbox))
return;
if (packet.Info.Target.empty())
return;
Player* player = _player;
if (player->getLevel() < sWorld->getIntConfig(CONFIG_MAIL_LEVEL_REQ))
{
SendNotification(GetTrinityString(LANG_MAIL_SENDER_REQ), sWorld->getIntConfig(CONFIG_MAIL_LEVEL_REQ));
return;
}
ObjectGuid receiverGuid;
if (normalizePlayerName(packet.Info.Target))
receiverGuid = ObjectMgr::GetPlayerGUIDByName(packet.Info.Target);
if (!receiverGuid)
{
TC_LOG_INFO("network", "Player %s is sending mail to %s (GUID: not existed!) with subject %s "
"and body %s includes " SZFMTD " items, " SI64FMTD " copper and " SI64FMTD " COD copper with StationeryID = %d, PackageID = %d",
GetPlayerInfo().c_str(), packet.Info.Target.c_str(), packet.Info.Subject.c_str(), packet.Info.Body.c_str(),
packet.Info.Attachments.size(), packet.Info.SendMoney, packet.Info.Cod, packet.Info.StationeryID, packet.Info.PackageID);
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_NOT_FOUND);
return;
}
if (packet.Info.SendMoney < 0)
{
GetPlayer()->SendMailResult(0, MAIL_SEND, MAIL_ERR_INTERNAL_ERROR);
TC_LOG_WARN("cheat", "Player %s attempted to send mail to %s (%s) with negative money value (SendMoney: " SI64FMTD ")",
GetPlayerInfo().c_str(), packet.Info.Target.c_str(), receiverGuid.ToString().c_str(), packet.Info.SendMoney);
return;
}
if (packet.Info.Cod < 0)
{
GetPlayer()->SendMailResult(0, MAIL_SEND, MAIL_ERR_INTERNAL_ERROR);
TC_LOG_WARN("cheat", "Player %s attempted to send mail to %s (%s) with negative COD value (Cod: " SI64FMTD ")",
GetPlayerInfo().c_str(), packet.Info.Target.c_str(), receiverGuid.ToString().c_str(), packet.Info.Cod);
return;
}
TC_LOG_INFO("network", "Player %s is sending mail to %s (%s) with subject %s and body %s "
"includes " SZFMTD " items, " SI64FMTD " copper and " SI64FMTD " COD copper with StationeryID = %d, PackageID = %d",
GetPlayerInfo().c_str(), packet.Info.Target.c_str(), receiverGuid.ToString().c_str(), packet.Info.Subject.c_str(),
packet.Info.Body.c_str(), packet.Info.Attachments.size(), packet.Info.SendMoney, packet.Info.Cod, packet.Info.StationeryID, packet.Info.PackageID);
if (player->GetGUID() == receiverGuid)
{
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_CANNOT_SEND_TO_SELF);
return;
}
uint32 cost = !packet.Info.Attachments.empty() ? 30 * packet.Info.Attachments.size() : 30; // price hardcoded in client
int64 reqmoney = cost + packet.Info.SendMoney;
// Check for overflow
if (reqmoney < packet.Info.SendMoney)
{
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_ENOUGH_MONEY);
return;
}
if (!player->HasEnoughMoney(reqmoney) && !player->IsGameMaster())
{
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_ENOUGH_MONEY);
return;
}
Player* receiver = ObjectAccessor::FindConnectedPlayer(receiverGuid);
uint32 receiverTeam = 0;
uint8 mailsCount = 0; //do not allow to send to one player more than 100 mails
uint8 receiverLevel = 0;
uint32 receiverAccountId = 0;
uint32 receiverBnetAccountId = 0;
if (receiver)
{
receiverTeam = receiver->GetTeam();
mailsCount = receiver->GetMailSize();
receiverLevel = receiver->getLevel();
receiverAccountId = receiver->GetSession()->GetAccountId();
receiverBnetAccountId = receiver->GetSession()->GetBattlenetAccountId();
}
else
{
receiverTeam = ObjectMgr::GetPlayerTeamByGUID(receiverGuid);
//.........这里部分代码省略.........
开发者ID:Rastrian,项目名称:DeathCore_6.x-1,代码行数:101,代码来源:MailHandler.cpp
示例5: MAKE_NEW_GUID
/**
* Handles the packet sent by the client when taking an item from the mail.
*/
void WorldSession::HandleTakeItem(WorldPacket & recv_data)
{
uint64 mailbox;
uint32 mailId;
uint32 itemId;
recv_data >> mailbox;
recv_data >> mailId;
recv_data >> itemId; // item guid low
if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX))
return;
Player* pl = _player;
Mail* m = pl->GetMail(mailId);
if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL))
{
pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_INTERNAL_ERROR);
return;
}
// prevent cheating with skip client money check
if (pl->GetMoney() < m->COD)
{
pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_NOT_ENOUGH_MONEY);
return;
}
Item *it = pl->GetMItem(itemId);
ItemPosCountVec dest;
uint8 msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, dest, it, false);
if (msg == EQUIP_ERR_OK)
{
m->RemoveItem(itemId);
m->removedItems.push_back(itemId);
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);
Player *receive = sObjectMgr->GetPlayer(sender_guid);
uint32 sender_accId = 0;
if (GetSecurity() > SEC_PLAYER && sWorld->getConfig(CONFIG_GM_LOG_TRADE))
{
std::string sender_name;
if (receive)
{
sender_accId = receive->GetSession()->GetAccountId();
sender_name = receive->GetName();
}
else
{
// can be calculated early
sender_accId = sObjectMgr->GetPlayerAccountIdByGUID(sender_guid);
if (!sObjectMgr->GetPlayerNameByGUID(sender_guid, sender_name))
sender_name = sObjectMgr->GetSkyFireStringForDBCLocale(LANG_UNKNOWN);
}
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);
}
else if (!receive)
sender_accId = sObjectMgr->GetPlayerAccountIdByGUID(sender_guid);
// check player existence
if (receive || sender_accId)
{
MailDraft(m->subject)
.AddMoney(m->COD)
.SendMailTo(MailReceiver(receive, m->sender), MailSender(MAIL_NORMAL, m->receiver), MAIL_CHECK_MASK_COD_PAYMENT);
}
pl->ModifyMoney(-int32(m->COD));
}
m->COD = 0;
m->state = MAIL_STATE_CHANGED;
pl->m_mailsUpdated = true;
pl->RemoveMItem(it->GetGUIDLow());
uint32 count = it->GetCount(); // save counts before store and possible merge with deleting
pl->MoveItemToInventory(dest, it, true);
CharacterDatabase.BeginTransaction();
pl->SaveInventoryAndGoldToDB();
pl->_SaveMail();
CharacterDatabase.CommitTransaction();
pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_OK, 0, itemId, count);
}
else
pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_EQUIP_ERROR, msg);
}
开发者ID:Bootz,项目名称:SF1,代码行数:97,代码来源:Mail.cpp
示例6: SendAuctionCommandResult
//.........这里部分代码省略.........
Item* item = items[i];
if (item->GetMaxStackCount() < finalCount)
{
SendAuctionCommandResult(NULL, AUCTION_SELL_ITEM, ERR_AUCTION_DATABASE_ERROR);
return;
}
}
Item* item = items[0];
uint32 auctionTime = uint32(etime * sWorld->getRate(RATE_AUCTION_TIME));
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction());
uint32 deposit = sAuctionMgr->GetAuctionDeposit(auctionHouseEntry, etime, item, finalCount);
if (!_player->HasEnoughMoney((uint64)deposit))
{
SendAuctionCommandResult(NULL, AUCTION_SELL_ITEM, ERR_AUCTION_NOT_ENOUGHT_MONEY);
return;
}
AuctionEntry* AH = new AuctionEntry();
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
AH->auctioneer = 23442; ///@TODO - HARDCODED DB GUID, BAD BAD BAD
else
AH->auctioneer = GUID_LOPART(auctioneer);
// Required stack size of auction matches to current item stack size, just move item to auctionhouse
if (itemsCount == 1 && item->GetCount() == count[0])
{
if (HasPermission(rbac::RBAC_PERM_LOG_GM_TRADE))
{
sLog->outCommand(GetAccountId(), "GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)",
GetPlayerName().c_str(), GetAccountId(), item->GetTemplate()->Name1.c_str(), item->GetEntry(), item->GetCount());
}
AH->Id = sObjectMgr->GenerateAuctionID();
AH->itemGUIDLow = item->GetGUIDLow();
AH->itemEntry = item->GetEntry();
AH->itemCount = item->GetCount();
AH->owner = _player->GetGUIDLow();
AH->startbid = bid;
AH->bidder = 0;
AH->bid = 0;
AH->buyout = buyout;
AH->expire_time = time(NULL) + auctionTime;
AH->deposit = deposit;
AH->auctionHouseEntry = auctionHouseEntry;
TC_LOG_INFO("network", "CMSG_AUCTION_SELL_ITEM: Player %s (guid %d) is selling item %s entry %u (guid %d) "
"to auctioneer %u with count %u with initial bid " UI64FMTD " with buyout " UI64FMTD " and with time %u (in sec) in auctionhouse %u",
_player->GetName().c_str(), _player->GetGUIDLow(), item->GetTemplate()->Name1.c_str(), item->GetEntry(), item->GetGUIDLow(),
AH->auctioneer, item->GetCount(), bid, buyout, auctionTime, AH->GetHouseId());
sAuctionMgr->AddAItem(item);
auctionHouse->AddAuction(AH);
_player->MoveItemFromInventory(item->GetBagSlot(), item->GetSlot(), true);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
item->DeleteFromInventoryDB(trans);
item->SaveToDB(trans);
AH->SaveToDB(trans);
_player->SaveInventoryAndGoldToDB(trans);
CharacterDatabase.CommitTransaction(trans);
开发者ID:Destalker,项目名称:SkyFire_5xx,代码行数:66,代码来源:AuctionHouseHandler.cpp
示例7: while
/// Update the WorldSession (triggered by World update)
bool WorldSession::Update(uint32 /*diff*/)
{
///- Retrieve packets from the receive queue and call the appropriate handlers
/// not proccess packets if socket already closed
WorldPacket* packet;
while (_recvQueue.next(packet) && m_Socket && !m_Socket->IsClosed ())
{
/*#if 1
sLog.outError( "MOEP: %s (0x%.4X)",
LookupOpcodeName(packet->GetOpcode()),
packet->GetOpcode());
#endif*/
OpcodeStruct const* opHandle = opCodes.LookupOpcode(packet->GetOpcode());
if(!opHandle)
{
sLog.outError( "SESSION: received non-existed opcode (0x%.4X)",
packet->GetOpcode());
}
else
{
try
{
switch (opHandle->status)
{
case STATUS_LOGGEDIN:
if(!_player)
{
// skip STATUS_LOGGEDIN opcode unexpected errors if player logout sometime ago - this can be network lag delayed packets
if(!m_playerRecentlyLogout)
LogUnexpectedOpcode(packet, "the player has not logged in yet");
}
else if(_player->IsInWorld())
{
(this->*opHandle->handler)(*packet);
if (sLog.IsOutDebug() && packet->rpos() < packet->wpos())
LogUnprocessedTail(packet);
}
// lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer
break;
case STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT:
if(!_player && !m_playerRecentlyLogout)
{
LogUnexpectedOpcode(packet, "the player has not logged in yet and not recently logout");
}
else
{
// not expected _player or must checked in packet hanlder
(this->*opHandle->handler)(*packet);
if (sLog.IsOutDebug() && packet->rpos() < packet->wpos())
LogUnprocessedTail(packet);
}
break;
case STATUS_TRANSFER:
if(!_player)
LogUnexpectedOpcode(packet, "the player has not logged in yet");
else if(_player->IsInWorld())
LogUnexpectedOpcode(packet, "the player is still in world");
else
{
(this->*opHandle->handler)(*packet);
if (sLog.IsOutDebug() && packet->rpos() < packet->wpos())
LogUnprocessedTail(packet);
}
break;
case STATUS_AUTHED:
// prevent cheating with skip queue wait
if(m_inQueue)
{
LogUnexpectedOpcode(packet, "the player not pass queue yet");
break;
}
// single from authed time opcodes send in to after logout time
// and before other STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT opcodes.
m_playerRecentlyLogout = false;
(this->*opHandle->handler)(*packet);
if (sLog.IsOutDebug() && packet->rpos() < packet->wpos())
LogUnprocessedTail(packet);
break;
case STATUS_NEVER:
sLog.outError( "SESSION: received not allowed opcode %s (0x%.4X)",
opHandle->name,
packet->GetOpcode());
break;
}
}
catch(ByteBufferException &)
{
sLog.outError("WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i. Skipped packet.",
packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
if(sLog.IsOutDebug())
{
sLog.outDebug("Dumping error causing packet:");
packet->hexlike();
}
}
}
//.........这里部分代码省略.........
开发者ID:Sphere-xx,项目名称:mangoszero,代码行数:101,代码来源:WorldSession.cpp
示例8: while
/// %Log the player out
void WorldSession::LogoutPlayer(bool Save)
{
// finish pending transfers before starting the logout
while(_player && _player->IsBeingTeleportedFar())
HandleMoveWorldportAckOpcode();
m_playerLogout = true;
m_playerSave = Save;
if (_player)
{
// Playerbot mod: log out all player bots owned by this toon
if (GetPlayer()->GetPlayerbotMgr())
GetPlayer()->GetPlayerbotMgr()->LogoutAllBots();
sLog.outChar("Account: %d (IP: %s) Logout Character:[%s] (guid: %u)", GetAccountId(), GetRemoteAddress().c_str(), _player->GetName() ,_player->GetGUIDLow());
if (ObjectGuid lootGuid = GetPlayer()->GetLootGuid())
DoLootRelease(lootGuid);
///- If the player just died before logging out, make him appear as a ghost
//FIXME: logout must be delayed in case lost connection with client in time of combat
if (GetPlayer()->GetDeathTimer())
{
GetPlayer()->getHostileRefManager().deleteReferences();
GetPlayer()->BuildPlayerRepop();
GetPlayer()->RepopAtGraveyard();
}
else if (GetPlayer()->IsInCombat() && GetPlayer()->GetMap())
{
GetPlayer()->CombatStop();
GetPlayer()->getHostileRefManager().setOnlineOfflineState(false);
GetPlayer()->RemoveAllAurasOnDeath();
// build set of player who attack _player or who have pet attacking of _player
std::set<Player*> aset;
GuidSet& attackers = GetPlayer()->GetMap()->GetAttackersFor(GetPlayer()->GetObjectGuid());
for (GuidSet::const_iterator itr = attackers.begin(); itr != attackers.end();)
{
Unit* attacker = GetPlayer()->GetMap()->GetUnit(*itr++);
if (!attacker)
continue;
Unit* owner = attacker->GetOwner(); // including player controlled case
if(owner)
{
if(owner->GetTypeId() == TYPEID_PLAYER)
aset.insert((Player*)owner);
}
else if(attacker->GetTypeId() == TYPEID_PLAYER)
aset.insert((Player*)(attacker));
}
GetPlayer()->SetPvPDeath(!aset.empty());
GetPlayer()->KillPlayer();
GetPlayer()->BuildPlayerRepop();
GetPlayer()->RepopAtGraveyard();
// give honor to all attackers from set like group case
for(std::set<Player*>::const_iterator itr = aset.begin(); itr != aset.end(); ++itr)
(*itr)->RewardHonor(GetPlayer(),aset.size());
// give bg rewards and update counters like kill by first from attackers
// this can't be called for all attackers.
if(!aset.empty())
if(BattleGround *bg = GetPlayer()->GetBattleGround())
bg->HandleKillPlayer(GetPlayer(),*aset.begin());
}
else if(GetPlayer()->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
{
// this will kill character by SPELL_AURA_SPIRIT_OF_REDEMPTION
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_MOD_SHAPESHIFT);
//GetPlayer()->SetDeathPvP(*); set at SPELL_AURA_SPIRIT_OF_REDEMPTION apply time
GetPlayer()->KillPlayer();
GetPlayer()->BuildPlayerRepop();
GetPlayer()->RepopAtGraveyard();
}
else if (GetPlayer()->HasPendingBind())
{
GetPlayer()->RepopAtGraveyard();
GetPlayer()->SetPendingBind(NULL, 0);
}
//drop a flag if player is carrying it
if(BattleGround *bg = GetPlayer()->GetBattleGround())
bg->EventPlayerLoggedOut(GetPlayer());
///- Teleport to home if the player is in an invalid instance
if(!GetPlayer()->m_InstanceValid && !GetPlayer()->isGameMaster())
{
GetPlayer()->TeleportToHomebind();
//this is a bad place to call for far teleport because we need player to be in world for successful logout
//maybe we should implement delayed far teleport logout?
}
// FG: finish pending transfers after starting the logout
// this should fix players beeing able to logout and login back with full hp at death position
while(GetPlayer()->IsBeingTeleportedFar())
//.........这里部分代码省略.........
开发者ID:StarCore,项目名称:mangos3,代码行数:101,代码来源:WorldSession.cpp
示例9: while
/// Update the WorldSession (triggered by World update)
bool WorldSession::Update(uint32 /*diff*/)
{
///- Retrieve packets from the receive queue and call the appropriate handlers
/// not proccess packets if socket already closed
WorldPacket* packet;
while (m_Socket && !m_Socket->IsClosed() && _recvQueue.next(packet))
{
/*#if 1
sLog.outError( "MOEP: %s (0x%.4X)",
LookupOpcodeName(packet->GetOpcode()),
packet->GetOpcode());
#endif*/
OpcodeHandler const* opHandle = opCodes.LookupOpcode(packet->GetOpcode());
if (!opHandle)
opHandle = opCodes.LookupOpcode(MSG_NULL_ACTION);
try
{
switch (opHandle->status)
{
case STATUS_LOGGEDIN:
if(!_player)
{
// skip STATUS_LOGGEDIN opcode unexpected errors if player logout sometime ago - this can be network lag delayed packets
if(!m_playerRecentlyLogout)
LogUnexpectedOpcode(packet, "the player has not logged in yet");
}
else if(_player->IsInWorld())
ExecuteOpcode(*opHandle, packet);
// lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer
break;
case STATUS_LOGGEDIN_OR_RECENTLY_LOGGEDOUT:
if(!_player && !m_playerRecentlyLogout)
{
LogUnexpectedOpcode(packet, "the player has not logged in yet and not recently logout");
}
else
// not expected _player or must checked in packet hanlder
ExecuteOpcode(*opHandle, packet);
break;
case STATUS_TRANSFER:
if(!_player)
LogUnexpectedOpcode(packet, "the player has not logged in yet");
else if(_player->IsInWorld())
LogUnexpectedOpcode(packet, "the player is still in world");
else
ExecuteOpcode(*opHandle, packet);
break;
case STATUS_AUTHED:
// prevent cheating with skip queue wait
if(m_inQueue)
{
LogUnexpectedOpcode(packet, "the player not pass queue yet");
break;
}
// single from authed time opcodes send in to after logout time
// and before other STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT opcodes.
m_playerRecentlyLogout = false;
ExecuteOpcode(*opHandle, packet);
break;
case STATUS_NEVER:
sLog.outError( "SESSION: received not allowed opcode %s (0x%.4X)",
opHandle->name,
packet->GetOpcode());
break;
case STATUS_UNHANDLED:
DEBUG_LOG("SESSION: received not handled opcode %s (0x%.4X)",
opHandle->name,
packet->GetOpcode());
break;
default:
sLog.outError("SESSION: received wrong-status-req opcode %s (0x%.4X)",
opHandle->name,
packet->GetOpcode());
break;
}
}
catch (ByteBufferException &)
{
sLog.outError("WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i.",
packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
if (sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))
{
DEBUG_LOG("Dumping error causing packet:");
packet->hexlike();
}
if (sWorld.getConfig(CONFIG_BOOL_KICK_PLAYER_ON_BAD_PACKET))
{
DETAIL_LOG("Disconnecting session [account id %u / address %s] for badly formatted packet.",
GetAccountId(), GetRemoteAddress().c_str());
KickPlayer();
}
}
//.........这里部分代码省略.........
开发者ID:z3usleo,项目名称:mangoszero,代码行数:101,代码来源:WorldSession.cpp
示例10: GetAccountId
void WorldSession::LoadGlobalAccountData()
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ACCOUNT_DATA);
stmt->setUInt32(0, GetAccountId());
LoadAccountData(CharacterDatabase.Query(stmt), GLOBAL_CACHE_MASK);
}
开发者ID:Bulbucan,项目名称:TrinityCore,代码行数:6,代码来源:WorldSession.cpp
示例11: while
//.........这里部分代码省略.........
bg->EventPlayerLoggedOut(_player);
///- Teleport to home if the player is in an invalid instance
if (!_player->m_InstanceValid && !_player->isGameMaster())
_player->TeleportTo(_player->m_homebindMapId, _player->m_homebindX, _player->m_homebindY, _player->m_homebindZ, _player->GetOrientation());
sOutdoorPvPMgr->HandlePlayerLeaveZone(_player, _player->GetZoneId());
for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
{
if (BattlegroundQueueTypeId bgQueueTypeId = _player->GetBattlegroundQueueTypeId(i))
{
_player->RemoveBattlegroundQueueId(bgQueueTypeId);
sBattlegroundMgr->m_BattlegroundQueues[ bgQueueTypeId ].RemovePlayer(_player->GetGUID(), true);
}
}
// Repop at GraveYard or other player far teleport will prevent saving player because of not present map
// Teleport player immediately for correct player save
while (_player->IsBeingTeleportedFar())
HandleMoveWorldportAckOpcode();
///- If the player is in a guild, update the guild roster and broadcast a logout message to other guild members
if (Guild* guild = sGuildMgr->GetGuildById(_player->GetGuildId()))
guild->HandleMemberLogout(this);
///- Remove pet
_player->RemovePet(NULL, PET_SAVE_AS_CURRENT, true);
///- empty buyback items and save the player in the database
// some save parts only correctly work in case player present in map/player_lists (pets, etc)
if (Save)
{
uint32 eslot;
for (int j = BUYBACK_SLOT_START; j < BUYBACK_SLOT_END; ++j)
{
eslot = j - BUYBACK_SLOT_START;
_player->SetUInt64Value(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), 0);
_player->SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0);
_player->SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0);
}
_player->SaveToDB();
}
///- Leave all channels before player delete...
_player->CleanupChannels();
///- If the player is in a group (or invited), remove him. If the group if then only 1 person, disband the group.
_player->UninviteFromGroup();
// remove player from the group if he is:
// a) in group; b) not in raid group; c) logging out normally (not being kicked or disconnected)
if (_player->GetGroup() && !_player->GetGroup()->isRaidGroup() && m_Socket)
_player->RemoveFromGroup();
///- Send update to group and reset stored max enchanting level
if (_player->GetGroup())
{
_player->GetGroup()->SendUpdate();
_player->GetGroup()->ResetMaxEnchantingLevel();
}
///- Broadcast a logout message to the player's friends
sSocialMgr->SendFriendStatus(_player, FRIEND_OFFLINE, _player->GetGUIDLow(), true);
sSocialMgr->RemovePlayerSocial (_player->GetGUIDLow ());
// Call script hook before deletion
sScriptMgr->OnPlayerLogout(GetPlayer());
///- Remove the player from the world
// the player may not be in the world when logging out
// e.g if he got disconnected during a transfer to another map
// calls to GetMap in this case may cause crashes
_player->CleanupsBeforeDelete();
sLog->outChar("Account: %d (IP: %s) Logout Character:[%s] (GUID: %u) Level: %d", GetAccountId(), GetRemoteAddress().c_str(), _player->GetName(), _player->GetGUIDLow(), _player->getLevel());
if (Map* _map = _player->FindMap())
_map->RemovePlayerFromMap(_player, true);
SetPlayer(NULL); // deleted in Remove call
///- Send the 'logout complete' packet to the client
WorldPacket data(SMSG_LOGOUT_COMPLETE, 0);
SendPacket(&data);
///- Since each account can only have one online character at any given time, ensure all characters for active account are marked as offline
//No SQL injection as AccountId is uint32
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ACCOUNT_ONLINE);
stmt->setUInt32(0, GetAccountId());
CharacterDatabase.Execute(stmt);
sLog->outDebug(LOG_FILTER_NETWORKIO, "SESSION: Sent SMSG_LOGOUT_COMPLETE Message");
}
m_playerLogout = false;
m_playerSave = false;
m_playerRecentlyLogout = true;
LogoutRequest(0);
}
开发者ID:Bulbucan,项目名称:TrinityCore,代码行数:101,代码来源:WorldSession.cpp
示例12: getMSTime
void Session::HandleCharacterEnum(WorldPacket & pck)
{
struct player_item
{
uint32 displayid;
uint8 invtype;
};
player_item items[20];
uint32 slot;
uint32 i;
ItemPrototype * proto;
uint32 start_time = getMSTime();
// loading characters
QueryResult* result = CharacterDatabase.Query("SELECT guid, level, race, class, gender, bytes, bytes2, name, positionX, positionY, positionZ, mapId, zoneId, banned, restState, deathstate, forced_rename_pending, player_flags, guild_data.guildid FROM characters LEFT JOIN guild_data ON characters.guid = guild_data.playerid WHERE acct=%u ORDER BY guid ASC LIMIT 10", GetAccountId());
QueryResult * res;
CreatureInfo *info = NULL;
uint8 num = 0;
// should be more than enough.. 200 bytes per char..
WorldPacket data((result ? result->GetRowCount() * 200 : 1));
// parse m_characters and build a mighty packet of
// characters to send to the client.
data.SetOpcode(SMSG_CHAR_ENUM);
data << num;
if( result )
{
uint64 guid;
uint8 Class;
uint32 banned;
uint32 bytes2;
Field *fields;
do
{
fields = result->Fetch();
guid = fields[0].GetUInt32();
bytes2 = fields[6].GetUInt32();
Class = fields[3].GetUInt8();
/* build character enum, w0000t :p */
data << fields[0].GetUInt64(); // guid
data << fields[7].GetString(); // name
data << fields[2].GetUInt8(); // race
data << fields[3].GetUInt8(); // class
data << fields[4].GetUInt8(); // gender
data << fields[5].GetUInt32(); // PLAYER_BYTES
data << uint8(bytes2 & 0xFF); // facial hair
data << fields[1].GetUInt8(); // Level
data << fields[12].GetUInt32(); // zoneid
data << fields[11].GetUInt32(); // Mapid
data << fields[10].GetFloat(); // X
data << fields[9].GetFloat(); // Y
data << fields[8].GetFloat(); // Z
data << fields[17].GetUInt32(); // GuildID
banned = fields[13].GetUInt32();
if(banned && (banned<10 || banned > (uint32)UNIXTIME))
data << uint32(0x01A04040);
else
{
if(fields[16].GetUInt32() != 0)
data << uint32(0x00A04342);
else if(fields[15].GetUInt32() != 0)
data << (uint32)8704; // Dead (displaying as Ghost)
else
data << uint32(1); // alive
}
data << uint32(0); //Added in 3.0.2
data << fields[14].GetUInt8(); // Rest State
if(Class == 9 /*WARLOCK*/ || Class == 3 /*HUNTER*/)
{
res = CharacterDatabase.Query("SELECT entry FROM playerpets WHERE ownerguid=%u AND active=1", guid);
if(res)
{
info = CreatureNameStorage.LookupEntry(res->Fetch()[0].GetUInt32());
delete res;
}
}
if(info)
data << uint32(info->Male_DisplayID) << uint32(10) << uint32(info->Family);
else
data << uint32(0) << uint32(0) << uint32(0);
res = CharacterDatabase.Query("SELECT slot, entry FROM playeritems WHERE ownerguid=%u and containerslot=-1 and slot < 19 and slot >= 0", guid);
memset(items, 0, sizeof(player_item) * 20);
if(res)
{
do
{
proto = ItemPrototypeStorage.LookupEntry(res->Fetch()[1].GetUInt32());
if(proto)
//.........这里部分代码省略.........
开发者ID:Bootz,项目名称:arcticdev,代码行数:101,代码来源:CharacterHandler.cpp
示例13: DEBUG_LOG
//.........这里部分代码省略.........
return;
// always return pointer
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);
// client send time in minutes, convert to common used sec time
etime *= MINUTE;
// client understand only 3 auction time
switch (etime)
{
case 1*MIN_AUCTION_TIME:
case 2*MIN_AUCTION_TIME:
case 4*MIN_AUCTION_TIME:
bre
|
请发表评论