Exclude virtual trains from various vehicle list iterations
This commit is contained in:
@@ -556,7 +556,7 @@ static bool DisasterTick_Big_Ufo(DisasterVehicle *v)
|
|||||||
|
|
||||||
Vehicle *target;
|
Vehicle *target;
|
||||||
FOR_ALL_VEHICLES(target) {
|
FOR_ALL_VEHICLES(target) {
|
||||||
if (target->IsGroundVehicle()) {
|
if (target->IsGroundVehicle() && !HasBit(target->subtype, GVSF_VIRTUAL)) {
|
||||||
if (Delta(target->x_pos, v->x_pos) + Delta(target->y_pos, v->y_pos) <= 12 * (int)TILE_SIZE) {
|
if (Delta(target->x_pos, v->x_pos) + Delta(target->y_pos, v->y_pos) <= 12 * (int)TILE_SIZE) {
|
||||||
target->breakdown_ctr = 5;
|
target->breakdown_ctr = 5;
|
||||||
target->breakdown_delay = 0xF0;
|
target->breakdown_delay = 0xF0;
|
||||||
|
@@ -782,7 +782,7 @@ static CompanyID GetPreviewCompany(Engine *e)
|
|||||||
/* Check whether the company uses similar vehicles */
|
/* Check whether the company uses similar vehicles */
|
||||||
Vehicle *v;
|
Vehicle *v;
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
if (v->owner != c->index || v->type != e->type) continue;
|
if (v->owner != c->index || v->type != e->type || HasBit(v->subtype, GVSF_VIRTUAL)) continue;
|
||||||
if (!v->GetEngine()->CanCarryCargo() || !HasBit(cargomask, v->cargo_type)) continue;
|
if (!v->GetEngine()->CanCarryCargo() || !HasBit(cargomask, v->cargo_type)) continue;
|
||||||
|
|
||||||
best_hist = c->old_economy[0].performance_history;
|
best_hist = c->old_economy[0].performance_history;
|
||||||
@@ -933,7 +933,7 @@ static void NewVehicleAvailable(Engine *e)
|
|||||||
c->block_preview = 20;
|
c->block_preview = 20;
|
||||||
|
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
if (v->type == VEH_TRAIN || v->type == VEH_ROAD || v->type == VEH_SHIP ||
|
if ((v->type == VEH_TRAIN && !HasBit(v->subtype, GVSF_VIRTUAL)) || v->type == VEH_ROAD || v->type == VEH_SHIP ||
|
||||||
(v->type == VEH_AIRCRAFT && Aircraft::From(v)->IsNormalAircraft())) {
|
(v->type == VEH_AIRCRAFT && Aircraft::From(v)->IsNormalAircraft())) {
|
||||||
if (v->owner == c->index && v->engine_type == index) {
|
if (v->owner == c->index && v->engine_type == index) {
|
||||||
/* The user did prove me wrong, so restore old value */
|
/* The user did prove me wrong, so restore old value */
|
||||||
|
@@ -209,7 +209,7 @@ void GroupStatistics::Clear()
|
|||||||
|
|
||||||
const Vehicle *v;
|
const Vehicle *v;
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
if (v->IsPrimaryVehicle() && v->age > VEHICLE_PROFIT_MIN_AGE) GroupStatistics::VehicleReachedProfitAge(v);
|
if (v->IsPrimaryVehicle() && v->age > VEHICLE_PROFIT_MIN_AGE && !HasBit(v->subtype, GVSF_VIRTUAL)) GroupStatistics::VehicleReachedProfitAge(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2499,7 +2499,7 @@ static int WhoCanServiceIndustry(Industry *ind)
|
|||||||
/* Check whether it accepts the right kind of cargo */
|
/* Check whether it accepts the right kind of cargo */
|
||||||
bool c_accepts = false;
|
bool c_accepts = false;
|
||||||
bool c_produces = false;
|
bool c_produces = false;
|
||||||
if (v->type == VEH_TRAIN && v->IsFrontEngine()) {
|
if (v->type == VEH_TRAIN && v->IsFrontEngine() && !HasBit(v->subtype, GVSF_VIRTUAL)) {
|
||||||
for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
|
for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
|
||||||
CanCargoServiceIndustry(u->cargo_type, ind, &c_accepts, &c_produces);
|
CanCargoServiceIndustry(u->cargo_type, ind, &c_accepts, &c_produces);
|
||||||
}
|
}
|
||||||
|
@@ -194,7 +194,7 @@ static void FixAllReservations()
|
|||||||
assert(!_settings_game.economy.infrastructure_sharing[VEH_TRAIN]);
|
assert(!_settings_game.economy.infrastructure_sharing[VEH_TRAIN]);
|
||||||
Train *v;
|
Train *v;
|
||||||
FOR_ALL_TRAINS(v) {
|
FOR_ALL_TRAINS(v) {
|
||||||
if (!v->IsPrimaryVehicle() || (v->vehstatus & VS_CRASHED) != 0) continue;
|
if (!v->IsPrimaryVehicle() || (v->vehstatus & VS_CRASHED) != 0 || HasBit(v->subtype, GVSF_VIRTUAL)) continue;
|
||||||
/* It might happen that the train reserved additional tracks,
|
/* It might happen that the train reserved additional tracks,
|
||||||
* but FollowTrainReservation can't detect those because they are no longer reachable.
|
* but FollowTrainReservation can't detect those because they are no longer reachable.
|
||||||
* detect this by first finding the end of the reservation,
|
* detect this by first finding the end of the reservation,
|
||||||
@@ -237,7 +237,7 @@ bool CheckSharingChangePossible(VehicleType type)
|
|||||||
StringID error_message = STR_NULL;
|
StringID error_message = STR_NULL;
|
||||||
Vehicle *v;
|
Vehicle *v;
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
if (type != v->type) continue;
|
if (type != v->type || HasBit(v->subtype, GVSF_VIRTUAL)) continue;
|
||||||
if (v->Previous() != nullptr) continue;
|
if (v->Previous() != nullptr) continue;
|
||||||
|
|
||||||
/* Check vehicle positiion */
|
/* Check vehicle positiion */
|
||||||
|
@@ -1581,7 +1581,7 @@ void NetworkPopulateCompanyStats(NetworkCompanyStats *stats)
|
|||||||
|
|
||||||
/* Go through all vehicles and count the type of vehicles */
|
/* Go through all vehicles and count the type of vehicles */
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
if (!Company::IsValidID(v->owner) || !v->IsPrimaryVehicle()) continue;
|
if (!Company::IsValidID(v->owner) || !v->IsPrimaryVehicle() || HasBit(v->subtype, GVSF_VIRTUAL)) continue;
|
||||||
byte type = 0;
|
byte type = 0;
|
||||||
switch (v->type) {
|
switch (v->type) {
|
||||||
case VEH_TRAIN: type = NETWORK_VEH_TRAIN; break;
|
case VEH_TRAIN: type = NETWORK_VEH_TRAIN; break;
|
||||||
@@ -1669,7 +1669,7 @@ static void NetworkAutoCleanCompanies()
|
|||||||
|
|
||||||
const Vehicle *v;
|
const Vehicle *v;
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
if (!Company::IsValidID(v->owner) || !v->IsPrimaryVehicle()) continue;
|
if (!Company::IsValidID(v->owner) || !v->IsPrimaryVehicle() || HasBit(v->subtype, GVSF_VIRTUAL)) continue;
|
||||||
vehicles_in_company[v->owner]++;
|
vehicles_in_company[v->owner]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -89,7 +89,7 @@ void CheckTrainsLengths()
|
|||||||
bool first = true;
|
bool first = true;
|
||||||
|
|
||||||
FOR_ALL_TRAINS(v) {
|
FOR_ALL_TRAINS(v) {
|
||||||
if (v->First() == v && !(v->vehstatus & VS_CRASHED)) {
|
if (v->First() == v && !(v->vehstatus & VS_CRASHED) && !v->IsVirtual()) {
|
||||||
for (const Train *u = v, *w = v->Next(); w != nullptr; u = w, w = w->Next()) {
|
for (const Train *u = v, *w = v->Next(); w != nullptr; u = w, w = w->Next()) {
|
||||||
if (u->track != TRACK_BIT_DEPOT) {
|
if (u->track != TRACK_BIT_DEPOT) {
|
||||||
if ((w->track != TRACK_BIT_DEPOT &&
|
if ((w->track != TRACK_BIT_DEPOT &&
|
||||||
@@ -862,7 +862,8 @@ static CommandCost CmdBuildRailWagon(TileIndex tile, DoCommandFlag flags, const
|
|||||||
w->engine_type == e->index && ///< Same type
|
w->engine_type == e->index && ///< Same type
|
||||||
w->First() != v && ///< Don't connect to ourself
|
w->First() != v && ///< Don't connect to ourself
|
||||||
!(w->vehstatus & VS_CRASHED) && ///< Not crashed/flooded
|
!(w->vehstatus & VS_CRASHED) && ///< Not crashed/flooded
|
||||||
w->owner == v->owner) { ///< Same owner
|
w->owner == v->owner && ///< Same owner
|
||||||
|
!w->IsVirtual()) { ///< Not virtual
|
||||||
DoCommand(0, v->index | 1 << 20, w->Last()->index, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
|
DoCommand(0, v->index | 1 << 20, w->Last()->index, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -879,7 +880,8 @@ static void NormalizeTrainVehInDepot(const Train *u)
|
|||||||
FOR_ALL_TRAINS(v) {
|
FOR_ALL_TRAINS(v) {
|
||||||
if (v->IsFreeWagon() && v->tile == u->tile &&
|
if (v->IsFreeWagon() && v->tile == u->tile &&
|
||||||
v->track == TRACK_BIT_DEPOT &&
|
v->track == TRACK_BIT_DEPOT &&
|
||||||
v->owner == u->owner) {
|
v->owner == u->owner &&
|
||||||
|
!v->IsVirtual()) {
|
||||||
if (DoCommand(0, v->index | 1 << 20, u->index, DC_EXEC,
|
if (DoCommand(0, v->index | 1 << 20, u->index, DC_EXEC,
|
||||||
CMD_MOVE_RAIL_VEHICLE).Failed())
|
CMD_MOVE_RAIL_VEHICLE).Failed())
|
||||||
break;
|
break;
|
||||||
@@ -1022,7 +1024,7 @@ static Train *FindGoodVehiclePos(const Train *src)
|
|||||||
|
|
||||||
Train *dst;
|
Train *dst;
|
||||||
FOR_ALL_TRAINS(dst) {
|
FOR_ALL_TRAINS(dst) {
|
||||||
if (dst->IsFreeWagon() && dst->tile == tile && !(dst->vehstatus & VS_CRASHED) && dst->owner == src->owner) {
|
if (dst->IsFreeWagon() && dst->tile == tile && !(dst->vehstatus & VS_CRASHED) && dst->owner == src->owner && !dst->IsVirtual()) {
|
||||||
/* check so all vehicles in the line have the same engine. */
|
/* check so all vehicles in the line have the same engine. */
|
||||||
Train *t = dst;
|
Train *t = dst;
|
||||||
while (t->engine_type == eng) {
|
while (t->engine_type == eng) {
|
||||||
|
@@ -38,7 +38,7 @@ void CcBuildWagon(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p
|
|||||||
const Vehicle *found = nullptr;
|
const Vehicle *found = nullptr;
|
||||||
const Train *t;
|
const Train *t;
|
||||||
FOR_ALL_TRAINS(t) {
|
FOR_ALL_TRAINS(t) {
|
||||||
if (t->IsFrontEngine() && t->tile == tile && t->IsStoppedInDepot()) {
|
if (t->IsFrontEngine() && t->tile == tile && t->IsStoppedInDepot() && !t->IsVirtual()) {
|
||||||
if (found != nullptr) return; // must be exactly one.
|
if (found != nullptr) return; // must be exactly one.
|
||||||
found = t;
|
found = t;
|
||||||
}
|
}
|
||||||
|
@@ -79,6 +79,7 @@ void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine
|
|||||||
/* General tests for all vehicle types */
|
/* General tests for all vehicle types */
|
||||||
if (v->type != type) continue;
|
if (v->type != type) continue;
|
||||||
if (v->tile != tile) continue;
|
if (v->tile != tile) continue;
|
||||||
|
if (HasBit(v->subtype, GVSF_VIRTUAL)) continue;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case VEH_TRAIN: {
|
case VEH_TRAIN: {
|
||||||
|
Reference in New Issue
Block a user