mirror of https://github.com/OpenTTD/OpenTTD
(svn r77) -Fix: [1010788] AI service interval bug (tnx truesatan)
-Add: AI overrides service interval to 180 days -Fix: AI hanged when all vehicles were disabled in Patch menurelease/0.4.5
parent
5e25a4ee79
commit
4b919416a2
16
ai.c
16
ai.c
|
@ -301,6 +301,8 @@ static void AiHandleReplaceTrain(Player *p)
|
||||||
veh = _new_train_id;
|
veh = _new_train_id;
|
||||||
AiRestoreVehicleOrders(&_vehicles[veh], orderbak);
|
AiRestoreVehicleOrders(&_vehicles[veh], orderbak);
|
||||||
DoCommandByTile(0, veh, 0, DC_EXEC, CMD_START_STOP_TRAIN);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -327,6 +329,8 @@ static void AiHandleReplaceRoadVeh(Player *p)
|
||||||
veh = _new_roadveh_id;
|
veh = _new_roadveh_id;
|
||||||
AiRestoreVehicleOrders(&_vehicles[veh], orderbak);
|
AiRestoreVehicleOrders(&_vehicles[veh], orderbak);
|
||||||
DoCommandByTile(0, veh, 0, DC_EXEC, CMD_START_STOP_ROADVEH);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -353,6 +357,8 @@ static void AiHandleReplaceAircraft(Player *p)
|
||||||
veh = _new_aircraft_id;
|
veh = _new_aircraft_id;
|
||||||
AiRestoreVehicleOrders(&_vehicles[veh], orderbak);
|
AiRestoreVehicleOrders(&_vehicles[veh], orderbak);
|
||||||
DoCommandByTile(0, veh, 0, DC_EXEC, CMD_START_STOP_AIRCRAFT);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1492,6 +1498,10 @@ static void AiStateWantNewRoute(Player *p)
|
||||||
for(;;) {
|
for(;;) {
|
||||||
r = (uint16)Random();
|
r = (uint16)Random();
|
||||||
|
|
||||||
|
if (_patches.ai_disable_veh_train && _patches.ai_disable_veh_roadveh &&
|
||||||
|
_patches.ai_disable_veh_aircraft && _patches.ai_disable_veh_ship)
|
||||||
|
return;
|
||||||
|
|
||||||
if (r < 0x7626) {
|
if (r < 0x7626) {
|
||||||
if (_patches.ai_disable_veh_train) continue;
|
if (_patches.ai_disable_veh_train) continue;
|
||||||
AiWantTrainRoute(p);
|
AiWantTrainRoute(p);
|
||||||
|
@ -2422,6 +2432,8 @@ handle_nocash:
|
||||||
}
|
}
|
||||||
|
|
||||||
DoCommandByTile(0, loco_id, 0, DC_EXEC, CMD_START_STOP_TRAIN);
|
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);
|
||||||
|
|
||||||
if (p->ai.num_want_fullload != 0)
|
if (p->ai.num_want_fullload != 0)
|
||||||
p->ai.num_want_fullload--;
|
p->ai.num_want_fullload--;
|
||||||
|
@ -3167,6 +3179,8 @@ static void AiStateBuildRoadVehicles(Player *p)
|
||||||
}
|
}
|
||||||
|
|
||||||
DoCommandByTile(0, loco_id, 0, DC_EXEC, CMD_START_STOP_ROADVEH);
|
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);
|
||||||
|
|
||||||
if (p->ai.num_want_fullload != 0)
|
if (p->ai.num_want_fullload != 0)
|
||||||
p->ai.num_want_fullload--;
|
p->ai.num_want_fullload--;
|
||||||
|
@ -3473,6 +3487,8 @@ static void AiStateBuildAircraftVehicles(Player *p)
|
||||||
}
|
}
|
||||||
|
|
||||||
DoCommandByTile(0, loco_id, 0, DC_EXEC, CMD_START_STOP_AIRCRAFT);
|
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);
|
||||||
|
|
||||||
if (p->ai.num_want_fullload != 0)
|
if (p->ai.num_want_fullload != 0)
|
||||||
p->ai.num_want_fullload--;
|
p->ai.num_want_fullload--;
|
||||||
|
|
|
@ -525,7 +525,7 @@ static void CheckIfAircraftNeedsService(Vehicle *v)
|
||||||
{
|
{
|
||||||
Station *st;
|
Station *st;
|
||||||
|
|
||||||
if (_patches.servint_aircraft == 0 && IS_HUMAN_PLAYER(v->owner))
|
if (_patches.servint_aircraft == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (v->date_of_last_service + v->service_interval > _date)
|
if (v->date_of_last_service + v->service_interval > _date)
|
||||||
|
@ -537,7 +537,7 @@ static void CheckIfAircraftNeedsService(Vehicle *v)
|
||||||
if ((v->next_order & (OT_MASK | OF_FULL_LOAD)) == (OT_GOTO_DEPOT | OF_FULL_LOAD))
|
if ((v->next_order & (OT_MASK | OF_FULL_LOAD)) == (OT_GOTO_DEPOT | OF_FULL_LOAD))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_patches.gotodepot && IS_HUMAN_PLAYER(v->owner) && ScheduleHasDepotOrders(v->schedule_ptr))
|
if (_patches.gotodepot && ScheduleHasDepotOrders(v->schedule_ptr))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
st = DEREF_STATION(v->next_order_param);
|
st = DEREF_STATION(v->next_order_param);
|
||||||
|
|
|
@ -1497,7 +1497,7 @@ static void CheckIfRoadVehNeedsService(Vehicle *v)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (_patches.servint_roadveh == 0 && IS_HUMAN_PLAYER(v->owner))
|
if (_patches.servint_roadveh == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (v->date_of_last_service + v->service_interval > _date)
|
if (v->date_of_last_service + v->service_interval > _date)
|
||||||
|
@ -1506,7 +1506,7 @@ static void CheckIfRoadVehNeedsService(Vehicle *v)
|
||||||
if (v->vehstatus & VS_STOPPED)
|
if (v->vehstatus & VS_STOPPED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_patches.gotodepot && IS_HUMAN_PLAYER(v->owner) && ScheduleHasDepotOrders(v->schedule_ptr))
|
if (_patches.gotodepot && ScheduleHasDepotOrders(v->schedule_ptr))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Don't interfere with a depot visit scheduled by the user, or a
|
// Don't interfere with a depot visit scheduled by the user, or a
|
||||||
|
|
|
@ -85,7 +85,7 @@ static void CheckIfShipNeedsService(Vehicle *v)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (_patches.servint_ships == 0 && IS_HUMAN_PLAYER(v->owner))
|
if (_patches.servint_ships == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (v->date_of_last_service + v->service_interval > _date)
|
if (v->date_of_last_service + v->service_interval > _date)
|
||||||
|
@ -97,7 +97,7 @@ static void CheckIfShipNeedsService(Vehicle *v)
|
||||||
if ((v->next_order & (OT_MASK | OF_FULL_LOAD)) == (OT_GOTO_DEPOT | OF_FULL_LOAD))
|
if ((v->next_order & (OT_MASK | OF_FULL_LOAD)) == (OT_GOTO_DEPOT | OF_FULL_LOAD))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_patches.gotodepot && IS_HUMAN_PLAYER(v->owner) && ScheduleHasDepotOrders(v->schedule_ptr))
|
if (_patches.gotodepot && ScheduleHasDepotOrders(v->schedule_ptr))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
i = FindClosestShipDepot(v);
|
i = FindClosestShipDepot(v);
|
||||||
|
|
|
@ -2520,7 +2520,7 @@ static void CheckIfTrainNeedsService(Vehicle *v)
|
||||||
uint tile;
|
uint tile;
|
||||||
byte depot;
|
byte depot;
|
||||||
|
|
||||||
if (_patches.servint_trains == 0 && IS_HUMAN_PLAYER(v->owner))
|
if (_patches.servint_trains == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (v->date_of_last_service + v->service_interval > _date)
|
if (v->date_of_last_service + v->service_interval > _date)
|
||||||
|
@ -2529,7 +2529,7 @@ static void CheckIfTrainNeedsService(Vehicle *v)
|
||||||
if (v->vehstatus & VS_STOPPED)
|
if (v->vehstatus & VS_STOPPED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_patches.gotodepot && IS_HUMAN_PLAYER(v->owner) && ScheduleHasDepotOrders(v->schedule_ptr))
|
if (_patches.gotodepot && ScheduleHasDepotOrders(v->schedule_ptr))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Don't interfere with a depot visit scheduled by the user, or a
|
// Don't interfere with a depot visit scheduled by the user, or a
|
||||||
|
|
Loading…
Reference in New Issue