Changeset - r21471:ce169ca93e3c
[Not reviewed]
master
0 11 0
rubidium - 10 years ago 2014-05-11 18:02:11
rubidium@openttd.org
(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)
11 files changed with 36 insertions and 36 deletions:
0 comments (0 inline, 0 general)
src/economy.cpp
Show inline comments
 
@@ -1059,27 +1059,27 @@ static Money DeliverGoods(int num_pieces
 
	assert(num_pieces > 0);
 

	
 
	Station *st = Station::Get(dest);
 

	
 
	/* Give the goods to the industry. */
 
	uint accepted = DeliverGoodsToIndustry(st, cargo_type, num_pieces, src_type == ST_INDUSTRY ? src : INVALID_INDUSTRY);
 

	
 
	/* If this cargo type is always accepted, accept all */
 
	if (HasBit(st->always_accepted, cargo_type)) accepted = num_pieces;
 

	
 
	/* 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 */
 
	company->cur_economy.delivered_cargo[cargo_type] += accepted;
 

	
 
	/* Increase town's counter for town effects */
 
	const CargoSpec *cs = CargoSpec::Get(cargo_type);
 
	st->town->received[cs->town_effect].new_act += accepted;
 

	
 
	/* Determine profit */
 
	Money profit = GetTransportedGoodsIncome(accepted, DistanceManhattan(source_tile, st->xy), days_in_transit, cargo_type);
 

	
 
@@ -1233,25 +1233,25 @@ void PrepareUnload(Vehicle *front_v)
 
	 * limit in number of CargoPayments. Can't go wrong. */
 
	assert_compile(CargoPaymentPool::MAX_SIZE == VehiclePool::MAX_SIZE);
 
	assert(CargoPayment::CanAllocateItem());
 
	front_v->cargo_payment = new CargoPayment(front_v);
 

	
 
	StationIDStack next_station = front_v->GetNextStoppingStation();
 
	if (front_v->orders.list == NULL || (front_v->current_order.GetUnloadType() & OUFB_NO_UNLOAD) == 0) {
 
		Station *st = Station::Get(front_v->last_station_visited);
 
		for (Vehicle *v = front_v; v != NULL; v = v->Next()) {
 
			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);
 
				if (v->cargo.UnloadCount() > 0) SetBit(v->vehicle_flags, VF_CARGO_UNLOADING);
 
			}
 
		}
 
	}
 
}
 

	
 
/**
 
 * Gets the amount of cargo the given vehicle can load in the current tick.
 
 * This is only about loading speed. The free capacity is ignored.
 
@@ -1524,25 +1524,25 @@ static void LoadUnloadVehicle(Vehicle *f
 

	
 
		uint load_amount = GetLoadAmount(v);
 

	
 
		GoodsEntry *ge = &st->goods[v->cargo_type];
 

	
 
		if (HasBit(v->vehicle_flags, VF_CARGO_UNLOADING) && (front->current_order.GetUnloadType() & OUFB_NO_UNLOAD) == 0) {
 
			uint cargo_count = v->cargo.UnloadCount();
 
			uint amount_unloaded = _settings_game.order.gradual_loading ? min(cargo_count, load_amount) : cargo_count;
 
			bool remaining = false; // Are there cargo entities in this vehicle that can still be unloaded here?
 

	
 
			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. */
 
					v->cargo.Reassign<VehicleCargoList::MTA_DELIVER, VehicleCargoList::MTA_TRANSFER>(
 
							v->cargo.ActionCount(VehicleCargoList::MTA_DELIVER), INVALID_STATION);
 
				} else {
 
					uint new_remaining = v->cargo.RemainingCount() + v->cargo.ActionCount(VehicleCargoList::MTA_DELIVER);
 
					if (v->cargo_cap < new_remaining) {
 
						/* Return some of the reserved cargo to not overload the vehicle. */
 
						v->cargo.Return(new_remaining - v->cargo_cap, &ge->cargo, INVALID_STATION);
 
					}
 

	
src/linkgraph/linkgraph.cpp
Show inline comments
 
@@ -172,25 +172,25 @@ void LinkGraph::UpdateDistances(NodeID i
 
NodeID LinkGraph::AddNode(const Station *st)
 
{
 
	const GoodsEntry &good = st->goods[this->cargo];
 

	
 
	NodeID new_node = this->Size();
 
	this->nodes.Append();
 
	/* Avoid reducing the height of the matrix as that is expensive and we
 
	 * most likely will increase it again later which is again expensive. */
 
	this->edges.Resize(new_node + 1U,
 
			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];
 

	
 
	/* Reset the first edge starting at the new node */
 
	new_edges[new_node].next_edge = INVALID_NODE;
 

	
 
	for (NodeID i = 0; i <= new_node; ++i) {
 
		uint distance = DistanceMaxPlusManhattan(st->xy, Station::Get(this->nodes[i].station)->xy);
 
		new_edges[i].Init(distance);
 
		this->edges[i][new_node].Init(distance);
 
	}
 
	return new_node;
src/newgrf_house.cpp
Show inline comments
 
@@ -371,28 +371,28 @@ static uint32 GetDistanceFromNearbyHouse
 
			/* Extract tile offset. */
 
			int8 x_offs = GB(GetRegister(0x100), 0, 8);
 
			int8 y_offs = GB(GetRegister(0x100), 8, 8);
 
			TileIndex testtile = TILE_MASK(this->tile + TileDiffXY(x_offs, y_offs));
 

	
 
			StationFinder stations(TileArea(testtile, 1, 1));
 
			const StationList *sl = stations.GetStations();
 

	
 
			/* Collect acceptance stats. */
 
			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? */
 
			if (HasBit(this->watched_cargo_triggers, cid)) SetBit(res, 4);
 

	
 
			return res;
 
		}
 

	
 
		/* Distance test for some house types */
 
		case 0x65: return GetDistanceFromNearbyHouse(parameter, this->tile, this->house_id);
 

	
 
		/* Class and ID of nearby house tile */
src/newgrf_station.cpp
Show inline comments
 
@@ -387,25 +387,25 @@ TownScopeResolver *StationResolverObject
 

	
 
	return this->st->GetNewGRFVariable(this->ro, variable, parameter, available);
 
}
 

	
 
uint32 Station::GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const
 
{
 
	switch (variable) {
 
		case 0x48: { // Accepted cargo types
 
			CargoID cargo_type;
 
			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;
 
		}
 

	
 
		case 0x8A: return this->had_vehicle_of_type;
 
		case 0xF1: return (this->airport.tile != INVALID_TILE) ? this->airport.GetSpec()->ttd_airport_type : ATP_TTDP_LARGE;
 
		case 0xF2: return (this->truck_stops != NULL) ? this->truck_stops->status : 0;
 
		case 0xF3: return (this->bus_stops != NULL)   ? this->bus_stops->status   : 0;
 
		case 0xF6: return this->airport.flags;
 
		case 0xF7: return GB(this->airport.flags, 8, 8);
 
	}
 

	
 
@@ -419,40 +419,40 @@ uint32 Station::GetNewGRFVariable(const 
 
				case 0x64: return 0xFF00;
 
				default:   return 0;
 
			}
 
		}
 
		const GoodsEntry *ge = &this->goods[c];
 

	
 
		switch (variable) {
 
			case 0x60: return min(ge->cargo.TotalCount(), 4095);
 
			case 0x61: return ge->HasVehicleEverTriedLoading() ? ge->time_since_pickup : 0;
 
			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);
 
			}
 
		}
 
	}
 

	
 
	/* Handle cargo variables (deprecated) */
 
	if (variable >= 0x8C && variable <= 0xEC) {
 
		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();
 
			case 5: return g->cargo.DaysInTransit();
 
			case 6: return g->last_speed;
 
			case 7: return g->last_age;
 
		}
 
	}
 

	
 
	DEBUG(grf, 1, "Unhandled station variable 0x%X", variable);
 

	
 
	*available = false;
src/saveload/afterload.cpp
Show inline comments
 
@@ -1590,25 +1590,25 @@ bool AfterLoadGame()
 
		for (TileIndex t = 0; t < map_size; t++) {
 
			if (IsShipDepotTile(t)) {
 
				_m[t].m4 = (TileHeight(t) == 0) ? OWNER_WATER : OWNER_NONE;
 
			}
 
		}
 
	}
 

	
 
	if (IsSavegameVersionBefore(74)) {
 
		Station *st;
 
		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);
 
			}
 
		}
 
	}
 

	
 
	if (IsSavegameVersionBefore(78)) {
 
		Industry *i;
 
		uint j;
 
		FOR_ALL_INDUSTRIES(i) {
 
			const IndustrySpec *indsp = GetIndustrySpec(i->type);
 
			for (j = 0; j < lengthof(i->produced_cargo); j++) {
 
				i->produced_cargo[j] = indsp->produced_cargo[j];
 
			}
src/saveload/oldloader_sl.cpp
Show inline comments
 
@@ -701,26 +701,26 @@ static const OldChunks goods_chunk[] = {
 
};
 

	
 
static bool LoadOldGood(LoadgameState *ls, int num)
 
{
 
	/* for TTO games, 12th (num == 11) goods entry is created in the Station constructor */
 
	if (_savegame_type == SGT_TTO && num == 11) return true;
 

	
 
	Station *st = Station::Get(_current_station_id);
 
	GoodsEntry *ge = &st->goods[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);
 
	}
 

	
 
	return true;
 
}
 

	
 
static const OldChunks station_chunk[] = {
 
	OCL_SVAR(   OC_TILE, Station, xy ),
 
	OCL_VAR ( OC_UINT32,   1, &_old_town_index ),
 

	
src/saveload/station_sl.cpp
Show inline comments
 
@@ -258,25 +258,25 @@ static const SaveLoad _flow_desc[] = {
 
	    SLE_END()
 
};
 

	
 
/**
 
 * Wrapper function to get the GoodsEntry's internal structure while
 
 * some of the variables itself are private.
 
 * @return the saveload description for GoodsEntry.
 
 */
 
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),
 
		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_CONDVAR(GoodsEntry, amount_fract,         SLE_UINT8,                 150, SL_MAX_VERSION),
 
@@ -330,39 +330,39 @@ static void Load_STNS()
 
		Station *st = new (index) Station();
 

	
 
		SlObject(st, _old_station_desc);
 

	
 
		_waiting_acceptance = 0;
 

	
 
		uint num_cargo = IsSavegameVersionBefore(55) ? 12 : NUM_CARGO;
 
		for (CargoID i = 0; i < num_cargo; i++) {
 
			GoodsEntry *ge = &st->goods[i];
 
			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;
 

	
 
					/* Make sure we can allocate the CargoPacket. This is safe
 
					 * as there can only be ~64k stations and 32 cargoes in these
 
					 * savegame versions. As the CargoPacketPool has more than
 
					 * 16 million entries; it fits by an order of magnitude. */
 
					assert(CargoPacket::CanAllocateItem());
 

	
 
					/* 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);
 
				}
 
			}
 
		}
 

	
 
		if (st->num_specs != 0) {
 
			/* Allocate speclist memory when loading a game */
 
			st->speclist = CallocT<StationSpecList>(st->num_specs);
 
			for (uint i = 0; i < st->num_specs; i++) {
 
				SlObject(&st->speclist[i], _station_speclist_desc);
 
			}
 
		}
 
	}
src/script/api/script_cargolist.cpp
Show inline comments
 
@@ -50,15 +50,15 @@ ScriptCargoList_IndustryProducing::Scrip
 
		if (cargo_id != CT_INVALID) {
 
			this->AddItem(cargo_id);
 
		}
 
	}
 
}
 

	
 
ScriptCargoList_StationAccepting::ScriptCargoList_StationAccepting(StationID station_id)
 
{
 
	if (!ScriptStation::IsValidStation(station_id)) return;
 

	
 
	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);
 
	}
 
}
src/station_base.h
Show inline comments
 
@@ -166,25 +166,25 @@ struct GoodsEntry {
 
		 * Set when the station accepts the cargo currently for final deliveries.
 
		 * It is updated every STATION_ACCEPTANCE_TICKS ticks by checking surrounding tiles for acceptance >= 8/8.
 
		 */
 
		GES_ACCEPTANCE,
 

	
 
		/**
 
		 * Set when the cargo was ever waiting at the station.
 
		 * It is set when cargo supplied by surrounding tiles is moved to the station, or when
 
		 * arriving vehicles unload/transfer cargo without it being a final delivery.
 
		 * 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.
 
		 * This flag is never cleared.
 
		 */
 
		GES_EVER_ACCEPTED,
 

	
 
		/**
 
		 * Set when cargo was delivered for final delivery last month.
 
		 * This flag is set to the value of GES_CURRENT_MONTH at the start of each month.
 
		 */
 
		GES_LAST_MONTH,
 
@@ -194,36 +194,36 @@ struct GoodsEntry {
 
		 * This flag is reset on the beginning of every month.
 
		 */
 
		GES_CURRENT_MONTH,
 

	
 
		/**
 
		 * Set when cargo was delivered for final delivery during the current STATION_ACCEPTANCE_TICKS interval.
 
		 * This flag is reset every STATION_ACCEPTANCE_TICKS ticks.
 
		 */
 
		GES_ACCEPTED_BIGTICK,
 
	};
 

	
 
	GoodsEntry() :
 
		acceptance_pickup(0),
 
		status(0),
 
		time_since_pickup(255),
 
		rating(INITIAL_STATION_RATING),
 
		last_speed(0),
 
		last_age(255),
 
		amount_fract(0),
 
		link_graph(INVALID_LINK_GRAPH),
 
		node(INVALID_NODE),
 
		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.
 
	 * The unit used is STATION_RATING_TICKS.
 
	 * This does not imply there was any cargo to load.
 
	 */
 
	byte time_since_pickup;
 

	
 
	byte rating;            ///< %Station rating for this cargo.
 

	
 
	/**
 
	 * Maximum speed (up to 255) of the last vehicle that tried to load this cargo.
 
@@ -243,36 +243,36 @@ struct GoodsEntry {
 
	byte last_age;
 

	
 
	byte amount_fract;      ///< Fractional part of the amount in the cargo list
 
	StationCargoList cargo; ///< The cargo packets of cargo waiting in this station
 

	
 
	LinkGraphID link_graph; ///< Link graph this station belongs to.
 
	NodeID node;            ///< ID of node in link graph referring to this goods entry.
 
	FlowStatMap flows;      ///< Planned flows through this station.
 
	uint max_waiting_cargo; ///< Max cargo from this station waiting at any station.
 

	
 
	/**
 
	 * 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;
 

	
 
	/**
 
	 * Get the best next hop for a cargo packet from station source.
 
	 * @param source Source of the packet.
 
	 * @return The chosen next hop or INVALID_STATION if none was found.
 
	 */
 
	inline StationID GetVia(StationID source) const
 
	{
 
		FlowStatMap::const_iterator flow_it(this->flows.find(source));
src/station_cmd.cpp
Show inline comments
 
@@ -429,25 +429,25 @@ void UpdateAllStationVirtCoords()
 
}
 

	
 
/**
 
 * Get a mask of the cargo types that the station accepts.
 
 * @param st Station to query
 
 * @return the expected mask
 
 */
 
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;
 
}
 

	
 
/**
 
 * Items contains the two cargo names that are to be accepted or rejected.
 
 * msg is the string id of the message to display.
 
 */
 
static void ShowRejectOrAcceptNews(const Station *st, uint num_items, CargoID *cargo, StringID msg)
 
{
 
	for (uint i = 0; i < num_items; i++) {
 
		SetDParam(i + 1, CargoSpec::Get(cargo[i])->name);
 
@@ -572,25 +572,25 @@ void UpdateStationAcceptance(Station *st
 
	/* Adjust in case our station only accepts fewer kinds of goods */
 
	for (CargoID i = 0; i < NUM_CARGO; i++) {
 
		uint amt = acceptance[i];
 

	
 
		/* Make sure the station can accept the goods type. */
 
		bool is_passengers = IsCargoInClass(i, CC_PASSENGERS);
 
		if ((!is_passengers && !(st->facilities & ~FACIL_BUS_STOP)) ||
 
				(is_passengers && !(st->facilities & ~FACIL_TRUCK_STOP))) {
 
			amt = 0;
 
		}
 

	
 
		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);
 
		}
 
	}
 

	
 
	/* Only show a message in case the acceptance was actually changed. */
 
	uint new_acc = GetAcceptanceMask(st);
 
	if (old_acc == new_acc) return;
 

	
 
	/* show a message to report that the acceptance was changed? */
 
	if (show_msg && st->owner == _local_company && st->IsInUse()) {
 
		/* List of accept and reject strings for different number of
 
@@ -3182,25 +3182,25 @@ static VehicleEnterTileStatus VehicleEnt
 
	return VETSB_CONTINUE;
 
}
 

	
 
/**
 
 * Run the watched cargo callback for all houses in the catchment area.
 
 * @param st Station.
 
 */
 
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? */
 
	if (cargoes == 0) return;
 

	
 
	/* Loop over all houses in the catchment. */
 
	Rect r = st->GetCatchmentRect();
 
	TileArea ta(TileXY(r.left, r.top), TileXY(r.right, r.bottom));
 
	TILE_AREA_LOOP(tile, ta) {
 
		if (IsTileType(tile, MP_HOUSE)) {
 
			WatchedCargoCallback(tile, cargoes);
 
		}
 
@@ -3215,25 +3215,25 @@ void TriggerWatchedCargoCallbacks(Statio
 
 */
 
static bool StationHandleBigTick(BaseStation *st)
 
{
 
	if (!st->IsInUse()) {
 
		if (++st->delete_ctr >= 8) delete st;
 
		return false;
 
	}
 

	
 
	if (Station::IsExpected(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);
 
		}
 
	}
 

	
 

	
 
	if ((st->facilities & FACIL_WAYPOINT) == 0) UpdateStationAcceptance(Station::From(st), true);
 

	
 
	return true;
 
}
 

	
 
static inline void byte_inc_sat(byte *p)
 
{
 
	byte b = *p + 1;
 
@@ -3612,42 +3612,42 @@ void OnTick_Station()
 
		}
 
	}
 
}
 

	
 
/** Monthly loop for stations. */
 
void StationMonthlyLoop()
 
{
 
	Station *st;
 

	
 
	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);
 
		}
 
	}
 
}
 

	
 

	
 
void ModifyStationRatingAround(TileIndex tile, Owner owner, int amount, uint radius)
 
{
 
	Station *st;
 

	
 
	FOR_ALL_STATIONS(st) {
 
		if (st->owner == owner &&
 
				DistanceManhattan(tile, st->xy) <= radius) {
 
			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);
 
				}
 
			}
 
		}
 
	}
 
}
 

	
 
static uint UpdateStationWaiting(Station *st, CargoID type, uint amount, SourceType source_type, SourceID source_id)
 
{
 
	/* We can't allocate a CargoPacket? Then don't do anything
 
	 * at all; i.e. just discard the incoming cargo. */
 
	if (!CargoPacket::CanAllocateItem()) return 0;
 
@@ -3670,25 +3670,25 @@ static uint UpdateStationWaiting(Station
 
			ge.link_graph = lg->index;
 
			ge.node = lg->AddNode(st);
 
		} else {
 
			DEBUG(misc, 0, "Can't allocate link graph");
 
		}
 
	} else {
 
		lg = LinkGraph::Get(ge.link_graph);
 
	}
 
	if (lg != NULL) (*lg)[ge.node].UpdateSupply(amount);
 

	
 
	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);
 
	TriggerStationAnimation(st, st->xy, SAT_NEW_CARGO, type);
 
	AirportAnimationTrigger(st, AAT_STATION_NEW_CARGO, type);
 

	
 
	SetWindowDirty(WC_STATION_VIEW, st->index);
 
	st->MarkTilesDirty(true);
 
	return amount;
 
}
 

	
 
static bool IsUniqueStationName(const char *name)
src/station_gui.cpp
Show inline comments
 
@@ -1789,25 +1789,25 @@ struct StationViewWindow : public Window
 

	
 
	/**
 
	 * Draw accepted cargo in the #WID_SV_ACCEPT_RATING_LIST widget.
 
	 * @param r Rectangle of the widget.
 
	 * @return Number of lines needed for drawing the accepted cargo.
 
	 */
 
	int DrawAcceptedCargo(const Rect &r) const
 
	{
 
		const Station *st = Station::Get(this->window_number);
 

	
 
		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);
 
		return CeilDiv(bottom - r.top - WD_FRAMERECT_TOP, FONT_HEIGHT_NORMAL);
 
	}
 

	
 
	/**
 
	 * Draw cargo ratings in the #WID_SV_ACCEPT_RATING_LIST widget.
 
	 * @param r Rectangle of the widget.
 
	 * @return Number of lines needed for drawing the cargo ratings.
 
	 */
 
	int DrawCargoRatings(const Rect &r) const
0 comments (0 inline, 0 general)