/* * Ascent MMORPG Server * Copyright (C) 2005-2007 Ascent Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ // // MapCell.h // #ifndef __MAP_CELL_H #define __MAP_CELL_H class Map; struct Instance_Map_InstanceId_Holder; #define MAKE_CELL_EVENT(x,y) ( ((x) * 1000) + 200 + y ) #define DECODE_CELL_EVENT(dest_x, dest_y, ev) (dest_x) = ((ev-200)/1000); (dest_y) = ((ev-200)%1000); class MapCell { friend class MapMgr; public: MapCell() {}; ~MapCell(); typedef std::set ObjectSet; //Init void Init(uint32 x, uint32 y, uint32 mapid, MapMgr *mapmgr); //Object Managing void AddObject(Object *obj); void RemoveObject(Object *obj); bool HasObject(Object *obj) { return (_objects.find(obj) != _objects.end()); } bool HasPlayers() { return ((_playerCount > 0) ? true : false); } inline uint32 GetObjectCount() { return _objects.size(); } void RemoveObjects(); inline ObjectSet::iterator Begin() { return _objects.begin(); } inline ObjectSet::iterator End() { return _objects.end(); } //State Related void SetActivity(bool state); inline bool IsActive() { return _active; } inline bool IsLoaded() { return _loaded; } //Object Loading Managing void LoadObjects(CellSpawns * sp, Instance_Map_InstanceId_Holder * pInstance); inline uint32 GetPlayerCount() { return _playerCount; } inline bool IsUnloadPending() { return _unloadpending; } inline void SetUnloadPending(bool up) { _unloadpending = up; } void QueueUnloadPending(); void CancelPendingUnload(); void Unload(); ObjectSet _respawnObjects; private: uint16 _x,_y; ObjectSet _objects; bool _active, _loaded; bool _unloadpending; uint16 _playerCount; MapMgr* _mapmgr; }; #endif