src/vehicle.cpp
changeset 10240 c4788a9b2cdf
parent 10230 bf81856a1101
child 10259 23ab8ff3d044
equal deleted inserted replaced
10239:a66b15550485 10240:c4788a9b2cdf
   833 static void ChimneySmokeTick(Vehicle *v)
   833 static void ChimneySmokeTick(Vehicle *v)
   834 {
   834 {
   835 	if (v->progress > 0) {
   835 	if (v->progress > 0) {
   836 		v->progress--;
   836 		v->progress--;
   837 	} else {
   837 	} else {
   838 		TileIndex tile;
       
   839 
       
   840 		BeginVehicleMove(v);
   838 		BeginVehicleMove(v);
   841 
   839 
   842 		tile = TileVirtXY(v->x_pos, v->y_pos);
   840 		TileIndex tile = TileVirtXY(v->x_pos, v->y_pos);
   843 		if (!IsTileType(tile, MP_INDUSTRY)) {
   841 		if (!IsTileType(tile, MP_INDUSTRY)) {
   844 			EndVehicleMove(v);
   842 			EndVehicleMove(v);
   845 			delete v;
   843 			delete v;
   846 			return;
   844 			return;
   847 		}
   845 		}
  1485 {
  1483 {
  1486 	int rel, rel_old;
  1484 	int rel, rel_old;
  1487 
  1485 
  1488 	/* decrease reliability */
  1486 	/* decrease reliability */
  1489 	v->reliability = rel = max((rel_old = v->reliability) - v->reliability_spd_dec, 0);
  1487 	v->reliability = rel = max((rel_old = v->reliability) - v->reliability_spd_dec, 0);
  1490 	if ((rel_old >> 8) != (rel >> 8))
  1488 	if ((rel_old >> 8) != (rel >> 8)) InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
  1491 		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
       
  1492 
  1489 
  1493 	if (v->breakdown_ctr != 0 || v->vehstatus & VS_STOPPED ||
  1490 	if (v->breakdown_ctr != 0 || v->vehstatus & VS_STOPPED ||
       
  1491 			_opt.diff.vehicle_breakdowns < 1 ||
  1494 			v->cur_speed < 5 || _game_mode == GM_MENU) {
  1492 			v->cur_speed < 5 || _game_mode == GM_MENU) {
  1495 		return;
  1493 		return;
  1496 	}
  1494 	}
  1497 
  1495 
  1498 	uint32 r = Random();
  1496 	uint32 r = Random();
  1499 
  1497 
  1500 	/* increase chance of failure */
  1498 	/* increase chance of failure */
  1501 	int chance = v->breakdown_chance + 1;
  1499 	int chance = v->breakdown_chance + 1;
  1502 	if (Chance16I(1,25,r)) chance += 25;
  1500 	if (Chance16I(1, 25, r)) chance += 25;
  1503 	v->breakdown_chance = min(255, chance);
  1501 	v->breakdown_chance = min(255, chance);
  1504 
  1502 
  1505 	/* calculate reliability value to use in comparison */
  1503 	/* calculate reliability value to use in comparison */
  1506 	rel = v->reliability;
  1504 	rel = v->reliability;
  1507 	if (v->type == VEH_SHIP) rel += 0x6666;
  1505 	if (v->type == VEH_SHIP) rel += 0x6666;
  1508 
       
  1509 	/* disabled breakdowns? */
       
  1510 	if (_opt.diff.vehicle_breakdowns < 1) return;
       
  1511 
  1506 
  1512 	/* reduced breakdowns? */
  1507 	/* reduced breakdowns? */
  1513 	if (_opt.diff.vehicle_breakdowns == 1) rel += 0x6666;
  1508 	if (_opt.diff.vehicle_breakdowns == 1) rel += 0x6666;
  1514 
  1509 
  1515 	/* check if to break down */
  1510 	/* check if to break down */