Implement improved breakdown speed reductions for ships

This commit is contained in:
Jonathan G Rennison
2021-09-11 23:50:04 +01:00
parent 282f5f22e3
commit 0748d540e8
7 changed files with 36 additions and 5 deletions

View File

@@ -32,6 +32,7 @@ struct Ship FINAL : public SpecializedVehicle<Ship, VEH_SHIP> {
int16 rotation_x_pos; ///< NOSAVE: X Position before rotation.
int16 rotation_y_pos; ///< NOSAVE: Y Position before rotation.
uint8 lost_count; ///< Count of number of failed pathfinder attempts
byte critical_breakdown_count; ///< Counter for the number of critical breakdowns since last service
/** We don't want GCC to zero our struct! It already is zeroed and has an index! */
Ship() : SpecializedVehicleBase() {}
@@ -47,7 +48,9 @@ struct Ship FINAL : public SpecializedVehicle<Ship, VEH_SHIP> {
Direction GetMapImageDirection() const { return this->rotation; }
int GetDisplaySpeed() const { return this->cur_speed / 2; }
int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed / 2; }
int GetCurrentMaxSpeed() const { return std::min<int>(this->vcache.cached_max_speed, this->current_order.GetMaxSpeed() * 2); }
int GetEffectiveMaxSpeed() const;
int GetDisplayEffectiveMaxSpeed() const { return this->GetEffectiveMaxSpeed() / 2; }
int GetCurrentMaxSpeed() const { return std::min<int>(this->GetEffectiveMaxSpeed(), this->current_order.GetMaxSpeed() * 2); }
Money GetRunningCost() const;
bool IsInDepot() const { return this->state == TRACK_BIT_DEPOT; }
bool Tick();