286 if (!Vehicle::AllocateList(vl, avi->subtype & AIR_CTOL ? 2 : 3)) { |
286 if (!Vehicle::AllocateList(vl, avi->subtype & AIR_CTOL ? 2 : 3)) { |
287 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
287 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
288 } |
288 } |
289 |
289 |
290 UnitID unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_AIRCRAFT); |
290 UnitID unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_AIRCRAFT); |
291 if (unit_num > _patches.max_aircraft) |
291 if (unit_num > _settings.vehicle.max_aircraft) |
292 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
292 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
293 |
293 |
294 if (flags & DC_EXEC) { |
294 if (flags & DC_EXEC) { |
295 Vehicle *v = vl[0]; // aircraft |
295 Vehicle *v = vl[0]; // aircraft |
296 Vehicle *u = vl[1]; // shadow |
296 Vehicle *u = vl[1]; // shadow |
403 v->u.air.state = HANGAR; |
403 v->u.air.state = HANGAR; |
404 v->u.air.previous_pos = v->u.air.pos; |
404 v->u.air.previous_pos = v->u.air.pos; |
405 v->u.air.targetairport = GetStationIndex(tile); |
405 v->u.air.targetairport = GetStationIndex(tile); |
406 v->SetNext(u); |
406 v->SetNext(u); |
407 |
407 |
408 v->service_interval = _patches.servint_aircraft; |
408 v->service_interval = _settings.vehicle.servint_aircraft; |
409 |
409 |
410 v->date_of_last_service = _date; |
410 v->date_of_last_service = _date; |
411 v->build_year = u->build_year = _cur_year; |
411 v->build_year = u->build_year = _cur_year; |
412 |
412 |
413 v->cur_image = u->cur_image = 0xEA0; |
413 v->cur_image = u->cur_image = 0xEA0; |
886 uint spd = v->acceleration * 16; |
886 uint spd = v->acceleration * 16; |
887 byte t; |
887 byte t; |
888 |
888 |
889 /* Adjust speed limits by plane speed factor to prevent taxiing |
889 /* Adjust speed limits by plane speed factor to prevent taxiing |
890 * and take-off speeds being too low. */ |
890 * and take-off speeds being too low. */ |
891 speed_limit *= _patches.plane_speed; |
891 speed_limit *= _settings.vehicle.plane_speed; |
892 |
892 |
893 if (v->u.air.cached_max_speed < speed_limit) { |
893 if (v->u.air.cached_max_speed < speed_limit) { |
894 if (v->cur_speed < speed_limit) hard_limit = false; |
894 if (v->cur_speed < speed_limit) hard_limit = false; |
895 speed_limit = v->u.air.cached_max_speed; |
895 speed_limit = v->u.air.cached_max_speed; |
896 } |
896 } |
904 * value 16384 was determined to give similar results to the old speed/48 |
904 * value 16384 was determined to give similar results to the old speed/48 |
905 * method at slower speeds. This also results in less reduction at slow |
905 * method at slower speeds. This also results in less reduction at slow |
906 * speeds to that aircraft do not get to taxi speed straight after |
906 * speeds to that aircraft do not get to taxi speed straight after |
907 * touchdown. */ |
907 * touchdown. */ |
908 if (!hard_limit && v->cur_speed > speed_limit) { |
908 if (!hard_limit && v->cur_speed > speed_limit) { |
909 speed_limit = v->cur_speed - max(1, ((v->cur_speed * v->cur_speed) / 16384) / _patches.plane_speed); |
909 speed_limit = v->cur_speed - max(1, ((v->cur_speed * v->cur_speed) / 16384) / _settings.vehicle.plane_speed); |
910 } |
910 } |
911 |
911 |
912 spd = min(v->cur_speed + (spd >> 8) + (v->subspeed < t), speed_limit); |
912 spd = min(v->cur_speed + (spd >> 8) + (v->subspeed < t), speed_limit); |
913 |
913 |
914 /* adjust speed for broken vehicles */ |
914 /* adjust speed for broken vehicles */ |
915 if (v->vehstatus & VS_AIRCRAFT_BROKEN) spd = min(spd, SPEED_LIMIT_BROKEN); |
915 if (v->vehstatus & VS_AIRCRAFT_BROKEN) spd = min(spd, SPEED_LIMIT_BROKEN); |
916 |
916 |
917 /* updates statusbar only if speed have changed to save CPU time */ |
917 /* updates statusbar only if speed have changed to save CPU time */ |
918 if (spd != v->cur_speed) { |
918 if (spd != v->cur_speed) { |
919 v->cur_speed = spd; |
919 v->cur_speed = spd; |
920 if (_patches.vehicle_speed) |
920 if (_settings.gui.vehicle_speed) |
921 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); |
921 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); |
922 } |
922 } |
923 |
923 |
924 /* Adjust distance moved by plane speed setting */ |
924 /* Adjust distance moved by plane speed setting */ |
925 if (_patches.plane_speed > 1) spd /= _patches.plane_speed; |
925 if (_settings.vehicle.plane_speed > 1) spd /= _settings.vehicle.plane_speed; |
926 |
926 |
927 if (!(v->direction & 1)) spd = spd * 3 / 4; |
927 if (!(v->direction & 1)) spd = spd * 3 / 4; |
928 |
928 |
929 spd += v->progress; |
929 spd += v->progress; |
930 v->progress = (byte)spd; |
930 v->progress = (byte)spd; |
1603 /* if we just arrived, execute EnterTerminal first */ |
1603 /* if we just arrived, execute EnterTerminal first */ |
1604 if (v->u.air.previous_pos != v->u.air.pos) { |
1604 if (v->u.air.previous_pos != v->u.air.pos) { |
1605 AircraftEventHandler_EnterTerminal(v, apc); |
1605 AircraftEventHandler_EnterTerminal(v, apc); |
1606 /* on an airport with helipads, a helicopter will always land there |
1606 /* on an airport with helipads, a helicopter will always land there |
1607 * and get serviced at the same time - patch setting */ |
1607 * and get serviced at the same time - patch setting */ |
1608 if (_patches.serviceathelipad) { |
1608 if (_settings.order.serviceathelipad) { |
1609 if (v->subtype == AIR_HELICOPTER && apc->helipads != NULL) { |
1609 if (v->subtype == AIR_HELICOPTER && apc->helipads != NULL) { |
1610 /* an exerpt of ServiceAircraft, without the invisibility stuff */ |
1610 /* an exerpt of ServiceAircraft, without the invisibility stuff */ |
1611 v->date_of_last_service = _date; |
1611 v->date_of_last_service = _date; |
1612 v->breakdowns_since_last_service = 0; |
1612 v->breakdowns_since_last_service = 0; |
1613 v->reliability = GetEngine(v->engine_type)->reliability; |
1613 v->reliability = GetEngine(v->engine_type)->reliability; |