diff options
-rw-r--r-- | src/newgrf_station.cpp | 2 | ||||
-rw-r--r-- | src/station_base.h | 9 | ||||
-rw-r--r-- | src/station_cmd.cpp | 6 | ||||
-rw-r--r-- | src/station_gui.cpp | 12 | ||||
-rw-r--r-- | src/vehicle.cpp | 2 |
5 files changed, 20 insertions, 11 deletions
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp index 717c866f5..d7dfe3845 100644 --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -423,7 +423,7 @@ uint32 Station::GetNewGRFVariable(const ResolverObject *object, byte variable, b switch (variable) { case 0x60: return min(ge->cargo.Count(), 4095); case 0x61: return ge->HasVehicleEverTriedLoading() ? ge->time_since_pickup : 0; - case 0x62: return HasBit(ge->acceptance_pickup, GoodsEntry::GES_PICKUP) ? ge->rating : 0xFFFFFFFF; + case 0x62: return ge->HasRating() ? ge->rating : 0xFFFFFFFF; case 0x63: return ge->cargo.DaysInTransit(); case 0x64: return ge->HasVehicleEverTriedLoading() ? ge->last_speed | (ge->last_age << 8) : 0xFF00; case 0x65: return GB(ge->acceptance_pickup, GoodsEntry::GES_ACCEPTANCE, 1) << 3; diff --git a/src/station_base.h b/src/station_base.h index 07d1d2294..322a7dc8e 100644 --- a/src/station_base.h +++ b/src/station_base.h @@ -114,6 +114,15 @@ struct GoodsEntry { * @return true if vehicle tried to load. */ bool HasVehicleEverTriedLoading() const { return this->last_speed != 0; } + + /** + * Does this cargo have a rating at this station? + * @return true if the cargo has a rating, i.e. pickup has been attempted. + */ + inline bool HasRating() const + { + return HasBit(this->acceptance_pickup, GES_PICKUP); + } }; /** All airport-related information. Only valid if tile != INVALID_TILE. */ diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 3a0275fad..67933160d 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -3215,12 +3215,12 @@ static void UpdateStationRating(Station *st) /* 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 (!HasBit(ge->acceptance_pickup, GoodsEntry::GES_PICKUP) && ge->rating < INITIAL_STATION_RATING) { + if (!ge->HasRating() && ge->rating < INITIAL_STATION_RATING) { ge->rating++; } /* Only change the rating if we are moving this cargo */ - if (HasBit(ge->acceptance_pickup, GoodsEntry::GES_PICKUP)) { + if (ge->HasRating()) { byte_inc_sat(&ge->time_since_pickup); bool skip = false; @@ -3411,7 +3411,7 @@ static uint UpdateStationWaiting(Station *st, CargoID type, uint amount, SourceT ge.cargo.Append(new CargoPacket(st->index, st->xy, amount, source_type, source_id)); - if (!HasBit(ge.acceptance_pickup, GoodsEntry::GES_PICKUP)) { + if (!ge.HasRating()) { InvalidateWindowData(WC_STATION_LIST, st->index); SetBit(ge.acceptance_pickup, GoodsEntry::GES_PICKUP); } diff --git a/src/station_gui.cpp b/src/station_gui.cpp index b25568866..98c5b3d22 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -178,7 +178,7 @@ protected: if (this->facilities & st->facilities) { // only stations with selected facilities int num_waiting_cargo = 0; for (CargoID j = 0; j < NUM_CARGO; j++) { - if (HasBit(st->goods[j].acceptance_pickup, GoodsEntry::GES_PICKUP)) { + if (st->goods[j].HasRating()) { num_waiting_cargo++; // count number of waiting cargo if (HasBit(this->cargo_filter, j)) { *this->stations.Append() = st; @@ -246,8 +246,8 @@ protected: CargoID j; FOR_EACH_SET_CARGO_ID(j, cargo_filter) { - if (HasBit((*a)->goods[j].acceptance_pickup, GoodsEntry::GES_PICKUP)) maxr1 = max(maxr1, (*a)->goods[j].rating); - if (HasBit((*b)->goods[j].acceptance_pickup, GoodsEntry::GES_PICKUP)) maxr2 = max(maxr2, (*b)->goods[j].rating); + if ((*a)->goods[j].HasRating()) maxr1 = max(maxr1, (*a)->goods[j].rating); + if ((*b)->goods[j].HasRating()) maxr2 = max(maxr2, (*b)->goods[j].rating); } return maxr1 - maxr2; @@ -261,8 +261,8 @@ protected: for (CargoID j = 0; j < NUM_CARGO; j++) { if (!HasBit(cargo_filter, j)) continue; - if (HasBit((*a)->goods[j].acceptance_pickup, GoodsEntry::GES_PICKUP)) minr1 = min(minr1, (*a)->goods[j].rating); - if (HasBit((*b)->goods[j].acceptance_pickup, GoodsEntry::GES_PICKUP)) minr2 = min(minr2, (*b)->goods[j].rating); + if ((*a)->goods[j].HasRating()) minr1 = min(minr1, (*a)->goods[j].rating); + if ((*b)->goods[j].HasRating()) minr2 = min(minr2, (*b)->goods[j].rating); } return -(minr1 - minr2); @@ -1081,7 +1081,7 @@ struct StationViewWindow : public Window { const CargoSpec *cs; FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) { const GoodsEntry *ge = &st->goods[cs->Index()]; - if (!HasBit(ge->acceptance_pickup, GoodsEntry::GES_PICKUP)) continue; + if (!ge->HasRating()) continue; SetDParam(0, cs->name); SetDParam(2, ToPercent8(ge->rating)); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index b15d3c608..caadbf49d 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1261,7 +1261,7 @@ uint8 CalcPercentVehicleFilled(const Vehicle *front, StringID *colour) if (v->cargo_cap != 0 && colour != NULL) { unloading += HasBit(v->vehicle_flags, VF_CARGO_UNLOADING) ? 1 : 0; loading |= !order_no_load && - (order_full_load || HasBit(st->goods[v->cargo_type].acceptance_pickup, GoodsEntry::GES_PICKUP)) && + (order_full_load || st->goods[v->cargo_type].HasRating()) && !HasBit(v->vehicle_flags, VF_LOADING_FINISHED) && !HasBit(v->vehicle_flags, VF_STOP_LOADING); cars++; } |