summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ai.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/ai.c b/ai.c
index 5b1650f4d..a3dc2a173 100644
--- a/ai.c
+++ b/ai.c
@@ -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 *p)
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(Player *p)
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(Player *p)
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(Player *p)
}
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(Player *p)
}
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;