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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef ULTIMA4_MAP_LOCATION_H 24 #define ULTIMA4_MAP_LOCATION_H 25 26 #include "ultima/ultima4/map/map.h" 27 #include "ultima/ultima4/map/movement.h" 28 #include "ultima/ultima4/core/observable.h" 29 #include "ultima/ultima4/core/types.h" 30 31 namespace Ultima { 32 namespace Ultima4 { 33 34 typedef enum { 35 CTX_WORLDMAP = 0x0001, 36 CTX_COMBAT = 0x0002, 37 CTX_CITY = 0x0004, 38 CTX_DUNGEON = 0x0008, 39 CTX_ALTAR_ROOM = 0x0010, 40 CTX_SHRINE = 0x0020 41 } LocationContext; 42 43 #define CTX_ANY (LocationContext)(0xffff) 44 #define CTX_NORMAL (LocationContext)(CTX_WORLDMAP | CTX_CITY) 45 #define CTX_NON_COMBAT (LocationContext)(CTX_ANY & ~CTX_COMBAT) 46 #define CTX_CAN_SAVE_GAME (LocationContext)(CTX_WORLDMAP | CTX_DUNGEON) 47 48 class TurnCompleter; 49 50 class Location : public Observable<Location *, MoveEvent &> { 51 public: 52 /** 53 * Add a new location to the stack, or start a new stack if 'prev' is nullptr 54 */ 55 Location(MapCoords coords, Map *map, int viewmode, LocationContext ctx, TurnCompleter *turnCompleter, Location *prev); 56 57 /** 58 * Return the entire stack of objects at the given location. 59 */ 60 Std::vector<MapTile> tilesAt(MapCoords coords, bool &focus); 61 62 /** 63 * Finds a valid replacement tile for the given location, using surrounding tiles 64 * as guidelines to choose the new tile. The new tile will only be chosen if it 65 * is marked as a valid replacement (or waterReplacement) tile in tiles.xml. If a valid replacement 66 * cannot be found, it returns a "best guess" tile. 67 */ 68 TileId getReplacementTile(MapCoords atCoords, Tile const *forTile); 69 70 /** 71 * Returns the current coordinates of the location given: 72 * If in combat - returns the coordinates of party member with focus 73 * If elsewhere - returns the coordinates of the avatar 74 */ 75 int getCurrentPosition(MapCoords *coords); 76 MoveResult move(Direction dir, bool userEvent); 77 78 MapCoords _coords; 79 Map *_map; 80 int _viewMode; 81 LocationContext _context; 82 TurnCompleter *_turnCompleter; 83 Location *_prev; 84 }; 85 86 /** 87 * Pop a location from the stack and free the memory 88 */ 89 void locationFree(Location **stack); 90 91 } // End of namespace Ultima4 92 } // End of namespace Ultima 93 94 #endif 95