ScummVM API documentation
dungeon.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef ULTIMA3_DATA_DUNGEON_H
23#define ULTIMA3_DATA_DUNGEON_H
24
25#include "common/scummsys.h"
26#include "common/serializer.h"
27
28namespace Ultima {
29namespace Ultima3 {
30namespace Data {
31
32constexpr int DUNGEON_LEVELS = 8;
33constexpr int DUNGEON_SIZE = 16;
34
35// Kinds of dungeon square, held in the low bits of a tile
36constexpr byte DTILE_TIME_LORD = 1;
37constexpr byte DTILE_FOUNTAIN = 2;
38constexpr byte DTILE_WIND = 3;
39constexpr byte DTILE_TRAP = 4;
40constexpr byte DTILE_MARK = 5;
41constexpr byte DTILE_GREMLINS = 6;
42constexpr byte DTILE_SIGN = 8;
43
44// Flags in the bits above those
45constexpr byte DTILE_LADDER_UP = 0x10;
46constexpr byte DTILE_LADDER_DOWN = 0x20;
47constexpr byte DTILE_CHEST = 0x40;
48constexpr byte DTILE_WALL = 0x80;
49constexpr byte DTILE_DOOR = 0xC0;
50
54class Dungeon {
55private:
56 static const int SIGNS_SIZE = 0x90;
57
58 byte _tiles[DUNGEON_LEVELS * DUNGEON_SIZE * DUNGEON_SIZE] = {};
59 byte _signs[SIGNS_SIZE] = {};
60
61public:
65 void load(const char *filename);
66
67 void synchronize(Common::Serializer &s);
68
72 byte tile(int level, int x, int y) const {
73 return _tiles[(level << 8) + ((y & (DUNGEON_SIZE - 1)) << 4) + (x & (DUNGEON_SIZE - 1))];
74 }
75
76 void setTile(int level, int x, int y, byte value) {
77 _tiles[(level << 8) + ((y & (DUNGEON_SIZE - 1)) << 4) + (x & (DUNGEON_SIZE - 1))] = value;
78 }
79
83 const char *sign(int level) const;
84};
85
86} // namespace Data
87} // namespace Ultima3
88} // namespace Ultima
89
90#endif
Definition: serializer.h:80
Definition: dungeon.h:54
void load(const char *filename)
const char * sign(int level) const
byte tile(int level, int x, int y) const
Definition: dungeon.h:72