TrinityCore
Loading...
Searching...
No Matches
GarrisonMap.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 "GarrisonMap.h"
19#include "DBCEnums.h"
20#include "GameObject.h"
21#include "Garrison.h"
22#include "Log.h"
23#include "ObjectAccessor.h"
24#include "ObjectGridLoader.h"
25#include "Player.h"
26#include "World.h"
27
29{
30public:
32 : i_grid(grid), i_map(map), i_garrison(map->GetGarrison()), i_gameObjects(0), i_creatures(0)
33 { }
34
35 void LoadN();
36
37private:
43};
44
46{
47 if (i_garrison)
48 {
49 for (Garrison::Plot* plot : i_garrison->GetPlots())
50 {
52 if (!go)
53 continue;
54
56 }
57 }
58
59 TC_LOG_DEBUG("maps", "{} GameObjects and {} Creatures loaded for grid {} on map {}", i_gameObjects, i_creatures, i_grid->GetGridId(), i_map->GetId());
60}
61
62GarrisonMap::GarrisonMap(uint32 id, time_t expiry, uint32 instanceId, ObjectGuid const& owner)
63 : Map(id, expiry, instanceId, DIFFICULTY_NORMAL), _owner(owner), _loadingPlayer(nullptr)
64{
66}
67
69{
71
72 GarrisonGridLoader loader(grid, this);
73 loader.LoadN();
74}
75
77{
80
82 return owner->GetGarrison();
83
84 return nullptr;
85}
86
93
94bool GarrisonMap::AddPlayerToMap(Player* player, bool initPlayer /*= true*/)
95{
96 if (player->GetGUID() == _owner)
97 _loadingPlayer = player;
98
99 bool result = Map::AddPlayerToMap(player, initPlayer);
100
101 if (player->GetGUID() == _owner)
102 _loadingPlayer = nullptr;
103
104 return result;
105}
@ DIFFICULTY_NORMAL
Definition DBCEnums.h:937
uint32_t uint32
Definition Define.h:154
#define TC_LOG_DEBUG(filterType__, message__,...)
Definition Log.h:173
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
static GameObject * CreateGameObject(uint32 entry, Map *map, Position const &pos, QuaternionData const &rotation, uint32 animProgress, GOState goState, uint32 artKit=0)
GarrisonGridLoader(NGridType *grid, GarrisonMap *map)
GarrisonMap * i_map
Garrison * i_garrison
ObjectGuid _owner
Definition GarrisonMap.h:39
bool AddPlayerToMap(Player *player, bool initPlayer=true) override
Player * _loadingPlayer
@workaround Player is not registered in ObjectAccessor during login
Definition GarrisonMap.h:40
GarrisonMap(uint32 id, time_t, uint32 instanceId, ObjectGuid const &owner)
void InitVisibilityDistance() override
Garrison * GetGarrison()
void LoadGridObjects(NGridType *grid) override
static constexpr GarrisonFactionIndex GetFaction(Team team)
Definition Garrison.h:232
std::vector< Plot * > GetPlots()
Definition Garrison.cpp:307
Definition Map.h:227
virtual bool AddPlayerToMap(Player *player, bool initPlayer=true)
Definition Map.cpp:392
int32 m_VisibilityNotifyPeriod
Definition Map.h:663
virtual void LoadGridObjects(NGridType *grid)
Definition Map.cpp:344
uint32 GetId() const
Definition Map.cpp:3288
float m_VisibleDistance
Definition Map.h:656
Definition NGrid.h:70
uint32 GetGridId(void) const
Definition NGrid.h:90
static void AddToMap(T *obj, Map *map, uint32 &objectCount)
Garrison * GetGarrison() const
Definition Player.h:2868
#define sWorld
Definition World.h:919
@ CONFIG_VISIBILITY_NOTIFY_PERIOD_INSTANCE
Definition World.h:432
@ CONFIG_MAX_VISIBILITY_DISTANCE_INSTANCE
Definition World.h:230
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)