diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lang/english.txt | 17 | ||||
-rw-r--r-- | src/openttd.cpp | 19 | ||||
-rw-r--r-- | src/order_cmd.cpp | 6 | ||||
-rw-r--r-- | src/roadveh_cmd.cpp | 14 | ||||
-rw-r--r-- | src/saveload.cpp | 2 | ||||
-rw-r--r-- | src/settings.cpp | 12 | ||||
-rw-r--r-- | src/settings_gui.cpp | 7 | ||||
-rw-r--r-- | src/settings_type.h | 4 | ||||
-rw-r--r-- | src/ship_cmd.cpp | 10 | ||||
-rw-r--r-- | src/train_cmd.cpp | 22 | ||||
-rw-r--r-- | src/vehicle_type.h | 8 |
11 files changed, 81 insertions, 40 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt index 7e76c89cb..f6448f176 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1049,7 +1049,6 @@ STR_CONFIG_PATCHES_BRIBE :{LTBLUE}Allow b STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE :{LTBLUE}Allow buying exclusive transport rights: {ORANGE}{STRING1} STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY :{LTBLUE}Allow sending money to other companies: {ORANGE}{STRING1} STR_CONFIG_PATCHES_NONUNIFORM_STATIONS :{LTBLUE}Nonuniform stations: {ORANGE}{STRING1} -STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL :{LTBLUE}New global pathfinding (NPF, overrides NTP): {ORANGE}{STRING1} STR_CONFIG_PATCHES_FREIGHT_TRAINS :{LTBLUE}Weight multiplier for freight to simulate heavy trains: {ORANGE}{STRING} STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD :{LTBLUE}Allow drive-through road stops on town owned roads: {ORANGE}{STRING} STR_CONFIG_PATCHES_ADJACENT_STATIONS :{LTBLUE}Allow building adjacent stations: {ORANGE}{STRING} @@ -1204,9 +1203,19 @@ STR_CONFIG_PATCHES_CURRENCY :{CURRENCY} STR_CONFIG_PATCHES_QUERY_CAPT :{WHITE}Change setting value STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE :{WHITE}Some or all of the default service interval(s) below are incompatible with the chosen setting! 5-90% and 30-800 days are valid -STR_CONFIG_PATCHES_YAPF_SHIPS :{LTBLUE}Use YAPF for ships: {ORANGE}{STRING1} -STR_CONFIG_PATCHES_YAPF_ROAD :{LTBLUE}Use YAPF for roadvehs: {ORANGE}{STRING1} -STR_CONFIG_PATCHES_YAPF_RAIL :{LTBLUE}Use YAPF for trains: {ORANGE}{STRING1} + +STR_CONFIG_PATCHES_PATHFINDER_FOR_TRAINS :{LTBLUE}Pathfinder for trains: {ORANGE}{STRING1} +STR_CONFIG_PATCHES_PATHFINDER_FOR_TRAINS_NTP :NTP {RED}(Not recommended) +STR_CONFIG_PATCHES_PATHFINDER_FOR_TRAINS_NPF :NPF +STR_CONFIG_PATCHES_PATHFINDER_FOR_TRAINS_YAPF :YAPF {BLUE}(Recommended) +STR_CONFIG_PATCHES_PATHFINDER_FOR_ROADVEH :{LTBLUE}Pathfinder for road vehicles: {ORANGE}{STRING1} +STR_CONFIG_PATCHES_PATHFINDER_FOR_ROADVEH_OPF :Original {RED}(Not recommended) +STR_CONFIG_PATCHES_PATHFINDER_FOR_ROADVEH_NPF :NPF +STR_CONFIG_PATCHES_PATHFINDER_FOR_ROADVEH_YAPF :YAPF {BLUE}(Recommended) +STR_CONFIG_PATCHES_PATHFINDER_FOR_SHIPS :{LTBLUE}Pathfinder for ships: {ORANGE}{STRING1} +STR_CONFIG_PATCHES_PATHFINDER_FOR_SHIPS_OPF :Original {BLUE}(Recommended) +STR_CONFIG_PATCHES_PATHFINDER_FOR_SHIPS_NPF :NPF +STR_CONFIG_PATCHES_PATHFINDER_FOR_SHIPS_YAPF :YAPF {RED}(Not recommended) STR_TEMPERATE_LANDSCAPE :Temperate landscape STR_SUB_ARCTIC_LANDSCAPE :Sub-arctic landscape diff --git a/src/openttd.cpp b/src/openttd.cpp index 3e86992b0..e4accf911 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -2398,6 +2398,25 @@ bool AfterLoadGame() } } } + + /* Convert old PF settings to new */ + if (_patches.yapf.rail_use_yapf) { + _patches.pathfinder_for_trains = VPF_YAPF; + } else { + _patches.pathfinder_for_trains = (_patches.new_pathfinding_all ? VPF_NPF : VPF_NTP); + } + + if (_patches.yapf.road_use_yapf) { + _patches.pathfinder_for_roadvehs = VPF_YAPF; + } else { + _patches.pathfinder_for_roadvehs = (_patches.new_pathfinding_all ? VPF_NPF : VPF_OPF); + } + + if (_patches.yapf.ship_use_yapf) { + _patches.pathfinder_for_ships = VPF_YAPF; + } else { + _patches.pathfinder_for_ships = (_patches.new_pathfinding_all ? VPF_NPF : VPF_OPF); + } } return InitializeWindowsAndCaches(); diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 770c91880..dbc1dac79 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -328,10 +328,8 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) if (!HasOrderPoolFree(1)) return_cmd_error(STR_8831_NO_MORE_SPACE_FOR_ORDERS); - if (v->type == VEH_SHIP && - IsHumanPlayer(v->owner) && - !_patches.new_pathfinding_all) { - // Make sure the new destination is not too far away from the previous + if (v->type == VEH_SHIP && IsHumanPlayer(v->owner) && _patches.pathfinder_for_ships != VPF_NPF) { + /* Make sure the new destination is not too far away from the previous */ const Order *prev = NULL; uint n = 0; diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 5a432837c..6c4db3316 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -416,10 +416,10 @@ static const Depot* FindClosestRoadDepot(const Vehicle* v) { TileIndex tile = v->tile; - if (_patches.yapf.road_use_yapf) { + if (_patches.pathfinder_for_roadvehs == VPF_YAPF) { /* YAPF is being used */ Depot* ret = YapfFindNearestRoadDepot(v); return ret; - } else if (_patches.new_pathfinding_all) { + } else if (_patches.pathfinder_for_roadvehs == VPF_NPF) { /* NPF is being used */ NPFFoundTargetData ftd; /* See where we are now */ Trackdir trackdir = GetVehicleTrackdir(v); @@ -431,7 +431,7 @@ static const Depot* FindClosestRoadDepot(const Vehicle* v) return NULL; /* Target not found */ } /* We do not search in two directions here, why should we? We can't reverse right now can we? */ - } else { + } else { /* OPF is being used */ RoadFindDepotData rfdd; rfdd.owner = v->owner; @@ -1217,11 +1217,11 @@ static Trackdir RoadFindPathToDest(Vehicle* v, TileIndex tile, DiagDirection ent return_track(FindFirstBit2x64(trackdirs)); } - if (_patches.yapf.road_use_yapf) { + if (_patches.pathfinder_for_roadvehs == VPF_YAPF) { /* YAPF */ Trackdir trackdir = YapfChooseRoadTrack(v, tile, enterdir); if (trackdir != INVALID_TRACKDIR) return_track(trackdir); return_track(PickRandomBit(trackdirs)); - } else if (_patches.new_pathfinding_all) { + } else if (_patches.pathfinder_for_roadvehs == VPF_NPF) { /* NPF */ NPFFindStationOrTileData fstd; NPFFoundTargetData ftd; Trackdir trackdir; @@ -1243,7 +1243,7 @@ static Trackdir RoadFindPathToDest(Vehicle* v, TileIndex tile, DiagDirection ent to the tile closest to our target. */ return_track(ftd.best_trackdir); } - } else { + } else { /* OPF */ DiagDirection dir; if (IsTileType(desttile, MP_ROAD)) { @@ -1300,7 +1300,7 @@ found_best_track:; static uint RoadFindPathToStop(const Vehicle *v, TileIndex tile) { uint dist; - if (_patches.yapf.road_use_yapf) { + if (_patches.pathfinder_for_roadvehs == VPF_YAPF) { /* use YAPF */ dist = YapfRoadVehDistanceToTile(v, tile); } else { diff --git a/src/saveload.cpp b/src/saveload.cpp index 33a5e58a8..2b71c4dd2 100644 --- a/src/saveload.cpp +++ b/src/saveload.cpp @@ -34,7 +34,7 @@ #include "table/strings.h" -extern const uint16 SAVEGAME_VERSION = 86; +extern const uint16 SAVEGAME_VERSION = 87; uint16 _sl_version; ///< the major savegame version identifier byte _sl_minor_version; ///< the minor savegame version, DO NOT USE! diff --git a/src/settings.cpp b/src/settings.cpp index 03a6afd1c..5375219ec 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1400,11 +1400,15 @@ const SettingDesc _patch_settings[] = { SDT_BOOL(Patches, mammoth_trains, 0,NN, true, STR_CONFIG_PATCHES_MAMMOTHTRAINS, NULL), SDT_BOOL(Patches, gotodepot, 0, 0, true, STR_CONFIG_PATCHES_GOTODEPOT, NULL), SDT_BOOL(Patches, roadveh_queue, 0, 0, true, STR_CONFIG_PATCHES_ROADVEH_QUEUE, NULL), - SDT_BOOL(Patches, new_pathfinding_all, 0, 0, false, STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL, NULL), - SDT_CONDBOOL(Patches, yapf.ship_use_yapf, 28, SL_MAX_VERSION, 0, 0, false, STR_CONFIG_PATCHES_YAPF_SHIPS, NULL), - SDT_CONDBOOL(Patches, yapf.road_use_yapf, 28, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_YAPF_ROAD, NULL), - SDT_CONDBOOL(Patches, yapf.rail_use_yapf, 28, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_YAPF_RAIL, NULL), + SDT_CONDBOOL(Patches, new_pathfinding_all, 0,86, 0, 0, false, STR_NULL, NULL), + SDT_CONDBOOL(Patches, yapf.ship_use_yapf, 28,86, 0, 0, false, STR_NULL, NULL), + SDT_CONDBOOL(Patches, yapf.road_use_yapf, 28,86, 0, 0, true, STR_NULL, NULL), + SDT_CONDBOOL(Patches, yapf.rail_use_yapf, 28,86, 0, 0, true, STR_NULL, NULL), + + SDT_CONDVAR(Patches, pathfinder_for_trains, SLE_UINT8, 87, SL_MAX_VERSION, 0, MS, 2, 0, 2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_TRAINS, NULL), + SDT_CONDVAR(Patches, pathfinder_for_roadvehs, SLE_UINT8, 87, SL_MAX_VERSION, 0, MS, 2, 0, 2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_ROADVEH, NULL), + SDT_CONDVAR(Patches, pathfinder_for_ships, SLE_UINT8, 87, SL_MAX_VERSION, 0, MS, 0, 0, 2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_SHIPS, NULL), SDT_BOOL(Patches, train_income_warn, S, 0, true, STR_CONFIG_PATCHES_WARN_INCOME_LESS, NULL), SDT_VAR(Patches, order_review_system,SLE_UINT8, S,MS, 2, 0, 2, 0, STR_CONFIG_PATCHES_ORDER_REVIEW, NULL), diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index c835a3b06..b6245e2d7 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -795,10 +795,9 @@ static const char *_patches_vehicles[] = { "mammoth_trains", "gotodepot", "roadveh_queue", - "new_pathfinding_all", - "yapf.ship_use_yapf", - "yapf.road_use_yapf", - "yapf.rail_use_yapf", + "pathfinder_for_trains", + "pathfinder_for_roadvehs", + "pathfinder_for_ships", "train_income_warn", "order_review_system", "never_expire_vehicles", diff --git a/src/settings_type.h b/src/settings_type.h index 6985f63a0..3460f47ed 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -126,6 +126,10 @@ struct Patches { uint16 servint_aircraft; ///< service interval for aircraft uint16 servint_ships; ///< service interval for ships + uint8 pathfinder_for_trains; ///< the pathfinder to use for trains + uint8 pathfinder_for_roadvehs; ///< the pathfinder to use for roadvehicles + uint8 pathfinder_for_ships; ///< the pathfinder to use for ships + bool autorenew; int16 autorenew_months; int32 autorenew_money; diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index 45341e149..6b986c494 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -120,7 +120,7 @@ static const Depot* FindClosestShipDepot(const Vehicle* v) TileIndex tile; TileIndex tile2 = v->tile; - if (_patches.new_pathfinding_all) { + if (_patches.pathfinder_for_ships == VPF_NPF) { /* NPF is used */ NPFFoundTargetData ftd; Trackdir trackdir = GetVehicleTrackdir(v); ftd = NPFRouteToDepotTrialError(v->tile, trackdir, false, TRANSPORT_WATER, 0, v->owner, INVALID_RAILTYPES); @@ -129,7 +129,7 @@ static const Depot* FindClosestShipDepot(const Vehicle* v) } else { best_depot = NULL; /* Did not find target */ } - } else { + } else { /* OPF or YAPF */ FOR_ALL_DEPOTS(depot) { tile = depot->xy; if (IsTileDepotType(tile, TRANSPORT_WATER) && IsTileOwner(tile, v->owner)) { @@ -527,10 +527,10 @@ static Track ChooseShipTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, { assert(enterdir >= 0 && enterdir <= 3); - if (_patches.yapf.ship_use_yapf) { + if (_patches.pathfinder_for_ships == VPF_YAPF) { /* YAPF */ Trackdir trackdir = YapfChooseShipTrack(v, tile, enterdir, tracks); return (trackdir != INVALID_TRACKDIR) ? TrackdirToTrack(trackdir) : INVALID_TRACK; - } else if (_patches.new_pathfinding_all) { + } else if (_patches.pathfinder_for_ships == VPF_NPF) { /* NPF */ NPFFindStationOrTileData fstd; NPFFoundTargetData ftd; Trackdir trackdir = GetVehicleTrackdir(v); @@ -549,7 +549,7 @@ static Track ChooseShipTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, } else { return INVALID_TRACK; /* Already at target, reverse? */ } - } else { + } else { /* OPF */ uint tot_dist, dist; Track track; TileIndex tile2; diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 110427547..79ca20083 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -2010,10 +2010,10 @@ static TrainFindDepotData FindClosestTrainDepot(Vehicle *v, int max_distance) return tfdd; } - if (_patches.yapf.rail_use_yapf) { + if (_patches.pathfinder_for_trains == VPF_YAPF) { /* YAPF is selected */ bool found = YapfFindNearestRailDepotTwoWay(v, max_distance, NPF_INFINITE_PENALTY, &tfdd.tile, &tfdd.reverse); tfdd.best_length = found ? max_distance / 2 : -1; // some fake distance or NOT_FOUND - } else if (_patches.new_pathfinding_all) { + } else if (_patches.pathfinder_for_trains == VPF_NPF) { /* NPF is selected */ Vehicle* last = GetLastVehicleInChain(v); Trackdir trackdir = GetVehicleTrackdir(v); Trackdir trackdir_rev = ReverseTrackdir(GetVehicleTrackdir(last)); @@ -2030,7 +2030,7 @@ static TrainFindDepotData FindClosestTrainDepot(Vehicle *v, int max_distance) tfdd.best_length = ftd.best_path_dist / NPF_TILE_LENGTH; if (NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE)) tfdd.reverse = true; } - } else { + } else { /* NTP */ /* search in the forward direction first. */ DiagDirection i = TrainExitDir(v->direction, v->u.rail.track); NewTrainPathfind(tile, 0, v->u.rail.compatible_railtypes, i, (NTPEnumProc*)NtpCallbFindDepot, &tfdd); @@ -2358,14 +2358,14 @@ static Track ChooseTrainTrack(Vehicle* v, TileIndex tile, DiagDirection enterdir /* quick return in case only one possible track is available */ if (KillFirstBit(tracks) == TRACK_BIT_NONE) return FindFirstTrack(tracks); - if (_patches.yapf.rail_use_yapf) { + if (_patches.pathfinder_for_trains == VPF_YAPF) { /* YAPF is selected */ Trackdir trackdir = YapfChooseRailTrack(v, tile, enterdir, tracks, &path_not_found); if (trackdir != INVALID_TRACKDIR) { best_track = TrackdirToTrack(trackdir); } else { best_track = FindFirstTrack(tracks); } - } else if (_patches.new_pathfinding_all) { /* Use a new pathfinding for everything */ + } else if (_patches.pathfinder_for_trains == VPF_NPF) { /* NPF is selected */ void* perf = NpfBeginInterval(); NPFFindStationOrTileData fstd; @@ -2393,7 +2393,7 @@ static Track ChooseTrainTrack(Vehicle* v, TileIndex tile, DiagDirection enterdir int time = NpfEndInterval(perf); DEBUG(yapf, 4, "[NPFT] %d us - %d rounds - %d open - %d closed -- ", time, 0, _aystar_stats_open_size, _aystar_stats_closed_size); - } else { + } else { /* NTP is selected */ void* perf = NpfBeginInterval(); TrainTrackFollowerData fd; @@ -2469,9 +2469,9 @@ static bool CheckReverseTrain(Vehicle *v) int i = _search_directions[FIND_FIRST_BIT(v->u.rail.track)][DirToDiagDir(v->direction)]; - if (_patches.yapf.rail_use_yapf) { + if (_patches.pathfinder_for_trains == VPF_YAPF) { /* YAPF is selected */ reverse_best = YapfCheckReverseTrain(v); - } else if (_patches.new_pathfinding_all) { /* Use a new pathfinding for everything */ + } else if (_patches.pathfinder_for_trains == VPF_NPF) { /* NPF if selected for trains */ NPFFindStationOrTileData fstd; NPFFoundTargetData ftd; Trackdir trackdir, trackdir_rev; @@ -2495,7 +2495,7 @@ static bool CheckReverseTrain(Vehicle *v) reverse_best = false; } } - } else { + } else { /* NTP is selected */ int best_track = -1; uint reverse = 0; uint best_bird_dist = 0; @@ -3025,7 +3025,7 @@ static void TrainController(Vehicle *v, bool update_image) * the signal status. */ uint32 tracks = ts | (ts >> 8); TrackBits bits = (TrackBits)(tracks & TRACK_BIT_MASK); - if ((_patches.new_pathfinding_all || _patches.yapf.rail_use_yapf) && _patches.forbid_90_deg && prev == NULL) { + if ((_patches.pathfinder_for_trains != VPF_NTP) && _patches.forbid_90_deg && prev == NULL) { /* We allow wagons to make 90 deg turns, because forbid_90_deg * can be switched on halfway a turn */ bits &= ~TrackCrossesTracks(FindFirstTrack(v->u.rail.track)); @@ -3459,7 +3459,7 @@ static bool TrainCheckIfLineEnds(Vehicle *v) /* mask unreachable track bits if we are forbidden to do 90deg turns */ TrackBits bits = (TrackBits)((ts | (ts >> 8)) & TRACK_BIT_MASK); - if ((_patches.new_pathfinding_all || _patches.yapf.rail_use_yapf) && _patches.forbid_90_deg) { + if ((_patches.pathfinder_for_trains != VPF_NTP) && _patches.forbid_90_deg) { bits &= ~TrackCrossesTracks(FindFirstTrack(v->u.rail.track)); } diff --git a/src/vehicle_type.h b/src/vehicle_type.h index a6d5aae4d..629c7bb3e 100644 --- a/src/vehicle_type.h +++ b/src/vehicle_type.h @@ -52,4 +52,12 @@ enum EffectVehicle { EV_BUBBLE = 9 }; +/** Pathfinding option states */ +enum { + VPF_OPF = 0, ///< The Original PathFinder + VPF_NTP = 0, ///< New Train Pathfinder, replacing OPF for trains + VPF_NPF = 1, ///< New PathFinder + VPF_YAPF = 2, ///< Yet Another PathFinder +}; + #endif /* VEHICLE_TYPE_H */ |