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 */ |