Browse code

Fix warning about invalid index.

Naram Qashat authored on 2021/03/21 13:14:35
Showing 1 changed files
... ...
@@ -105,14 +105,17 @@ int Player::ChannelAlloc(ChannelAllocateType type, int priority)
105 105
 		int thisChnNo = chnArray[i];
106 106
 		if (!this->allowedChannels[thisChnNo])
107 107
 			continue;
108
-		Channel &thisChn = this->channels[thisChnNo];
109
-		Channel &curChn = this->channels[curChnNo];
110
-		if (curChnNo != -1 && thisChn.prio >= curChn.prio)
108
+		if (curChnNo != -1)
111 109
 		{
112
-			if (thisChn.prio != curChn.prio)
113
-				continue;
114
-			if (curChn.vol <= thisChn.vol)
115
-				continue;
110
+			Channel &thisChn = this->channels[thisChnNo];
111
+			Channel &curChn = this->channels[curChnNo];
112
+			if (curChnNo != -1 && thisChn.prio >= curChn.prio)
113
+			{
114
+				if (thisChn.prio != curChn.prio)
115
+					continue;
116
+				if (curChn.vol <= thisChn.vol)
117
+					continue;
118
+			}
116 119
 		}
117 120
 		curChnNo = thisChnNo;
118 121
 	}