changeset 20155:90904cdf8d95 draft

(svn r25099) -Fix [FS#5492]: Limit aircraft property 0D to 19, since the conversion result to km-ish/h needs to fit into a byte.
author frosch <frosch@openttd.org>
date Sun, 17 Mar 2013 18:31:35 +0000
parents dc50eeba6fd2
children 61b6b4e390a6
files src/newgrf.cpp
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -1618,9 +1618,15 @@
 				avi->max_speed = (buf->ReadByte() * 128) / 10;
 				break;
 
-			case 0x0D: // Acceleration
-				avi->acceleration = (buf->ReadByte() * 128) / 10;
-				break;
+			case 0x0D: { // Acceleration
+				uint acceleration = (buf->ReadByte() * 128) / 10;
+				if (acceleration > UINT8_MAX) {
+					grfmsg(1, "Acceleration property of aircraft %d is too big.", engine + i);
+					acceleration = UINT8_MAX;
+				}
+				avi->acceleration = acceleration;
+				break;
+			}
 
 			case PROP_AIRCRAFT_RUNNING_COST_FACTOR: // 0x0E Running cost factor
 				avi->running_cost = buf->ReadByte();