Loading

wagon weight running cost

  1. Index: src/build_vehicle_gui.cpp
  2. ===================================================================
  3. --- src/build_vehicle_gui.cpp   (revision 27762)
  4. +++ src/build_vehicle_gui.cpp   (working copy)
  5. @@ -580,11 +580,11 @@
  6.     }
  7.  
  8.     /* Running cost */
  9. -   if (rvi->running_cost_class != INVALID_PRICE) {
  10. +// if (rvi->running_cost_class != INVALID_PRICE) {
  11.         SetDParam(0, e->GetRunningCost());
  12.         DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
  13.         y += FONT_HEIGHT_NORMAL;
  14. -   }
  15. +// }
  16.  
  17.     return y;
  18.  }
  19. Index: src/engine.cpp
  20. ===================================================================
  21. --- src/engine.cpp  (revision 27762)
  22. +++ src/engine.cpp  (working copy)
  23. @@ -285,6 +285,7 @@
  24.  {
  25.     Price base_price;
  26.     uint cost_factor;
  27. +// int shift = 0;
  28.     switch (this->type) {
  29.         case VEH_ROAD:
  30.             base_price = this->u.road.running_cost_class;
  31. @@ -294,7 +295,19 @@
  32.  
  33.         case VEH_TRAIN:
  34.             base_price = this->u.rail.running_cost_class;
  35. -           if (base_price == INVALID_PRICE) return 0;
  36. +           if (this->u.rail.railveh_type == RAILVEH_WAGON) {
  37. +               if (base_price == INVALID_PRICE) {
  38. +                   if (this->u.rail.railtype == RAILTYPE_RAIL) base_price = PR_RUNNING_TRAIN_ELECTRIC;
  39. +                   if (this->u.rail.railtype == RAILTYPE_ELECTRIC) base_price = PR_RUNNING_TRAIN_ELECTRIC;
  40. +                   if (this->u.rail.railtype == RAILTYPE_MONO) base_price = PR_RUNNING_TRAIN_DIESEL;
  41. +                   if (this->u.rail.railtype == RAILTYPE_MAGLEV) base_price = PR_RUNNING_TRAIN_STEAM;
  42. +                   cost_factor = this->u.rail.weight;
  43. +//                 shift = -3;
  44. +                   break;
  45. +               }
  46. +           } else {
  47. +               if (base_price == INVALID_PRICE) return 0;
  48. +           }
  49.             cost_factor = GetEngineProperty(this->index, PROP_TRAIN_RUNNING_COST_FACTOR, this->u.rail.running_cost);
  50.             break;
  51.  
  52. @@ -311,7 +324,7 @@
  53.         default: NOT_REACHED();
  54.     }
  55.  
  56. -   return GetPrice(base_price, cost_factor, this->GetGRF(), -8);
  57. +   return GetPrice(base_price, cost_factor, this->GetGRF(), -8/* + shift*/);
  58.  }
  59.  
  60.  /**
  61. Index: src/train_cmd.cpp
  62. ===================================================================
  63. --- src/train_cmd.cpp   (revision 27762)
  64. +++ src/train_cmd.cpp   (working copy)
  65. @@ -3901,11 +3901,27 @@
  66.  {
  67.     Money cost = 0;
  68.     const Train *v = this;
  69. +// uint16 unc_len = 0;
  70.  
  71.     do {
  72.         const Engine *e = v->GetEngine();
  73. -       if (e->u.rail.running_cost_class == INVALID_PRICE) continue;
  74.  
  75. +       if (e->u.rail.running_cost_class == INVALID_PRICE) {
  76. +//         const Train *a = v;
  77. +
  78. +//         do {
  79. +//             unc_len += a->gcache.cached_veh_length;
  80. +//             a = a->HasArticulatedPart() ? a->GetNextArticulatedPart() : NULL;
  81. +//         } while (a != NULL);
  82. +           if (v->IsWagon()) {
  83. +               if (e->u.rail.railtype == RAILTYPE_RAIL) cost += GetPrice(PR_RUNNING_TRAIN_ELECTRIC, e->u.rail.weight, e->GetGRF());
  84. +               if (e->u.rail.railtype == RAILTYPE_ELECTRIC) cost += GetPrice(PR_RUNNING_TRAIN_ELECTRIC, e->u.rail.weight, e->GetGRF());
  85. +               if (e->u.rail.railtype == RAILTYPE_MONO) cost += GetPrice(PR_RUNNING_TRAIN_DIESEL, e->u.rail.weight, e->GetGRF());
  86. +               if (e->u.rail.railtype == RAILTYPE_MAGLEV) cost += GetPrice(PR_RUNNING_TRAIN_STEAM, e->u.rail.weight, e->GetGRF());
  87. +           }
  88. +           continue;
  89. +       }
  90. +
  91.         uint cost_factor = GetVehicleProperty(v, PROP_TRAIN_RUNNING_COST_FACTOR, e->u.rail.running_cost);
  92.         if (cost_factor == 0) continue;
  93.  
  94. @@ -3915,6 +3931,7 @@
  95.         cost += GetPrice(e->u.rail.running_cost_class, cost_factor, e->GetGRF());
  96.     } while ((v = v->GetNextVehicle()) != NULL);
  97.  
  98. +// cost += cost * unc_len / (VEHICLE_LENGTH * 2);
  99.     return cost;
  100.  }

Comments