ScummVM API documentation
map.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_MAP_H
23#define ULTIMA3_DATA_MAP_H
24
25#include "common/scummsys.h"
26#include "common/serializer.h"
27
28namespace Ultima {
29namespace Ultima3 {
30namespace Data {
31
32constexpr int MAP_SIZE = 64;
33constexpr int CREATURE_COUNT = 32;
34
40struct Creatures {
41 byte _tile[CREATURE_COUNT] = {};
42 byte _floor[CREATURE_COUNT] = {};
43 byte _x[CREATURE_COUNT] = {};
44 byte _y[CREATURE_COUNT] = {};
45
46 // The top two bits give how it behaves, and the rest what a person says
47 byte _flags[CREATURE_COUNT] = {};
48};
49
55class Map {
56private:
57 static const int TEXT_SIZE = 0x180;
58 static const int EXTRA_SIZE = 8;
59
60 byte _cells[MAP_SIZE * MAP_SIZE] = {};
61
62 // The offsets of the things said in a town, followed by the things
63 byte _text[TEXT_SIZE] = {};
64
65 // The whirlpool and moon phases on the overworld
66 byte _extra[EXTRA_SIZE] = {};
67
68 void synchronizeData(Common::Serializer &s);
69
70public:
71 Creatures _creatures;
72
77 byte &extra(int index) {
78 return _extra[index];
79 }
80
84 static bool exists(const char *filename);
85
89 void load(const char *filename);
90
96
101
102 void synchronize(Common::Serializer &s);
103
107 byte cell(int x, int y) const {
108 return _cells[(y & (MAP_SIZE - 1)) * MAP_SIZE + (x & (MAP_SIZE - 1))];
109 }
110
111 void setCell(int x, int y, byte value) {
112 _cells[(y & (MAP_SIZE - 1)) * MAP_SIZE + (x & (MAP_SIZE - 1))] = value;
113 }
114
119 const char *text(int index) const;
120
124 byte tile(int x, int y) const {
125 return cell(x, y) >> 2;
126 }
127};
128
129} // namespace Data
130} // namespace Ultima3
131} // namespace Ultima
132
133#endif
Definition: stream.h:745
Definition: serializer.h:80
Definition: stream.h:77
Definition: map.h:55
static bool exists(const char *filename)
void save(Common::WriteStream &dest)
bool load(Common::SeekableReadStream &src)
byte cell(int x, int y) const
Definition: map.h:107
byte & extra(int index)
Definition: map.h:77
byte tile(int x, int y) const
Definition: map.h:124
void load(const char *filename)
const char * text(int index) const