[Scummvm-git-logs] scummvm master -> cb846751182a17e33591aa1a28cb4c622292d995
dreammaster
paulfgilbert at gmail.com
Thu Apr 23 04:41:08 UTC 2020
This automated email contains information about 7 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
3dc6403a41 ULTIMA4: Janitorial
f5c5f15a93 ULTIMA4: Split MapTile into it's own source file
ae0f99f9ce ULTIMA4: Simplify mouse areas array to remove button commands
56585cb814 ULTIMA4: Remove custom keycode defines
2004e2740c ULTIMA4: Renamed event.cpp to event_handler.cpp
9518991e2f ULTIMA4: Repeated walk when right mouse button is pressed
cb84675118 ULTIMA4: Remove unused settings
Commit: 3dc6403a41199e4dfca90ad39b877cb3ed7d16b3
https://github.com/scummvm/scummvm/commit/3dc6403a41199e4dfca90ad39b877cb3ed7d16b3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-22T21:38:51-07:00
Commit Message:
ULTIMA4: Janitorial
Changed paths:
engines/ultima/ultima4/core/types.h
engines/ultima/ultima4/map/annotation.cpp
engines/ultima/ultima4/map/annotation.h
engines/ultima/ultima4/map/city.cpp
engines/ultima/ultima4/map/city.h
engines/ultima/ultima4/map/direction.cpp
engines/ultima/ultima4/map/direction.h
engines/ultima/ultima4/map/dungeon.cpp
engines/ultima/ultima4/map/dungeon.h
engines/ultima/ultima4/map/dungeonview.cpp
engines/ultima/ultima4/map/location.cpp
engines/ultima/ultima4/map/location.h
engines/ultima/ultima4/map/map.cpp
engines/ultima/ultima4/map/maploader.cpp
engines/ultima/ultima4/map/mapmgr.cpp
engines/ultima/ultima4/map/movement.cpp
engines/ultima/ultima4/map/movement.h
engines/ultima/ultima4/map/shrine.cpp
engines/ultima/ultima4/map/shrine.h
engines/ultima/ultima4/map/tile.cpp
engines/ultima/ultima4/map/tileanim.cpp
engines/ultima/ultima4/map/tilemap.cpp
engines/ultima/ultima4/map/tileset.cpp
diff --git a/engines/ultima/ultima4/core/types.h b/engines/ultima/ultima4/core/types.h
index bf9a47306a..e22f112998 100644
--- a/engines/ultima/ultima4/core/types.h
+++ b/engines/ultima/ultima4/core/types.h
@@ -71,30 +71,30 @@ public:
MapTile(const TileId &i, byte f = 0) : _id(i), _frame(f), _freezeAnimation(false) {}
MapTile(const MapTile &t) : _id(t._id), _frame(t._frame), _freezeAnimation(t._freezeAnimation) {}
- TileId getId() const {
+ TileId getId() const {
return _id;
}
- byte getFrame() const {
+ byte getFrame() const {
return _frame;
}
bool getFreezeAnimation() const {
return _freezeAnimation;
}
- bool operator==(const MapTile &m) const {
+ bool operator==(const MapTile &m) const {
return _id == m._id;
}
- bool operator==(const TileId &i) const {
+ bool operator==(const TileId &i) const {
return _id == i;
}
- bool operator!=(const MapTile &m) const {
+ bool operator!=(const MapTile &m) const {
return _id != m._id;
}
- bool operator!=(const TileId &i) const {
+ bool operator!=(const TileId &i) const {
return _id != i;
}
- bool operator<(const MapTile &m) const {
- return _id < m._id; /* for Std::less */
+ bool operator<(const MapTile &m) const {
+ return _id < m._id; // for Std::less
}
/**
diff --git a/engines/ultima/ultima4/map/annotation.cpp b/engines/ultima/ultima4/map/annotation.cpp
index a4e8fd809d..129967218a 100644
--- a/engines/ultima/ultima4/map/annotation.cpp
+++ b/engines/ultima/ultima4/map/annotation.cpp
@@ -30,12 +30,6 @@
namespace Ultima {
namespace Ultima4 {
-/**
- * Annotation class implementation
- */
-/**
- * Constructors
- */
Annotation::Annotation(const Coords &pos, MapTile t, bool v, bool coverUp) :
_coords(pos),
_tile(t),
@@ -44,9 +38,6 @@ Annotation::Annotation(const Coords &pos, MapTile t, bool v, bool coverUp) :
_coverUp(coverUp) {
}
-/**
- * Members
- */
void Annotation::debug_output() const {
debug(1, "x: %d\n", _coords.x);
debug(1, "y: %d\n", _coords.y);
@@ -55,9 +46,6 @@ void Annotation::debug_output() const {
debug(1, "visual: %s\n", _visual ? "Yes" : "No");
}
-/**
- * Operators
- */
bool Annotation::operator==(const Annotation &a) const {
return ((_coords == a.getCoords()) && (_tile == a._tile)) ? true : false;
}
@@ -67,7 +55,7 @@ bool Annotation::operator==(const Annotation &a) const {
AnnotationMgr::AnnotationMgr() {}
Annotation *AnnotationMgr::add(Coords coords, MapTile tile, bool visual, bool isCoverUp) {
- /* new annotations go to the front so they're handled "on top" */
+ // New annotations go to the front so they're handled "on top"
_annotations.push_front(Annotation(coords, tile, visual, isCoverUp));
return &_annotations.front();
}
diff --git a/engines/ultima/ultima4/map/annotation.h b/engines/ultima/ultima4/map/annotation.h
index 6c5d96007d..019bce4767 100644
--- a/engines/ultima/ultima4/map/annotation.h
+++ b/engines/ultima/ultima4/map/annotation.h
@@ -48,37 +48,72 @@ public:
void debug_output() const;
// Getters
+ /**
+ * Returns the coordinates of the annotation
+ */
const Coords &getCoords() const {
- return _coords; /**< Returns the coordinates of the annotation */
+ return _coords;
}
- MapTile &getTile() {
- return _tile; /**< Returns the annotation's tile */
+
+ /**
+ * Returns the annotation's tile
+ */
+ MapTile &getTile() {
+ return _tile;
}
+
+ /**
+ * Returns true for visual-only annotations
+ */
bool isVisualOnly() const {
- return _visual; /**< Returns true for visual-only annotations */
+ return _visual;
}
- int getTTL() const {
- return _ttl; /**< Returns the number of turns the annotation has left to live */
+
+ /**
+ * Returns the number of turns the annotation has left to live
+ */
+ int getTTL() const {
+ return _ttl;
}
- bool isCoverUp() {
+
+ bool isCoverUp() const {
return _coverUp;
}
// Setters
+ /**
+ * Sets the coordinates for the annotation
+ */
void setCoords(const Coords &c) {
- _coords = c; /**< Sets the coordinates for the annotation */
+ _coords = c;
}
- void setTile(const MapTile &t) {
- _tile = t; /**< Sets the tile for the annotation */
+
+ /**
+ * Sets the tile for the annotation
+ */
+ void setTile(const MapTile &t) {
+ _tile = t;
}
- void setVisualOnly(bool v) {
- _visual = v; /**< Sets whether or not the annotation is visual-only */
+
+ /**
+ * Sets whether or not the annotation is visual-only
+ */
+ void setVisualOnly(bool v) {
+ _visual = v;
}
- void setTTL(int turns) {
- _ttl = turns; /**< Sets the number of turns the annotation will live */
+
+ /**
+ * Sets the number of turns the annotation will live
+ */
+ void setTTL(int turns) {
+ _ttl = turns;
}
- void passTurn() {
- if (_ttl > 0) _ttl--; /**< Passes a turn for the annotation */
+
+ /**
+ * Passes a turn for the annotation
+ */
+ void passTurn() {
+ if (_ttl > 0) _ttl--;
}
bool operator==(const Annotation &) const;
diff --git a/engines/ultima/ultima4/map/city.cpp b/engines/ultima/ultima4/map/city.cpp
index 82e63b95f3..6f252b1512 100644
--- a/engines/ultima/ultima4/map/city.cpp
+++ b/engines/ultima/ultima4/map/city.cpp
@@ -36,7 +36,6 @@ using Common::String;
City::City() : Map() {
}
-
City::~City() {
for (PersonList::iterator i = _persons.begin(); i != _persons.end(); i++)
delete *i;
@@ -56,7 +55,7 @@ Person *City::addPerson(Person *person) {
// forgotten the next time you visit :)
Person *p = new Person(person);
- /* set the start coordinates for the person */
+ // Set the start coordinates for the person
p->setMap(this);
p->goToStartLocation();
@@ -99,10 +98,7 @@ Person *City::personAt(const Coords &coords) {
return nullptr;
}
-/**
- * Returns true if the Map pointed to by 'punknown'
- * is a City map
- */
+
bool isCity(Map *punknown) {
City *pCity;
if ((pCity = dynamic_cast<City *>(punknown)) != nullptr)
diff --git a/engines/ultima/ultima4/map/city.h b/engines/ultima/ultima4/map/city.h
index ec1ea9599a..f2a74542a5 100644
--- a/engines/ultima/ultima4/map/city.h
+++ b/engines/ultima/ultima4/map/city.h
@@ -81,6 +81,10 @@ public:
Std::vector<Dialogue *> _extraDialogues;
};
+/**
+ * Returns true if the Map pointed to by 'punknown'
+ * is a City map
+ */
bool isCity(Map *punknown);
} // End of namespace Ultima4
diff --git a/engines/ultima/ultima4/map/direction.cpp b/engines/ultima/ultima4/map/direction.cpp
index ea1f1fcb8f..236fccdbdf 100644
--- a/engines/ultima/ultima4/map/direction.cpp
+++ b/engines/ultima/ultima4/map/direction.cpp
@@ -74,11 +74,6 @@ Direction dirRotateCCW(Direction dir) {
return dir;
}
-/**
- * Returns the a mask containing the broadsides directions for a given direction.
- * For instance, dirGetBroadsidesDirs(DIR_NORTH) returns:
- * (MASK_DIR(DIR_WEST) | MASK_DIR(DIR_EAST))
- */
int dirGetBroadsidesDirs(Direction dir) {
int dirmask = MASK_DIR_ALL;
dirmask = DIR_REMOVE_FROM_MASK(dir, dirmask);
@@ -87,10 +82,6 @@ int dirGetBroadsidesDirs(Direction dir) {
return dirmask;
}
-/**
- * Returns a random direction from a provided mask of available
- * directions.
- */
Direction dirRandomDir(int valid_directions_mask) {
int i, n;
Direction d[4];
@@ -109,12 +100,6 @@ Direction dirRandomDir(int valid_directions_mask) {
return d[xu4_random(n)];
}
-/**
- * Normalizes the direction based on the orientation given
- * (if facing west, and 'up' is pressed, the 'up' is translated
- * into DIR_NORTH -- this function tranlates that direction
- * to DIR_WEST, the correct direction in this case).
- */
Direction dirNormalize(Direction orientation, Direction dir) {
Direction temp = orientation,
realDir = dir;
@@ -127,9 +112,6 @@ Direction dirNormalize(Direction orientation, Direction dir) {
return realDir;
}
-/**
- * Translates a keyboard code into a direction
- */
Direction keyToDirection(int key) {
switch (key) {
case U4_UP:
@@ -145,9 +127,6 @@ Direction keyToDirection(int key) {
}
}
-/**
- * Translates a direction into a keyboard code
- */
int directionToKey(Direction dir) {
switch (dir) {
case DIR_WEST:
diff --git a/engines/ultima/ultima4/map/direction.h b/engines/ultima/ultima4/map/direction.h
index 5b46915a92..55013c85d5 100644
--- a/engines/ultima/ultima4/map/direction.h
+++ b/engines/ultima/ultima4/map/direction.h
@@ -53,10 +53,36 @@ Direction dirReverse(Direction dir);
Direction dirFromMask(int dir_mask);
Direction dirRotateCW(Direction dir);
Direction dirRotateCCW(Direction dir);
+
+/**
+ * Returns the a mask containing the broadsides directions for a given direction.
+ * For instance, dirGetBroadsidesDirs(DIR_NORTH) returns:
+ * (MASK_DIR(DIR_WEST) | MASK_DIR(DIR_EAST))
+ */
int dirGetBroadsidesDirs(Direction dir);
+
+/**
+ * Returns a random direction from a provided mask of available
+ * directions.
+ */
Direction dirRandomDir(int valid_directions_mask);
+
+/**
+ * Normalizes the direction based on the orientation given
+ * (if facing west, and 'up' is pressed, the 'up' is translated
+ * into DIR_NORTH -- this function tranlates that direction
+ * to DIR_WEST, the correct direction in this case).
+ */
Direction dirNormalize(Direction orientation, Direction dir);
+
+/**
+ * Translates a keyboard code into a direction
+ */
Direction keyToDirection(int key);
+
+/**
+ * Translates a direction into a keyboard code
+ */
int directionToKey(Direction dir);
} // End of namespace Ultima4
diff --git a/engines/ultima/ultima4/map/dungeon.cpp b/engines/ultima/ultima4/map/dungeon.cpp
index 0d67dc6c18..c2b5130d7a 100644
--- a/engines/ultima/ultima4/map/dungeon.cpp
+++ b/engines/ultima/ultima4/map/dungeon.cpp
@@ -36,9 +36,6 @@
namespace Ultima {
namespace Ultima4 {
-/**
- * Returns true if 'map' points to a dungeon map
- */
bool isDungeon(Map *punknown) {
Dungeon *pd;
if ((pd = dynamic_cast<Dungeon *>(punknown)) != nullptr)
@@ -82,10 +79,6 @@ DungeonToken Dungeon::currentToken() {
return tokenAt(g_context->_location->_coords);
}
-/**
- * Return the dungeon sub-token associated with the given dungeon tile.
- *
- */
byte Dungeon::currentSubToken() {
return subTokenAt(g_context->_location->_coords);
}
@@ -99,9 +92,6 @@ byte Dungeon::subTokenAt(MapCoords coords) {
return _dataSubTokens[index];
}
-/**
- * Handles 's'earching while in dungeons
- */
void dungeonSearch(void) {
Dungeon *dungeon = dynamic_cast<Dungeon *>(g_context->_location->_map);
DungeonToken token = dungeon->currentToken();
@@ -141,9 +131,6 @@ void dungeonSearch(void) {
}
}
-/**
- * Drink from the fountain at the current location
- */
void dungeonDrinkFountain() {
g_screen->screenMessage("You find a Fountain.\nWho drinks? ");
int player = gameGetPlayer(false, false);
@@ -194,9 +181,6 @@ void dungeonDrinkFountain() {
}
}
-/**
- * Touch the magical ball at the current location
- */
void dungeonTouchOrb() {
g_screen->screenMessage("You find a Magical Ball...\nWho touches? ");
int player = gameGetPlayer(false, false);
@@ -259,9 +243,6 @@ void dungeonTouchOrb() {
g_context->_location->_map->_annotations->add(g_context->_location->_coords, replacementTile);
}
-/**
- * Handles dungeon traps
- */
bool dungeonHandleTrap(TrapType trap) {
Dungeon *dungeon = dynamic_cast<Dungeon *>(g_context->_location->_map);
switch ((TrapType)dungeon->currentSubToken()) {
diff --git a/engines/ultima/ultima4/map/dungeon.h b/engines/ultima/ultima4/map/dungeon.h
index 7240ee81b1..f42fa361e0 100644
--- a/engines/ultima/ultima4/map/dungeon.h
+++ b/engines/ultima/ultima4/map/dungeon.h
@@ -170,11 +170,29 @@ enum FieldType {
FIELD_SLEEP = 0x3
};
+/**
+ * Handles 's'earching while in dungeons
+ */
void dungeonSearch();
+
+/**
+ * Drink from the fountain at the current location
+ */
void dungeonDrinkFountain();
+
+/**
+ * Touch the magical ball at the current location
+ */
void dungeonTouchOrb();
+
+/**
+ * Handles dungeon traps
+ */
bool dungeonHandleTrap(TrapType trap);
+/**
+ * Returns true if 'map' points to a dungeon map
+ */
bool isDungeon(Map *punknown);
} // End of namespace Ultima4
diff --git a/engines/ultima/ultima4/map/dungeonview.cpp b/engines/ultima/ultima4/map/dungeonview.cpp
index e62d2154fa..6bda03cb18 100644
--- a/engines/ultima/ultima4/map/dungeonview.cpp
+++ b/engines/ultima/ultima4/map/dungeonview.cpp
@@ -34,12 +34,12 @@
namespace Ultima {
namespace Ultima4 {
+DungeonView *DungeonView::_instance = nullptr;
+
DungeonView::DungeonView(int x, int y, int columns, int rows) : TileView(x, y, rows, columns)
, screen3dDungeonViewEnabled(true) {
}
-
-DungeonView *DungeonView::_instance(nullptr);
DungeonView *DungeonView::getInstance() {
if (!_instance) {
_instance = new DungeonView(BORDER_WIDTH, BORDER_HEIGHT, VIEWPORT_W, VIEWPORT_H);
@@ -50,9 +50,9 @@ DungeonView *DungeonView::getInstance() {
void DungeonView::display(Context *c, TileView *view) {
int x, y;
- /* 1st-person perspective */
+ // 1st-person perspective
if (screen3dDungeonViewEnabled) {
- //Note: This shouldn't go above 4, unless we check opaque tiles each step of the way.
+ // Note: This shouldn't go above 4, unless we check opaque tiles each step of the way.
const int farthest_non_wall_tile_visibility = 4;
Std::vector<MapTile> tiles;
@@ -62,7 +62,7 @@ void DungeonView::display(Context *c, TileView *view) {
for (y = 3; y >= 0; y--) {
DungeonGraphicType type;
- //FIXME: Maybe this should be in a loop
+ // FIXME: Maybe this should be in a loop
tiles = getTiles(y, -1);
type = tilesToGraphic(tiles);
drawWall(-1, y, (Direction)g_ultima->_saveGame->_orientation, type);
@@ -75,7 +75,7 @@ void DungeonView::display(Context *c, TileView *view) {
type = tilesToGraphic(tiles);
drawWall(0, y, (Direction)g_ultima->_saveGame->_orientation, type);
- //This only checks that the tile at y==3 is opaque
+ // This only checks that the tile at y==3 is opaque
if (y == 3 && !tiles.front().getTileType()->isOpaque()) {
for (int y_obj = farthest_non_wall_tile_visibility; y_obj > y; y_obj--) {
Std::vector<MapTile> distant_tiles = getTiles(y_obj , 0);
@@ -91,7 +91,7 @@ void DungeonView::display(Context *c, TileView *view) {
}
}
- /* 3rd-person perspective */
+ // 3rd-person perspective
else {
Std::vector<MapTile> tiles;
@@ -102,7 +102,7 @@ void DungeonView::display(Context *c, TileView *view) {
for (x = 0; x < VIEWPORT_W; x++) {
tiles = getTiles((VIEWPORT_H / 2) - y, x - (VIEWPORT_W / 2));
- /* Only show blackness if there is no light */
+ // Only show blackness if there is no light
if (c->_party->getTorchDuration() <= 0)
view->drawTile(black, false, x, y);
else if (x == VIEWPORT_W / 2 && y == VIEWPORT_H / 2)
@@ -141,9 +141,9 @@ void DungeonView::drawInDungeon(Tile *tile, int x_offset, int distance, Directio
const int *dscale = tiledWall ? lscale : nscale;
- //Clear scratchpad and set a background color
+ // Clear scratchpad and set a background color
_animated->initializeToBackgroundColor();
- //Put tile on animated scratchpad
+ // Put tile on animated scratchpad
if (tile->getAnim()) {
MapTile mt = tile->getId();
tile->getAnim()->draw(_animated, tile, mt, orientation);
@@ -151,8 +151,8 @@ void DungeonView::drawInDungeon(Tile *tile, int x_offset, int distance, Directio
tile->getImage()->drawOn(_animated, 0, 0);
}
_animated->makeBackgroundColorTransparent();
- //This process involving the background color is only required for drawing in the dungeon.
- //It will not play well with semi-transparent graphics.
+ // This process involving the background color is only required for drawing in the dungeon.
+ // It will not play well with semi-transparent graphics.
/* scale is based on distance; 1 means half size, 2 regular, 4 means scale by 2x, etc. */
if (dscale[distance] == 0)
@@ -174,25 +174,15 @@ void DungeonView::drawInDungeon(Tile *tile, int x_offset, int distance, Directio
for (int x = i_x; x < f_x; x += d_x)
for (int y = i_y; y < f_y; y += d_y)
_animated->drawSubRectOn(this->_screen,
- x,
- y,
- 0,
- 0,
- f_x - x,
- f_y - y
- );
+ x, y, 0, 0, f_x - x, f_y - y);
} else {
int y_offset = MAX(0, (dscale[distance] - offset_adj) * offset_multiplier);
int x = SCALED((VIEWPORT_W * _tileWidth / 2) + this->_x) - (scaled->width() / 2);
int y = SCALED((VIEWPORT_H * _tileHeight / 2) + this->_y + y_offset) - (scaled->height() / 8);
- scaled->drawSubRectOn(this->_screen,
- x,
- y,
- 0,
- 0,
- SCALED(_tileWidth * VIEWPORT_W + this->_x) - x ,
- SCALED(_tileHeight * VIEWPORT_H + this->_y) - y);
+ scaled->drawSubRectOn(this->_screen, x, y, 0, 0,
+ SCALED(_tileWidth * VIEWPORT_W + this->_x) - x ,
+ SCALED(_tileHeight * VIEWPORT_H + this->_y) - y);
}
delete scaled;
@@ -218,7 +208,7 @@ int DungeonView::graphicIndex(int xoffset, int distance, Direction orientation,
(distance * 2) +
(DIR_IN_MASK(orientation, MASK_DIR_SOUTH | MASK_DIR_NORTH) ? 1 : 0);
- /* FIXME */
+ // FIXME
if (type != DNGGRAPHIC_WALL && type != DNGGRAPHIC_DOOR)
return -1;
@@ -336,7 +326,7 @@ const struct {
int ega_x2, ega_y2;
int vga_x2, vga_y2;
const char *subimage2;
-} dngGraphicInfo[] = {
+} DNG_GRAPHIC_INFO[] = {
{ "dung0_lft_ew", -1, -1, -1, -1, nullptr },
{ "dung0_lft_ns", -1, -1, -1, -1, nullptr },
{ "dung0_mid_ew", -1, -1, -1, -1, nullptr },
@@ -429,25 +419,25 @@ void DungeonView::drawWall(int xoffset, int distance, Direction orientation, Dun
return;
int x = 0, y = 0;
- SubImage *subimage = imageMgr->getSubImage(dngGraphicInfo[index].subimage);
+ SubImage *subimage = imageMgr->getSubImage(DNG_GRAPHIC_INFO[index].subimage);
if (subimage) {
x = subimage->x;
y = subimage->y;
}
- g_screen->screenDrawImage(dngGraphicInfo[index].subimage, (BORDER_WIDTH + x) * settings._scale,
+ g_screen->screenDrawImage(DNG_GRAPHIC_INFO[index].subimage, (BORDER_WIDTH + x) * settings._scale,
(BORDER_HEIGHT + y) * settings._scale);
- if (dngGraphicInfo[index].subimage2 != nullptr) {
+ if (DNG_GRAPHIC_INFO[index].subimage2 != nullptr) {
// FIXME: subimage2 is a horrible hack, needs to be cleaned up
if (settings._videoType == "EGA")
- g_screen->screenDrawImage(dngGraphicInfo[index].subimage2,
- (8 + dngGraphicInfo[index].ega_x2) * settings._scale,
- (8 + dngGraphicInfo[index].ega_y2) * settings._scale);
+ g_screen->screenDrawImage(DNG_GRAPHIC_INFO[index].subimage2,
+ (8 + DNG_GRAPHIC_INFO[index].ega_x2) * settings._scale,
+ (8 + DNG_GRAPHIC_INFO[index].ega_y2) * settings._scale);
else
- g_screen->screenDrawImage(dngGraphicInfo[index].subimage2,
- (8 + dngGraphicInfo[index].vga_x2) * settings._scale,
- (8 + dngGraphicInfo[index].vga_y2) * settings._scale);
+ g_screen->screenDrawImage(DNG_GRAPHIC_INFO[index].subimage2,
+ (8 + DNG_GRAPHIC_INFO[index].vga_x2) * settings._scale,
+ (8 + DNG_GRAPHIC_INFO[index].vga_y2) * settings._scale);
}
}
diff --git a/engines/ultima/ultima4/map/location.cpp b/engines/ultima/ultima4/map/location.cpp
index 65c271da81..eb65557cac 100644
--- a/engines/ultima/ultima4/map/location.cpp
+++ b/engines/ultima/ultima4/map/location.cpp
@@ -36,8 +36,25 @@
namespace Ultima {
namespace Ultima4 {
-Location *locationPush(Location *stack, Location *loc);
-Location *locationPop(Location **stack);
+/**
+ * Push a location onto the stack
+ */
+static Location *locationPush(Location *stack, Location *loc) {
+ loc->_prev = stack;
+ return loc;
+}
+
+/**
+ * Pop a location off the stack
+ */
+static Location *locationPop(Location **stack) {
+ Location *loc = *stack;
+ *stack = (*stack)->_prev;
+ loc->_prev = nullptr;
+ return loc;
+}
+
+/*-------------------------------------------------------------------*/
Location::Location(MapCoords coords, Map *map, int viewmode, LocationContext ctx,
TurnCompleter *turnCompleter, Location *prev) {
@@ -61,7 +78,7 @@ Std::vector<MapTile> Location::tilesAt(MapCoords coords, bool &focus) {
bool avatar = this->_coords == coords;
- /* Do not return objects for VIEW_GEM mode, show only the avatar and tiles */
+ // Do not return objects for VIEW_GEM mode, show only the avatar and tiles
if (_viewMode == VIEW_GEM && (!settings._enhancements || !settings._enhancementsOptions._peerShowsObjects)) {
// When viewing a gem, always show the avatar regardless of whether or not
// it is shown in our normal view
@@ -73,11 +90,11 @@ Std::vector<MapTile> Location::tilesAt(MapCoords coords, bool &focus) {
return tiles;
}
- /* Add the avatar to gem view */
+ // Add the avatar to gem view
if (avatar && _viewMode == VIEW_GEM)
tiles.push_back(g_context->_party->getTransport());
- /* Add visual-only annotations to the list */
+ // Add visual-only annotations to the list
for (i = a.begin(); i != a.end(); i++) {
if ((*i)->isVisualOnly()) {
tiles.push_back((*i)->getTile());
@@ -91,17 +108,17 @@ Std::vector<MapTile> Location::tilesAt(MapCoords coords, bool &focus) {
}
}
- /* then the avatar is drawn (unless on a ship) */
+ // then the avatar is drawn (unless on a ship)
if ((_map->_flags & SHOW_AVATAR) && (g_context->_transportContext != TRANSPORT_SHIP) && avatar)
//tiles.push_back(map->tileset->getByName("avatar")->id);
tiles.push_back(g_context->_party->getTransport());
- /* then camouflaged creatures that have a disguise */
+ // then camouflaged creatures that have a disguise
if (obj && (obj->getType() == Object::CREATURE) && !obj->isVisible() && (!m->getCamouflageTile().empty())) {
focus = focus || obj->hasFocus();
tiles.push_back(_map->_tileset->getByName(m->getCamouflageTile())->getId());
}
- /* then visible creatures and objects */
+ // then visible creatures and objects
else if (obj && obj->isVisible()) {
focus = focus || obj->hasFocus();
MapTile visibleCreatureAndObjectTile = obj->getTile();
@@ -111,11 +128,11 @@ Std::vector<MapTile> Location::tilesAt(MapCoords coords, bool &focus) {
tiles.push_back(visibleCreatureAndObjectTile);
}
- /* then the party's ship (because twisters and whirlpools get displayed on top of ships) */
+ // then the party's ship (because twisters and whirlpools get displayed on top of ships)
if ((_map->_flags & SHOW_AVATAR) && (g_context->_transportContext == TRANSPORT_SHIP) && avatar)
tiles.push_back(g_context->_party->getTransport());
- /* then permanent annotations */
+ // then permanent annotations
for (i = a.begin(); i != a.end(); i++) {
if (!(*i)->isVisualOnly()) {
tiles.push_back((*i)->getTile());
@@ -129,7 +146,7 @@ Std::vector<MapTile> Location::tilesAt(MapCoords coords, bool &focus) {
}
}
- /* finally the base tile */
+ // finally the base tile
MapTile tileFromMapData = *_map->getTileFromData(coords);
const Tile *tileType = _map->getTileFromData(coords)->getTileType();
if (tileType->isLivingObject()) {
@@ -138,7 +155,7 @@ Std::vector<MapTile> Location::tilesAt(MapCoords coords, bool &focus) {
}
tiles.push_back(tileFromMapData);
- /* But if the base tile requires a background, we must find it */
+ // But if the base tile requires a background, we must find it
if (tileType->isLandForeground() ||
tileType->isWaterForeground() ||
tileType->isLivingObject()) {
@@ -206,10 +223,10 @@ TileId Location::getReplacementTile(MapCoords atCoords, const Tile *forTile) {
return winner;
}
- /* loop_count is an ugly hack to temporarily fix infinite loop */
+ // loop_count is an ugly hack to temporarily fix infinite loop
} while (++loop_count < 128 && searchQueue.size() > 0 && searchQueue.size() < 64);
- /* couldn't find a tile, give it the classic default */
+ // couldn't find a tile, give it the classic default
return _map->_tileset->getByName("brick_floor")->getId();
}
@@ -248,30 +265,9 @@ MoveResult Location::move(Direction dir, bool userEvent) {
}
-/**
- * Pop a location from the stack and free the memory
- */
void locationFree(Location **stack) {
delete locationPop(stack);
}
-/**
- * Push a location onto the stack
- */
-Location *locationPush(Location *stack, Location *loc) {
- loc->_prev = stack;
- return loc;
-}
-
-/**
- * Pop a location off the stack
- */
-Location *locationPop(Location **stack) {
- Location *loc = *stack;
- *stack = (*stack)->_prev;
- loc->_prev = nullptr;
- return loc;
-}
-
} // End of namespace Ultima4
} // End of namespace Ultima
diff --git a/engines/ultima/ultima4/map/location.h b/engines/ultima/ultima4/map/location.h
index 731d90532a..664204abe5 100644
--- a/engines/ultima/ultima4/map/location.h
+++ b/engines/ultima/ultima4/map/location.h
@@ -83,6 +83,9 @@ public:
Location *_prev;
};
+/**
+ * Pop a location from the stack and free the memory
+ */
void locationFree(Location **stack);
} // End of namespace Ultima4
diff --git a/engines/ultima/ultima4/map/map.cpp b/engines/ultima/ultima4/map/map.cpp
index 994b45056c..06e07d49f7 100644
--- a/engines/ultima/ultima4/map/map.cpp
+++ b/engines/ultima/ultima4/map/map.cpp
@@ -53,7 +53,7 @@ bool MapCoords::operator!=(const MapCoords &a) const {
return !operator==(a);
}
bool MapCoords::operator<(const MapCoords &a) const {
- //TODO cooler boolean logic
+ // TODO: cooler boolean logic
if (x > a.x)
return false;
if (y > a.y)
@@ -135,7 +135,7 @@ int MapCoords::getRelativeDirection(const MapCoords &c, const Map *map) const {
if (z != c.z)
return dirmask;
- /* adjust our coordinates to find the closest path */
+ // Adjust our coordinates to find the closest path
if (map && map->_borderBehavior == Map::BORDER_WRAP) {
MapCoords me = *this;
@@ -156,32 +156,32 @@ int MapCoords::getRelativeDirection(const MapCoords &c, const Map *map) const {
dy = y - c.y;
}
- /* add x directions that lead towards to_x to the mask */
+ // Add x directions that lead towards to_x to the mask
if (dx < 0) dirmask |= MASK_DIR(DIR_EAST);
else if (dx > 0) dirmask |= MASK_DIR(DIR_WEST);
- /* add y directions that lead towards to_y to the mask */
+ // Add y directions that lead towards to_y to the mask
if (dy < 0) dirmask |= MASK_DIR(DIR_SOUTH);
else if (dy > 0) dirmask |= MASK_DIR(DIR_NORTH);
- /* return the result */
+ // Return the result
return dirmask;
}
Direction MapCoords::pathTo(const MapCoords &c, int valid_directions, bool towards, const Map *map) const {
int directionsToObject;
- /* find the directions that lead [to/away from] our target */
+ // Find the directions that lead [to/away from] our target
directionsToObject = towards ? getRelativeDirection(c, map) : ~getRelativeDirection(c, map);
- /* make sure we eliminate impossible options */
+ // Make sure we eliminate impossible options
directionsToObject &= valid_directions;
- /* get the new direction to move */
+ // Get the new direction to move
if (directionsToObject > DIR_NONE)
return dirRandomDir(directionsToObject);
- /* there are no valid directions that lead to our target, just move wherever we can! */
+ // There are no valid directions that lead to our target, just move wherever we can!
else return dirRandomDir(valid_directions);
}
@@ -197,7 +197,7 @@ int MapCoords::movementDistance(const MapCoords &c, const Map *map) const {
if (z != c.z)
return -1;
- /* get the direction(s) to the coordinates */
+ // Get the direction(s) to the coordinates
dirmask = getRelativeDirection(c, map);
while ((me.x != c.x) || (me.y != c.y)) {
@@ -225,7 +225,7 @@ int MapCoords::distance(const MapCoords &c, const Map *map) const {
if (dist <= 0)
return dist;
- /* calculate how many fewer movements there would have been */
+ // Calculate how many fewer movements there would have been
dist -= abs(x - c.x) < abs(y - c.y) ? abs(x - c.x) : abs(y - c.y);
return dist;
@@ -258,7 +258,7 @@ Common::String Map::getName() {
}
Object *Map::objectAt(const Coords &coords) {
- /* FIXME: return a list instead of one object */
+ // FIXME: return a list instead of one object
ObjectDeque::const_iterator i;
Object *objAt = nullptr;
@@ -266,10 +266,10 @@ Object *Map::objectAt(const Coords &coords) {
Object *obj = *i;
if (obj->getCoords() == coords) {
- /* get the most visible object */
+ // Get the most visible object
if (objAt && (objAt->getType() == Object::UNKNOWN) && (obj->getType() != Object::UNKNOWN))
objAt = obj;
- /* give priority to objects that have the focus */
+ // Give priority to objects that have the focus
else if (objAt && (!objAt->hasFocus()) && (obj->hasFocus()))
objAt = obj;
else if (!objAt)
@@ -301,7 +301,7 @@ MapTile *Map::getTileFromData(const Coords &coords) {
}
MapTile *Map::tileAt(const Coords &coords, int withObjects) {
- /* FIXME: this should return a list of tiles, with the most visible at the front */
+ // FIXME: this should return a list of tiles, with the most visible at the front
MapTile *tile;
Common::List<Annotation *> a = _annotations->ptrsToAllAt(coords);
Common::List<Annotation *>::iterator i;
@@ -309,7 +309,7 @@ MapTile *Map::tileAt(const Coords &coords, int withObjects) {
tile = getTileFromData(coords);
- /* FIXME: this only returns the first valid annotation it can find */
+ // FIXME: this only returns the first valid annotation it can find
if (a.size() > 0) {
for (i = a.begin(); i != a.end(); i++) {
if (!(*i)->isVisualOnly())
@@ -381,13 +381,15 @@ void Map::findWalkability(Coords coords, int *path_data) {
findWalkability(Coords(coords.x, coords.y - 1, coords.z), path_data);
if ((coords.y < signed(_height - 1)) && path_data[coords.x + ((coords.y + 1) * _width)] < 0)
findWalkability(Coords(coords.x, coords.y + 1, coords.z), path_data);
- } else path_data[index] = 0;
+ } else {
+ path_data[index] = 0;
+ }
}
Creature *Map::addCreature(const Creature *creature, Coords coords) {
Creature *m = new Creature();
- /* make a copy of the creature before placing it */
+ // Make a copy of the creature before placing it
*m = *creature;
m->setInitialHp();
@@ -395,18 +397,18 @@ Creature *Map::addCreature(const Creature *creature, Coords coords) {
m->setCoords(coords);
m->setMap(this);
- /* initialize the creature before placing it */
+ // initialize the creature before placing it
if (m->wanders())
m->setMovementBehavior(MOVEMENT_WANDER);
else if (m->isStationary())
m->setMovementBehavior(MOVEMENT_FIXED);
else m->setMovementBehavior(MOVEMENT_ATTACK_AVATAR);
- /* hide camouflaged creatures from view during combat */
+ // Hide camouflaged creatures from view during combat
if (m->camouflages() && (_type == COMBAT))
m->setVisible(false);
- /* place the creature on the map */
+ // place the creature on the map
_objects.push_back(m);
return m;
}
@@ -434,7 +436,7 @@ void Map::removeObject(const Object *rem, bool deleteObject) {
ObjectDeque::iterator i;
for (i = _objects.begin(); i != _objects.end(); i++) {
if (*i == rem) {
- /* Party members persist through different maps, so don't delete them! */
+ // Party members persist through different maps, so don't delete them!
if (!isPartyMember(*i) && deleteObject)
delete(*i);
_objects.erase(i);
@@ -444,7 +446,7 @@ void Map::removeObject(const Object *rem, bool deleteObject) {
}
ObjectDeque::iterator Map::removeObject(ObjectDeque::iterator rem, bool deleteObject) {
- /* Party members persist through different maps, so don't delete them! */
+ // Party members persist through different maps, so don't delete them!
if (!isPartyMember(*rem) && deleteObject)
delete(*rem);
return _objects.erase(rem);
@@ -463,7 +465,7 @@ Creature *Map::moveObjects(MapCoords avatar) {
(m->getType() == Object::CREATURE && m->willAttack())) {
MapCoords o_coords = m->getCoords();
- /* don't move objects that aren't on the same level as us */
+ // Don't move objects that aren't on the same level as us
if (o_coords.z != avatar.z)
continue;
@@ -473,15 +475,15 @@ Creature *Map::moveObjects(MapCoords avatar) {
}
}
- /* Before moving, Enact any special effects of the creature (such as storms eating objects, whirlpools teleporting, etc.) */
+ // Before moving, Enact any special effects of the creature (such as storms eating objects, whirlpools teleporting, etc.)
m->specialEffect();
- /* Perform any special actions (such as pirate ships firing cannons, sea serpents' fireblast attect, etc.) */
+ // Perform any special actions (such as pirate ships firing cannons, sea serpents' fireblast attect, etc.)
if (!m->specialAction()) {
if (moveObject(this, m, avatar)) {
m->animateMovement();
- /* After moving, Enact any special effects of the creature (such as storms eating objects, whirlpools teleporting, etc.) */
+ // After moving, Enact any special effects of the creature (such as storms eating objects, whirlpools teleporting, etc.)
m->specialEffect();
}
}
@@ -528,7 +530,7 @@ int Map::getValidMoves(MapCoords from, MapTile transport) {
int ontoAvatar, ontoCreature;
MapCoords coords = from;
- // get the creature object, if it exists (the one that's moving)
+ // Get the creature object, if it exists (the one that's moving)
m = creatureMgr->getByTile(transport);
bool isAvatar = (g_context->_location->_coords == coords);
@@ -544,7 +546,7 @@ int Map::getValidMoves(MapCoords from, MapTile transport) {
// Move the coordinates in the current direction and test it
coords.move(d, this);
- // you can always walk off the edge of the map
+ // You can always walk off the edge of the map
if (MAP_IS_OOB(this, coords)) {
retval = DIR_ADD_TO_MASK(d, retval);
continue;
@@ -552,15 +554,15 @@ int Map::getValidMoves(MapCoords from, MapTile transport) {
obj = objectAt(coords);
- // see if it's trying to move onto the avatar
+ // See if it's trying to move onto the avatar
if ((_flags & SHOW_AVATAR) && (coords == g_context->_location->_coords))
ontoAvatar = 1;
- // see if it's trying to move onto a person or creature
+ // See if it's trying to move onto a person or creature
else if (obj && (obj->getType() != Object::UNKNOWN))
ontoCreature = 1;
- // get the destination tile
+ // Get the destination tile
MapTile tile;
if (ontoAvatar)
tile = g_context->_party->getTransport();
@@ -571,10 +573,10 @@ int Map::getValidMoves(MapCoords from, MapTile transport) {
MapTile prev_tile = *tileAt(from, WITHOUT_OBJECTS);
- // get the other creature object, if it exists (the one that's being moved onto)
+ // Get the other creature object, if it exists (the one that's being moved onto)
to_m = dynamic_cast<Creature *>(obj);
- // move on if unable to move onto the avatar or another creature
+ // Move on if unable to move onto the avatar or another creature
if (m && !isAvatar) { // some creatures/persons have the same tile as the avatar, so we have to adjust
// If moving onto the avatar, the creature must be able to move onto the player
// If moving onto another creature, it must be able to move onto other creatures,
@@ -595,7 +597,7 @@ int Map::getValidMoves(MapCoords from, MapTile transport) {
continue;
}
- // avatar movement
+ // Avatar movement
if (isAvatar) {
// if the transport is a ship, check sailable
if (transport.getTileType()->isShip() && tile.getTileType()->isSailable())
@@ -615,9 +617,9 @@ int Map::getValidMoves(MapCoords from, MapTile transport) {
// }
}
- // creature movement
+ // Creature movement
else if (m) {
- // flying creatures
+ // Flying creatures
if (tile.getTileType()->isFlyable() && m->flies()) {
// FIXME: flying creatures behave differently on the world map?
if (isWorldMap())
@@ -627,7 +629,7 @@ int Map::getValidMoves(MapCoords from, MapTile transport) {
tile.getTileType()->isSailable())
retval = DIR_ADD_TO_MASK(d, retval);
}
- // swimming creatures and sailing creatures
+ // Swimming creatures and sailing creatures
else if (tile.getTileType()->isSwimable() ||
tile.getTileType()->isSailable() ||
tile.getTileType()->isShip()) {
@@ -638,14 +640,14 @@ int Map::getValidMoves(MapCoords from, MapTile transport) {
if (m->canMoveOntoPlayer() && tile.getTileType()->isShip())
retval = DIR_ADD_TO_MASK(d, retval);
}
- // ghosts and other incorporeal creatures
+ // Ghosts and other incorporeal creatures
else if (m->isIncorporeal()) {
// can move anywhere but onto water, unless of course the creature can swim
if (!(tile.getTileType()->isSwimable() ||
tile.getTileType()->isSailable()))
retval = DIR_ADD_TO_MASK(d, retval);
}
- // walking creatures
+ // Walking creatures
else if (m->walks()) {
if (tile.getTileType()->canWalkOn(d) &&
prev_tile.getTileType()->canWalkOff(d) &&
@@ -655,10 +657,9 @@ int Map::getValidMoves(MapCoords from, MapTile transport) {
// Creatures that can move onto player
else if (ontoAvatar && m->canMoveOntoPlayer()) {
- //tile should be transport
+ // Tile should be transport
if (tile.getTileType()->isShip() && m->swims())
retval = DIR_ADD_TO_MASK(d, retval);
-
}
}
}
@@ -679,7 +680,7 @@ void Map::alertGuards() {
ObjectDeque::iterator i;
const Creature *m;
- /* switch all the guards to attack mode */
+ // Switch all the guards to attack mode
for (i = _objects.begin(); i != _objects.end(); i++) {
m = creatureMgr->getByTile((*i)->getTile());
if (m && (m->getId() == GUARD_ID || m->getId() == LORDBRITISH_ID))
@@ -714,10 +715,10 @@ bool Map::fillMonsterTable() {
for (current = _objects.begin(); current != _objects.end(); current++) {
obj = *current;
- /* moving objects first */
+ // Moving objects first
if ((obj->getType() == Object::CREATURE) && (obj->getMovementBehavior() != MOVEMENT_FIXED)) {
Creature *c = dynamic_cast<Creature *>(obj);
- /* whirlpools and storms are separated from other moving objects */
+ // Whirlpools and storms are separated from other moving objects
if (c->getId() == WHIRLPOOL_ID || c->getId() == STORM_ID)
monsters.push_back(obj);
else other_creatures.push_back(obj);
diff --git a/engines/ultima/ultima4/map/maploader.cpp b/engines/ultima/ultima4/map/maploader.cpp
index 23362c4eaa..86b5b9a807 100644
--- a/engines/ultima/ultima4/map/maploader.cpp
+++ b/engines/ultima/ultima4/map/maploader.cpp
@@ -74,7 +74,7 @@ MapLoader *MapLoader::registerLoader(MapLoader *loader, Map::Type type) {
bool MapLoader::loadData(Map *map, Common::File *f) {
uint x, xch, y, ych;
- /* allocate the space we need for the map data */
+ // Allocate the space we need for the map data
map->_data.clear();
map->_data.resize(map->_height * map->_width);
@@ -139,14 +139,14 @@ bool CityMapLoader::load(Map *map) {
if (!ult || !tlk)
error("unable to load map data");
- /* the map must be 32x32 to be read from an .ULT file */
+ // The map must be 32x32 to be read from an .ULT file
ASSERT(city->_width == CITY_WIDTH, "map width is %d, should be %d", city->_width, CITY_WIDTH);
ASSERT(city->_height == CITY_HEIGHT, "map height is %d, should be %d", city->_height, CITY_HEIGHT);
if (!loadData(city, ult))
return false;
- /* Properly construct people for the city */
+ // Properly construct people for the city
for (i = 0; i < CITY_MAX_PERSONS; i++)
people[i] = new Person(map->translateFromRawTileIndex(u4fgetc(ult)));
@@ -160,7 +160,7 @@ bool CityMapLoader::load(Map *map) {
people[i]->setPrevTile(map->translateFromRawTileIndex(u4fgetc(ult)));
for (i = 0; i < CITY_MAX_PERSONS * 2; i++)
- u4fgetc(ult); /* read redundant startx/starty */
+ u4fgetc(ult); // Read redundant startx/starty
for (i = 0; i < CITY_MAX_PERSONS; i++) {
byte c = u4fgetc(ult);
@@ -251,7 +251,7 @@ bool ConMapLoader::load(Map *map) {
if (!con)
error("unable to load map data");
- /* the map must be 11x11 to be read from an .CON file */
+ // The map must be 11x11 to be read from an .CON file
ASSERT(map->_width == CON_WIDTH, "map width is %d, should be %d", map->_width, CON_WIDTH);
ASSERT(map->_height == CON_HEIGHT, "map height is %d, should be %d", map->_height, CON_HEIGHT);
@@ -288,23 +288,23 @@ bool DngMapLoader::load(Map *map) {
if (!dng)
error("unable to load map data");
- /* the map must be 11x11 to be read from an .CON file */
+ // The map must be 11x11 to be read from an .CON file
ASSERT(dungeon->_width == DNG_WIDTH, "map width is %d, should be %d", dungeon->_width, DNG_WIDTH);
ASSERT(dungeon->_height == DNG_HEIGHT, "map height is %d, should be %d", dungeon->_height, DNG_HEIGHT);
- /* load the dungeon map */
+ // Load the dungeon map
uint i, j;
for (i = 0; i < (DNG_HEIGHT * DNG_WIDTH * dungeon->_levels); i++) {
byte mapData = u4fgetc(dng);
MapTile tile = map->translateFromRawTileIndex(mapData);
- /* determine what type of tile it is */
+ // Determine what type of tile it is
dungeon->_data.push_back(tile);
dungeon->_dataSubTokens.push_back(mapData % 16);
}
- /* read in the dungeon rooms */
- /* FIXME: needs a cleanup function to free this memory later */
+ // Read in the dungeon rooms
+ // FIXME: needs a cleanup function to free this memory later
dungeon->_rooms = new DngRoom[dungeon->_nRooms];
for (i = 0; i < dungeon->_nRooms; i++) {
@@ -348,11 +348,11 @@ bool DngMapLoader::load(Map *map) {
u4fread(room_tiles, sizeof(room_tiles), 1, dng);
u4fread(dungeon->_rooms[i]._buffer, sizeof(dungeon->_rooms[i]._buffer), 1, dng);
- /* translate each creature tile to a tile id */
+ // Translate each creature tile to a tile id
for (j = 0; j < sizeof(dungeon->_rooms[i]._creatureTiles); j++)
dungeon->_rooms[i]._creatureTiles[j] = TileMap::get("base")->translate(dungeon->_rooms[i]._creatureTiles[j])._id;
- /* translate each map tile to a tile id */
+ // Translate each map tile to a tile id
for (j = 0; j < sizeof(room_tiles); j++)
dungeon->_rooms[i]._mapData.push_back(TileMap::get("base")->translate(room_tiles[j]));
@@ -383,13 +383,13 @@ bool DngMapLoader::load(Map *map) {
memcpy(dungeon->_rooms[i]._partySouthStartX, x2, sizeof(x2));
memcpy(dungeon->_rooms[i]._partySouthStartY, y2, sizeof(y2));
} else if (i == 0x9) {
- // update the starting position of monsters 7, 8, and 9
+ // Update the starting position of monsters 7, 8, and 9
const byte x1[3] = { 0x4, 0x6, 0x5 },
y1[3] = { 0x5, 0x5, 0x6 };
memcpy(dungeon->_rooms[i]._creatureStartX + 7, x1, sizeof(x1));
memcpy(dungeon->_rooms[i]._creatureStartY + 7, y1, sizeof(y1));
- // update party start positions when entering from the west
+ // Update party start positions when entering from the west
const byte x2[8] = { 0x2, 0x2, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0 },
y2[8] = { 0x9, 0x8, 0x9, 0x8, 0x7, 0x9, 0x8, 0x7 };
memcpy(dungeon->_rooms[i]._partyWestStartX, x2, sizeof(x2));
diff --git a/engines/ultima/ultima4/map/mapmgr.cpp b/engines/ultima/ultima4/map/mapmgr.cpp
index 57b20559e7..48f6ba3df7 100644
--- a/engines/ultima/ultima4/map/mapmgr.cpp
+++ b/engines/ultima/ultima4/map/mapmgr.cpp
@@ -70,7 +70,7 @@ MapMgr::MapMgr() {
for (Std::vector<ConfigElement>::iterator i = maps.begin(); i != maps.end(); i++) {
map = initMapFromConf(*i);
- /* map actually gets loaded later, when it's needed */
+ // Map actually gets loaded later, when it's needed
registerMap(map);
}
}
@@ -128,7 +128,7 @@ Map *MapMgr::initMap(Map::Type type) {
}
Map *MapMgr::get(MapId id) {
- /* if the map hasn't been loaded yet, load it! */
+ // if the map hasn't been loaded yet, load it!
if (!_mapList[id]->_data.size()) {
MapLoader *loader = MapLoader::getLoader(_mapList[id]->_type);
if (loader == nullptr)
diff --git a/engines/ultima/ultima4/map/movement.cpp b/engines/ultima/ultima4/map/movement.cpp
index ebcff53ab2..db16ad809e 100644
--- a/engines/ultima/ultima4/map/movement.cpp
+++ b/engines/ultima/ultima4/map/movement.cpp
@@ -59,7 +59,7 @@ void moveAvatar(MoveEvent &event) {
else if (g_context->_transportContext == TRANSPORT_BALLOON)
slowedType = SLOWED_BY_NOTHING;
- /* if you're on ship, you must turn first! */
+ // If you're on ship, you must turn first!
if (g_context->_transportContext == TRANSPORT_SHIP) {
if (g_context->_party->getDirection() != event._dir) {
g_context->_party->setDirection(event._dir);
@@ -68,17 +68,17 @@ void moveAvatar(MoveEvent &event) {
}
}
- /* change direction of horse, if necessary */
+ // Change direction of horse, if necessary
if (g_context->_transportContext == TRANSPORT_HORSE) {
if ((event._dir == DIR_WEST || event._dir == DIR_EAST) && (g_context->_party->getDirection() != event._dir))
g_context->_party->setDirection(event._dir);
}
- /* figure out our new location we're trying to move to */
+ // Figure out our new location we're trying to move to
newCoords = g_context->_location->_coords;
newCoords.move(event._dir, g_context->_location->_map);
- /* see if we moved off the map */
+ // See if we moved off the map
if (MAP_IS_OOB(g_context->_location->_map, newCoords)) {
event._result = (MoveResult)(MOVE_MAP_CHANGE | MOVE_EXIT_TO_PARENT | MOVE_SUCCEEDED);
return;
@@ -86,13 +86,13 @@ void moveAvatar(MoveEvent &event) {
if (!g_debugger->_collisionOverride && !g_context->_party->isFlying()) {
int movementMask = g_context->_location->_map->getValidMoves(g_context->_location->_coords, g_context->_party->getTransport());
- /* See if movement was blocked */
+ // See if movement was blocked
if (!DIR_IN_MASK(event._dir, movementMask)) {
event._result = (MoveResult)(MOVE_BLOCKED | MOVE_END_TURN);
return;
}
- /* Are we slowed by terrain or by wind direction? */
+ // Are we slowed by terrain or by wind direction?
switch (slowedType) {
case SLOWED_BY_TILE:
// TODO: CHEST: Make a user option to not make chests always fast to
@@ -113,7 +113,7 @@ void moveAvatar(MoveEvent &event) {
}
}
- /* move succeeded */
+ // Move succeeded
g_context->_location->_coords = newCoords;
/* if the avatar moved onto a creature (whirlpool, twister), then do the creature's special effect (this current code does double damage according to changeset 2753.
@@ -138,23 +138,23 @@ void moveAvatarInDungeon(MoveEvent &event) {
retreating = realDir == dirReverse((Direction)g_ultima->_saveGame->_orientation);
MapTile *tile;
- /* we're not in a dungeon, failed! */
+ // We're not in a dungeon, failed!
ASSERT(g_context->_location->_context & CTX_DUNGEON, "moveAvatarInDungeon() called outside of dungeon, failed!");
- /* you must turn first! */
+ // You must turn first!
if (!advancing && !retreating) {
g_ultima->_saveGame->_orientation = realDir;
event._result = MOVE_TURNED;
return;
}
- /* figure out our new location */
+ // Figure out our new location
newCoords = g_context->_location->_coords;
newCoords.move(realDir, g_context->_location->_map);
tile = g_context->_location->_map->tileAt(newCoords, WITH_OBJECTS);
- /* see if we moved off the map (really, this should never happen in a dungeon) */
+ // See if we moved off the map (really, this should never happen in a dungeon)
if (MAP_IS_OOB(g_context->_location->_map, newCoords)) {
event._result = (MoveResult)(MOVE_MAP_CHANGE | MOVE_EXIT_TO_PARENT | MOVE_SUCCEEDED);
return;
@@ -174,25 +174,19 @@ void moveAvatarInDungeon(MoveEvent &event) {
}
}
- /* move succeeded */
+ // Move succeeded
g_context->_location->_coords = newCoords;
event._result = (MoveResult)(MOVE_SUCCEEDED | MOVE_END_TURN);
}
-/**
- * Moves an object on the map according to its movement behavior
- * Returns 1 if the object was moved successfully, 0 if slowed,
- * tile direction changed, or object simply cannot move
- * (fixed objects, nowhere to go, etc.)
- */
int moveObject(Map *map, Creature *obj, MapCoords avatar) {
int dirmask = DIR_NONE;
Direction dir;
MapCoords new_coords = obj->getCoords();
int slowed = 0;
- /* determine a direction depending on the object's movement behavior */
+ // Determine a direction depending on the object's movement behavior
dir = DIR_NONE;
switch (obj->getMovementBehavior()) {
case MOVEMENT_FIXED:
@@ -221,18 +215,18 @@ int moveObject(Map *map, Creature *obj, MapCoords avatar) {
break;
}
- /* now, get a new x and y for the object */
+ // Now, get a new x and y for the object
if (dir)
new_coords.move(dir, g_context->_location->_map);
else
return 0;
- /* figure out what method to use to tell if the object is getting slowed */
+ // Figure out what method to use to tell if the object is getting slowed
SlowedType slowedType = SLOWED_BY_TILE;
if (obj->getType() == Object::CREATURE)
slowedType = obj->getSlowedType();
- /* is the object slowed by terrain or by wind direction? */
+ // Is the object slowed by terrain or by wind direction?
switch (slowedType) {
case SLOWED_BY_TILE:
slowed = slowedByTile(map->tileTypeAt(new_coords, WITHOUT_OBJECTS));
@@ -247,11 +241,11 @@ int moveObject(Map *map, Creature *obj, MapCoords avatar) {
obj->setPrevCoords(obj->getCoords());
- /* see if the object needed to turn instead of move */
+ // See if the object needed to turn instead of move
if (obj->setDirection(dir))
return 0;
- /* was the object slowed? */
+ // Was the object slowed?
if (slowed)
return 0;
@@ -265,9 +259,6 @@ int moveObject(Map *map, Creature *obj, MapCoords avatar) {
return 1;
}
-/**
- * Moves an object in combat according to its chosen combat action
- */
int moveCombatObject(int act, Map *map, Creature *obj, MapCoords target) {
MapCoords new_coords = obj->getCoords();
int valid_dirs = map->getValidMoves(new_coords, obj->getTile());
@@ -276,12 +267,12 @@ int moveCombatObject(int act, Map *map, Creature *obj, MapCoords target) {
SlowedType slowedType = SLOWED_BY_TILE;
int slowed = 0;
- /* fixed objects cannot move */
+ // Fixed objects cannot move
if (obj->getMovementBehavior() == MOVEMENT_FIXED)
return 0;
if (action == CA_FLEE) {
- /* run away from our target instead! */
+ // Run away from our target instead!
dir = new_coords.pathAway(target, valid_dirs);
} else {
@@ -304,11 +295,11 @@ int moveCombatObject(int act, Map *map, Creature *obj, MapCoords target) {
else
return 0;
- /* figure out what method to use to tell if the object is getting slowed */
+ // Figure out what method to use to tell if the object is getting slowed
if (obj->getType() == Object::CREATURE)
slowedType = obj->getSlowedType();
- /* is the object slowed by terrain or by wind direction? */
+ // Is the object slowed by terrain or by wind direction?
switch (slowedType) {
case SLOWED_BY_TILE:
slowed = slowedByTile(map->tileTypeAt(new_coords, WITHOUT_OBJECTS));
@@ -321,7 +312,7 @@ int moveCombatObject(int act, Map *map, Creature *obj, MapCoords target) {
break;
}
- /* if the object wan't slowed... */
+ // If the object wan't slowed...
if (!slowed) {
// Set the new coordinates
obj->setCoords(new_coords);
@@ -331,9 +322,6 @@ int moveCombatObject(int act, Map *map, Creature *obj, MapCoords target) {
return 0;
}
-/**
- * Moves a party member during combat screens
- */
void movePartyMember(MoveEvent &event) {
CombatController *ct = dynamic_cast<CombatController *>(eventHandler->getController());
CombatMap *cm = getCombatMap();
@@ -343,16 +331,16 @@ void movePartyMember(MoveEvent &event) {
event._result = MOVE_SUCCEEDED;
- /* find our new location */
+ // Find our new location
newCoords = (*party)[member]->getCoords();
newCoords.move(event._dir, g_context->_location->_map);
if (MAP_IS_OOB(g_context->_location->_map, newCoords)) {
bool sameExit = (!cm->isDungeonRoom() || (ct->getExitDir() == DIR_NONE) || (event._dir == ct->getExitDir()));
if (sameExit) {
- /* if in a win-or-lose battle and not camping, then it can be bad to flee while healthy */
+ // If in a win-or-lose battle and not camping, then it can be bad to flee while healthy
if (ct->isWinOrLose() && !ct->isCamping()) {
- /* A fully-healed party member fled from an evil creature :( */
+ // A fully-healed party member fled from an evil creature :(
if (ct->getCreature() && ct->getCreature()->isEvil() &&
g_context->_party->member(member)->getHp() == g_context->_party->member(member)->getMaxHp())
g_context->_party->adjustKarma(KA_HEALTHY_FLED_EVIL);
@@ -375,12 +363,12 @@ void movePartyMember(MoveEvent &event) {
return;
}
- /* is the party member slowed? */
+ // is the party member slowed?
if (!slowedByTile(g_context->_location->_map->tileTypeAt(newCoords, WITHOUT_OBJECTS))) {
- /* move succeeded */
+ // Move succeeded
(*party)[member]->setCoords(newCoords);
- /* handle dungeon room triggers */
+ // Handle dungeon room triggers
if (cm->isDungeonRoom()) {
Dungeon *dungeon = dynamic_cast<Dungeon *>(g_context->_location->_prev->_map);
int i;
@@ -396,7 +384,7 @@ void movePartyMember(MoveEvent &event) {
*/
MapCoords trigger(triggers[i].x, triggers[i].y, g_context->_location->_coords.z);
- /* see if we're on a trigger */
+ // See if we're on a trigger
if (newCoords == trigger) {
MapCoords change1(triggers[i]._changeX1, triggers[i]._changeY1, g_context->_location->_coords.z),
change2(triggers[i].changeX2, triggers[i].changeY2, g_context->_location->_coords.z);
@@ -407,7 +395,7 @@ void movePartyMember(MoveEvent &event) {
g_context->_location->_map->_annotations->remove(g_context->_location->_map->_annotations->allAt(change1));
g_context->_location->_map->_annotations->remove(g_context->_location->_map->_annotations->allAt(change2));
- /* change the tiles! */
+ // Change the tiles!
if (change1.x || change1.y) {
/*if (m) combatAddCreature(m, triggers[i].change_x1, triggers[i].change_y1, c->location->coords.z);
else*/ g_context->_location->_map->_annotations->add(change1, triggers[i]._tile, false, true);
@@ -425,10 +413,6 @@ void movePartyMember(MoveEvent &event) {
}
}
-/**
- * Default handler for slowing movement.
- * Returns true if slowed, false if not slowed
- */
bool slowedByTile(const Tile *tile) {
bool slow;
@@ -451,15 +435,11 @@ bool slowedByTile(const Tile *tile) {
return slow;
}
-/**
- * Slowed depending on the direction of object with respect to wind direction
- * Returns true if slowed, false if not slowed
- */
bool slowedByWind(int direction) {
- /* 1 of 4 moves while trying to move into the wind succeeds */
+ // 1 of 4 moves while trying to move into the wind succeeds
if (direction == g_context->_windDirection)
return (g_ultima->_saveGame->_moves % 4) != 0;
- /* 1 of 4 moves while moving directly away from wind fails */
+ // 1 of 4 moves while moving directly away from wind fails
else if (direction == dirReverse((Direction) g_context->_windDirection))
return (g_ultima->_saveGame->_moves % 4) == 3;
else
diff --git a/engines/ultima/ultima4/map/movement.h b/engines/ultima/ultima4/map/movement.h
index 20da646d31..5775276565 100644
--- a/engines/ultima/ultima4/map/movement.h
+++ b/engines/ultima/ultima4/map/movement.h
@@ -62,10 +62,35 @@ public:
void moveAvatar(MoveEvent &event);
void moveAvatarInDungeon(MoveEvent &event);
+
+/**
+ * Moves an object on the map according to its movement behavior
+ * Returns 1 if the object was moved successfully, 0 if slowed,
+ * tile direction changed, or object simply cannot move
+ * (fixed objects, nowhere to go, etc.)
+ */
int moveObject(class Map *map, class Creature *obj, MapCoords avatar);
+
+/**
+ * Moves an object in combat according to its chosen combat action
+ */
int moveCombatObject(int action, class Map *map, class Creature *obj, MapCoords target);
+
+/**
+ * Moves a party member during combat screens
+ */
void movePartyMember(MoveEvent &event);
+
+/**
+ * Default handler for slowing movement.
+ * Returns true if slowed, false if not slowed
+ */
bool slowedByTile(const Tile *tile);
+
+/**
+ * Slowed depending on the direction of object with respect to wind direction
+ * Returns true if slowed, false if not slowed
+ */
bool slowedByWind(int direction);
} // End of namespace Ultima4
diff --git a/engines/ultima/ultima4/map/shrine.cpp b/engines/ultima/ultima4/map/shrine.cpp
index c6c5d0ac0b..cd0fbd56d5 100644
--- a/engines/ultima/ultima4/map/shrine.cpp
+++ b/engines/ultima/ultima4/map/shrine.cpp
@@ -52,9 +52,6 @@ using Std::vector;
int cycles, completedCycles;
Std::vector<Common::String> shrineAdvice;
-/**
- * Returns true if the player can use the portal to the shrine
- */
bool shrineCanEnter(const Portal *p) {
Shrine *shrine = dynamic_cast<Shrine *>(mapMgr->get(p->_destid));
if (!g_context->_party->canEnterShrine(shrine->getVirtue())) {
@@ -64,9 +61,6 @@ bool shrineCanEnter(const Portal *p) {
return 1;
}
-/**
- * Returns true if 'map' points to a Shrine map
- */
bool isShrine(Map *punknown) {
Shrine *ps;
if ((ps = dynamic_cast<Shrine *>(punknown)) != nullptr)
@@ -75,9 +69,7 @@ bool isShrine(Map *punknown) {
return false;
}
-/**
- * Shrine class implementation
- */
+
Shrine::Shrine() {}
Common::String Shrine::getName() {
@@ -88,19 +80,19 @@ Common::String Shrine::getName() {
return _name;
}
-Virtue Shrine::getVirtue() const {
+Virtue Shrine::getVirtue() const {
return _virtue;
}
-Common::String Shrine::getMantra() const {
+Common::String Shrine::getMantra() const {
return _mantra;
}
-void Shrine::setVirtue(Virtue v) {
+void Shrine::setVirtue(Virtue v) {
_virtue = v;
}
-void Shrine::setMantra(Common::String m) {
+void Shrine::setMantra(Common::String m) {
_mantra = m;
}
@@ -169,7 +161,7 @@ void Shrine::enter() {
}
void Shrine::enhancedSequence() {
- /* replace the 'static' avatar tile with grass */
+ // Replace the 'static' avatar tile with grass
_annotations->add(Coords(5, 6, g_context->_location->_coords.z), _tileset->getByName("grass")->getId(), false, true);
g_screen->screenDisableCursor();
@@ -203,7 +195,7 @@ void Shrine::enhancedSequence() {
}
void Shrine::meditationCycle() {
- /* find our interval for meditation */
+ // Find our interval for meditation
int interval = (settings._shrineTime * 1000) / MEDITATION_MANTRAS_PER_CYCLE;
interval -= (interval % settings._eventTimerGranularity);
interval /= settings._eventTimerGranularity;
diff --git a/engines/ultima/ultima4/map/shrine.h b/engines/ultima/ultima4/map/shrine.h
index f3b573a73f..155f41f3c6 100644
--- a/engines/ultima/ultima4/map/shrine.h
+++ b/engines/ultima/ultima4/map/shrine.h
@@ -61,7 +61,14 @@ private:
Common::String _mantra;
};
+/**
+ * Returns true if the player can use the portal to the shrine
+ */
bool shrineCanEnter(const struct _Portal *p);
+
+/**
+ * Returns true if 'map' points to a Shrine map
+ */
bool isShrine(Map *punknown);
} // End of namespace Ultima4
diff --git a/engines/ultima/ultima4/map/tile.cpp b/engines/ultima/ultima4/map/tile.cpp
index 1634cf5f28..cf962cbf93 100644
--- a/engines/ultima/ultima4/map/tile.cpp
+++ b/engines/ultima/ultima4/map/tile.cpp
@@ -64,14 +64,14 @@ void Tile::loadProperties(const ConfigElement &conf) {
if (conf.getName() != "tile")
return;
- _name = conf.getString("name"); /* get the name of the tile */
+ _name = conf.getString("name"); // Get the name of the tile
- /* get the animation for the tile, if one is specified */
+ // Get the animation for the tile, if one is specified
if (conf.exists("animation")) {
_animationRule = conf.getString("animation");
}
- /* see if the tile is opaque */
+ // See if the tile is opaque
_opaque = conf.getBool("opaque");
_foreground = conf.getBool("usesReplacementTileAsBackground");
@@ -85,10 +85,10 @@ void Tile::loadProperties(const ConfigElement &conf) {
rule = TileRule::findByName("default");
} else rule = TileRule::findByName("default");
- /* get the number of frames the tile has */
+ // Get the number of frames the tile has
_frames = conf.getInt("frames", 1);
- /* get the name of the image that belongs to this tile */
+ // Get the name of the image that belongs to this tile
if (conf.exists("image"))
_imageName = conf.getString("image");
else
@@ -133,7 +133,7 @@ void Tile::loadImage() {
if (subimage)
info = imageMgr->get(subimage->_srcImageName);
}
- if (!info) { //IF still no info loaded
+ if (!info) { // IF still no info loaded
warning("Error: couldn't load image for tile '%s'", _name.c_str());
return;
}
@@ -160,7 +160,7 @@ void Tile::loadImage() {
//info->image->alphaOff();
- /* draw the tile from the image we found to our tile image */
+ // Draw the tile from the image we found to our tile image
if (subimage) {
Image *tiles = info->_image;
tiles->drawSubRectOn(_image, 0, 0, subimage->x * _scale, subimage->y * _scale, subimage->width * _scale, subimage->height * _scale);
@@ -196,7 +196,7 @@ Direction MapTile::getDirection() const {
}
bool MapTile::setDirection(Direction d) {
- /* if we're already pointing the right direction, do nothing! */
+ // if we're already pointing the right direction, do nothing!
if (getDirection() == d)
return false;
diff --git a/engines/ultima/ultima4/map/tileanim.cpp b/engines/ultima/ultima4/map/tileanim.cpp
index d59fcacd7c..4cacae291d 100644
--- a/engines/ultima/ultima4/map/tileanim.cpp
+++ b/engines/ultima/ultima4/map/tileanim.cpp
@@ -92,9 +92,7 @@ TileAnimTransform *TileAnimTransform::create(const ConfigElement &conf) {
error("Unknown type");
}
- /**
- * See if the transform is performed randomely
- */
+ // See if the transform is performed randomly
if (conf.exists("random"))
transform->_random = conf.getInt("random");
else
@@ -237,9 +235,7 @@ TileAnimContext *TileAnimContext::create(const ConfigElement &conf) {
break;
}
- /**
- * Add the transforms to the context
- */
+ // Add the transforms to the context
if (context) {
vector<ConfigElement> children = conf.getChildren();
@@ -270,9 +266,8 @@ bool TileAnimPlayerDirContext::isInContext(Tile *t, MapTile &mapTile, Direction
return (d == _dir);
}
-/**
- * TileAnimSet
- */
+/*-------------------------------------------------------------------*/
+
TileAnimSet::TileAnimSet(const ConfigElement &conf) {
_name = conf.getString("name");
@@ -316,15 +311,13 @@ void TileAnim::draw(Image *dest, Tile *tile, MapTile &mapTile, Direction dir) {
Std::vector<TileAnimContext *>::const_iterator c;
bool drawn = false;
- /* nothing to do, draw the tile and return! */
+ // Nothing to do, draw the tile and return!
if ((_random && xu4_random(100) > _random) || (!_transforms.size() && !_contexts.size()) || mapTile._freezeAnimation) {
tile->getImage()->drawSubRectOn(dest, 0, 0, 0, mapTile._frame * tile->getHeight(), tile->getWidth(), tile->getHeight());
return;
}
- /**
- * Do global transforms
- */
+ // Do global transforms
for (t = _transforms.begin(); t != _transforms.end(); t++) {
TileAnimTransform *transform = *t;
@@ -336,9 +329,7 @@ void TileAnim::draw(Image *dest, Tile *tile, MapTile &mapTile, Direction dir) {
}
}
- /**
- * Do contextual transforms
- */
+ // Do contextual transforms
for (c = _contexts.begin(); c != _contexts.end(); c++) {
if ((*c)->isInContext(tile, mapTile, dir)) {
TileAnimContext::TileAnimTransformList ctx_transforms = (*c)->getTransforms();
diff --git a/engines/ultima/ultima4/map/tilemap.cpp b/engines/ultima/ultima4/map/tilemap.cpp
index 00191e187f..c854852afb 100644
--- a/engines/ultima/ultima4/map/tilemap.cpp
+++ b/engines/ultima/ultima4/map/tilemap.cpp
@@ -39,17 +39,17 @@ void TileMap::loadAll() {
const Config *config = Config::getInstance();
vector<ConfigElement> conf;
- /* FIXME: make sure tilesets are loaded by now */
+ // FIXME: make sure tilesets are loaded by now
unloadAll();
- /* open the filename for the tileset and parse it! */
+ // Open the filename for the tileset and parse it!
conf = config->getElement("tilesets").getChildren();
- /* load all of the tilemaps */
+ // Load all of the tilemaps
for (Std::vector<ConfigElement>::iterator i = conf.begin(); i != conf.end(); i++) {
if (i->getName() == "tilemap") {
- /* load the tilemap ! */
+ // Load the tilemap !
load(*i);
}
}
@@ -58,13 +58,11 @@ void TileMap::loadAll() {
void TileMap::unloadAll() {
TileIndexMapMap::iterator map;
- /* free all the memory for the tile maps */
+ // Free all the memory for the tile maps
for (map = _tileMaps.begin(); map != _tileMaps.end(); map++)
delete map->_value;
- /* Clear the map so we don't attempt to delete the memory again
- * next time.
- */
+ // Clear the map so we don't attempt to delete the memory again next time
_tileMaps.clear();
}
@@ -81,13 +79,12 @@ void TileMap::load(const ConfigElement &tilemapConf) {
if (i->getName() != "mapping")
continue;
- /* we assume tiles have already been loaded at this point,
- so let's do some translations! */
-
+ // We assume tiles have already been loaded at this point,
+ // so let's do some translations!
int frames = 1;
Common::String tile = i->getString("tile");
- /* find the tile this references */
+ // Find the tile this references
Tile *t = Tileset::get(tileset)->getByName(tile);
if (!t)
error("Error: tile '%s' from '%s' was not found in tileset %s", tile.c_str(), name.c_str(), tileset.c_str());
@@ -97,11 +94,11 @@ void TileMap::load(const ConfigElement &tilemapConf) {
if (i->exists("frames"))
frames = i->getInt("frames");
- /* insert the tile into the tile map */
+ // Insert the tile into the tile map
for (int idx = 0; idx < frames; idx++) {
if (idx < t->getFrames())
tm->_tileMap[index + idx] = MapTile(t->getId(), idx);
- /* frame fell out of the scope of the tile -- frame is set to 0 */
+ // Frame fell out of the scope of the tile -- frame is set to 0
else
tm->_tileMap[index + idx] = MapTile(t->getId(), 0);
}
@@ -109,7 +106,7 @@ void TileMap::load(const ConfigElement &tilemapConf) {
index += frames;
}
- /* add the tilemap to our list */
+ // Add the tilemap to our list
_tileMaps[name] = tm;
}
diff --git a/engines/ultima/ultima4/map/tileset.cpp b/engines/ultima/ultima4/map/tileset.cpp
index a60ac20f17..49f32a2698 100644
--- a/engines/ultima/ultima4/map/tileset.cpp
+++ b/engines/ultima/ultima4/map/tileset.cpp
@@ -30,8 +30,6 @@
namespace Ultima {
namespace Ultima4 {
-using Std::vector;
-
/**
* TileRule Class Implementation
*/
@@ -46,7 +44,7 @@ TileRule *TileRule::findByName(const Common::String &name) {
void TileRule::load() {
const Config *config = Config::getInstance();
- vector<ConfigElement> rules = config->getElement("tileRules").getChildren();
+ Std::vector<ConfigElement> rules = config->getElement("tileRules").getChildren();
for (Std::vector<ConfigElement>::iterator i = rules.begin(); i != rules.end(); i++) {
TileRule *rule = new TileRule();
@@ -79,12 +77,11 @@ bool TileRule::initFromConf(const ConfigElement &conf) {
{ "foreground", MASK_FOREGROUND },
{ "onWaterOnlyReplacement", MASK_WATER_REPLACEMENT},
{ "livingthing", MASK_LIVING_THING }
-
};
static const struct {
- const char *name;
- uint mask;
+ const char *_name;
+ uint _mask;
} movementBooleanAttr[] = {
{ "swimable", MASK_SWIMABLE },
{ "sailable", MASK_SAILABLE },
@@ -94,84 +91,81 @@ bool TileRule::initFromConf(const ConfigElement &conf) {
static const char *speedEnumStrings[] = { "fast", "slow", "vslow", "vvslow", nullptr };
static const char *effectsEnumStrings[] = { "none", "fire", "sleep", "poison", "poisonField", "electricity", "lava", nullptr };
- this->_mask = 0;
- this->_movementMask = 0;
- this->_speed = FAST;
- this->_effect = EFFECT_NONE;
- this->_walkOnDirs = MASK_DIR_ALL;
- this->_walkOffDirs = MASK_DIR_ALL;
- this->_name = conf.getString("name");
+ _mask = 0;
+ _movementMask = 0;
+ _speed = FAST;
+ _effect = EFFECT_NONE;
+ _walkOnDirs = MASK_DIR_ALL;
+ _walkOffDirs = MASK_DIR_ALL;
+ _name = conf.getString("name");
for (i = 0; i < sizeof(booleanAttributes) / sizeof(booleanAttributes[0]); i++) {
if (conf.getBool(booleanAttributes[i].name))
- this->_mask |= booleanAttributes[i].mask;
+ _mask |= booleanAttributes[i].mask;
}
for (i = 0; i < sizeof(movementBooleanAttr) / sizeof(movementBooleanAttr[0]); i++) {
- if (conf.getBool(movementBooleanAttr[i].name))
- this->_movementMask |= movementBooleanAttr[i].mask;
+ if (conf.getBool(movementBooleanAttr[i]._name))
+ _movementMask |= movementBooleanAttr[i]._mask;
}
Common::String cantwalkon = conf.getString("cantwalkon");
if (cantwalkon == "all")
- this->_walkOnDirs = 0;
+ _walkOnDirs = 0;
else if (cantwalkon == "west")
- this->_walkOnDirs = DIR_REMOVE_FROM_MASK(DIR_WEST, this->_walkOnDirs);
+ _walkOnDirs = DIR_REMOVE_FROM_MASK(DIR_WEST, _walkOnDirs);
else if (cantwalkon == "north")
- this->_walkOnDirs = DIR_REMOVE_FROM_MASK(DIR_NORTH, this->_walkOnDirs);
+ _walkOnDirs = DIR_REMOVE_FROM_MASK(DIR_NORTH, _walkOnDirs);
else if (cantwalkon == "east")
- this->_walkOnDirs = DIR_REMOVE_FROM_MASK(DIR_EAST, this->_walkOnDirs);
+ _walkOnDirs = DIR_REMOVE_FROM_MASK(DIR_EAST, _walkOnDirs);
else if (cantwalkon == "south")
- this->_walkOnDirs = DIR_REMOVE_FROM_MASK(DIR_SOUTH, this->_walkOnDirs);
+ _walkOnDirs = DIR_REMOVE_FROM_MASK(DIR_SOUTH, _walkOnDirs);
else if (cantwalkon == "advance")
- this->_walkOnDirs = DIR_REMOVE_FROM_MASK(DIR_ADVANCE, this->_walkOnDirs);
+ _walkOnDirs = DIR_REMOVE_FROM_MASK(DIR_ADVANCE, _walkOnDirs);
else if (cantwalkon == "retreat")
- this->_walkOnDirs = DIR_REMOVE_FROM_MASK(DIR_RETREAT, this->_walkOnDirs);
+ _walkOnDirs = DIR_REMOVE_FROM_MASK(DIR_RETREAT, _walkOnDirs);
Common::String cantwalkoff = conf.getString("cantwalkoff");
if (cantwalkoff == "all")
- this->_walkOffDirs = 0;
+ _walkOffDirs = 0;
else if (cantwalkoff == "west")
- this->_walkOffDirs = DIR_REMOVE_FROM_MASK(DIR_WEST, this->_walkOffDirs);
+ _walkOffDirs = DIR_REMOVE_FROM_MASK(DIR_WEST, _walkOffDirs);
else if (cantwalkoff == "north")
- this->_walkOffDirs = DIR_REMOVE_FROM_MASK(DIR_NORTH, this->_walkOffDirs);
+ _walkOffDirs = DIR_REMOVE_FROM_MASK(DIR_NORTH, _walkOffDirs);
else if (cantwalkoff == "east")
- this->_walkOffDirs = DIR_REMOVE_FROM_MASK(DIR_EAST, this->_walkOffDirs);
+ _walkOffDirs = DIR_REMOVE_FROM_MASK(DIR_EAST, _walkOffDirs);
else if (cantwalkoff == "south")
- this->_walkOffDirs = DIR_REMOVE_FROM_MASK(DIR_SOUTH, this->_walkOffDirs);
+ _walkOffDirs = DIR_REMOVE_FROM_MASK(DIR_SOUTH, _walkOffDirs);
else if (cantwalkoff == "advance")
- this->_walkOffDirs = DIR_REMOVE_FROM_MASK(DIR_ADVANCE, this->_walkOffDirs);
+ _walkOffDirs = DIR_REMOVE_FROM_MASK(DIR_ADVANCE, _walkOffDirs);
else if (cantwalkoff == "retreat")
- this->_walkOffDirs = DIR_REMOVE_FROM_MASK(DIR_RETREAT, this->_walkOffDirs);
+ _walkOffDirs = DIR_REMOVE_FROM_MASK(DIR_RETREAT, _walkOffDirs);
- this->_speed = static_cast<TileSpeed>(conf.getEnum("speed", speedEnumStrings));
- this->_effect = static_cast<TileEffect>(conf.getEnum("effect", effectsEnumStrings));
+ _speed = static_cast<TileSpeed>(conf.getEnum("speed", speedEnumStrings));
+ _effect = static_cast<TileEffect>(conf.getEnum("effect", effectsEnumStrings));
return true;
}
+/*-------------------------------------------------------------------*/
-/**
- * Tileset Class Implementation
- */
-
-/* static member variables */
+// Static member variables
Tileset::TilesetMap Tileset::tilesets;
void Tileset::loadAll() {
const Config *config = Config::getInstance();
- vector<ConfigElement> conf;
+ Std::vector<ConfigElement> conf;
unloadAll();
- // get the config element for all tilesets
+ // Get the config element for all tilesets
conf = config->getElement("tilesets").getChildren();
- // load tile rules
+ // Load tile rules
if (!TileRule::_rules.size())
TileRule::load();
- // load all of the tilesets
+ // Load all of the tilesets
for (Std::vector<ConfigElement>::iterator i = conf.begin(); i != conf.end(); i++) {
if (i->getName() == "tileset") {
@@ -182,14 +176,14 @@ void Tileset::loadAll() {
}
}
- // load tile maps, including translations from index to id
+ // Load tile maps, including translations from index to id
TileMap::loadAll();
}
void Tileset::unloadAll() {
TilesetMap::iterator i;
- // unload all tilemaps
+ // Unload all tilemaps
TileMap::unloadAll();
for (i = tilesets.begin(); i != tilesets.end(); i++) {
@@ -248,7 +242,7 @@ void Tileset::load(const ConfigElement &tilesetConf) {
else _extends = nullptr;
int index = 0;
- vector<ConfigElement> children = tilesetConf.getChildren();
+ Std::vector<ConfigElement> children = tilesetConf.getChildren();
for (Std::vector<ConfigElement>::iterator i = children.begin(); i != children.end(); i++) {
if (i->getName() != "tile")
continue;
@@ -256,7 +250,7 @@ void Tileset::load(const ConfigElement &tilesetConf) {
Tile *tile = new Tile(this);
tile->loadProperties(*i);
- /* add the tile to our tileset */
+ // Add the tile to our tileset
_tiles[tile->getId()] = tile;
_nameMap[tile->getName()] = tile;
@@ -268,7 +262,7 @@ void Tileset::load(const ConfigElement &tilesetConf) {
void Tileset::unloadImages() {
Tileset::TileIdMap::iterator i;
- /* free all the image memory and nullify so that reloading can automatically take place lazily */
+ // Free all the image memory and nullify so that reloading can automatically take place lazily
for (i = _tiles.begin(); i != _tiles.end(); i++) {
i->_value->deleteImage();
}
@@ -277,7 +271,7 @@ void Tileset::unloadImages() {
void Tileset::unload() {
Tileset::TileIdMap::iterator i;
- /* free all the memory for the tiles */
+ // Free all the memory for the tiles
for (i = _tiles.begin(); i != _tiles.end(); i++)
delete i->_value;
Commit: f5c5f15a9326cac5e084d26e6848eb26e54d6dc6
https://github.com/scummvm/scummvm/commit/f5c5f15a9326cac5e084d26e6848eb26e54d6dc6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-22T21:38:52-07:00
Commit Message:
ULTIMA4: Split MapTile into it's own source file
Changed paths:
A engines/ultima/ultima4/map/map_tile.cpp
A engines/ultima/ultima4/map/map_tile.h
engines/ultima/module.mk
engines/ultima/ultima4/core/types.h
engines/ultima/ultima4/game/object.h
engines/ultima/ultima4/gfx/screen.h
engines/ultima/ultima4/map/annotation.h
engines/ultima/ultima4/map/tile.cpp
engines/ultima/ultima4/map/tilemap.h
diff --git a/engines/ultima/module.mk b/engines/ultima/module.mk
index 3e64d5067b..caa0717493 100644
--- a/engines/ultima/module.mk
+++ b/engines/ultima/module.mk
@@ -206,6 +206,7 @@ MODULE_OBJS := \
ultima4/map/direction.o \
ultima4/map/dungeon.o \
ultima4/map/dungeonview.o \
+ ultima4/map/map_tile.o \
ultima4/map/movement.o \
ultima4/map/shrine.o \
ultima4/map/location.o \
diff --git a/engines/ultima/ultima4/core/types.h b/engines/ultima/ultima4/core/types.h
index e22f112998..1db242b7f9 100644
--- a/engines/ultima/ultima4/core/types.h
+++ b/engines/ultima/ultima4/core/types.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ULTIMA4_CORE_TYPEDEFS_H
-#define ULTIMA4_CORE_TYPEDEFS_H
+#ifndef ULTIMA4_CORE_TYPES_H
+#define ULTIMA4_CORE_TYPES_H
#include "ultima/ultima4/map/direction.h"
#include "common/scummsys.h"
@@ -62,55 +62,6 @@ enum TileAnimationStyle {
ANIM_FRAMES
};
-/**
- * A MapTile is a specific instance of a Tile.
- */
-class MapTile {
-public:
- MapTile() : _id(0), _frame(0) {}
- MapTile(const TileId &i, byte f = 0) : _id(i), _frame(f), _freezeAnimation(false) {}
- MapTile(const MapTile &t) : _id(t._id), _frame(t._frame), _freezeAnimation(t._freezeAnimation) {}
-
- TileId getId() const {
- return _id;
- }
- byte getFrame() const {
- return _frame;
- }
- bool getFreezeAnimation() const {
- return _freezeAnimation;
- }
-
- bool operator==(const MapTile &m) const {
- return _id == m._id;
- }
- bool operator==(const TileId &i) const {
- return _id == i;
- }
- bool operator!=(const MapTile &m) const {
- return _id != m._id;
- }
- bool operator!=(const TileId &i) const {
- return _id != i;
- }
- bool operator<(const MapTile &m) const {
- return _id < m._id; // for Std::less
- }
-
- /**
- * MapTile Class Implementation
- */
- Direction getDirection() const;
- bool setDirection(Direction d);
-
- const Tile *getTileType() const;
-
- // Properties
- TileId _id;
- byte _frame;
- bool _freezeAnimation;
-};
-
/**
* An Uncopyable has no default copy constructor of operator=. A subclass may derive from
* Uncopyable at any level of visibility, even private, and subclasses will not have a default copy
diff --git a/engines/ultima/ultima4/game/object.h b/engines/ultima/ultima4/game/object.h
index 27357c5360..6ef2e080a2 100644
--- a/engines/ultima/ultima4/game/object.h
+++ b/engines/ultima/ultima4/game/object.h
@@ -23,7 +23,7 @@
#define ULTIMA4_GAME_OBJECT_H
#include "ultima/ultima4/core/coords.h"
-#include "ultima/ultima4/map/tile.h"
+#include "ultima/ultima4/map/map_tile.h"
#include "ultima/ultima4/core/types.h"
namespace Ultima {
diff --git a/engines/ultima/ultima4/gfx/screen.h b/engines/ultima/ultima4/gfx/screen.h
index 8d489aa2bc..db1e82820c 100644
--- a/engines/ultima/ultima4/gfx/screen.h
+++ b/engines/ultima/ultima4/gfx/screen.h
@@ -29,6 +29,7 @@
#include "ultima/ultima4/filesys/u4file.h"
#include "ultima/ultima4/gfx/scale.h"
#include "ultima/ultima4/map/direction.h"
+#include "ultima/ultima4/map/map_tile.h"
#include "ultima/shared/core/file.h"
namespace Ultima {
diff --git a/engines/ultima/ultima4/map/annotation.h b/engines/ultima/ultima4/map/annotation.h
index 019bce4767..0a919273c9 100644
--- a/engines/ultima/ultima4/map/annotation.h
+++ b/engines/ultima/ultima4/map/annotation.h
@@ -25,6 +25,7 @@
#include "ultima/ultima4/core/coords.h"
#include "ultima/ultima4/core/types.h"
+#include "ultima/ultima4/map/map_tile.h"
#include "common/list.h"
namespace Ultima {
diff --git a/engines/ultima/ultima4/map/map_tile.cpp b/engines/ultima/ultima4/map/map_tile.cpp
new file mode 100644
index 0000000000..e3cea51885
--- /dev/null
+++ b/engines/ultima/ultima4/map/map_tile.cpp
@@ -0,0 +1,52 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "ultima/ultima4/map/map_tile.h"
+
+namespace Ultima {
+namespace Ultima4 {
+
+Direction MapTile::getDirection() const {
+ return getTileType()->directionForFrame(_frame);
+}
+
+bool MapTile::setDirection(Direction d) {
+ // if we're already pointing the right direction, do nothing!
+ if (getDirection() == d)
+ return false;
+
+ const Tile *type = getTileType();
+
+ int new_frame = type->frameForDirection(d);
+ if (new_frame != -1) {
+ _frame = new_frame;
+ return true;
+ }
+ return false;
+}
+
+const Tile *MapTile::getTileType() const {
+ return Tileset::findTileById(_id);
+}
+
+} // End of namespace Ultima4
+} // End of namespace Ultima
diff --git a/engines/ultima/ultima4/map/map_tile.h b/engines/ultima/ultima4/map/map_tile.h
new file mode 100644
index 0000000000..f8b512d9f9
--- /dev/null
+++ b/engines/ultima/ultima4/map/map_tile.h
@@ -0,0 +1,87 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ULTIMA4_MAP_MAP_TILE_H
+#define ULTIMA4_MAP_MAP_TILE_H
+
+#include "ultima/ultima4/core/types.h"
+#include "ultima/ultima4/map/tile.h"
+
+namespace Ultima {
+namespace Ultima4 {
+
+/**
+ * A MapTile is a specific instance of a Tile.
+ */
+class MapTile {
+public:
+ MapTile() : _id(0), _frame(0) {
+ }
+ MapTile(const TileId &i, byte f = 0) : _id(i), _frame(f), _freezeAnimation(false) {
+ }
+ MapTile(const MapTile &t) : _id(t._id), _frame(t._frame), _freezeAnimation(t._freezeAnimation) {
+ }
+
+ TileId getId() const {
+ return _id;
+ }
+ byte getFrame() const {
+ return _frame;
+ }
+ bool getFreezeAnimation() const {
+ return _freezeAnimation;
+ }
+
+ bool operator==(const MapTile &m) const {
+ return _id == m._id;
+ }
+ bool operator==(const TileId &i) const {
+ return _id == i;
+ }
+ bool operator!=(const MapTile &m) const {
+ return _id != m._id;
+ }
+ bool operator!=(const TileId &i) const {
+ return _id != i;
+ }
+ bool operator<(const MapTile &m) const {
+ return _id < m._id; // for Std::less
+ }
+
+ /**
+ * MapTile Class Implementation
+ */
+ Direction getDirection() const;
+ bool setDirection(Direction d);
+
+ const Tile *getTileType() const;
+
+ // Properties
+ TileId _id;
+ byte _frame;
+ bool _freezeAnimation;
+};
+
+} // End of namespace Ultima4
+} // End of namespace Ultima
+
+#endif
diff --git a/engines/ultima/ultima4/map/tile.cpp b/engines/ultima/ultima4/map/tile.cpp
index cf962cbf93..ad9f645e8a 100644
--- a/engines/ultima/ultima4/map/tile.cpp
+++ b/engines/ultima/ultima4/map/tile.cpp
@@ -191,25 +191,6 @@ void Tile::deleteImage() {
_scale = settings._scale;
}
-Direction MapTile::getDirection() const {
- return getTileType()->directionForFrame(_frame);
-}
-
-bool MapTile::setDirection(Direction d) {
- // if we're already pointing the right direction, do nothing!
- if (getDirection() == d)
- return false;
-
- const Tile *type = getTileType();
-
- int new_frame = type->frameForDirection(d);
- if (new_frame != -1) {
- _frame = new_frame;
- return true;
- }
- return false;
-}
-
bool Tile::isDungeonFloor() const {
Tile *floor = _tileset->getByName("brick_floor");
if (_id == floor->_id)
@@ -240,10 +221,5 @@ int Tile::frameForDirection(Direction d) const {
return -1;
}
-
-const Tile *MapTile::getTileType() const {
- return Tileset::findTileById(_id);
-}
-
} // End of namespace Ultima4
} // End of namespace Ultima
diff --git a/engines/ultima/ultima4/map/tilemap.h b/engines/ultima/ultima4/map/tilemap.h
index 8b22dbe5e0..fac999c58a 100644
--- a/engines/ultima/ultima4/map/tilemap.h
+++ b/engines/ultima/ultima4/map/tilemap.h
@@ -24,6 +24,7 @@
#define ULTIMA4_MAP_TILEMAP_H
#include "ultima/ultima4/core/types.h"
+#include "ultima/ultima4/map/map_tile.h"
#include "ultima/shared/std/containers.h"
namespace Ultima {
Commit: ae0f99f9cebf6fc4820abfbc4aac2a439bc53c71
https://github.com/scummvm/scummvm/commit/ae0f99f9cebf6fc4820abfbc4aac2a439bc53c71
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-22T21:38:52-07:00
Commit Message:
ULTIMA4: Simplify mouse areas array to remove button commands
Changed paths:
engines/ultima/ultima4/controllers/game_controller.cpp
engines/ultima/ultima4/events/event.cpp
engines/ultima/ultima4/gfx/screen.h
diff --git a/engines/ultima/ultima4/controllers/game_controller.cpp b/engines/ultima/ultima4/controllers/game_controller.cpp
index a6ee13bebf..ad5daeae9c 100644
--- a/engines/ultima/ultima4/controllers/game_controller.cpp
+++ b/engines/ultima/ultima4/controllers/game_controller.cpp
@@ -48,11 +48,11 @@ using namespace std;
GameController *g_game = nullptr;
static const MouseArea MOUSE_AREAS[] = {
- { 3, { { 8, 8 }, { 8, 184 }, { 96, 96 } }, MC_WEST, { KEYBIND_INTERACT, KEYBIND_NONE, KEYBIND_LEFT } },
- { 3, { { 8, 8 }, { 184, 8 }, { 96, 96 } }, MC_NORTH, { KEYBIND_INTERACT, KEYBIND_NONE, KEYBIND_UP } },
- { 3, { { 184, 8 }, { 184, 184 }, { 96, 96 } }, MC_EAST, { KEYBIND_INTERACT, KEYBIND_NONE, KEYBIND_RIGHT } },
- { 3, { { 8, 184 }, { 184, 184 }, { 96, 96 } }, MC_SOUTH, { KEYBIND_INTERACT, KEYBIND_NONE, KEYBIND_DOWN } },
- { 0, { { 0, 0 }, { 0, 0 }, { 0, 0 } }, MC_NORTH, { KEYBIND_NONE, KEYBIND_NONE, KEYBIND_NONE } }
+ { 3, { { 8, 8 }, { 8, 184 }, { 96, 96 } }, MC_WEST },
+ { 3, { { 8, 8 }, { 184, 8 }, { 96, 96 } }, MC_NORTH },
+ { 3, { { 184, 8 }, { 184, 184 }, { 96, 96 } }, MC_EAST },
+ { 3, { { 8, 184 }, { 184, 184 }, { 96, 96 } }, MC_SOUTH },
+ { 0, { { 0, 0 }, { 0, 0 }, { 0, 0 } }, MC_NORTH }
};
GameController::GameController() : _mapArea(BORDER_WIDTH, BORDER_HEIGHT, VIEWPORT_W, VIEWPORT_H), _paused(false), _pausedTimer(0) {
diff --git a/engines/ultima/ultima4/events/event.cpp b/engines/ultima/ultima4/events/event.cpp
index d4d7d03f74..9457ceb608 100644
--- a/engines/ultima/ultima4/events/event.cpp
+++ b/engines/ultima/ultima4/events/event.cpp
@@ -252,19 +252,13 @@ void EventHandler::handleMouseMotionEvent(const Common::Event &event) {
}
void EventHandler::handleMouseButtonDownEvent(const Common::Event &event, Controller *controller, updateScreenCallback updateScreen) {
- int button = 0;
- if (event.type == Common::EVENT_MBUTTONDOWN)
- button = 1;
- else if (event.type == Common::EVENT_RBUTTONDOWN)
- button = 2;
-
- if (!settings._mouseOptions._enabled)
+ if (!settings._mouseOptions._enabled || event.type != Common::EVENT_LBUTTONDOWN)
return;
const MouseArea *area = eventHandler->mouseAreaForPoint(event.mouse.x, event.mouse.y);
- if (!area || area->_command[button] == KEYBIND_NONE)
+ if (!area)
return;
- controller->keybinder((KeybindingAction)area->_command[button]);
+ controller->keybinder(KEYBIND_INTERACT);
if (updateScreen)
(*updateScreen)();
diff --git a/engines/ultima/ultima4/gfx/screen.h b/engines/ultima/ultima4/gfx/screen.h
index db1e82820c..7317371577 100644
--- a/engines/ultima/ultima4/gfx/screen.h
+++ b/engines/ultima/ultima4/gfx/screen.h
@@ -91,7 +91,6 @@ struct MouseArea {
int x, y;
} _point[3];
MouseCursor _cursor;
- int _command[3];
};
struct Layout {
Commit: 56585cb814fae12836bcc84bf841698e954fd1f4
https://github.com/scummvm/scummvm/commit/56585cb814fae12836bcc84bf841698e954fd1f4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-22T21:38:52-07:00
Commit Message:
ULTIMA4: Remove custom keycode defines
Changed paths:
engines/ultima/ultima4/controllers/alpha_action_controller.cpp
engines/ultima/ultima4/controllers/combat_controller.cpp
engines/ultima/ultima4/controllers/key_handler_controller.cpp
engines/ultima/ultima4/controllers/menu_controller.cpp
engines/ultima/ultima4/controllers/read_string_controller.cpp
engines/ultima/ultima4/controllers/reagents_menu_controller.cpp
engines/ultima/ultima4/controllers/ztats_controller.cpp
engines/ultima/ultima4/events/event.cpp
engines/ultima/ultima4/events/event.h
engines/ultima/ultima4/map/direction.cpp
diff --git a/engines/ultima/ultima4/controllers/alpha_action_controller.cpp b/engines/ultima/ultima4/controllers/alpha_action_controller.cpp
index df0ddcc4fb..4bae9f0f0b 100644
--- a/engines/ultima/ultima4/controllers/alpha_action_controller.cpp
+++ b/engines/ultima/ultima4/controllers/alpha_action_controller.cpp
@@ -34,7 +34,8 @@ bool AlphaActionController::keyPressed(int key) {
if (key >= 'A' && key <= toupper(_lastValidLetter)) {
_value = key - 'A';
doneWaiting();
- } else if (key == U4_SPACE || key == U4_ESC || key == U4_ENTER) {
+ } else if (key == Common::KEYCODE_SPACE || key == Common::KEYCODE_ESCAPE
+ || key == Common::KEYCODE_RETURN) {
g_screen->screenMessage("\n");
_value = -1;
doneWaiting();
@@ -43,6 +44,7 @@ bool AlphaActionController::keyPressed(int key) {
g_screen->update();
return KeyHandler::defaultHandler(key, nullptr);
}
+
return true;
}
diff --git a/engines/ultima/ultima4/controllers/combat_controller.cpp b/engines/ultima/ultima4/controllers/combat_controller.cpp
index 727c90b800..cb9dc7f4fe 100644
--- a/engines/ultima/ultima4/controllers/combat_controller.cpp
+++ b/engines/ultima/ultima4/controllers/combat_controller.cpp
@@ -837,14 +837,14 @@ bool CombatController::keyPressed(int key) {
bool endTurn = true;
switch (key) {
- case U4_UP:
- case U4_DOWN:
- case U4_LEFT:
- case U4_RIGHT:
+ case Common::KEYCODE_UP:
+ case Common::KEYCODE_DOWN:
+ case Common::KEYCODE_LEFT:
+ case Common::KEYCODE_RIGHT:
g_context->_location->move(keyToDirection(key), true);
break;
- case U4_ESC:
+ case Common::KEYCODE_ESCAPE:
if (settings._debug)
end(false); /* don't adjust karma */
else g_screen->screenMessage("Bad command\n");
@@ -855,7 +855,7 @@ bool CombatController::keyPressed(int key) {
g_screen->screenMessage("Pass\n");
break;
- case U4_FKEY: {
+ case Common::KEYCODE_F1: {
if (settings._debug)
gameDestroyAllCreatures();
else valid = false;
@@ -865,13 +865,13 @@ bool CombatController::keyPressed(int key) {
// Change the speed of battle
case '+':
case '-':
- case U4_KEYPAD_ENTER: {
+ case Common::KEYCODE_KP_ENTER: {
int old_speed = settings._battleSpeed;
if (key == '+' && ++settings._battleSpeed > MAX_BATTLE_SPEED)
settings._battleSpeed = MAX_BATTLE_SPEED;
else if (key == '-' && --settings._battleSpeed == 0)
settings._battleSpeed = 1;
- else if (key == U4_KEYPAD_ENTER)
+ else if (key == Common::KEYCODE_KP_ENTER)
settings._battleSpeed = DEFAULT_BATTLE_SPEED;
if (old_speed != settings._battleSpeed) {
@@ -923,7 +923,7 @@ bool CombatController::keyPressed(int key) {
break;
#ifdef IOS
- case U4_ENTER: // Fall through and get the chest.
+ case Common::KEYCODE_RETURN: // Fall through and get the chest.
#endif
case 'g':
g_screen->screenMessage("Get Chest!\n");
diff --git a/engines/ultima/ultima4/controllers/key_handler_controller.cpp b/engines/ultima/ultima4/controllers/key_handler_controller.cpp
index b13c096c75..0c02ddf8a9 100644
--- a/engines/ultima/ultima4/controllers/key_handler_controller.cpp
+++ b/engines/ultima/ultima4/controllers/key_handler_controller.cpp
@@ -48,21 +48,7 @@ int KeyHandler::setKeyRepeat(int delay, int interval) {
}
bool KeyHandler::globalHandler(int key) {
- switch (key) {
-#if defined(MACOSX)
- case U4_META + 'q': /* Cmd+q */
- case U4_META + 'x': /* Cmd+x */
-#endif
- case U4_ALT + 'x': /* Alt+x */
-#if defined(WIN32)
- case U4_ALT + U4_FKEY + 3:
-#endif
- g_ultima->quitGame();
- EventHandler::end();
- return true;
- default:
- return false;
- }
+ return false;
}
bool KeyHandler::defaultHandler(int key, void *data) {
@@ -98,15 +84,15 @@ bool KeyHandler::handle(int key) {
bool KeyHandler::isKeyIgnored(int key) {
switch (key) {
- case U4_RIGHT_SHIFT:
- case U4_LEFT_SHIFT:
- case U4_RIGHT_CTRL:
- case U4_LEFT_CTRL:
- case U4_RIGHT_ALT:
- case U4_LEFT_ALT:
- case U4_RIGHT_META:
- case U4_LEFT_META:
- case U4_TAB:
+ case Common::KEYCODE_RSHIFT:
+ case Common::KEYCODE_LSHIFT:
+ case Common::KEYCODE_RCTRL:
+ case Common::KEYCODE_LCTRL:
+ case Common::KEYCODE_RALT:
+ case Common::KEYCODE_LALT:
+ case Common::KEYCODE_RMETA:
+ case Common::KEYCODE_LMETA:
+ case Common::KEYCODE_TAB:
return true;
default:
return false;
diff --git a/engines/ultima/ultima4/controllers/menu_controller.cpp b/engines/ultima/ultima4/controllers/menu_controller.cpp
index 54b720cec3..17b2e3885f 100644
--- a/engines/ultima/ultima4/controllers/menu_controller.cpp
+++ b/engines/ultima/ultima4/controllers/menu_controller.cpp
@@ -41,20 +41,20 @@ bool MenuController::keyPressed(int key) {
_view->disableCursor();
switch (key) {
- case U4_UP:
+ case Common::KEYCODE_UP:
_menu->prev();
break;
- case U4_DOWN:
+ case Common::KEYCODE_DOWN:
_menu->next();
break;
- case U4_LEFT:
- case U4_RIGHT:
- case U4_ENTER: {
+ case Common::KEYCODE_LEFT:
+ case Common::KEYCODE_RIGHT:
+ case Common::KEYCODE_RETURN: {
MenuEvent::Type action = MenuEvent::ACTIVATE;
- if (key == U4_LEFT)
+ if (key == Common::KEYCODE_LEFT)
action = MenuEvent::DECREMENT;
- else if (key == U4_RIGHT)
+ else if (key == Common::KEYCODE_RIGHT)
action = MenuEvent::INCREMENT;
_menu->activateItem(-1, action);
}
diff --git a/engines/ultima/ultima4/controllers/read_string_controller.cpp b/engines/ultima/ultima4/controllers/read_string_controller.cpp
index d9c9987885..f71b4c57af 100644
--- a/engines/ultima/ultima4/controllers/read_string_controller.cpp
+++ b/engines/ultima/ultima4/controllers/read_string_controller.cpp
@@ -47,7 +47,7 @@ bool ReadStringController::keyPressed(int key) {
int valid = true, len = _value.size();
size_t pos = Common::String::npos;
- if (key < U4_ALT)
+ if (key < 0x80)
pos = _accepted.findFirstOf(key);
if (pos != Common::String::npos) {
diff --git a/engines/ultima/ultima4/controllers/reagents_menu_controller.cpp b/engines/ultima/ultima4/controllers/reagents_menu_controller.cpp
index 613f07c4c2..f8f9cf6568 100644
--- a/engines/ultima/ultima4/controllers/reagents_menu_controller.cpp
+++ b/engines/ultima/ultima4/controllers/reagents_menu_controller.cpp
@@ -41,13 +41,13 @@ bool ReagentsMenuController::keyPressed(int key) {
Menu::MenuItemList::iterator mi = _menu->getById(key - 'a');
if ((*mi)->isVisible()) {
_menu->setCurrent(_menu->getById(key - 'a'));
- keyPressed(U4_SPACE);
+ keyPressed(Common::KEYCODE_SPACE);
}
}
break;
- case U4_LEFT:
- case U4_RIGHT:
- case U4_SPACE:
+ case Common::KEYCODE_LEFT:
+ case Common::KEYCODE_RIGHT:
+ case Common::KEYCODE_SPACE:
if (_menu->isVisible()) {
MenuItem *item = *_menu->getCurrent();
@@ -60,11 +60,12 @@ bool ReagentsMenuController::keyPressed(int key) {
_ingredients->removeReagent((Reagent)item->getId());
}
break;
- case U4_ENTER:
+
+ case Common::KEYCODE_RETURN:
eventHandler->setControllerDone();
break;
- case U4_ESC:
+ case Common::KEYCODE_ESCAPE:
_ingredients->revert();
eventHandler->setControllerDone();
break;
diff --git a/engines/ultima/ultima4/controllers/ztats_controller.cpp b/engines/ultima/ultima4/controllers/ztats_controller.cpp
index 94fb76e915..e9c9f55032 100644
--- a/engines/ultima/ultima4/controllers/ztats_controller.cpp
+++ b/engines/ultima/ultima4/controllers/ztats_controller.cpp
@@ -31,12 +31,12 @@ namespace Ultima4 {
bool ZtatsController::keyPressed(int key) {
switch (key) {
- case U4_UP:
- case U4_LEFT:
+ case Common::KEYCODE_UP:
+ case Common::KEYCODE_LEFT:
g_context->_stats->prevItem();
return true;
- case U4_DOWN:
- case U4_RIGHT:
+ case Common::KEYCODE_DOWN:
+ case Common::KEYCODE_RIGHT:
g_context->_stats->nextItem();
return true;
case '1':
@@ -53,9 +53,9 @@ bool ZtatsController::keyPressed(int key) {
case '0':
g_context->_stats->setView(StatsView(STATS_WEAPONS));
return true;
- case U4_ESC:
- case U4_SPACE:
- case U4_ENTER:
+ case Common::KEYCODE_ESCAPE:
+ case Common::KEYCODE_SPACE:
+ case Common::KEYCODE_RETURN:
g_context->_stats->setView(StatsView(STATS_PARTY_OVERVIEW));
doneWaiting();
return true;
diff --git a/engines/ultima/ultima4/events/event.cpp b/engines/ultima/ultima4/events/event.cpp
index 9457ceb608..09027e15d7 100644
--- a/engines/ultima/ultima4/events/event.cpp
+++ b/engines/ultima/ultima4/events/event.cpp
@@ -269,28 +269,10 @@ void EventHandler::handleKeyDownEvent(const Common::Event &event, Controller *co
int key;
bool processed;
- if (event.kbd.keycode == Common::KEYCODE_UP)
- key = U4_UP;
- else if (event.kbd.keycode == Common::KEYCODE_DOWN)
- key = U4_DOWN;
- else if (event.kbd.keycode == Common::KEYCODE_LEFT)
- key = U4_LEFT;
- else if (event.kbd.keycode == Common::KEYCODE_RIGHT)
- key = U4_RIGHT;
- else if (event.kbd.keycode == Common::KEYCODE_BACKSPACE ||
- event.kbd.keycode == Common::KEYCODE_DELETE)
- key = U4_BACKSPACE;
- else {
- key = event.kbd.ascii;
- if (!key)
- return;
-
- if (event.kbd.flags & Common::KBD_ALT)
- key += U4_ALT;
-
- if (event.kbd.flags & Common::KBD_META)
- key += U4_META;
- }
+ key = event.kbd.ascii;
+ if (!key)
+ return;
+ key += event.kbd.flags << 16;
debug(1, "key event: sym = %d, mod = %d; translated = %d",
event.kbd.keycode, event.kbd.flags, key);
diff --git a/engines/ultima/ultima4/events/event.h b/engines/ultima/ultima4/events/event.h
index 405180c894..961f44a2dd 100644
--- a/engines/ultima/ultima4/events/event.h
+++ b/engines/ultima/ultima4/events/event.h
@@ -38,28 +38,6 @@ namespace Ultima4 {
#define eventHandler (EventHandler::getInstance())
-#define U4_UP '['
-#define U4_DOWN '/'
-#define U4_LEFT ';'
-#define U4_RIGHT '\''
-#define U4_BACKSPACE 8
-#define U4_TAB 9
-#define U4_SPACE ' '
-#define U4_ESC 27
-#define U4_ENTER 13
-#define U4_ALT 128
-#define U4_KEYPAD_ENTER Common::KEYCODE_KP_ENTER
-#define U4_META 323
-#define U4_FKEY 282
-#define U4_RIGHT_SHIFT Common::KEYCODE_RSHIFT
-#define U4_LEFT_SHIFT Common::KEYCODE_LSHIFT
-#define U4_RIGHT_CTRL Common::KEYCODE_RCTRL
-#define U4_LEFT_CTRL Common::KEYCODE_LCTRL
-#define U4_RIGHT_ALT Common::KEYCODE_RALT
-#define U4_LEFT_ALT Common::KEYCODE_LALT
-#define U4_RIGHT_META Common::KEYCODE_RMETA
-#define U4_LEFT_META Common::KEYCODE_LMETA
-
#if defined(IOS)
#ifndef __OBJC__
typedef void *TimedManagerHelper;
diff --git a/engines/ultima/ultima4/map/direction.cpp b/engines/ultima/ultima4/map/direction.cpp
index 236fccdbdf..cacb862ff9 100644
--- a/engines/ultima/ultima4/map/direction.cpp
+++ b/engines/ultima/ultima4/map/direction.cpp
@@ -114,13 +114,13 @@ Direction dirNormalize(Direction orientation, Direction dir) {
Direction keyToDirection(int key) {
switch (key) {
- case U4_UP:
+ case Common::KEYCODE_UP:
return DIR_NORTH;
- case U4_DOWN:
+ case Common::KEYCODE_DOWN:
return DIR_SOUTH;
- case U4_LEFT:
+ case Common::KEYCODE_LEFT:
return DIR_WEST;
- case U4_RIGHT:
+ case Common::KEYCODE_RIGHT:
return DIR_EAST;
default:
return DIR_NONE;
@@ -130,13 +130,13 @@ Direction keyToDirection(int key) {
int directionToKey(Direction dir) {
switch (dir) {
case DIR_WEST:
- return U4_LEFT;
+ return Common::KEYCODE_LEFT;
case DIR_NORTH:
- return U4_UP;
+ return Common::KEYCODE_UP;
case DIR_EAST:
- return U4_RIGHT;
+ return Common::KEYCODE_RIGHT;
case DIR_SOUTH:
- return U4_DOWN;
+ return Common::KEYCODE_DOWN;
case DIR_NONE:
case DIR_ADVANCE:
Commit: 2004e2740c285fd13292b028ea493c0f1db1c5d9
https://github.com/scummvm/scummvm/commit/2004e2740c285fd13292b028ea493c0f1db1c5d9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-22T21:38:52-07:00
Commit Message:
ULTIMA4: Renamed event.cpp to event_handler.cpp
Changed paths:
A engines/ultima/ultima4/events/event_handler.cpp
A engines/ultima/ultima4/events/event_handler.h
R engines/ultima/ultima4/events/event.cpp
R engines/ultima/ultima4/events/event.h
engines/ultima/module.mk
engines/ultima/ultima4/controllers/alpha_action_controller.cpp
engines/ultima/ultima4/controllers/alpha_action_controller.h
engines/ultima/ultima4/controllers/combat_controller.cpp
engines/ultima/ultima4/controllers/controller.cpp
engines/ultima/ultima4/controllers/intro_controller.cpp
engines/ultima/ultima4/controllers/key_handler_controller.cpp
engines/ultima/ultima4/controllers/menu_controller.cpp
engines/ultima/ultima4/controllers/read_choice_controller.h
engines/ultima/ultima4/controllers/read_string_controller.h
engines/ultima/ultima4/controllers/wait_controller.cpp
engines/ultima/ultima4/controllers/ztats_controller.cpp
engines/ultima/ultima4/core/settings.cpp
engines/ultima/ultima4/game/codex.cpp
engines/ultima/ultima4/game/death.cpp
engines/ultima/ultima4/game/game.cpp
engines/ultima/ultima4/game/game.h
engines/ultima/ultima4/game/menu.cpp
engines/ultima/ultima4/game/menu.h
engines/ultima/ultima4/game/person.cpp
engines/ultima/ultima4/game/script.cpp
engines/ultima/ultima4/game/spell.cpp
engines/ultima/ultima4/game/textview.cpp
engines/ultima/ultima4/gfx/screen.cpp
engines/ultima/ultima4/map/annotation.cpp
engines/ultima/ultima4/map/direction.cpp
engines/ultima/ultima4/map/location.cpp
engines/ultima/ultima4/map/movement.cpp
engines/ultima/ultima4/map/shrine.cpp
engines/ultima/ultima4/sound/music.cpp
engines/ultima/ultima4/ultima4.cpp
diff --git a/engines/ultima/module.mk b/engines/ultima/module.mk
index caa0717493..d3489d2edc 100644
--- a/engines/ultima/module.mk
+++ b/engines/ultima/module.mk
@@ -164,7 +164,7 @@ MODULE_OBJS := \
ultima4/core/debugger_actions.o \
ultima4/core/settings.o \
ultima4/core/utils.o \
- ultima4/events/event.o \
+ ultima4/events/event_handler.o \
ultima4/events/timed_event_mgr.o \
ultima4/filesys/filesystem.o \
ultima4/filesys/rle.o \
diff --git a/engines/ultima/ultima4/controllers/alpha_action_controller.cpp b/engines/ultima/ultima4/controllers/alpha_action_controller.cpp
index 4bae9f0f0b..cfdc58bc76 100644
--- a/engines/ultima/ultima4/controllers/alpha_action_controller.cpp
+++ b/engines/ultima/ultima4/controllers/alpha_action_controller.cpp
@@ -21,7 +21,7 @@
*/
#include "ultima/ultima4/controllers/alpha_action_controller.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/gfx/screen.h"
namespace Ultima {
diff --git a/engines/ultima/ultima4/controllers/alpha_action_controller.h b/engines/ultima/ultima4/controllers/alpha_action_controller.h
index 0a7b335150..f50e50f492 100644
--- a/engines/ultima/ultima4/controllers/alpha_action_controller.h
+++ b/engines/ultima/ultima4/controllers/alpha_action_controller.h
@@ -24,7 +24,7 @@
#define ULTIMA4_CONTROLLERS_ALPHA_ACTION_CONTROLLER_H
#include "ultima/ultima4/controllers/controller.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
namespace Ultima {
namespace Ultima4 {
diff --git a/engines/ultima/ultima4/controllers/combat_controller.cpp b/engines/ultima/ultima4/controllers/combat_controller.cpp
index cb9dc7f4fe..c0408d57da 100644
--- a/engines/ultima/ultima4/controllers/combat_controller.cpp
+++ b/engines/ultima/ultima4/controllers/combat_controller.cpp
@@ -33,7 +33,7 @@
#include "ultima/ultima4/core/debugger.h"
#include "ultima/ultima4/core/settings.h"
#include "ultima/ultima4/core/utils.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/game/context.h"
#include "ultima/ultima4/game/creature.h"
#include "ultima/ultima4/game/death.h"
diff --git a/engines/ultima/ultima4/controllers/controller.cpp b/engines/ultima/ultima4/controllers/controller.cpp
index 5f5c1bee13..5a500ec19d 100644
--- a/engines/ultima/ultima4/controllers/controller.cpp
+++ b/engines/ultima/ultima4/controllers/controller.cpp
@@ -21,7 +21,7 @@
*/
#include "ultima/ultima4/controllers/controller.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "engines/engine.h"
namespace Ultima {
diff --git a/engines/ultima/ultima4/controllers/intro_controller.cpp b/engines/ultima/ultima4/controllers/intro_controller.cpp
index 06a3fdacba..b109352ea0 100644
--- a/engines/ultima/ultima4/controllers/intro_controller.cpp
+++ b/engines/ultima/ultima4/controllers/intro_controller.cpp
@@ -29,7 +29,7 @@
#include "ultima/ultima4/core/config.h"
#include "ultima/ultima4/core/utils.h"
#include "ultima/ultima4/core/settings.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/filesys/savegame.h"
#include "ultima/ultima4/filesys/u4file.h"
#include "ultima/ultima4/gfx/imagemgr.h"
diff --git a/engines/ultima/ultima4/controllers/key_handler_controller.cpp b/engines/ultima/ultima4/controllers/key_handler_controller.cpp
index 0c02ddf8a9..a78f3530a9 100644
--- a/engines/ultima/ultima4/controllers/key_handler_controller.cpp
+++ b/engines/ultima/ultima4/controllers/key_handler_controller.cpp
@@ -22,7 +22,7 @@
#include "ultima/ultima4/controllers/key_handler_controller.h"
#include "ultima/ultima4/core/utils.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/game/context.h"
#include "ultima/ultima4/ultima4.h"
diff --git a/engines/ultima/ultima4/controllers/menu_controller.cpp b/engines/ultima/ultima4/controllers/menu_controller.cpp
index 17b2e3885f..e2ebb68b35 100644
--- a/engines/ultima/ultima4/controllers/menu_controller.cpp
+++ b/engines/ultima/ultima4/controllers/menu_controller.cpp
@@ -21,7 +21,7 @@
*/
#include "ultima/ultima4/controllers/menu_controller.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/game/menu.h"
#include "ultima/ultima4/game/textview.h"
diff --git a/engines/ultima/ultima4/controllers/read_choice_controller.h b/engines/ultima/ultima4/controllers/read_choice_controller.h
index 2a448dc29b..a6b1614f51 100644
--- a/engines/ultima/ultima4/controllers/read_choice_controller.h
+++ b/engines/ultima/ultima4/controllers/read_choice_controller.h
@@ -24,7 +24,7 @@
#define ULTIMA4_CONTROLLERS_READ_CHOICE_CONTROLLER_H
#include "ultima/ultima4/controllers/controller.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
namespace Ultima {
namespace Ultima4 {
diff --git a/engines/ultima/ultima4/controllers/read_string_controller.h b/engines/ultima/ultima4/controllers/read_string_controller.h
index aea84785cd..2e59493aef 100644
--- a/engines/ultima/ultima4/controllers/read_string_controller.h
+++ b/engines/ultima/ultima4/controllers/read_string_controller.h
@@ -24,7 +24,7 @@
#define ULTIMA4_CONTROLLERS_READ_STRING_CONTROLLER_H
#include "ultima/ultima4/controllers/controller.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/game/textview.h"
namespace Ultima {
diff --git a/engines/ultima/ultima4/controllers/wait_controller.cpp b/engines/ultima/ultima4/controllers/wait_controller.cpp
index 4bdc9a88cf..3a94411ec8 100644
--- a/engines/ultima/ultima4/controllers/wait_controller.cpp
+++ b/engines/ultima/ultima4/controllers/wait_controller.cpp
@@ -21,7 +21,7 @@
*/
#include "ultima/ultima4/controllers/wait_controller.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
namespace Ultima {
namespace Ultima4 {
diff --git a/engines/ultima/ultima4/controllers/ztats_controller.cpp b/engines/ultima/ultima4/controllers/ztats_controller.cpp
index e9c9f55032..6274a7d197 100644
--- a/engines/ultima/ultima4/controllers/ztats_controller.cpp
+++ b/engines/ultima/ultima4/controllers/ztats_controller.cpp
@@ -21,7 +21,7 @@
*/
#include "ultima/ultima4/controllers/ztats_controller.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/game/context.h"
#include "ultima/ultima4/game/stats.h"
#include "ultima/ultima4/ultima4.h"
diff --git a/engines/ultima/ultima4/core/settings.cpp b/engines/ultima/ultima4/core/settings.cpp
index 654e43d5f9..fccf7594c6 100644
--- a/engines/ultima/ultima4/core/settings.cpp
+++ b/engines/ultima/ultima4/core/settings.cpp
@@ -21,7 +21,7 @@
*/
#include "ultima/ultima4/core/settings.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/filesys/filesystem.h"
#include "ultima/ultima4/core/utils.h"
#include "common/config-manager.h"
diff --git a/engines/ultima/ultima4/events/event.cpp b/engines/ultima/ultima4/events/event_handler.cpp
similarity index 99%
rename from engines/ultima/ultima4/events/event.cpp
rename to engines/ultima/ultima4/events/event_handler.cpp
index 09027e15d7..14abc8c401 100644
--- a/engines/ultima/ultima4/events/event.cpp
+++ b/engines/ultima/ultima4/events/event_handler.cpp
@@ -20,7 +20,7 @@
*
*/
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/controllers/wait_controller.h"
#include "ultima/ultima4/core/settings.h"
#include "ultima/ultima4/core/utils.h"
diff --git a/engines/ultima/ultima4/events/event.h b/engines/ultima/ultima4/events/event_handler.h
similarity index 97%
rename from engines/ultima/ultima4/events/event.h
rename to engines/ultima/ultima4/events/event_handler.h
index 961f44a2dd..a1315b18a3 100644
--- a/engines/ultima/ultima4/events/event.h
+++ b/engines/ultima/ultima4/events/event_handler.h
@@ -20,10 +20,9 @@
*
*/
-#ifndef ULTIMA4_EVENTS_EVENT_H
-#define ULTIMA4_EVENTS_EVENT_H
+#ifndef ULTIMA4_EVENTS_EVENT_HANDLER_H
+#define ULTIMA4_EVENTS_EVENT_HANDLER_H
-#include "ultima/ultima4/events/event.h"
#include "ultima/ultima4/events/timed_event_mgr.h"
#include "ultima/ultima4/controllers/key_handler_controller.h"
#include "ultima/ultima4/core/types.h"
diff --git a/engines/ultima/ultima4/game/codex.cpp b/engines/ultima/ultima4/game/codex.cpp
index f3b3ec16fe..f0315da282 100644
--- a/engines/ultima/ultima4/game/codex.cpp
+++ b/engines/ultima/ultima4/game/codex.cpp
@@ -22,7 +22,7 @@
#include "ultima/ultima4/game/codex.h"
#include "ultima/ultima4/game/context.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/game/game.h"
#include "ultima/ultima4/game/item.h"
#include "ultima/ultima4/gfx/imagemgr.h"
diff --git a/engines/ultima/ultima4/game/death.cpp b/engines/ultima/ultima4/game/death.cpp
index f2e0756263..eced29991d 100644
--- a/engines/ultima/ultima4/game/death.cpp
+++ b/engines/ultima/ultima4/game/death.cpp
@@ -28,7 +28,7 @@
#include "ultima/ultima4/game/stats.h"
#include "ultima/ultima4/controllers/wait_controller.h"
#include "ultima/ultima4/core/settings.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/gfx/screen.h"
#include "ultima/ultima4/map/map.h"
#include "ultima/ultima4/map/annotation.h"
diff --git a/engines/ultima/ultima4/game/game.cpp b/engines/ultima/ultima4/game/game.cpp
index b48a3ec5b6..06676078ee 100644
--- a/engines/ultima/ultima4/game/game.cpp
+++ b/engines/ultima/ultima4/game/game.cpp
@@ -34,7 +34,7 @@
#include "ultima/ultima4/core/debugger.h"
#include "ultima/ultima4/core/settings.h"
#include "ultima/ultima4/core/utils.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/filesys/savegame.h"
#include "ultima/ultima4/game/game.h"
#include "ultima/ultima4/game/armor.h"
diff --git a/engines/ultima/ultima4/game/game.h b/engines/ultima/ultima4/game/game.h
index ec81563faf..6cd2b42cf6 100644
--- a/engines/ultima/ultima4/game/game.h
+++ b/engines/ultima/ultima4/game/game.h
@@ -23,7 +23,7 @@
#ifndef ULTIMA4_GAME_GAME_H
#define ULTIMA4_GAME_GAME_H
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/controllers/game_controller.h"
#include "ultima/ultima4/core/observer.h"
#include "ultima/ultima4/core/types.h"
diff --git a/engines/ultima/ultima4/game/menu.cpp b/engines/ultima/ultima4/game/menu.cpp
index a3963b898a..25a3d34800 100644
--- a/engines/ultima/ultima4/game/menu.cpp
+++ b/engines/ultima/ultima4/game/menu.cpp
@@ -21,7 +21,7 @@
*/
#include "ultima/ultima4/game/menu.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/game/textview.h"
namespace Ultima {
diff --git a/engines/ultima/ultima4/game/menu.h b/engines/ultima/ultima4/game/menu.h
index 6db6e388a7..48f07816ff 100644
--- a/engines/ultima/ultima4/game/menu.h
+++ b/engines/ultima/ultima4/game/menu.h
@@ -23,7 +23,7 @@
#ifndef ULTIMA4_GAME_MENU_H
#define ULTIMA4_GAME_MENU_H
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/game/menuitem.h"
#include "ultima/ultima4/core/observable.h"
#include "ultima/ultima4/core/types.h"
diff --git a/engines/ultima/ultima4/game/person.cpp b/engines/ultima/ultima4/game/person.cpp
index 3ea5209ffa..1b25244598 100644
--- a/engines/ultima/ultima4/game/person.cpp
+++ b/engines/ultima/ultima4/game/person.cpp
@@ -34,7 +34,7 @@
#include "ultima/ultima4/core/settings.h"
#include "ultima/ultima4/core/types.h"
#include "ultima/ultima4/core/utils.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/filesys/savegame.h"
#include "ultima/ultima4/filesys/u4file.h"
#include "ultima/ultima4/map/city.h"
diff --git a/engines/ultima/ultima4/game/script.cpp b/engines/ultima/ultima4/game/script.cpp
index 72b15722c9..c0b73cb422 100644
--- a/engines/ultima/ultima4/game/script.cpp
+++ b/engines/ultima/ultima4/game/script.cpp
@@ -27,7 +27,7 @@
#include "ultima/ultima4/conversation/conversation.h"
#include "ultima/ultima4/core/settings.h"
#include "ultima/ultima4/core/utils.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/filesys/filesystem.h"
#include "ultima/ultima4/filesys/savegame.h"
#include "ultima/ultima4/filesys/u4file.h"
diff --git a/engines/ultima/ultima4/game/spell.cpp b/engines/ultima/ultima4/game/spell.cpp
index 4d4eededa2..d81875112d 100644
--- a/engines/ultima/ultima4/game/spell.cpp
+++ b/engines/ultima/ultima4/game/spell.cpp
@@ -30,7 +30,7 @@
#include "ultima/ultima4/core/settings.h"
#include "ultima/ultima4/core/debugger.h"
#include "ultima/ultima4/core/utils.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/gfx/screen.h"
#include "ultima/ultima4/map/annotation.h"
#include "ultima/ultima4/map/direction.h"
diff --git a/engines/ultima/ultima4/game/textview.cpp b/engines/ultima/ultima4/game/textview.cpp
index 06af97fee9..edd2f0083c 100644
--- a/engines/ultima/ultima4/game/textview.cpp
+++ b/engines/ultima/ultima4/game/textview.cpp
@@ -20,7 +20,7 @@
*
*/
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/gfx/image.h"
#include "ultima/ultima4/gfx/imagemgr.h"
#include "ultima/ultima4/core/settings.h"
diff --git a/engines/ultima/ultima4/gfx/screen.cpp b/engines/ultima/ultima4/gfx/screen.cpp
index c62a36b570..c7b5bf6fb0 100644
--- a/engines/ultima/ultima4/gfx/screen.cpp
+++ b/engines/ultima/ultima4/gfx/screen.cpp
@@ -24,7 +24,7 @@
#include "ultima/ultima4/core/config.h"
#include "ultima/ultima4/core/utils.h"
#include "ultima/ultima4/core/settings.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/filesys/savegame.h"
#include "ultima/ultima4/game/context.h"
#include "ultima/ultima4/game/names.h"
diff --git a/engines/ultima/ultima4/map/annotation.cpp b/engines/ultima/ultima4/map/annotation.cpp
index 129967218a..12fd8da458 100644
--- a/engines/ultima/ultima4/map/annotation.cpp
+++ b/engines/ultima/ultima4/map/annotation.cpp
@@ -22,7 +22,7 @@
#include "ultima/ultima4/map/annotation.h"
#include "ultima/ultima4/game/context.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/map/map.h"
#include "ultima/ultima4/core/settings.h"
#include "common/debug.h"
diff --git a/engines/ultima/ultima4/map/direction.cpp b/engines/ultima/ultima4/map/direction.cpp
index cacb862ff9..24023c60b0 100644
--- a/engines/ultima/ultima4/map/direction.cpp
+++ b/engines/ultima/ultima4/map/direction.cpp
@@ -21,7 +21,7 @@
*/
#include "ultima/ultima4/map/direction.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/core/utils.h"
namespace Ultima {
diff --git a/engines/ultima/ultima4/map/location.cpp b/engines/ultima/ultima4/map/location.cpp
index eb65557cac..426c33e7d4 100644
--- a/engines/ultima/ultima4/map/location.cpp
+++ b/engines/ultima/ultima4/map/location.cpp
@@ -25,7 +25,7 @@
#include "ultima/ultima4/game/context.h"
#include "ultima/ultima4/controllers/combat_controller.h"
#include "ultima/ultima4/game/creature.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/game/game.h"
#include "ultima/ultima4/map/map.h"
#include "ultima/ultima4/game/object.h"
diff --git a/engines/ultima/ultima4/map/movement.cpp b/engines/ultima/ultima4/map/movement.cpp
index db16ad809e..c187409900 100644
--- a/engines/ultima/ultima4/map/movement.cpp
+++ b/engines/ultima/ultima4/map/movement.cpp
@@ -25,7 +25,7 @@
#include "ultima/ultima4/controllers/combat_controller.h"
#include "ultima/ultima4/game/context.h"
#include "ultima/ultima4/map/dungeon.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/map/location.h"
#include "ultima/ultima4/game/creature.h"
#include "ultima/ultima4/game/object.h"
diff --git a/engines/ultima/ultima4/map/shrine.cpp b/engines/ultima/ultima4/map/shrine.cpp
index cd0fbd56d5..f10b57f648 100644
--- a/engines/ultima/ultima4/map/shrine.cpp
+++ b/engines/ultima/ultima4/map/shrine.cpp
@@ -30,7 +30,7 @@
#include "ultima/ultima4/core/config.h"
#include "ultima/ultima4/core/settings.h"
#include "ultima/ultima4/core/types.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/game/context.h"
#include "ultima/ultima4/game/game.h"
#include "ultima/ultima4/game/creature.h"
diff --git a/engines/ultima/ultima4/sound/music.cpp b/engines/ultima/ultima4/sound/music.cpp
index b6ac0dc6dd..97bd7e5734 100644
--- a/engines/ultima/ultima4/sound/music.cpp
+++ b/engines/ultima/ultima4/sound/music.cpp
@@ -25,7 +25,7 @@
#include "ultima/ultima4/core/config.h"
#include "ultima/ultima4/core/settings.h"
#include "ultima/ultima4/core/utils.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/filesys/u4file.h"
#include "ultima/ultima4/game/context.h"
#include "ultima/ultima4/map/location.h"
diff --git a/engines/ultima/ultima4/ultima4.cpp b/engines/ultima/ultima4/ultima4.cpp
index d6abb0def4..0fa7dcb02b 100644
--- a/engines/ultima/ultima4/ultima4.cpp
+++ b/engines/ultima/ultima4/ultima4.cpp
@@ -27,7 +27,7 @@
#include "ultima/ultima4/core/debugger.h"
#include "ultima/ultima4/core/settings.h"
#include "ultima/ultima4/core/utils.h"
-#include "ultima/ultima4/events/event.h"
+#include "ultima/ultima4/events/event_handler.h"
#include "ultima/ultima4/filesys/savegame.h"
#include "ultima/ultima4/game/context.h"
#include "ultima/ultima4/game/game.h"
Commit: 9518991e2fb44ede116aef32ebdb0ef4f8867e1e
https://github.com/scummvm/scummvm/commit/9518991e2fb44ede116aef32ebdb0ef4f8867e1e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-22T21:38:52-07:00
Commit Message:
ULTIMA4: Repeated walk when right mouse button is pressed
Changed paths:
engines/ultima/ultima4/controllers/game_controller.cpp
engines/ultima/ultima4/events/event_handler.cpp
engines/ultima/ultima4/events/event_handler.h
engines/ultima/ultima4/gfx/screen.h
diff --git a/engines/ultima/ultima4/controllers/game_controller.cpp b/engines/ultima/ultima4/controllers/game_controller.cpp
index ad5daeae9c..7e70cf7690 100644
--- a/engines/ultima/ultima4/controllers/game_controller.cpp
+++ b/engines/ultima/ultima4/controllers/game_controller.cpp
@@ -48,11 +48,11 @@ using namespace std;
GameController *g_game = nullptr;
static const MouseArea MOUSE_AREAS[] = {
- { 3, { { 8, 8 }, { 8, 184 }, { 96, 96 } }, MC_WEST },
- { 3, { { 8, 8 }, { 184, 8 }, { 96, 96 } }, MC_NORTH },
- { 3, { { 184, 8 }, { 184, 184 }, { 96, 96 } }, MC_EAST },
- { 3, { { 8, 184 }, { 184, 184 }, { 96, 96 } }, MC_SOUTH },
- { 0, { { 0, 0 }, { 0, 0 }, { 0, 0 } }, MC_NORTH }
+ { 3, { { 8, 8 }, { 8, 184 }, { 96, 96 } }, MC_WEST, DIR_WEST },
+ { 3, { { 8, 8 }, { 184, 8 }, { 96, 96 } }, MC_NORTH, DIR_NORTH },
+ { 3, { { 184, 8 }, { 184, 184 }, { 96, 96 } }, MC_EAST, DIR_EAST },
+ { 3, { { 8, 184 }, { 184, 184 }, { 96, 96 } }, MC_SOUTH, DIR_SOUTH },
+ { 0, { { 0, 0 }, { 0, 0 }, { 0, 0 } }, MC_NORTH, DIR_NONE }
};
GameController::GameController() : _mapArea(BORDER_WIDTH, BORDER_HEIGHT, VIEWPORT_W, VIEWPORT_H), _paused(false), _pausedTimer(0) {
@@ -598,6 +598,11 @@ void GameController::timerFired() {
g_screen->screenCycle();
+ // Check for any right-button mouse movement
+ KeybindingAction action = eventHandler->getAction();
+ if (action != KEYBIND_NONE)
+ keybinder(action);
+
// Do game udpates to the screen, like tile animations
gameUpdateScreen();
diff --git a/engines/ultima/ultima4/events/event_handler.cpp b/engines/ultima/ultima4/events/event_handler.cpp
index 14abc8c401..68381794ce 100644
--- a/engines/ultima/ultima4/events/event_handler.cpp
+++ b/engines/ultima/ultima4/events/event_handler.cpp
@@ -42,7 +42,8 @@ bool EventHandler::_ended = false;
EventHandler *EventHandler::_instance = nullptr;
-EventHandler::EventHandler() : _timer(settings._eventTimerGranularity), _updateScreen(nullptr) {
+EventHandler::EventHandler() : _timer(settings._eventTimerGranularity),
+ _updateScreen(nullptr), _isRightButtonDown(false) {
}
EventHandler *EventHandler::getInstance() {
@@ -165,6 +166,12 @@ void EventHandler::run() {
handleMouseButtonDownEvent(event, getController(), _updateScreen);
break;
+ case Common::EVENT_LBUTTONUP:
+ case Common::EVENT_RBUTTONUP:
+ case Common::EVENT_MBUTTONUP:
+ handleMouseButtonUpEvent(event, getController(), _updateScreen);
+ break;
+
case Common::EVENT_MOUSEMOVE:
handleMouseMotionEvent(event);
continue;
@@ -245,26 +252,49 @@ void EventHandler::handleMouseMotionEvent(const Common::Event &event) {
const MouseArea *area;
area = eventHandler->mouseAreaForPoint(event.mouse.x, event.mouse.y);
- if (area)
+ if (area) {
g_screen->setMouseCursor(area->_cursor);
- else
+
+ if (_isRightButtonDown) {
+ int xd = (event.mouse.x / settings._scale) - 96,
+ yd = (event.mouse.y / settings._scale) - 96;
+ double dist = sqrt((double)(xd * xd + yd * yd));
+ _walk.setDelta(area->_direction, (int)dist);
+ }
+ } else {
g_screen->setMouseCursor(MC_DEFAULT);
+ if (_isRightButtonDown)
+ _walk.setDelta(DIR_NONE, 0);
+ }
}
void EventHandler::handleMouseButtonDownEvent(const Common::Event &event, Controller *controller, updateScreenCallback updateScreen) {
- if (!settings._mouseOptions._enabled || event.type != Common::EVENT_LBUTTONDOWN)
+ if (!settings._mouseOptions._enabled)
return;
- const MouseArea *area = eventHandler->mouseAreaForPoint(event.mouse.x, event.mouse.y);
- if (!area)
- return;
- controller->keybinder(KEYBIND_INTERACT);
+ if (event.type == Common::EVENT_LBUTTONDOWN) {
+ const MouseArea *area = eventHandler->mouseAreaForPoint(event.mouse.x, event.mouse.y);
+ if (!area)
+ return;
+ controller->keybinder(KEYBIND_INTERACT);
+ } else if (event.type == Common::EVENT_RBUTTONDOWN) {
+ _isRightButtonDown = true;
+ handleMouseMotionEvent(event);
+ }
if (updateScreen)
(*updateScreen)();
g_screen->update();
}
+void EventHandler::handleMouseButtonUpEvent(const Common::Event &event, Controller *controller, updateScreenCallback updateScreen) {
+ if (!settings._mouseOptions._enabled)
+ return;
+
+ if (event.type == Common::EVENT_RBUTTONUP)
+ _isRightButtonDown = false;
+}
+
void EventHandler::handleKeyDownEvent(const Common::Event &event, Controller *controller, updateScreenCallback updateScreen) {
int key;
bool processed;
@@ -287,5 +317,56 @@ void EventHandler::handleKeyDownEvent(const Common::Event &event, Controller *co
}
}
+/*-------------------------------------------------------------------*/
+
+void WalkTrigger::reset() {
+ _action = KEYBIND_NONE;
+ _ticksCtr = 0;
+}
+
+void WalkTrigger::setDelta(Direction dir, int distance) {
+ if (distance > 96) {
+ distance = 0;
+ dir = DIR_NONE;
+ }
+
+ KeybindingAction action;
+ switch (dir) {
+ case DIR_NORTH:
+ action = KEYBIND_UP;
+ break;
+ case DIR_SOUTH:
+ action = KEYBIND_DOWN;
+ break;
+ case DIR_WEST:
+ action = KEYBIND_LEFT;
+ break;
+ case DIR_EAST:
+ action = KEYBIND_RIGHT;
+ break;
+ default:
+ action = KEYBIND_NONE;
+ break;
+ }
+
+ if (action != _action) {
+ // Walk quadrant changed
+ _action = action;
+ _ticksCtr = 0;
+ }
+
+ _ticksPerWalk = 4 - (distance / 25);
+}
+
+KeybindingAction WalkTrigger::getAction() {
+ if (--_ticksCtr <= 0) {
+ _ticksCtr = _ticksPerWalk;
+ return _action;
+ }
+
+ return KEYBIND_NONE;
+}
+
+
} // End of namespace Ultima4
} // End of namespace Ultima
diff --git a/engines/ultima/ultima4/events/event_handler.h b/engines/ultima/ultima4/events/event_handler.h
index a1315b18a3..e9ddd80318 100644
--- a/engines/ultima/ultima4/events/event_handler.h
+++ b/engines/ultima/ultima4/events/event_handler.h
@@ -30,6 +30,7 @@
#include "ultima/shared/std/containers.h"
#include "common/events.h"
#include "common/list.h"
+#include "common/rect.h"
#include "common/str.h"
namespace Ultima {
@@ -48,6 +49,39 @@ typedef void *UIEvent;
#endif
typedef void(*updateScreenCallback)();
+
+/**
+ * Encapsulates the logic for deciding how frequently to walk
+ * when holding down the right moues button in enhanced mode
+ */
+class WalkTrigger {
+private:
+ int _ticksCtr, _ticksPerWalk;
+ KeybindingAction _action;
+public:
+ /**
+ * Constructor
+ */
+ WalkTrigger() : _ticksCtr(0), _ticksPerWalk(0), _action(KEYBIND_NONE) {
+ }
+
+ /**
+ * Resets the walker
+ */
+ void reset();
+
+ /**
+ * Sets the delta from the center of the map
+ */
+ void setDelta(Direction dir, int distance);
+
+ /**
+ * Checks for whether to walk, and if so, returns the direction
+ */
+ KeybindingAction getAction();
+};
+
+
/**
* A class for handling game events.
*/
@@ -55,9 +89,12 @@ class EventHandler {
typedef Common::List<const MouseArea *> MouseAreaList;
private:
static EventHandler *_instance;
+ WalkTrigger _walk;
+ bool _isRightButtonDown;
private:
void handleMouseMotionEvent(const Common::Event &event);
void handleMouseButtonDownEvent(const Common::Event &event, Controller *controller, updateScreenCallback updateScreen);
+ void handleMouseButtonUpEvent(const Common::Event &event, Controller *controller, updateScreenCallback updateScreen);
void handleKeyDownEvent(const Common::Event &event, Controller *controller, updateScreenCallback updateScreen);
protected:
static bool _controllerDone;
@@ -158,6 +195,13 @@ public:
const MouseArea *getMouseAreaSet() const;
const MouseArea *mouseAreaForPoint(int x, int y);
+
+ /**
+ * Checks for whether to walk, and if so, returns the direction action
+ */
+ KeybindingAction getAction() {
+ return _isRightButtonDown ? _walk.getAction() : KEYBIND_NONE;
+ }
};
} // End of namespace Ultima4
diff --git a/engines/ultima/ultima4/gfx/screen.h b/engines/ultima/ultima4/gfx/screen.h
index 7317371577..f2684be409 100644
--- a/engines/ultima/ultima4/gfx/screen.h
+++ b/engines/ultima/ultima4/gfx/screen.h
@@ -91,6 +91,7 @@ struct MouseArea {
int x, y;
} _point[3];
MouseCursor _cursor;
+ Direction _direction;
};
struct Layout {
Commit: cb846751182a17e33591aa1a28cb4c622292d995
https://github.com/scummvm/scummvm/commit/cb846751182a17e33591aa1a28cb4c622292d995
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-22T21:38:52-07:00
Commit Message:
ULTIMA4: Remove unused settings
Changed paths:
engines/ultima/ultima4/core/settings.cpp
engines/ultima/ultima4/core/settings.h
diff --git a/engines/ultima/ultima4/core/settings.cpp b/engines/ultima/ultima4/core/settings.cpp
index fccf7594c6..9d3f90810d 100644
--- a/engines/ultima/ultima4/core/settings.cpp
+++ b/engines/ultima/ultima4/core/settings.cpp
@@ -133,9 +133,6 @@ bool Settings::read() {
_titleSpeedRandom = DEFAULT_TITLE_SPEED_RANDOM;
_titleSpeedOther = DEFAULT_TITLE_SPEED_OTHER;
- _pauseForEachMovement = DEFAULT_PAUSE_FOR_EACH_MOVEMENT;
- _pauseForEachTurn = DEFAULT_PAUSE_FOR_EACH_TURN;
-
// all specific minor enhancements default to "on", any major enhancements default to "off"
_enhancementsOptions._activePlayer = true;
_enhancementsOptions._u5spellMixing = true;
diff --git a/engines/ultima/ultima4/core/settings.h b/engines/ultima/ultima4/core/settings.h
index efe64986f9..6cb95dd26f 100644
--- a/engines/ultima/ultima4/core/settings.h
+++ b/engines/ultima/ultima4/core/settings.h
@@ -74,9 +74,6 @@ namespace Ultima4 {
#define DEFAULT_TITLE_SPEED_RANDOM 150
#define DEFAULT_TITLE_SPEED_OTHER 30
-#define DEFAULT_PAUSE_FOR_EACH_TURN 100
-#define DEFAULT_PAUSE_FOR_EACH_MOVEMENT 10
-
//--Tile transparency stuff
#define DEFAULT_SHADOW_PIXEL_OPACITY 64
#define DEFAULT_SHADOW_PIXEL_SIZE 2
@@ -144,11 +141,6 @@ public:
int _titleSpeedRandom;
int _titleSpeedOther;
- //Settings that aren't in file yet
- int _pauseForEachTurn;
- int _pauseForEachMovement;
-
-
int _eventTimerGranularity;
Common::String _filter;
Common::String _gemLayout;
More information about the Scummvm-git-logs
mailing list