/* * 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 . * */ // // Map.h // #ifndef __MAP_H #define __MAP_H class MapMgr; class TemplateMgr; struct MapInfo; typedef std::map InstanceMap; class TerrainMgr; #include "TerrainMgr.h" struct Formation; typedef struct { uint32 id;//spawn ID uint32 entry; float x; float y; float z; float o; Formation* form; uint32 movetype; uint32 displayid; uint32 factionid; uint32 flags; uint32 bytes; uint32 bytes2; uint32 emote_state; uint32 respawnNpcLink; }CreatureSpawn; typedef struct { uint32 id;//spawn ID uint32 entry; float x; float y; float z; float o; float o1; float o2; float o3; float facing; uint32 flags; uint32 state; uint32 faction; // uint32 level; float scale; uint32 stateNpcLink; } GOSpawn; typedef std::set CreatureSpawnList; typedef std::set GOSpawnList; typedef struct { CreatureSpawnList CreatureSpawns; GOSpawnList GOSpawns; }CellSpawns; class SERVER_DECL Map { public: Map(uint32 mapid); ~Map(); inline InstanceMap::iterator GetInstancesBegin() { return _instances.begin(); } inline InstanceMap::iterator GetInstancesEnd() { return _instances.end(); } MapMgr * CreateMapMgrInstance(uint32 instanceid = 0); void DestroyMapMgrInstance(uint32 instanceId); MapMgr * GetFirstInstance(); // for main continents MapMgr * GetInstance(Object* obj); MapMgr * GetInstance(uint32 instanceId); MapMgr * GetRawInstance(uint32 instanceid); //this function bypass pending stattes MapMgr * GetInstanceByGroup(Group *pGroup, Player *pCaller); MapMgr * GetInstanceByCreator(Player *pCreator); MapMgr * GetInstanceByGroupInstanceId(uint32 InstanceID, bool Lock); MapMgr * InstanceExists(uint32 instanceId); inline string GetNameString() { return name; } inline const char* GetName() { return name.c_str(); } inline MapEntry* GetDBCEntry() { return me; } void BuildXMLStats(char * m_file); inline CellSpawns *GetSpawnsList(uint32 cellx,uint32 celly) { ASSERT(cellx < _sizeX); ASSERT(celly < _sizeY); if(spawns[cellx]==NULL) return NULL; return spawns[cellx][celly]; } inline CellSpawns * GetSpawnsListAndCreate(uint32 cellx, uint32 celly) { ASSERT(cellx < _sizeX); ASSERT(celly < _sizeY); if(spawns[cellx]==NULL) { spawns[cellx] = new CellSpawns*[_sizeY]; memset(spawns[cellx],0,sizeof(CellSpawns*)*_sizeY); } if(spawns[cellx][celly] == 0) spawns[cellx][celly] = new CellSpawns; return spawns[cellx][celly]; } void LoadSpawns(bool reload);//set to true to make clean up uint32 CreatureSpawnCount; uint32 GameObjectSpawnCount; inline float GetLandHeight(float x, float y) { if(_terrain) { return _terrain->GetLandHeight(x, y); } else { return 999999.0f; } } inline float GetWaterHeight(float x, float y) { if(_terrain) { return _terrain->GetWaterHeight(x, y); } else { return 999999.0f; } } inline uint8 GetWaterType(float x, float y) { if(_terrain) { return _terrain->GetWaterType(x, y); } else { return 0; } } inline uint8 GetWalkableState(float x, float y) { if(_terrain) { return _terrain->GetWalkableState(x, y); } else { return 1; } } inline uint16 GetAreaID(float x, float y) { if(_terrain) { return _terrain->GetAreaID(x, y); } else { return 0xFFFF; } } inline void CellGoneActive(uint32 x, uint32 y) { if(_terrain) { _terrain->CellGoneActive(x,y); } } inline void CellGoneIdle(uint32 x,uint32 y) { if(_terrain) { _terrain->CellGoneIdle(x,y); } } private: InstanceMap _instances; MapInfo * _mapInfo; TerrainMgr* _terrain; uint32 _mapId; string name; MapEntry * me; Mutex listmutex; //new stuff CellSpawns **spawns[_sizeX]; public: CellSpawns staticSpawns; }; #endif