root/trunk/src/game/MapInstanced.h @ 252

Revision 206, 2.6 kB (checked in by yumileroy, 17 years ago)

[svn] * Switch from hashmap to unordered map. - cleanup source - mangos. Help - Aokromes

Original author: KingPin?
Date: 2008-11-10 06:53:00-06:00

Line 
1/*
2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
3 *
4 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef TRINITY_MAP_INSTANCED_H
22#define TRINITY_MAP_INSTANCED_H
23
24#include "Map.h"
25#include "InstanceSaveMgr.h"
26
27class TRINITY_DLL_DECL MapInstanced : public Map
28{
29    friend class MapManager;
30    public:
31        typedef UNORDERED_MAP< uint32, Map* > InstancedMaps;
32
33        MapInstanced(uint32 id, time_t, uint32 aInstanceId);
34        ~MapInstanced() {}
35
36        // functions overwrite Map versions
37        void Update(const uint32&);
38        void MoveAllCreaturesInMoveList();
39        void RemoveAllObjectsInRemoveList();
40        bool RemoveBones(uint64 guid, float x, float y);
41        void UnloadAll(bool pForce);
42
43        Map* GetInstance(const WorldObject* obj);
44        Map* FindMap(uint32 InstanceId) { return _FindMap(InstanceId); }
45        void DestroyInstance(uint32 InstanceId);
46        void DestroyInstance(InstancedMaps::iterator &itr);
47        void AddGridMapReference(const GridPair &p) { ++GridMapReference[p.x_coord][p.y_coord]; }
48        void RemoveGridMapReference(const GridPair &p)
49        {
50            --GridMapReference[p.x_coord][p.y_coord];
51            if (!GridMapReference[p.x_coord][p.y_coord]) { SetUnloadFlag(GridPair(63-p.x_coord,63-p.y_coord), true); }
52        }
53
54        InstancedMaps &GetInstancedMaps() { return m_InstancedMaps; }
55
56    private:
57
58        InstanceMap* CreateInstance(uint32 InstanceId, InstanceSave *save, uint8 difficulty);
59        BattleGroundMap* CreateBattleGround(uint32 InstanceId);
60
61        InstancedMaps m_InstancedMaps;
62
63        Map* _FindMap(uint32 InstanceId)
64        {
65            InstancedMaps::iterator i = m_InstancedMaps.find(InstanceId);
66
67            return(i == m_InstancedMaps.end() ? NULL : i->second);
68        }
69
70        uint16 GridMapReference[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS];
71};
72#endif
Note: See TracBrowser for help on using the browser.