ai.c
changeset 192 614bba52258d
parent 159 139cf78bfb28
child 193 0a7025304867
--- a/ai.c	Fri Sep 10 18:19:06 2004 +0000
+++ b/ai.c	Fri Sep 10 18:54:23 2004 +0000
@@ -13,6 +13,7 @@
 
 // remove some day perhaps?
 static Player *_cur_ai_player;
+static uint _ai_service_interval;
 
 typedef void AiStateAction(Player *p);
 
@@ -301,8 +302,8 @@
 			veh = _new_train_id;
 			AiRestoreVehicleOrders(&_vehicles[veh], orderbak);
 			DoCommandByTile(0, veh, 0, DC_EXEC, CMD_START_STOP_TRAIN);
-			// Force the service interval to 180 days.. else things can go very wrong :p
-			DoCommandByTile(0, veh, 180, DC_EXEC, CMD_CHANGE_TRAIN_SERVICE_INT);
+
+			DoCommandByTile(0, veh, _ai_service_interval, DC_EXEC, CMD_CHANGE_TRAIN_SERVICE_INT);
 		}
 	}
 }
@@ -329,8 +330,8 @@
 			veh = _new_roadveh_id;
 			AiRestoreVehicleOrders(&_vehicles[veh], orderbak);
 			DoCommandByTile(0, veh, 0, DC_EXEC, CMD_START_STOP_ROADVEH);
-			// Force the service interval to 180 days.. else things can go very wrong :p
-			DoCommandByTile(0, veh, 180, DC_EXEC, CMD_CHANGE_ROADVEH_SERVICE_INT);
+
+			DoCommandByTile(0, veh, _ai_service_interval, DC_EXEC, CMD_CHANGE_TRAIN_SERVICE_INT);
 		}
 	}
 }
@@ -357,8 +358,8 @@
 			veh = _new_aircraft_id;
 			AiRestoreVehicleOrders(&_vehicles[veh], orderbak);
 			DoCommandByTile(0, veh, 0, DC_EXEC, CMD_START_STOP_AIRCRAFT);
-			// Force the service interval to 180 days.. else things can go very wrong :p
-			DoCommandByTile(0, veh, 180, DC_EXEC, CMD_CHANGE_AIRCRAFT_SERVICE_INT);
+
+			DoCommandByTile(0, veh, _ai_service_interval, DC_EXEC, CMD_CHANGE_TRAIN_SERVICE_INT);
 		}
 	}
 }
@@ -2432,8 +2433,8 @@
 	}
 
 	DoCommandByTile(0, loco_id, 0, DC_EXEC, CMD_START_STOP_TRAIN);
-	// Force the service interval to 180 days.. else things can go very wrong :p
-	DoCommandByTile(0, loco_id, 180, DC_EXEC, CMD_CHANGE_TRAIN_SERVICE_INT);
+
+	DoCommandByTile(0, loco_id, _ai_service_interval, DC_EXEC, CMD_CHANGE_TRAIN_SERVICE_INT);
 
 	if (p->ai.num_want_fullload != 0)
 		p->ai.num_want_fullload--;
@@ -3179,8 +3180,8 @@
 	}
 
 	DoCommandByTile(0, loco_id, 0, DC_EXEC, CMD_START_STOP_ROADVEH);
-	// Force the service interval to 180 days.. else things can go very wrong :p
-	DoCommandByTile(0, loco_id, 180, DC_EXEC, CMD_CHANGE_ROADVEH_SERVICE_INT);
+
+	DoCommandByTile(0, loco_id, _ai_service_interval, DC_EXEC, CMD_CHANGE_TRAIN_SERVICE_INT);
 
 	if (p->ai.num_want_fullload != 0)
 		p->ai.num_want_fullload--;
@@ -3487,8 +3488,8 @@
 	}
 
 	DoCommandByTile(0, loco_id, 0, DC_EXEC, CMD_START_STOP_AIRCRAFT);
-	// Force the service interval to 180 days.. else things can go very wrong :p
-	DoCommandByTile(0, loco_id, 180, DC_EXEC, CMD_CHANGE_AIRCRAFT_SERVICE_INT);
+
+	DoCommandByTile(0, loco_id, _ai_service_interval, DC_EXEC, CMD_CHANGE_TRAIN_SERVICE_INT);
 
 	if (p->ai.num_want_fullload != 0)
 		p->ai.num_want_fullload--;
@@ -3883,6 +3884,12 @@
 		return;
 	}
 
+	// Ugly hack to make sure the service interval of the AI is good, not looking
+	//  to the patch-setting
+	// Also, it takes into account the setting if the service-interval is in days
+	//  or in %
+	_ai_service_interval = _patches.servint_ispercent?80:180;
+
 	if (IS_HUMAN_PLAYER(_current_player))
 		return;