prevent range overflow

whenever dealing with unsigned, there's better no "-" in the line ...
This commit is contained in:
Thomas Lübking 2016-10-09 20:25:55 +02:00
parent 3301e993ad
commit 4bab7afaa4

View file

@ -404,7 +404,7 @@ void Container::repositionItems() {
for (int i = 0; i < buttonDemands.size(); ++i) {
if (buttonDemands.at(i) > thresh) {
int d = buttonDemands.at(i)*overhead/greed;
if (buttonDemands.at(i) - d > mean) {
if (buttonDemands.at(i) > mean + d) {
buttonDemands.at(i) -= d;
} else { // do not shrink below mean or a huge item number would super-punish larger ones
d = buttonDemands.at(i) - mean;