[Scummvm-git-logs] scummvm master -> 7af5cd372ccbefa7b08241206966a8c3b1064e3a
bluegr
noreply at scummvm.org
Mon Jun 2 17:39:36 UTC 2025
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
7af5cd372c ULTIMA4: Replace Std::deque with Common::List
Commit: 7af5cd372ccbefa7b08241206966a8c3b1064e3a
https://github.com/scummvm/scummvm/commit/7af5cd372ccbefa7b08241206966a8c3b1064e3a
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2025-06-02T20:39:32+03:00
Commit Message:
ULTIMA4: Replace Std::deque with Common::List
Changed paths:
engines/ultima/shared/std/containers.h
engines/ultima/ultima4/game/object.cpp
engines/ultima/ultima4/game/object.h
engines/ultima/ultima4/map/map.cpp
diff --git a/engines/ultima/shared/std/containers.h b/engines/ultima/shared/std/containers.h
index 5a166ddf72e..07a7073d7a4 100644
--- a/engines/ultima/shared/std/containers.h
+++ b/engines/ultima/shared/std/containers.h
@@ -182,20 +182,6 @@ public:
}
};
-template<class VAL>
-class deque : public Common::List<VAL> {
-public:
- VAL operator[](uint index) {
- for (typename Common::List<VAL>::iterator it = this->begin();
- it != this->end(); ++it, --index) {
- if (index == 0)
- return *it;
- }
-
- error("Invalid index");
- }
-};
-
template<class T>
class list : public Common::List<T> {
public:
diff --git a/engines/ultima/ultima4/game/object.cpp b/engines/ultima/ultima4/game/object.cpp
index 07366f40bc1..73d3d57ab0b 100644
--- a/engines/ultima/ultima4/game/object.cpp
+++ b/engines/ultima/ultima4/game/object.cpp
@@ -45,10 +45,13 @@ Map *Object::getMap() {
void Object::remove() {
uint size = _maps.size();
- for (uint i = 0; i < size; i++) {
+ uint i = 0;
+
+ for (auto *map : _maps) {
if (i == size - 1)
- _maps[i]->removeObject(this);
- else _maps[i]->removeObject(this, false);
+ map->removeObject(this);
+ else map->removeObject(this, false);
+ i++;
}
}
diff --git a/engines/ultima/ultima4/game/object.h b/engines/ultima/ultima4/game/object.h
index 6f8bb88bd0b..fb370335075 100644
--- a/engines/ultima/ultima4/game/object.h
+++ b/engines/ultima/ultima4/game/object.h
@@ -30,7 +30,7 @@ namespace Ultima4 {
class Object;
-typedef Std::deque<Object *> ObjectDeque;
+typedef Common::List<Object *> ObjectDeque;
enum ObjectMovementBehavior {
MOVEMENT_FIXED,
@@ -134,7 +134,7 @@ protected:
Coords _coords, _prevCoords;
ObjectMovementBehavior _movementBehavior;
Type _objType;
- Std::deque<class Map *> _maps; /**< A list of maps this object is a part of */
+ Common::List<class Map *> _maps; /**< A list of maps this object is a part of */
bool _focused;
bool _visible;
diff --git a/engines/ultima/ultima4/map/map.cpp b/engines/ultima/ultima4/map/map.cpp
index 1d0baaf2a6d..cb009240cea 100644
--- a/engines/ultima/ultima4/map/map.cpp
+++ b/engines/ultima/ultima4/map/map.cpp
@@ -442,8 +442,8 @@ ObjectDeque::iterator Map::removeObject(ObjectDeque::iterator rem, bool deleteOb
Creature *Map::moveObjects(MapCoords avatar) {
Creature *attacker = nullptr;
- for (uint i = 0; i < _objects.size(); i++) {
- Creature *m = dynamic_cast<Creature *>(_objects[i]);
+ for (auto *object : _objects) {
+ Creature *m = dynamic_cast<Creature *>(object);
if (m) {
/* check if the object is an attacking creature and not
@@ -693,7 +693,6 @@ bool Map::fillMonsterTable() {
int nCreatures = 0;
int nObjects = 0;
- int i;
for (int idx = 0; idx < MONSTERTABLE_SIZE; ++idx)
_monsterTable[idx].clear();
@@ -747,17 +746,19 @@ bool Map::fillMonsterTable() {
/**
* Fill in our monster table
*/
+ int i = 0;
TileMap *base = g_tileMaps->get("base");
- for (i = 0; i < MONSTERTABLE_SIZE; i++) {
- Coords c = monsters[i]->getCoords(),
- prevc = monsters[i]->getPrevCoords();
+ for (auto *monster : monsters) {
+ Coords c = monster->getCoords(),
+ prevc = monster->getPrevCoords();
- _monsterTable[i]._tile = base->untranslate(monsters[i]->getTile());
+ _monsterTable[i]._tile = base->untranslate(monster->getTile());
_monsterTable[i]._x = c.x;
_monsterTable[i]._y = c.y;
- _monsterTable[i]._prevTile = base->untranslate(monsters[i]->getPrevTile());
+ _monsterTable[i]._prevTile = base->untranslate(monster->getPrevTile());
_monsterTable[i]._prevX = prevc.x;
_monsterTable[i]._prevY = prevc.y;
+ i++;
}
return true;
More information about the Scummvm-git-logs
mailing list