Loading

Paste #pslvkynrl

  1. Index: src/economy.cpp
  2. ===================================================================
  3. --- src/economy.cpp (revision 27655)
  4. +++ src/economy.cpp (working copy)
  5. @@ -1109,7 +1109,7 @@
  6.     st->town->received[cs->town_effect].new_act += accepted;
  7.  
  8.     /* Determine profit */
  9. -   Money profit = GetTransportedGoodsIncome(accepted, DistanceManhattan(source_tile, st->xy), days_in_transit, cargo_type);
  10. +   Money profit = GetTransportedGoodsIncome(accepted, DistanceManhattan_dp_(source_tile, st->xy), days_in_transit, cargo_type);
  11.  
  12.     /* Update the cargo monitor. */
  13.     AddCargoDelivery(cargo_type, company->index, accepted, src_type, src, st);
  14. @@ -1230,7 +1230,7 @@
  15.     Money profit = GetTransportedGoodsIncome(
  16.             count,
  17.             /* pay transfer vehicle for only the part of transfer it has done: ie. cargo_loaded_at_xy to here */
  18. -           DistanceManhattan(cp->LoadedAtXY(), Station::Get(this->current_station)->xy),
  19. +           DistanceManhattan_dp_(cp->LoadedAtXY(), Station::Get(this->current_station)->xy),
  20.             cp->DaysInTransit(),
  21.             this->ct);
  22.  
  23. Index: src/map.cpp
  24. ===================================================================
  25. --- src/map.cpp (revision 27655)
  26. +++ src/map.cpp (working copy)
  27. @@ -163,6 +163,12 @@
  28.     return dx + dy;
  29.  }
  30.  
  31. +uint DistanceManhattan_dp_(TileIndex t0, TileIndex t1)
  32. +{
  33. +   const uint dx = Delta(TileX(t0), TileX(t1));
  34. +   const uint dy = Delta(TileY(t0), TileY(t1));
  35. +   return 2 * minu(dx, dy) + 3 * Delta(dx, dy) / 2;
  36. +}
  37.  
  38.  /**
  39.   * Gets the 'Square' distance between the two given tiles.
  40. Index: src/map_func.h
  41. ===================================================================
  42. --- src/map_func.h  (revision 27655)
  43. +++ src/map_func.h  (working copy)
  44. @@ -327,6 +327,7 @@
  45.  
  46.  /* Functions to calculate distances */
  47.  uint DistanceManhattan(TileIndex, TileIndex); ///< also known as L1-Norm. Is the shortest distance one could go over diagonal tracks (or roads)
  48. +uint DistanceManhattan_dp_(TileIndex, TileIndex); ///< _dp_
  49.  uint DistanceSquare(TileIndex, TileIndex); ///< euclidian- or L2-Norm squared
  50.  uint DistanceMax(TileIndex, TileIndex); ///< also known as L-Infinity-Norm
  51.  uint DistanceMaxPlusManhattan(TileIndex, TileIndex); ///< Max + Manhattan

Version history

Revision # Author Created at
phnkvt9ud Anonymous 11 Sep 2016, 00:21:46 UTC Diff

Comments