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 ULTIMA2_DATA_MAP_H
23#define ULTIMA2_DATA_MAP_H
24
25#include "common/array.h"
26#include "common/hash-str.h"
27#include "common/serializer.h"
28#include "common/str.h"
29#include "ultima/ultima2/data/tiles.h"
30#include "ultima/ultima2/data/map_monsters.h"
31
32namespace Ultima {
33namespace Ultima2 {
34namespace Data {
35
36constexpr int MAP_WIDTH = 64;
37constexpr int MAP_HEIGHT = 64;
38
39// Both build "MAPXnn"/"MONXnn" from the same two map-number digits
40Common::String mapFilename(int mapEra, int mapType);
41Common::String monsterFilename(int mapEra, int mapType);
42Common::String talkFilename(int mapEra, int mapType);
43
50struct Map {
51 TileId _tiles[MAP_HEIGHT][MAP_WIDTH] = {};
52 MapMonsters _monsters;
54
55private:
61 struct SavedMap {
62 byte _tiles[MAP_HEIGHT][MAP_WIDTH];
63 MapMonsters _monsters;
64 };
66
67 void loadTalk(int mapEra, int mapType);
68
72 void loadDungeon(int mapEra, int mapType);
73
78 void showMapView(const Common::String &mapViewName);
79
80public:
81 void load(int mapEra, int mapType);
82
92 bool canLoad(int mapEra, int mapType) const;
93
99 void synchronize(Common::Serializer &s, bool isDungeon);
100
106
110 void clearSaved() {
111 _saved.clear();
112 }
113
118
123 Common::String talkString(int index) const {
124 return (index >= 0 && index < (int)_talk.size()) ? _talk[index] : Common::String();
125 }
126
127 TileId tileAt(int x, int y) const {
128 return _tiles[y][x];
129 }
130};
131
132} // namespace Data
133} // namespace Ultima2
134} // namespace Ultima
135
136#endif
size_type size() const
Definition: array.h:316
Definition: serializer.h:80
Definition: str.h:59
void clear(bool shrinkArray=0)
Definition: hashmap.h:431
Definition: map.h:50
void synchronizeSaved(Common::Serializer &s)
Common::String talkString(int index) const
Definition: map.h:123
void clearSaved()
Definition: map.h:110
bool canLoad(int mapEra, int mapType) const
void synchronize(Common::Serializer &s, bool isDungeon)
Definition: map_monsters.h:40