Loading

Paste #p0a0nmkke

  1. # HG changeset patch
  2. # User Ricardo@FX-8150
  3. # Date 1516922321 0
  4. #      Thu Jan 25 23:18:41 2018 +0000
  5. # Branch trunk
  6. # Node ID bb9639bf29af9fb142efd08d3ef6f4526f6de620
  7. # Parent  437a5c7b0b81f96fe16ab21e1fd51e37226e1115
  8. 11
  9.  
  10. diff -r 437a5c7b0b81 -r bb9639bf29af src/vehicle.cpp
  11. --- a/src/vehicle.cpp   Tue Jan 23 18:45:40 2018 +0000
  12. +++ b/src/vehicle.cpp   Thu Jan 25 23:18:41 2018 +0000
  13. @@ -153,35 +153,15 @@
  14.  }
  15.  
  16.  /**
  17. - * Check if the vehicle needs to go to a depot in near future (if a opportunity presents itself) for service or replacement.
  18. - *
  19. - * @see NeedsAutomaticServicing()
  20. - * @return true if the vehicle should go to a depot if a opportunity presents itself.
  21. + * Test whether there is some pending autoreplace.
  22. + * @note We do this after the service-interval test.
  23. + *       There are a lot more reasons for autoreplace to fail than we can test here reasonably.
  24. + * @see NeedsServicing()
  25. + * @return true if there is a pending autoreplace
  26.   */
  27. -bool Vehicle::NeedsServicing() const
  28. +bool Vehicle::HasPendingReplace() const
  29.  {
  30. -   /* Stopped or crashed vehicles will not move, as such making unmovable
  31. -    * vehicles to go for service is lame. */
  32. -   if (this->vehstatus & (VS_STOPPED | VS_CRASHED)) return false;
  33. -
  34. -   /* Are we ready for the next service cycle? */
  35.     const Company *c = Company::Get(this->owner);
  36. -   if (this->ServiceIntervalIsPercent() ?
  37. -           (this->reliability >= this->GetEngine()->reliability * (100 - this->GetServiceInterval()) / 100) :
  38. -           (this->date_of_last_service + this->GetServiceInterval() >= _date)) {
  39. -       return false;
  40. -   }
  41. -
  42. -   /* If we're servicing anyway, because we have not disabled servicing when
  43. -    * there are no breakdowns or we are playing with breakdowns, bail out. */
  44. -   if (!_settings_game.order.no_servicing_if_no_breakdowns ||
  45. -           _settings_game.difficulty.vehicle_breakdowns != 0) {
  46. -       return true;
  47. -   }
  48. -
  49. -   /* Test whether there is some pending autoreplace.
  50. -    * Note: We do this after the service-interval test.
  51. -    * There are a lot more reasons for autoreplace to fail than we can test here reasonably. */
  52.     bool pending_replace = false;
  53.     Money needed_money = c->settings.engine_renew_money;
  54.     if (needed_money > c->money) return false;
  55. @@ -222,6 +202,36 @@
  56.  }
  57.  
  58.  /**
  59. + * Check if the vehicle needs to go to a depot in near future (if a opportunity presents itself) for service or replacement.
  60. + *
  61. + * @see NeedsAutomaticServicing()
  62. + * @return true if the vehicle should go to a depot if a opportunity presents itself.
  63. + */
  64. +bool Vehicle::NeedsServicing() const
  65. +{
  66. +   /* Stopped or crashed vehicles will not move, as such making unmovable
  67. +    * vehicles to go for service is lame. */
  68. +   if (this->vehstatus & (VS_STOPPED | VS_CRASHED)) return false;
  69. +
  70. +   /* Are we ready for the next service cycle? */
  71. +   const Company *c = Company::Get(this->owner);
  72. +   if (this->ServiceIntervalIsPercent() ?
  73. +           (this->reliability >= this->GetEngine()->reliability * (100 - this->GetServiceInterval()) / 100) :
  74. +           (this->date_of_last_service + this->GetServiceInterval() >= _date)) {
  75. +       return false;
  76. +   }
  77. +
  78. +   /* If we're servicing anyway, because we have not disabled servicing when
  79. +    * there are no breakdowns or we are playing with breakdowns, bail out. */
  80. +   if (!_settings_game.order.no_servicing_if_no_breakdowns ||
  81. +           _settings_game.difficulty.vehicle_breakdowns != 0) {
  82. +       return true;
  83. +   }
  84. +
  85. +   return this->HasPendingReplace();
  86. +}
  87. +
  88. +/**
  89.   * Checks if the current order should be interrupted for a service-in-depot order.
  90.   * @see NeedsServicing()
  91.   * @return true if the current order should be interrupted.
  92. diff -r 437a5c7b0b81 -r bb9639bf29af src/vehicle_base.h
  93. --- a/src/vehicle_base.h    Tue Jan 23 18:45:40 2018 +0000
  94. +++ b/src/vehicle_base.h    Thu Jan 25 23:18:41 2018 +0000
  95. @@ -728,6 +728,8 @@
  96.  
  97.     bool NeedsAutorenewing(const Company *c, bool use_renew_setting = true) const;
  98.  
  99. +   bool HasPendingReplace() const;
  100. +
  101.     bool NeedsServicing() const;
  102.     bool NeedsAutomaticServicing() const;

Comments