Loading

Paste #p40zvlxz6

  1. Index: src/economy_func.h
  2. ===================================================================
  3. --- src/economy_func.h  (revision 27929)
  4. +++ src/economy_func.h  (working copy)
  5. @@ -31,7 +31,7 @@
  6.  void StartupIndustryDailyChanges(bool init_counter);
  7.  
  8.  Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type);
  9. -uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, SourceID source_id, const StationList *all_stations);
  10. +uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, SourceID source_id, const StationList *all_stations, bool oil_rig = false);
  11.  
  12.  void PrepareUnload(Vehicle *front_v);
  13.  void LoadUnloadStation(Station *st);
  14. Index: src/industry_cmd.cpp
  15. ===================================================================
  16. --- src/industry_cmd.cpp    (revision 27929)
  17. +++ src/industry_cmd.cpp    (working copy)
  18. @@ -390,7 +390,7 @@
  19.     return FlatteningFoundation(tileh);
  20.  }
  21.  
  22. -static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted)
  23. +static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted, bool oil_rig)
  24.  {
  25.     IndustryGfx gfx = GetIndustryGfx(tile);
  26.     const IndustryTileSpec *itspec = GetIndustryTileSpec(gfx);
  27. @@ -423,6 +423,8 @@
  28.     for (byte i = 0; i < lengthof(itspec->accepts_cargo); i++) {
  29.         CargoID a = accepts_cargo[i];
  30.         if (a == CT_INVALID || cargo_acceptance[i] == 0) continue; // work only with valid cargoes
  31. +       if (oil_rig && (GetIndustrySpec(ind->type)->behaviour & INDUSTRYBEH_BUILT_ONWATER) == 0) continue;
  32. +       if (!oil_rig && (GetIndustrySpec(ind->type)->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0) continue;
  33.  
  34.         /* Add accepted cargo */
  35.         acceptance[a] += cargo_acceptance[i];
  36. @@ -495,6 +497,7 @@
  37.  {
  38.     Industry *i = Industry::GetByTile(tile);
  39.     const IndustrySpec *indspec = GetIndustrySpec(i->type);
  40. +   bool oil_rig = (indspec->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0;
  41.     bool moved_cargo = false;
  42.  
  43.     StationFinder stations(i->location);
  44. @@ -509,7 +512,7 @@
  45.  
  46.             i->this_month_production[j] += cw;
  47.  
  48. -           uint am = MoveGoodsToStation(i->produced_cargo[j], cw, ST_INDUSTRY, i->index, stations.GetStations());
  49. +           uint am = MoveGoodsToStation(i->produced_cargo[j], cw, ST_INDUSTRY, i->index, stations.GetStations(), oil_rig);
  50.             i->this_month_transported[j] += am;
  51.  
  52.             moved_cargo |= (am != 0);
  53. Index: src/object_cmd.cpp
  54. ===================================================================
  55. --- src/object_cmd.cpp  (revision 27929)
  56. +++ src/object_cmd.cpp  (working copy)
  57. @@ -540,9 +540,10 @@
  58.     return cost;
  59.  }
  60.  
  61. -static void AddAcceptedCargo_Object(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted)
  62. +static void AddAcceptedCargo_Object(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted, bool oil_rig)
  63.  {
  64.     if (!IsObjectType(tile, OBJECT_HQ)) return;
  65. +   if (oil_rig) return;
  66.  
  67.     /* HQ accepts passenger and mail; but we have to divide the values
  68.      * between 4 tiles it occupies! */
  69. Index: src/station_cmd.cpp
  70. ===================================================================
  71. --- src/station_cmd.cpp (revision 27929)
  72. +++ src/station_cmd.cpp (working copy)
  73. @@ -506,6 +506,7 @@
  74.     const Industry *i;
  75.     FOR_ALL_INDUSTRIES(i) {
  76.         if (!ta.Intersects(i->location)) continue;
  77. +       if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_BUILT_ONWATER)) continue;
  78.  
  79.         for (uint j = 0; j < lengthof(i->produced_cargo); j++) {
  80.             CargoID cargo = i->produced_cargo[j];
  81. @@ -524,7 +525,7 @@
  82.   * @param rad Search radius in addition to given area
  83.   * @param always_accepted bitmask of cargo accepted by houses and headquarters; can be NULL
  84.   */
  85. -CargoArray GetAcceptanceAroundTiles(TileIndex tile, int w, int h, int rad, uint32 *always_accepted)
  86. +CargoArray GetAcceptanceAroundTiles(TileIndex tile, int w, int h, int rad, uint32 *always_accepted, bool oil_rig)
  87.  {
  88.     CargoArray acceptance;
  89.     if (always_accepted != NULL) *always_accepted = 0;
  90. @@ -547,7 +548,7 @@
  91.     for (int yc = y1; yc != y2; yc++) {
  92.         for (int xc = x1; xc != x2; xc++) {
  93.             TileIndex tile = TileXY(xc, yc);
  94. -           AddAcceptedCargo(tile, acceptance, always_accepted);
  95. +           AddAcceptedCargo(tile, acceptance, always_accepted, oil_rig);
  96.         }
  97.     }
  98.  
  99. @@ -572,7 +573,8 @@
  100.             st->rect.right  - st->rect.left + 1,
  101.             st->rect.bottom - st->rect.top  + 1,
  102.             st->GetCatchmentRadius(),
  103. -           &st->always_accepted
  104. +           &st->always_accepted,
  105. +           IsOilRig(st->xy)
  106.         );
  107.     }
  108.  
  109. @@ -3832,7 +3834,7 @@
  110.     return &this->stations;
  111.  }
  112.  
  113. -uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, SourceID source_id, const StationList *all_stations)
  114. +uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, SourceID source_id, const StationList *all_stations, bool oil_rig)
  115.  {
  116.     /* Return if nothing to do. Also the rounding below fails for 0. */
  117.     if (amount == 0) return 0;
  118. @@ -3846,7 +3848,7 @@
  119.         Station *st = *st_iter;
  120.  
  121.         /* Is the station reserved exclusively for somebody else? */
  122. -       if (st->town->exclusive_counter > 0 && st->town->exclusivity != st->owner) continue;
  123. +       if (!oil_rig && st->town->exclusive_counter > 0 && st->town->exclusivity != st->owner) continue;
  124.  
  125.         if (st->goods[type].rating == 0) continue; // Lowest possible rating, better not to give cargo anymore
  126.  
  127. @@ -3858,6 +3860,10 @@
  128.             if (st->facilities == FACIL_BUS_STOP) continue; // non-passengers are never served by just a bus stop
  129.         }
  130.  
  131. +       if (oil_rig && !IsOilRig(st->xy)) continue; // Oil rig cargo is served by none other than Oil Rigs' own stations.
  132. +
  133. +       if (!oil_rig && IsOilRig(st->xy)) continue; // Cargo not originated from Oil Rigs are never served by Oil Rigs' own stations.
  134. +
  135.         /* This station can be used, add it to st1/st2 */
  136.         if (st1 == NULL || st->goods[type].rating >= best_rating1) {
  137.             st2 = st1; best_rating2 = best_rating1; st1 = st; best_rating1 = st->goods[type].rating;
  138. Index: src/station_func.h
  139. ===================================================================
  140. --- src/station_func.h  (revision 27929)
  141. +++ src/station_func.h  (working copy)
  142. @@ -28,7 +28,7 @@
  143.  void UpdateAllStationVirtCoords();
  144.  
  145.  CargoArray GetProductionAroundTiles(TileIndex tile, int w, int h, int rad);
  146. -CargoArray GetAcceptanceAroundTiles(TileIndex tile, int w, int h, int rad, uint32 *always_accepted = NULL);
  147. +CargoArray GetAcceptanceAroundTiles(TileIndex tile, int w, int h, int rad, uint32 *always_accepted = NULL, bool oil_rig = false);
  148.  
  149.  void UpdateStationAcceptance(Station *st, bool show_msg);
  150.  
  151. Index: src/tile_cmd.h
  152. ===================================================================
  153. --- src/tile_cmd.h  (revision 27929)
  154. +++ src/tile_cmd.h  (working copy)
  155. @@ -81,7 +81,7 @@
  156.   * @param acceptance      Storage destination of the cargo acceptance in 1/8
  157.   * @param always_accepted Bitmask of always accepted cargo types
  158.   */
  159. -typedef void AddAcceptedCargoProc(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted);
  160. +typedef void AddAcceptedCargoProc(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted, bool oil_rig);
  161.  
  162.  /**
  163.   * Tile callback function signature for obtaining a tile description
  164. @@ -165,12 +165,12 @@
  165.  void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner);
  166.  void GetTileDesc(TileIndex tile, TileDesc *td);
  167.  
  168. -static inline void AddAcceptedCargo(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted)
  169. +static inline void AddAcceptedCargo(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted, bool oil_rig = false)
  170.  {
  171.     AddAcceptedCargoProc *proc = _tile_type_procs[GetTileType(tile)]->add_accepted_cargo_proc;
  172.     if (proc == NULL) return;
  173.     uint32 dummy = 0; // use dummy bitmask so there don't need to be several 'always_accepted != NULL' checks
  174. -   proc(tile, acceptance, always_accepted == NULL ? &dummy : always_accepted);
  175. +   proc(tile, acceptance, always_accepted == NULL ? &dummy : always_accepted, oil_rig);
  176.  }
  177.  
  178.  static inline void AddProducedCargo(TileIndex tile, CargoArray &produced)
  179. Index: src/town_cmd.cpp
  180. ===================================================================
  181. --- src/town_cmd.cpp    (revision 27929)
  182. +++ src/town_cmd.cpp    (working copy)
  183. @@ -601,14 +601,15 @@
  184.     }
  185.  }
  186.  
  187. -static inline void AddAcceptedCargoSetMask(CargoID cargo, uint amount, CargoArray &acceptance, uint32 *always_accepted)
  188. +static inline void AddAcceptedCargoSetMask(CargoID cargo, uint amount, CargoArray &acceptance, uint32 *always_accepted, bool oil_rig = false)
  189.  {
  190.     if (cargo == CT_INVALID || amount == 0) return;
  191. +   if (oil_rig) return;
  192.     acceptance[cargo] += amount;
  193.     SetBit(*always_accepted, cargo);
  194.  }
  195.  
  196. -static void AddAcceptedCargo_Town(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted)
  197. +static void AddAcceptedCargo_Town(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted, bool oil_rig = false)
  198.  {
  199.     const HouseSpec *hs = HouseSpec::Get(GetHouseType(tile));
  200.     CargoID accepts[3];

Comments