[Scummvm-git-logs] scummvm master -> ee4f4e7d20afd830ece8256f89dbb4794184e191
bluegr
noreply at scummvm.org
Fri Nov 7 12:14:41 UTC 2025
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
87c7f3e5db ULTIMA: Replace Std::list::reverse_iterator
9807f2dc71 ULTIMA: Replace Std::vector::reverse_iterator
ee4f4e7d20 ULTIMA: Replace Std::string::reverse_iterator
Commit: 87c7f3e5db5a663eb84ccfd86dbc09619422d9d0
https://github.com/scummvm/scummvm/commit/87c7f3e5db5a663eb84ccfd86dbc09619422d9d0
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2025-11-07T14:14:36+02:00
Commit Message:
ULTIMA: Replace Std::list::reverse_iterator
Changed paths:
engines/ultima/shared/std/containers.h
engines/ultima/ultima4/game/script.cpp
engines/ultima/ultima4/game/script.h
engines/ultima/ultima8/gumps/container_gump.cpp
engines/ultima/ultima8/gumps/gump.cpp
diff --git a/engines/ultima/shared/std/containers.h b/engines/ultima/shared/std/containers.h
index b21fb2b5095..ea2cdff4010 100644
--- a/engines/ultima/shared/std/containers.h
+++ b/engines/ultima/shared/std/containers.h
@@ -173,31 +173,6 @@ public:
template<class T>
class list : public Common::List<T> {
-public:
- struct reverse_iterator {
- private:
- typename Common::List<T>::iterator _it;
- public:
- reverse_iterator(typename Common::List<T>::iterator it) : _it(it) {}
- reverse_iterator() {}
-
- T operator*() const { return *_it; }
-
- reverse_iterator &operator++() {
- --_it;
- return *this;
- }
-
- bool operator==(const reverse_iterator &rhs) { return _it == rhs._it; }
- bool operator!=(const reverse_iterator &rhs) { return _it != rhs._it; }
- };
-public:
- reverse_iterator rbegin() {
- return reverse_iterator(Common::List<T>::reverse_begin());
- }
- reverse_iterator rend() {
- return reverse_iterator(Common::List<T>::end());
- }
};
/**
diff --git a/engines/ultima/ultima4/game/script.cpp b/engines/ultima/ultima4/game/script.cpp
index df39a2bb2eb..0d8cc74ca57 100644
--- a/engines/ultima/ultima4/game/script.cpp
+++ b/engines/ultima/ultima4/game/script.cpp
@@ -766,11 +766,11 @@ Shared::XMLNode *Script::find(Shared::XMLNode *node, const Common::String &scrip
return nullptr;
}
-Common::String Script::getPropAsStr(Std::list<Shared::XMLNode *> &nodes, const Common::String &prop, bool recursive) {
+Common::String Script::getPropAsStr(Common::List<Shared::XMLNode *> &nodes, const Common::String &prop, bool recursive) {
Common::String propvalue;
- Std::list<Shared::XMLNode *>::reverse_iterator i;
+ Common::List<Shared::XMLNode *>::iterator i;
- for (i = nodes.rbegin(); i != nodes.rend(); ++i) {
+ for (i = nodes.reverse_begin(); i != nodes.end(); --i) {
Shared::XMLNode *node = *i;
if (node->hasProperty(prop)) {
propvalue = node->getProperty(prop);
@@ -779,7 +779,7 @@ Common::String Script::getPropAsStr(Std::list<Shared::XMLNode *> &nodes, const C
}
if (propvalue.empty() && recursive) {
- for (i = nodes.rbegin(); i != nodes.rend(); ++i) {
+ for (i = nodes.reverse_begin(); i != nodes.end(); --i) {
Shared::XMLNode *node = *i;
if (node->getParent()) {
propvalue = getPropAsStr(node->getParent(), prop, recursive);
@@ -793,12 +793,12 @@ Common::String Script::getPropAsStr(Std::list<Shared::XMLNode *> &nodes, const C
}
Common::String Script::getPropAsStr(Shared::XMLNode *node, const Common::String &prop, bool recursive) {
- Std::list<Shared::XMLNode *> list;
+ Common::List<Shared::XMLNode *> list;
list.push_back(node);
return getPropAsStr(list, prop, recursive);
}
-int Script::getPropAsInt(Std::list<Shared::XMLNode *> &nodes, const Common::String &prop, bool recursive) {
+int Script::getPropAsInt(Common::List<Shared::XMLNode *> &nodes, const Common::String &prop, bool recursive) {
Common::String propvalue = getPropAsStr(nodes, prop, recursive);
return mathValue(propvalue);
}
diff --git a/engines/ultima/ultima4/game/script.h b/engines/ultima/ultima4/game/script.h
index 66ddb8171ab..ceeaccd6d1c 100644
--- a/engines/ultima/ultima4/game/script.h
+++ b/engines/ultima/ultima4/game/script.h
@@ -26,6 +26,7 @@
#include "ultima/shared/conf/xml_node.h"
#include "ultima/shared/std/containers.h"
#include "common/file.h"
+#include "common/list.h"
namespace Ultima {
namespace Ultima4 {
@@ -218,14 +219,14 @@ private:
* Gets a property as Common::String from the script, and
* translates it using scriptTranslate.
*/
- Common::String getPropAsStr(Std::list<Shared::XMLNode *> &nodes, const Common::String &prop, bool recursive);
+ Common::String getPropAsStr(Common::List<Shared::XMLNode *> &nodes, const Common::String &prop, bool recursive);
Common::String getPropAsStr(Shared::XMLNode *node, const Common::String &prop, bool recursive = false);
/**
* Gets a property as int from the script
*/
- int getPropAsInt(Std::list<Shared::XMLNode *> &nodes, const Common::String &prop, bool recursive);
+ int getPropAsInt(Common::List<Shared::XMLNode *> &nodes, const Common::String &prop, bool recursive);
int getPropAsInt(Shared::XMLNode *node, const Common::String &prop, bool recursive = false);
@@ -419,7 +420,7 @@ private:
State _state; /**< The state the script is in */
Shared::XMLNode *_currentScript; /**< The currently running script */
Shared::XMLNode *_currentItem; /**< The current position in the script */
- Std::list<Shared::XMLNode *> _translationContext; /**< A list of nodes that make up our translation context */
+ Common::List<Shared::XMLNode *> _translationContext; /**< A list of nodes that make up our translation context */
Common::String _target; /**< The name of a target script */
InputType _inputType; /**< The type of input required */
Common::String _inputName; /**< The variable in which to place the input (by default, "input") */
diff --git a/engines/ultima/ultima8/gumps/container_gump.cpp b/engines/ultima/ultima8/gumps/container_gump.cpp
index cd25b25ccea..1e8115a18e0 100644
--- a/engines/ultima/ultima8/gumps/container_gump.cpp
+++ b/engines/ultima/ultima8/gumps/container_gump.cpp
@@ -207,10 +207,10 @@ uint16 ContainerGump::TraceObjId(int32 mx, int32 my) {
bool showEditorItems = Ultima8Engine::get_instance()->isShowEditorItems();
Std::list<Item *> &contents = c->_contents;
- Std::list<Item *>::reverse_iterator iter;
+ Std::list<Item *>::iterator iter;
// iterate backwards, since we're painting from begin() to end()
- for (iter = contents.rbegin(); iter != contents.rend(); ++iter) {
+ for (iter = contents.reverse_begin(); iter != contents.end(); --iter) {
Item *item = *iter;
if (!showEditorItems && item->getShapeInfo()->is_editor())
continue;
diff --git a/engines/ultima/ultima8/gumps/gump.cpp b/engines/ultima/ultima8/gumps/gump.cpp
index 730a40c2248..d23952c946b 100644
--- a/engines/ultima/ultima8/gumps/gump.cpp
+++ b/engines/ultima/ultima8/gumps/gump.cpp
@@ -129,12 +129,12 @@ void Gump::Close(bool no_del) {
void Gump::RenderSurfaceChanged() {
// Iterate all children
- Std::list<Gump *>::reverse_iterator it = _children.rbegin();
- Std::list<Gump *>::reverse_iterator end = _children.rend();
+ Std::list<Gump *>::iterator it = _children.reverse_begin();
+ Std::list<Gump *>::iterator end = _children.end();
while (it != end) {
(*it)->RenderSurfaceChanged();
- ++it;
+ --it;
}
}
@@ -195,8 +195,8 @@ bool Gump::GetMouseCursor(int32 mx, int32 my, Shape &shape, int32 &frame) {
bool ret = false;
// This reverse iterates the children
- Std::list<Gump *>::reverse_iterator it;
- for (it = _children.rbegin(); it != _children.rend(); ++it)
+ Std::list<Gump *>::iterator it;
+ for (it = _children.reverse_begin(); it != _children.end(); --it)
{
Gump *g = *it;
@@ -285,8 +285,8 @@ void Gump::PaintCompositing(RenderSurface *surf, int32 lerp_factor,
surf->setClippingRect(new_rect);
// Iterate all children
- Std::list<Gump *>::reverse_iterator it = _children.rbegin();
- Std::list<Gump *>::reverse_iterator end = _children.rend();
+ Std::list<Gump *>::iterator it = _children.reverse_begin();
+ Std::list<Gump *>::iterator end = _children.end();
while (it != end) {
Gump *g = *it;
@@ -294,7 +294,7 @@ void Gump::PaintCompositing(RenderSurface *surf, int32 lerp_factor,
if (!g->IsClosing())
g->PaintCompositing(surf, lerp_factor, sx, sy);
- ++it;
+ --it;
}
// Paint This
@@ -316,13 +316,13 @@ Gump *Gump::FindGump(int mx, int my) {
Gump *gump = nullptr;
// Iterate all children
- Std::list<Gump *>::reverse_iterator it = _children.rbegin();
- Std::list<Gump *>::reverse_iterator end = _children.rend();
+ Std::list<Gump *>::iterator it = _children.reverse_begin();
+ Std::list<Gump *>::iterator end = _children.end();
while (it != end && !gump) {
Gump *g = *it;
gump = g->FindGump(gx, gy);
- ++it;
+ --it;
}
// it's over a child
@@ -396,8 +396,8 @@ bool Gump::PointOnGump(int mx, int my) {
}
// reverse-iterate children
- Std::list<Gump *>::reverse_iterator it;
- for (it = _children.rbegin(); it != _children.rend(); ++it) {
+ Std::list<Gump *>::iterator it;
+ for (it = _children.reverse_begin(); it != _children.end(); --it) {
Gump *g = *it;
// It's got the point
@@ -483,8 +483,8 @@ uint16 Gump::TraceObjId(int32 mx, int32 my) {
uint16 objId_ = 0;
// reverse-iterate children
- Std::list<Gump *>::reverse_iterator it;
- for (it = _children.rbegin(); it != _children.rend(); ++it) {
+ Std::list<Gump *>::iterator it;
+ for (it = _children.reverse_begin(); it != _children.end(); --it) {
Gump *g = *it;
// Not if closing or hidden
@@ -559,9 +559,9 @@ void Gump::FindNewFocusChild() {
_focusChild = nullptr;
// Now add the gump to use as the new focus
- Std::list<Gump *>::reverse_iterator it = _children.rbegin();
+ Std::list<Gump *>::iterator it = _children.reverse_begin();
- if (it != _children.rend()) {
+ if (it != _children.end()) {
(*it)->MakeFocus();
}
}
@@ -674,8 +674,8 @@ Gump *Gump::onMouseDown(int button, int32 mx, int32 my) {
Gump *handled = nullptr;
// Iterate children backwards
- Std::list<Gump *>::reverse_iterator it;
- for (it = _children.rbegin(); it != _children.rend(); ++it) {
+ Std::list<Gump *>::iterator it;
+ for (it = _children.reverse_begin(); it != _children.end(); --it) {
Gump *g = *it;
// Not if closing or hidden
@@ -698,8 +698,8 @@ Gump *Gump::onMouseMotion(int32 mx, int32 my) {
Gump *handled = nullptr;
// Iterate children backwards
- Std::list<Gump *>::reverse_iterator it;
- for (it = _children.rbegin(); it != _children.rend(); ++it) {
+ Std::list<Gump *>::iterator it;
+ for (it = _children.reverse_begin(); it != _children.end(); --it) {
Gump *g = *it;
// Not if closing or hidden
Commit: 9807f2dc7177abe541f0373d6d1f8c42c8433ed8
https://github.com/scummvm/scummvm/commit/9807f2dc7177abe541f0373d6d1f8c42c8433ed8
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2025-11-07T14:14:36+02:00
Commit Message:
ULTIMA: Replace Std::vector::reverse_iterator
Changed paths:
engines/ultima/nuvie/conf/configuration.cpp
engines/ultima/shared/std/containers.h
engines/ultima/ultima4/views/tileview.cpp
engines/ultima/ultima8/conf/config_file_manager.cpp
diff --git a/engines/ultima/nuvie/conf/configuration.cpp b/engines/ultima/nuvie/conf/configuration.cpp
index 4ee12fc7ff7..ac847982116 100644
--- a/engines/ultima/nuvie/conf/configuration.cpp
+++ b/engines/ultima/nuvie/conf/configuration.cpp
@@ -80,10 +80,10 @@ void Configuration::clear() {
void Configuration::value(const Std::string &key, Std::string &ret,
const char *defaultvalue) const {
// Check for a .cfg file value in the trees
- for (Std::vector<Shared::XMLTree *>::const_reverse_iterator i = _trees.rbegin();
- i != _trees.rend(); ++i) {
- if ((*i)->hasNode(key)) {
- (*i)->value(key, ret, defaultvalue);
+ for (int i = _trees.size() - 1; i >= 0; --i) {
+ const Shared::XMLTree *tree = _trees[i];
+ if (tree->hasNode(key)) {
+ tree->value(key, ret, defaultvalue);
return;
}
}
@@ -108,10 +108,10 @@ void Configuration::value(const Std::string &key, Std::string &ret,
void Configuration::value(const Std::string &key, int &ret, int defaultvalue) const {
// Check for a .cfg file value in the trees
- for (Std::vector<Shared::XMLTree *>::const_reverse_iterator i = _trees.rbegin();
- i != _trees.rend(); ++i) {
- if ((*i)->hasNode(key)) {
- (*i)->value(key, ret, defaultvalue);
+ for (int i = _trees.size() - 1; i >= 0; --i) {
+ const Shared::XMLTree *tree = _trees[i];
+ if (tree->hasNode(key)) {
+ tree->value(key, ret, defaultvalue);
return;
}
}
@@ -136,10 +136,10 @@ void Configuration::value(const Std::string &key, int &ret, int defaultvalue) co
void Configuration::value(const Std::string &key, bool &ret, bool defaultvalue) const {
// Check for a .cfg file value in the trees
- for (Std::vector<Shared::XMLTree *>::const_reverse_iterator i = _trees.rbegin();
- i != _trees.rend(); ++i) {
- if ((*i)->hasNode(key)) {
- (*i)->value(key, ret, defaultvalue);
+ for (int i = _trees.size() - 1; i >= 0; --i) {
+ const Shared::XMLTree *tree = _trees[i];
+ if (tree->hasNode(key)) {
+ tree->value(key, ret, defaultvalue);
return;
}
}
@@ -175,11 +175,11 @@ bool Configuration::set(const Std::string &key, const Std::string &value) {
// Currently a value is written to the last writable tree with
// the correct root.
- for (Std::vector<Shared::XMLTree *>::reverse_iterator i = _trees.rbegin();
- i != _trees.rend(); ++i) {
- if (!((*i)->isReadonly()) &&
- (*i)->checkRoot(key)) {
- (*i)->set(key, value);
+ for (int i = _trees.size() - 1; i >= 0; --i) {
+ Shared::XMLTree *tree = _trees[i];
+ if (!(tree->isReadonly()) &&
+ tree->checkRoot(key)) {
+ tree->set(key, value);
return true;
}
}
@@ -208,11 +208,11 @@ bool Configuration::set(const Std::string &key, int value) {
// Currently a value is written to the last writable tree with
// the correct root.
- for (Std::vector<Shared::XMLTree *>::reverse_iterator i = _trees.rbegin();
- i != _trees.rend(); ++i) {
- if (!((*i)->isReadonly()) &&
- (*i)->checkRoot(key)) {
- (*i)->set(key, value);
+ for (int i = _trees.size() - 1; i >= 0; --i) {
+ Shared::XMLTree *tree = _trees[i];
+ if (!(tree->isReadonly()) &&
+ tree->checkRoot(key)) {
+ tree->set(key, value);
return true;
}
}
@@ -236,11 +236,11 @@ bool Configuration::set(const Std::string &key, bool value) {
// Currently a value is written to the last writable tree with
// the correct root.
- for (Std::vector<Shared::XMLTree *>::reverse_iterator i = _trees.rbegin();
- i != _trees.rend(); ++i) {
- if (!((*i)->isReadonly()) &&
- (*i)->checkRoot(key)) {
- (*i)->set(key, value);
+ for (int i = _trees.size() - 1; i >= 0; --i) {
+ Shared::XMLTree *tree = _trees[i];
+ if (!(tree->isReadonly()) &&
+ tree->checkRoot(key)) {
+ tree->set(key, value);
return true;
}
}
diff --git a/engines/ultima/shared/std/containers.h b/engines/ultima/shared/std/containers.h
index ea2cdff4010..0acd10cace3 100644
--- a/engines/ultima/shared/std/containers.h
+++ b/engines/ultima/shared/std/containers.h
@@ -36,73 +36,10 @@ namespace Std {
template<class T>
class vector : public Common::Array<T> {
-public:
- struct reverse_iterator {
- private:
- vector<T> *_owner;
- int _index;
- public:
- reverse_iterator(vector<T> *owner, int index) : _owner(owner), _index(index) {}
- reverse_iterator() : _owner(0), _index(-1) {}
-
- T &operator*() { return (*_owner)[_index]; }
-
- reverse_iterator &operator++() {
- --_index;
- return *this;
- }
-
- bool operator==(const reverse_iterator &rhs) {
- return _owner == rhs._owner && _index == rhs._index;
- }
- bool operator!=(const reverse_iterator &rhs) {
- return !operator==(rhs);
- }
- };
-
- struct const_reverse_iterator {
- private:
- const vector<T> *_owner;
- int _index;
- public:
- const_reverse_iterator(const vector<T> *owner, int index) : _owner(owner), _index(index) {
- }
- const_reverse_iterator() : _owner(0), _index(-1) {
- }
-
- const T operator*() const {
- return (*_owner)[_index];
- }
-
- const_reverse_iterator &operator++() {
- --_index;
- return *this;
- }
-
- bool operator==(const const_reverse_iterator &rhs) {
- return _owner == rhs._owner && _index == rhs._index;
- }
- bool operator!=(const const_reverse_iterator &rhs) {
- return !operator==(rhs);
- }
- };
public:
constexpr vector() : Common::Array<T>() {}
vector(size_t newSize) : Common::Array<T>(newSize) {}
vector(size_t newSize, const T elem) : Common::Array<T>(newSize, elem) {}
-
- reverse_iterator rbegin() {
- return reverse_iterator(this, (int)Common::Array<T>::size() - 1);
- }
- reverse_iterator rend() {
- return reverse_iterator(this, -1);
- }
- const_reverse_iterator rbegin() const {
- return const_reverse_iterator(this, (int)Common::Array<T>::size() - 1);
- }
- const_reverse_iterator rend() const {
- return const_reverse_iterator(this, -1);
- }
};
template<class T>
diff --git a/engines/ultima/ultima4/views/tileview.cpp b/engines/ultima/ultima4/views/tileview.cpp
index 83ec817ff44..7f9ee6e55c5 100644
--- a/engines/ultima/ultima4/views/tileview.cpp
+++ b/engines/ultima/ultima4/views/tileview.cpp
@@ -134,8 +134,8 @@ void TileView::drawTile(Std::vector<MapTile> &tiles, bool focus, int x, int y) {
);
// Iterate through rendering each of the needed tiles
- for (Std::vector<MapTile>::reverse_iterator t = tiles.rbegin(); t != tiles.rend(); ++t) {
- MapTile &frontTile = *t;
+ for (int t = tiles.size() - 1; t >= 0; --t) {
+ MapTile &frontTile = tiles[t];
Tile *frontTileType = _tileSet->get(frontTile._id);
if (!frontTileType) {
diff --git a/engines/ultima/ultima8/conf/config_file_manager.cpp b/engines/ultima/ultima8/conf/config_file_manager.cpp
index 74b0bf11a81..377f209ae16 100644
--- a/engines/ultima/ultima8/conf/config_file_manager.cpp
+++ b/engines/ultima/ultima8/conf/config_file_manager.cpp
@@ -85,10 +85,10 @@ void ConfigFileManager::clearRoot(const Std::string &category) {
}
bool ConfigFileManager::get(const Std::string &category, const Std::string §ion, const Std::string &key, string &ret) const {
- Std::vector<ConfigFile*>::const_reverse_iterator i;
- for (i = _configFiles.rbegin(); i != _configFiles.rend(); ++i) {
- if (category.equalsIgnoreCase((*i)->_category)) {
- if ((*i)->_iniFile.getKey(key, section, ret)) {
+ for (int i = _configFiles.size() - 1; i >= 0; --i) {
+ const ConfigFile *file = _configFiles[i];
+ if (category.equalsIgnoreCase(file->_category)) {
+ if (file->_iniFile.getKey(key, section, ret)) {
return true;
}
}
Commit: ee4f4e7d20afd830ece8256f89dbb4794184e191
https://github.com/scummvm/scummvm/commit/ee4f4e7d20afd830ece8256f89dbb4794184e191
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2025-11-07T14:14:36+02:00
Commit Message:
ULTIMA: Replace Std::string::reverse_iterator
Changed paths:
engines/ultima/nuvie/gui/widgets/msg_scroll_new_ui.cpp
engines/ultima/shared/std/string.h
diff --git a/engines/ultima/nuvie/gui/widgets/msg_scroll_new_ui.cpp b/engines/ultima/nuvie/gui/widgets/msg_scroll_new_ui.cpp
index 14807199267..5c4d7425994 100644
--- a/engines/ultima/nuvie/gui/widgets/msg_scroll_new_ui.cpp
+++ b/engines/ultima/nuvie/gui/widgets/msg_scroll_new_ui.cpp
@@ -106,10 +106,9 @@ void MsgScrollNewUI::display_string(const Std::string &str, Font *f, bool includ
string s = trailing_whitespace + str;
trailing_whitespace.clear();
- Std::string::reverse_iterator iter;
- uint16 i;
- for (i = 0, iter = s.rbegin(); iter != s.rend(); iter++, i++) {
- char c = *iter;
+ uint16 i, pos;
+ for (i = 0, pos = s.size(); pos >= 0; pos--, i++) {
+ char c = s[pos];
if (c != '\t' && c != '\n')
break;
}
diff --git a/engines/ultima/shared/std/string.h b/engines/ultima/shared/std/string.h
index fc16c89b534..5f2ce913024 100644
--- a/engines/ultima/shared/std/string.h
+++ b/engines/ultima/shared/std/string.h
@@ -28,34 +28,6 @@ namespace Ultima {
namespace Std {
class string final : public Common::String {
-public:
- struct reverse_iterator {
- private:
- string *_owner;
- int _index;
- public:
- reverse_iterator(string *owner, int index) : _owner(owner), _index(index) {}
- reverse_iterator() : _owner(0), _index(-1) {}
-
- char &operator*() const { return (*_owner)[_index]; }
-
- reverse_iterator &operator++() {
- --_index;
- return *this;
- }
- reverse_iterator operator++(int) {
- reverse_iterator tmp(_owner, _index);
- ++(*this);
- return tmp;
- }
-
- bool operator==(const reverse_iterator &rhs) {
- return _owner == rhs._owner && _index == rhs._index;
- }
- bool operator!=(const reverse_iterator &rhs) {
- return !operator==(rhs);
- }
- };
public:
constexpr string() : Common::String() {}
string(const char *str) : Common::String(str) {}
@@ -64,13 +36,6 @@ public:
string(const String &str) : Common::String(str) {}
explicit constexpr string(char c) : Common::String(c) {}
string(size_t n, char c) : Common::String(n, c) {}
-
- reverse_iterator rbegin() {
- return reverse_iterator(this, (int)size() - 1);
- }
- reverse_iterator rend() {
- return reverse_iterator(this, -1);
- }
};
} // End of namespace Std
More information about the Scummvm-git-logs
mailing list