1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
/*
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ScenarioMgr_h__
#define ScenarioMgr_h__
#include "Common.h"
#include "Hash.h"
#include "SharedDefines.h"
#include <map>
#include <unordered_map>
#include <vector>
class InstanceMap;
class InstanceScenario;
struct ScenarioEntry;
struct ScenarioStepEntry;
struct ScenarioData
{
ScenarioEntry const* Entry;
std::map<uint8, ScenarioStepEntry const*> Steps;
};
/*
Scenario data should be loaded on demand.
The server will get data from the database which scenario ids is linked with which map id/difficulty/player team.
The first time a scenario is loaded, the map loads and stores the scenario data for future scenario instance launches.
*/
struct ScenarioDBData
{
uint32 MapID;
uint8 DifficultyID;
uint32 Scenario_A;
uint32 Scenario_H;
};
typedef std::unordered_map<std::pair<uint32, uint8>, ScenarioDBData> ScenarioDBDataContainer;
typedef std::map<uint32, ScenarioData> ScenarioDataContainer;
enum ScenarioType
{
SCENARIO_TYPE_SCENARIO = 0,
SCENARIO_TYPE_CHALLENGE_MODE = 1,
SCENARIO_TYPE_SOLO = 2,
SCENARIO_TYPE_DUNGEON = 10,
};
struct ScenarioPOIPoint
{
int32 X;
int32 Y;
int32 Z;
ScenarioPOIPoint() : X(0), Y(0), Z(0) { }
ScenarioPOIPoint(int32 x, int32 y, int32 z) : X(x), Y(y), Z(z) { }
};
struct ScenarioPOI
{
int32 BlobIndex;
int32 MapID;
int32 UiMapID;
int32 Priority;
int32 Flags;
int32 WorldEffectID;
int32 PlayerConditionID;
int32 NavigationPlayerConditionID;
std::vector<ScenarioPOIPoint> Points;
ScenarioPOI() : BlobIndex(0), MapID(0), UiMapID(0), Priority(0), Flags(0), WorldEffectID(0), PlayerConditionID(0), NavigationPlayerConditionID(0) { }
ScenarioPOI(int32 blobIndex, int32 mapID, int32 uiMapID, int32 priority, int32 flags, int32 worldEffectID,
int32 playerConditionID, int32 navigationPlayerConditionID, std::vector<ScenarioPOIPoint> points) :
BlobIndex(blobIndex), MapID(mapID), UiMapID(uiMapID), Priority(priority), Flags(flags), WorldEffectID(worldEffectID),
PlayerConditionID(playerConditionID), NavigationPlayerConditionID(navigationPlayerConditionID), Points(std::move(points)) { }
ScenarioPOI(ScenarioPOI&& scenarioPOI) = default;
};
typedef std::vector<ScenarioPOI> ScenarioPOIVector;
typedef std::unordered_map<uint32, ScenarioPOIVector> ScenarioPOIContainer;
class TC_GAME_API ScenarioMgr
{
private:
ScenarioMgr() { }
~ScenarioMgr() { }
public:
static ScenarioMgr* Instance();
InstanceScenario* CreateInstanceScenario(InstanceMap const* map, TeamId team) const;
void LoadDBData();
void LoadDB2Data();
void LoadScenarioPOI();
ScenarioPOIVector const* GetScenarioPOIs(int32 criteriaTreeID) const;
private:
ScenarioDataContainer _scenarioData;
ScenarioPOIContainer _scenarioPOIStore;
ScenarioDBDataContainer _scenarioDBData;
ScenarioMgr(ScenarioMgr const&) = delete;
ScenarioMgr& operator=(ScenarioMgr const&) = delete;
};
#define sScenarioMgr ScenarioMgr::Instance()
#endif // ScenarioMgr_h__
|