summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2010-11-06 13:11:24 +0000
committerterkhen <terkhen@openttd.org>2010-11-06 13:11:24 +0000
commitb65df931216207038d3560141166f2547041e18a (patch)
treec45d888fd72b967e8e4ec92142b9683d8e69c21c
parent18e3a3ddfc7c9eee4d1023485a4c23b3cc40fbb3 (diff)
downloadopenttd-b65df931216207038d3560141166f2547041e18a.tar.xz
(svn r21100) -Feature [NewGRF]: Add CB36 support for road vehicle property 0x15 (Speed).
-rw-r--r--src/engine.cpp6
-rw-r--r--src/newgrf.cpp2
-rw-r--r--src/newgrf_properties.h1
-rw-r--r--src/roadveh_cmd.cpp3
4 files changed, 8 insertions, 4 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index 55358b63f..3c6ae964c 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -294,8 +294,10 @@ uint Engine::GetDisplayMaxSpeed() const
case VEH_TRAIN:
return GetEngineProperty(this->index, PROP_TRAIN_SPEED, this->u.rail.max_speed);
- case VEH_ROAD:
- return this->u.road.max_speed / 2;
+ case VEH_ROAD: {
+ uint max_speed = GetEngineProperty(this->index, PROP_ROADVEH_SPEED, 0);
+ return (max_speed != 0) ? max_speed * 2 : this->u.road.max_speed / 2;
+ }
case VEH_SHIP:
return GetEngineProperty(this->index, PROP_SHIP_SPEED, this->u.ship.max_speed) / 2;
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index d2db54e3d..cfec0dd8d 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -832,7 +832,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop
rvi->weight = buf->ReadByte();
break;
- case 0x15: // Speed in mph/0.8
+ case PROP_ROADVEH_SPEED: // Speed in mph/0.8
_gted[e->index].rv_max_speed = buf->ReadByte();
break;
diff --git a/src/newgrf_properties.h b/src/newgrf_properties.h
index fc46aea2e..900220f94 100644
--- a/src/newgrf_properties.h
+++ b/src/newgrf_properties.h
@@ -32,6 +32,7 @@ enum PropertyID {
PROP_ROADVEH_COST_FACTOR = 0x11, ///< Purchase cost
PROP_ROADVEH_POWER = 0x13, ///< Power in 10 HP
PROP_ROADVEH_WEIGHT = 0x14, ///< Weight in 1/4 t
+ PROP_ROADVEH_SPEED = 0x15, ///< Max. speed: 1 unit = 1/0.8 mph = 2 km-ish/h
PROP_ROADVEH_TRACTIVE_EFFORT = 0x18, ///< Tractive effort coefficient in 1/256
PROP_SHIP_COST_FACTOR = 0x0A, ///< Purchase cost
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 1b9fef366..e6b575140 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -192,7 +192,8 @@ void RoadVehUpdateCache(RoadVehicle *v)
u->colourmap = PAL_NONE;
}
- v->vcache.cached_max_speed = RoadVehInfo(v->engine_type)->max_speed;
+ uint max_speed = GetVehicleProperty(v, PROP_ROADVEH_SPEED, 0);
+ v->vcache.cached_max_speed = (max_speed != 0) ? max_speed * 4 : RoadVehInfo(v->engine_type)->max_speed;
}
/**