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 #include "ultima/ultima1/widgets/overworld_widget.h"
24 #include "ultima/ultima1/maps/map_base.h"
25 #include "ultima/ultima1/maps/map_tile.h"
26 #include "ultima/ultima1/core/resources.h"
27 #include "ultima/ultima1/game.h"
28 #include "ultima/shared/early/ultima_early.h"
29 
30 namespace Ultima {
31 namespace Ultima1 {
32 namespace Widgets {
33 
getGame() const34 Ultima1Game *OverworldWidget::getGame() const {
35 	return static_cast<Ultima1Game *>(_game);
36 }
37 
getMap() const38 Maps::MapBase *OverworldWidget::getMap() const {
39 	return static_cast<Maps::MapBase *>(_map);
40 }
41 
synchronize(Common::Serializer & s)42 void OverworldWidget::synchronize(Common::Serializer &s) {
43 	MapWidget::synchronize(s);
44 	s.syncAsUint16LE(_tileNum);
45 }
46 
canMoveTo(const Point & destPos)47 Shared::Maps::MapWidget::CanMove OverworldWidget::canMoveTo(const Point &destPos) {
48 	Shared::Maps::MapWidget::CanMove result = Shared::Maps::MapWidget::canMoveTo(destPos);
49 	if (result != Shared::Maps::MapWidget::UNSET)
50 		return result;
51 
52 	Maps::U1MapTile tile;
53 	getMap()->getTileAt(destPos, &tile);
54 
55 	// Default mobility for most monsters and transports is overland only
56 	return tile.isGround() ? Shared::Maps::MapWidget::YES : Shared::Maps::MapWidget::NO;
57 }
58 
59 
60 } // End of namespace Widgets
61 } // End of namespace Ultima1
62 } // End of namespace Ultima
63