src/aircraft_cmd.cpp
changeset 7010 6f0d9f03180d
parent 6990 136a08baf0ed
child 7070 2f4e1b2facc6
equal deleted inserted replaced
7009:9992ccf17e58 7010:6f0d9f03180d
   678 		v->cargo_cap = pass;
   678 		v->cargo_cap = pass;
   679 
   679 
   680 		Vehicle *u = v->next;
   680 		Vehicle *u = v->next;
   681 		uint mail = IsCargoInClass(new_cid, CC_PASSENGERS) ? avi->mail_capacity : 0;
   681 		uint mail = IsCargoInClass(new_cid, CC_PASSENGERS) ? avi->mail_capacity : 0;
   682 		u->cargo_cap = mail;
   682 		u->cargo_cap = mail;
   683 		if (v->cargo_type == new_cid) {
   683 		v->cargo.Truncate(v->cargo_type == new_cid ? pass : 0);
   684 			v->cargo_count = min(pass, v->cargo_count);
   684 		u->cargo.Truncate(v->cargo_type == new_cid ? mail : 0);
   685 			u->cargo_count = min(mail, u->cargo_count);
       
   686 		} else {
       
   687 			v->cargo_count = 0;
       
   688 			u->cargo_count = 0;
       
   689 		}
       
   690 		v->cargo_type = new_cid;
   685 		v->cargo_type = new_cid;
   691 		v->cargo_subtype = new_subtype;
   686 		v->cargo_subtype = new_subtype;
   692 		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
   687 		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
   693 		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
   688 		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
   694 		RebuildVehicleLists();
   689 		RebuildVehicleLists();
   772 static void AgeAircraftCargo(Vehicle *v)
   767 static void AgeAircraftCargo(Vehicle *v)
   773 {
   768 {
   774 	if (_age_cargo_skip_counter != 0) return;
   769 	if (_age_cargo_skip_counter != 0) return;
   775 
   770 
   776 	do {
   771 	do {
   777 		if (v->cargo_days != 0xFF) v->cargo_days++;
   772 		v->cargo.AgeCargo();
   778 		v = v->next;
   773 		v = v->next;
   779 	} while (v != NULL);
   774 	} while (v != NULL);
   780 }
   775 }
   781 
   776 
   782 static void HelicopterTickHandler(Vehicle *v)
   777 static void HelicopterTickHandler(Vehicle *v)
  1427 	CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
  1422 	CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
  1428 
  1423 
  1429 	InvalidateWindow(WC_VEHICLE_VIEW, v->index);
  1424 	InvalidateWindow(WC_VEHICLE_VIEW, v->index);
  1430 
  1425 
  1431 	uint amt = 2;
  1426 	uint amt = 2;
  1432 	if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) amt += v->cargo_count;
  1427 	if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) amt += v->cargo.Count();
  1433 	SetDParam(0, amt);
  1428 	SetDParam(0, amt);
  1434 
  1429 
  1435 	v->cargo_count = 0;
  1430 	v->cargo.Truncate(0);
  1436 	v->next->cargo_count = 0;
  1431 	v->next->cargo.Truncate(0);
  1437 	const Station *st = GetStation(v->u.air.targetairport);
  1432 	const Station *st = GetStation(v->u.air.targetairport);
  1438 	StringID newsitem;
  1433 	StringID newsitem;
  1439 	if (st->airport_tile == 0) {
  1434 	if (st->airport_tile == 0) {
  1440 		newsitem = STR_PLANE_CRASH_OUT_OF_FUEL;
  1435 		newsitem = STR_PLANE_CRASH_OUT_OF_FUEL;
  1441 	} else {
  1436 	} else {
  1467 	if (GB(Random(), 0, 16) > prob) return;
  1462 	if (GB(Random(), 0, 16) > prob) return;
  1468 
  1463 
  1469 	/* Crash the airplane. Remove all goods stored at the station. */
  1464 	/* Crash the airplane. Remove all goods stored at the station. */
  1470 	for (CargoID i = 0; i < NUM_CARGO; i++) {
  1465 	for (CargoID i = 0; i < NUM_CARGO; i++) {
  1471 		st->goods[i].rating = 1;
  1466 		st->goods[i].rating = 1;
  1472 		SB(st->goods[i].waiting_acceptance, 0, 12, 0);
  1467 		st->goods[i].cargo.Truncate(0);
  1473 	}
  1468 	}
  1474 
  1469 
  1475 	CrashAirplane(v);
  1470 	CrashAirplane(v);
  1476 }
  1471 }
  1477 
  1472