From f656f5e8eb8835aad2ad19ca9ade253666b17089 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Mon, 25 Feb 2019 13:07:29 +0000 Subject: [PATCH] Change: Remove ship max order distance. It is skipped when NPF is in use. It is trivial to work around by adding and removing dummy orders. It is mostly alleviated by the ship path cache in YAPF. --- src/order_cmd.cpp | 37 ------------------------------------- src/ship.h | 2 -- 2 files changed, 39 deletions(-) diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index dae6e58ad6..2bfe5d29bf 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -23,7 +23,6 @@ #include "core/random_func.hpp" #include "aircraft.h" #include "roadveh.h" -#include "ship.h" #include "station_base.h" #include "waypoint_base.h" #include "company_base.h" @@ -900,42 +899,6 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 if (!Order::CanAllocateItem()) return_cmd_error(STR_ERROR_NO_MORE_SPACE_FOR_ORDERS); if (v->orders.list == NULL && !OrderList::CanAllocateItem()) return_cmd_error(STR_ERROR_NO_MORE_SPACE_FOR_ORDERS); - if (v->type == VEH_SHIP && _settings_game.pf.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; - - /* Find the last goto station or depot order before the insert location. - * If the order is to be inserted at the beginning of the order list this - * finds the last order in the list. */ - const Order *o; - FOR_VEHICLE_ORDERS(v, o) { - switch (o->GetType()) { - case OT_GOTO_STATION: - case OT_GOTO_DEPOT: - case OT_GOTO_WAYPOINT: - prev = o; - break; - - default: break; - } - if (++n == sel_ord && prev != NULL) break; - } - if (prev != NULL) { - uint dist; - if (new_order.IsType(OT_CONDITIONAL)) { - /* The order is not yet inserted, so we have to do the first iteration here. */ - dist = GetOrderDistance(prev, v->GetOrder(new_order.GetConditionSkipToOrder()), v); - } else { - dist = GetOrderDistance(prev, &new_order, v); - } - - if (dist >= SHIP_MAX_ORDER_DISTANCE) { - return_cmd_error(STR_ERROR_TOO_FAR_FROM_PREVIOUS_DESTINATION); - } - } - } - if (flags & DC_EXEC) { Order *new_o = new Order(); new_o->AssignOrder(new_order); diff --git a/src/ship.h b/src/ship.h index 60d4466d68..6f818efb2c 100644 --- a/src/ship.h +++ b/src/ship.h @@ -57,8 +57,6 @@ struct Ship FINAL : public SpecializedVehicle { void SetDestTile(TileIndex tile); }; -static const uint SHIP_MAX_ORDER_DISTANCE = 130; - /** * Iterate over all ships. * @param var The variable used for iteration.