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

pull/155/head
frosch 13 years ago
parent a608cbab5d
commit 8bd5d079c5

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

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

@ -161,11 +161,12 @@ void DrawRoadVehEngine(int left, int right, int preferred_x, int y, EngineID eng
*/
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);
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);
}

@ -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
* 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[] = {
/* image_index sfx max_speed power
* | cost_factor | | capacity |

Loading…
Cancel
Save