--- a/src/station_cmd.cpp Sun Aug 19 14:04:13 2007 +0000
+++ b/src/station_cmd.cpp Sun Sep 02 11:17:33 2007 +0000
@@ -389,7 +389,7 @@
uint mask = 0;
for (CargoID i = 0; i < NUM_CARGO; i++) {
- if (st->goods[i].acceptance) mask |= 1 << i;
+ if (HASBIT(st->goods[i].acceptance_pickup, GoodsEntry::ACCEPTANCE)) mask |= 1 << i;
}
return mask;
}
@@ -570,7 +570,7 @@
(is_passengers && !(st->facilities & (byte)~FACIL_TRUCK_STOP)))
amt = 0;
- st->goods[i].acceptance = (amt >= 8);
+ SB(st->goods[i].acceptance_pickup, GoodsEntry::ACCEPTANCE, 1, amt >= 8);
}
// Only show a message in case the acceptance was actually changed.
@@ -2343,8 +2343,8 @@
}
/* For normal (non drive-through) road stops */
- /* Check if station is busy or if there are no free bays. */
- if (rs->IsEntranceBusy() || !rs->HasFreeBay()) return VETSB_CANNOT_ENTER;
+ /* Check if station is busy or if there are no free bays or whether it is a articulated vehicle. */
+ if (rs->IsEntranceBusy() || !rs->HasFreeBay() || RoadVehHasArticPart(v)) return VETSB_CANNOT_ENTER;
SETBIT(v->u.road.state, RVS_IN_ROAD_STOP);
@@ -2384,10 +2384,12 @@
/* Slowly increase the rating back to his original level in the case we
* didn't deliver cargo yet to this station. This happens when a bribe
* failed while you didn't moved that cargo yet to a station. */
- if (ge->days_since_pickup == 255 && ge->rating < INITIAL_STATION_RATING)
+ if (!HASBIT(ge->acceptance_pickup, GoodsEntry::PICKUP) && ge->rating < INITIAL_STATION_RATING) {
ge->rating++;
+ }
+
/* Only change the rating if we are moving this cargo */
- if (ge->last_speed != 0) {
+ if (HASBIT(ge->acceptance_pickup, GoodsEntry::PICKUP)) {
byte_inc_sat(&ge->days_since_pickup);
int rating = 0;
@@ -2519,7 +2521,7 @@
for (CargoID i = 0; i < NUM_CARGO; i++) {
GoodsEntry* ge = &st->goods[i];
- if (ge->days_since_pickup != 255) {
+ if (ge->acceptance_pickup != 0) {
ge->rating = clamp(ge->rating + amount, 0, 255);
}
}
@@ -2530,6 +2532,7 @@
static void UpdateStationWaiting(Station *st, CargoID type, uint amount)
{
st->goods[type].cargo.Append(new CargoPacket(st->index, amount));
+ SETBIT(st->goods[type].acceptance_pickup, GoodsEntry::PICKUP);
InvalidateWindow(WC_STATION_VIEW, st->index);
st->MarkTilesDirty(true);
@@ -2595,9 +2598,9 @@
if (_patches.modified_catchment) {
w_prod = w;
h_prod = h;
- w += 16;
- h += 16;
- max_rad = 8;
+ w += 2 * MAX_CATCHMENT;
+ h += 2 * MAX_CATCHMENT;
+ max_rad = MAX_CATCHMENT;
} else {
w_prod = 0;
h_prod = 0;
@@ -2616,16 +2619,16 @@
if (around[i] == NULL) {
if (!st->IsBuoy() &&
(st->town->exclusive_counter == 0 || st->town->exclusivity == st->owner) && // check exclusive transport rights
- st->goods[type].rating != 0 && st->goods[type].last_speed != 0 && // we actually service the station
- (!_patches.selectgoods || st->goods[type].last_speed > 0) && // if last_speed is 0, no vehicle has been there.
+ st->goods[type].rating != 0 && // when you've got the lowest rating you can get, it's better not to give cargo anymore
+ (!_patches.selectgoods || st->goods[type].last_speed != 0) && // we are servicing the station (or cargo is dumped on all stations)
((st->facilities & ~FACIL_BUS_STOP) != 0 || IsCargoInClass(type, CC_PASSENGERS)) && // if we have other fac. than a bus stop, or the cargo is passengers
((st->facilities & ~FACIL_TRUCK_STOP) != 0 || !IsCargoInClass(type, CC_PASSENGERS))) { // if we have other fac. than a cargo bay or the cargo is not passengers
if (_patches.modified_catchment) {
// min and max coordinates of the producer relative
- const int x_min_prod = 9;
- const int x_max_prod = 8 + w_prod;
- const int y_min_prod = 9;
- const int y_max_prod = 8 + h_prod;
+ const int x_min_prod = max_rad + 1;
+ const int x_max_prod = max_rad + w_prod;
+ const int y_min_prod = max_rad + 1;
+ const int y_max_prod = max_rad + h_prod;
int rad = FindCatchmentRadius(st);
@@ -2746,7 +2749,7 @@
st->build_date = _date;
for (CargoID j = 0; j < NUM_CARGO; j++) {
- st->goods[j].acceptance = false;
+ st->goods[j].acceptance_pickup = 0;
st->goods[j].days_since_pickup = 255;
st->goods[j].rating = INITIAL_STATION_RATING;
st->goods[j].last_speed = 0;
@@ -2876,6 +2879,11 @@
}
}
+static CommandCost TerraformTile_Station(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
+{
+ return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+}
+
extern const TileTypeProcs _tile_type_station_procs = {
DrawTile_Station, /* draw_tile_proc */
@@ -2891,6 +2899,7 @@
NULL, /* get_produced_cargo_proc */
VehicleEnter_Station, /* vehicle_enter_tile_proc */
GetFoundation_Station, /* get_foundation_proc */
+ TerraformTile_Station, /* terraform_tile_proc */
};
static const SaveLoad _roadstop_desc[] = {
@@ -2975,25 +2984,6 @@
static uint16 _cargo_days;
static Money _cargo_feeder_share;
-static const SaveLoad _goods_desc[] = {
- SLEG_CONDVAR( _waiting_acceptance, SLE_UINT16, 0, 67),
- SLE_CONDVAR(GoodsEntry, acceptance, SLE_BOOL, 68, SL_MAX_VERSION),
- SLE_CONDNULL(2, 51, 67),
- SLE_VAR(GoodsEntry, days_since_pickup, SLE_UINT8),
- SLE_VAR(GoodsEntry, rating, SLE_UINT8),
- SLEG_CONDVAR( _cargo_source, SLE_FILE_U8 | SLE_VAR_U16, 0, 6),
- SLEG_CONDVAR( _cargo_source, SLE_UINT16, 7, 67),
- SLEG_CONDVAR( _cargo_source_xy, SLE_UINT32, 44, 67),
- SLEG_CONDVAR( _cargo_days, SLE_UINT8, 0, 67),
- SLE_VAR(GoodsEntry, last_speed, SLE_UINT8),
- SLE_VAR(GoodsEntry, last_age, SLE_UINT8),
- SLEG_CONDVAR( _cargo_feeder_share, SLE_FILE_U32 | SLE_VAR_I64, 14, 64),
- SLEG_CONDVAR( _cargo_feeder_share, SLE_INT64, 65, 67),
- SLE_CONDLST(GoodsEntry, cargo, REF_CARGO_PACKET, 68, SL_MAX_VERSION),
-
- SLE_END()
-};
-
static const SaveLoad _station_speclist_desc[] = {
SLE_CONDVAR(StationSpecList, grfid, SLE_UINT32, 27, SL_MAX_VERSION),
SLE_CONDVAR(StationSpecList, localidx, SLE_UINT8, 27, SL_MAX_VERSION),
@@ -3002,8 +2992,28 @@
};
-static void SaveLoad_STNS(Station *st)
+void SaveLoad_STNS(Station *st)
{
+ static const SaveLoad _goods_desc[] = {
+ SLEG_CONDVAR( _waiting_acceptance, SLE_UINT16, 0, 67),
+ SLE_CONDVAR(GoodsEntry, acceptance_pickup, SLE_UINT8, 68, SL_MAX_VERSION),
+ SLE_CONDNULL(2, 51, 67),
+ SLE_VAR(GoodsEntry, days_since_pickup, SLE_UINT8),
+ SLE_VAR(GoodsEntry, rating, SLE_UINT8),
+ SLEG_CONDVAR( _cargo_source, SLE_FILE_U8 | SLE_VAR_U16, 0, 6),
+ SLEG_CONDVAR( _cargo_source, SLE_UINT16, 7, 67),
+ SLEG_CONDVAR( _cargo_source_xy, SLE_UINT32, 44, 67),
+ SLEG_CONDVAR( _cargo_days, SLE_UINT8, 0, 67),
+ SLE_VAR(GoodsEntry, last_speed, SLE_UINT8),
+ SLE_VAR(GoodsEntry, last_age, SLE_UINT8),
+ SLEG_CONDVAR( _cargo_feeder_share, SLE_FILE_U32 | SLE_VAR_I64, 14, 64),
+ SLEG_CONDVAR( _cargo_feeder_share, SLE_INT64, 65, 67),
+ SLE_CONDLST(GoodsEntry, cargo.packets, REF_CARGO_PACKET, 68, SL_MAX_VERSION),
+
+ SLE_END()
+};
+
+
SlObject(st, _station_desc);
_waiting_acceptance = 0;
@@ -3013,7 +3023,7 @@
GoodsEntry *ge = &st->goods[i];
SlObject(ge, _goods_desc);
if (CheckSavegameVersion(68)) {
- ge->acceptance = HASBIT(_waiting_acceptance, 15);
+ SB(ge->acceptance_pickup, GoodsEntry::ACCEPTANCE, 1, HASBIT(_waiting_acceptance, 15));
if (GB(_waiting_acceptance, 0, 12) != 0) {
/* Don't construct the packet with station here, because that'll fail with old savegames */
CargoPacket *cp = new CargoPacket();
@@ -3025,9 +3035,8 @@
cp->source_xy = _cargo_source_xy;
cp->days_in_transit = _cargo_days;
cp->feeder_share = _cargo_feeder_share;
+ SB(ge->acceptance_pickup, GoodsEntry::PICKUP, 1, 1);
ge->cargo.Append(cp);
- } else {
- ge->days_since_pickup = 255;
}
}
}