summaryrefslogtreecommitdiff
path: root/src/newgrf.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2013-03-17 18:31:35 +0000
committerfrosch <frosch@openttd.org>2013-03-17 18:31:35 +0000
commitcf4a2702f8d6094757c80e2bed39e94a0cba9cff (patch)
tree179e332aacaf79c7caad72aa9a3945350f86beaf /src/newgrf.cpp
parent8ca173e365792b830d5fd090a011c827a0b4dcb3 (diff)
downloadopenttd-cf4a2702f8d6094757c80e2bed39e94a0cba9cff.tar.xz
(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.
Diffstat (limited to 'src/newgrf.cpp')
-rw-r--r--src/newgrf.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index f56b99899..848903324 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -1618,9 +1618,15 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint engine, int numinfo, int
avi->max_speed = (buf->ReadByte() * 128) / 10;
break;
- case 0x0D: // Acceleration
- avi->acceleration = (buf->ReadByte() * 128) / 10;
+ 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();