mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r24996) -Change: Apply default service interval changes to vehicles without custom interval (peter1138)
This commit is contained in:
parent
369a6f9d1b
commit
ef8d491d8f
|
@ -15,6 +15,7 @@
|
||||||
#include "command_type.h"
|
#include "command_type.h"
|
||||||
#include "company_type.h"
|
#include "company_type.h"
|
||||||
#include "gfx_type.h"
|
#include "gfx_type.h"
|
||||||
|
#include "vehicle_type.h"
|
||||||
|
|
||||||
bool MayCompanyTakeOver(CompanyID cbig, CompanyID small);
|
bool MayCompanyTakeOver(CompanyID cbig, CompanyID small);
|
||||||
void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner);
|
void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner);
|
||||||
|
@ -56,4 +57,6 @@ static inline bool IsInteractiveCompany(CompanyID company)
|
||||||
return company == _local_company;
|
return company == _local_company;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CompanyServiceInterval(const Company *c, VehicleType type);
|
||||||
|
|
||||||
#endif /* COMPANY_FUNC_H */
|
#endif /* COMPANY_FUNC_H */
|
||||||
|
|
|
@ -856,11 +856,14 @@ static bool UpdateConsists(int32 p1)
|
||||||
/* Check service intervals of vehicles, p1 is value of % or day based servicing */
|
/* Check service intervals of vehicles, p1 is value of % or day based servicing */
|
||||||
static bool CheckInterval(int32 p1)
|
static bool CheckInterval(int32 p1)
|
||||||
{
|
{
|
||||||
|
bool update_vehicles;
|
||||||
VehicleDefaultSettings *vds;
|
VehicleDefaultSettings *vds;
|
||||||
if (_game_mode == GM_MENU || !Company::IsValidID(_current_company)) {
|
if (_game_mode == GM_MENU || !Company::IsValidID(_current_company)) {
|
||||||
vds = &_settings_client.company.vehicle;
|
vds = &_settings_client.company.vehicle;
|
||||||
|
update_vehicles = false;
|
||||||
} else {
|
} else {
|
||||||
vds = &Company::Get(_current_company)->settings.vehicle;
|
vds = &Company::Get(_current_company)->settings.vehicle;
|
||||||
|
update_vehicles = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p1 != 0) {
|
if (p1 != 0) {
|
||||||
|
@ -875,11 +878,72 @@ static bool CheckInterval(int32 p1)
|
||||||
vds->servint_ships = 360;
|
vds->servint_ships = 360;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (update_vehicles) {
|
||||||
|
const Company *c = Company::Get(_current_company);
|
||||||
|
Vehicle *v;
|
||||||
|
FOR_ALL_VEHICLES(v) {
|
||||||
|
if (v->owner == _current_company && v->IsPrimaryVehicle() && !v->ServiceIntervalIsCustom()) {
|
||||||
|
v->SetServiceInterval(CompanyServiceInterval(c, v->type));
|
||||||
|
v->SetServiceIntervalIsPercent(p1 != 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
InvalidateDetailsWindow(0);
|
InvalidateDetailsWindow(0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool UpdateInterval(VehicleType type, int32 p1)
|
||||||
|
{
|
||||||
|
bool update_vehicles;
|
||||||
|
VehicleDefaultSettings *vds;
|
||||||
|
if (_game_mode == GM_MENU || !Company::IsValidID(_current_company)) {
|
||||||
|
vds = &_settings_client.company.vehicle;
|
||||||
|
update_vehicles = false;
|
||||||
|
} else {
|
||||||
|
vds = &Company::Get(_current_company)->settings.vehicle;
|
||||||
|
update_vehicles = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test if the interval is valid */
|
||||||
|
uint16 interval = GetServiceIntervalClamped(p1, vds->servint_ispercent);
|
||||||
|
if (interval != p1) return false;
|
||||||
|
|
||||||
|
if (update_vehicles) {
|
||||||
|
Vehicle *v;
|
||||||
|
FOR_ALL_VEHICLES(v) {
|
||||||
|
if (v->owner == _current_company && v->type == type && v->IsPrimaryVehicle() && !v->ServiceIntervalIsCustom()) {
|
||||||
|
v->SetServiceInterval(p1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
InvalidateDetailsWindow(0);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool UpdateIntervalTrains(int32 p1)
|
||||||
|
{
|
||||||
|
return UpdateInterval(VEH_TRAIN, p1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool UpdateIntervalRoadVeh(int32 p1)
|
||||||
|
{
|
||||||
|
return UpdateInterval(VEH_ROAD, p1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool UpdateIntervalShips(int32 p1)
|
||||||
|
{
|
||||||
|
return UpdateInterval(VEH_SHIP, p1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool UpdateIntervalAircraft(int32 p1)
|
||||||
|
{
|
||||||
|
return UpdateInterval(VEH_AIRCRAFT, p1);
|
||||||
|
}
|
||||||
|
|
||||||
static bool TrainAccelerationModelChanged(int32 p1)
|
static bool TrainAccelerationModelChanged(int32 p1)
|
||||||
{
|
{
|
||||||
Train *t;
|
Train *t;
|
||||||
|
|
|
@ -9,6 +9,10 @@
|
||||||
[pre-amble]
|
[pre-amble]
|
||||||
static bool CheckInterval(int32 p1);
|
static bool CheckInterval(int32 p1);
|
||||||
static bool InvalidateDetailsWindow(int32 p1);
|
static bool InvalidateDetailsWindow(int32 p1);
|
||||||
|
static bool UpdateIntervalTrains(int32 p1);
|
||||||
|
static bool UpdateIntervalRoadVeh(int32 p1);
|
||||||
|
static bool UpdateIntervalShips(int32 p1);
|
||||||
|
static bool UpdateIntervalAircraft(int32 p1);
|
||||||
|
|
||||||
static const SettingDesc _company_settings[] = {
|
static const SettingDesc _company_settings[] = {
|
||||||
[post-amble]
|
[post-amble]
|
||||||
|
@ -88,7 +92,7 @@ max = 800
|
||||||
str = STR_CONFIG_SETTING_SERVINT_TRAINS
|
str = STR_CONFIG_SETTING_SERVINT_TRAINS
|
||||||
strhelp = STR_CONFIG_SETTING_SERVINT_TRAINS_HELPTEXT
|
strhelp = STR_CONFIG_SETTING_SERVINT_TRAINS_HELPTEXT
|
||||||
strval = STR_CONFIG_SETTING_SERVINT_VALUE
|
strval = STR_CONFIG_SETTING_SERVINT_VALUE
|
||||||
proc = InvalidateDetailsWindow
|
proc = UpdateIntervalTrains
|
||||||
|
|
||||||
[SDT_VAR]
|
[SDT_VAR]
|
||||||
base = CompanySettings
|
base = CompanySettings
|
||||||
|
@ -101,7 +105,7 @@ max = 800
|
||||||
str = STR_CONFIG_SETTING_SERVINT_ROAD_VEHICLES
|
str = STR_CONFIG_SETTING_SERVINT_ROAD_VEHICLES
|
||||||
strhelp = STR_CONFIG_SETTING_SERVINT_ROAD_VEHICLES_HELPTEXT
|
strhelp = STR_CONFIG_SETTING_SERVINT_ROAD_VEHICLES_HELPTEXT
|
||||||
strval = STR_CONFIG_SETTING_SERVINT_VALUE
|
strval = STR_CONFIG_SETTING_SERVINT_VALUE
|
||||||
proc = InvalidateDetailsWindow
|
proc = UpdateIntervalRoadVeh
|
||||||
|
|
||||||
[SDT_VAR]
|
[SDT_VAR]
|
||||||
base = CompanySettings
|
base = CompanySettings
|
||||||
|
@ -114,7 +118,7 @@ max = 800
|
||||||
str = STR_CONFIG_SETTING_SERVINT_SHIPS
|
str = STR_CONFIG_SETTING_SERVINT_SHIPS
|
||||||
strhelp = STR_CONFIG_SETTING_SERVINT_SHIPS_HELPTEXT
|
strhelp = STR_CONFIG_SETTING_SERVINT_SHIPS_HELPTEXT
|
||||||
strval = STR_CONFIG_SETTING_SERVINT_VALUE
|
strval = STR_CONFIG_SETTING_SERVINT_VALUE
|
||||||
proc = InvalidateDetailsWindow
|
proc = UpdateIntervalShips
|
||||||
|
|
||||||
[SDT_VAR]
|
[SDT_VAR]
|
||||||
base = CompanySettings
|
base = CompanySettings
|
||||||
|
@ -127,7 +131,7 @@ max = 800
|
||||||
str = STR_CONFIG_SETTING_SERVINT_AIRCRAFT
|
str = STR_CONFIG_SETTING_SERVINT_AIRCRAFT
|
||||||
strhelp = STR_CONFIG_SETTING_SERVINT_AIRCRAFT_HELPTEXT
|
strhelp = STR_CONFIG_SETTING_SERVINT_AIRCRAFT_HELPTEXT
|
||||||
strval = STR_CONFIG_SETTING_SERVINT_VALUE
|
strval = STR_CONFIG_SETTING_SERVINT_VALUE
|
||||||
proc = InvalidateDetailsWindow
|
proc = UpdateIntervalAircraft
|
||||||
|
|
||||||
[SDT_END]
|
[SDT_END]
|
||||||
|
|
||||||
|
|
|
@ -176,6 +176,4 @@ void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8 num_vehicles);
|
||||||
|
|
||||||
void CheckCargoCapacity(Vehicle *v);
|
void CheckCargoCapacity(Vehicle *v);
|
||||||
|
|
||||||
int CompanyServiceInterval(const Company *c, VehicleType type);
|
|
||||||
|
|
||||||
#endif /* VEHICLE_FUNC_H */
|
#endif /* VEHICLE_FUNC_H */
|
||||||
|
|
Loading…
Reference in New Issue