4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
10 AILog
.Info("0.7 API compatibility in effect:");
11 AILog
.Info(" - AITown::GetLastMonthProduction's behaviour has slightly changed.");
12 AILog
.Info(" - AISubsidy::GetDestination returns STATION_INVALID for awarded subsidies.");
13 AILog
.Info(" - AISubsidy::GetSource returns STATION_INVALID for awarded subsidies.");
15 AISign
.GetMaxSignID
<- function()
17 local list
= AISignList();
19 foreach (id
, d
in list
) {
20 if (id
> max_id
) max_id
= id
;
25 AITile
.GetHeight
<- function(tile
)
27 if (!AIMap
.IsValidTile(tile
)) return -1;
29 return AITile
.GetCornerHeight(tile
, AITile
.CORNER_N
);
32 AIOrder
.ChangeOrder
<- function(vehicle_id
, order_position
, order_flags
)
34 return AIOrder
.SetOrderFlags(vehicle_id
, order_position
, order_flags
);
37 AIWaypoint
.WAYPOINT_INVALID
<- 0xFFFF;
39 AISubsidy
.SourceIsTown
<- function(subsidy_id
)
41 if (!AISubsidy
.IsValidSubsidy(subsidy_id
) || AISubsidy
.IsAwarded(subsidy_id
)) return false
;
43 return AISubsidy
.GetSourceType(subsidy_id
) == AISubsidy
.SPT_TOWN
;
46 AISubsidy
.GetSource
<- function(subsidy_id
)
48 if (!AISubsidy
.IsValidSubsidy(subsidy_id
)) return AIBaseStation
.STATION_INVALID
;
50 if (AISubsidy
.IsAwarded(subsidy_id
)) {
51 return AIBaseStation
.STATION_INVALID
;
54 return AISubsidy
.GetSourceIndex(subsidy_id
);
57 AISubsidy
.DestinationIsTown
<- function(subsidy_id
)
59 if (!AISubsidy
.IsValidSubsidy(subsidy_id
) || AISubsidy
.IsAwarded(subsidy_id
)) return false
;
61 return AISubsidy
.GetDestinationType(subsidy_id
) == AISubsidy
.SPT_TOWN
;
64 AISubsidy
.GetDestination
<- function(subsidy_id
)
66 if (!AISubsidy
.IsValidSubsidy(subsidy_id
)) return AIBaseStation
.STATION_INVALID
;
68 if (AISubsidy
.IsAwarded(subsidy_id
)) {
69 return AIBaseStation
.STATION_INVALID
;
72 return AISubsidy
.GetDestinationIndex(subsidy_id
);
75 AITown
.GetMaxProduction
<- function(town_id
, cargo_id
)
77 return AITown
.GetLastMonthProduction(town_id
, cargo_id
);
80 AIRail
.RemoveRailWaypoint
<- function(tile
)
82 return AIRail
.RemoveRailWaypointTileRect(tile
, tile
, true
);
85 AIRail
.RemoveRailStationTileRect
<- function(tile
, tile2
)
87 return AIRail
.RemoveRailStationTileRectangle(tile
, tile2
, false
);
90 AIVehicle
.SkipToVehicleOrder
<- function(vehicle_id
, order_position
)
92 return AIOrder
.SkipToOrder(vehicle_id
, order_position
);
95 AIEngine
.IsValidEngine
<- function(engine_id
)
97 return AIEngine
.IsBuildable(engine_id
);
100 AIEngine
._GetName
<- AIEngine
.GetName
;
101 AIEngine
.GetName
<- function(engine_id
)
103 if (!AIEngine
.IsBuildable(engine_id
)) return null;
104 return AIEngine
._GetName(engine_id
);
107 AIEngine
._GetCargoType
<- AIEngine
.GetCargoType
;
108 AIEngine
.GetCargoType
<- function(engine_id
)
110 if (!AIEngine
.IsBuildable(engine_id
)) return 255;
111 return AIEngine
._GetCargoType(engine_id
);
114 AIEngine
._CanRefitCargo
<- AIEngine
.CanRefitCargo
;
115 AIEngine
.CanRefitCargo
<- function(engine_id
, cargo_id
)
117 if (!AIEngine
.IsBuildable(engine_id
)) return false
;
118 return AIEngine
._CanRefitCargo(engine_id
, cargo_id
);
121 AIEngine
._CanPullCargo
<- AIEngine
.CanPullCargo
;
122 AIEngine
.CanPullCargo
<- function(engine_id
, cargo_id
)
124 if (!AIEngine
.IsBuildable(engine_id
)) return false
;
125 return AIEngine
._CanPullCargo(engine_id
, cargo_id
);
128 AIEngine
._GetCapacity
<- AIEngine
.GetCapacity
;
129 AIEngine
.GetCapacity
<- function(engine_id
)
131 if (!AIEngine
.IsBuildable(engine_id
)) return -1;
132 return AIEngine
._GetCapacity(engine_id
);
135 AIEngine
._GetReliability
<- AIEngine
.GetReliability
;
136 AIEngine
.GetReliability
<- function(engine_id
)
138 if (!AIEngine
.IsBuildable(engine_id
)) return -1;
139 return AIEngine
._GetReliability(engine_id
);
142 AIEngine
._GetMaxSpeed
<- AIEngine
.GetMaxSpeed
;
143 AIEngine
.GetMaxSpeed
<- function(engine_id
)
145 if (!AIEngine
.IsBuildable(engine_id
)) return -1;
146 return AIEngine
._GetMaxSpeed(engine_id
);
149 AIEngine
._GetPrice
<- AIEngine
.GetPrice
;
150 AIEngine
.GetPrice
<- function(engine_id
)
152 if (!AIEngine
.IsBuildable(engine_id
)) return -1;
153 return AIEngine
._GetPrice(engine_id
);
156 AIEngine
._GetMaxAge
<- AIEngine
.GetMaxAge
;
157 AIEngine
.GetMaxAge
<- function(engine_id
)
159 if (!AIEngine
.IsBuildable(engine_id
)) return -1;
160 return AIEngine
._GetMaxAge(engine_id
);
163 AIEngine
._GetRunningCost
<- AIEngine
.GetRunningCost
;
164 AIEngine
.GetRunningCost
<- function(engine_id
)
166 if (!AIEngine
.IsBuildable(engine_id
)) return -1;
167 return AIEngine
._GetRunningCost(engine_id
);
170 AIEngine
._GetPower
<- AIEngine
.GetPower
;
171 AIEngine
.GetPower
<- function(engine_id
)
173 if (!AIEngine
.IsBuildable(engine_id
)) return -1;
174 return AIEngine
._GetPower(engine_id
);
177 AIEngine
._GetWeight
<- AIEngine
.GetWeight
;
178 AIEngine
.GetWeight
<- function(engine_id
)
180 if (!AIEngine
.IsBuildable(engine_id
)) return -1;
181 return AIEngine
._GetWeight(engine_id
);
184 AIEngine
._GetMaxTractiveEffort
<- AIEngine
.GetMaxTractiveEffort
;
185 AIEngine
.GetMaxTractiveEffort
<- function(engine_id
)
187 if (!AIEngine
.IsBuildable(engine_id
)) return -1;
188 return AIEngine
._GetMaxTractiveEffort(engine_id
);
191 AIEngine
._GetDesignDate
<- AIEngine
.GetDesignDate
;
192 AIEngine
.GetDesignDate
<- function(engine_id
)
194 if (!AIEngine
.IsBuildable(engine_id
)) return -1;
195 return AIEngine
._GetDesignDate(engine_id
);
198 AIEngine
._GetVehicleType
<- AIEngine
.GetVehicleType
;
199 AIEngine
.GetVehicleType
<- function(engine_id
)
201 if (!AIEngine
.IsBuildable(engine_id
)) return AIVehicle
.VT_INVALID
;
202 return AIEngine
._GetVehicleType(engine_id
);
205 AIEngine
._IsWagon
<- AIEngine
.IsWagon
;
206 AIEngine
.IsWagon
<- function(engine_id
)
208 if (!AIEngine
.IsBuildable(engine_id
)) return false
;
209 return AIEngine
._IsWagon(engine_id
);
212 AIEngine
._CanRunOnRail
<- AIEngine
.CanRunOnRail
;
213 AIEngine
.CanRunOnRail
<- function(engine_id
, track_rail_type
)
215 if (!AIEngine
.IsBuildable(engine_id
)) return false
;
216 return AIEngine
._CanRunOnRail(engine_id
, track_rail_type
);
219 AIEngine
._HasPowerOnRail
<- AIEngine
.HasPowerOnRail
;
220 AIEngine
.HasPowerOnRail
<- function(engine_id
, track_rail_type
)
222 if (!AIEngine
.IsBuildable(engine_id
)) return false
;
223 return AIEngine
._HasPowerOnRail(engine_id
, track_rail_type
);
226 AIEngine
._GetRoadType
<- AIEngine
.GetRoadType
;
227 AIEngine
.GetRoadType
<- function(engine_id
)
229 if (!AIEngine
.IsBuildable(engine_id
)) return AIRoad
.ROADTYPE_INVALID
;
230 return AIEngine
._GetRoadType(engine_id
);
233 AIEngine
._GetRailType
<- AIEngine
.GetRailType
;
234 AIEngine
.GetRailType
<- function(engine_id
)
236 if (!AIEngine
.IsBuildable(engine_id
)) return AIRail
.RAILTYPE_INVALID
;
237 return AIEngine
._GetRailType(engine_id
);
240 AIEngine
._IsArticulated
<- AIEngine
.IsArticulated
;
241 AIEngine
.IsArticulated
<- function(engine_id
)
243 if (!AIEngine
.IsBuildable(engine_id
)) return false
;
244 return AIEngine
._IsArticulated(engine_id
);
247 AIEngine
._GetPlaneType
<- AIEngine
.GetPlaneType
;
248 AIEngine
.GetPlaneType
<- function(engine_id
)
250 if (!AIEngine
.IsBuildable(engine_id
)) return -1;
251 return AIEngine
._GetPlaneType(engine_id
);
254 _AIWaypointList
<- AIWaypointList
;
255 class AIWaypointList extends _AIWaypointList
{
258 ::_AIWaypointList
.constructor(AIWaypoint
.WAYPOINT_RAIL
);
262 AIRoad
._BuildRoadStation
<- AIRoad
.BuildRoadStation
;
263 AIRoad
.BuildRoadStation
<- function(tile
, front
, road_veh_type
, station_id
)
265 if (AIRoad
.IsRoadStationTile(tile
) && AICompany
.IsMine(AITile
.GetOwner(tile
))) return false
;
267 return AIRoad
._BuildRoadStation(tile
, front
, road_veh_type
, station_id
);
270 AIRoad
._BuildDriveThroughRoadStation
<- AIRoad
.BuildDriveThroughRoadStation
;
271 AIRoad
.BuildDriveThroughRoadStation
<- function(tile
, front
, road_veh_type
, station_id
)
273 if (AIRoad
.IsRoadStationTile(tile
) && AICompany
.IsMine(AITile
.GetOwner(tile
))) return false
;
275 return AIRoad
._BuildDriveThroughRoadStation(tile
, front
, road_veh_type
, station_id
);
278 AIBridgeList
.HasNext
<-
279 AIBridgeList_Length
.HasNext
<-
280 AICargoList
.HasNext
<-
281 AICargoList_IndustryAccepting
.HasNext
<-
282 AICargoList_IndustryProducing
.HasNext
<-
283 AIDepotList
.HasNext
<-
284 AIEngineList
.HasNext
<-
285 AIGroupList
.HasNext
<-
286 AIIndustryList
.HasNext
<-
287 AIIndustryList_CargoAccepting
.HasNext
<-
288 AIIndustryList_CargoProducing
.HasNext
<-
289 AIIndustryTypeList
.HasNext
<-
291 AIRailTypeList
.HasNext
<-
292 AISignList
.HasNext
<-
293 AIStationList
.HasNext
<-
294 AIStationList_Vehicle
.HasNext
<-
295 AISubsidyList
.HasNext
<-
296 AITileList
.HasNext
<-
297 AITileList_IndustryAccepting
.HasNext
<-
298 AITileList_IndustryProducing
.HasNext
<-
299 AITileList_StationType
.HasNext
<-
300 AITownList
.HasNext
<-
301 AIVehicleList
.HasNext
<-
302 AIVehicleList_DefaultGroup
.HasNext
<-
303 AIVehicleList_Group
.HasNext
<-
304 AIVehicleList_SharedOrders
.HasNext
<-
305 AIVehicleList_Station
.HasNext
<-
306 AIWaypointList
.HasNext
<-
307 AIWaypointList_Vehicle
.HasNext
<-
310 return !this.IsEnd();
313 AIIndustry
._IsCargoAccepted
<- AIIndustry
.IsCargoAccepted
;
314 AIIndustry
.IsCargoAccepted
<- function(industry_id
, cargo_id
)
316 return AIIndustry
._IsCargoAccepted(industry_id
, cargo_id
) != AIIndustry
.CAS_NOT_ACCEPTED
;
319 AIAbstractList
<- AIList
;
321 AIList
.ChangeItem
<- AIList
.SetValue
;
323 AIRail
.ERR_NONUNIFORM_STATIONS_DISABLED
<- 0xFFFF;
325 AICompany
.GetCompanyValue
<- function(company
)
327 return AICompany
.GetQuarterlyCompanyValue(company
, AICompany
.CURRENT_QUARTER
);
330 AITown
.GetLastMonthTransported
<- AITown
.GetLastMonthSupplied
;
332 AIEvent
.AI_ET_INVALID
<- AIEvent
.ET_INVALID
;
333 AIEvent
.AI_ET_TEST
<- AIEvent
.ET_TEST
;
334 AIEvent
.AI_ET_SUBSIDY_OFFER
<- AIEvent
.ET_SUBSIDY_OFFER
;
335 AIEvent
.AI_ET_SUBSIDY_OFFER_EXPIRED
<- AIEvent
.ET_SUBSIDY_OFFER_EXPIRED
;
336 AIEvent
.AI_ET_SUBSIDY_AWARDED
<- AIEvent
.ET_SUBSIDY_AWARDED
;
337 AIEvent
.AI_ET_SUBSIDY_EXPIRED
<- AIEvent
.ET_SUBSIDY_EXPIRED
;
338 AIEvent
.AI_ET_ENGINE_PREVIEW
<- AIEvent
.ET_ENGINE_PREVIEW
;
339 AIEvent
.AI_ET_COMPANY_NEW
<- AIEvent
.ET_COMPANY_NEW
;
340 AIEvent
.AI_ET_COMPANY_IN_TROUBLE
<- AIEvent
.ET_COMPANY_IN_TROUBLE
;
341 AIEvent
.AI_ET_COMPANY_MERGER
<- AIEvent
.ET_COMPANY_MERGER
;
342 AIEvent
.AI_ET_COMPANY_BANKRUPT
<- AIEvent
.ET_COMPANY_BANKRUPT
;
343 AIEvent
.AI_ET_VEHICLE_CRASHED
<- AIEvent
.ET_VEHICLE_CRASHED
;
344 AIEvent
.AI_ET_VEHICLE_LOST
<- AIEvent
.ET_VEHICLE_LOST
;
345 AIEvent
.AI_ET_VEHICLE_WAITING_IN_DEPOT
<- AIEvent
.ET_VEHICLE_WAITING_IN_DEPOT
;
346 AIEvent
.AI_ET_VEHICLE_UNPROFITABLE
<- AIEvent
.ET_VEHICLE_UNPROFITABLE
;
347 AIEvent
.AI_ET_INDUSTRY_OPEN
<- AIEvent
.ET_INDUSTRY_OPEN
;
348 AIEvent
.AI_ET_INDUSTRY_CLOSE
<- AIEvent
.ET_INDUSTRY_CLOSE
;
349 AIEvent
.AI_ET_ENGINE_AVAILABLE
<- AIEvent
.ET_ENGINE_AVAILABLE
;
350 AIEvent
.AI_ET_STATION_FIRST_VEHICLE
<- AIEvent
.ET_STATION_FIRST_VEHICLE
;
351 AIEvent
.AI_ET_DISASTER_ZEPPELINER_CRASHED
<- AIEvent
.ET_DISASTER_ZEPPELINER_CRASHED
;
352 AIEvent
.AI_ET_DISASTER_ZEPPELINER_CLEARED
<- AIEvent
.ET_DISASTER_ZEPPELINER_CLEARED
;
353 AIOrder
.AIOF_NONE
<- AIOrder
.OF_NONE
354 AIOrder
.AIOF_NON_STOP_INTERMEDIATE
<- AIOrder
.OF_NON_STOP_INTERMEDIATE
355 AIOrder
.AIOF_NON_STOP_DESTINATION
<- AIOrder
.OF_NON_STOP_DESTINATION
356 AIOrder
.AIOF_UNLOAD
<- AIOrder
.OF_UNLOAD
357 AIOrder
.AIOF_TRANSFER
<- AIOrder
.OF_TRANSFER
358 AIOrder
.AIOF_NO_UNLOAD
<- AIOrder
.OF_NO_UNLOAD
359 AIOrder
.AIOF_FULL_LOAD
<- AIOrder
.OF_FULL_LOAD
360 AIOrder
.AIOF_FULL_LOAD_ANY
<- AIOrder
.OF_FULL_LOAD_ANY
361 AIOrder
.AIOF_NO_LOAD
<- AIOrder
.OF_NO_LOAD
362 AIOrder
.AIOF_SERVICE_IF_NEEDED
<- AIOrder
.OF_SERVICE_IF_NEEDED
363 AIOrder
.AIOF_STOP_IN_DEPOT
<- AIOrder
.OF_STOP_IN_DEPOT
364 AIOrder
.AIOF_GOTO_NEAREST_DEPOT
<- AIOrder
.OF_GOTO_NEAREST_DEPOT
365 AIOrder
.AIOF_NON_STOP_FLAGS
<- AIOrder
.OF_NON_STOP_FLAGS
366 AIOrder
.AIOF_UNLOAD_FLAGS
<- AIOrder
.OF_UNLOAD_FLAGS
367 AIOrder
.AIOF_LOAD_FLAGS
<- AIOrder
.OF_LOAD_FLAGS
368 AIOrder
.AIOF_DEPOT_FLAGS
<- AIOrder
.OF_DEPOT_FLAGS
369 AIOrder
.AIOF_INVALID
<- AIOrder
.OF_INVALID