src/aircraft_cmd.cpp
branchnoai
changeset 9704 197cb8c6ae17
parent 9703 d2a6acdbd665
child 9718 f82a4facea8b
equal deleted inserted replaced
9703:d2a6acdbd665 9704:197cb8c6ae17
   281 	if (!IsHangarTile(tile) || !IsTileOwner(tile, _current_player)) return CMD_ERROR;
   281 	if (!IsHangarTile(tile) || !IsTileOwner(tile, _current_player)) return CMD_ERROR;
   282 
   282 
   283 	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
   283 	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
   284 
   284 
   285 	/* Prevent building aircraft types at places which can't handle them */
   285 	/* Prevent building aircraft types at places which can't handle them */
   286 	if (!IsAircraftBuildableAtStation(p1, tile)) return CMD_ERROR;
   286 	if (!CanAircraftUseStation(p1, tile)) return CMD_ERROR;
   287 
   287 
   288 	/* Allocate 2 or 3 vehicle structs, depending on type
   288 	/* Allocate 2 or 3 vehicle structs, depending on type
   289 	 * vl[0] = aircraft, vl[1] = shadow, [vl[2] = rotor] */
   289 	 * vl[0] = aircraft, vl[1] = shadow, [vl[2] = rotor] */
   290 	Vehicle *vl[3];
   290 	Vehicle *vl[3];
   291 	if (!Vehicle::AllocateList(vl, avi->subtype & AIR_CTOL ? 2 : 3)) {
   291 	if (!Vehicle::AllocateList(vl, avi->subtype & AIR_CTOL ? 2 : 3)) {
   363 		if (cargo != CT_INVALID && cargo != CT_PASSENGERS) {
   363 		if (cargo != CT_INVALID && cargo != CT_PASSENGERS) {
   364 			uint16 callback = CALLBACK_FAILED;
   364 			uint16 callback = CALLBACK_FAILED;
   365 
   365 
   366 			v->cargo_type = cargo;
   366 			v->cargo_type = cargo;
   367 
   367 
   368 			if (HASBIT(EngInfo(p1)->callbackmask, CBM_REFIT_CAPACITY)) {
   368 			if (HASBIT(EngInfo(p1)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
   369 				callback = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, v->engine_type, v);
   369 				callback = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, v->engine_type, v);
   370 			}
   370 			}
   371 
   371 
   372 			if (callback == CALLBACK_FAILED) {
   372 			if (callback == CALLBACK_FAILED) {
   373 				/* Callback failed, or not executed; use the default cargo capacity */
   373 				/* Callback failed, or not executed; use the default cargo capacity */
   644 
   644 
   645 	SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_RUN);
   645 	SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_RUN);
   646 
   646 
   647 	/* Check the refit capacity callback */
   647 	/* Check the refit capacity callback */
   648 	uint16 callback = CALLBACK_FAILED;
   648 	uint16 callback = CALLBACK_FAILED;
   649 	if (HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_REFIT_CAPACITY)) {
   649 	if (HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
   650 		/* Back up the existing cargo type */
   650 		/* Back up the existing cargo type */
   651 		CargoID temp_cid = v->cargo_type;
   651 		CargoID temp_cid = v->cargo_type;
   652 		byte temp_subtype = v->cargo_subtype;
   652 		byte temp_subtype = v->cargo_subtype;
   653 		v->cargo_type = new_cid;
   653 		v->cargo_type = new_cid;
   654 		v->cargo_subtype = new_subtype;
   654 		v->cargo_subtype = new_subtype;