[Scummvm-git-logs] scummvm master -> d35257888755181850cabf3aae96f6c676e5897b
dreammaster
paulfgilbert at gmail.com
Sat May 2 00:25:09 UTC 2020
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
f86a31cfdb ULTIMA4: Fixing Coverity warnings
d352578887 ULTIMA4: Cleanup of CombatController moveCreatures
Commit: f86a31cfdb94c8c144499832da7459078627d16c
https://github.com/scummvm/scummvm/commit/f86a31cfdb94c8c144499832da7459078627d16c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-05-01T17:10:53-07:00
Commit Message:
ULTIMA4: Fixing Coverity warnings
Changed paths:
engines/ultima/ultima4/controllers/game_controller.cpp
engines/ultima/ultima4/core/debugger.cpp
engines/ultima/ultima4/filesys/savegame.cpp
engines/ultima/ultima4/gfx/imagemgr.cpp
engines/ultima/ultima4/gfx/imagemgr.h
engines/ultima/ultima4/map/map.h
engines/ultima/ultima4/map/tile.cpp
diff --git a/engines/ultima/ultima4/controllers/game_controller.cpp b/engines/ultima/ultima4/controllers/game_controller.cpp
index ad1a6e98c3..26395d503f 100644
--- a/engines/ultima/ultima4/controllers/game_controller.cpp
+++ b/engines/ultima/ultima4/controllers/game_controller.cpp
@@ -689,6 +689,7 @@ bool GameController::checkMoongates() {
Shrine *shrine_spirituality;
shrine_spirituality = dynamic_cast<Shrine *>(mapMgr->get(MAP_SHRINE_SPIRITUALITY));
+ assert(shrine_spirituality);
if (!g_context->_party->canEnterShrine(VIRT_SPIRITUALITY))
return true;
diff --git a/engines/ultima/ultima4/core/debugger.cpp b/engines/ultima/ultima4/core/debugger.cpp
index 8a227fdd11..2e8ddbe1ac 100644
--- a/engines/ultima/ultima4/core/debugger.cpp
+++ b/engines/ultima/ultima4/core/debugger.cpp
@@ -1669,7 +1669,7 @@ bool Debugger::cmdTransport(int argc, const char **argv) {
break;
}
- if (choice && ok) {
+ if (ok) {
g_context->_location->_map->addObject(*choice, *choice, coords);
print("%s created!", tile->getName().c_str());
} else if (!choice) {
diff --git a/engines/ultima/ultima4/filesys/savegame.cpp b/engines/ultima/ultima4/filesys/savegame.cpp
index 7a0ed3db08..d7eeb9a8cd 100644
--- a/engines/ultima/ultima4/filesys/savegame.cpp
+++ b/engines/ultima/ultima4/filesys/savegame.cpp
@@ -140,7 +140,7 @@ void SaveGame::save(Common::WriteStream *stream) {
void SaveGame::load(Common::SeekableReadStream *stream) {
Common::Serializer *ser = nullptr;
- assert(g_context);
+ assert(g_context && g_context->_location);
if (stream) {
ser = new Common::Serializer(stream, nullptr);
diff --git a/engines/ultima/ultima4/gfx/imagemgr.cpp b/engines/ultima/ultima4/gfx/imagemgr.cpp
index d2f76a782d..0251d90a20 100644
--- a/engines/ultima/ultima4/gfx/imagemgr.cpp
+++ b/engines/ultima/ultima4/gfx/imagemgr.cpp
@@ -80,21 +80,20 @@ void ImageMgr::init() {
* register the "screen" image representing the entire screen
*/
Image *screen = Image::createScreenImage();
- ImageInfo *screenInfo = new ImageInfo();
-
- screenInfo->_name = "screen";
- screenInfo->_filename = "";
- screenInfo->_width = screen->width();
- screenInfo->_height = screen->height();
- screenInfo->_depth = 0;
- screenInfo->_prescale = 0;
- screenInfo->_filetype = "";
- screenInfo->_tiles = 0;
- screenInfo->_introOnly = false;
- screenInfo->_transparentIndex = -1;
- screenInfo->_xu4Graphic = false;
- screenInfo->_fixup = FIXUP_NONE;
- screenInfo->_image = screen;
+
+ _screenInfo._name = "screen";
+ _screenInfo._filename = "";
+ _screenInfo._width = screen->width();
+ _screenInfo._height = screen->height();
+ _screenInfo._depth = 0;
+ _screenInfo._prescale = 0;
+ _screenInfo._filetype = "";
+ _screenInfo._tiles = 0;
+ _screenInfo._introOnly = false;
+ _screenInfo._transparentIndex = -1;
+ _screenInfo._xu4Graphic = false;
+ _screenInfo._fixup = FIXUP_NONE;
+ _screenInfo._image = screen;
/*
* register all the images declared in the config files
@@ -107,7 +106,7 @@ void ImageMgr::init() {
_imageSets[set->_name] = set;
// all image sets include the "screen" image
- set->_info[screenInfo->_name] = screenInfo;
+ set->_info[_screenInfo._name] = &_screenInfo;
}
}
@@ -332,7 +331,7 @@ void ImageMgr::fixupIntro(Image *im, int prescale) {
im->setPaletteFromImage(borderInfo->_image);
// update the color of "and" and "present"
- im->setPaletteIndex(15, im->setColor(226, 226, 255));
+ (void)im->setPaletteIndex(15, im->setColor(226, 226, 255));
// update the color of "Origin Systems, Inc."
(void)im->setPaletteIndex(9, im->setColor(129, 129, 255));
diff --git a/engines/ultima/ultima4/gfx/imagemgr.h b/engines/ultima/ultima4/gfx/imagemgr.h
index b91b46f4e5..b53a386aa0 100644
--- a/engines/ultima/ultima4/gfx/imagemgr.h
+++ b/engines/ultima/ultima4/gfx/imagemgr.h
@@ -191,6 +191,7 @@ private:
Std::map<Common::String, ImageSet *> _imageSets;
Std::vector<Common::String> _imageSetNames;
ImageSet *_baseSet;
+ ImageInfo _screenInfo;
};
#define imageMgr (ImageMgr::getInstance())
diff --git a/engines/ultima/ultima4/map/map.h b/engines/ultima/ultima4/map/map.h
index 82c4ccd3e9..18f8da005c 100644
--- a/engines/ultima/ultima4/map/map.h
+++ b/engines/ultima/ultima4/map/map.h
@@ -152,7 +152,7 @@ public:
class Source {
public:
- Source() {}
+ Source() : _type(WORLD) {}
Source(const Common::String &f, Type t) : _fname(f), _type(t) {}
Common::String _fname;
diff --git a/engines/ultima/ultima4/map/tile.cpp b/engines/ultima/ultima4/map/tile.cpp
index c2b4ed4b07..5b29444713 100644
--- a/engines/ultima/ultima4/map/tile.cpp
+++ b/engines/ultima/ultima4/map/tile.cpp
@@ -161,11 +161,14 @@ void Tile::loadImage() {
//info->image->alphaOff();
// Draw the tile from the image we found to our tile image
+ Image *tiles = info->_image;
+ assert(tiles);
+
if (subimage) {
- Image *tiles = info->_image;
- assert(tiles);
tiles->drawSubRectOn(_image, 0, 0, subimage->x * _scale, subimage->y * _scale, subimage->width * _scale, subimage->height * _scale);
- } else info->_image->drawOn(_image, 0, 0);
+ } else {
+ tiles->drawOn(_image, 0, 0);
+ }
}
if (_animationRule.size() > 0) {
Commit: d35257888755181850cabf3aae96f6c676e5897b
https://github.com/scummvm/scummvm/commit/d35257888755181850cabf3aae96f6c676e5897b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-05-01T17:23:58-07:00
Commit Message:
ULTIMA4: Cleanup of CombatController moveCreatures
Changed paths:
engines/ultima/shared/std/containers.h
engines/ultima/ultima4/controllers/combat_controller.cpp
engines/ultima/ultima4/filesys/savegame.cpp
diff --git a/engines/ultima/shared/std/containers.h b/engines/ultima/shared/std/containers.h
index b29ee24b8f..f1dafb2fe6 100644
--- a/engines/ultima/shared/std/containers.h
+++ b/engines/ultima/shared/std/containers.h
@@ -160,7 +160,7 @@ public:
this->operator[](idx) = elem;
}
- T at(size_t index) {
+ T at(size_t index) const {
return (*this)[index];
}
};
diff --git a/engines/ultima/ultima4/controllers/combat_controller.cpp b/engines/ultima/ultima4/controllers/combat_controller.cpp
index 23c9fbf71b..9fedb0125a 100644
--- a/engines/ultima/ultima4/controllers/combat_controller.cpp
+++ b/engines/ultima/ultima4/controllers/combat_controller.cpp
@@ -480,18 +480,18 @@ bool CombatController::isLost() const {
void CombatController::moveCreatures() {
Creature *m;
+ CreatureVector creatures = _map->getCreatures();
- // XXX: this iterator is rather complex; but the vector::iterator can
- // break and crash if we delete elements while iterating it, which we do
- // if a jinxed monster kills another
- for (uint i = 0; i < _map->getCreatures().size(); i++) {
- m = _map->getCreatures().at(i);
- //GameController::doScreenAnimationsWhilePausing(1);
+ // IMPORTANT: We need to keep regenerating the creatures list,
+ // because monsters may be removed if a jinxed monster kills another
+ for (int i = 0; i < (int)creatures.size(); ++i) {
+ m = creatures[i];
m->act(this);
- if (i < _map->getCreatures().size() && _map->getCreatures().at(i) != m) {
- // don't skip a later creature when an earlier one flees
- i--;
+ creatures = _map->getCreatures();
+ if (i < (int)creatures.size() && creatures[i] != m) {
+ // Don't skip a later creature when an earlier one flees
+ --i;
}
}
}
diff --git a/engines/ultima/ultima4/filesys/savegame.cpp b/engines/ultima/ultima4/filesys/savegame.cpp
index d7eeb9a8cd..d736342758 100644
--- a/engines/ultima/ultima4/filesys/savegame.cpp
+++ b/engines/ultima/ultima4/filesys/savegame.cpp
@@ -140,7 +140,7 @@ void SaveGame::save(Common::WriteStream *stream) {
void SaveGame::load(Common::SeekableReadStream *stream) {
Common::Serializer *ser = nullptr;
- assert(g_context && g_context->_location);
+ assert(g_context);
if (stream) {
ser = new Common::Serializer(stream, nullptr);
@@ -168,6 +168,7 @@ void SaveGame::load(Common::SeekableReadStream *stream) {
// set the map to the world map
g_game->setMap(mapMgr->get(MAP_WORLD), 0, nullptr);
+ assert(g_context->_location && g_context->_location->_map);
g_context->_location->_map->clearObjects();
// initialize our start location
More information about the Scummvm-git-logs
mailing list