src/aircraft_cmd.cpp
changeset 6159 9a782ac72dba
parent 6137 3d0a1dfdfba7
child 6170 cababf676259
equal deleted inserted replaced
6158:ca1471170695 6159:9a782ac72dba
   896 	v->progress = (t = v->progress) - (byte)spd;
   896 	v->progress = (t = v->progress) - (byte)spd;
   897 
   897 
   898 	return t < v->progress;
   898 	return t < v->progress;
   899 }
   899 }
   900 
   900 
   901 // get Aircraft running altitude
   901 /**
       
   902  * Gets the cruise altitude of an aircraft.
       
   903  * The cruise altitude is determined by the velocity of the vehicle
       
   904  * and the direction it is moving
       
   905  * @param v The vehicle. Should be an aircraft
       
   906  * @returns Altitude in pixel units
       
   907  */
   902 static byte GetAircraftFlyingAltitude(const Vehicle *v)
   908 static byte GetAircraftFlyingAltitude(const Vehicle *v)
   903 {
   909 {
   904 	switch (v->max_speed) {
   910 	/* Make sure Aircraft fly no lower so that they don't conduct
   905 		case 37: return 162;
   911 	 * CFITs (controlled flight into terrain)
   906 		case 74: return 171;
   912 	 */
   907 		default: return 180;
   913 	byte base_altitude = 150;
   908 	}
   914 
       
   915 	/* Make sure eastbound and westbound planes do not "crash" into each
       
   916 	 * other by providing them with vertical seperation
       
   917 	 */
       
   918 	switch (v->direction) {
       
   919 		case DIR_N: case DIR_NE: case DIR_E: case DIR_SE: base_altitude += 15; break;
       
   920 		default: break;
       
   921 	}
       
   922 
       
   923 	/* Make faster planes fly higher so that they can overtake slower ones */
       
   924 	base_altitude += min(30 * (v->max_speed / 37), 90);
       
   925 
       
   926 	return base_altitude;
   909 }
   927 }
   910 
   928 
   911 static bool AircraftController(Vehicle *v)
   929 static bool AircraftController(Vehicle *v)
   912 {
   930 {
   913 	Station *st;
   931 	Station *st;