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

LittleToonCat noreply at scummvm.org
Sun Mar 19 22:47:42 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:
c4a453ff74 SCUMM HE: Replace iterator loops with range-based.


Commit: c4a453ff74f21551eb3aaa6577a56de1793d2b87
    https://github.com/scummvm/scummvm/commit/c4a453ff74f21551eb3aaa6577a56de1793d2b87
Author: Little Cat (toontownlittlecat at gmail.com)
Date: 2023-03-19T19:43:57-03:00

Commit Message:
SCUMM HE: Replace iterator loops with range-based.

Changed paths:
    engines/scumm/he/net/net_main.cpp


diff --git a/engines/scumm/he/net/net_main.cpp b/engines/scumm/he/net/net_main.cpp
index b39d7e246ec..85709b0cc5b 100644
--- a/engines/scumm/he/net/net_main.cpp
+++ b/engines/scumm/he/net/net_main.cpp
@@ -325,9 +325,9 @@ int Net::joinSessionById(int sessionId) {
 		return 0;
 	}
 
-	for (Common::Array<Session>::iterator i = _sessions.begin(); i != _sessions.end(); i++) {
-		if (i->id == sessionId) {
-			return doJoinSession(*i);
+	for (auto &i : _sessions) {
+		if (i.id == sessionId) {
+			return doJoinSession(i);
 		}
 	}
 	warning("Net::joinSessionById(): session %d not found", sessionId);
@@ -341,8 +341,8 @@ int Net::ifSessionExist(int sessionId) {
 		return 0;
 	}
 
-	for (Common::Array<Session>::iterator i = _sessions.begin(); i != _sessions.end(); i++) {
-		if (i->id == sessionId) {
+	for (auto &i : _sessions) {
+		if (i.id == sessionId) {
 			return 1;
 		}
 	}
@@ -928,14 +928,14 @@ void Net::handleSessionServerData(Common::String data) {
 
 					// Check if we already know about this session:
 					bool makeNewSession = true;
-					for (Common::Array<Session>::iterator j = _sessions.begin(); j != _sessions.end(); j++) {
-						if (j->id == sessionData["id"]->asIntegerNumber()) {
+					for (auto &j : _sessions) {
+						if (j.id == sessionData["id"]->asIntegerNumber()) {
 							// Yes we do, Update the timestamp and player count.
 							makeNewSession = false;
-							if (!j->local) {
+							if (!j.local) {
 								// Only update if it's not a local session
-								j->timestamp = g_system->getMillis();
-								j->players = sessionData["players"]->asIntegerNumber();
+								j.timestamp = g_system->getMillis();
+								j.players = sessionData["players"]->asIntegerNumber();
 							}
 							break;
 						}
@@ -1079,22 +1079,22 @@ void Net::handleBroadcastData(Common::String data, Common::String host, int port
 
 				// Check if the session of the game ID (from the internet session server) exists.
 				// if so, update it as a local session and swap the internet-based address to local.
-				for (Common::Array<Session>::iterator i = _sessions.begin(); i != _sessions.end(); i++) {
-					if (i->id == sessionId && !i->local) {
-						i->local = true;
-						i->host = host;
-						i->port = port;
-						i->timestamp = g_system->getMillis();
-						i->players = players;
+				for (auto &i : _sessions) {
+					if (i.id == sessionId && !i.local) {
+						i.local = true;
+						i.host = host;
+						i.port = port;
+						i.timestamp = g_system->getMillis();
+						i.players = players;
 						return;
 					}
 				}
 				// Check if we already know about this session:
-				for (Common::Array<Session>::iterator i = _sessions.begin(); i != _sessions.end(); i++) {
-					if (i->host == host && i->port == port) {
+				for (auto &i : _sessions) {
+					if (i.host == host && i.port == port) {
 						// Yes we do, Update the timestamp and player count.
-						i->timestamp = g_system->getMillis();
-						i->players = players;
+						i.timestamp = g_system->getMillis();
+						i.players = players;
 						return;
 					}
 				}




More information about the Scummvm-git-logs mailing list