Codechange: Cache train curve speed limit can be stored in 16 bits.
Cache curve speed modifier and max curve speed are both 16 bit values so can be stored in 16 bit types instead of 32 bit types.
(cherry picked from commit 3fc7b3b9a0
)
This commit is contained in:

committed by
Jonathan G Rennison

parent
a1b7ca979b
commit
64bc95722b
@@ -262,7 +262,7 @@ void Train::ConsistChanged(ConsistChangeFlags allowed_changes)
|
||||
|
||||
bool train_can_tilt = true;
|
||||
bool speed_varies_by_railtype = false;
|
||||
int min_curve_speed_mod = INT_MAX;
|
||||
int16_t min_curve_speed_mod = INT16_MAX;
|
||||
|
||||
for (Train *u = this; u != nullptr; u = u->Next()) {
|
||||
const RailVehicleInfo *rvi_u = RailVehInfo(u->engine_type);
|
||||
@@ -607,7 +607,7 @@ int GetTrainStopLocation(StationID station_id, TileIndex tile, Train *v, bool up
|
||||
* Computes train speed limit caused by curves
|
||||
* @return imposed speed limit
|
||||
*/
|
||||
int Train::GetCurveSpeedLimit() const
|
||||
uint16_t Train::GetCurveSpeedLimit() const
|
||||
{
|
||||
dbg_assert(this->First() == this);
|
||||
|
||||
@@ -674,7 +674,7 @@ int Train::GetCurveSpeedLimit() const
|
||||
max_speed = Clamp(max_speed, 2, absolute_max_speed);
|
||||
}
|
||||
|
||||
return max_speed;
|
||||
return static_cast<uint16_t>(max_speed);
|
||||
}
|
||||
|
||||
void AdvanceOrderIndex(const Vehicle *v, VehicleOrderID &index)
|
||||
|
Reference in New Issue
Block a user