| 1 | /* |
|---|
| 2 | * ArcEmu MMORPG Server |
|---|
| 3 | * Copyright (C) 2005-2007 Ascent Team <http://www.ascentemu.com/> |
|---|
| 4 | * Copyright (C) 2008-2010 <http://www.ArcEmu.org/> |
|---|
| 5 | * |
|---|
| 6 | * This program is free software: you can redistribute it and/or modify |
|---|
| 7 | * it under the terms of the GNU Affero General Public License as published by |
|---|
| 8 | * the Free Software Foundation, either version 3 of the License, or |
|---|
| 9 | * 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 Affero General Public License for more details. |
|---|
| 15 | * |
|---|
| 16 | * You should have received a copy of the GNU Affero General Public License |
|---|
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 18 | * |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | // |
|---|
| 22 | // MapCell.h |
|---|
| 23 | // |
|---|
| 24 | |
|---|
| 25 | #ifndef __MAP_CELL_H |
|---|
| 26 | #define __MAP_CELL_H |
|---|
| 27 | |
|---|
| 28 | class Map; |
|---|
| 29 | |
|---|
| 30 | #define MAKE_CELL_EVENT(x,y) ( ((x) * 1000) + 200 + y ) |
|---|
| 31 | #define DECODE_CELL_EVENT(dest_x, dest_y, ev) (dest_x) = ((ev-200)/1000); (dest_y) = ((ev-200)%1000); |
|---|
| 32 | |
|---|
| 33 | class SERVER_DECL MapCell |
|---|
| 34 | { |
|---|
| 35 | friend class MapMgr; |
|---|
| 36 | public: |
|---|
| 37 | MapCell() {}; |
|---|
| 38 | ~MapCell(); |
|---|
| 39 | |
|---|
| 40 | typedef std::set<Object*> ObjectSet; |
|---|
| 41 | |
|---|
| 42 | //Init |
|---|
| 43 | void Init(uint32 x, uint32 y, uint32 mapid, MapMgr *mapmgr); |
|---|
| 44 | |
|---|
| 45 | //Object Managing |
|---|
| 46 | void AddObject(Object *obj); |
|---|
| 47 | void RemoveObject(Object *obj); |
|---|
| 48 | bool HasObject(Object *obj) { return (_objects.find(obj) != _objects.end()); } |
|---|
| 49 | bool HasPlayers() { return ((_playerCount > 0) ? true : false); } |
|---|
| 50 | ARCEMU_INLINE size_t GetObjectCount() { return _objects.size(); } |
|---|
| 51 | void RemoveObjects(); |
|---|
| 52 | ARCEMU_INLINE ObjectSet::iterator Begin() { return _objects.begin(); } |
|---|
| 53 | ARCEMU_INLINE ObjectSet::iterator End() { return _objects.end(); } |
|---|
| 54 | |
|---|
| 55 | //State Related |
|---|
| 56 | void SetActivity(bool state); |
|---|
| 57 | |
|---|
| 58 | ARCEMU_INLINE bool IsActive() { return _active; } |
|---|
| 59 | ARCEMU_INLINE bool IsLoaded() { return _loaded; } |
|---|
| 60 | ARCEMU_INLINE void SetLoaded( bool Loaded = true ) { _loaded = Loaded; } |
|---|
| 61 | |
|---|
| 62 | //Object Loading Managing |
|---|
| 63 | void LoadObjects(CellSpawns * sp); |
|---|
| 64 | ARCEMU_INLINE uint32 GetPlayerCount() { return _playerCount; } |
|---|
| 65 | |
|---|
| 66 | ARCEMU_INLINE bool IsUnloadPending() { return _unloadpending; } |
|---|
| 67 | ARCEMU_INLINE void SetUnloadPending(bool up) { _unloadpending = up; } |
|---|
| 68 | void QueueUnloadPending(); |
|---|
| 69 | void CancelPendingUnload(); |
|---|
| 70 | void Unload(); |
|---|
| 71 | ARCEMU_INLINE uint16 GetPositionX() { return _x; } |
|---|
| 72 | ARCEMU_INLINE uint16 GetPositionY() { return _y; } |
|---|
| 73 | |
|---|
| 74 | ObjectSet _respawnObjects; |
|---|
| 75 | |
|---|
| 76 | private: |
|---|
| 77 | uint16 _x,_y; |
|---|
| 78 | ObjectSet _objects; |
|---|
| 79 | bool _active, _loaded; |
|---|
| 80 | bool _unloadpending; |
|---|
| 81 | |
|---|
| 82 | uint16 _playerCount; |
|---|
| 83 | MapMgr* _mapmgr; |
|---|
| 84 | |
|---|
| 85 | Mutex m_objectlock; |
|---|
| 86 | }; |
|---|
| 87 | |
|---|
| 88 | #endif |
|---|