diff --git a/bin/ai/regression/regression.txt b/bin/ai/regression/regression.txt index c45cb1d5e7..0402a50c8d 100644 --- a/bin/ai/regression/regression.txt +++ b/bin/ai/regression/regression.txt @@ -2148,201 +2148,201 @@ ERROR: HasNext() is invalid as Begin() is never called GetRoadType(): -1 GetPlaneType(): -1 Engine 57 - IsValidEngine(): true - GetName(): Passenger Carriage - GetCargoType(): 0 + IsValidEngine(): false + GetName(): (null : 0x00000000) + GetCargoType(): 255 CanRefitCargo(): false - GetCapacity(): 45 + GetCapacity(): -1 GetReliability(): -1 - GetMaxSpeed(): 0 - GetPrice(): 1447 + GetMaxSpeed(): -1 + GetPrice(): -1 GetMaxAge(): -1 - GetRunningCost(): 0 + GetRunningCost(): -1 GetPower(): -1 - GetWeight(): 25 + GetWeight(): -1 GetMaxTractiveEffort(): -1 - GetVehicleType(): 0 - GetRailType(): 2 + GetVehicleType(): 255 + GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 Engine 58 - IsValidEngine(): true - GetName(): Mail Van - GetCargoType(): 2 + IsValidEngine(): false + GetName(): (null : 0x00000000) + GetCargoType(): 255 CanRefitCargo(): false - GetCapacity(): 35 + GetCapacity(): -1 GetReliability(): -1 - GetMaxSpeed(): 0 - GetPrice(): 1335 + GetMaxSpeed(): -1 + GetPrice(): -1 GetMaxAge(): -1 - GetRunningCost(): 0 + GetRunningCost(): -1 GetPower(): -1 - GetWeight(): 21 + GetWeight(): -1 GetMaxTractiveEffort(): -1 - GetVehicleType(): 0 - GetRailType(): 2 + GetVehicleType(): 255 + GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 Engine 59 - IsValidEngine(): true - GetName(): Coal Truck - GetCargoType(): 1 - CanRefitCargo(): true - GetCapacity(): 35 + IsValidEngine(): false + GetName(): (null : 0x00000000) + GetCargoType(): 255 + CanRefitCargo(): false + GetCapacity(): -1 GetReliability(): -1 - GetMaxSpeed(): 0 - GetPrice(): 1031 + GetMaxSpeed(): -1 + GetPrice(): -1 GetMaxAge(): -1 - GetRunningCost(): 0 + GetRunningCost(): -1 GetPower(): -1 - GetWeight(): 18 + GetWeight(): -1 GetMaxTractiveEffort(): -1 - GetVehicleType(): 0 - GetRailType(): 2 + GetVehicleType(): 255 + GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 Engine 60 - IsValidEngine(): true - GetName(): Oil Tanker - GetCargoType(): 3 + IsValidEngine(): false + GetName(): (null : 0x00000000) + GetCargoType(): 255 CanRefitCargo(): false - GetCapacity(): 35 + GetCapacity(): -1 GetReliability(): -1 - GetMaxSpeed(): 0 - GetPrice(): 1171 + GetMaxSpeed(): -1 + GetPrice(): -1 GetMaxAge(): -1 - GetRunningCost(): 0 + GetRunningCost(): -1 GetPower(): -1 - GetWeight(): 24 + GetWeight(): -1 GetMaxTractiveEffort(): -1 - GetVehicleType(): 0 - GetRailType(): 2 + GetVehicleType(): 255 + GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 Engine 61 - IsValidEngine(): true - GetName(): Livestock Van - GetCargoType(): 4 + IsValidEngine(): false + GetName(): (null : 0x00000000) + GetCargoType(): 255 CanRefitCargo(): false - GetCapacity(): 30 + GetCapacity(): -1 GetReliability(): -1 - GetMaxSpeed(): 0 - GetPrice(): 1125 + GetMaxSpeed(): -1 + GetPrice(): -1 GetMaxAge(): -1 - GetRunningCost(): 0 + GetRunningCost(): -1 GetPower(): -1 - GetWeight(): 20 + GetWeight(): -1 GetMaxTractiveEffort(): -1 - GetVehicleType(): 0 - GetRailType(): 2 + GetVehicleType(): 255 + GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 Engine 62 - IsValidEngine(): true - GetName(): Goods Van - GetCargoType(): 5 + IsValidEngine(): false + GetName(): (null : 0x00000000) + GetCargoType(): 255 CanRefitCargo(): false - GetCapacity(): 30 + GetCapacity(): -1 GetReliability(): -1 - GetMaxSpeed(): 0 - GetPrice(): 1113 + GetMaxSpeed(): -1 + GetPrice(): -1 GetMaxAge(): -1 - GetRunningCost(): 0 + GetRunningCost(): -1 GetPower(): -1 - GetWeight(): 21 + GetWeight(): -1 GetMaxTractiveEffort(): -1 - GetVehicleType(): 0 - GetRailType(): 2 + GetVehicleType(): 255 + GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 Engine 63 - IsValidEngine(): true - GetName(): Grain Hopper - GetCargoType(): 6 + IsValidEngine(): false + GetName(): (null : 0x00000000) + GetCargoType(): 255 CanRefitCargo(): false - GetCapacity(): 35 + GetCapacity(): -1 GetReliability(): -1 - GetMaxSpeed(): 0 - GetPrice(): 1066 + GetMaxSpeed(): -1 + GetPrice(): -1 GetMaxAge(): -1 - GetRunningCost(): 0 + GetRunningCost(): -1 GetPower(): -1 - GetWeight(): 19 + GetWeight(): -1 GetMaxTractiveEffort(): -1 - GetVehicleType(): 0 - GetRailType(): 2 + GetVehicleType(): 255 + GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 Engine 64 - IsValidEngine(): true - GetName(): Wood Truck - GetCargoType(): 7 + IsValidEngine(): false + GetName(): (null : 0x00000000) + GetCargoType(): 255 CanRefitCargo(): false - GetCapacity(): 35 + GetCapacity(): -1 GetReliability(): -1 - GetMaxSpeed(): 0 - GetPrice(): 1060 + GetMaxSpeed(): -1 + GetPrice(): -1 GetMaxAge(): -1 - GetRunningCost(): 0 + GetRunningCost(): -1 GetPower(): -1 - GetWeight(): 16 + GetWeight(): -1 GetMaxTractiveEffort(): -1 - GetVehicleType(): 0 - GetRailType(): 2 + GetVehicleType(): 255 + GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 Engine 65 - IsValidEngine(): true - GetName(): Iron Ore Hopper - GetCargoType(): 8 + IsValidEngine(): false + GetName(): (null : 0x00000000) + GetCargoType(): 255 CanRefitCargo(): false - GetCapacity(): 35 + GetCapacity(): -1 GetReliability(): -1 - GetMaxSpeed(): 0 - GetPrice(): 1048 + GetMaxSpeed(): -1 + GetPrice(): -1 GetMaxAge(): -1 - GetRunningCost(): 0 + GetRunningCost(): -1 GetPower(): -1 - GetWeight(): 19 + GetWeight(): -1 GetMaxTractiveEffort(): -1 - GetVehicleType(): 0 - GetRailType(): 2 + GetVehicleType(): 255 + GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 Engine 66 - IsValidEngine(): true - GetName(): Steel Truck - GetCargoType(): 9 + IsValidEngine(): false + GetName(): (null : 0x00000000) + GetCargoType(): 255 CanRefitCargo(): false - GetCapacity(): 25 + GetCapacity(): -1 GetReliability(): -1 - GetMaxSpeed(): 0 - GetPrice(): 1148 + GetMaxSpeed(): -1 + GetPrice(): -1 GetMaxAge(): -1 - GetRunningCost(): 0 + GetRunningCost(): -1 GetPower(): -1 - GetWeight(): 18 + GetWeight(): -1 GetMaxTractiveEffort(): -1 - GetVehicleType(): 0 - GetRailType(): 2 + GetVehicleType(): 255 + GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 Engine 67 - IsValidEngine(): true - GetName(): Armoured Van - GetCargoType(): 10 + IsValidEngine(): false + GetName(): (null : 0x00000000) + GetCargoType(): 255 CanRefitCargo(): false - GetCapacity(): 25 + GetCapacity(): -1 GetReliability(): -1 - GetMaxSpeed(): 0 - GetPrice(): 1494 + GetMaxSpeed(): -1 + GetPrice(): -1 GetMaxAge(): -1 - GetRunningCost(): 0 + GetRunningCost(): -1 GetPower(): -1 - GetWeight(): 30 + GetWeight(): -1 GetMaxTractiveEffort(): -1 - GetVehicleType(): 0 - GetRailType(): 2 + GetVehicleType(): 255 + GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 Engine 68 @@ -2724,201 +2724,201 @@ ERROR: HasNext() is invalid as Begin() is never called GetRoadType(): -1 GetPlaneType(): -1 Engine 89 - IsValidEngine(): true - GetName(): Passenger Carriage - GetCargoType(): 0 + IsValidEngine(): false + GetName(): (null : 0x00000000) + GetCargoType(): 255 CanRefitCargo(): false - GetCapacity(): 47 + GetCapacity(): -1 GetReliability(): -1 - GetMaxSpeed(): 0 - GetPrice(): 1447 + GetMaxSpeed(): -1 + GetPrice(): -1 GetMaxAge(): -1 - GetRunningCost(): 0 + GetRunningCost(): -1 GetPower(): -1 - GetWeight(): 25 + GetWeight(): -1 GetMaxTractiveEffort(): -1 - GetVehicleType(): 0 - GetRailType(): 3 + GetVehicleType(): 255 + GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 Engine 90 - IsValidEngine(): true - GetName(): Mail Van - GetCargoType(): 2 + IsValidEngine(): false + GetName(): (null : 0x00000000) + GetCargoType(): 255 CanRefitCargo(): false - GetCapacity(): 37 + GetCapacity(): -1 GetReliability(): -1 - GetMaxSpeed(): 0 - GetPrice(): 1335 + GetMaxSpeed(): -1 + GetPrice(): -1 GetMaxAge(): -1 - GetRunningCost(): 0 + GetRunningCost(): -1 GetPower(): -1 - GetWeight(): 21 + GetWeight(): -1 GetMaxTractiveEffort(): -1 - GetVehicleType(): 0 - GetRailType(): 3 + GetVehicleType(): 255 + GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 Engine 91 - IsValidEngine(): true - GetName(): Coal Truck - GetCargoType(): 1 - CanRefitCargo(): true - GetCapacity(): 37 + IsValidEngine(): false + GetName(): (null : 0x00000000) + GetCargoType(): 255 + CanRefitCargo(): false + GetCapacity(): -1 GetReliability(): -1 - GetMaxSpeed(): 0 - GetPrice(): 1031 + GetMaxSpeed(): -1 + GetPrice(): -1 GetMaxAge(): -1 - GetRunningCost(): 0 + GetRunningCost(): -1 GetPower(): -1 - GetWeight(): 18 + GetWeight(): -1 GetMaxTractiveEffort(): -1 - GetVehicleType(): 0 - GetRailType(): 3 + GetVehicleType(): 255 + GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 Engine 92 - IsValidEngine(): true - GetName(): Oil Tanker - GetCargoType(): 3 + IsValidEngine(): false + GetName(): (null : 0x00000000) + GetCargoType(): 255 CanRefitCargo(): false - GetCapacity(): 37 + GetCapacity(): -1 GetReliability(): -1 - GetMaxSpeed(): 0 - GetPrice(): 1171 + GetMaxSpeed(): -1 + GetPrice(): -1 GetMaxAge(): -1 - GetRunningCost(): 0 + GetRunningCost(): -1 GetPower(): -1 - GetWeight(): 24 + GetWeight(): -1 GetMaxTractiveEffort(): -1 - GetVehicleType(): 0 - GetRailType(): 3 + GetVehicleType(): 255 + GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 Engine 93 - IsValidEngine(): true - GetName(): Livestock Van - GetCargoType(): 4 + IsValidEngine(): false + GetName(): (null : 0x00000000) + GetCargoType(): 255 CanRefitCargo(): false - GetCapacity(): 32 + GetCapacity(): -1 GetReliability(): -1 - GetMaxSpeed(): 0 - GetPrice(): 1125 + GetMaxSpeed(): -1 + GetPrice(): -1 GetMaxAge(): -1 - GetRunningCost(): 0 + GetRunningCost(): -1 GetPower(): -1 - GetWeight(): 20 + GetWeight(): -1 GetMaxTractiveEffort(): -1 - GetVehicleType(): 0 - GetRailType(): 3 + GetVehicleType(): 255 + GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 Engine 94 - IsValidEngine(): true - GetName(): Goods Van - GetCargoType(): 5 + IsValidEngine(): false + GetName(): (null : 0x00000000) + GetCargoType(): 255 CanRefitCargo(): false - GetCapacity(): 32 + GetCapacity(): -1 GetReliability(): -1 - GetMaxSpeed(): 0 - GetPrice(): 1113 + GetMaxSpeed(): -1 + GetPrice(): -1 GetMaxAge(): -1 - GetRunningCost(): 0 + GetRunningCost(): -1 GetPower(): -1 - GetWeight(): 21 + GetWeight(): -1 GetMaxTractiveEffort(): -1 - GetVehicleType(): 0 - GetRailType(): 3 + GetVehicleType(): 255 + GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 Engine 95 - IsValidEngine(): true - GetName(): Grain Hopper - GetCargoType(): 6 + IsValidEngine(): false + GetName(): (null : 0x00000000) + GetCargoType(): 255 CanRefitCargo(): false - GetCapacity(): 37 + GetCapacity(): -1 GetReliability(): -1 - GetMaxSpeed(): 0 - GetPrice(): 1066 + GetMaxSpeed(): -1 + GetPrice(): -1 GetMaxAge(): -1 - GetRunningCost(): 0 + GetRunningCost(): -1 GetPower(): -1 - GetWeight(): 19 + GetWeight(): -1 GetMaxTractiveEffort(): -1 - GetVehicleType(): 0 - GetRailType(): 3 + GetVehicleType(): 255 + GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 Engine 96 - IsValidEngine(): true - GetName(): Wood Truck - GetCargoType(): 7 + IsValidEngine(): false + GetName(): (null : 0x00000000) + GetCargoType(): 255 CanRefitCargo(): false - GetCapacity(): 37 + GetCapacity(): -1 GetReliability(): -1 - GetMaxSpeed(): 0 - GetPrice(): 1060 + GetMaxSpeed(): -1 + GetPrice(): -1 GetMaxAge(): -1 - GetRunningCost(): 0 + GetRunningCost(): -1 GetPower(): -1 - GetWeight(): 16 + GetWeight(): -1 GetMaxTractiveEffort(): -1 - GetVehicleType(): 0 - GetRailType(): 3 + GetVehicleType(): 255 + GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 Engine 97 - IsValidEngine(): true - GetName(): Iron Ore Hopper - GetCargoType(): 8 + IsValidEngine(): false + GetName(): (null : 0x00000000) + GetCargoType(): 255 CanRefitCargo(): false - GetCapacity(): 37 + GetCapacity(): -1 GetReliability(): -1 - GetMaxSpeed(): 0 - GetPrice(): 1048 + GetMaxSpeed(): -1 + GetPrice(): -1 GetMaxAge(): -1 - GetRunningCost(): 0 + GetRunningCost(): -1 GetPower(): -1 - GetWeight(): 19 + GetWeight(): -1 GetMaxTractiveEffort(): -1 - GetVehicleType(): 0 - GetRailType(): 3 + GetVehicleType(): 255 + GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 Engine 98 - IsValidEngine(): true - GetName(): Steel Truck - GetCargoType(): 9 + IsValidEngine(): false + GetName(): (null : 0x00000000) + GetCargoType(): 255 CanRefitCargo(): false - GetCapacity(): 27 + GetCapacity(): -1 GetReliability(): -1 - GetMaxSpeed(): 0 - GetPrice(): 1148 + GetMaxSpeed(): -1 + GetPrice(): -1 GetMaxAge(): -1 - GetRunningCost(): 0 + GetRunningCost(): -1 GetPower(): -1 - GetWeight(): 18 + GetWeight(): -1 GetMaxTractiveEffort(): -1 - GetVehicleType(): 0 - GetRailType(): 3 + GetVehicleType(): 255 + GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 Engine 99 - IsValidEngine(): true - GetName(): Armoured Van - GetCargoType(): 10 + IsValidEngine(): false + GetName(): (null : 0x00000000) + GetCargoType(): 255 CanRefitCargo(): false - GetCapacity(): 27 + GetCapacity(): -1 GetReliability(): -1 - GetMaxSpeed(): 0 - GetPrice(): 1494 + GetMaxSpeed(): -1 + GetPrice(): -1 GetMaxAge(): -1 - GetRunningCost(): 0 + GetRunningCost(): -1 GetPower(): -1 - GetWeight(): 30 + GetWeight(): -1 GetMaxTractiveEffort(): -1 - GetVehicleType(): 0 - GetRailType(): 3 + GetVehicleType(): 255 + GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 Engine 100 @@ -5747,7 +5747,7 @@ ERROR: HasNext() is invalid as Begin() is never called GetRailType(): 255 GetRoadType(): -1 GetPlaneType(): -1 - Valid Engines: 53 + Valid Engines: 31 --EngineList-- Count(): 11 diff --git a/src/ai/api/ai_engine.cpp b/src/ai/api/ai_engine.cpp index 3793b748c9..5d5a1b814f 100644 --- a/src/ai/api/ai_engine.cpp +++ b/src/ai/api/ai_engine.cpp @@ -16,20 +16,21 @@ #include "../../strings_func.h" #include "../../rail.h" #include "../../engine_base.h" +#include "../../engine_func.h" #include "../../articulated_vehicles.h" #include "table/strings.h" /* static */ bool AIEngine::IsValidEngine(EngineID engine_id) { const Engine *e = ::Engine::GetIfValid(engine_id); - return e != NULL && (HasBit(e->company_avail, _current_company) || ::Company::Get(_current_company)->num_engines[engine_id] > 0); + return e != NULL && (::IsEngineBuildable(engine_id, e->type, _current_company) || ::Company::Get(_current_company)->num_engines[engine_id] > 0); } /* static */ bool AIEngine::IsBuildable(EngineID engine_id) { const Engine *e = ::Engine::GetIfValid(engine_id); - return e != NULL && HasBit(e->company_avail, _current_company); + return e != NULL && ::IsEngineBuildable(engine_id, e->type, _current_company); } /* static */ char *AIEngine::GetName(EngineID engine_id) diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 833f57d227..45a4690fd9 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -252,7 +252,18 @@ static const FiosItem *GetFiosItem(const char *file) int i = strtol(file, &endptr, 10); if (file == endptr || *endptr != '\0') i = -1; - return IsInsideMM(i, 0, _fios_items.Length()) ? _fios_items.Get(i) : NULL; + if (IsInsideMM(i, 0, _fios_items.Length())) return _fios_items.Get(i); + + /* As a last effort assume it is an OpenTTD savegame and + * that the ".sav" part was not given. */ + char long_file[MAX_PATH]; + seprintf(long_file, lastof(long_file), "%s.sav", file); + for (const FiosItem *item = _fios_items.Begin(); item != _fios_items.End(); item++) { + if (strcmp(long_file, item->name) == 0) return item; + if (strcmp(long_file, item->title) == 0) return item; + } + + return NULL; } diff --git a/src/pathfinder/yapf/yapf_costrail.hpp b/src/pathfinder/yapf/yapf_costrail.hpp index 6c4603c68c..a2ec9da252 100644 --- a/src/pathfinder/yapf/yapf_costrail.hpp +++ b/src/pathfinder/yapf/yapf_costrail.hpp @@ -507,9 +507,12 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th /* Gather the next tile/trackdir/tile_type/rail_type. */ TILE next(tf_local.m_new_tile, (Trackdir)FindFirstBit2x64(tf_local.m_new_td_bits)); - if (TrackFollower::DoTrackMasking() && HasPbsSignalOnTrackdir(next.tile, next.td)) { - /* Possible safe tile. */ - end_segment_reason |= ESRB_SAFE_TILE; + if (TrackFollower::DoTrackMasking() && IsTileType(next.tile, MP_RAILWAY)) { + if ((HasSignalOnTrackdir(next.tile, next.td) && IsPbsSignal(GetSignalType(next.tile, TrackdirToTrack(next.td)))) || + (HasSignalOnTrackdir(next.tile, ReverseTrackdir(next.td)) && GetSignalType(next.tile, TrackdirToTrack(next.td)) == SIGTYPE_PBS_ONEWAY)) { + /* Possible safe tile. */ + end_segment_reason |= ESRB_SAFE_TILE; + } } /* Check the next tile for the rail type. */ diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index bf91dc8413..7bac59bb38 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -281,6 +281,9 @@ struct DropdownWindow : Window { } if (this->click_delay != 0 && --this->click_delay == 0) { + /* Make the dropdown "invisible", so it doesn't affect new window placement. */ + this->window_class = WC_INVALID; + w2->OnDropdownSelect(this->parent_button, this->selected_index); delete this; return; @@ -293,6 +296,9 @@ struct DropdownWindow : Window { this->drag_mode = false; if (!this->GetDropDownItem(item)) { if (this->instant_close) { + /* Make the dropdown "invisible", so it doesn't affect new window placement. */ + this->window_class = WC_INVALID; + if (GetWidgetFromPos(w2, _cursor.pos.x - w2->left, _cursor.pos.y - w2->top) == this->parent_button) { /* Send event for selected option if we're still * on the parent button of the list. */