[2] | 1 | /* |
---|
| 2 | * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> |
---|
| 3 | * |
---|
| 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. |
---|
| 8 | * |
---|
| 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. |
---|
| 13 | * |
---|
| 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 |
---|
| 17 | */ |
---|
| 18 | |
---|
| 19 | #ifndef MANGOS_OBJECTGRIDLOADER_H |
---|
| 20 | #define MANGOS_OBJECTGRIDLOADER_H |
---|
| 21 | |
---|
| 22 | #include "Utilities/TypeList.h" |
---|
| 23 | #include "Platform/Define.h" |
---|
| 24 | #include "GameSystem/GridLoader.h" |
---|
| 25 | #include "GridDefines.h" |
---|
| 26 | #include "Cell.h" |
---|
| 27 | |
---|
| 28 | class ObjectWorldLoader; |
---|
| 29 | |
---|
| 30 | class MANGOS_DLL_DECL ObjectGridLoader |
---|
| 31 | { |
---|
| 32 | friend class ObjectWorldLoader; |
---|
| 33 | |
---|
| 34 | public: |
---|
| 35 | ObjectGridLoader(NGridType &grid, Map* map, const Cell &cell) |
---|
| 36 | : i_cell(cell), i_grid(grid), i_map(map), i_gameObjects(0), i_creatures(0), i_corpses (0) |
---|
| 37 | {} |
---|
| 38 | |
---|
| 39 | void Load(GridType &grid); |
---|
| 40 | void Visit(GameObjectMapType &m); |
---|
| 41 | void Visit(CreatureMapType &m); |
---|
| 42 | void Visit(CorpseMapType &) {} |
---|
| 43 | |
---|
| 44 | void Visit(DynamicObjectMapType&) { } |
---|
| 45 | |
---|
| 46 | void LoadN(void); |
---|
| 47 | |
---|
| 48 | private: |
---|
| 49 | Cell i_cell; |
---|
| 50 | NGridType &i_grid; |
---|
| 51 | Map* i_map; |
---|
| 52 | uint32 i_gameObjects; |
---|
| 53 | uint32 i_creatures; |
---|
| 54 | uint32 i_corpses; |
---|
| 55 | }; |
---|
| 56 | |
---|
| 57 | class MANGOS_DLL_DECL ObjectGridUnloader |
---|
| 58 | { |
---|
| 59 | public: |
---|
| 60 | ObjectGridUnloader(NGridType &grid) : i_grid(grid) {} |
---|
| 61 | |
---|
| 62 | void MoveToRespawnN(); |
---|
| 63 | void UnloadN() |
---|
| 64 | { |
---|
| 65 | for(unsigned int x=0; x < MAX_NUMBER_OF_CELLS; ++x) |
---|
| 66 | { |
---|
| 67 | for(unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y) |
---|
| 68 | { |
---|
| 69 | GridLoader<Player, AllWorldObjectTypes, AllGridObjectTypes> loader; |
---|
| 70 | loader.Unload(i_grid(x, y), *this); |
---|
| 71 | } |
---|
| 72 | } |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | void Unload(GridType &grid); |
---|
| 76 | template<class T> void Visit(GridRefManager<T> &m); |
---|
| 77 | private: |
---|
| 78 | NGridType &i_grid; |
---|
| 79 | }; |
---|
| 80 | |
---|
| 81 | class MANGOS_DLL_DECL ObjectGridStoper |
---|
| 82 | { |
---|
| 83 | public: |
---|
| 84 | ObjectGridStoper(NGridType &grid) : i_grid(grid) {} |
---|
| 85 | |
---|
| 86 | void MoveToRespawnN(); |
---|
| 87 | void StopN() |
---|
| 88 | { |
---|
| 89 | for(unsigned int x=0; x < MAX_NUMBER_OF_CELLS; ++x) |
---|
| 90 | { |
---|
| 91 | for(unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y) |
---|
| 92 | { |
---|
| 93 | GridLoader<Player, AllWorldObjectTypes, AllGridObjectTypes> loader; |
---|
| 94 | loader.Stop(i_grid(x, y), *this); |
---|
| 95 | } |
---|
| 96 | } |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | void Stop(GridType &grid); |
---|
| 100 | void Visit(CreatureMapType &m); |
---|
| 101 | |
---|
| 102 | template<class NONACTIVE> void Visit(GridRefManager<NONACTIVE> &) {} |
---|
| 103 | private: |
---|
| 104 | NGridType &i_grid; |
---|
| 105 | }; |
---|
| 106 | |
---|
| 107 | typedef GridLoader<Player, AllWorldObjectTypes, AllGridObjectTypes> GridLoaderType; |
---|
| 108 | #endif |
---|