summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2009-02-14 21:17:35 +0000
committeryexo <yexo@openttd.org>2009-02-14 21:17:35 +0000
commit7d88077addf412c3d2c392c4b16d6adaec0d006e (patch)
tree05b9b751f604a46d2d479768bb5f35bfd5ca3446 /src/ai
parent16954ba37806a4510e626d5ceb29f8114c275a3d (diff)
downloadopenttd-7d88077addf412c3d2c392c4b16d6adaec0d006e.tar.xz
(svn r15490) -Change [API CHANGE]: Remove AIBridge::GetYearAvailable. AIBridge::IsValidBridge now only returns true for available bridges.
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/api/ai_bridge.cpp10
-rw-r--r--src/ai/api/ai_bridge.hpp9
-rw-r--r--src/ai/api/ai_bridge.hpp.sq1
-rw-r--r--src/ai/api/ai_bridgelist.cpp16
4 files changed, 10 insertions, 26 deletions
diff --git a/src/ai/api/ai_bridge.cpp b/src/ai/api/ai_bridge.cpp
index f342404cf..03c457d4c 100644
--- a/src/ai/api/ai_bridge.cpp
+++ b/src/ai/api/ai_bridge.cpp
@@ -10,10 +10,11 @@
#include "../../core/alloc_func.hpp"
#include "../../economy_func.h"
#include "../../settings_type.h"
+#include "../../date_func.h"
/* static */ bool AIBridge::IsValidBridge(BridgeID bridge_id)
{
- return bridge_id < MAX_BRIDGES;
+ return bridge_id < MAX_BRIDGES && ::GetBridgeSpec(bridge_id)->avail_year <= _cur_year;
}
/* static */ bool AIBridge::IsBridgeTile(TileIndex tile)
@@ -159,13 +160,6 @@ static void _DoCommandReturnBuildBridge1(class AIInstance *instance)
return ::GetBridgeSpec(bridge_id)->min_length + 2;
}
-/* static */ int32 AIBridge::GetYearAvailable(BridgeID bridge_id)
-{
- if (!IsValidBridge(bridge_id)) return -1;
-
- return ::GetBridgeSpec(bridge_id)->avail_year;
-}
-
/* static */ TileIndex AIBridge::GetOtherBridgeEnd(TileIndex tile)
{
if (!::IsValidTile(tile)) return INVALID_TILE;
diff --git a/src/ai/api/ai_bridge.hpp b/src/ai/api/ai_bridge.hpp
index a4bac67f7..befb7a02a 100644
--- a/src/ai/api/ai_bridge.hpp
+++ b/src/ai/api/ai_bridge.hpp
@@ -95,15 +95,6 @@ public:
*/
static int32 GetMinLength(BridgeID bridge_id);
- /**
- * Get the year in which a bridge becomes available.
- * @param bridge_id The bridge to get the year of availability of.
- * @pre IsValidBridge(bridge_id).
- * @returns The year of availability the bridge has.
- * @note Years are like 2010, -10 (10 B.C.), 1950, ..
- */
- static int32 GetYearAvailable(BridgeID bridge_id);
-
#ifndef DOXYGEN_SKIP
/**
* Internal function to help BuildBridge in case of road.
diff --git a/src/ai/api/ai_bridge.hpp.sq b/src/ai/api/ai_bridge.hpp.sq
index 7759bdbbc..be031d77d 100644
--- a/src/ai/api/ai_bridge.hpp.sq
+++ b/src/ai/api/ai_bridge.hpp.sq
@@ -41,7 +41,6 @@ void SQAIBridge_Register(Squirrel *engine) {
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetPrice, "GetPrice", 3, "?ii");
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetMaxLength, "GetMaxLength", 2, "?i");
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetMinLength, "GetMinLength", 2, "?i");
- SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetYearAvailable, "GetYearAvailable", 2, "?i");
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::BuildBridge, "BuildBridge", 5, "?iiii");
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::RemoveBridge, "RemoveBridge", 2, "?i");
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetOtherBridgeEnd, "GetOtherBridgeEnd", 2, "?i");
diff --git a/src/ai/api/ai_bridgelist.cpp b/src/ai/api/ai_bridgelist.cpp
index 9fd6728c2..2c4f36af9 100644
--- a/src/ai/api/ai_bridgelist.cpp
+++ b/src/ai/api/ai_bridgelist.cpp
@@ -9,16 +9,16 @@
AIBridgeList::AIBridgeList()
{
- /* Add all bridges, no matter if they are available or not */
- for (byte j = 0; j < MAX_BRIDGES; j++)
- if (::GetBridgeSpec(j)->avail_year <= _cur_year)
- this->AddItem(j);
+ for (byte j = 0; j < MAX_BRIDGES; j++) {
+ if (AIBridge::IsValidBridge(j)) this->AddItem(j);
+ }
}
AIBridgeList_Length::AIBridgeList_Length(uint length)
{
- for (byte j = 0; j < MAX_BRIDGES; j++)
- if (::GetBridgeSpec(j)->avail_year <= _cur_year)
- if (length >= (uint)AIBridge::GetMinLength(j) && length <= (uint)AIBridge::GetMaxLength(j))
- this->AddItem(j);
+ for (byte j = 0; j < MAX_BRIDGES; j++) {
+ if (AIBridge::IsValidBridge(j)) {
+ if (length >= (uint)AIBridge::GetMinLength(j) && length <= (uint)AIBridge::GetMaxLength(j)) this->AddItem(j);
+ }
+ }
}