Changeset - r20058:431b83660079
[Not reviewed]
master
0 1 0
rubidium - 11 years ago 2013-02-17 20:16:49
rubidium@openttd.org
(svn r25016) -Fix [FS#5476]: integer overflow in UpdateStationRating (fonsinchen)
1 file changed with 3 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/station_cmd.cpp
Show inline comments
 
@@ -3298,25 +3298,27 @@ static void UpdateStationRating(Station 
 
				static const uint WAITING_CARGO_THRESHOLD  = 1 << 12;
 
				static const uint WAITING_CARGO_CUT_FACTOR = 1 <<  6;
 
				static const uint MAX_WAITING_CARGO        = 1 << 15;
 

	
 
				if (waiting > WAITING_CARGO_THRESHOLD) {
 
					uint difference = waiting - WAITING_CARGO_THRESHOLD;
 
					waiting -= (difference / WAITING_CARGO_CUT_FACTOR);
 

	
 
					waiting = min(waiting, MAX_WAITING_CARGO);
 
					waiting_changed = true;
 
				}
 

	
 
				if (waiting_changed) ge->cargo.Truncate(ge->cargo.Count() - waiting);
 
				if (waiting_changed && waiting < ge->cargo.Count()) {
 
					ge->cargo.Truncate(ge->cargo.Count() - waiting);
 
				}
 
			}
 
		}
 
	}
 

	
 
	StationID index = st->index;
 
	if (waiting_changed) {
 
		SetWindowDirty(WC_STATION_VIEW, index); // update whole window
 
	} else {
 
		SetWindowWidgetDirty(WC_STATION_VIEW, index, WID_SV_ACCEPT_RATING_LIST); // update only ratings list
 
	}
 
}
 

	
0 comments (0 inline, 0 general)