Fix infrastructure sharing checks not being executed when disabling
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "scope_info.h"
|
||||
#include "order_cmd.h"
|
||||
#include "strings_func.h"
|
||||
#include "scope.h"
|
||||
|
||||
#include "table/strings.h"
|
||||
|
||||
@@ -238,13 +239,19 @@ static void FixAllReservations()
|
||||
* If vehicles are still on others' infrastructure or using others' stations,
|
||||
* The change is not possible and false is returned.
|
||||
* @param type The type of vehicle whose setting will be changed.
|
||||
* @param new_value True if sharing will become enabled.
|
||||
* @return True if the change can take place, false otherwise.
|
||||
*/
|
||||
bool CheckSharingChangePossible(VehicleType type)
|
||||
bool CheckSharingChangePossible(VehicleType type, bool new_value)
|
||||
{
|
||||
if (type != VEH_AIRCRAFT) YapfNotifyTrackLayoutChange(INVALID_TILE, INVALID_TRACK);
|
||||
/* Only do something when sharing is being disabled */
|
||||
if (_settings_game.economy.infrastructure_sharing[type]) return true;
|
||||
if (!_settings_game.economy.infrastructure_sharing[type] || new_value) return true;
|
||||
|
||||
_settings_game.economy.infrastructure_sharing[type] = false;
|
||||
auto guard = scope_guard([type]() {
|
||||
_settings_game.economy.infrastructure_sharing[type] = true;
|
||||
});
|
||||
|
||||
StringID error_message = STR_NULL;
|
||||
for (Vehicle *v : Vehicle::Iterate()) {
|
||||
|
@@ -19,7 +19,7 @@
|
||||
void PayStationSharingFee(Vehicle *v, const Station *st);
|
||||
void PayDailyTrackSharingFee(Train *v);
|
||||
|
||||
bool CheckSharingChangePossible(VehicleType type);
|
||||
bool CheckSharingChangePossible(VehicleType type, bool new_value);
|
||||
void HandleSharingCompanyDeletion(Owner owner);
|
||||
void UpdateAllBlockSignals(Owner owner = INVALID_OWNER);
|
||||
|
||||
|
@@ -1617,7 +1617,7 @@ static void StationCatchmentChanged(int32 new_value)
|
||||
|
||||
static bool CheckSharingRail(int32 &new_value)
|
||||
{
|
||||
return CheckSharingChangePossible(VEH_TRAIN);
|
||||
return CheckSharingChangePossible(VEH_TRAIN, new_value);
|
||||
}
|
||||
|
||||
static void SharingRailChanged(int32 new_value)
|
||||
@@ -1627,17 +1627,17 @@ static void SharingRailChanged(int32 new_value)
|
||||
|
||||
static bool CheckSharingRoad(int32 &new_value)
|
||||
{
|
||||
return CheckSharingChangePossible(VEH_ROAD);
|
||||
return CheckSharingChangePossible(VEH_ROAD, new_value);
|
||||
}
|
||||
|
||||
static bool CheckSharingWater(int32 &new_value)
|
||||
{
|
||||
return CheckSharingChangePossible(VEH_SHIP);
|
||||
return CheckSharingChangePossible(VEH_SHIP, new_value);
|
||||
}
|
||||
|
||||
static bool CheckSharingAir(int32 &new_value)
|
||||
{
|
||||
return CheckSharingChangePossible(VEH_AIRCRAFT);
|
||||
return CheckSharingChangePossible(VEH_AIRCRAFT, new_value);
|
||||
}
|
||||
|
||||
static void MaxVehiclesChanged(int32 new_value)
|
||||
|
Reference in New Issue
Block a user