Import vehicle repair costs patch
Strip trailing whitespace http://www.tt-forums.net/viewtopic.php?p=1093268#p1093268
This commit is contained in:

committed by
Jonathan G Rennison

parent
224dcab437
commit
7537ae2a7e
@@ -1663,6 +1663,11 @@ STR_CONFIG_SETTING_REVERSE_AT_SIGNALS_HELPTEXT :Allow trains to
|
|||||||
|
|
||||||
STR_CONFIG_SETTING_QUERY_CAPTION :{WHITE}Change setting value
|
STR_CONFIG_SETTING_QUERY_CAPTION :{WHITE}Change setting value
|
||||||
|
|
||||||
|
STR_CONFIG_SETTING_PAY_FOR_REPAIR_VEHICLE :Pay for repairing vehicle: {STRING2}
|
||||||
|
STR_CONFIG_SETTING_PAY_FOR_REPAIR_VEHICLE_HELPTEXT :Pay for repairing vehicle
|
||||||
|
STR_CONFIG_SETTING_REPAIR_COST :Cost of repairing vehicle: 1/{STRING2} of total cost
|
||||||
|
STR_CONFIG_SETTING_REPAIR_COST_HELPTEXT :Cost of repairing vehicle
|
||||||
|
|
||||||
# Config errors
|
# Config errors
|
||||||
STR_CONFIG_ERROR :{WHITE}Error with the configuration file...
|
STR_CONFIG_ERROR :{WHITE}Error with the configuration file...
|
||||||
STR_CONFIG_ERROR_ARRAY :{WHITE}... error in array '{RAW_STRING}'
|
STR_CONFIG_ERROR_ARRAY :{WHITE}... error in array '{RAW_STRING}'
|
||||||
|
@@ -5098,3 +5098,8 @@ STR_PLANE :{BLACK}{PLANE}
|
|||||||
STR_SHIP :{BLACK}{SHIP}
|
STR_SHIP :{BLACK}{SHIP}
|
||||||
|
|
||||||
STR_TOOLBAR_RAILTYPE_VELOCITY :{STRING} ({VELOCITY})
|
STR_TOOLBAR_RAILTYPE_VELOCITY :{STRING} ({VELOCITY})
|
||||||
|
|
||||||
|
STR_CONFIG_SETTING_PAY_FOR_REPAIR_VEHICLE :Взымать плату за починку тс: {STRING}
|
||||||
|
STR_CONFIG_SETTING_PAY_FOR_REPAIR_VEHICLE_HELPTEXT :Если включено, в депо бужет взыматься плата за ремонт каждой поломки транспортного средства
|
||||||
|
STR_CONFIG_SETTING_REPAIR_COST :Стоимость ремонта: 1/{STRING} полной стоимости тс
|
||||||
|
STR_CONFIG_SETTING_REPAIR_COST_HELPTEXT :Стоимость ремонта одной поломки транспортного средства
|
||||||
|
@@ -252,7 +252,7 @@
|
|||||||
* 184 25508
|
* 184 25508
|
||||||
* 185 25620
|
* 185 25620
|
||||||
*/
|
*/
|
||||||
extern const uint16 SAVEGAME_VERSION = 185; ///< Current savegame version of OpenTTD.
|
extern const uint16 SAVEGAME_VERSION = SL_REPAIRCOST; ///< Current savegame version of OpenTTD.
|
||||||
|
|
||||||
SavegameType _savegame_type; ///< type of savegame we are loading
|
SavegameType _savegame_type; ///< type of savegame we are loading
|
||||||
|
|
||||||
|
@@ -89,6 +89,7 @@ enum SLRefType {
|
|||||||
|
|
||||||
/** Highest possible savegame version. */
|
/** Highest possible savegame version. */
|
||||||
#define SL_MAX_VERSION UINT16_MAX
|
#define SL_MAX_VERSION UINT16_MAX
|
||||||
|
#define SL_REPAIRCOST 200
|
||||||
|
|
||||||
/** Flags of a chunk. */
|
/** Flags of a chunk. */
|
||||||
enum ChunkType {
|
enum ChunkType {
|
||||||
|
@@ -364,6 +364,24 @@ void AfterLoadVehicles(bool part_of_load)
|
|||||||
v->SetServiceIntervalIsPercent(c->settings.vehicle.servint_ispercent);
|
v->SetServiceIntervalIsPercent(c->settings.vehicle.servint_ispercent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( IsSavegameVersionBefore( SL_REPAIRCOST )) {
|
||||||
|
/* repair cost is value for new vehicles and each week +/256 part for old */
|
||||||
|
FOR_ALL_VEHICLES(v) {
|
||||||
|
if (!v->IsPrimaryVehicle()) continue;
|
||||||
|
|
||||||
|
v->repair_cost = v->value;
|
||||||
|
for(int w = 0; w < v->age / 7; w++, v->repair_cost += v->repair_cost >> 8 );
|
||||||
|
//DEBUG(misc,0, "eid#%d, value=%lld, weeks=%d/%d, repair cost=%lld",
|
||||||
|
// v->engine_type, (int64)v->value, v->age, v->max_age, (int64)v->repair_cost );
|
||||||
|
|
||||||
|
if ( v->age > v->max_age ) {
|
||||||
|
Date weeks = (v->age - v->max_age)/7;
|
||||||
|
for(int w = 0; w < weeks; w++, v->repair_cost += v->repair_cost >> 8 );
|
||||||
|
//DEBUG(misc,0, "OLD: value=%lld, weeks=%d, repair cost=%lld", (int64)v->value, weeks, (int64)v->repair_cost );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckValidVehicles();
|
CheckValidVehicles();
|
||||||
@@ -684,6 +702,7 @@ const SaveLoad *GetVehicleDescription(VehicleType vt)
|
|||||||
SLEG_CONDVAR( _cargo_loaded_at_xy, SLE_UINT32, 51, 67),
|
SLEG_CONDVAR( _cargo_loaded_at_xy, SLE_UINT32, 51, 67),
|
||||||
SLE_CONDVAR(Vehicle, value, SLE_FILE_I32 | SLE_VAR_I64, 0, 64),
|
SLE_CONDVAR(Vehicle, value, SLE_FILE_I32 | SLE_VAR_I64, 0, 64),
|
||||||
SLE_CONDVAR(Vehicle, value, SLE_INT64, 65, SL_MAX_VERSION),
|
SLE_CONDVAR(Vehicle, value, SLE_INT64, 65, SL_MAX_VERSION),
|
||||||
|
SLE_CONDVAR(Vehicle, repair_cost, SLE_INT64, SL_REPAIRCOST, SL_MAX_VERSION),
|
||||||
|
|
||||||
SLE_CONDVAR(Vehicle, random_bits, SLE_UINT8, 2, SL_MAX_VERSION),
|
SLE_CONDVAR(Vehicle, random_bits, SLE_UINT8, 2, SL_MAX_VERSION),
|
||||||
SLE_CONDVAR(Vehicle, waiting_triggers, SLE_UINT8, 2, SL_MAX_VERSION),
|
SLE_CONDVAR(Vehicle, waiting_triggers, SLE_UINT8, 2, SL_MAX_VERSION),
|
||||||
|
@@ -1643,6 +1643,8 @@ static SettingEntry _settings_vehicles_autorenew[] = {
|
|||||||
static SettingsPage _settings_vehicles_autorenew_page = {_settings_vehicles_autorenew, lengthof(_settings_vehicles_autorenew)};
|
static SettingsPage _settings_vehicles_autorenew_page = {_settings_vehicles_autorenew, lengthof(_settings_vehicles_autorenew)};
|
||||||
|
|
||||||
static SettingEntry _settings_vehicles_servicing[] = {
|
static SettingEntry _settings_vehicles_servicing[] = {
|
||||||
|
SettingEntry("vehicle.pay_for_repair"),
|
||||||
|
SettingEntry("vehicle.repair_cost"),
|
||||||
SettingEntry("vehicle.servint_ispercent"),
|
SettingEntry("vehicle.servint_ispercent"),
|
||||||
SettingEntry("vehicle.servint_trains"),
|
SettingEntry("vehicle.servint_trains"),
|
||||||
SettingEntry("vehicle.servint_roadveh"),
|
SettingEntry("vehicle.servint_roadveh"),
|
||||||
|
@@ -460,6 +460,8 @@ struct VehicleSettings {
|
|||||||
byte extend_vehicle_life; ///< extend vehicle life by this many years
|
byte extend_vehicle_life; ///< extend vehicle life by this many years
|
||||||
byte road_side; ///< the side of the road vehicles drive on
|
byte road_side; ///< the side of the road vehicles drive on
|
||||||
uint8 plane_crashes; ///< number of plane crashes, 0 = none, 1 = reduced, 2 = normal
|
uint8 plane_crashes; ///< number of plane crashes, 0 = none, 1 = reduced, 2 = normal
|
||||||
|
bool pay_for_repair; ///< pay for repairing vehicle
|
||||||
|
uint8 repair_cost; ///< cost of repairing vehicle
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Settings related to the economy. */
|
/** Settings related to the economy. */
|
||||||
|
@@ -3895,5 +3895,28 @@ strhelp = STR_CONFIG_SETTING_RIGHT_MOUSE_BTN_EMU_HELPTEXT
|
|||||||
strval = STR_CONFIG_SETTING_RIGHT_MOUSE_BTN_EMU_COMMAND
|
strval = STR_CONFIG_SETTING_RIGHT_MOUSE_BTN_EMU_COMMAND
|
||||||
cat = SC_BASIC
|
cat = SC_BASIC
|
||||||
|
|
||||||
|
[SDT_BOOL]
|
||||||
|
base = GameSettings
|
||||||
|
var = vehicle.pay_for_repair
|
||||||
|
from = SL_REPAIRCOST
|
||||||
|
def = true
|
||||||
|
str = STR_CONFIG_SETTING_PAY_FOR_REPAIR_VEHICLE
|
||||||
|
strhelp = STR_CONFIG_SETTING_PAY_FOR_REPAIR_VEHICLE_HELPTEXT
|
||||||
|
cat = SC_EXPERT
|
||||||
|
|
||||||
|
[SDT_VAR]
|
||||||
|
base = GameSettings
|
||||||
|
var = vehicle.repair_cost
|
||||||
|
type = SLE_UINT8
|
||||||
|
from = SL_REPAIRCOST
|
||||||
|
def = 100
|
||||||
|
min = 1
|
||||||
|
max = 255
|
||||||
|
interval = 1
|
||||||
|
str = STR_CONFIG_SETTING_REPAIR_COST
|
||||||
|
strhelp = STR_CONFIG_SETTING_REPAIR_COST_HELPTEXT
|
||||||
|
strval = STR_JUST_INT
|
||||||
|
cat = SC_EXPERT
|
||||||
|
|
||||||
[SDT_END]
|
[SDT_END]
|
||||||
|
|
||||||
|
@@ -99,6 +99,33 @@ void VehicleServiceInDepot(Vehicle *v)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
v->date_of_last_service = _date;
|
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->breakdowns_since_last_service = 0;
|
||||||
v->reliability = v->GetEngine()->reliability;
|
v->reliability = v->GetEngine()->reliability;
|
||||||
/* Prevent vehicles from breaking down directly after exiting the depot. */
|
/* Prevent vehicles from breaking down directly after exiting the depot. */
|
||||||
@@ -1118,6 +1145,9 @@ Vehicle *CheckClickOnVehicle(const ViewPort *vp, int x, int y)
|
|||||||
void DecreaseVehicleValue(Vehicle *v)
|
void DecreaseVehicleValue(Vehicle *v)
|
||||||
{
|
{
|
||||||
v->value -= v->value >> 8;
|
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);
|
SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -151,6 +151,7 @@ public:
|
|||||||
Money profit_this_year; ///< Profit this year << 8, low 8 bits are fract
|
Money profit_this_year; ///< Profit this year << 8, low 8 bits are fract
|
||||||
Money profit_last_year; ///< Profit last year << 8, low 8 bits are fract
|
Money profit_last_year; ///< Profit last year << 8, low 8 bits are fract
|
||||||
Money value; ///< Value of the vehicle
|
Money value; ///< Value of the vehicle
|
||||||
|
Money repair_cost; ///< Cost to repair one breakdown
|
||||||
|
|
||||||
CargoPayment *cargo_payment; ///< The cargo payment we're currently in
|
CargoPayment *cargo_payment; ///< The cargo payment we're currently in
|
||||||
|
|
||||||
|
@@ -133,6 +133,7 @@ CommandCost CmdBuildVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
|||||||
if (value.Succeeded() && flags & DC_EXEC) {
|
if (value.Succeeded() && flags & DC_EXEC) {
|
||||||
v->unitnumber = unit_num;
|
v->unitnumber = unit_num;
|
||||||
v->value = value.GetCost();
|
v->value = value.GetCost();
|
||||||
|
v->repair_cost = value.GetCost();
|
||||||
|
|
||||||
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
||||||
InvalidateWindowClassesData(GetWindowClassForVehicleType(type), 0);
|
InvalidateWindowClassesData(GetWindowClassForVehicleType(type), 0);
|
||||||
|
Reference in New Issue
Block a user