[Scummvm-git-logs] scummvm master -> f2c9137979c6d73b781dc6f5e51d94ab662117fc

bluegr noreply at scummvm.org
Sat Jan 7 00:40:49 UTC 2023


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
f2c9137979 COMMON: removed foreach.h


Commit: f2c9137979c6d73b781dc6f5e51d94ab662117fc
    https://github.com/scummvm/scummvm/commit/f2c9137979c6d73b781dc6f5e51d94ab662117fc
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2023-01-07T02:40:44+02:00

Commit Message:
COMMON: removed foreach.h

now that we are using c++11 we don't need this wrapper anymore

Changed paths:
  R common/foreach.h
    engines/grim/actor.cpp
    engines/grim/animation.cpp
    engines/grim/costume/main_model_component.cpp
    engines/grim/emi/costume/emianim_component.cpp
    engines/grim/emi/costume/emimesh_component.cpp
    engines/grim/emi/costume/emiskel_component.cpp
    engines/grim/emi/emi.cpp
    engines/grim/emi/lua_v2.cpp
    engines/grim/emi/modelemi.cpp
    engines/grim/grim.cpp
    engines/grim/lua.cpp
    engines/grim/lua_v1_actor.cpp
    engines/grim/lua_v1_text.cpp
    engines/grim/remastered/lua_remastered.cpp
    engines/grim/set.cpp


diff --git a/common/foreach.h b/common/foreach.h
deleted file mode 100644
index a0c8f9ec899..00000000000
--- a/common/foreach.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* 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 3 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef COMMON_FOREACH_H
-#define COMMON_FOREACH_H
-
-#include "common/scummsys.h"
-
-#if __cplusplus < 201103L
-
-namespace Common {
-
-class _Foreach_Container_Base_ {
-public:
-	_Foreach_Container_Base_() : brk(1) { }
-	mutable uint brk;
-};
-
-template<class T>
-class _Foreach_Container_ : public _Foreach_Container_Base_ {
-public:
-	_Foreach_Container_(const T &co) : i(co.begin()), e(co.end()) { }
-	void next() const {
-		++i;
-		brk = 1;
-	}
-	bool end() const { return i == e; }
-
-	mutable typename T::const_iterator i;
-	typename T::const_iterator e;
-};
-
-template<class T>
-inline _Foreach_Container_<T> _Create_Foreach_Container_(const T &c) {
-	return _Foreach_Container_<T>(c);
-}
-
-template<class T>
-inline const _Foreach_Container_<T> *_Get_Foreach_Container_(const _Foreach_Container_Base_ *c, const T &) {
-	return static_cast<const _Foreach_Container_<T> *>(c);
-}
-
-}
-
-#define foreach(var, container) \
-for (const Common::_Foreach_Container_Base_ &_FOREACH_CONTAINER_ = Common::_Create_Foreach_Container_(container);\
-	!Common::_Get_Foreach_Container_(&_FOREACH_CONTAINER_, container)->end(); \
-	Common::_Get_Foreach_Container_(&_FOREACH_CONTAINER_, container)->next()) \
-	for (var = *Common::_Get_Foreach_Container_(&_FOREACH_CONTAINER_, container)->i;\
-		_FOREACH_CONTAINER_.brk > 0; --_FOREACH_CONTAINER_.brk)
-
-#else
-
-#define foreach(var, container) for (var : container)
-
-#endif
-
-#endif
diff --git a/engines/grim/actor.cpp b/engines/grim/actor.cpp
index 8c7cff73a7d..8be6aa43738 100644
--- a/engines/grim/actor.cpp
+++ b/engines/grim/actor.cpp
@@ -41,8 +41,6 @@
 #include "engines/grim/emi/costume/emiskel_component.h"
 #include "engines/grim/emi/modelemi.h"
 
-#include "common/foreach.h"
-
 namespace Grim {
 
 Shadow::Shadow() :
@@ -516,7 +514,7 @@ void Actor::setPos(const Math::Vector3d &position) {
 
 	if (g_grim->getGameType() == GType_MONKEY4) {
 		Math::Vector3d moveVec = position - _pos;
-		foreach (Actor *a, g_grim->getActiveActors()) {
+		for (Actor *a : g_grim->getActiveActors()) {
 			handleCollisionWith(a, _collisionMode, &moveVec);
 		}
 	}
@@ -792,7 +790,7 @@ void Actor::moveTo(const Math::Vector3d &pos) {
 	}
 
 	Math::Vector3d moveVec = pos - _pos;
-	foreach (Actor *a, g_grim->getActiveActors()) {
+	for (Actor *a : g_grim->getActiveActors()) {
 		handleCollisionWith(a, mode, &moveVec);
 	}
 	_pos += moveVec;
@@ -1239,14 +1237,14 @@ void Actor::sayLine(const char *msgId, bool background, float x, float y) {
 			// if we're talking background draw the text object only if there are no no-background
 			// talking actors. This prevents glottis and nick subtitles overlapping in the high roller lounge,
 			// where glottis is background and nick isn't. (https://github.com/residualvm/residualvm/issues/685)
-			foreach (Actor *a, g_grim->getTalkingActors()) {
+			for (Actor *a : g_grim->getTalkingActors()) {
 				if (!a->_backgroundTalk && a->_sayLineText) {
 					return;
 				}
 			}
 		} else {
 			// if we're not background then delete the TextObject of any talking background actor.
-			foreach (Actor *a, g_grim->getTalkingActors()) {
+			for (Actor *a : g_grim->getTalkingActors()) {
 				if (a->_backgroundTalk && a->_sayLineText) {
 					delete TextObject::getPool().getObject(a->_sayLineText);
 					a->_sayLineText = 0;
@@ -1994,7 +1992,7 @@ Math::Vector3d Actor::handleCollisionTo(const Math::Vector3d &from, const Math::
 
 	Math::Vector3d p = pos;
 	Math::Vector3d moveVec = pos - _pos;
-	foreach (Actor *a, Actor::getPool()) {
+	for (Actor *a : Actor::getPool()) {
 		if (a != this && a->isInSet(_setName) && a->isVisible()) {
 			p = a->getTangentPos(from, p);
 			handleCollisionWith(a, _collisionMode, &moveVec);
diff --git a/engines/grim/animation.cpp b/engines/grim/animation.cpp
index dad77fef840..9527b424acc 100644
--- a/engines/grim/animation.cpp
+++ b/engines/grim/animation.cpp
@@ -19,8 +19,6 @@
  *
  */
 
-#include "common/foreach.h"
-
 #include "engines/grim/animation.h"
 #include "engines/grim/resource.h"
 #include "engines/grim/model.h"
@@ -197,7 +195,7 @@ AnimManager::AnimManager() {
 }
 
 AnimManager::~AnimManager() {
-	foreach (const AnimationEntry &entry, _activeAnims) {
+	for (const AnimationEntry &entry : _activeAnims) {
 		Animation *anim = entry._anim;
 		// Don't call deactivate() here so we don't mess with the list we're using.
 		anim->_manager = nullptr;
diff --git a/engines/grim/costume/main_model_component.cpp b/engines/grim/costume/main_model_component.cpp
index 9a0a059d46d..454c9840f93 100644
--- a/engines/grim/costume/main_model_component.cpp
+++ b/engines/grim/costume/main_model_component.cpp
@@ -19,8 +19,6 @@
  *
  */
 
-#include "common/foreach.h"
-
 #include "engines/grim/model.h"
 #include "engines/grim/costume/model_component.h"
 #include "engines/grim/costume/main_model_component.h"
@@ -49,7 +47,7 @@ MainModelComponent::~MainModelComponent() {
 		_animation = nullptr;
 	}
 
-	foreach (MainModelComponent *child, _children) {
+	for (MainModelComponent *child : _children) {
 		child->_obj = nullptr;
 		child->_hier = nullptr;
 		child->_parentModel = nullptr;
diff --git a/engines/grim/emi/costume/emianim_component.cpp b/engines/grim/emi/costume/emianim_component.cpp
index 437642fccfe..45fd0088270 100644
--- a/engines/grim/emi/costume/emianim_component.cpp
+++ b/engines/grim/emi/costume/emianim_component.cpp
@@ -19,8 +19,6 @@
  *
  */
 
-#include "common/foreach.h"
-
 #include "engines/grim/debug.h"
 #include "engines/grim/emi/costume/emianim_component.h"
 #include "engines/grim/emi/costume/emiskel_component.h"
diff --git a/engines/grim/emi/costume/emimesh_component.cpp b/engines/grim/emi/costume/emimesh_component.cpp
index 8ed4b414609..61d8a5bae34 100644
--- a/engines/grim/emi/costume/emimesh_component.cpp
+++ b/engines/grim/emi/costume/emimesh_component.cpp
@@ -19,8 +19,6 @@
  *
  */
 
-#include "common/foreach.h"
-
 #include "engines/grim/emi/costume/emimesh_component.h"
 #include "engines/grim/emi/modelemi.h"
 #include "engines/grim/resource.h"
@@ -41,7 +39,7 @@ EMIMeshComponent::~EMIMeshComponent() {
 		delete _obj;
 	}
 
-	foreach (EMIMeshComponent *child, _children) {
+	for (EMIMeshComponent *child : _children) {
 		child->_obj = nullptr;
 		//child->_hier = NULL;
 		child->_parentModel = nullptr;
diff --git a/engines/grim/emi/costume/emiskel_component.cpp b/engines/grim/emi/costume/emiskel_component.cpp
index 94e9bb9b65d..a92fd62ca77 100644
--- a/engines/grim/emi/costume/emiskel_component.cpp
+++ b/engines/grim/emi/costume/emiskel_component.cpp
@@ -19,8 +19,6 @@
  *
  */
 
-#include "common/foreach.h"
-
 #include "engines/grim/emi/costume/emiskel_component.h"
 #include "engines/grim/resource.h"
 #include "engines/grim/emi/modelemi.h"
diff --git a/engines/grim/emi/emi.cpp b/engines/grim/emi/emi.cpp
index 95df8afbc66..513af1cbc83 100644
--- a/engines/grim/emi/emi.cpp
+++ b/engines/grim/emi/emi.cpp
@@ -19,8 +19,6 @@
  *
  */
 
-#include "common/foreach.h"
-
 #include "engines/grim/emi/emi.h"
 #include "engines/grim/emi/emi_registry.h"
 #include "engines/grim/emi/lua_v2.h"
@@ -81,7 +79,7 @@ const char *EMIEngine::getUpdateFilename() {
 }
 
 void EMIEngine::pushText() {
-	foreach (TextObject *t, TextObject::getPool()) {
+	for (TextObject *t : TextObject::getPool()) {
 		t->incStackLevel();
 	}
 	invalidateTextObjectsSortOrder();
@@ -90,7 +88,7 @@ void EMIEngine::pushText() {
 void EMIEngine::popText() {
 	Common::List<TextObject *> toDelete;
 
-	foreach (TextObject *t, TextObject::getPool()) {
+	for (TextObject *t : TextObject::getPool()) {
 		if (t->getStackLevel() == 0) {
 			warning("Text stack top not empty; deleting object");
 			toDelete.push_back(t);
@@ -111,7 +109,7 @@ void EMIEngine::popText() {
 void EMIEngine::purgeText() {
 	Common::List<TextObject *> toDelete;
 
-	foreach (TextObject *t, TextObject::getPool()) {
+	for (TextObject *t : TextObject::getPool()) {
 		if (t->getStackLevel() == 0) {
 			toDelete.push_back(t);
 		}
@@ -192,13 +190,13 @@ void EMIEngine::drawNormalMode() {
 
 	g_driver->drawDimPlane();
 
-	foreach (Actor *a, _activeActors) {
+	for (Actor *a : _activeActors) {
 		if (a->isInOverworld())
 			a->draw();
 	}
 
 	// Draw Primitives
-	foreach (PrimitiveObject *p, PrimitiveObject::getPool()) {
+	for (PrimitiveObject *p : PrimitiveObject::getPool()) {
 		p->draw();
 	}
 
@@ -274,7 +272,7 @@ bool EMIEngine::compareLayer(const Layer *x, const Layer *y) {
 
 void EMIEngine::drawTextObjects() {
 	sortTextObjects();
-	foreach (TextObject *t, _textObjects) {
+	for (TextObject *t : _textObjects) {
 		t->draw();
 	}
 }
@@ -286,7 +284,7 @@ void EMIEngine::sortTextObjects() {
 	_textObjectsSortOrderInvalidated = false;
 
 	_textObjects.clear();
-	foreach (TextObject *t, TextObject::getPool()) {
+	for (TextObject *t : TextObject::getPool()) {
 		if (t->getStackLevel() == 0) {
 			_textObjects.push_back(t);
 		}
@@ -297,7 +295,7 @@ void EMIEngine::sortTextObjects() {
 
 void EMIEngine::sortLayers() {
 	_layers.clear();
-	foreach (Layer *l, Layer::getPool()) {
+	for (Layer *l : Layer::getPool()) {
 		_layers.push_back(l);
 	}
 
diff --git a/engines/grim/emi/lua_v2.cpp b/engines/grim/emi/lua_v2.cpp
index 0a5e9445385..c733d2893fb 100644
--- a/engines/grim/emi/lua_v2.cpp
+++ b/engines/grim/emi/lua_v2.cpp
@@ -20,7 +20,6 @@
  */
 
 #include "common/endian.h"
-#include "common/foreach.h"
 #include "common/savefile.h"
 
 #include "graphics/surface.h"
@@ -221,7 +220,7 @@ void Lua_V2::GetFontDimensions() {
 	const char *fontName = lua_getstring(fontObj);
 
 	Font *font = nullptr;
-	foreach (Font *f, Font::getPool()) {
+	for (Font *f : Font::getPool()) {
 		if (f->getFilename() == fontName) {
 			font = f;
 		}
diff --git a/engines/grim/emi/modelemi.cpp b/engines/grim/emi/modelemi.cpp
index a0764ddc9d1..dd365ba103a 100644
--- a/engines/grim/emi/modelemi.cpp
+++ b/engines/grim/emi/modelemi.cpp
@@ -20,7 +20,6 @@
  */
 
 #include "common/endian.h"
-#include "common/foreach.h"
 
 #include "engines/grim/debug.h"
 #include "engines/grim/grim.h"
@@ -324,7 +323,7 @@ void EMIModel::updateLighting(const Math::Matrix4 &modelToWorld) {
 
 	Actor *actor = _costume->getOwner();
 
-	foreach(Light *l, g_grim->getCurrSet()->getLights(actor->isInOverworld())) {
+	for (Light *l : g_grim->getCurrSet()->getLights(actor->isInOverworld())) {
 		if (l->_enabled) {
 			activeLights.push_back(l);
 			if (l->_type == Light::Ambient)
diff --git a/engines/grim/grim.cpp b/engines/grim/grim.cpp
index d59aa07ee9d..209080c21dc 100644
--- a/engines/grim/grim.cpp
+++ b/engines/grim/grim.cpp
@@ -28,7 +28,6 @@
 #include "common/archive.h"
 #include "common/debug-channels.h"
 #include "common/file.h"
-#include "common/foreach.h"
 #include "common/fs.h"
 #include "common/config-manager.h"
 #include "common/compression/stuffit.h"
@@ -756,7 +755,7 @@ void GrimEngine::handleDebugLoadResource() {
 }
 
 void GrimEngine::drawTextObjects() {
-	foreach (TextObject *t, TextObject::getPool()) {
+	for (TextObject *t : TextObject::getPool()) {
 		t->draw();
 	}
 }
@@ -797,7 +796,7 @@ void GrimEngine::luaUpdate() {
 		// Update the actors. Do it here so that we are sure to react asap to any change
 		// in the actors state caused by lua.
 		buildActiveActorsList();
-		foreach (Actor *a, _activeActors) {
+		for (Actor *a : _activeActors) {
 			// Note that the actor need not be visible to update chores, for example:
 			// when Manny has just brought Meche back he is offscreen several times
 			// when he needs to perform certain chores
@@ -806,7 +805,7 @@ void GrimEngine::luaUpdate() {
 
 		_iris->update(_frameTime);
 
-		foreach (TextObject *t, TextObject::getPool()) {
+		for (TextObject *t : TextObject::getPool()) {
 			t->update();
 		}
 	}
@@ -903,11 +902,11 @@ void GrimEngine::drawNormalMode() {
 	_currSet->drawBitmaps(ObjectState::OBJSTATE_UNDERLAY);
 
 	// Draw Primitives
-	foreach (PrimitiveObject *p, PrimitiveObject::getPool()) {
+	for (PrimitiveObject *p : PrimitiveObject::getPool()) {
 		p->draw();
 	}
 
-	foreach (Overlay *p, Overlay::getPool()) {
+	for (Overlay *p : Overlay::getPool()) {
 		p->draw();
 	}
 
@@ -922,7 +921,7 @@ void GrimEngine::drawNormalMode() {
 
 	// Draw actors
 	buildActiveActorsList();
-	foreach (Actor *a, _activeActors) {
+	for (Actor *a : _activeActors) {
 		if (a->isVisible())
 			a->draw();
 	}
@@ -1447,7 +1446,7 @@ void GrimEngine::saveGRIM() {
 
 Set *GrimEngine::findSet(const Common::String &name) {
 	// Find scene object
-	foreach (Set *s, Set::getPool()) {
+	for (Set *s : Set::getPool()) {
 		if (s->getName() == name)
 			return s;
 	}
@@ -1495,14 +1494,14 @@ void GrimEngine::setSet(Set *scene) {
 		return;
 
 	if (getGameType() == GType_MONKEY4) {
-		foreach (PoolSound *s, PoolSound::getPool()) {
+		for (PoolSound *s : PoolSound::getPool()) {
 			s->stop();
 		}
 	}
 	// Stop the actors. This fixes bug #289 (https://github.com/residualvm/residualvm/issues/289)
 	// and it makes sense too, since when changing set the directions
 	// and coords change too.
-	foreach (Actor *a, Actor::getPool()) {
+	for (Actor *a : Actor::getPool()) {
 		a->stopWalking();
 	}
 
@@ -1569,7 +1568,7 @@ void GrimEngine::buildActiveActorsList() {
 	}
 
 	_activeActors.clear();
-	foreach (Actor *a, Actor::getPool()) {
+	for (Actor *a : Actor::getPool()) {
 		if (((_mode == NormalMode || _mode == DrawMode) && a->isDrawableInSet(_currSet->getName())) || a->isInOverworld()) {
 			_activeActors.push_back(a);
 		}
@@ -1584,7 +1583,7 @@ void GrimEngine::addTalkingActor(Actor *a) {
 bool GrimEngine::areActorsTalking() const {
 	//This takes into account that there may be actors which are still talking, but in the background.
 	bool talking = false;
-	foreach (Actor *a, _talkingActors) {
+	for (Actor *a : _talkingActors) {
 		if (a->isTalkingForeground()) {
 			talking = true;
 			break;
diff --git a/engines/grim/lua.cpp b/engines/grim/lua.cpp
index 850ed961dd5..184dd3ca831 100644
--- a/engines/grim/lua.cpp
+++ b/engines/grim/lua.cpp
@@ -20,7 +20,6 @@
  */
 
 #include "common/endian.h"
-#include "common/foreach.h"
 #include "common/system.h"
 #include "common/events.h"
 
@@ -513,7 +512,7 @@ void LuaBase::setTextObjectParams(TextObjectCommon *textObject, lua_Object table
 		if (g_grim->getGameType() == GType_MONKEY4 && lua_isstring(keyObj)) {
 			const char *str = lua_getstring(keyObj);
 			Font *font = nullptr;
-			foreach (Font *f, Font::getPool()) {
+			for (Font *f : Font::getPool()) {
 				if (f->getFilename() == str) {
 					font = f;
 				}
diff --git a/engines/grim/lua_v1_actor.cpp b/engines/grim/lua_v1_actor.cpp
index 5dc9d62a8b8..e7a045ab678 100644
--- a/engines/grim/lua_v1_actor.cpp
+++ b/engines/grim/lua_v1_actor.cpp
@@ -19,8 +19,6 @@
  *
  */
 
-#include "common/foreach.h"
-
 #include "engines/grim/grim.h"
 #include "engines/grim/lua_v1.h"
 #include "engines/grim/actor.h"
@@ -1420,7 +1418,7 @@ void Lua_V1::GetVisibleThings() {
 
 	// TODO verify code below
 	if (actor->isInSet(g_grim->getCurrSet()->getName())) {
-		foreach (Actor *a, g_grim->getActiveActors()) {
+		for (Actor *a : g_grim->getActiveActors()) {
 			// Consider the active actor visible
 			if (actor == a || actor->getYawTo(a) < 90) {
 				lua_pushobject(result);
diff --git a/engines/grim/lua_v1_text.cpp b/engines/grim/lua_v1_text.cpp
index ebde640a515..4f7c6e32a97 100644
--- a/engines/grim/lua_v1_text.cpp
+++ b/engines/grim/lua_v1_text.cpp
@@ -19,7 +19,6 @@
  *
  */
 
-#include "common/foreach.h"
 #include "common/savefile.h"
 #include "common/system.h"
 
@@ -135,7 +134,7 @@ void Lua_V1::GetTextObjectDimensions() {
 
 void Lua_V1::ExpireText() {
 	// Cleanup actor references to deleted text objects
-	foreach (Actor *a, Actor::getPool()) {
+	for (Actor *a : Actor::getPool()) {
 		a->lineCleanup();
 	}
 }
diff --git a/engines/grim/remastered/lua_remastered.cpp b/engines/grim/remastered/lua_remastered.cpp
index ded96d999d4..199fd044730 100644
--- a/engines/grim/remastered/lua_remastered.cpp
+++ b/engines/grim/remastered/lua_remastered.cpp
@@ -20,7 +20,6 @@
  */
 
 #include "common/endian.h"
-#include "common/foreach.h"
 #include "common/savefile.h"
 #include "common/config-manager.h"
 
@@ -177,7 +176,7 @@ void Lua_Remastered::QueryActiveHotspots() {
 	Math::Vector2d pos(g_grim->_cursorX*scaleX, g_grim->_cursorY*scaleY);
 	lua_Object result = lua_createtable();
 	int count = 0;
-	foreach (Hotspot *h, Hotspot::getPool()) {
+	for (Hotspot *h : Hotspot::getPool()) {
 		if (!h->_rect.containsPoint(pos)) {
 			continue;
 		}
diff --git a/engines/grim/set.cpp b/engines/grim/set.cpp
index ecdc433041b..0e2240b30bb 100644
--- a/engines/grim/set.cpp
+++ b/engines/grim/set.cpp
@@ -19,8 +19,6 @@
  *
  */
 
-#include "common/foreach.h"
-
 #include "engines/grim/debug.h"
 #include "engines/grim/set.h"
 #include "engines/grim/textsplit.h"
@@ -81,7 +79,7 @@ Set::~Set() {
 		}
 		delete[] _shadows;
 	}
-	foreach (Light *l, _overworldLightsList) {
+	for (Light *l : _overworldLightsList) {
 		delete l;
 	}
 }
@@ -820,7 +818,7 @@ void Set::setupLights(const Math::Vector3d &pos, bool inOverworld) {
 	Common::sort(lightsList->begin(), lightsList->end(), sorter);
 
 	int count = 0;
-	foreach (Light *l, *lightsList) {
+	for (Light *l : *lightsList) {
 		if (l->_enabled) {
 			g_driver->setupLight(l, count);
 			++count;




More information about the Scummvm-git-logs mailing list