mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 15:41:15 +00:00
(svn r6738) - Fix (r2441): Only apply the virtual transfer profit if the order is a transfer order, rather than to any unload order. This fixes an issue where the AI doesn't know that a route is unprofitable.
This commit is contained in:
parent
75fe56eff0
commit
1926d97888
@ -1302,7 +1302,7 @@ static bool LoadWait(const Vehicle* v, const Vehicle* u)
|
|||||||
int LoadUnloadVehicle(Vehicle *v)
|
int LoadUnloadVehicle(Vehicle *v)
|
||||||
{
|
{
|
||||||
int profit = 0;
|
int profit = 0;
|
||||||
int v_profit; //virtual profit for feeder systems
|
int v_profit = 0; //virtual profit for feeder systems
|
||||||
int v_profit_total = 0;
|
int v_profit_total = 0;
|
||||||
int unloading_time = 20;
|
int unloading_time = 20;
|
||||||
Vehicle *u = v;
|
Vehicle *u = v;
|
||||||
@ -1345,6 +1345,7 @@ int LoadUnloadVehicle(Vehicle *v)
|
|||||||
/* unload goods and let it wait at the station */
|
/* unload goods and let it wait at the station */
|
||||||
st->time_since_unload = 0;
|
st->time_since_unload = 0;
|
||||||
|
|
||||||
|
if (u->current_order.flags & OF_TRANSFER) {
|
||||||
v_profit = GetTransportedGoodsIncome(
|
v_profit = GetTransportedGoodsIncome(
|
||||||
v->cargo_count,
|
v->cargo_count,
|
||||||
DistanceManhattan(GetStation(v->cargo_source)->xy, GetStation(last_visited)->xy),
|
DistanceManhattan(GetStation(v->cargo_source)->xy, GetStation(last_visited)->xy),
|
||||||
@ -1352,6 +1353,7 @@ int LoadUnloadVehicle(Vehicle *v)
|
|||||||
v->cargo_type) * 3 / 2;
|
v->cargo_type) * 3 / 2;
|
||||||
|
|
||||||
v_profit_total += v_profit;
|
v_profit_total += v_profit;
|
||||||
|
}
|
||||||
|
|
||||||
unloading_time += v->cargo_count;
|
unloading_time += v->cargo_count;
|
||||||
t = GB(ge->waiting_acceptance, 0, 12);
|
t = GB(ge->waiting_acceptance, 0, 12);
|
||||||
@ -1368,8 +1370,11 @@ int LoadUnloadVehicle(Vehicle *v)
|
|||||||
}
|
}
|
||||||
// Update amount of waiting cargo
|
// Update amount of waiting cargo
|
||||||
SB(ge->waiting_acceptance, 0, 12, min(v->cargo_count + t, 0xFFF));
|
SB(ge->waiting_acceptance, 0, 12, min(v->cargo_count + t, 0xFFF));
|
||||||
|
|
||||||
|
if (u->current_order.flags & OF_TRANSFER) {
|
||||||
ge->feeder_profit += v_profit;
|
ge->feeder_profit += v_profit;
|
||||||
u->profit_this_year += v_profit;
|
u->profit_this_year += v_profit;
|
||||||
|
}
|
||||||
result |= 2;
|
result |= 2;
|
||||||
v->cargo_count = 0;
|
v->cargo_count = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user