aboutsummaryrefslogtreecommitdiff
path: root/src/common/Collision/Maps/MapDefines.h
blob: c95fa1ede2a8aa305f483f3834172d85ca0a3427 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
 *
 * 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, see <http://www.gnu.org/licenses/>.
 */

#ifndef MapDefines_h__
#define MapDefines_h__

#include "Define.h"
#include "EnumFlag.h"
#include <array>

/// Represents a map magic value of 4 bytes (used in versions)
using u_map_magic = std::array<char, 4>;

TC_COMMON_API extern u_map_magic const MapMagic;
TC_COMMON_API extern uint32 const MapVersionMagic;
TC_COMMON_API extern u_map_magic const MapAreaMagic;
TC_COMMON_API extern u_map_magic const MapHeightMagic;
TC_COMMON_API extern u_map_magic const MapLiquidMagic;

// ******************************************
// Map file format defines
// ******************************************
struct map_fileheader
{
    u_map_magic mapMagic;
    uint32 versionMagic;
    uint32 buildMagic;
    uint32 areaMapOffset;
    uint32 areaMapSize;
    uint32 heightMapOffset;
    uint32 heightMapSize;
    uint32 liquidMapOffset;
    uint32 liquidMapSize;
    uint32 holesOffset;
    uint32 holesSize;
};

enum class map_areaHeaderFlags : uint16
{
    None    = 0x0000,
    NoArea  = 0x0001
};

DEFINE_ENUM_FLAG(map_areaHeaderFlags);

struct map_areaHeader
{
    u_map_magic areaMagic;
    EnumFlag<map_areaHeaderFlags> flags = map_areaHeaderFlags::None;
    uint16 gridArea;
};

enum class map_heightHeaderFlags : uint32
{
    None            = 0x0000,
    NoHeight        = 0x0001,
    HeightAsInt16   = 0x0002,
    HeightAsInt8    = 0x0004,
    HasFlightBounds = 0x0008
};

DEFINE_ENUM_FLAG(map_heightHeaderFlags);

struct map_heightHeader
{
    u_map_magic heightMagic;
    EnumFlag<map_heightHeaderFlags> flags = map_heightHeaderFlags::None;
    float  gridHeight;
    float  gridMaxHeight;
};

enum class map_liquidHeaderFlags : uint8
{
    None        = 0x0000,
    NoType      = 0x0001,
    NoHeight    = 0x0002
};

DEFINE_ENUM_FLAG(map_liquidHeaderFlags);

enum class map_liquidHeaderTypeFlags : uint8
{
    NoWater     = 0x00,
    Water       = 0x01,
    Ocean       = 0x02,
    Magma       = 0x04,
    Slime       = 0x08,

    DarkWater   = 0x10,

    AllLiquids  = Water | Ocean | Magma | Slime
};

DEFINE_ENUM_FLAG(map_liquidHeaderTypeFlags);

struct map_liquidHeader
{
    u_map_magic liquidMagic;
    EnumFlag<map_liquidHeaderFlags> flags = map_liquidHeaderFlags::None;
    EnumFlag<map_liquidHeaderTypeFlags> liquidFlags = map_liquidHeaderTypeFlags::NoWater;
    uint16 liquidType;
    uint8  offsetX;
    uint8  offsetY;
    uint8  width;
    uint8  height;
    float  liquidLevel;
};

#endif // MapDefines_h__