diff options
Diffstat (limited to 'src/ground_vehicle.hpp')
-rw-r--r-- | src/ground_vehicle.hpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/ground_vehicle.hpp b/src/ground_vehicle.hpp index 15aac1f36..b08a23d0e 100644 --- a/src/ground_vehicle.hpp +++ b/src/ground_vehicle.hpp @@ -14,6 +14,7 @@ #include "vehicle_gui.h" #include "landscape.h" #include "window_func.h" +#include "tunnel_map.h" #include "widgets/vehicle_widget.h" /** What is the status of our acceleration? */ @@ -52,6 +53,7 @@ enum GroundVehicleFlags { GVF_GOINGUP_BIT = 0, ///< Vehicle is currently going uphill. (Cached track information for acceleration) GVF_GOINGDOWN_BIT = 1, ///< Vehicle is currently going downhill. (Cached track information for acceleration) GVF_SUPPRESS_IMPLICIT_ORDERS = 2, ///< Disable insertion and removal of automatic orders until the vehicle completes the real order. + GVF_CHUNNEL_BIT = 3, ///< Vehicle may currently be in a chunnel. (Cached track information for inclination changes) }; /** @@ -220,20 +222,28 @@ struct GroundVehicle : public SpecializedVehicle<T, Type> { this->z_pos += HasBit(this->gv_flags, GVF_GOINGUP_BIT) ? d : -d; } + if (HasBit(this->gv_flags, GVF_CHUNNEL_BIT) && !IsTunnelTile(this->tile)) { + ClrBit(this->gv_flags, GVF_CHUNNEL_BIT); + } + assert(this->z_pos == GetSlopePixelZ(this->x_pos, this->y_pos)); } + void UpdateZPositionInWormhole(); + /** * Checks if the vehicle is in a slope and sets the required flags in that case. * @param new_tile True if the vehicle reached a new tile. * @param update_delta Indicates to also update the delta. * @return Old height of the vehicle. */ - inline int UpdateInclination(bool new_tile, bool update_delta) + inline int UpdateInclination(bool new_tile, bool update_delta, bool in_wormhole = false) { int old_z = this->z_pos; - if (new_tile) { + if (in_wormhole) { + if (HasBit(this->gv_flags, GVF_CHUNNEL_BIT)) this->UpdateZPositionInWormhole(); + } else if (new_tile) { this->UpdateZPositionAndInclination(); } else { this->UpdateZPosition(); |