From 5a7c9037709772e4678ee57d9b42f5332bd66f97 Mon Sep 17 00:00:00 2001 From: smatz Date: Wed, 23 Jan 2008 22:34:04 +0000 Subject: (svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead --- src/ai/trolly/build.cpp | 4 +++- src/ai/trolly/pathfinder.cpp | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src/ai/trolly') diff --git a/src/ai/trolly/build.cpp b/src/ai/trolly/build.cpp index 329c54d34..c6bf330e7 100644 --- a/src/ai/trolly/build.cpp +++ b/src/ai/trolly/build.cpp @@ -15,6 +15,8 @@ #include "../../player_base.h" #include "../../player_func.h" #include "../ai.h" +#include "../../tunnelbridge.h" + // Build HQ // Params: @@ -58,7 +60,7 @@ CommandCost AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, by int bridge_type, bridge_len, type, type2; // Find a good bridgetype (the best money can buy) - bridge_len = GetBridgeLength(tile_a, tile_b); + bridge_len = GetTunnelBridgeLength(tile_a, tile_b); type = type2 = 0; for (bridge_type = MAX_BRIDGES-1; bridge_type >= 0; bridge_type--) { if (CheckBridge_Stuff(bridge_type, bridge_len)) { diff --git a/src/ai/trolly/pathfinder.cpp b/src/ai/trolly/pathfinder.cpp index caef80147..3580f48a3 100644 --- a/src/ai/trolly/pathfinder.cpp +++ b/src/ai/trolly/pathfinder.cpp @@ -14,6 +14,7 @@ #include "../../variables.h" #include "../../player_base.h" #include "../../player_func.h" +#include "../../tunnelbridge.h" #define TEST_STATION_NO_DIR 0xFF @@ -320,7 +321,7 @@ static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *curr new_tile += TileOffsByDiagDir(dir); // Precheck, is the length allowed? - if (!CheckBridge_Stuff(0, GetBridgeLength(tile, new_tile))) break; + if (!CheckBridge_Stuff(0, GetTunnelBridgeLength(tile, new_tile))) break; // Check if we hit the station-tile.. we don't like that! if (TILES_BETWEEN(new_tile, PathFinderInfo->end_tile_tl, PathFinderInfo->end_tile_br)) break; @@ -425,14 +426,14 @@ static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current, int r; // Tunnels are very expensive when build on long routes.. // Ironicly, we are using BridgeCode here ;) - r = AI_PATHFINDER_TUNNEL_PENALTY * GetBridgeLength(current->tile, parent->path.node.tile); + r = AI_PATHFINDER_TUNNEL_PENALTY * GetTunnelBridgeLength(current->tile, parent->path.node.tile); res += r + (r >> 8); } // Are we part of a bridge? if ((AI_PATHFINDER_FLAG_BRIDGE & current->user_data[0]) != 0) { // That means for every length a penalty - res += AI_PATHFINDER_BRIDGE_PENALTY * GetBridgeLength(current->tile, parent->path.node.tile); + res += AI_PATHFINDER_BRIDGE_PENALTY * GetTunnelBridgeLength(current->tile, parent->path.node.tile); // Check if we are going up or down, first for the starting point // In user_data[0] is at the 8th bit the direction if (!HasBridgeFlatRamp(parent_tileh, (Axis)((current->user_data[0] >> 8) & 1))) res += AI_PATHFINDER_BRIDGE_GOES_UP_PENALTY; -- cgit v1.2.3-54-g00ecf