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 HDB_MAP_H
23 #define HDB_MAP_H
24 
25 namespace HDB {
26 
27 enum {
28  kMaxGratings = 250,
29  kMaxForegrounds = 250
30 };
31 
32 struct MSMIcon {
33  uint16 icon; // index into icon list
34  uint16 x;
35  uint16 y;
36 
37  char funcInit[32]; // Lua init function for this entity
38  char funcAction[32];
39  char funcUse[32];
40  uint16 dir; // direction entity is facing
41  uint16 level; // which floor level entity is on
42  uint16 value1, value2;
43 
44  MSMIcon(): icon(0), x(0), y(0), dir(0), level(0), value1(0), value2(0) {
45  funcInit[0] = 0;
46  funcAction[0] = 0;
47  funcUse[0] = 0;
48  }
49 };
50 
51 struct Foreground {
52  uint16 x;
53  uint16 y;
54  uint16 tile;
55 
56  Foreground() : x(0), y(0), tile(0) {}
57 };
58 
60  uint16 x;
61  uint16 y;
62  uint16 tile;
63 
64  SeeThroughTile() : x(0), y(0), tile(0) {}
65 };
66 
67 class Map {
68 public:
69  Map();
70  ~Map();
71 
72  void save(Common::OutSaveFile *out);
73  void loadSaveFile(Common::InSaveFile *in);
74  void restartSystem();
75 
76  int loadTiles();
77  bool load(Common::SeekableReadStream *stream);
78  bool loadMap(char *name);
79  void draw();
80  void drawEnts();
81  void drawGratings();
82  void drawForegrounds();
83 
84  bool isLoaded() {
85  return _mapLoaded;
86  }
87 
88  bool onScreen(int x, int y);
89  int mapPixelWidth() {
90  return _width * kTileWidth;
91  }
92  int mapPixelHeight() {
93  return _height * kTileHeight;
94  }
95 
96  uint32 getMapBGTileFlags(int x, int y);
97  uint32 getMapFGTileFlags(int x, int y);
98  int16 getMapBGTileIndex(int x, int y);
99  int16 getMapFGTileIndex(int x, int y);
100  void setMapBGTileIndex(int x, int y, int index);
101  void setMapFGTileIndex(int x, int y, int index);
102  void addBGTileAnimation(int x, int y);
103  void addFGTileAnimation(int x, int y);
104  void removeBGTileAnimation(int x, int y);
105  void removeFGTileAnimation(int x, int y);
106 
107  void getMapXY(int *x, int *y);
108  void setMapXY(int x, int y);
109  void centerMapXY(int x, int y);
110  bool checkEntOnScreen(AIEntity *);
111  bool checkXYOnScreen(int x, int y);
112 
113  // Check if one of the tiles in a range exists in the map on either layer
114  bool checkOneTileExistInRange(int tileIndex, int count);
115 
116  bool explosionExist(int x, int y) {
117  return _mapExplosions[y * _width + x];
118  }
119  void setExplosion(int x, int y, int value) {
120  _mapExplosions[y * _width + x] = value;
121  }
122 
123  bool boomBarrelExist(int x, int y) {
124  return _mapExpBarrels[y * _width + x];
125  }
126  void setBoomBarrel(int x, int y, int value) {
127  _mapExpBarrels[y * _width + x] = value;
128  }
129 
130  bool laserBeamExist(int x, int y) {
131  return _mapLaserBeams[y * _width + x];
132  }
133  void setLaserBeam(int x, int y, int value) {
134  _mapLaserBeams[y * _width + x] = value;
135  }
136  void clearLaserBeams() {
137  uint size = _width * _height;
138  memset(_mapLaserBeams, 0, size);
139  }
140 
141  // Platform-specific Constants;
142  int _screenXTiles;
143  int _screenYTiles;
144  int _screenTileWidth;
145  int _screenTileHeight;
146 
147  uint16 _width, _height;
148  int _mapX, _mapY; // Coordinates of Map
149  int _mapTileX, _mapTileY; // Tile Coordinates of Map
150  int _mapTileXOff, _mapTileYOff; // Tile Coordinates Offset (0-31)
151 
152  Foreground _gratings[kMaxGratings], _foregrounds[kMaxForegrounds];
153  int _numGratings, _numForegrounds;
154 
155  int _animCycle; // Tile Animation Counter
156  Common::Array<uint32> _listBGAnimSlow;
157  Common::Array<uint32> _listBGAnimMedium;
158  Common::Array<uint32> _listBGAnimFast;
159  Common::Array<uint32> _listFGAnimSlow;
160  Common::Array<uint32> _listFGAnimMedium;
161  Common::Array<uint32> _listFGAnimFast;
162 
163 private:
164  char _name[32];
165  uint32 _backgroundOffset;
166  uint32 _foregroundOffset;
167  uint16 _iconNum;
168  uint32 _iconListOffset;
169  uint16 _infoNum;
170  uint32 _infoListOffset;
171 
172  int16 *_background;
173  int16 *_foreground;
174  MSMIcon *_iconList;
175 
176  byte *_mapExplosions;
177  byte *_mapExpBarrels;
178  byte *_mapLaserBeams;
179 
180  bool _mapLoaded;
181 };
182 }
183 
184 #endif // !HDB_MAP_H
Definition: ai-player.h:25
Definition: savefile.h:54
Definition: map.h:51
Definition: stream.h:745
Definition: ai.h:388
Definition: map.h:32
Definition: map.h:67
Definition: map.h:59