Merge branch 'vehicle_repair_costs-sx' into jgrpp

Conflicts:
	src/lang/english.txt
	src/saveload/extended_ver_sl.cpp
	src/saveload/extended_ver_sl.h
	src/settings_type.h
This commit is contained in:
Jonathan G Rennison
2015-08-04 23:59:12 +01:00
11 changed files with 96 additions and 0 deletions

View File

@@ -122,6 +122,37 @@ void VehicleServiceInDepot(Vehicle *v)
do {
v->date_of_last_service = _date;
if (_settings_game.vehicle.pay_for_repair && v->breakdowns_since_last_service) {
ExpensesType type = INVALID_EXPENSES;
_current_company = v->owner;
switch (v->type) {
case VEH_AIRCRAFT:
type = EXPENSES_AIRCRAFT_RUN;
break;
case VEH_TRAIN:
type = EXPENSES_TRAIN_RUN;
break;
case VEH_SHIP:
type = EXPENSES_SHIP_RUN;
break;
case VEH_ROAD:
type = EXPENSES_ROADVEH_RUN;
break;
default:
NOT_REACHED();
}
assert(type != INVALID_EXPENSES);
Money repair_cost = (v->breakdowns_since_last_service * v->repair_cost / _settings_game.vehicle.repair_cost) + 1;
CommandCost cost(type, repair_cost);
v->First()->profit_this_year -= cost.GetCost() << 8;
SubtractMoneyFromCompany(cost);
ShowCostOrIncomeAnimation(v->x_pos, v->y_pos, v->z_pos, cost.GetCost());
}
v->breakdowns_since_last_service = 0;
v->reliability = v->GetEngine()->reliability;
/* Prevent vehicles from breaking down directly after exiting the depot. */
@@ -1171,6 +1202,9 @@ Vehicle *CheckClickOnVehicle(const ViewPort *vp, int x, int y)
void DecreaseVehicleValue(Vehicle *v)
{
v->value -= v->value >> 8;
if ( v->age > v->max_age ) { // double cost for each max_age days after max_age
v->repair_cost += v->repair_cost >> 8;
}
SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
}