TrinityCore
AdventureMapHandler.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"
19#include "AdventureMapPackets.h"
20#include "DB2Stores.h"
21#include "ObjectMgr.h"
22#include "Player.h"
23
25{
26 AdventureMapPOIEntry const* entry = sAdventureMapPOIStore.LookupEntry(checkIsAdventureMapPoiValid.AdventureMapPoiID);
27 if (!entry)
28 return;
29
30 auto sendIsPoiValid = [this](uint32 adventureMapPoiId, bool isVisible) -> void
31 {
33 isMapPoiValid.AdventureMapPoiID = adventureMapPoiId;
34 isMapPoiValid.IsVisible = isVisible;
35 SendPacket(isMapPoiValid.Write());
36 };
37
38 Quest const* quest = sObjectMgr->GetQuestTemplate(entry->QuestID);
39 if (!quest)
40 {
41 sendIsPoiValid(entry->ID, false);
42 return;
43 }
44
46 {
47 sendIsPoiValid(entry->ID, false);
48 return;
49 }
50
51 sendIsPoiValid(entry->ID, true);
52}
53
55{
56 Quest const* quest = sObjectMgr->GetQuestTemplate(startQuest.QuestID);
57 if (!quest)
58 return;
59
60 auto itr = std::find_if(sAdventureMapPOIStore.begin(), sAdventureMapPOIStore.end(), [&](AdventureMapPOIEntry const* adventureMap)
61 {
62 return adventureMap->QuestID == uint32(startQuest.QuestID) && _player->MeetPlayerCondition(adventureMap->PlayerConditionID);
63 });
64
65 if (itr == sAdventureMapPOIStore.end())
66 return;
67
68 if (_player->CanTakeQuest(quest, true))
70}
DB2Storage< AdventureMapPOIEntry > sAdventureMapPOIStore("AdventureMapPOI.db2", &AdventureMapPoiLoadInfo::Instance)
uint32_t uint32
Definition: Define.h:142
#define sObjectMgr
Definition: ObjectMgr.h:1946
bool MeetPlayerCondition(uint32 conditionId) const
Definition: Player.cpp:29377
void AddQuestAndCheckCompletion(Quest const *quest, Object *questGiver)
Definition: Player.cpp:14774
bool CanTakeQuest(Quest const *quest, bool msg) const
Definition: Player.cpp:14620
void HandleCheckIsAdventureMapPoiValid(WorldPackets::AdventureMap::CheckIsAdventureMapPoiValid &CheckIsAdventureMapPoiValid)
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Player * _player
void HandleAdventureMapStartQuest(WorldPackets::AdventureMap::AdventureMapStartQuest &startQuest)