Changeset - r18304:4a661ee8ffe5
[Not reviewed]
master
0 4 0
frosch - 13 years ago 2011-11-08 17:27:55
frosch@openttd.org
(svn r23150) -Change: [NewGRF v8] Deprecate callback 11, and use callback 36 instead.
4 files changed with 21 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/newgrf.cpp
Show inline comments
 
@@ -1099,7 +1099,7 @@ static ChangeInfoResult RailVehicleChang
 
				rvi->air_drag = buf->ReadByte();
 
				break;
 

	
 
			case 0x21: // Shorter vehicle
 
			case PROP_TRAIN_SHORTEN_FACTOR: // 0x21 Shorter vehicle
 
				rvi->shorten_factor = buf->ReadByte();
 
				break;
 

	
 
@@ -1319,7 +1319,7 @@ static ChangeInfoResult RoadVehicleChang
 
				ei->cargo_age_period = buf->ReadWord();
 
				break;
 

	
 
			case 0x23: // Shorter vehicle
 
			case PROP_ROADVEH_SHORTEN_FACTOR: // 0x23 Shorter vehicle
 
				rvi->shorten_factor = buf->ReadByte();
 
				break;
 

	
src/newgrf_properties.h
Show inline comments
 
@@ -25,6 +25,7 @@ enum PropertyID {
 
	PROP_TRAIN_WEIGHT                           = 0x16, ///< Weight in t          (if dualheaded: for each single vehicle)
 
	PROP_TRAIN_COST_FACTOR                      = 0x17, ///< Purchase cost        (if dualheaded: sum of both vehicles)
 
	PROP_TRAIN_TRACTIVE_EFFORT                  = 0x1F, ///< Tractive effort coefficient in 1/256
 
	PROP_TRAIN_SHORTEN_FACTOR                   = 0x21, ///< Shorter vehicles
 
	PROP_TRAIN_USER_DATA                        = 0x25, ///< User defined data for vehicle variable 0x42
 
	PROP_TRAIN_CARGO_AGE_PERIOD                 = 0x2B, ///< Number of ticks before carried cargo is aged
 

	
 
@@ -36,6 +37,7 @@ enum PropertyID {
 
	PROP_ROADVEH_SPEED                          = 0x15, ///< Max. speed: 1 unit = 1/0.8 mph = 2 km-ish/h
 
	PROP_ROADVEH_TRACTIVE_EFFORT                = 0x18, ///< Tractive effort coefficient in 1/256
 
	PROP_ROADVEH_CARGO_AGE_PERIOD               = 0x22, ///< Number of ticks before carried cargo is aged
 
	PROP_ROADVEH_SHORTEN_FACTOR                 = 0x23, ///< Shorter vehicles
 

	
 
	PROP_SHIP_COST_FACTOR                       = 0x0A, ///< Purchase cost
 
	PROP_SHIP_SPEED                             = 0x0B, ///< Max. speed: 1 unit = 1/3.2 mph = 0.5 km-ish/h
src/roadveh_cmd.cpp
Show inline comments
 
@@ -34,6 +34,7 @@
 
#include "core/random_func.hpp"
 
#include "company_base.h"
 
#include "core/backup_type.hpp"
 
#include "newgrf.h"
 

	
 
#include "table/strings.h"
 

	
 
@@ -164,7 +165,14 @@ static uint GetRoadVehLength(const RoadV
 
	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 = CALLBACK_FAILED;
 
	if (e->GetGRF() != NULL && e->GetGRF()->grf_version >= 8) {
 
		/* Use callback 36 */
 
		veh_len = GetVehicleProperty(v, PROP_ROADVEH_SHORTEN_FACTOR, CALLBACK_FAILED);
 
	} else {
 
		/* Use callback 11 */
 
		veh_len = GetVehicleCallback(CBID_VEHICLE_LENGTH, 0, 0, v->engine_type, v);
 
	}
 
	if (veh_len != CALLBACK_FAILED) {
 
		if (veh_len >= VEHICLE_LENGTH) ErrorUnknownCallbackResult(e->GetGRFID(), CBID_VEHICLE_LENGTH, veh_len);
 
		length -= Clamp(veh_len, 0, VEHICLE_LENGTH - 1);
src/train_cmd.cpp
Show inline comments
 
@@ -221,12 +221,15 @@ void Train::ConsistChanged(bool same_len
 

	
 
		/* check the vehicle length (callback) */
 
		uint16 veh_len = CALLBACK_FAILED;
 
		if (HasBit(e_u->info.callback_mask, CBM_VEHICLE_LENGTH)) {
 
		if (e_u->GetGRF() != NULL && e_u->GetGRF()->grf_version >= 8) {
 
			/* Use callback 36 */
 
			veh_len = GetVehicleProperty(u, PROP_TRAIN_SHORTEN_FACTOR, CALLBACK_FAILED);
 
		} else if (HasBit(e_u->info.callback_mask, CBM_VEHICLE_LENGTH)) {
 
			/* Use callback 11 */
 
			veh_len = GetVehicleCallback(CBID_VEHICLE_LENGTH, 0, 0, u->engine_type, u);
 

	
 
			if (veh_len != CALLBACK_FAILED && veh_len >= VEHICLE_LENGTH) {
 
				ErrorUnknownCallbackResult(e_u->GetGRFID(), CBID_VEHICLE_LENGTH, veh_len);
 
			}
 
		}
 
		if (veh_len != CALLBACK_FAILED && veh_len >= VEHICLE_LENGTH) {
 
			ErrorUnknownCallbackResult(e_u->GetGRFID(), CBID_VEHICLE_LENGTH, veh_len);
 
		}
 
		if (veh_len == CALLBACK_FAILED) veh_len = rvi_u->shorten_factor;
 
		veh_len = VEHICLE_LENGTH - Clamp(veh_len, 0, VEHICLE_LENGTH - 1);
0 comments (0 inline, 0 general)