Mercurial > hg > openttd
changeset 8551:bfe75aee55ee draft
(svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
author | smatz <smatz@openttd.org> |
---|---|
date | Wed, 13 Feb 2008 14:21:36 +0000 |
parents | 14ecde7f8abf |
children | e730ad7aad64 |
files | src/lang/english.txt src/openttd.cpp src/order_cmd.cpp src/roadveh_cmd.cpp src/saveload.cpp src/settings.cpp src/settings_gui.cpp src/settings_type.h src/ship_cmd.cpp src/train_cmd.cpp src/vehicle_type.h |
diffstat | 11 files changed, 81 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1049,7 +1049,6 @@ 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_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
--- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -2398,6 +2398,25 @@ } } } + + /* 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();
--- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -328,10 +328,8 @@ 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;
--- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -416,10 +416,10 @@ { 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 @@ 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 @@ 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 @@ 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 @@ 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 {
--- 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!
--- a/src/settings.cpp +++ b/src/settings.cpp @@ -1400,11 +1400,15 @@ 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),
--- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -795,10 +795,9 @@ "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",
--- a/src/settings_type.h +++ b/src/settings_type.h @@ -126,6 +126,10 @@ 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;
--- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -120,7 +120,7 @@ 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 @@ } 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 @@ { 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 @@ } else { return INVALID_TRACK; /* Already at target, reverse? */ } - } else { + } else { /* OPF */ uint tot_dist, dist; Track track; TileIndex tile2;
--- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -2010,10 +2010,10 @@ 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 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ reverse_best = false; } } - } else { + } else { /* NTP is selected */ int best_track = -1; uint reverse = 0; uint best_bird_dist = 0; @@ -3025,7 +3025,7 @@ * 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 @@ /* 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)); }
--- a/src/vehicle_type.h +++ b/src/vehicle_type.h @@ -52,4 +52,12 @@ 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 */