|
@@ -257,61 +257,59 @@ CommandCost CmdBuildRoadVeh(TileIndex ti
|
|
|
|
|
|
v->reliability = e->reliability;
|
|
|
v->reliability_spd_dec = e->reliability_spd_dec;
|
|
|
v->max_age = e->GetLifeLengthInDays();
|
|
|
_new_vehicle_id = v->index;
|
|
|
|
|
|
v->name = NULL;
|
|
|
|
|
|
v->service_interval = Company::Get(v->owner)->settings.vehicle.servint_roadveh;
|
|
|
|
|
|
v->date_of_last_service = _date;
|
|
|
v->build_year = _cur_year;
|
|
|
|
|
|
v->cur_image = SPR_IMG_QUERY;
|
|
|
v->random_bits = VehicleRandomBits();
|
|
|
v->SetRoadVehFront();
|
|
|
|
|
|
v->roadtype = HasBit(e->info.misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD;
|
|
|
v->compatible_roadtypes = RoadTypeToRoadTypes(v->roadtype);
|
|
|
v->rcache.cached_veh_length = 8;
|
|
|
|
|
|
v->vehicle_flags = 0;
|
|
|
if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SetBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
|
|
|
|
|
|
v->cargo_cap = rvi->capacity;
|
|
|
|
|
|
AddArticulatedParts(v);
|
|
|
v->InvalidateNewGRFCacheOfChain();
|
|
|
|
|
|
/* Call various callbacks after the whole consist has been constructed */
|
|
|
for (RoadVehicle *u = v; u != NULL; u = u->Next()) {
|
|
|
u->rcache.cached_veh_length = GetRoadVehLength(u);
|
|
|
/* Cargo capacity is zero if and only if the vehicle cannot carry anything */
|
|
|
if (u->cargo_cap != 0) u->cargo_cap = GetVehicleProperty(u, PROP_ROADVEH_CARGO_CAPACITY, u->cargo_cap);
|
|
|
v->InvalidateNewGRFCache();
|
|
|
u->InvalidateNewGRFCache();
|
|
|
}
|
|
|
RoadVehUpdateCache(v);
|
|
|
|
|
|
VehicleMove(v, false);
|
|
|
|
|
|
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
|
|
InvalidateWindowClassesData(WC_ROADVEH_LIST, 0);
|
|
|
SetWindowDirty(WC_COMPANY, v->owner);
|
|
|
if (IsLocalCompany()) {
|
|
|
InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Road window
|
|
|
}
|
|
|
|
|
|
Company::Get(_current_company)->num_engines[p1]++;
|
|
|
|
|
|
CheckConsistencyOfArticulatedVehicle(v);
|
|
|
}
|
|
|
|
|
|
return cost;
|
|
|
}
|
|
|
|
|
|
void ClearSlot(RoadVehicle *v)
|
|
|
{
|
|
|
RoadStop *rs = v->slot;
|
|
|
if (v->slot == NULL) return;
|
|
|
|
|
|
v->slot = NULL;
|