TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GarrisonMgr.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
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 #ifndef GarrisonMgr_h__
19 #define GarrisonMgr_h__
20 
21 #include "DB2Stores.h"
22 #include <unordered_set>
23 #include "Position.h"
24 
26 {
27  struct
28  {
32  } FactionInfo[2];
33 };
34 
36 {
37  std::unordered_set<GarrAbilityEntry const*> Counters;
38  std::unordered_set<GarrAbilityEntry const*> Traits;
39 };
40 
42 {
43 public:
44  static GarrisonMgr& Instance();
45 
46  void Initialize();
47 
48  GarrSiteLevelEntry const* GetGarrSiteLevelEntry(uint32 garrSiteId, uint32 level) const;
49  std::vector<GarrSiteLevelPlotInstEntry const*> const* GetGarrPlotInstForSiteLevel(uint32 garrSiteLevelId) const;
50  GameObjectsEntry const* GetPlotGameObject(uint32 mapId, uint32 garrPlotInstanceId) const;
51  bool IsPlotMatchingBuilding(uint32 garrPlotId, uint32 garrBuildingId) const;
52  uint32 GetGarrBuildingPlotInst(uint32 garrBuildingId, uint32 garrSiteLevelPlotInstId) const;
53  GarrBuildingEntry const* GetPreviousLevelBuilding(uint32 buildingType, uint32 currentLevel) const;
54  FinalizeGarrisonPlotGOInfo const* GetPlotFinalizeGOInfo(uint32 garrPlotInstanceID) const;
55  uint64 GenerateFollowerDbId();
56  std::list<GarrAbilityEntry const*> RollFollowerAbilities(GarrFollowerEntry const* follower, uint32 quality, uint32 faction, bool initial) const;
57  std::list<GarrAbilityEntry const*> GetClassSpecAbilities(GarrFollowerEntry const* follower, uint32 faction) const;
58 
59 private:
60  void InitializeDbIdSequences();
61  void LoadPlotFinalizeGOInfo();
62  void LoadFollowerClassSpecAbilities();
63 
64  std::unordered_map<uint32 /*garrSiteId*/, std::vector<GarrSiteLevelPlotInstEntry const*>> _garrisonPlotInstBySiteLevel;
65  std::unordered_map<uint32 /*mapId*/, std::unordered_map<uint32 /*garrPlotId*/, GameObjectsEntry const*>> _garrisonPlots;
66  std::unordered_map<uint32 /*garrPlotId*/, std::unordered_set<uint32/*garrBuildingId*/>> _garrisonBuildingsByPlot;
67  std::unordered_map<uint64 /*garrBuildingId | garrSiteLevelPlotInstId << 32*/, uint32 /*garrBuildingPlotInstId*/> _garrisonBuildingPlotInstances;
68  std::unordered_map<uint32 /*buildingType*/, std::vector<GarrBuildingEntry const*>> _garrisonBuildingsByType;
69  std::unordered_map<uint32 /*garrPlotInstanceId*/, FinalizeGarrisonPlotGOInfo> _finalizePlotGOInfo;
70  std::unordered_map<uint32 /*garrFollowerId*/, GarrAbilities> _garrisonFollowerAbilities[2];
71  std::unordered_map<uint32 /*classSpecId*/, std::list<GarrAbilityEntry const*>> _garrisonFollowerClassSpecAbilities;
72  std::set<GarrAbilityEntry const*> _garrisonFollowerRandomTraits;
73 
74  uint64 _followerDbIdGenerator = UI64LIT(1);
75 };
76 
77 #define sGarrisonMgr GarrisonMgr::Instance()
78 
79 #endif // GarrisonMgr_h__
Definition: GarrisonMgr.h:41
uint32 GameObjectId
Definition: GarrisonMgr.h:29
std::unordered_map< uint32, std::unordered_map< uint32, GameObjectsEntry const * > > _garrisonPlots
Definition: GarrisonMgr.h:65
Definition: DB2Structure.h:439
std::unordered_set< GarrAbilityEntry const * > Traits
Definition: GarrisonMgr.h:38
std::unordered_map< uint32, std::list< GarrAbilityEntry const * > > _garrisonFollowerClassSpecAbilities
Definition: GarrisonMgr.h:71
#define UI64LIT(N)
Definition: Define.h:138
Definition: DB2Structure.h:400
Definition: DB2Structure.h:549
std::set< GarrAbilityEntry const * > _garrisonFollowerRandomTraits
Definition: GarrisonMgr.h:72
std::unordered_set< GarrAbilityEntry const * > Counters
Definition: GarrisonMgr.h:37
struct FinalizeGarrisonPlotGOInfo::@279 FactionInfo[2]
std::unordered_map< uint32, FinalizeGarrisonPlotGOInfo > _finalizePlotGOInfo
Definition: GarrisonMgr.h:69
Position Pos
Definition: GarrisonMgr.h:30
uint32_t uint32
Definition: Define.h:150
static void Initialize(PCASC_SALSA20 pState, LPBYTE pbKey, DWORD cbKeyLength, LPBYTE pbVector)
Definition: CascDecrypt.cpp:81
uint64_t uint64
Definition: Define.h:149
std::unordered_map< uint32, std::vector< GarrBuildingEntry const * > > _garrisonBuildingsByType
Definition: GarrisonMgr.h:68
uint16_t uint16
Definition: Define.h:151
std::unordered_map< uint32, std::unordered_set< uint32 > > _garrisonBuildingsByPlot
Definition: GarrisonMgr.h:66
#define TC_GAME_API
Definition: Define.h:134
std::unordered_map< uint32, std::vector< GarrSiteLevelPlotInstEntry const * > > _garrisonPlotInstBySiteLevel
Definition: GarrisonMgr.h:64
Definition: Position.h:27
Definition: DB2Structure.h:486
Definition: GarrisonMgr.h:25
Definition: GarrisonMgr.h:35
std::unordered_map< uint64, uint32 > _garrisonBuildingPlotInstances
Definition: GarrisonMgr.h:67
uint16 AnimKitId
Definition: GarrisonMgr.h:31