diff --git a/src/disaster_vehicle.cpp b/src/disaster_vehicle.cpp index 05841a4e30..e728a94dc5 100644 --- a/src/disaster_vehicle.cpp +++ b/src/disaster_vehicle.cpp @@ -556,7 +556,7 @@ static bool DisasterTick_Big_Ufo(DisasterVehicle *v) Vehicle *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) { target->breakdown_ctr = 5; target->breakdown_delay = 0xF0; diff --git a/src/engine.cpp b/src/engine.cpp index 018fbd1513..8e9eeb6242 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -782,7 +782,7 @@ static CompanyID GetPreviewCompany(Engine *e) /* Check whether the company uses similar vehicles */ Vehicle *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; best_hist = c->old_economy[0].performance_history; @@ -933,7 +933,7 @@ static void NewVehicleAvailable(Engine *e) c->block_preview = 20; 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())) { if (v->owner == c->index && v->engine_type == index) { /* The user did prove me wrong, so restore old value */ diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp index 1042859220..8a0fd10b76 100644 --- a/src/group_cmd.cpp +++ b/src/group_cmd.cpp @@ -209,7 +209,7 @@ void GroupStatistics::Clear() const Vehicle *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); } } diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 8d67a3c133..034052a507 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -2499,7 +2499,7 @@ static int WhoCanServiceIndustry(Industry *ind) /* Check whether it accepts the right kind of cargo */ bool c_accepts = 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()) { CanCargoServiceIndustry(u->cargo_type, ind, &c_accepts, &c_produces); } diff --git a/src/infrastructure.cpp b/src/infrastructure.cpp index 99f4f8acf4..6e4bd87e31 100644 --- a/src/infrastructure.cpp +++ b/src/infrastructure.cpp @@ -194,7 +194,7 @@ static void FixAllReservations() assert(!_settings_game.economy.infrastructure_sharing[VEH_TRAIN]); Train *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, * but FollowTrainReservation can't detect those because they are no longer reachable. * detect this by first finding the end of the reservation, @@ -237,7 +237,7 @@ bool CheckSharingChangePossible(VehicleType type) StringID error_message = STR_NULL; Vehicle *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; /* Check vehicle positiion */ diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 0613d47e8a..9da604ab84 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -1581,7 +1581,7 @@ void NetworkPopulateCompanyStats(NetworkCompanyStats *stats) /* Go through all vehicles and count the type of vehicles */ 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; switch (v->type) { case VEH_TRAIN: type = NETWORK_VEH_TRAIN; break; @@ -1669,7 +1669,7 @@ static void NetworkAutoCleanCompanies() const Vehicle *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]++; } } diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 991a4d8de9..5502488f94 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -89,7 +89,7 @@ void CheckTrainsLengths() bool first = true; 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()) { if (u->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->First() != v && ///< Don't connect to ourself !(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); break; } @@ -879,7 +880,8 @@ static void NormalizeTrainVehInDepot(const Train *u) FOR_ALL_TRAINS(v) { if (v->IsFreeWagon() && v->tile == u->tile && 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, CMD_MOVE_RAIL_VEHICLE).Failed()) break; @@ -1022,7 +1024,7 @@ static Train *FindGoodVehiclePos(const Train *src) Train *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. */ Train *t = dst; while (t->engine_type == eng) { diff --git a/src/train_gui.cpp b/src/train_gui.cpp index a1f5952462..2fecd473fa 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -38,7 +38,7 @@ void CcBuildWagon(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p const Vehicle *found = nullptr; const Train *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. found = t; } diff --git a/src/vehiclelist.cpp b/src/vehiclelist.cpp index 54338b03b9..26febe5876 100644 --- a/src/vehiclelist.cpp +++ b/src/vehiclelist.cpp @@ -79,6 +79,7 @@ void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine /* General tests for all vehicle types */ if (v->type != type) continue; if (v->tile != tile) continue; + if (HasBit(v->subtype, GVSF_VIRTUAL)) continue; switch (type) { case VEH_TRAIN: {