TrinityCore
AdventureJournalHandler.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "WorldSession.h"
20#include "DB2Stores.h"
21#include "GossipDef.h"
22#include "ObjectMgr.h"
23#include "Player.h"
24
26{
27 if (ChrClassUIDisplayEntry const* uiDisplay = sDB2Manager.GetUiDisplayForClass(Classes(_player->GetClass())))
28 if (!_player->MeetPlayerCondition(uiDisplay->AdvGuidePlayerConditionID))
29 return;
30
31 AdventureJournalEntry const* adventureJournal = sAdventureJournalStore.LookupEntry(openQuest.AdventureJournalID);
32 if (!adventureJournal)
33 return;
34
35 if (!_player->MeetPlayerCondition(adventureJournal->PlayerConditionID))
36 return;
37
38 Quest const* quest = sObjectMgr->GetQuestTemplate(adventureJournal->QuestID);
39 if (!quest)
40 return;
41
42 if (_player->CanTakeQuest(quest, true))
43 _player->PlayerTalkClass->SendQuestGiverQuestDetails(quest, _player->GetGUID(), true, false);
44}
45
47{
48 if (ChrClassUIDisplayEntry const* uiDisplay = sDB2Manager.GetUiDisplayForClass(Classes(_player->GetClass())))
49 if (!_player->MeetPlayerCondition(uiDisplay->AdvGuidePlayerConditionID))
50 return;
51
53 response.OnLevelUp = updateSuggestions.OnLevelUp;
54
55 for (AdventureJournalEntry const* adventureJournal : sAdventureJournalStore)
56 {
57 if (_player->MeetPlayerCondition(adventureJournal->PlayerConditionID))
58 {
60 adventureJournalData.AdventureJournalID = int32(adventureJournal->ID);
61 adventureJournalData.Priority = int32(adventureJournal->PriorityMax);
62 response.Entries.push_back(adventureJournalData);
63 }
64 }
65
66 SendPacket(response.Write());
67}
DB2Storage< AdventureJournalEntry > sAdventureJournalStore("AdventureJournal.db2", &AdventureJournalLoadInfo::Instance)
#define sDB2Manager
Definition: DB2Stores.h:538
int32_t int32
Definition: Define.h:138
#define sObjectMgr
Definition: ObjectMgr.h:1946
Classes
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
bool MeetPlayerCondition(uint32 conditionId) const
Definition: Player.cpp:29377
bool CanTakeQuest(Quest const *quest, bool msg) const
Definition: Player.cpp:14620
std::unique_ptr< PlayerMenu > PlayerTalkClass
Definition: Player.h:2380
uint8 GetClass() const
Definition: Unit.h:752
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
void HandleAdventureJournalUpdateSuggestions(WorldPackets::AdventureJournal::AdventureJournalUpdateSuggestions &updateSuggestions)
Player * _player
void HandleAdventureJournalOpenQuest(WorldPackets::AdventureJournal::AdventureJournalOpenQuest &openQuest)