Various Cleanups (game Q-R)

This commit is contained in:
Schmoozerd 2012-07-19 21:51:54 +02:00
parent 98e1efd435
commit 865f7d7428
10 changed files with 246 additions and 246 deletions

View file

@ -30,7 +30,7 @@
#include "ScriptMgr.h"
#include "Group.h"
void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket & recv_data)
void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket& recv_data)
{
ObjectGuid guid;
recv_data >> guid;
@ -46,7 +46,7 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket & recv_data)
DEBUG_LOG("WORLD: Received CMSG_QUESTGIVER_STATUS_QUERY - for %s to %s", _player->GetGuidStr().c_str(), guid.GetString().c_str());
switch(questgiver->GetTypeId())
switch (questgiver->GetTypeId())
{
case TYPEID_UNIT:
{
@ -80,7 +80,7 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket & recv_data)
_player->PlayerTalkClass->SendQuestGiverStatus(dialogStatus, guid);
}
void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket & recv_data)
void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket& recv_data)
{
ObjectGuid guid;
recv_data >> guid;
@ -90,7 +90,7 @@ void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket & recv_data)
Creature* pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE);
if (!pCreature)
{
DEBUG_LOG ("WORLD: HandleQuestgiverHelloOpcode - for %s to %s not found or you can't interact with him.", _player->GetGuidStr().c_str(), guid.GetString().c_str());
DEBUG_LOG("WORLD: HandleQuestgiverHelloOpcode - for %s to %s not found or you can't interact with him.", _player->GetGuidStr().c_str(), guid.GetString().c_str());
return;
}
@ -109,7 +109,7 @@ void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket & recv_data)
_player->SendPreparedGossip(pCreature);
}
void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket& recv_data)
{
ObjectGuid guid;
uint32 quest;
@ -119,15 +119,15 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
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 );
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))
)
|| (pObject->GetTypeId() != TYPEID_PLAYER && !pObject->HasQuest(quest))
|| (pObject->GetTypeId() == TYPEID_PLAYER && pObject != _player && !((Player*)pObject)->CanShareQuest(quest))
)
{
_player->PlayerTalkClass->CloseGossip();
_player->ClearDividerGuid();
@ -135,31 +135,31 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
}
Quest const* qInfo = sObjectMgr.GetQuestTemplate(quest);
if ( qInfo )
if (qInfo)
{
// prevent cheating
if(!GetPlayer()->CanTakeQuest(qInfo,true) )
if (!GetPlayer()->CanTakeQuest(qInfo,true))
{
_player->PlayerTalkClass->CloseGossip();
_player->ClearDividerGuid();
return;
}
if (Player *pPlayer = ObjectAccessor::FindPlayer(_player->GetDividerGuid()))
if (Player* pPlayer = ObjectAccessor::FindPlayer(_player->GetDividerGuid()))
{
pPlayer->SendPushToPartyResponse(_player, QUEST_PARTY_MSG_ACCEPT_QUEST);
_player->ClearDividerGuid();
}
if( _player->CanAddQuest( qInfo, true ) )
if (_player->CanAddQuest(qInfo, true))
{
_player->AddQuest( qInfo, pObject ); // pObject (if it item) can be destroyed at call
_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())
for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* pPlayer = itr->getSource();
@ -179,15 +179,15 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
}
}
if ( _player->CanCompleteQuest( quest ) )
_player->CompleteQuest( quest );
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);
if (qInfo->GetSrcSpell() > 0)
_player->CastSpell(_player, qInfo->GetSrcSpell(), true);
return;
}
@ -196,7 +196,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
_player->PlayerTalkClass->CloseGossip();
}
void WorldSession::HandleQuestgiverQueryQuestOpcode( WorldPacket & recv_data )
void WorldSession::HandleQuestgiverQueryQuestOpcode(WorldPacket& recv_data)
{
ObjectGuid guid;
uint32 quest;
@ -217,26 +217,26 @@ void WorldSession::HandleQuestgiverQueryQuestOpcode( WorldPacket & recv_data )
_player->PlayerTalkClass->SendQuestGiverQuestDetails(pQuest, pObject->GetObjectGuid(), true);
}
void WorldSession::HandleQuestQueryOpcode( WorldPacket & recv_data )
void WorldSession::HandleQuestQueryOpcode(WorldPacket& recv_data)
{
uint32 quest;
recv_data >> quest;
DEBUG_LOG( "WORLD: Received CMSG_QUEST_QUERY quest = %u",quest );
DEBUG_LOG("WORLD: Received CMSG_QUEST_QUERY quest = %u",quest);
Quest const *pQuest = sObjectMgr.GetQuestTemplate(quest);
if ( pQuest )
Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest);
if (pQuest)
{
_player->PlayerTalkClass->SendQuestQueryResponse( pQuest );
_player->PlayerTalkClass->SendQuestQueryResponse(pQuest);
}
}
void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket & recv_data)
void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket& recv_data)
{
uint32 quest, reward;
ObjectGuid guid;
recv_data >> guid >> quest >> reward;
if(reward >= QUEST_REWARD_CHOICES_COUNT)
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;
@ -248,18 +248,18 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket & recv_data)
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)
if (!pObject)
return;
if(!pObject->HasInvolvedQuest(quest))
if (!pObject->HasInvolvedQuest(quest))
return;
Quest const *pQuest = sObjectMgr.GetQuestTemplate(quest);
if( pQuest )
Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest);
if (pQuest)
{
if( _player->CanRewardQuest( pQuest, reward, true ) )
if (_player->CanRewardQuest(pQuest, reward, true))
{
_player->RewardQuest( pQuest, reward, pObject );
_player->RewardQuest(pQuest, reward, pObject);
// Send next quest
if (Quest const* nextquest = _player->GetNextQuest(guid, pQuest))
@ -270,7 +270,7 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket & recv_data)
}
}
void WorldSession::HandleQuestgiverRequestRewardOpcode( WorldPacket & recv_data )
void WorldSession::HandleQuestgiverRequestRewardOpcode(WorldPacket& recv_data)
{
uint32 quest;
ObjectGuid guid;
@ -291,26 +291,26 @@ void WorldSession::HandleQuestgiverRequestRewardOpcode( WorldPacket & recv_data
if (_player->GetQuestStatus(quest) != QUEST_STATUS_COMPLETE)
return;
if (Quest const *pQuest = sObjectMgr.GetQuestTemplate(quest))
if (Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest))
_player->PlayerTalkClass->SendQuestGiverOfferReward(pQuest, guid, true);
}
void WorldSession::HandleQuestgiverCancel(WorldPacket& /*recv_data*/ )
void WorldSession::HandleQuestgiverCancel(WorldPacket& /*recv_data*/)
{
DEBUG_LOG( "WORLD: Received CMSG_QUESTGIVER_CANCEL" );
DEBUG_LOG("WORLD: Received CMSG_QUESTGIVER_CANCEL");
_player->PlayerTalkClass->CloseGossip();
}
void WorldSession::HandleQuestLogSwapQuest(WorldPacket& recv_data )
void WorldSession::HandleQuestLogSwapQuest(WorldPacket& recv_data)
{
uint8 slot1, slot2;
recv_data >> slot1 >> slot2;
if(slot1 == slot2 || slot1 >= MAX_QUEST_LOG_SIZE || slot2 >= MAX_QUEST_LOG_SIZE)
if (slot1 == slot2 || slot1 >= MAX_QUEST_LOG_SIZE || slot2 >= MAX_QUEST_LOG_SIZE)
return;
DEBUG_LOG( "WORLD: Received CMSG_QUESTLOG_SWAP_QUEST slot 1 = %u, slot 2 = %u", slot1, slot2 );
DEBUG_LOG("WORLD: Received CMSG_QUESTLOG_SWAP_QUEST slot 1 = %u, slot 2 = %u", slot1, slot2);
GetPlayer()->SwapQuestSlot(slot1,slot2);
}
@ -422,7 +422,7 @@ void WorldSession::HandleQuestgiverCompleteQuest(WorldPacket& recv_data)
void WorldSession::HandleQuestgiverQuestAutoLaunch(WorldPacket& /*recvPacket*/)
{
DEBUG_LOG( "WORLD: Received CMSG_QUESTGIVER_QUEST_AUTOLAUNCH" );
DEBUG_LOG("WORLD: Received CMSG_QUESTGIVER_QUEST_AUTOLAUNCH");
}
void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket)
@ -432,13 +432,13 @@ void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket)
DEBUG_LOG("WORLD: Received CMSG_PUSHQUESTTOPARTY quest = %u", questId);
if (Quest const *pQuest = sObjectMgr.GetQuestTemplate(questId))
if (Quest const* pQuest = sObjectMgr.GetQuestTemplate(questId))
{
if (Group* pGroup = _player->GetGroup())
{
for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player *pPlayer = itr->getSource();
Player* pPlayer = itr->getSource();
if (!pPlayer || pPlayer == _player) // skip self
continue;
@ -490,9 +490,9 @@ void WorldSession::HandleQuestPushResult(WorldPacket& recvPacket)
DEBUG_LOG("WORLD: Received MSG_QUEST_PUSH_RESULT");
if (Player *pPlayer = ObjectAccessor::FindPlayer(_player->GetDividerGuid()))
if (Player* pPlayer = ObjectAccessor::FindPlayer(_player->GetDividerGuid()))
{
WorldPacket data( MSG_QUEST_PUSH_RESULT, (8+1) );
WorldPacket data(MSG_QUEST_PUSH_RESULT, (8+1));
data << ObjectGuid(guid);
data << uint8(msg); // valid values: 0-8
pPlayer->GetSession()->SendPacket(&data);
@ -500,14 +500,14 @@ void WorldSession::HandleQuestPushResult(WorldPacket& recvPacket)
}
}
uint32 WorldSession::getDialogStatus(Player *pPlayer, Object* questgiver, uint32 defstatus)
uint32 WorldSession::getDialogStatus(Player* pPlayer, Object* questgiver, uint32 defstatus)
{
uint32 dialogStatus = defstatus;
QuestRelationsMapBounds rbounds;
QuestRelationsMapBounds irbounds;
switch(questgiver->GetTypeId())
switch (questgiver->GetTypeId())
{
case TYPEID_UNIT:
{
@ -527,11 +527,11 @@ uint32 WorldSession::getDialogStatus(Player *pPlayer, Object* questgiver, uint32
return DIALOG_STATUS_NONE;
}
for(QuestRelationsMap::const_iterator itr = irbounds.first; itr != irbounds.second; ++itr)
for (QuestRelationsMap::const_iterator itr = irbounds.first; itr != irbounds.second; ++itr)
{
uint32 dialogStatusNew = 0;
uint32 quest_id = itr->second;
Quest const *pQuest = sObjectMgr.GetQuestTemplate(quest_id);
Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest_id);
if (!pQuest || !pQuest->IsActive())
continue;
@ -539,7 +539,7 @@ uint32 WorldSession::getDialogStatus(Player *pPlayer, Object* questgiver, uint32
QuestStatus status = pPlayer->GetQuestStatus(quest_id);
if ((status == QUEST_STATUS_COMPLETE && !pPlayer->GetQuestRewardStatus(quest_id)) ||
(pQuest->IsAutoComplete() && pPlayer->CanTakeQuest(pQuest, false)))
(pQuest->IsAutoComplete() && pPlayer->CanTakeQuest(pQuest, false)))
{
if (pQuest->IsAutoComplete() && pQuest->IsRepeatable())
dialogStatusNew = DIALOG_STATUS_REWARD_REP;
@ -553,11 +553,11 @@ uint32 WorldSession::getDialogStatus(Player *pPlayer, Object* questgiver, uint32
dialogStatus = dialogStatusNew;
}
for(QuestRelationsMap::const_iterator itr = rbounds.first; itr != rbounds.second; ++itr)
for (QuestRelationsMap::const_iterator itr = rbounds.first; itr != rbounds.second; ++itr)
{
uint32 dialogStatusNew = 0;
uint32 quest_id = itr->second;
Quest const *pQuest = sObjectMgr.GetQuestTemplate(quest_id);
Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest_id);
if (!pQuest || !pQuest->IsActive())
continue;
@ -605,14 +605,14 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket
WorldPacket data(SMSG_QUESTGIVER_STATUS_MULTIPLE, 4);
data << uint32(count); // placeholder
for(GuidSet::const_iterator itr = _player->m_clientGUIDs.begin(); itr != _player->m_clientGUIDs.end(); ++itr)
for (GuidSet::const_iterator itr = _player->m_clientGUIDs.begin(); itr != _player->m_clientGUIDs.end(); ++itr)
{
uint8 dialogStatus = DIALOG_STATUS_NONE;
if (itr->IsAnyTypeCreature())
{
// need also pet quests case support
Creature *questgiver = GetPlayer()->GetMap()->GetAnyTypeCreature(*itr);
Creature* questgiver = GetPlayer()->GetMap()->GetAnyTypeCreature(*itr);
if (!questgiver || questgiver->IsHostileTo(_player))
continue;
@ -631,7 +631,7 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket
}
else if (itr->IsGameObject())
{
GameObject *questgiver = GetPlayer()->GetMap()->GetGameObject(*itr);
GameObject* questgiver = GetPlayer()->GetMap()->GetGameObject(*itr);
if (!questgiver)
continue;