2 * Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef MANGOS_MAP_INSTANCED_H
20 #define MANGOS_MAP_INSTANCED_H
23 #include "InstanceSaveMgr.h"
26 class MANGOS_DLL_DECL MapInstanced
: public Map
28 friend class MapManager
;
30 typedef UNORDERED_MAP
< uint32
, Map
* > InstancedMaps
;
32 MapInstanced(uint32 id
, time_t expiry
);
35 // functions overwrite Map versions
36 void Update(const uint32
&);
37 void MoveAllCreaturesInMoveList();
38 void RemoveAllObjectsInRemoveList();
39 bool RemoveBones(uint64 guid
, float x
, float y
);
40 void UnloadAll(bool pForce
);
42 Map
* CreateInstance(const uint32 mapId
, Player
* player
);
43 Map
* FindMap(uint32 InstanceId
) const { return _FindMap(InstanceId
); }
44 void DestroyInstance(uint32 InstanceId
);
45 void DestroyInstance(InstancedMaps::iterator
&itr
);
47 void AddGridMapReference(const GridPair
&p
)
49 ++GridMapReference
[p
.x_coord
][p
.y_coord
];
50 SetUnloadReferenceLock(GridPair(63-p
.x_coord
, 63-p
.y_coord
), true);
53 void RemoveGridMapReference(GridPair
const& p
)
55 --GridMapReference
[p
.x_coord
][p
.y_coord
];
56 if (!GridMapReference
[p
.x_coord
][p
.y_coord
])
57 SetUnloadReferenceLock(GridPair(63-p
.x_coord
, 63-p
.y_coord
), false);
60 InstancedMaps
&GetInstancedMaps() { return m_InstancedMaps
; }
61 virtual void InitVisibilityDistance();
65 InstanceMap
* CreateInstance(uint32 InstanceId
, InstanceSave
*save
, Difficulty difficulty
);
66 BattleGroundMap
* CreateBattleGroundMap(uint32 InstanceId
, BattleGround
* bg
);
68 InstancedMaps m_InstancedMaps
;
70 Map
* _FindMap(uint32 InstanceId
) const
72 InstancedMaps::const_iterator i
= m_InstancedMaps
.find(InstanceId
);
73 return(i
== m_InstancedMaps
.end() ? NULL
: i
->second
);
76 uint16 GridMapReference
[MAX_NUMBER_OF_GRIDS
][MAX_NUMBER_OF_GRIDS
];