Changeset - r20142:5508447246ff
[Not reviewed]
master
0 4 0
frosch - 11 years ago 2013-03-22 21:27:13
frosch@openttd.org
(svn r25115) -Fix (r8973) [FS#5492-ish]: [NewGRF] Acceleration of NewGRF aircraft was too fast, while acceleration of default aircraft was way too slow. I.e. choose wisely who to let write the software for your orbiter.
4 files changed with 24 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/aircraft_cmd.cpp
Show inline comments
 
@@ -598,7 +598,14 @@ enum AircraftSpeedLimits {
 
 */
 
static int UpdateAircraftSpeed(Aircraft *v, uint speed_limit = SPEED_LIMIT_NONE, bool hard_limit = true)
 
{
 
	uint spd = v->acceleration * 16;
 
	/**
 
	 * 'acceleration' has the unit 3/8 mph/tick. This function is called twice per tick.
 
	 * So the speed amount we need to accelerate is:
 
	 *     acceleration * 3 / 16 mph = acceleration * 3 / 16 * 16 / 10 km-ish/h
 
	 *                               = acceleration * 3 / 10 * 256 * (km-ish/h / 256)
 
	 *                               ~ acceleration * 77 (km-ish/h / 256)
 
	 */
 
	uint spd = v->acceleration * 77;
 
	byte t;
 

	
 
	/* Adjust speed limits by plane speed factor to prevent taxiing
src/newgrf.cpp
Show inline comments
 
@@ -1618,15 +1618,9 @@ static ChangeInfoResult AircraftVehicleC
 
				avi->max_speed = (buf->ReadByte() * 128) / 10;
 
				break;
 

	
 
			case 0x0D: { // Acceleration
 
				uint acceleration = (buf->ReadByte() * 128) / 10;
 
				if (acceleration > UINT8_MAX) {
 
					grfmsg(1, "Acceleration property of aircraft %d is too big.", engine + i);
 
					acceleration = UINT8_MAX;
 
				}
 
				avi->acceleration = acceleration;
 
				break;
 
			}
 
			case 0x0D: // Acceleration
 
				avi->acceleration = buf->ReadByte();
 
				break;
 

	
 
			case PROP_AIRCRAFT_RUNNING_COST_FACTOR: // 0x0E Running cost factor
 
				avi->running_cost = buf->ReadByte();
src/saveload/afterload.cpp
Show inline comments
 
@@ -2761,6 +2761,17 @@ bool AfterLoadGame()
 
		_settings_game.script.settings_profile = IsInsideMM(_old_diff_level, SP_BEGIN, SP_END) ? _old_diff_level : (uint)SP_MEDIUM;
 
	}
 

	
 
	if (IsSavegameVersionBefore(182)) {
 
		Aircraft *v;
 
		/* Aircraft acceleration variable was bonkers */
 
		FOR_ALL_AIRCRAFT(v) {
 
			if (v->subtype <= AIR_AIRCRAFT) {
 
				const AircraftVehicleInfo *avi = AircraftVehInfo(v->engine_type);
 
				v->acceleration = avi->acceleration;
 
			}
 
		}
 
	}
 

	
 
	/* Road stops is 'only' updating some caches */
 
	AfterLoadRoadStops();
 
	AfterLoadLabelMaps();
src/table/engines.h
Show inline comments
 
@@ -580,8 +580,8 @@ static const ShipVehicleInfo _orig_ship_
 
 * @param c running_Cost
 
 * @param d subtype (bit 0 - plane, bit 1 - large plane)
 
 * @param e sound effect
 
 * @param f acceleration
 
 * @param g max_speed (1 unit = 8 mph = 12.8 km-ish/h)
 
 * @param f acceleration (1 unit = 3/8 mph/tick = 3/5 km-ish/h/tick) (stays the same in the variable)
 
 * @param g max_speed (1 unit = 8 mph = 12.8 km-ish/h) (is converted to km-ish/h by the macro)
 
 * @param h mail_capacity (bags)
 
 * @param i passenger_capacity (persons)
 
 */
0 comments (0 inline, 0 general)