(svn r23149) -Add: [NewGRF] Road vehicle property 23 to shorten vehicles without callback usage.

This commit is contained in:
frosch 2011-11-08 17:27:46 +00:00
parent 52774235eb
commit c2cf26b451
4 changed files with 9 additions and 3 deletions

View File

@ -121,6 +121,7 @@ struct RoadVehicleInfo {
uint8 tractive_effort; ///< Coefficient of tractive effort uint8 tractive_effort; ///< Coefficient of tractive effort
uint8 air_drag; ///< Coefficient of air drag uint8 air_drag; ///< Coefficient of air drag
byte visual_effect; ///< Bitstuffed NewGRF visual effect data byte visual_effect; ///< Bitstuffed NewGRF visual effect data
byte shorten_factor; ///< length on main map for this type is 8 - shorten_factor
}; };
/** /**

View File

@ -1319,6 +1319,10 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop
ei->cargo_age_period = buf->ReadWord(); ei->cargo_age_period = buf->ReadWord();
break; break;
case 0x23: // Shorter vehicle
rvi->shorten_factor = buf->ReadByte();
break;
default: default:
ret = CommonVehicleChangeInfo(ei, prop, buf); ret = CommonVehicleChangeInfo(ei, prop, buf);
break; break;

View File

@ -161,11 +161,12 @@ void DrawRoadVehEngine(int left, int right, int preferred_x, int y, EngineID eng
*/ */
static uint GetRoadVehLength(const RoadVehicle *v) static uint GetRoadVehLength(const RoadVehicle *v)
{ {
uint length = VEHICLE_LENGTH; const Engine *e = v->GetEngine();
uint length = e->u.road.shorten_factor;
uint16 veh_len = GetVehicleCallback(CBID_VEHICLE_LENGTH, 0, 0, v->engine_type, v); uint16 veh_len = GetVehicleCallback(CBID_VEHICLE_LENGTH, 0, 0, v->engine_type, v);
if (veh_len != CALLBACK_FAILED) { if (veh_len != CALLBACK_FAILED) {
if (veh_len >= VEHICLE_LENGTH) ErrorUnknownCallbackResult(v->GetGRFID(), CBID_VEHICLE_LENGTH, veh_len); if (veh_len >= VEHICLE_LENGTH) ErrorUnknownCallbackResult(e->GetGRFID(), CBID_VEHICLE_LENGTH, veh_len);
length -= Clamp(veh_len, 0, VEHICLE_LENGTH - 1); length -= Clamp(veh_len, 0, VEHICLE_LENGTH - 1);
} }

View File

@ -656,7 +656,7 @@ static const AircraftVehicleInfo _orig_aircraft_vehicle_info[] = {
* Tractive effort coefficient by default is the same as TTDPatch, 0.30*256=76 * Tractive effort coefficient by default is the same as TTDPatch, 0.30*256=76
* Air drag value depends on the top speed of the vehicle. * Air drag value depends on the top speed of the vehicle.
*/ */
#define ROV(a, b, c, d, e, f, g, h) { a, b, c, PR_RUNNING_ROADVEH, d, e, f, g, h, 76, 0, VE_DEFAULT } #define ROV(a, b, c, d, e, f, g, h) { a, b, c, PR_RUNNING_ROADVEH, d, e, f, g, h, 76, 0, VE_DEFAULT, 0 }
static const RoadVehicleInfo _orig_road_vehicle_info[] = { static const RoadVehicleInfo _orig_road_vehicle_info[] = {
/* image_index sfx max_speed power /* image_index sfx max_speed power
* | cost_factor | | capacity | * | cost_factor | | capacity |