equal
deleted
inserted
replaced
269 |
269 |
270 /** Build an aircraft. |
270 /** Build an aircraft. |
271 * @param tile tile of depot where aircraft is built |
271 * @param tile tile of depot where aircraft is built |
272 * @param flags for command |
272 * @param flags for command |
273 * @param p1 aircraft type being built (engine) |
273 * @param p1 aircraft type being built (engine) |
274 * @param p2 bit 0 when set, the unitnumber will be 0, otherwise it will be a free number |
274 * @param p2 unused |
275 * return result of operation. Could be cost, error |
275 * return result of operation. Could be cost, error |
276 */ |
276 */ |
277 CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
277 CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
278 { |
278 { |
279 if (!IsEngineBuildable(p1, VEH_AIRCRAFT, _current_player)) return_cmd_error(STR_AIRCRAFT_NOT_AVAILABLE); |
279 if (!IsEngineBuildable(p1, VEH_AIRCRAFT, _current_player)) return_cmd_error(STR_AIRCRAFT_NOT_AVAILABLE); |
294 Vehicle *vl[3]; |
294 Vehicle *vl[3]; |
295 if (!Vehicle::AllocateList(vl, avi->subtype & AIR_CTOL ? 2 : 3)) { |
295 if (!Vehicle::AllocateList(vl, avi->subtype & AIR_CTOL ? 2 : 3)) { |
296 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
296 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
297 } |
297 } |
298 |
298 |
299 UnitID unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_AIRCRAFT); |
299 UnitID unit_num = (flags & DC_AUTOREPLACE) ? 0 : GetFreeUnitNumber(VEH_AIRCRAFT); |
300 if (unit_num > _patches.max_aircraft) |
300 if (unit_num > _patches.max_aircraft) |
301 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
301 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
302 |
302 |
303 if (flags & DC_EXEC) { |
303 if (flags & DC_EXEC) { |
304 Vehicle *v = vl[0]; // aircraft |
304 Vehicle *v = vl[0]; // aircraft |