(svn r26580) -Codechange: s/GES_PICKUP/GES_RATING/ (it has nothing to do with actual pickup), s/acceptance_pickup/status/ (the enum isn't called GoodEntryStatus for a reason; it's not only acceptance and pickup anymore)

pull/155/head
rubidium 10 years ago
parent efa70e7a7c
commit fb9dbf30fa

@ -1068,9 +1068,9 @@ static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, Ti
/* Update station statistics */
if (accepted > 0) {
SetBit(st->goods[cargo_type].acceptance_pickup, GoodsEntry::GES_EVER_ACCEPTED);
SetBit(st->goods[cargo_type].acceptance_pickup, GoodsEntry::GES_CURRENT_MONTH);
SetBit(st->goods[cargo_type].acceptance_pickup, GoodsEntry::GES_ACCEPTED_BIGTICK);
SetBit(st->goods[cargo_type].status, GoodsEntry::GES_EVER_ACCEPTED);
SetBit(st->goods[cargo_type].status, GoodsEntry::GES_CURRENT_MONTH);
SetBit(st->goods[cargo_type].status, GoodsEntry::GES_ACCEPTED_BIGTICK);
}
/* Update company statistics */
@ -1242,7 +1242,7 @@ void PrepareUnload(Vehicle *front_v)
const GoodsEntry *ge = &st->goods[v->cargo_type];
if (v->cargo_cap > 0 && v->cargo.TotalCount() > 0) {
v->cargo.Stage(
HasBit(ge->acceptance_pickup, GoodsEntry::GES_ACCEPTANCE),
HasBit(ge->status, GoodsEntry::GES_ACCEPTANCE),
front_v->last_station_visited, next_station,
front_v->current_order.GetUnloadType(), ge,
front_v->cargo_payment);
@ -1533,7 +1533,7 @@ static void LoadUnloadVehicle(Vehicle *front)
payment->SetCargo(v->cargo_type);
if (!HasBit(ge->acceptance_pickup, GoodsEntry::GES_ACCEPTANCE) && v->cargo.ActionCount(VehicleCargoList::MTA_DELIVER) > 0) {
if (!HasBit(ge->status, GoodsEntry::GES_ACCEPTANCE) && v->cargo.ActionCount(VehicleCargoList::MTA_DELIVER) > 0) {
/* The station does not accept our goods anymore. */
if (front->current_order.GetUnloadType() & (OUFB_TRANSFER | OUFB_UNLOAD)) {
/* Transfer instead of delivering. */

@ -181,7 +181,7 @@ NodeID LinkGraph::AddNode(const Station *st)
max(new_node + 1U, this->edges.Height()));
this->nodes[new_node].Init(st->index,
HasBit(good.acceptance_pickup, GoodsEntry::GES_ACCEPTANCE));
HasBit(good.status, GoodsEntry::GES_ACCEPTANCE));
BaseEdge *new_edges = this->edges[new_node];

@ -380,10 +380,10 @@ static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseI
uint32 res = 0;
for (Station * const * st_iter = sl->Begin(); st_iter != sl->End(); st_iter++) {
const Station *st = *st_iter;
if (HasBit(st->goods[cid].acceptance_pickup, GoodsEntry::GES_EVER_ACCEPTED)) SetBit(res, 0);
if (HasBit(st->goods[cid].acceptance_pickup, GoodsEntry::GES_LAST_MONTH)) SetBit(res, 1);
if (HasBit(st->goods[cid].acceptance_pickup, GoodsEntry::GES_CURRENT_MONTH)) SetBit(res, 2);
if (HasBit(st->goods[cid].acceptance_pickup, GoodsEntry::GES_ACCEPTED_BIGTICK)) SetBit(res, 3);
if (HasBit(st->goods[cid].status, GoodsEntry::GES_EVER_ACCEPTED)) SetBit(res, 0);
if (HasBit(st->goods[cid].status, GoodsEntry::GES_LAST_MONTH)) SetBit(res, 1);
if (HasBit(st->goods[cid].status, GoodsEntry::GES_CURRENT_MONTH)) SetBit(res, 2);
if (HasBit(st->goods[cid].status, GoodsEntry::GES_ACCEPTED_BIGTICK)) SetBit(res, 3);
}
/* Cargo triggered CB 148? */

@ -396,7 +396,7 @@ uint32 Station::GetNewGRFVariable(const ResolverObject &object, byte variable, b
uint32 value = 0;
for (cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) {
if (HasBit(this->goods[cargo_type].acceptance_pickup, GoodsEntry::GES_ACCEPTANCE)) SetBit(value, cargo_type);
if (HasBit(this->goods[cargo_type].status, GoodsEntry::GES_ACCEPTANCE)) SetBit(value, cargo_type);
}
return value;
}
@ -428,12 +428,12 @@ uint32 Station::GetNewGRFVariable(const ResolverObject &object, byte variable, b
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;
case 0x65: return GB(ge->status, GoodsEntry::GES_ACCEPTANCE, 1) << 3;
case 0x69: {
assert_compile((int)GoodsEntry::GES_EVER_ACCEPTED + 1 == (int)GoodsEntry::GES_LAST_MONTH);
assert_compile((int)GoodsEntry::GES_EVER_ACCEPTED + 2 == (int)GoodsEntry::GES_CURRENT_MONTH);
assert_compile((int)GoodsEntry::GES_EVER_ACCEPTED + 3 == (int)GoodsEntry::GES_ACCEPTED_BIGTICK);
return GB(ge->acceptance_pickup, GoodsEntry::GES_EVER_ACCEPTED, 4);
return GB(ge->status, GoodsEntry::GES_EVER_ACCEPTED, 4);
}
}
}
@ -443,7 +443,7 @@ uint32 Station::GetNewGRFVariable(const ResolverObject &object, byte variable, b
const GoodsEntry *g = &this->goods[GB(variable - 0x8C, 3, 4)];
switch (GB(variable - 0x8C, 0, 3)) {
case 0: return g->cargo.TotalCount();
case 1: return GB(min(g->cargo.TotalCount(), 4095), 0, 4) | (GB(g->acceptance_pickup, GoodsEntry::GES_ACCEPTANCE, 1) << 7);
case 1: return GB(min(g->cargo.TotalCount(), 4095), 0, 4) | (GB(g->status, GoodsEntry::GES_ACCEPTANCE, 1) << 7);
case 2: return g->time_since_pickup;
case 3: return g->rating;
case 4: return g->cargo.Source();

@ -1599,7 +1599,7 @@ bool AfterLoadGame()
FOR_ALL_STATIONS(st) {
for (CargoID c = 0; c < NUM_CARGO; c++) {
st->goods[c].last_speed = 0;
if (st->goods[c].cargo.AvailableCount() != 0) SetBit(st->goods[c].acceptance_pickup, GoodsEntry::GES_PICKUP);
if (st->goods[c].cargo.AvailableCount() != 0) SetBit(st->goods[c].status, GoodsEntry::GES_RATING);
}
}
}

@ -710,8 +710,8 @@ static bool LoadOldGood(LoadgameState *ls, int num)
if (!LoadChunk(ls, ge, goods_chunk)) return false;
SB(ge->acceptance_pickup, GoodsEntry::GES_ACCEPTANCE, 1, HasBit(_waiting_acceptance, 15));
SB(ge->acceptance_pickup, GoodsEntry::GES_PICKUP, 1, _cargo_source != 0xFF);
SB(ge->status, GoodsEntry::GES_ACCEPTANCE, 1, HasBit(_waiting_acceptance, 15));
SB(ge->status, GoodsEntry::GES_RATING, 1, _cargo_source != 0xFF);
if (GB(_waiting_acceptance, 0, 12) != 0 && CargoPacket::CanAllocateItem()) {
ge->cargo.Append(new CargoPacket(GB(_waiting_acceptance, 0, 12), _cargo_days, (_cargo_source == 0xFF) ? INVALID_STATION : _cargo_source, 0, 0),
INVALID_STATION);

@ -267,7 +267,7 @@ const SaveLoad *GetGoodsDesc()
{
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_CONDVAR(GoodsEntry, status, SLE_UINT8, 68, SL_MAX_VERSION),
SLE_CONDNULL(2, 51, 67),
SLE_VAR(GoodsEntry, time_since_pickup, SLE_UINT8),
SLE_VAR(GoodsEntry, rating, SLE_UINT8),
@ -339,7 +339,7 @@ static void Load_STNS()
SlObject(ge, GetGoodsDesc());
SwapPackets(ge);
if (IsSavegameVersionBefore(68)) {
SB(ge->acceptance_pickup, GoodsEntry::GES_ACCEPTANCE, 1, HasBit(_waiting_acceptance, 15));
SB(ge->status, GoodsEntry::GES_ACCEPTANCE, 1, HasBit(_waiting_acceptance, 15));
if (GB(_waiting_acceptance, 0, 12) != 0) {
/* In old versions, enroute_from used 0xFF as INVALID_STATION */
StationID source = (IsSavegameVersionBefore(7) && _cargo_source == 0xFF) ? INVALID_STATION : _cargo_source;
@ -353,7 +353,7 @@ static void Load_STNS()
/* Don't construct the packet with station here, because that'll fail with old savegames */
CargoPacket *cp = new CargoPacket(GB(_waiting_acceptance, 0, 12), _cargo_days, source, _cargo_source_xy, _cargo_source_xy, _cargo_feeder_share);
ge->cargo.Append(cp, INVALID_STATION);
SB(ge->acceptance_pickup, GoodsEntry::GES_PICKUP, 1, 1);
SB(ge->status, GoodsEntry::GES_RATING, 1, 1);
}
}
}

@ -59,6 +59,6 @@ ScriptCargoList_StationAccepting::ScriptCargoList_StationAccepting(StationID sta
Station *st = ::Station::Get(station_id);
for (CargoID i = 0; i < NUM_CARGO; i++) {
if (HasBit(st->goods[i].acceptance_pickup, GoodsEntry::GES_ACCEPTANCE)) this->AddItem(i);
if (HasBit(st->goods[i].status, GoodsEntry::GES_ACCEPTANCE)) this->AddItem(i);
}
}

@ -175,7 +175,7 @@ struct GoodsEntry {
* This also indicates, whether a cargo has a rating at the station.
* This flag is never cleared.
*/
GES_PICKUP,
GES_RATING,
/**
* Set when a vehicle ever delivered cargo to the station for final delivery.
@ -203,7 +203,7 @@ struct GoodsEntry {
};
GoodsEntry() :
acceptance_pickup(0),
status(0),
time_since_pickup(255),
rating(INITIAL_STATION_RATING),
last_speed(0),
@ -214,7 +214,7 @@ struct GoodsEntry {
max_waiting_cargo(0)
{}
byte acceptance_pickup; ///< Status of this cargo, see #GoodsEntryStatus.
byte status; ///< Status of this cargo, see #GoodsEntryStatus.
/**
* Number of rating-intervals (up to 255) since the last vehicle tried to load this cargo.
@ -252,18 +252,18 @@ struct GoodsEntry {
/**
* Reports whether a vehicle has ever tried to load the cargo at this station.
* This does not imply that there was cargo available for loading. Refer to GES_PICKUP for that.
* This does not imply that there was cargo available for loading. Refer to GES_RATING for that.
* @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.
* @return true if the cargo has a rating, i.e. cargo has been moved to the station.
*/
inline bool HasRating() const
{
return HasBit(this->acceptance_pickup, GES_PICKUP);
return HasBit(this->status, GES_RATING);
}
uint GetSumFlowVia(StationID via) const;

@ -438,7 +438,7 @@ static uint GetAcceptanceMask(const Station *st)
uint mask = 0;
for (CargoID i = 0; i < NUM_CARGO; i++) {
if (HasBit(st->goods[i].acceptance_pickup, GoodsEntry::GES_ACCEPTANCE)) mask |= 1 << i;
if (HasBit(st->goods[i].status, GoodsEntry::GES_ACCEPTANCE)) mask |= 1 << i;
}
return mask;
}
@ -581,7 +581,7 @@ void UpdateStationAcceptance(Station *st, bool show_msg)
}
GoodsEntry &ge = st->goods[i];
SB(ge.acceptance_pickup, GoodsEntry::GES_ACCEPTANCE, 1, amt >= 8);
SB(ge.status, GoodsEntry::GES_ACCEPTANCE, 1, amt >= 8);
if (LinkGraph::IsValidID(ge.link_graph)) {
(*LinkGraph::Get(ge.link_graph))[ge.node].SetDemand(amt / 8);
}
@ -3191,7 +3191,7 @@ void TriggerWatchedCargoCallbacks(Station *st)
/* Collect cargoes accepted since the last big tick. */
uint cargoes = 0;
for (CargoID cid = 0; cid < NUM_CARGO; cid++) {
if (HasBit(st->goods[cid].acceptance_pickup, GoodsEntry::GES_ACCEPTED_BIGTICK)) SetBit(cargoes, cid);
if (HasBit(st->goods[cid].status, GoodsEntry::GES_ACCEPTED_BIGTICK)) SetBit(cargoes, cid);
}
/* Anything to do? */
@ -3224,7 +3224,7 @@ static bool StationHandleBigTick(BaseStation *st)
TriggerWatchedCargoCallbacks(Station::From(st));
for (CargoID i = 0; i < NUM_CARGO; i++) {
ClrBit(Station::From(st)->goods[i].acceptance_pickup, GoodsEntry::GES_ACCEPTED_BIGTICK);
ClrBit(Station::From(st)->goods[i].status, GoodsEntry::GES_ACCEPTED_BIGTICK);
}
}
@ -3621,8 +3621,8 @@ void StationMonthlyLoop()
FOR_ALL_STATIONS(st) {
for (CargoID i = 0; i < NUM_CARGO; i++) {
GoodsEntry *ge = &st->goods[i];
SB(ge->acceptance_pickup, GoodsEntry::GES_LAST_MONTH, 1, GB(ge->acceptance_pickup, GoodsEntry::GES_CURRENT_MONTH, 1));
ClrBit(ge->acceptance_pickup, GoodsEntry::GES_CURRENT_MONTH);
SB(ge->status, GoodsEntry::GES_LAST_MONTH, 1, GB(ge->status, GoodsEntry::GES_CURRENT_MONTH, 1));
ClrBit(ge->status, GoodsEntry::GES_CURRENT_MONTH);
}
}
}
@ -3638,7 +3638,7 @@ void ModifyStationRatingAround(TileIndex tile, Owner owner, int amount, uint rad
for (CargoID i = 0; i < NUM_CARGO; i++) {
GoodsEntry *ge = &st->goods[i];
if (ge->acceptance_pickup != 0) {
if (ge->status != 0) {
ge->rating = Clamp(ge->rating + amount, 0, 255);
}
}
@ -3679,7 +3679,7 @@ static uint UpdateStationWaiting(Station *st, CargoID type, uint amount, SourceT
if (!ge.HasRating()) {
InvalidateWindowData(WC_STATION_LIST, st->index);
SetBit(ge.acceptance_pickup, GoodsEntry::GES_PICKUP);
SetBit(ge.status, GoodsEntry::GES_RATING);
}
TriggerStationRandomisation(st, st->xy, SRT_NEW_CARGO, type);

@ -1798,7 +1798,7 @@ struct StationViewWindow : public Window {
uint32 cargo_mask = 0;
for (CargoID i = 0; i < NUM_CARGO; i++) {
if (HasBit(st->goods[i].acceptance_pickup, GoodsEntry::GES_ACCEPTANCE)) SetBit(cargo_mask, i);
if (HasBit(st->goods[i].status, GoodsEntry::GES_ACCEPTANCE)) SetBit(cargo_mask, i);
}
SetDParam(0, cargo_mask);
int bottom = DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, INT32_MAX, STR_STATION_VIEW_ACCEPTS_CARGO);

Loading…
Cancel
Save