本文整理汇总了C++中ObjectGuid::GetString方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectGuid::GetString方法的具体用法?C++ ObjectGuid::GetString怎么用?C++ ObjectGuid::GetString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectGuid
的用法示例。
在下文中一共展示了ObjectGuid::GetString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddMember
bool ArenaTeam::AddMember(ObjectGuid playerGuid)
{
std::string plName;
uint8 plClass;
// arena team is full (can't have more than type * 2 players!)
if (GetMembersSize() >= GetMaxMembersSize())
return false;
Player* pl = sObjectMgr.GetPlayer(playerGuid);
if (pl)
{
if (pl->GetArenaTeamId(GetSlot()))
{
sLog.outError("Arena::AddMember() : player already in this sized team");
return false;
}
plClass = pl->getClass();
plName = pl->GetName();
}
else
{
// 0 1
QueryResult* result = CharacterDatabase.PQuery("SELECT name, class FROM characters WHERE guid='%u'", playerGuid.GetCounter());
if (!result)
return false;
plName = (*result)[0].GetCppString();
plClass = (*result)[1].GetUInt8();
delete result;
// check if player already in arenateam of that size
if (Player::GetArenaTeamIdFromDB(playerGuid, GetType()) != 0)
{
sLog.outError("Arena::AddMember() : player %s already in this sized team", playerGuid.GetString().c_str());
return false;
}
}
// remove all player signs from another petitions
// this will be prevent attempt joining player to many arenateams and corrupt arena team data integrity
Player::RemovePetitionsAndSigns(playerGuid, GetType());
ArenaTeamMember newmember;
newmember.name = plName;
newmember.guid = playerGuid;
newmember.Class = plClass;
newmember.games_season = 0;
newmember.games_week = 0;
newmember.wins_season = 0;
newmember.wins_week = 0;
int32 conf_value = sWorld.getConfig(CONFIG_INT32_ARENA_STARTPERSONALRATING);
if (conf_value < 0) // -1 = select by season id
{
if (sWorld.getConfig(CONFIG_UINT32_ARENA_SEASON_ID) >= 6)
{
if (m_stats.rating < 1000)
newmember.personal_rating = 0;
else
newmember.personal_rating = 1000;
}
else
{
newmember.personal_rating = 1500;
}
}
else
newmember.personal_rating = uint32(conf_value);
m_members.push_back(newmember);
CharacterDatabase.PExecute("INSERT INTO arena_team_member (arenateamid, guid, personal_rating) VALUES ('%u', '%u', '%u')", m_TeamId, newmember.guid.GetCounter(), newmember.personal_rating);
if (pl)
{
pl->SetInArenaTeam(m_TeamId, GetSlot(), GetType());
pl->SetArenaTeamIdInvited(0);
pl->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_PERSONAL_RATING, newmember.personal_rating);
// hide promote/remove buttons
if (m_CaptainGuid != playerGuid)
pl->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 1);
}
return true;
}
示例2: HandleQuestgiverStatusQueryOpcode
void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket & recv_data)
{
ObjectGuid guid;
recv_data >> guid;
uint8 dialogStatus = DIALOG_STATUS_NONE;
Object* questgiver = _player->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_OR_GAMEOBJECT);
if (!questgiver)
{
DETAIL_LOG("Error in CMSG_QUESTGIVER_STATUS_QUERY, called for not found questgiver %s", guid.GetString().c_str());
return;
}
DEBUG_LOG("WORLD: Received CMSG_QUESTGIVER_STATUS_QUERY - for %s to %s", _player->GetGuidStr().c_str(), guid.GetString().c_str());
switch(questgiver->GetTypeId())
{
case TYPEID_UNIT:
{
Creature* cr_questgiver = (Creature*)questgiver;
if (!cr_questgiver->IsHostileTo(_player)) // not show quest status to enemies
{
dialogStatus = sScriptMgr.GetDialogStatus(_player, cr_questgiver);
if (dialogStatus > DIALOG_STATUS_REWARD_REP)
dialogStatus = getDialogStatus(_player, cr_questgiver, DIALOG_STATUS_NONE);
}
break;
}
case TYPEID_GAMEOBJECT:
{
GameObject* go_questgiver = (GameObject*)questgiver;
dialogStatus = sScriptMgr.GetDialogStatus(_player, go_questgiver);
if (dialogStatus > DIALOG_STATUS_REWARD_REP)
dialogStatus = getDialogStatus(_player, go_questgiver, DIALOG_STATUS_NONE);
break;
}
default:
sLog.outError("QuestGiver called for unexpected type %u", questgiver->GetTypeId());
break;
}
//inform client about status of quest
_player->PlayerTalkClass->SendQuestGiverStatus(dialogStatus, guid);
}
示例3: CanInteractWithQuestGiver
bool WorldSession::CanInteractWithQuestGiver(ObjectGuid guid, char const* descr)
{
if (guid.IsCreatureOrVehicle())
{
Creature* pCreature = _player->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_QUESTGIVER);
if (!pCreature)
{
DEBUG_LOG("WORLD: %s - %s cannot interact with %s.", descr, _player->GetGuidStr().c_str(), guid.GetString().c_str());
return false;
}
}
else if (guid.IsGameObject())
{
GameObject* pGo = _player->GetGameObjectIfCanInteractWith(guid, GAMEOBJECT_TYPE_QUESTGIVER);
if (!pGo)
{
DEBUG_LOG("WORLD: %s - %s cannot interact with %s.", descr, _player->GetGuidStr().c_str(), guid.GetString().c_str());
return false;
}
}
else if (!_player->isAlive())
{
DEBUG_LOG("WORLD: %s - %s is dead, requested guid was %s", descr, _player->GetGuidStr().c_str(), guid.GetString().c_str());
return false;
}
return true;
}
示例4: HandleQuestgiverAcceptQuestOpcode
void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
{
ObjectGuid guid;
uint32 quest;
uint32 unk1;
recv_data >> guid >> quest >> unk1;
if (!CanInteractWithQuestGiver(guid, "CMSG_QUESTGIVER_ACCEPT_QUEST"))
return;
DEBUG_LOG("WORLD: Received CMSG_QUESTGIVER_ACCEPT_QUEST - for %s to %s, quest = %u, unk1 = %u", _player->GetGuidStr().c_str(), guid.GetString().c_str(), quest, unk1 );
Object* pObject = _player->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_GAMEOBJECT_PLAYER_OR_ITEM);
// no or incorrect quest giver (player himself is questgiver for SPELL_EFFECT_QUEST_OFFER)
if (!pObject
|| (pObject->GetTypeId() != TYPEID_PLAYER && !pObject->HasQuest(quest))
|| (pObject->GetTypeId() == TYPEID_PLAYER && pObject != _player && !((Player*)pObject)->CanShareQuest(quest))
)
{
_player->PlayerTalkClass->CloseGossip();
_player->ClearDividerGuid();
return;
}
Quest const* qInfo = sObjectMgr.GetQuestTemplate(quest);
if ( qInfo )
{
// prevent cheating
if(!GetPlayer()->CanTakeQuest(qInfo,true) )
{
_player->PlayerTalkClass->CloseGossip();
_player->ClearDividerGuid();
return;
}
if (Player *pPlayer = ObjectAccessor::FindPlayer(_player->GetDividerGuid()))
{
pPlayer->SendPushToPartyResponse(_player, QUEST_PARTY_MSG_ACCEPT_QUEST);
_player->ClearDividerGuid();
}
if( _player->CanAddQuest( qInfo, true ) )
{
_player->AddQuest( qInfo, pObject ); // pObject (if it item) can be destroyed at call
if (qInfo->HasQuestFlag(QUEST_FLAGS_PARTY_ACCEPT))
{
if (Group* pGroup = _player->GetGroup())
{
for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* pPlayer = itr->getSource();
if (!pPlayer || pPlayer == _player) // not self
continue;
if (pPlayer->CanTakeQuest(qInfo, true))
{
pPlayer->SetDividerGuid(_player->GetObjectGuid());
//need confirmation that any gossip window will close
pPlayer->PlayerTalkClass->CloseGossip();
_player->SendQuestConfirmAccept(qInfo, pPlayer);
}
}
}
}
if ( _player->CanCompleteQuest( quest ) )
_player->CompleteQuest( quest );
_player->GetAchievementMgr().StartTimedAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST, quest);
_player->PlayerTalkClass->CloseGossip();
if( qInfo->GetSrcSpell() > 0 )
_player->CastSpell( _player, qInfo->GetSrcSpell(), true);
return;
}
}
_player->PlayerTalkClass->CloseGossip();
}
示例5: HandleQuestgiverChooseRewardOpcode
void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket & recv_data)
{
uint32 quest, reward;
ObjectGuid guid;
recv_data >> guid >> quest >> reward;
if(reward >= QUEST_REWARD_CHOICES_COUNT)
{
sLog.outError("Error in CMSG_QUESTGIVER_CHOOSE_REWARD - %s tried to get invalid reward (%u) (probably packet hacking)", _player->GetGuidStr().c_str(), _player->GetGUIDLow(), reward);
return;
}
if (!CanInteractWithQuestGiver(guid, "CMSG_QUESTGIVER_CHOOSE_REWARD"))
return;
DEBUG_LOG("WORLD: Received CMSG_QUESTGIVER_CHOOSE_REWARD - for %s to %s, quest = %u, reward = %u", _player->GetGuidStr().c_str(), guid.GetString().c_str(), quest, reward);
Object* pObject = _player->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_OR_GAMEOBJECT);
if(!pObject)
return;
if(!pObject->HasInvolvedQuest(quest))
return;
Quest const *pQuest = sObjectMgr.GetQuestTemplate(quest);
if( pQuest )
{
if( _player->CanRewardQuest( pQuest, reward, true ) )
{
_player->RewardQuest( pQuest, reward, pObject );
// Send next quest
if (Quest const* nextquest = _player->GetNextQuest(guid, pQuest))
_player->PlayerTalkClass->SendQuestGiverQuestDetails(nextquest, guid, true);
}
else
_player->PlayerTalkClass->SendQuestGiverOfferReward(pQuest, guid, true);
}
}
示例6: HandlePetitionBuyOpcode
void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recv_data)
{
DEBUG_LOG("Received opcode CMSG_PETITION_BUY");
recv_data.hexlike();
ObjectGuid guidNPC;
uint32 clientIndex; // 1 for guild and arenaslot+1 for arenas in client
std::string name;
recv_data >> guidNPC; // NPC GUID
recv_data.read_skip<uint32>(); // 0
recv_data.read_skip<uint64>(); // 0
recv_data >> name; // name
recv_data.read_skip<uint32>(); // 0
recv_data.read_skip<uint32>(); // 0
recv_data.read_skip<uint32>(); // 0
recv_data.read_skip<uint32>(); // 0
recv_data.read_skip<uint32>(); // 0
recv_data.read_skip<uint32>(); // 0
recv_data.read_skip<uint32>(); // 0
recv_data.read_skip<uint32>(); // 0
recv_data.read_skip<uint32>(); // 0
recv_data.read_skip<uint32>(); // 0
recv_data.read_skip<uint16>(); // 0
recv_data.read_skip<uint8>(); // 0
recv_data >> clientIndex; // index
recv_data.read_skip<uint32>(); // 0
DEBUG_LOG("Petitioner %s tried sell petition: name %s", guidNPC.GetString().c_str(), name.c_str());
// prevent cheating
Creature* pCreature = GetPlayer()->GetNPCIfCanInteractWith(guidNPC, UNIT_NPC_FLAG_PETITIONER);
if (!pCreature)
{
DEBUG_LOG("WORLD: HandlePetitionBuyOpcode - %s not found or you can't interact with him.", guidNPC.GetString().c_str());
return;
}
uint32 charterid;
uint32 cost;
uint32 type;
if (pCreature->isTabardDesigner())
{
// if tabard designer, then trying to buy a guild charter.
// do not let if already in guild.
if (_player->GetGuildId())
return;
charterid = GUILD_CHARTER;
cost = GUILD_CHARTER_COST;
type = 9;
}
else
{
// TODO: find correct opcode
if (_player->getLevel() < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL))
{
SendNotification(LANG_ARENA_ONE_TOOLOW, sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL));
return;
}
switch (clientIndex) // arenaSlot+1 as received from client (1 from 3 case)
{
case 1:
charterid = ARENA_TEAM_CHARTER_2v2;
cost = ARENA_TEAM_CHARTER_2v2_COST;
type = 2; // 2v2
break;
case 2:
charterid = ARENA_TEAM_CHARTER_3v3;
cost = ARENA_TEAM_CHARTER_3v3_COST;
type = 3; // 3v3
break;
case 3:
charterid = ARENA_TEAM_CHARTER_5v5;
cost = ARENA_TEAM_CHARTER_5v5_COST;
type = 5; // 5v5
break;
default:
DEBUG_LOG("unknown selection at buy arena petition: %u", clientIndex);
return;
}
if (_player->GetArenaTeamId(clientIndex - 1)) // arenaSlot+1 as received from client
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ALREADY_IN_ARENA_TEAM);
return;
}
}
if (type == 9)
{
if (sGuildMgr.GetGuildByName(name))
{
SendGuildCommandResult(GUILD_CREATE_S, name, ERR_GUILD_NAME_EXISTS_S);
return;
}
if (sObjectMgr.IsReservedName(name) || !ObjectMgr::IsValidCharterName(name))
{
//.........这里部分代码省略.........
示例7: HandleTurnInPetitionOpcode
void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recv_data)
{
DEBUG_LOG("Received opcode CMSG_TURN_IN_PETITION"); // ok
// recv_data.hexlike();
ObjectGuid petitionGuid;
recv_data >> petitionGuid;
DEBUG_LOG("Petition %s turned in by %s", petitionGuid.GetString().c_str(), _player->GetGuidStr().c_str());
/// Collect petition info data
ObjectGuid ownerGuid;
uint32 type;
std::string name;
// data
QueryResult* result = CharacterDatabase.PQuery("SELECT ownerguid, name, type FROM petition WHERE petitionguid = '%u'", petitionGuid.GetCounter());
if (result)
{
Field* fields = result->Fetch();
ownerGuid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32());
name = fields[1].GetCppString();
type = fields[2].GetUInt32();
delete result;
}
else
{
sLog.outError("CMSG_TURN_IN_PETITION: petition table not have data for guid %u!", petitionGuid.GetCounter());
return;
}
if (type == 9)
{
if (_player->GetGuildId())
{
WorldPacket data(SMSG_TURN_IN_PETITION_RESULTS, 4);
data << uint32(PETITION_TURN_ALREADY_IN_GUILD); // already in guild
_player->GetSession()->SendPacket(&data);
return;
}
}
else
{
if (!IsArenaTypeValid(ArenaType(type)))
return;
uint8 slot = ArenaTeam::GetSlotByType(ArenaType(type));
if (slot >= MAX_ARENA_SLOT)
return;
if (_player->GetArenaTeamId(slot))
{
// data.Initialize(SMSG_TURN_IN_PETITION_RESULTS, 4);
// data << (uint32)PETITION_TURN_ALREADY_IN_GUILD; // already in guild
//_player->GetSession()->SendPacket(&data);
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ALREADY_IN_ARENA_TEAM);
return;
}
}
if (_player->GetObjectGuid() != ownerGuid)
return;
// signs
result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE petitionguid = '%u'", petitionGuid.GetCounter());
uint8 signs = result ? (uint8)result->GetRowCount() : 0;
uint32 count = type == 9 ? sWorld.getConfig(CONFIG_UINT32_MIN_PETITION_SIGNS) : type - 1;
if (signs < count)
{
WorldPacket data(SMSG_TURN_IN_PETITION_RESULTS, 4);
data << uint32(PETITION_TURN_NEED_MORE_SIGNATURES); // need more signatures...
SendPacket(&data);
delete result;
return;
}
if (type == 9)
{
if (sGuildMgr.GetGuildByName(name))
{
SendGuildCommandResult(GUILD_CREATE_S, name, ERR_GUILD_NAME_EXISTS_S);
delete result;
return;
}
}
else
{
if (sObjectMgr.GetArenaTeamByName(name))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
delete result;
return;
}
}
// and at last charter item check
Item* item = _player->GetItemByGuid(petitionGuid);
if (!item)
//.........这里部分代码省略.........
示例8: HandleTrainerBuySpellOpcode
void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data )
{
ObjectGuid guid;
uint32 spellId = 0;
recv_data >> guid >> spellId;
DEBUG_LOG("WORLD: Received CMSG_TRAINER_BUY_SPELL Trainer: %s, learn spell id is: %u", guid.GetString().c_str(), spellId);
Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TRAINER);
if (!unit)
{
DEBUG_LOG("WORLD: HandleTrainerBuySpellOpcode - %s not found or you can't interact with him.", guid.GetString().c_str());
return;
}
// remove fake death
if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
if (!unit->IsTrainerOf(_player, true))
return;
// check present spell in trainer spell list
TrainerSpellData const* cSpells = unit->GetTrainerSpells();
TrainerSpellData const* tSpells = unit->GetTrainerTemplateSpells();
if (!cSpells && !tSpells)
return;
// Try find spell in npc_trainer
TrainerSpell const* trainer_spell = cSpells ? cSpells->Find(spellId) : NULL;
// Not found, try find in npc_trainer_template
if (!trainer_spell && tSpells)
trainer_spell = tSpells->Find(spellId);
// Not found anywhere, cheating?
if (!trainer_spell)
return;
// can't be learn, cheat? Or double learn with lags...
if (_player->GetTrainerSpellState(trainer_spell) != TRAINER_SPELL_GREEN)
return;
// apply reputation discount
uint32 nSpellCost = uint32(floor(trainer_spell->spellCost * _player->GetReputationPriceDiscount(unit)));
// check money requirement
if(_player->GetMoney() < nSpellCost )
return;
_player->ModifyMoney( -int32(nSpellCost) );
WorldPacket data(SMSG_PLAY_SPELL_VISUAL, 12); // visual effect on trainer
data << ObjectGuid(guid);
data << uint32(0xB3); // index from SpellVisualKit.dbc
SendPacket(&data);
data.Initialize(SMSG_PLAY_SPELL_IMPACT, 12); // visual effect on player
data << _player->GetObjectGuid();
data << uint32(0x016A); // index from SpellVisualKit.dbc
SendPacket(&data);
// learn explicitly or cast explicitly
if(trainer_spell->IsCastable())
_player->CastSpell(_player, trainer_spell->spell, true);
else
_player->learnSpell(spellId, false);
data.Initialize(SMSG_TRAINER_BUY_SUCCEEDED, 12);
data << ObjectGuid(guid);
data << uint32(spellId); // should be same as in packet from client
SendPacket(&data);
}
示例9: HandleGossipHelloOpcode
void WorldSession::HandleGossipHelloOpcode(WorldPacket & recv_data)
{
DEBUG_LOG("WORLD: Received CMSG_GOSSIP_HELLO");
ObjectGuid guid;
recv_data >> guid;
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE);
if (!pCreature)
{
DEBUG_LOG("WORLD: HandleGossipHelloOpcode - %s not found or you can't interact with him.", guid.GetString().c_str());
return;
}
// remove fake death
if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
if (!pCreature->IsStopped())
pCreature->StopMoving();
if (pCreature->isSpiritGuide())
pCreature->SendAreaSpiritHealerQueryOpcode(_player);
if (!sScriptMgr.OnGossipHello(_player, pCreature))
{
_player->PrepareGossipMenu(pCreature, pCreature->GetCreatureInfo()->GossipMenuId);
_player->SendPreparedGossip(pCreature);
}
}
示例10: SendQuestGiverRequestItems
void PlayerMenu::SendQuestGiverRequestItems(Quest const* pQuest, ObjectGuid npcGUID, bool Completable, bool CloseOnCancel)
{
// We can always call to RequestItems, but this packet only goes out if there are actually
// items. Otherwise, we'll skip straight to the OfferReward
std::string Title = pQuest->GetTitle();
std::string RequestItemsText = pQuest->GetRequestItemsText();
int loc_idx = GetMenuSession()->GetSessionDbLocaleIndex();
if (loc_idx >= 0)
{
if (QuestLocale const* ql = sObjectMgr.GetQuestLocale(pQuest->GetQuestId()))
{
if (ql->Title.size() > (size_t)loc_idx && !ql->Title[loc_idx].empty())
Title = ql->Title[loc_idx];
if (ql->RequestItemsText.size() > (size_t)loc_idx && !ql->RequestItemsText[loc_idx].empty())
RequestItemsText = ql->RequestItemsText[loc_idx];
}
}
if (!pQuest->GetReqItemsCount() && Completable)
{
SendQuestGiverOfferReward(pQuest, npcGUID, true);
return;
}
WorldPacket data(SMSG_QUESTGIVER_REQUEST_ITEMS, 50); // guess size
data << ObjectGuid(npcGUID);
data << uint32(pQuest->GetQuestId());
data << Title;
data << RequestItemsText;
data << uint32(0x00); // emote delay
if (Completable)
data << pQuest->GetCompleteEmote(); // emote id
else
data << pQuest->GetIncompleteEmote();
// Close Window after cancel
if (CloseOnCancel)
data << uint32(0x01); // auto finish
else
data << uint32(0x00);
data << uint32(pQuest->GetQuestFlags()); // 3.3.3 questFlags
data << uint32(pQuest->GetSuggestedPlayers()); // SuggestedGroupNum
// Required Money
data << uint32(pQuest->GetRewOrReqMoney() < 0 ? -pQuest->GetRewOrReqMoney() : 0);
data << uint32(pQuest->GetReqItemsCount());
ItemPrototype const* pItem;
for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
{
if (!pQuest->ReqItemId[i])
continue;
pItem = ObjectMgr::GetItemPrototype(pQuest->ReqItemId[i]);
data << uint32(pQuest->ReqItemId[i]);
data << uint32(pQuest->ReqItemCount[i]);
if (pItem)
data << uint32(pItem->DisplayInfoID);
else
data << uint32(0);
}
if (!Completable) // Completable = flags1 && flags2 && flags3 && flags4
data << uint32(0x00); // flags1
else
data << uint32(0x03);
data << uint32(0x04); // flags2
data << uint32(0x08); // flags3
data << uint32(0x10); // flags4
GetMenuSession()->SendPacket(&data);
DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid = %s, questid = %u", npcGUID.GetString().c_str(), pQuest->GetQuestId());
}
示例11: SendTrainerList
void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle)
{
DEBUG_LOG( "WORLD: SendTrainerList" );
Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_TRAINER);
if (!unit)
{
DEBUG_LOG("WORLD: SendTrainerList - %s not found or you can't interact with him.", guid.GetString().c_str());
return;
}
// remove fake death
if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
// trainer list loaded at check;
if (!unit->IsTrainerOf(_player,true))
return;
CreatureInfo const *ci = unit->GetCreatureInfo();
if (!ci)
return;
TrainerSpellData const* cSpells = unit->GetTrainerSpells();
TrainerSpellData const* tSpells = unit->GetTrainerTemplateSpells();
if (!cSpells && !tSpells)
{
DEBUG_LOG("WORLD: SendTrainerList - Training spells not found for %s", guid.GetString().c_str());
return;
}
uint32 maxcount = (cSpells ? cSpells->spellList.size() : 0) + (tSpells ? tSpells->spellList.size() : 0);
uint32 trainer_type = cSpells && cSpells->trainerType ? cSpells->trainerType : (tSpells ? tSpells->trainerType : 0);
WorldPacket data( SMSG_TRAINER_LIST, 8+4+4+maxcount*38 + strTitle.size()+1);
data << ObjectGuid(guid);
data << uint32(trainer_type);
size_t count_pos = data.wpos();
data << uint32(maxcount);
// reputation discount
float fDiscountMod = _player->GetReputationPriceDiscount(unit);
bool can_learn_primary_prof = GetPlayer()->GetFreePrimaryProfessionPoints() > 0;
uint32 count = 0;
if (cSpells)
{
for(TrainerSpellMap::const_iterator itr = cSpells->spellList.begin(); itr != cSpells->spellList.end(); ++itr)
{
TrainerSpell const* tSpell = &itr->second;
if(!_player->IsSpellFitByClassAndRace(tSpell->learnedSpell))
continue;
TrainerSpellState state = _player->GetTrainerSpellState(tSpell);
SendTrainerSpellHelper(data, tSpell, state, fDiscountMod, can_learn_primary_prof);
++count;
}
}
if (tSpells)
{
for(TrainerSpellMap::const_iterator itr = tSpells->spellList.begin(); itr != tSpells->spellList.end(); ++itr)
{
TrainerSpell const* tSpell = &itr->second;
if(!_player->IsSpellFitByClassAndRace(tSpell->learnedSpell))
continue;
TrainerSpellState state = _player->GetTrainerSpellState(tSpell);
SendTrainerSpellHelper(data, tSpell, state, fDiscountMod, can_learn_primary_prof);
++count;
}
}
data << strTitle;
data.put<uint32>(count_pos,count);
SendPacket(&data);
}
示例12: SendQuestGiverOfferReward
//.........这里部分代码省略.........
if (loc_idx >= 0)
{
if (QuestLocale const* ql = sObjectMgr.GetQuestLocale(pQuest->GetQuestId()))
{
if (ql->Title.size() > (size_t)loc_idx && !ql->Title[loc_idx].empty())
Title = ql->Title[loc_idx];
if (ql->OfferRewardText.size() > (size_t)loc_idx && !ql->OfferRewardText[loc_idx].empty())
OfferRewardText = ql->OfferRewardText[loc_idx];
}
}
WorldPacket data(SMSG_QUESTGIVER_OFFER_REWARD, 50); // guess size
data << ObjectGuid(npcGUID);
data << uint32(pQuest->GetQuestId());
data << Title;
data << OfferRewardText;
data << uint8(EnableNext ? 1 : 0); // Auto Finish
data << uint32(pQuest->GetQuestFlags()); // 3.3.3 questFlags
data << uint32(pQuest->GetSuggestedPlayers()); // SuggestedGroupNum
uint32 EmoteCount = 0;
for (uint32 i = 0; i < QUEST_EMOTE_COUNT; ++i)
{
if (pQuest->OfferRewardEmote[i] <= 0)
break;
++EmoteCount;
}
data << EmoteCount; // Emote Count
for (uint32 i = 0; i < EmoteCount; ++i)
{
data << uint32(pQuest->OfferRewardEmoteDelay[i]); // Delay Emote
data << uint32(pQuest->OfferRewardEmote[i]);
}
ItemPrototype const* pItem;
data << uint32(pQuest->GetRewChoiceItemsCount());
for (uint32 i = 0; i < pQuest->GetRewChoiceItemsCount(); ++i)
{
pItem = ObjectMgr::GetItemPrototype(pQuest->RewChoiceItemId[i]);
data << uint32(pQuest->RewChoiceItemId[i]);
data << uint32(pQuest->RewChoiceItemCount[i]);
if (pItem)
data << uint32(pItem->DisplayInfoID);
else
data << uint32(0);
}
data << uint32(pQuest->GetRewItemsCount());
for (uint32 i = 0; i < pQuest->GetRewItemsCount(); ++i)
{
pItem = ObjectMgr::GetItemPrototype(pQuest->RewItemId[i]);
data << uint32(pQuest->RewItemId[i]);
data << uint32(pQuest->RewItemCount[i]);
if (pItem)
data << uint32(pItem->DisplayInfoID);
else
data << uint32(0);
}
// send rewMoneyMaxLevel explicit for max player level, else send RewOrReqMoney
if (GetMenuSession()->GetPlayer()->getLevel() >= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL))
data << uint32(pQuest->GetRewMoneyMaxLevel());
else
data << uint32(pQuest->GetRewOrReqMoney());
// xp
data << uint32(pQuest->XPValue(GetMenuSession()->GetPlayer()));
// TODO: fixme. rewarded honor points. Multiply with 10 to satisfy client
data << uint32(10 * MaNGOS::Honor::hk_honor_at_level(GetMenuSession()->GetPlayer()->getLevel(), pQuest->GetRewHonorAddition()));
data << float(pQuest->GetRewHonorMultiplier());
data << uint32(0x08); // unused by client?
data << uint32(pQuest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0)
data << uint32(pQuest->GetRewSpellCast()); // casted spell
data << uint32(pQuest->GetCharTitleId()); // character title
data << uint32(pQuest->GetBonusTalents()); // bonus talents
data << uint32(0); // bonus arena points
data << uint32(0); // rew rep show mask?
for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids
data << uint32(pQuest->RewRepFaction[i]);
for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid in QuestFactionReward.dbc (if negative, from second row)
data << int32(pQuest->RewRepValueId[i]);
for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward reputation override. No diplomacy bonus is expected given, reward also does not display in chat window
data << int32(0);
// data << int32(pQuest->RewRepValue[i]);
GetMenuSession()->SendPacket(&data);
DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid = %s, questid = %u", npcGUID.GetString().c_str(), pQuest->GetQuestId());
}
示例13: SendQuestGiverQuestDetails
//.........这里部分代码省略.........
data << guid;
data << uint64(0); // wotlk, something todo with quest sharing?
data << uint32(pQuest->GetQuestId());
data << Title;
data << Details;
data << Objectives;
data << uint8(ActivateAccept ? 1 : 0); // auto finish
data << uint32(pQuest->GetQuestFlags()); // 3.3.3 questFlags
data << uint32(pQuest->GetSuggestedPlayers());
data << uint8(0); // IsFinished? value is sent back to server in quest accept packet
if (pQuest->HasQuestFlag(QUEST_FLAGS_HIDDEN_REWARDS))
{
data << uint32(0); // Rewarded chosen items hidden
data << uint32(0); // Rewarded items hidden
data << uint32(0); // Rewarded money hidden
data << uint32(0); // Rewarded XP hidden
}
else
{
ItemPrototype const* IProto;
data << uint32(pQuest->GetRewChoiceItemsCount());
for (uint32 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
{
if (!pQuest->RewChoiceItemId[i])
continue;
data << uint32(pQuest->RewChoiceItemId[i]);
data << uint32(pQuest->RewChoiceItemCount[i]);
IProto = ObjectMgr::GetItemPrototype(pQuest->RewChoiceItemId[i]);
if (IProto)
data << uint32(IProto->DisplayInfoID);
else
data << uint32(0x00);
}
data << uint32(pQuest->GetRewItemsCount());
for (uint32 i = 0; i < QUEST_REWARDS_COUNT; ++i)
{
if (!pQuest->RewItemId[i])
continue;
data << uint32(pQuest->RewItemId[i]);
data << uint32(pQuest->RewItemCount[i]);
IProto = ObjectMgr::GetItemPrototype(pQuest->RewItemId[i]);
if (IProto)
data << uint32(IProto->DisplayInfoID);
else
data << uint32(0);
}
// send rewMoneyMaxLevel explicit for max player level, else send RewOrReqMoney
if (GetMenuSession()->GetPlayer()->getLevel() >= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL))
data << uint32(pQuest->GetRewMoneyMaxLevel());
else
data << uint32(pQuest->GetRewOrReqMoney());
data << uint32(pQuest->XPValue(GetMenuSession()->GetPlayer()));
}
// TODO: fixme. rewarded honor points
data << uint32(pQuest->GetRewHonorAddition());
data << float(pQuest->GetRewHonorMultiplier()); // new 3.3.0
data << uint32(pQuest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0)
data << uint32(pQuest->GetRewSpellCast()); // casted spell
data << uint32(pQuest->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
data << uint32(pQuest->GetBonusTalents()); // bonus talents
data << uint32(0); // bonus arena points
data << uint32(0); // rep reward show mask?
for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids
data << uint32(pQuest->RewRepFaction[i]);
for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid in QuestFactionReward.dbc (if negative, from second row)
data << int32(pQuest->RewRepValueId[i]);
for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward reputation override. No bonus is expected given
data << int32(0);
// data << int32(pQuest->RewRepValue[i]); // current field for store of rep value, can be reused to implement "override value"
data << uint32(QUEST_EMOTE_COUNT);
for (uint32 i = 0; i < QUEST_EMOTE_COUNT; ++i)
{
data << uint32(pQuest->DetailsEmote[i]);
data << uint32(pQuest->DetailsEmoteDelay[i]); // DetailsEmoteDelay (in ms)
}
GetMenuSession()->SendPacket(&data);
DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS - for %s of %s, questid = %u", GetMenuSession()->GetPlayer()->GetGuidStr().c_str(), guid.GetString().c_str(), pQuest->GetQuestId());
}
示例14: HandleAuctionSellItem
// this void creates new auction and adds auction to some auctionhouse
void WorldSession::HandleAuctionSellItem(WorldPacket& recv_data)
{
DEBUG_LOG("WORLD: HandleAuctionSellItem");
ObjectGuid auctioneerGuid;
ObjectGuid itemGuid;
uint32 etime, bid, buyout;
recv_data >> auctioneerGuid;
recv_data >> itemGuid;
recv_data >> bid;
recv_data >> buyout;
recv_data >> etime;
if (!bid || !etime)
return; // check for cheaters
Player* pl = GetPlayer();
AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid);
if (!auctionHouseEntry)
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:
break;
default:
return;
}
// remove fake death
if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
if (!itemGuid)
return;
Item* it = pl->GetItemByGuid(itemGuid);
// do not allow to sell already auctioned items
if (sAuctionMgr.GetAItem(itemGuid.GetCounter()))
{
sLog.outError("AuctionError, %s is sending %s, but item is already in another auction", pl->GetGuidStr().c_str(), itemGuid.GetString().c_str());
SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_INVENTORY, EQUIP_ERR_ITEM_NOT_FOUND);
return;
}
// prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to auction)
if (!it)
{
SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_INVENTORY, EQUIP_ERR_ITEM_NOT_FOUND);
return;
}
if (!it->CanBeTraded())
{
SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_INVENTORY, EQUIP_ERR_CANNOT_TRADE_THAT);
return;
}
if ((it->GetProto()->Flags & ITEM_FLAG_CONJURED) || it->GetUInt32Value(ITEM_FIELD_DURATION))
{
SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_INVENTORY, EQUIP_ERR_CANNOT_TRADE_THAT);
return;
}
// check money for deposit
uint32 deposit = AuctionHouseMgr::GetAuctionDeposit(auctionHouseEntry, etime, it);
if (pl->GetMoney() < deposit)
{
SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_NOT_ENOUGH_MONEY);
return;
}
if (GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_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));
AuctionEntry* AH = auctionHouse->AddAuction(auctionHouseEntry, it, etime, bid, buyout, deposit, pl);
DETAIL_LOG("selling %s to auctioneer %s with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u",
itemGuid.GetString().c_str(), auctioneerGuid.GetString().c_str(), bid, buyout, etime, auctionHouseEntry->houseId);
SendAuctionCommandResult(AH, AUCTION_STARTED, AUCTION_OK);
//.........这里部分代码省略.........
示例15: HandlePetitionRenameOpcode
void WorldSession::HandlePetitionRenameOpcode(WorldPacket& recv_data)
{
DEBUG_LOG("Received opcode MSG_PETITION_RENAME"); // ok
// recv_data.hexlike();
ObjectGuid petitionGuid;
uint32 type;
std::string newname;
recv_data >> petitionGuid; // guid
recv_data >> newname; // new name
Item* item = _player->GetItemByGuid(petitionGuid);
if (!item)
return;
QueryResult* result = CharacterDatabase.PQuery("SELECT type FROM petition WHERE petitionguid = '%u'", petitionGuid.GetCounter());
if (result)
{
Field* fields = result->Fetch();
type = fields[0].GetUInt32();
delete result;
}
else
{
DEBUG_LOG("CMSG_PETITION_QUERY failed for petition: %s", petitionGuid.GetString().c_str());
return;
}
if (type == 9)
{
if (sGuildMgr.GetGuildByName(newname))
{
SendGuildCommandResult(GUILD_CREATE_S, newname, ERR_GUILD_NAME_EXISTS_S);
return;
}
if (sObjectMgr.IsReservedName(newname) || !ObjectMgr::IsValidCharterName(newname))
{
SendGuildCommandResult(GUILD_CREATE_S, newname, ERR_GUILD_NAME_INVALID);
return;
}
}
else
{
if (sObjectMgr.GetArenaTeamByName(newname))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, newname, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
return;
}
if (sObjectMgr.IsReservedName(newname) || !ObjectMgr::IsValidCharterName(newname))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, newname, "", ERR_ARENA_TEAM_NAME_INVALID);
return;
}
}
std::string db_newname = newname;
CharacterDatabase.escape_string(db_newname);
CharacterDatabase.PExecute("UPDATE petition SET name = '%s' WHERE petitionguid = '%u'",
db_newname.c_str(), petitionGuid.GetCounter());
DEBUG_LOG("Petition %s renamed to '%s'", petitionGuid.GetString().c_str(), newname.c_str());
WorldPacket data(MSG_PETITION_RENAME, (8 + newname.size() + 1));
data << ObjectGuid(petitionGuid);
data << newname;
SendPacket(&data);
}