2007-06-01 11:41:02 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file articulated_vehicles.cpp Implementation of articulated vehicles. */
|
2007-06-01 11:41:02 +00:00
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "train.h"
|
2007-06-11 14:00:16 +00:00
|
|
|
#include "roadveh.h"
|
2007-06-01 11:41:02 +00:00
|
|
|
#include "newgrf_engine.h"
|
2007-12-27 13:35:39 +00:00
|
|
|
#include "vehicle_func.h"
|
2007-06-01 11:41:02 +00:00
|
|
|
|
2009-03-13 21:28:40 +00:00
|
|
|
#include "table/strings.h"
|
2009-05-13 21:45:56 +00:00
|
|
|
#include "table/sprites.h"
|
2009-03-13 21:28:40 +00:00
|
|
|
|
2008-07-27 12:35:14 +00:00
|
|
|
static const uint MAX_ARTICULATED_PARTS = 100; ///< Maximum of articulated parts per vehicle, i.e. when to abort calling the articulated vehicle callback.
|
|
|
|
|
2007-09-17 04:23:03 +00:00
|
|
|
uint CountArticulatedParts(EngineID engine_type, bool purchase_window)
|
2007-06-01 11:41:02 +00:00
|
|
|
{
|
2007-11-19 21:02:30 +00:00
|
|
|
if (!HasBit(EngInfo(engine_type)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return 0;
|
2007-06-01 11:41:02 +00:00
|
|
|
|
2009-01-09 14:59:02 +00:00
|
|
|
/* If we can't allocate a vehicle now, we can't allocate it in the command
|
|
|
|
* either, so it doesn't matter how many articulated parts there are. */
|
|
|
|
if (!Vehicle::CanAllocateItem()) return 0;
|
|
|
|
|
2009-05-22 15:13:50 +00:00
|
|
|
Vehicle *v = NULL;
|
2007-09-17 04:23:03 +00:00
|
|
|
if (!purchase_window) {
|
2009-05-22 15:13:50 +00:00
|
|
|
v = new Vehicle();
|
2007-09-17 04:23:03 +00:00
|
|
|
v->engine_type = engine_type;
|
|
|
|
}
|
|
|
|
|
2007-06-01 11:41:02 +00:00
|
|
|
uint i;
|
2008-07-27 12:35:14 +00:00
|
|
|
for (i = 1; i < MAX_ARTICULATED_PARTS; i++) {
|
2007-09-17 04:23:03 +00:00
|
|
|
uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, i, 0, engine_type, v);
|
2008-04-21 14:33:33 +00:00
|
|
|
if (callback == CALLBACK_FAILED || GB(callback, 0, 8) == 0xFF) break;
|
2007-06-01 11:41:02 +00:00
|
|
|
}
|
|
|
|
|
2007-09-17 04:23:03 +00:00
|
|
|
delete v;
|
|
|
|
|
2007-06-01 11:41:02 +00:00
|
|
|
return i - 1;
|
|
|
|
}
|
|
|
|
|
2008-02-14 07:25:24 +00:00
|
|
|
|
2008-07-27 15:17:16 +00:00
|
|
|
/**
|
|
|
|
* Returns the default (non-refitted) capacity of a specific EngineID.
|
|
|
|
* @param engine the EngineID of iterest
|
|
|
|
* @param type the type of the engine
|
|
|
|
* @param cargo_type returns the default cargo type, if needed
|
|
|
|
* @return capacity
|
|
|
|
*/
|
|
|
|
static inline uint16 GetVehicleDefaultCapacity(EngineID engine, VehicleType type, CargoID *cargo_type)
|
|
|
|
{
|
2009-05-16 23:34:14 +00:00
|
|
|
const Engine *e = Engine::Get(engine);
|
2009-02-21 12:52:41 +00:00
|
|
|
CargoID cargo = (e->CanCarryCargo() ? e->GetDefaultCargoType() : (CargoID)CT_INVALID);
|
|
|
|
if (cargo_type != NULL) *cargo_type = cargo;
|
|
|
|
if (cargo == CT_INVALID) return 0;
|
2009-03-18 19:32:13 +00:00
|
|
|
return e->GetDisplayDefaultCapacity();
|
2008-07-27 15:17:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns all cargos a vehicle can carry.
|
|
|
|
* @param engine the EngineID of iterest
|
|
|
|
* @param type the type of the engine
|
|
|
|
* @param include_initial_cargo_type if true the default cargo type of the vehicle is included; if false only the refit_mask
|
|
|
|
* @return bit set of CargoIDs
|
|
|
|
*/
|
|
|
|
static inline uint32 GetAvailableVehicleCargoTypes(EngineID engine, VehicleType type, bool include_initial_cargo_type)
|
|
|
|
{
|
|
|
|
uint32 cargos = 0;
|
|
|
|
CargoID initial_cargo_type;
|
|
|
|
|
|
|
|
if (GetVehicleDefaultCapacity(engine, type, &initial_cargo_type) > 0) {
|
|
|
|
if (type != VEH_SHIP || ShipVehInfo(engine)->refittable) {
|
|
|
|
const EngineInfo *ei = EngInfo(engine);
|
|
|
|
cargos = ei->refit_mask;
|
|
|
|
}
|
|
|
|
if (include_initial_cargo_type && initial_cargo_type < NUM_CARGO) SetBit(cargos, initial_cargo_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
return cargos;
|
|
|
|
}
|
|
|
|
|
2009-06-27 21:36:04 +00:00
|
|
|
CargoArray GetCapacityOfArticulatedParts(EngineID engine, VehicleType type)
|
2008-02-14 07:25:24 +00:00
|
|
|
{
|
2009-06-27 21:36:04 +00:00
|
|
|
CargoArray capacity;
|
2008-02-14 07:25:24 +00:00
|
|
|
|
2008-07-27 15:17:16 +00:00
|
|
|
CargoID cargo_type;
|
|
|
|
uint16 cargo_capacity = GetVehicleDefaultCapacity(engine, type, &cargo_type);
|
|
|
|
if (cargo_type < NUM_CARGO) capacity[cargo_type] = cargo_capacity;
|
|
|
|
|
|
|
|
if (type != VEH_TRAIN && type != VEH_ROAD) return capacity;
|
2008-02-14 07:25:24 +00:00
|
|
|
|
|
|
|
if (!HasBit(EngInfo(engine)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return capacity;
|
|
|
|
|
2008-07-27 12:35:14 +00:00
|
|
|
for (uint i = 1; i < MAX_ARTICULATED_PARTS; i++) {
|
2008-02-14 07:25:24 +00:00
|
|
|
uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, i, 0, engine, NULL);
|
2008-04-21 14:33:33 +00:00
|
|
|
if (callback == CALLBACK_FAILED || GB(callback, 0, 8) == 0xFF) break;
|
2008-02-14 07:25:24 +00:00
|
|
|
|
2008-04-29 21:31:29 +00:00
|
|
|
EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), type, GB(callback, 0, 7));
|
2008-02-14 07:25:24 +00:00
|
|
|
|
2008-07-27 15:17:16 +00:00
|
|
|
cargo_capacity = GetVehicleDefaultCapacity(artic_engine, type, &cargo_type);
|
|
|
|
if (cargo_type < NUM_CARGO) capacity[cargo_type] += cargo_capacity;
|
2008-02-14 07:25:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return capacity;
|
|
|
|
}
|
|
|
|
|
2009-02-27 20:40:39 +00:00
|
|
|
/**
|
|
|
|
* Checks whether any of the articulated parts is refittable
|
|
|
|
* @param engine the first part
|
|
|
|
* @return true if refittable
|
|
|
|
*/
|
|
|
|
bool IsArticulatedVehicleRefittable(EngineID engine)
|
|
|
|
{
|
|
|
|
if (IsEngineRefittable(engine)) return true;
|
|
|
|
|
2009-05-16 23:34:14 +00:00
|
|
|
const Engine *e = Engine::Get(engine);
|
2009-02-27 20:40:39 +00:00
|
|
|
if (e->type != VEH_TRAIN && e->type != VEH_ROAD) return false;
|
|
|
|
|
|
|
|
if (!HasBit(e->info.callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return false;
|
|
|
|
|
|
|
|
for (uint i = 1; i < MAX_ARTICULATED_PARTS; i++) {
|
|
|
|
uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, i, 0, engine, NULL);
|
|
|
|
if (callback == CALLBACK_FAILED || GB(callback, 0, 8) == 0xFF) break;
|
|
|
|
|
|
|
|
EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), e->type, GB(callback, 0, 7));
|
|
|
|
if (IsEngineRefittable(artic_engine)) return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-07-27 15:17:16 +00:00
|
|
|
/**
|
|
|
|
* Ors the refit_masks of all articulated parts.
|
|
|
|
* @param engine the first part
|
|
|
|
* @param type the vehicle type
|
|
|
|
* @param include_initial_cargo_type if true the default cargo type of the vehicle is included; if false only the refit_mask
|
|
|
|
* @return bit mask of CargoIDs which are a refit option for at least one articulated part
|
|
|
|
*/
|
|
|
|
uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool include_initial_cargo_type)
|
|
|
|
{
|
|
|
|
uint32 cargos = GetAvailableVehicleCargoTypes(engine, type, include_initial_cargo_type);
|
|
|
|
|
|
|
|
if (type != VEH_TRAIN && type != VEH_ROAD) return cargos;
|
|
|
|
|
|
|
|
if (!HasBit(EngInfo(engine)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return cargos;
|
|
|
|
|
|
|
|
for (uint i = 1; i < MAX_ARTICULATED_PARTS; i++) {
|
|
|
|
uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, i, 0, engine, NULL);
|
|
|
|
if (callback == CALLBACK_FAILED || GB(callback, 0, 8) == 0xFF) break;
|
|
|
|
|
|
|
|
EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), type, GB(callback, 0, 7));
|
|
|
|
cargos |= GetAvailableVehicleCargoTypes(artic_engine, type, include_initial_cargo_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
return cargos;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ands the refit_masks of all articulated parts.
|
|
|
|
* @param engine the first part
|
|
|
|
* @param type the vehicle type
|
|
|
|
* @param include_initial_cargo_type if true the default cargo type of the vehicle is included; if false only the refit_mask
|
|
|
|
* @return bit mask of CargoIDs which are a refit option for every articulated part (with default capacity > 0)
|
|
|
|
*/
|
|
|
|
uint32 GetIntersectionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool include_initial_cargo_type)
|
|
|
|
{
|
|
|
|
uint32 cargos = UINT32_MAX;
|
|
|
|
|
|
|
|
uint32 veh_cargos = GetAvailableVehicleCargoTypes(engine, type, include_initial_cargo_type);
|
|
|
|
if (veh_cargos != 0) cargos &= veh_cargos;
|
|
|
|
|
|
|
|
if (type != VEH_TRAIN && type != VEH_ROAD) return cargos;
|
|
|
|
|
|
|
|
if (!HasBit(EngInfo(engine)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return cargos;
|
|
|
|
|
|
|
|
for (uint i = 1; i < MAX_ARTICULATED_PARTS; i++) {
|
|
|
|
uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, i, 0, engine, NULL);
|
|
|
|
if (callback == CALLBACK_FAILED || GB(callback, 0, 8) == 0xFF) break;
|
|
|
|
|
|
|
|
EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), type, GB(callback, 0, 7));
|
|
|
|
veh_cargos = GetAvailableVehicleCargoTypes(artic_engine, type, include_initial_cargo_type);
|
|
|
|
if (veh_cargos != 0) cargos &= veh_cargos;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cargos;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests if all parts of an articulated vehicle are refitted to the same cargo.
|
|
|
|
* Note: Vehicles not carrying anything are ignored
|
|
|
|
* @param v the first vehicle in the chain
|
|
|
|
* @param cargo_type returns the common CargoID if needed. (CT_INVALID if no part is carrying something or they are carrying different things)
|
|
|
|
* @return true if some parts are carrying different cargos, false if all parts are carrying the same (nothing is also the same)
|
|
|
|
*/
|
|
|
|
bool IsArticulatedVehicleCarryingDifferentCargos(const Vehicle *v, CargoID *cargo_type)
|
|
|
|
{
|
|
|
|
CargoID first_cargo = CT_INVALID;
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (v->cargo_cap > 0 && v->cargo_type != CT_INVALID) {
|
|
|
|
if (first_cargo == CT_INVALID) first_cargo = v->cargo_type;
|
|
|
|
if (first_cargo != v->cargo_type) {
|
|
|
|
if (cargo_type != NULL) *cargo_type = CT_INVALID;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (v->type) {
|
|
|
|
case VEH_TRAIN:
|
2009-07-01 23:57:20 +00:00
|
|
|
v = Train::From(v)->EngineHasArticPart() ? GetNextArticPart(Train::From(v)) : NULL;
|
2008-07-27 15:17:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VEH_ROAD:
|
|
|
|
v = (RoadVehHasArticPart(v) ? v->Next() : NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
v = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (v != NULL);
|
|
|
|
|
|
|
|
if (cargo_type != NULL) *cargo_type = first_cargo;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-03-13 21:28:40 +00:00
|
|
|
/**
|
|
|
|
* Checks whether the specs of freshly build articulated vehicles are consistent with the information specified in the purchase list.
|
|
|
|
* Only essential information is checked to leave room for magic tricks/workarounds to grfcoders.
|
|
|
|
* It checks:
|
|
|
|
* For autoreplace/-renew:
|
|
|
|
* - Default cargo type (without capacity)
|
|
|
|
* - intersection and union of refit masks.
|
|
|
|
*/
|
|
|
|
void CheckConsistencyOfArticulatedVehicle(const Vehicle *v)
|
|
|
|
{
|
2009-05-16 23:34:14 +00:00
|
|
|
const Engine *engine = Engine::Get(v->engine_type);
|
2009-03-13 21:28:40 +00:00
|
|
|
|
|
|
|
uint32 purchase_refit_union = GetUnionOfArticulatedRefitMasks(v->engine_type, v->type, true);
|
|
|
|
uint32 purchase_refit_intersection = GetIntersectionOfArticulatedRefitMasks(v->engine_type, v->type, true);
|
2009-06-27 21:36:04 +00:00
|
|
|
CargoArray purchase_default_capacity = GetCapacityOfArticulatedParts(v->engine_type, v->type);
|
2009-03-13 21:28:40 +00:00
|
|
|
|
|
|
|
uint32 real_refit_union = 0;
|
|
|
|
uint32 real_refit_intersection = UINT_MAX;
|
2009-06-27 21:36:04 +00:00
|
|
|
CargoArray real_default_capacity;
|
2009-03-13 21:28:40 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
uint32 refit_mask = GetAvailableVehicleCargoTypes(v->engine_type, v->type, true);
|
|
|
|
real_refit_union |= refit_mask;
|
|
|
|
if (refit_mask != 0) real_refit_intersection &= refit_mask;
|
|
|
|
|
|
|
|
assert(v->cargo_type < NUM_CARGO);
|
|
|
|
real_default_capacity[v->cargo_type] += v->cargo_cap;
|
|
|
|
|
|
|
|
switch (v->type) {
|
|
|
|
case VEH_TRAIN:
|
2009-07-01 23:57:20 +00:00
|
|
|
v = Train::From(v)->EngineHasArticPart() ? GetNextArticPart(Train::From(v)) : NULL;
|
2009-03-13 21:28:40 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VEH_ROAD:
|
|
|
|
v = (RoadVehHasArticPart(v) ? v->Next() : NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
v = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (v != NULL);
|
|
|
|
|
|
|
|
/* Check whether the vehicle carries more cargos than expected */
|
|
|
|
bool carries_more = false;
|
|
|
|
for (CargoID cid = 0; cid < NUM_CARGO; cid++) {
|
|
|
|
if (real_default_capacity[cid] != 0 && purchase_default_capacity[cid] == 0) {
|
|
|
|
carries_more = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* show a warning once for each GRF after each game load */
|
|
|
|
if (real_refit_union != purchase_refit_union || real_refit_intersection != purchase_refit_intersection || carries_more) {
|
|
|
|
ShowNewGrfVehicleError(engine->index, STR_NEWGRF_BUGGY, STR_NEWGRF_BUGGY_ARTICULATED_CARGO, GBUG_VEH_REFIT, false);
|
|
|
|
}
|
|
|
|
}
|
2008-02-14 07:25:24 +00:00
|
|
|
|
2009-05-13 21:38:23 +00:00
|
|
|
void AddArticulatedParts(Vehicle *first, VehicleType type)
|
2007-06-01 11:41:02 +00:00
|
|
|
{
|
2009-05-24 12:05:27 +00:00
|
|
|
if (!HasBit(EngInfo(first->engine_type)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return;
|
2007-06-01 11:41:02 +00:00
|
|
|
|
2009-05-24 12:05:27 +00:00
|
|
|
Vehicle *v = first;
|
2008-07-27 12:35:14 +00:00
|
|
|
for (uint i = 1; i < MAX_ARTICULATED_PARTS; i++) {
|
2009-05-24 12:05:27 +00:00
|
|
|
uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, i, 0, first->engine_type, first);
|
2008-04-21 14:33:33 +00:00
|
|
|
if (callback == CALLBACK_FAILED || GB(callback, 0, 8) == 0xFF) return;
|
2007-06-01 11:41:02 +00:00
|
|
|
|
2009-05-13 21:38:23 +00:00
|
|
|
/* In the (very rare) case the GRF reported wrong number of articulated parts
|
|
|
|
* and we run out of available vehicles, bail out. */
|
|
|
|
if (!Vehicle::CanAllocateItem()) return;
|
2007-06-01 11:41:02 +00:00
|
|
|
|
2009-05-24 12:05:27 +00:00
|
|
|
EngineID engine_type = GetNewEngineID(GetEngineGRF(first->engine_type), type, GB(callback, 0, 7));
|
2007-11-19 21:02:30 +00:00
|
|
|
bool flip_image = HasBit(callback, 7);
|
2007-06-01 11:41:02 +00:00
|
|
|
|
2009-05-16 23:34:14 +00:00
|
|
|
const Engine *e_artic = Engine::Get(engine_type);
|
2007-06-11 14:00:16 +00:00
|
|
|
switch (type) {
|
|
|
|
default: NOT_REACHED();
|
|
|
|
|
2009-05-22 22:22:46 +00:00
|
|
|
case VEH_TRAIN: {
|
2009-06-06 16:54:22 +00:00
|
|
|
Train *front = Train::From(first);
|
2009-05-22 22:22:46 +00:00
|
|
|
Train *t = new Train();
|
2009-05-24 12:05:27 +00:00
|
|
|
v->SetNext(t);
|
|
|
|
v = t;
|
|
|
|
|
2009-05-22 22:22:46 +00:00
|
|
|
t->subtype = 0;
|
2009-05-22 22:33:05 +00:00
|
|
|
t->track = front->track;
|
|
|
|
t->railtype = front->railtype;
|
2009-05-22 22:55:41 +00:00
|
|
|
t->tcache.first_engine = front->engine_type;
|
2007-06-11 14:00:16 +00:00
|
|
|
|
2009-05-22 22:22:46 +00:00
|
|
|
t->spritenum = e_artic->u.rail.image_index;
|
2009-02-21 12:52:41 +00:00
|
|
|
if (e_artic->CanCarryCargo()) {
|
2009-05-22 22:22:46 +00:00
|
|
|
t->cargo_type = e_artic->GetDefaultCargoType();
|
|
|
|
t->cargo_cap = e_artic->u.rail.capacity; // Callback 36 is called when the consist is finished
|
2009-02-21 12:52:41 +00:00
|
|
|
} else {
|
2009-05-22 22:22:46 +00:00
|
|
|
t->cargo_type = front->cargo_type; // Needed for livery selection
|
|
|
|
t->cargo_cap = 0;
|
2009-02-21 12:52:41 +00:00
|
|
|
}
|
2007-06-11 14:00:16 +00:00
|
|
|
|
2009-05-22 22:22:46 +00:00
|
|
|
SetArticulatedPart(t);
|
|
|
|
} break;
|
2007-06-11 14:00:16 +00:00
|
|
|
|
2009-05-22 20:22:20 +00:00
|
|
|
case VEH_ROAD: {
|
2009-06-06 16:54:22 +00:00
|
|
|
RoadVehicle *front = RoadVehicle::From(first);
|
2009-05-22 20:22:20 +00:00
|
|
|
RoadVehicle *rv = new RoadVehicle();
|
2009-05-24 12:05:27 +00:00
|
|
|
v->SetNext(rv);
|
|
|
|
v = rv;
|
|
|
|
|
2009-05-22 20:22:20 +00:00
|
|
|
rv->subtype = 0;
|
2009-05-23 09:10:56 +00:00
|
|
|
rv->rcache.first_engine = front->engine_type;
|
|
|
|
rv->rcache.cached_veh_length = 8; // Callback is called when the consist is finished
|
2009-05-22 20:22:20 +00:00
|
|
|
rv->state = RVSB_IN_DEPOT;
|
2007-06-11 14:00:16 +00:00
|
|
|
|
2009-05-22 20:22:20 +00:00
|
|
|
rv->roadtype = front->roadtype;
|
|
|
|
rv->compatible_roadtypes = front->compatible_roadtypes;
|
2007-06-11 14:00:16 +00:00
|
|
|
|
2009-05-26 08:51:33 +00:00
|
|
|
rv->spritenum = e_artic->u.road.image_index;
|
2009-02-21 12:52:41 +00:00
|
|
|
if (e_artic->CanCarryCargo()) {
|
2009-05-22 20:22:20 +00:00
|
|
|
rv->cargo_type = e_artic->GetDefaultCargoType();
|
|
|
|
rv->cargo_cap = e_artic->u.road.capacity; // Callback 36 is called when the consist is finished
|
2009-02-21 12:52:41 +00:00
|
|
|
} else {
|
2009-05-22 20:22:20 +00:00
|
|
|
rv->cargo_type = front->cargo_type; // Needed for livery selection
|
|
|
|
rv->cargo_cap = 0;
|
2009-02-21 12:52:41 +00:00
|
|
|
}
|
2007-06-11 14:00:16 +00:00
|
|
|
|
2009-05-22 20:22:20 +00:00
|
|
|
SetRoadVehArticPart(rv);
|
|
|
|
} break;
|
2007-06-11 14:00:16 +00:00
|
|
|
}
|
|
|
|
|
2009-03-09 19:14:36 +00:00
|
|
|
/* get common values from first engine */
|
2009-05-24 12:05:27 +00:00
|
|
|
v->direction = first->direction;
|
|
|
|
v->owner = first->owner;
|
|
|
|
v->tile = first->tile;
|
|
|
|
v->x_pos = first->x_pos;
|
|
|
|
v->y_pos = first->y_pos;
|
|
|
|
v->z_pos = first->z_pos;
|
|
|
|
v->build_year = first->build_year;
|
|
|
|
v->vehstatus = first->vehstatus & ~VS_STOPPED;
|
|
|
|
|
|
|
|
v->cargo_subtype = 0;
|
|
|
|
v->max_speed = 0;
|
|
|
|
v->max_age = 0;
|
|
|
|
v->engine_type = engine_type;
|
|
|
|
v->value = 0;
|
|
|
|
v->cur_image = SPR_IMG_QUERY;
|
|
|
|
v->random_bits = VehicleRandomBits();
|
|
|
|
|
|
|
|
if (flip_image) v->spritenum++;
|
|
|
|
|
|
|
|
VehicleMove(v, false);
|
2007-06-01 11:41:02 +00:00
|
|
|
}
|
|
|
|
}
|