Loading

Paste #pdk6cftpp

  1. Index: src/train_cmd.cpp
  2. ===================================================================
  3. --- src/train_cmd.cpp   (revision 27760)
  4. +++ src/train_cmd.cpp   (working copy)
  5. @@ -3901,11 +3901,21 @@
  6.  {
  7.     Money cost = 0;
  8.     const Train *v = this;
  9. +   uint16 unc_len = 0;
  10.  
  11.     do {
  12.         const Engine *e = v->GetEngine();
  13. -       if (e->u.rail.running_cost_class == INVALID_PRICE) continue;
  14.  
  15. +       if (e->u.rail.running_cost_class == INVALID_PRICE) {
  16. +           const Train *a = v;
  17. +
  18. +           do {
  19. +               unc_len += a->gcache.cached_veh_length;
  20. +               a = a->HasArticulatedPart() ? a->GetNextArticulatedPart() : NULL;
  21. +           } while (a != NULL);
  22. +           continue;
  23. +       }
  24. +
  25.         uint cost_factor = GetVehicleProperty(v, PROP_TRAIN_RUNNING_COST_FACTOR, e->u.rail.running_cost);
  26.         if (cost_factor == 0) continue;
  27.  
  28. @@ -3915,7 +3925,7 @@
  29.         cost += GetPrice(e->u.rail.running_cost_class, cost_factor, e->GetGRF());
  30.     } while ((v = v->GetNextVehicle()) != NULL);
  31.  
  32. -   return cost;
  33. +   return cost += cost * unc_len / (VEHICLE_LENGTH * 2 * _settings_game.vehicle.max_train_length);
  34.  }
  35.  
  36.  /**

Comments