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