| 1 | /* |
|---|
| 2 | * ArcEmu MMORPG Server |
|---|
| 3 | * Copyright (C) 2005-2007 Ascent Team <http://www.ascentemu.com/> |
|---|
| 4 | * Copyright (C) 2008-2009 <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 | // Map.h |
|---|
| 23 | // |
|---|
| 24 | |
|---|
| 25 | #ifndef __MAP_H |
|---|
| 26 | #define __MAP_H |
|---|
| 27 | |
|---|
| 28 | class MapMgr; |
|---|
| 29 | class TemplateMgr; |
|---|
| 30 | struct MapInfo; |
|---|
| 31 | class TerrainMgr; |
|---|
| 32 | |
|---|
| 33 | #include "TerrainMgr.h" |
|---|
| 34 | |
|---|
| 35 | struct Formation; |
|---|
| 36 | |
|---|
| 37 | typedef struct |
|---|
| 38 | { |
|---|
| 39 | uint32 id;//spawn ID |
|---|
| 40 | uint32 entry; |
|---|
| 41 | float x; |
|---|
| 42 | float y; |
|---|
| 43 | float z; |
|---|
| 44 | float o; |
|---|
| 45 | Formation* form; |
|---|
| 46 | uint8 movetype; |
|---|
| 47 | uint32 displayid; |
|---|
| 48 | uint32 factionid; |
|---|
| 49 | uint32 flags; |
|---|
| 50 | uint32 bytes0; |
|---|
| 51 | uint32 bytes1; |
|---|
| 52 | uint32 bytes2; |
|---|
| 53 | uint32 emote_state; |
|---|
| 54 | //uint32 respawnNpcLink; |
|---|
| 55 | uint16 channel_spell; |
|---|
| 56 | uint32 channel_target_go; |
|---|
| 57 | uint32 channel_target_creature; |
|---|
| 58 | uint16 stand_state; |
|---|
| 59 | uint32 MountedDisplayID; |
|---|
| 60 | uint32 Item1SlotDisplay; |
|---|
| 61 | uint32 Item2SlotDisplay; |
|---|
| 62 | uint32 Item3SlotDisplay; |
|---|
| 63 | uint32 CanFly; |
|---|
| 64 | uint32 phase; |
|---|
| 65 | |
|---|
| 66 | /* sets one of the bytes of an uint32 */ |
|---|
| 67 | uint32 setbyte(uint32 buffer, uint8 index, uint32 byte){ |
|---|
| 68 | |
|---|
| 69 | /* We don't want a segfault, now do we? */ |
|---|
| 70 | if(index >= 4) |
|---|
| 71 | return buffer; |
|---|
| 72 | |
|---|
| 73 | byte = byte << index*8; |
|---|
| 74 | buffer = buffer | byte; |
|---|
| 75 | |
|---|
| 76 | return buffer; |
|---|
| 77 | } |
|---|
| 78 | }CreatureSpawn; |
|---|
| 79 | |
|---|
| 80 | typedef struct |
|---|
| 81 | { |
|---|
| 82 | uint32 id;//spawn ID |
|---|
| 83 | uint32 entry; |
|---|
| 84 | float x; |
|---|
| 85 | float y; |
|---|
| 86 | float z; |
|---|
| 87 | float o; |
|---|
| 88 | float o1; |
|---|
| 89 | float o2; |
|---|
| 90 | float o3; |
|---|
| 91 | float facing; |
|---|
| 92 | uint32 flags; |
|---|
| 93 | uint32 state; |
|---|
| 94 | uint32 faction; |
|---|
| 95 | //uint32 level; |
|---|
| 96 | float scale; |
|---|
| 97 | //uint32 stateNpcLink; |
|---|
| 98 | uint32 phase; |
|---|
| 99 | uint32 overrides; |
|---|
| 100 | } GOSpawn; |
|---|
| 101 | |
|---|
| 102 | typedef std::vector<CreatureSpawn*> CreatureSpawnList; |
|---|
| 103 | typedef std::vector<GOSpawn*> GOSpawnList; |
|---|
| 104 | |
|---|
| 105 | typedef struct |
|---|
| 106 | { |
|---|
| 107 | CreatureSpawnList CreatureSpawns; |
|---|
| 108 | GOSpawnList GOSpawns; |
|---|
| 109 | }CellSpawns; |
|---|
| 110 | |
|---|
| 111 | class SERVER_DECL Map |
|---|
| 112 | { |
|---|
| 113 | public: |
|---|
| 114 | Map(uint32 mapid, MapInfo * inf); |
|---|
| 115 | ~Map(); |
|---|
| 116 | |
|---|
| 117 | ARCEMU_INLINE string GetNameString() { return name; } |
|---|
| 118 | ARCEMU_INLINE const char* GetName() { return name.c_str(); } |
|---|
| 119 | ARCEMU_INLINE MapEntry* GetDBCEntry() { return me; } |
|---|
| 120 | |
|---|
| 121 | ARCEMU_INLINE CellSpawns *GetSpawnsList(uint32 cellx,uint32 celly) |
|---|
| 122 | { |
|---|
| 123 | ASSERT(cellx < _sizeX); |
|---|
| 124 | ASSERT(celly < _sizeY); |
|---|
| 125 | if(spawns[cellx]==NULL) return NULL; |
|---|
| 126 | |
|---|
| 127 | return spawns[cellx][celly]; |
|---|
| 128 | } |
|---|
| 129 | ARCEMU_INLINE CellSpawns * GetSpawnsListAndCreate(uint32 cellx, uint32 celly) |
|---|
| 130 | { |
|---|
| 131 | ASSERT(cellx < _sizeX); |
|---|
| 132 | ASSERT(celly < _sizeY); |
|---|
| 133 | if(spawns[cellx]==NULL) |
|---|
| 134 | { |
|---|
| 135 | spawns[cellx] = new CellSpawns*[_sizeY]; |
|---|
| 136 | memset(spawns[cellx],0,sizeof(CellSpawns*)*_sizeY); |
|---|
| 137 | } |
|---|
| 138 | |
|---|
| 139 | if(spawns[cellx][celly] == 0) |
|---|
| 140 | spawns[cellx][celly] = new CellSpawns; |
|---|
| 141 | return spawns[cellx][celly]; |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | void LoadSpawns(bool reload);//set to true to make clean up |
|---|
| 145 | uint32 CreatureSpawnCount; |
|---|
| 146 | uint32 GameObjectSpawnCount; |
|---|
| 147 | |
|---|
| 148 | ARCEMU_INLINE float GetLandHeight(float x, float y) |
|---|
| 149 | { |
|---|
| 150 | if(_terrain) |
|---|
| 151 | { |
|---|
| 152 | return _terrain->GetLandHeight(x, y); |
|---|
| 153 | } |
|---|
| 154 | else |
|---|
| 155 | { |
|---|
| 156 | return 999999.0f; |
|---|
| 157 | } |
|---|
| 158 | } |
|---|
| 159 | |
|---|
| 160 | ARCEMU_INLINE float GetWaterHeight(float x, float y) |
|---|
| 161 | { |
|---|
| 162 | if(_terrain) |
|---|
| 163 | { |
|---|
| 164 | return _terrain->GetWaterHeight(x, y); |
|---|
| 165 | } |
|---|
| 166 | else |
|---|
| 167 | { |
|---|
| 168 | return 999999.0f; |
|---|
| 169 | } |
|---|
| 170 | } |
|---|
| 171 | |
|---|
| 172 | ARCEMU_INLINE uint8 GetWaterType(float x, float y) |
|---|
| 173 | { |
|---|
| 174 | if(_terrain) |
|---|
| 175 | { |
|---|
| 176 | return _terrain->GetWaterType(x, y); |
|---|
| 177 | } |
|---|
| 178 | else |
|---|
| 179 | { |
|---|
| 180 | return 0; |
|---|
| 181 | } |
|---|
| 182 | } |
|---|
| 183 | |
|---|
| 184 | ARCEMU_INLINE uint8 GetWalkableState(float x, float y) |
|---|
| 185 | { |
|---|
| 186 | if(_terrain) |
|---|
| 187 | { |
|---|
| 188 | return _terrain->GetWalkableState(x, y); |
|---|
| 189 | } |
|---|
| 190 | else |
|---|
| 191 | { |
|---|
| 192 | return 1; |
|---|
| 193 | } |
|---|
| 194 | } |
|---|
| 195 | |
|---|
| 196 | ARCEMU_INLINE uint16 GetAreaID(float x, float y) |
|---|
| 197 | { |
|---|
| 198 | if(_terrain) |
|---|
| 199 | { |
|---|
| 200 | return _terrain->GetAreaID(x, y); |
|---|
| 201 | } |
|---|
| 202 | else |
|---|
| 203 | { |
|---|
| 204 | return 0xFFFF; |
|---|
| 205 | } |
|---|
| 206 | } |
|---|
| 207 | |
|---|
| 208 | ARCEMU_INLINE void CellGoneActive(uint32 x, uint32 y) |
|---|
| 209 | { |
|---|
| 210 | if(_terrain) |
|---|
| 211 | { |
|---|
| 212 | _terrain->CellGoneActive(x,y); |
|---|
| 213 | } |
|---|
| 214 | } |
|---|
| 215 | |
|---|
| 216 | ARCEMU_INLINE void CellGoneIdle(uint32 x,uint32 y) |
|---|
| 217 | { |
|---|
| 218 | if(_terrain) |
|---|
| 219 | { |
|---|
| 220 | _terrain->CellGoneIdle(x,y); |
|---|
| 221 | } |
|---|
| 222 | } |
|---|
| 223 | |
|---|
| 224 | private: |
|---|
| 225 | MapInfo * _mapInfo; |
|---|
| 226 | TerrainMgr* _terrain; |
|---|
| 227 | uint32 _mapId; |
|---|
| 228 | string name; |
|---|
| 229 | MapEntry * me; |
|---|
| 230 | |
|---|
| 231 | //new stuff |
|---|
| 232 | CellSpawns **spawns[_sizeX]; |
|---|
| 233 | public: |
|---|
| 234 | CellSpawns staticSpawns; |
|---|
| 235 | }; |
|---|
| 236 | |
|---|
| 237 | #endif |
|---|