Changeset - r192:731807cde462
[Not reviewed]
master
0 1 0
truelight - 20 years ago 2004-09-10 18:54:23
truelight@openttd.org
(svn r193) -Fix: [OldAI] If service-interval is in %, it works correct now.
1 file changed with 19 insertions and 12 deletions:
ai.c
19
12
0 comments (0 inline, 0 general)
ai.c
Show inline comments
 
@@ -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 @@ static void AiHandleReplaceTrain(Player 
 
			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 @@ static void AiHandleReplaceRoadVeh(Playe
 
			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 @@ static void AiHandleReplaceAircraft(Play
 
			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 @@ handle_nocash:
 
	}
 

	
 
	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 @@ static void AiStateBuildRoadVehicles(Pla
 
	}
 

	
 
	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 @@ static void AiStateBuildAircraftVehicles
 
	}
 

	
 
	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 @@ void AiDoGameLoop(Player *p)
 
		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;
 

	
0 comments (0 inline, 0 general)