From 5c237780650517d674739f7b4eecaaed1f085109 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Tue, 1 Jan 2008 22:24:18 +0000 Subject: (svn r11741) -Feature: Add support for NewGRF's train 'tilt' flag. Trains with tilt capability (specific details are per NewGRF set) will be given a 20% speed limit bonus on curves. --- src/train_cmd.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/train_cmd.cpp') diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 6c6a905c7..02fd41069 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -164,12 +164,16 @@ void TrainConsistChanged(Vehicle* v) v->u.rail.cached_total_length = 0; v->u.rail.compatible_railtypes = 0; + bool train_can_tilt = true; + for (Vehicle *u = v; u != NULL; u = u->Next()) { const RailVehicleInfo *rvi_u = RailVehInfo(u->engine_type); /* Check the v->first cache. */ assert(u->First() == v); + if (!HasBit(EngInfo(u->engine_type)->misc_flags, EF_RAIL_TILTS)) train_can_tilt = false; + /* update the 'first engine' */ u->u.rail.first_engine = v == u ? INVALID_ENGINE : first_engine; u->u.rail.railtype = rvi_u->railtype; @@ -253,6 +257,7 @@ void TrainConsistChanged(Vehicle* v) /* store consist weight/max speed in cache */ v->u.rail.cached_max_speed = max_speed; + v->u.rail.cached_tilt = train_can_tilt; /* recalculate cached weights and power too (we do this *after* the rest, so it is known which wagons are powered and need extra weight added) */ TrainCargoChanged(v); @@ -338,6 +343,11 @@ static int GetTrainAcceleration(Vehicle *v, bool mode) /* Apply the engine's rail type curve speed advantage, if it slowed by curves */ const RailtypeInfo *rti = GetRailTypeInfo(v->u.rail.railtype); max_speed += (max_speed / 2) * rti->curve_speed; + + if (v->u.rail.cached_tilt) { + /* Apply max_speed bonus of 20% for a tilting train */ + max_speed += max_speed / 5; + } } if (IsTileType(v->tile, MP_STATION) && IsFrontEngine(v)) { -- cgit v1.2.3-54-g00ecf