Index: src/economy_func.h
===================================================================
--- src/economy_func.h (revision 27929)
+++ src/economy_func.h (working copy)
@@ -31,7 +31,7 @@
void StartupIndustryDailyChanges(bool init_counter);
Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type);
-uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, SourceID source_id, const StationList *all_stations);
+uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, SourceID source_id, const StationList *all_stations, bool oil_rig = false);
void PrepareUnload(Vehicle *front_v);
void LoadUnloadStation(Station *st);
Index: src/industry_cmd.cpp
===================================================================
--- src/industry_cmd.cpp (revision 27929)
+++ src/industry_cmd.cpp (working copy)
@@ -390,7 +390,7 @@
return FlatteningFoundation(tileh);
}
-static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted)
+static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted, bool oil_rig)
{
IndustryGfx gfx = GetIndustryGfx(tile);
const IndustryTileSpec *itspec = GetIndustryTileSpec(gfx);
@@ -423,6 +423,8 @@
for (byte i = 0; i < lengthof(itspec->accepts_cargo); i++) {
CargoID a = accepts_cargo[i];
if (a == CT_INVALID || cargo_acceptance[i] == 0) continue; // work only with valid cargoes
+ if (oil_rig && (GetIndustrySpec(ind->type)->behaviour & INDUSTRYBEH_BUILT_ONWATER) == 0) continue;
+ if (!oil_rig && (GetIndustrySpec(ind->type)->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0) continue;
/* Add accepted cargo */
acceptance[a] += cargo_acceptance[i];
@@ -495,6 +497,7 @@
{
Industry *i = Industry::GetByTile(tile);
const IndustrySpec *indspec = GetIndustrySpec(i->type);
+ bool oil_rig = (indspec->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0;
bool moved_cargo = false;
StationFinder stations(i->location);
@@ -509,7 +512,7 @@
i->this_month_production[j] += cw;
- uint am = MoveGoodsToStation(i->produced_cargo[j], cw, ST_INDUSTRY, i->index, stations.GetStations());
+ uint am = MoveGoodsToStation(i->produced_cargo[j], cw, ST_INDUSTRY, i->index, stations.GetStations(), oil_rig);
i->this_month_transported[j] += am;
moved_cargo |= (am != 0);
Index: src/object_cmd.cpp
===================================================================
--- src/object_cmd.cpp (revision 27929)
+++ src/object_cmd.cpp (working copy)
@@ -540,9 +540,10 @@
return cost;
}
-static void AddAcceptedCargo_Object(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted)
+static void AddAcceptedCargo_Object(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted, bool oil_rig)
{
if (!IsObjectType(tile, OBJECT_HQ)) return;
+ if (oil_rig) return;
/* HQ accepts passenger and mail; but we have to divide the values
* between 4 tiles it occupies! */
Index: src/station_cmd.cpp
===================================================================
--- src/station_cmd.cpp (revision 27929)
+++ src/station_cmd.cpp (working copy)
@@ -506,6 +506,7 @@
const Industry *i;
FOR_ALL_INDUSTRIES(i) {
if (!ta.Intersects(i->location)) continue;
+ if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_BUILT_ONWATER)) continue;
for (uint j = 0; j < lengthof(i->produced_cargo); j++) {
CargoID cargo = i->produced_cargo[j];
@@ -524,7 +525,7 @@
* @param rad Search radius in addition to given area
* @param always_accepted bitmask of cargo accepted by houses and headquarters; can be NULL
*/
-CargoArray GetAcceptanceAroundTiles(TileIndex tile, int w, int h, int rad, uint32 *always_accepted)
+CargoArray GetAcceptanceAroundTiles(TileIndex tile, int w, int h, int rad, uint32 *always_accepted, bool oil_rig)
{
CargoArray acceptance;
if (always_accepted != NULL) *always_accepted = 0;
@@ -547,7 +548,7 @@
for (int yc = y1; yc != y2; yc++) {
for (int xc = x1; xc != x2; xc++) {
TileIndex tile = TileXY(xc, yc);
- AddAcceptedCargo(tile, acceptance, always_accepted);
+ AddAcceptedCargo(tile, acceptance, always_accepted, oil_rig);
}
}
@@ -572,7 +573,8 @@
st->rect.right - st->rect.left + 1,
st->rect.bottom - st->rect.top + 1,
st->GetCatchmentRadius(),
- &st->always_accepted
+ &st->always_accepted,
+ IsOilRig(st->xy)
);
}
@@ -3832,7 +3834,7 @@
return &this->stations;
}
-uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, SourceID source_id, const StationList *all_stations)
+uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, SourceID source_id, const StationList *all_stations, bool oil_rig)
{
/* Return if nothing to do. Also the rounding below fails for 0. */
if (amount == 0) return 0;
@@ -3846,7 +3848,7 @@
Station *st = *st_iter;
/* Is the station reserved exclusively for somebody else? */
- if (st->town->exclusive_counter > 0 && st->town->exclusivity != st->owner) continue;
+ if (!oil_rig && st->town->exclusive_counter > 0 && st->town->exclusivity != st->owner) continue;
if (st->goods[type].rating == 0) continue; // Lowest possible rating, better not to give cargo anymore
@@ -3858,6 +3860,10 @@
if (st->facilities == FACIL_BUS_STOP) continue; // non-passengers are never served by just a bus stop
}
+ if (oil_rig && !IsOilRig(st->xy)) continue; // Oil rig cargo is served by none other than Oil Rigs' own stations.
+
+ if (!oil_rig && IsOilRig(st->xy)) continue; // Cargo not originated from Oil Rigs are never served by Oil Rigs' own stations.
+
/* This station can be used, add it to st1/st2 */
if (st1 == NULL || st->goods[type].rating >= best_rating1) {
st2 = st1; best_rating2 = best_rating1; st1 = st; best_rating1 = st->goods[type].rating;
Index: src/station_func.h
===================================================================
--- src/station_func.h (revision 27929)
+++ src/station_func.h (working copy)
@@ -28,7 +28,7 @@
void UpdateAllStationVirtCoords();
CargoArray GetProductionAroundTiles(TileIndex tile, int w, int h, int rad);
-CargoArray GetAcceptanceAroundTiles(TileIndex tile, int w, int h, int rad, uint32 *always_accepted = NULL);
+CargoArray GetAcceptanceAroundTiles(TileIndex tile, int w, int h, int rad, uint32 *always_accepted = NULL, bool oil_rig = false);
void UpdateStationAcceptance(Station *st, bool show_msg);
Index: src/tile_cmd.h
===================================================================
--- src/tile_cmd.h (revision 27929)
+++ src/tile_cmd.h (working copy)
@@ -81,7 +81,7 @@
* @param acceptance Storage destination of the cargo acceptance in 1/8
* @param always_accepted Bitmask of always accepted cargo types
*/
-typedef void AddAcceptedCargoProc(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted);
+typedef void AddAcceptedCargoProc(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted, bool oil_rig);
/**
* Tile callback function signature for obtaining a tile description
@@ -165,12 +165,12 @@
void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner);
void GetTileDesc(TileIndex tile, TileDesc *td);
-static inline void AddAcceptedCargo(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted)
+static inline void AddAcceptedCargo(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted, bool oil_rig = false)
{
AddAcceptedCargoProc *proc = _tile_type_procs[GetTileType(tile)]->add_accepted_cargo_proc;
if (proc == NULL) return;
uint32 dummy = 0; // use dummy bitmask so there don't need to be several 'always_accepted != NULL' checks
- proc(tile, acceptance, always_accepted == NULL ? &dummy : always_accepted);
+ proc(tile, acceptance, always_accepted == NULL ? &dummy : always_accepted, oil_rig);
}
static inline void AddProducedCargo(TileIndex tile, CargoArray &produced)
Index: src/town_cmd.cpp
===================================================================
--- src/town_cmd.cpp (revision 27929)
+++ src/town_cmd.cpp (working copy)
@@ -601,14 +601,15 @@
}
}
-static inline void AddAcceptedCargoSetMask(CargoID cargo, uint amount, CargoArray &acceptance, uint32 *always_accepted)
+static inline void AddAcceptedCargoSetMask(CargoID cargo, uint amount, CargoArray &acceptance, uint32 *always_accepted, bool oil_rig = false)
{
if (cargo == CT_INVALID || amount == 0) return;
+ if (oil_rig) return;
acceptance[cargo] += amount;
SetBit(*always_accepted, cargo);
}
-static void AddAcceptedCargo_Town(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted)
+static void AddAcceptedCargo_Town(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted, bool oil_rig = false)
{
const HouseSpec *hs = HouseSpec::Get(GetHouseType(tile));
CargoID accepts[3];