mirror of https://github.com/OpenTTD/OpenTTD
Add: [YAPF] Rail depot penalty based on the number of trains waiting in it
parent
b0fd51a5ef
commit
3b540a01d9
|
@ -13,6 +13,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../../pbs.h"
|
#include "../../pbs.h"
|
||||||
|
#include "../../vehiclelist.h"
|
||||||
|
|
||||||
template <class Types>
|
template <class Types>
|
||||||
class CYapfCostRailT : public CYapfCostBase {
|
class CYapfCostRailT : public CYapfCostBase {
|
||||||
|
@ -396,6 +397,18 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th
|
||||||
} else if (IsRailDepotTile(cur.tile)) {
|
} else if (IsRailDepotTile(cur.tile)) {
|
||||||
/* We will end in this pass (depot is possible target) */
|
/* We will end in this pass (depot is possible target) */
|
||||||
end_segment_reason |= ESRB_DEPOT;
|
end_segment_reason |= ESRB_DEPOT;
|
||||||
|
/* Add a penalty for each non-stopped train in the depot.
|
||||||
|
* The penalty is capped at 8 trains. */
|
||||||
|
VehicleList vl;
|
||||||
|
BuildDepotVehicleList(VEH_TRAIN, cur.tile, &vl, nullptr, false);
|
||||||
|
int count = 0;
|
||||||
|
for (auto v : vl) {
|
||||||
|
if (!(v->vehstatus & VS_STOPPED)) {
|
||||||
|
count++;
|
||||||
|
if (count == 8) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
segment_cost += Yapf().PfGetSettings().rail_pbs_cross_penalty * count;
|
||||||
|
|
||||||
} else if (cur.tile_type == MP_STATION && IsRailWaypoint(cur.tile)) {
|
} else if (cur.tile_type == MP_STATION && IsRailWaypoint(cur.tile)) {
|
||||||
if (v->current_order.IsType(OT_GOTO_WAYPOINT) &&
|
if (v->current_order.IsType(OT_GOTO_WAYPOINT) &&
|
||||||
|
|
Loading…
Reference in New Issue