Changeset - r19758:0924962fbd17
[Not reviewed]
master
0 2 0
frosch - 12 years ago 2012-11-12 20:13:02
frosch@openttd.org
(svn r24713) -Fix [FS#5262]: [NewGRF] Tolerate old NewGRFs returning invalid values via CB 11.
2 files changed with 5 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/roadveh_cmd.cpp
Show inline comments
 
@@ -169,13 +169,13 @@ static uint GetRoadVehLength(const RoadV
 
	if (e->GetGRF() != NULL && e->GetGRF()->grf_version >= 8) {
 
		/* Use callback 36 */
 
		veh_len = GetVehicleProperty(v, PROP_ROADVEH_SHORTEN_FACTOR, CALLBACK_FAILED);
 
		if (veh_len != CALLBACK_FAILED && veh_len >= VEHICLE_LENGTH) ErrorUnknownCallbackResult(e->GetGRFID(), CBID_VEHICLE_LENGTH, veh_len);
 
	} else {
 
		/* Use callback 11 */
 
		veh_len = GetVehicleCallback(CBID_VEHICLE_LENGTH, 0, 0, v->engine_type, v);
 
	}
 
	if (veh_len == CALLBACK_FAILED) veh_len = e->u.road.shorten_factor;
 
	if (veh_len != 0) {
 
		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
 
@@ -208,13 +208,14 @@ void Train::ConsistChanged(bool same_len
 
		if (e_u->GetGRF() != NULL && e_u->GetGRF()->grf_version >= 8) {
 
			/* Use callback 36 */
 
			veh_len = GetVehicleProperty(u, PROP_TRAIN_SHORTEN_FACTOR, CALLBACK_FAILED);
 

	
 
			if (veh_len != CALLBACK_FAILED && veh_len >= VEHICLE_LENGTH) {
 
				ErrorUnknownCallbackResult(e_u->GetGRFID(), CBID_VEHICLE_LENGTH, veh_len);
 
			}
 
		} 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 = rvi_u->shorten_factor;
 
		veh_len = VEHICLE_LENGTH - Clamp(veh_len, 0, VEHICLE_LENGTH - 1);
 

	
0 comments (0 inline, 0 general)