(svn r1640) fix: now helicopters will use a hangar in schedule to be replaced in, even if they are only set to service there. Since helicopters are serviced at helipads, they will only go there if they needs to be replaced or renewed.
authorbjarni
Mon, 24 Jan 2005 18:21:23 +0000
changeset 1139 c63f257aa7fb
parent 1138 b0926a703887
child 1140 c53b2b8a000c
(svn r1640) fix: now helicopters will use a hangar in schedule to be replaced in, even if they are only set to service there. Since helicopters are serviced at helipads, they will only go there if they needs to be replaced or renewed.
aircraft_cmd.c
vehicle.c
vehicle.h
--- a/aircraft_cmd.c	Mon Jan 24 17:49:22 2005 +0000
+++ b/aircraft_cmd.c	Mon Jan 24 18:21:23 2005 +0000
@@ -363,6 +363,8 @@
 
 	v = GetVehicle(p1);
 
+	if (p2 != 0) v->set_for_replacement = true; //now all clients knows that the vehicle wants to be replaced
+
 	if (!CheckOwnership(v->owner))
 		return CMD_ERROR;
 
@@ -1030,7 +1032,8 @@
 
 	if (v->current_order.type == OT_GOTO_DEPOT &&
 			(v->current_order.flags & (OF_UNLOAD | OF_FULL_LOAD)) == (OF_UNLOAD | OF_FULL_LOAD) &&
- 			!VehicleNeedsService(v)) {
+ 			!VehicleNeedsService(v) &&
+			v->set_for_replacement == false) {
  		v->cur_order_index++;
  	}
 
@@ -1434,8 +1437,8 @@
 	AircraftNextAirportPos_and_Order(v);
 
 	// check if the aircraft needs to be replaced or renewed and send it to a hangar if needed
-	if ((v->owner == _local_player && _autoreplace_array[v->engine_type] != v->engine_type) ||
-		(v->owner == _local_player && _patches.autorenew && v->age - v->max_age > (_patches.autorenew_months * 30))) {
+	if (v->current_order.type != OT_GOTO_DEPOT && ((v->owner == _local_player && _autoreplace_array[v->engine_type] != v->engine_type) ||
+		(v->owner == _local_player && _patches.autorenew && v->age - v->max_age > (_patches.autorenew_months * 30)))) {
 		_current_player = _local_player;
 		DoCommandP(v->tile, v->index, 1, NULL, CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_SHOW_NO_ERROR);
 		_current_player = OWNER_NONE;
--- a/vehicle.c	Mon Jan 24 17:49:22 2005 +0000
+++ b/vehicle.c	Mon Jan 24 18:21:23 2005 +0000
@@ -194,6 +194,7 @@
 	v->string_id = 0;
 	v->next_shared = NULL;
 	v->prev_shared = NULL;
+	v->set_for_replacement = false;
 	/* random_bits is used to pick out a random sprite for vehicles
 	    which are technical the same (newgrf stuff).
 	   Because RandomRange() results in desyncs, and because it does
@@ -1422,6 +1423,7 @@
 		Engine *e;
 		e = DEREF_ENGINE(new_engine_type);
 
+		v->set_for_replacement = false;
 		v->reliability = e->reliability;
 		v->reliability_spd_dec = e->reliability_spd_dec;
 		v->age = 0;
--- a/vehicle.h	Mon Jan 24 17:49:22 2005 +0000
+++ b/vehicle.h	Mon Jan 24 18:21:23 2005 +0000
@@ -180,6 +180,8 @@
 	int32 profit_last_year;
 	uint32 value;
 
+	bool set_for_replacement;   // marks this vehicle to be replaced
+
 	union {
 		VehicleRail rail;
 		VehicleAir air;