|
@@ -1947,55 +1947,55 @@ int WhoCanServiceIndustry(Industry* ind)
|
|
|
/* Is it worthwhile to try this vehicle? */
|
|
|
if (v->owner != _local_player && result != 0) continue;
|
|
|
|
|
|
/* Check whether it accepts the right kind of cargo */
|
|
|
bool c_accepts = false;
|
|
|
bool c_produces = false;
|
|
|
if (v->type == VEH_TRAIN && IsFrontEngine(v)) {
|
|
|
const Vehicle *u = v;
|
|
|
BEGIN_ENUM_WAGONS(u)
|
|
|
CanCargoServiceIndustry(u->cargo_type, ind, &c_accepts, &c_produces);
|
|
|
END_ENUM_WAGONS(u)
|
|
|
} else if (v->type == VEH_ROAD || v->type == VEH_SHIP || v->type == VEH_AIRCRAFT) {
|
|
|
CanCargoServiceIndustry(v->cargo_type, ind, &c_accepts, &c_produces);
|
|
|
} else {
|
|
|
continue;
|
|
|
}
|
|
|
if (!c_accepts && !c_produces) continue; // Wrong cargo
|
|
|
|
|
|
/* Check orders of the vehicle.
|
|
|
* We cannot check the first of shared orders only, since the first vehicle in such a chain
|
|
|
* may have a different cargo type.
|
|
|
*/
|
|
|
const Order *o;
|
|
|
FOR_VEHICLE_ORDERS(v, o) {
|
|
|
if (o->IsType(OT_GOTO_STATION) && !HasBit(o->GetUnloadType(), OF_TRANSFER)) {
|
|
|
if (o->IsType(OT_GOTO_STATION) && !(o->GetUnloadType() & OUFB_TRANSFER)) {
|
|
|
/* Vehicle visits a station to load or unload */
|
|
|
Station *st = GetStation(o->GetDestination());
|
|
|
if (!st->IsValid()) continue;
|
|
|
|
|
|
/* Same cargo produced by industry is dropped here => not serviced by vehicle v */
|
|
|
if (HasBit(o->GetUnloadType(), OF_UNLOAD) && !c_accepts) break;
|
|
|
if ((o->GetUnloadType() & OUFB_UNLOAD) && !c_accepts) break;
|
|
|
|
|
|
if (stations.find(st) != stations.end()) {
|
|
|
if (v->owner == _local_player) return 2; // Player services industry
|
|
|
result = 1; // Competitor services industry
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Report news that industry production has changed significantly
|
|
|
*
|
|
|
* @param ind: Industry with changed production
|
|
|
* @param type: Cargo type that has changed
|
|
|
* @param percent: Percentage of change (>0 means increase, <0 means decrease)
|
|
|
*/
|
|
|
static void ReportNewsProductionChangeIndustry(Industry *ind, CargoID type, int percent)
|
|
|
{
|
|
|
NewsType nt;
|
|
|
|
|
|
switch (WhoCanServiceIndustry(ind)) {
|
|
|
case 0: nt = NT_INDUSTRY_NOBODY; break;
|