/*
* Copyright (C) 2008 Trinity
*
* Thanks to the original authors: MaNGOS
*
* 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 2 of the License, or
* (at your option) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef TRINITY_MAP_H
#define TRINITY_MAP_H
#include "Platform/Define.h"
#include "Policies/ThreadingModel.h"
#include "zthread/Lockable.h"
#include "zthread/Mutex.h"
#include "zthread/FairReadWriteLock.h"
#include "Database/DBCStructure.h"
#include "GridDefines.h"
#include "Cell.h"
#include "Object.h"
#include "Timer.h"
#include "SharedDefines.h"
#include "GameSystem/GridRefManager.h"
#include
#include
class Unit;
class WorldPacket;
class InstanceData;
class Group;
class InstanceSave;
namespace ZThread
{
class Lockable;
class ReadWriteLock;
}
typedef ZThread::FairReadWriteLock GridRWLock;
template
struct RGuard
{
RGuard(MUTEX &l) : i_lock(l.getReadLock()) {}
Trinity::GeneralLock i_lock;
};
template
struct WGuard
{
WGuard(MUTEX &l) : i_lock(l.getWriteLock()) {}
Trinity::GeneralLock i_lock;
};
typedef RGuard GridReadGuard;
typedef WGuard GridWriteGuard;
typedef Trinity::SingleThreaded::Lock NullGuard;
typedef struct
{
uint16 area_flag[16][16];
uint8 terrain_type[16][16];
float liquid_level[128][128];
float Z[MAP_RESOLUTION][MAP_RESOLUTION];
}GridMap;
struct CreatureMover
{
CreatureMover() : x(0), y(0), z(0), ang(0) {}
CreatureMover(float _x, float _y, float _z, float _ang) : x(_x), y(_y), z(_z), ang(_ang) {}
float x, y, z, ang;
};
// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform
#if defined( __GNUC__ )
#pragma pack(1)
#else
#pragma pack(push,1)
#endif
struct InstanceTemplate
{
uint32 map;
uint32 parent;
uint32 levelMin;
uint32 levelMax;
uint32 maxPlayers;
uint32 reset_delay;
float startLocX;
float startLocY;
float startLocZ;
float startLocO;
char const* script;
};
enum LevelRequirementVsMode
{
LEVELREQUIREMENT_HEROIC = 70
};
#if defined( __GNUC__ )
#pragma pack()
#else
#pragma pack(pop)
#endif
typedef HM_NAMESPACE::hash_map CreatureMoveList;
#define MAX_HEIGHT 100000.0f // can be use for find ground height at surface
#define INVALID_HEIGHT -100000.0f // for check, must be equal to VMAP_INVALID_HEIGHT, real value for unknown height is VMAP_INVALID_HEIGHT_VALUE
#define MIN_UNLOAD_DELAY 1 // immediate unload
class TRINITY_DLL_SPEC Map : public GridRefManager, public Trinity::ObjectLevelLockable