Merge branch 'openttd'

This commit is contained in:
dP
2024-03-17 01:02:31 +07:00
164 changed files with 9303 additions and 5998 deletions
+4 -9
View File
@@ -217,7 +217,7 @@ int UpdateCompanyRatingAndValue(Company *c, bool update)
if (v->owner != owner) continue;
if (IsCompanyBuildableVehicleType(v->type) && v->IsPrimaryVehicle()) {
if (v->profit_last_year > 0) num++; // For the vehicle score only count profitable vehicles
if (v->age > 730) {
if (v->economy_age > VEHICLE_PROFIT_MIN_AGE) {
/* Find the vehicle with the lowest amount of profit */
if (min_profit_first || min_profit > v->profit_last_year) {
min_profit = v->profit_last_year;
@@ -432,17 +432,13 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
}
{
FreeUnitIDGenerator unitidgen[] = {
FreeUnitIDGenerator(VEH_TRAIN, new_owner), FreeUnitIDGenerator(VEH_ROAD, new_owner),
FreeUnitIDGenerator(VEH_SHIP, new_owner), FreeUnitIDGenerator(VEH_AIRCRAFT, new_owner)
};
Company *new_company = new_owner == INVALID_OWNER ? nullptr : Company::Get(new_owner);
/* Override company settings to new company defaults in case we need to convert them.
* This is required as the CmdChangeServiceInt doesn't copy the supplied value when it is non-custom
*/
if (new_owner != INVALID_OWNER) {
Company *old_company = Company::Get(old_owner);
Company *new_company = Company::Get(new_owner);
old_company->settings.vehicle.servint_aircraft = new_company->settings.vehicle.servint_aircraft;
old_company->settings.vehicle.servint_trains = new_company->settings.vehicle.servint_trains;
@@ -459,8 +455,6 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
* This prevents invalid values on mismatching company defaults being accepted.
*/
if (!v->ServiceIntervalIsCustom()) {
Company *new_company = Company::Get(new_owner);
/* Technically, passing the interval is not needed as the command will query the default value itself.
* However, do not rely on that behaviour.
*/
@@ -479,7 +473,8 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
}
if (v->IsPrimaryVehicle()) {
GroupStatistics::CountVehicle(v, 1);
v->unitnumber = unitidgen[v->type].NextID();
auto &unitidgen = new_company->freeunits[v->type];
v->unitnumber = unitidgen.UseID(unitidgen.NextID());
}
/* Invalidate the vehicle's cargo payment "owner cache". */