Index: aircraft_cmd.c
===================================================================
--- aircraft_cmd.c	(revision 750)
+++ aircraft_cmd.c	(working copy)
@@ -171,6 +171,11 @@
 	return success;
 }
 
+static int32 EstimateAircraftCost(uint16 engine_type)
+{
+	return _aircraft_cost_table[engine_type - AIRCRAFT_ENGINES_INDEX] * (_price.aircraft_base>>3)>>5;
+}
+
 /* p1 = engine */
 int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 {
@@ -182,8 +187,7 @@
 
 	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
 
-	value = _aircraft_cost_table[p1 - AIRCRAFT_ENGINES_INDEX] * (_price.aircraft_base>>3)>>5;
-
+	value = EstimateAircraftCost(p1);
 	if (flags & DC_QUERY_COST)
 		return value;
 
@@ -1202,6 +1206,9 @@
 	byte old_order;
 
 	ServiceAircraft(v);
+
+	MaybeRenewVehicle(v, EstimateAircraftCost(v->engine_type));
+
 	if ((v->next_order & OT_MASK) == OT_GOTO_DEPOT) {
 		InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 
Index: roadveh_cmd.c
===================================================================
--- roadveh_cmd.c	(revision 750)
+++ roadveh_cmd.c	(working copy)
@@ -190,6 +190,10 @@
 	DrawStringMultiCenter(x, y, STR_902A_COST_SPEED_RUNNING_COST, maxw);
 }
 
+static int32 EstimateRoadVehCost(byte engine_type)
+{
+	return ((_price.roadveh_base >> 3) * _roadveh_price[engine_type - ROAD_ENGINES_INDEX]) >> 5;
+}
 
 int32 CmdBuildRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 {
@@ -201,7 +205,7 @@
 	
 	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
 
-	cost = ((_price.roadveh_base >> 3) * _roadveh_price[p1 - ROAD_ENGINES_INDEX]) >> 5;
+	cost = EstimateRoadVehCost(p1);
 	if (flags & DC_QUERY_COST)
 		return cost;
 
@@ -1418,6 +1422,8 @@
 	v->reliability = _engines[v->engine_type].reliability;
 	InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
+	MaybeRenewVehicle(v, EstimateRoadVehCost(v->engine_type));
+
 	
 	if ((v->next_order&OT_MASK) == OT_GOTO_DEPOT) {
 		InvalidateWindow(WC_VEHICLE_VIEW, v->index);
Index: train_cmd.c
===================================================================
--- train_cmd.c	(revision 750)
+++ train_cmd.c	(working copy)
@@ -354,6 +354,11 @@
 };
 
 
+static int32 EstimateTrainCost(const RailVehicleInfo *rvi)
+{
+	return (rvi->base_cost * (_price.build_railvehicle >> 3)) >> 5;
+}
+
 /* Build a railroad vehicle
  * p1 = vehicle type id
  */
@@ -378,7 +383,7 @@
 		return CmdBuildRailWagon(p1, tile, flags);
 	}
 
-	value = (rvi->base_cost * (_price.build_railvehicle >> 3)) >> 5;
+	value = EstimateTrainCost(rvi);
 
 	if (!(flags & DC_QUERY_COST)) {
 		v = AllocateVehicle();
@@ -2414,6 +2419,8 @@
 	v->load_unload_time_rem = 0;
 	v->cur_speed = 0;
 
+	MaybeRenewVehicle(v, EstimateTrainCost(&_rail_vehicle_info[v->engine_type]));
+
 	if ((v->next_order&OT_MASK) == OT_GOTO_DEPOT) {
 		InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 	
Index: vehicle.c
===================================================================
--- vehicle.c	(revision 750)
+++ vehicle.c	(working copy)
@@ -8,6 +8,7 @@
 #include "command.h"
 #include "saveload.h"
 #include "player.h"
+#include "engine.h"
 
 #define INVALID_COORD (-0x8000)
 #define GEN_HASH(x,y) (((x & 0x1F80)>>7) + ((y & 0xFC0)))
@@ -1307,7 +1308,34 @@
 	}
 }
 
+void MaybeRenewVehicle(Vehicle *v, int32 build_cost)
+{
+	Engine *e;
 
+	// When automatically renewing a vehicle we want to prevent the
+	// "getting old" messages so we renew it if it won't enter the
+	// depot during the next service sooner than half a year before
+	// the vehicle getting old (that's one year before it reaches
+	// the max_age, see AgeVehicle).
+	if (!(_patches.autorenew && v->max_age - v->age < 366 + 183 + v->service_interval))
+		return;
+
+	e = &_engines[v->engine_type];
+	v->reliability = e->reliability;
+	v->reliability_spd_dec = e->reliability_spd_dec;
+	v->age = 0;
+
+	v->date_of_last_service = _date;
+	v->build_year = _cur_year;
+
+	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
+	SubtractMoneyFromPlayer(build_cost - v->value);
+	v->value = build_cost;
+	
+	InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
+}
+
+
 int32 CmdNameVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 {
 	Vehicle *v;
Index: vehicle.h
===================================================================
--- vehicle.h	(revision 750)
+++ vehicle.h	(working copy)
@@ -309,6 +310,7 @@
 void DecreaseVehicleValue(Vehicle *v);
 void CheckVehicleBreakdown(Vehicle *v);
 void AgeVehicle(Vehicle *v);
+void MaybeRenewVehicle(Vehicle *v, int32 build_cost);
 
 void DeleteCommandFromVehicleSchedule(uint cmd);
 
Index: ship_cmd.c
===================================================================
--- ship_cmd.c	(revision 750)
+++ ship_cmd.c	(working copy)
@@ -367,6 +367,8 @@
 }
 
 
+static int32 EstimateShipCost(uint16 engine_type);
+
 static void ShipEnterDepot(Vehicle *v)
 {
 	byte t;
@@ -381,6 +383,7 @@
 	v->reliability = _engines[v->engine_type].reliability;
 	InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
+	MaybeRenewVehicle(v, EstimateShipCost(v->engine_type));
 
 	if ((v->next_order&OT_MASK) == OT_GOTO_DEPOT) {
 		InvalidateWindow(WC_VEHICLE_VIEW, v->index);
@@ -771,8 +774,12 @@
 	}
 }
 
+static int32 EstimateShipCost(uint16 engine_type)
+{
+	return ship_vehicle_info(engine_type).base_cost * (_price.ship_base>>3)>>5;
+}
+
 // p1 = type to build
-
 int32 CmdBuildShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 {
 	int32 value;
@@ -783,7 +790,7 @@
 	
 	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
 
-	value = ship_vehicle_info(p1).base_cost * (_price.ship_base>>3)>>5;
+	value = EstimateShipCost(p1);
 	if (flags & DC_QUERY_COST)
 		return value;
 
