1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-19 18:32:35 +01:00

Fix: Clear rail vehicle flipped flag if reverse probability callback returns false. (#14281)

This now distinguishes between not-flipped and callback not implemented.
This commit is contained in:
Peter Nelson
2025-05-20 23:03:55 +01:00
committed by GitHub
parent acf594a7b7
commit a2addf0fe7
6 changed files with 24 additions and 10 deletions

View File

@@ -662,7 +662,8 @@ static CommandCost CmdBuildRailWagon(DoCommandFlags flags, TileIndex tile, const
v->group_id = DEFAULT_GROUP;
if (TestVehicleBuildProbability(v, v->engine_type, BuildProbabilityType::Reversed)) v->flags.Set(VehicleRailFlag::Flipped);
auto prob = TestVehicleBuildProbability(v, v->engine_type, BuildProbabilityType::Reversed);
if (prob.has_value()) v->flags.Set(VehicleRailFlag::Flipped, prob.value());
AddArticulatedParts(v);
v->UpdatePosition();
@@ -731,7 +732,8 @@ static void AddRearEngineToMultiheadedTrain(Train *v)
v->SetMultiheaded();
u->SetMultiheaded();
v->SetNext(u);
if (TestVehicleBuildProbability(u, u->engine_type, BuildProbabilityType::Reversed)) u->flags.Set(VehicleRailFlag::Flipped);
auto prob = TestVehicleBuildProbability(u, u->engine_type, BuildProbabilityType::Reversed);
if (prob.has_value()) u->flags.Set(VehicleRailFlag::Flipped, prob.value());
u->UpdatePosition();
/* Now we need to link the front and rear engines together */
@@ -804,7 +806,8 @@ CommandCost CmdBuildRailVehicle(DoCommandFlags flags, TileIndex tile, const Engi
v->SetFrontEngine();
v->SetEngine();
if (TestVehicleBuildProbability(v, v->engine_type, BuildProbabilityType::Reversed)) v->flags.Set(VehicleRailFlag::Flipped);
auto prob = TestVehicleBuildProbability(v, v->engine_type, BuildProbabilityType::Reversed);
if (prob.has_value()) v->flags.Set(VehicleRailFlag::Flipped, prob.value());
v->UpdatePosition();
if (rvi->railveh_type == RAILVEH_MULTIHEAD) {