Changeset - r23343:afd1a49ccadc
[Not reviewed]
master
0 2 0
SamuXarick - 6 years ago 2019-02-21 21:23:37
43006711+SamuXarick@users.noreply.github.com
Change: Owner of vehicle with exclusive transport rights may now load cargo from neutral stations (#7256)
2 files changed with 14 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/economy.cpp
Show inline comments
 
@@ -1515,22 +1515,33 @@ static void HandleStationRefit(Vehicle *
 
	IterateVehicleParts(v_start, FinalizeRefitAction(consist_capleft, st, next_station,
 
			is_auto_refit || (v->First()->current_order.GetLoadType() & OLFB_FULL_LOAD) != 0));
 

	
 
	cur_company.Restore();
 
}
 

	
 
/**
 
 * Test whether a vehicle can load cargo at a station even if exclusive transport rights are present.
 
 * @param st Station with cargo waiting to be loaded.
 
 * @param v Vehicle loading the cargo.
 
 * @return true when a vehicle can load the cargo.
 
 */
 
static bool MayLoadUnderExclusiveRights(const Station *st, const Vehicle *v)
 
{
 
	return st->owner != OWNER_NONE || st->town->exclusive_counter == 0 || st->town->exclusivity == v->owner;
 
}
 

	
 
struct ReserveCargoAction {
 
	Station *st;
 
	StationIDStack *next_station;
 

	
 
	ReserveCargoAction(Station *st, StationIDStack *next_station) :
 
		st(st), next_station(next_station) {}
 

	
 
	bool operator()(Vehicle *v)
 
	{
 
		if (v->cargo_cap > v->cargo.RemainingCount()) {
 
		if (v->cargo_cap > v->cargo.RemainingCount() && MayLoadUnderExclusiveRights(st, v)) {
 
			st->goods[v->cargo_type].cargo.Reserve(v->cargo_cap - v->cargo.RemainingCount(),
 
					&v->cargo, st->xy, *next_station);
 
		}
 

	
 
		return true;
 
	}
 
@@ -1748,13 +1759,13 @@ static void LoadUnloadVehicle(Vehicle *f
 
		ge->time_since_pickup = 0;
 

	
 
		assert(v->cargo_cap >= v->cargo.StoredCount());
 
		/* If there's goods waiting at the station, and the vehicle
 
		 * has capacity for it, load it on the vehicle. */
 
		uint cap_left = v->cargo_cap - v->cargo.StoredCount();
 
		if (cap_left > 0 && (v->cargo.ActionCount(VehicleCargoList::MTA_LOAD) > 0 || ge->cargo.AvailableCount() > 0)) {
 
		if (cap_left > 0 && (v->cargo.ActionCount(VehicleCargoList::MTA_LOAD) > 0 || ge->cargo.AvailableCount() > 0) && MayLoadUnderExclusiveRights(st, v)) {
 
			if (v->cargo.StoredCount() == 0) TriggerVehicle(v, VEHICLE_TRIGGER_NEW_CARGO);
 
			if (_settings_game.order.gradual_loading) cap_left = min(cap_left, GetLoadAmount(v));
 

	
 
			uint loaded = ge->cargo.Load(cap_left, &v->cargo, st->xy, next_station);
 
			if (v->cargo.ActionCount(VehicleCargoList::MTA_LOAD) > 0) {
 
				/* Remember if there are reservations left so that we don't stop
src/station_cmd.cpp
Show inline comments
 
@@ -3850,13 +3850,13 @@ uint MoveGoodsToStation(CargoID type, ui
 
	uint best_rating2 = 0; // rating of st2
 

	
 
	for (Station * const *st_iter = all_stations->Begin(); st_iter != all_stations->End(); ++st_iter) {
 
		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 (st->owner != OWNER_NONE && 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
 

	
 
		if (_settings_game.order.selectgoods && !st->goods[type].HasVehicleEverTriedLoading()) continue; // Selectively servicing stations, and not this one
 

	
 
		if (IsCargoInClass(type, CC_PASSENGERS)) {
0 comments (0 inline, 0 general)