summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/ai/regression/regression.nut6
-rw-r--r--bin/ai/regression/regression.txt64
-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
6 files changed, 29 insertions, 77 deletions
diff --git a/bin/ai/regression/regression.nut b/bin/ai/regression/regression.nut
index eaa7c88a7..e93e9252f 100644
--- a/bin/ai/regression/regression.nut
+++ b/bin/ai/regression/regression.nut
@@ -252,7 +252,6 @@ function Regression::Bridge()
print(" GetPrice(): " + AIBridge.GetPrice(i, 5));
print(" GetMaxLength(): " + AIBridge.GetMaxLength(i));
print(" GetMinLength(): " + AIBridge.GetMinLength(i));
- print(" GetYearAvailable(): " + AIBridge.GetYearAvailable(i));
}
print(" Valid Bridges: " + j);
@@ -297,11 +296,6 @@ function Regression::BridgeList()
for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
- list.Valuate(AIBridge.GetYearAvailable);
- print(" YearAvailable ListDump:");
- for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
- print(" " + i + " => " + list.GetValue(i));
- }
list = AIBridgeList_Length(14);
diff --git a/bin/ai/regression/regression.txt b/bin/ai/regression/regression.txt
index d23e5451e..350da2025 100644
--- a/bin/ai/regression/regression.txt
+++ b/bin/ai/regression/regression.txt
@@ -643,7 +643,6 @@
GetPrice(): -1
GetMaxLength(): -1
GetMinLength(): -1
- GetYearAvailable(): -1
Bridge 0
IsValidBridge(): true
GetName(): Wooden rail bridge
@@ -651,7 +650,6 @@
GetPrice(): 10
GetMaxLength(): 102
GetMinLength(): 2
- GetYearAvailable(): 0
Bridge 1
IsValidBridge(): true
GetName(): Concrete rail bridge
@@ -659,7 +657,6 @@
GetPrice(): 15
GetMaxLength(): 4
GetMinLength(): 2
- GetYearAvailable(): 0
Bridge 2
IsValidBridge(): true
GetName(): Steel girder rail bridge
@@ -667,7 +664,6 @@
GetPrice(): 19
GetMaxLength(): 7
GetMinLength(): 2
- GetYearAvailable(): 1930
Bridge 3
IsValidBridge(): true
GetName(): Reinforced concrete suspension rail bridge
@@ -675,7 +671,6 @@
GetPrice(): 22
GetMaxLength(): 12
GetMinLength(): 4
- GetYearAvailable(): 0
Bridge 4
IsValidBridge(): true
GetName(): Steel suspension rail bridge
@@ -683,7 +678,6 @@
GetPrice(): 25
GetMaxLength(): 102
GetMinLength(): 5
- GetYearAvailable(): 1930
Bridge 5
IsValidBridge(): true
GetName(): Steel suspension rail bridge
@@ -691,7 +685,6 @@
GetPrice(): 26
GetMaxLength(): 102
GetMinLength(): 5
- GetYearAvailable(): 1930
Bridge 6
IsValidBridge(): true
GetName(): Steel cantilever rail bridge
@@ -699,7 +692,6 @@
GetPrice(): 30
GetMaxLength(): 9
GetMinLength(): 5
- GetYearAvailable(): 1930
Bridge 7
IsValidBridge(): true
GetName(): Steel cantilever rail bridge
@@ -707,7 +699,6 @@
GetPrice(): 31
GetMaxLength(): 10
GetMinLength(): 5
- GetYearAvailable(): 1930
Bridge 8
IsValidBridge(): true
GetName(): Steel cantilever rail bridge
@@ -715,7 +706,6 @@
GetPrice(): 33
GetMaxLength(): 11
GetMinLength(): 5
- GetYearAvailable(): 1930
Bridge 9
IsValidBridge(): true
GetName(): Steel girder rail bridge
@@ -723,31 +713,27 @@
GetPrice(): 32
GetMaxLength(): 4
GetMinLength(): 2
- GetYearAvailable(): 1930
Bridge 10
- IsValidBridge(): true
- GetName(): Tubular rail bridge
- GetMaxSpeed(): 320
- GetPrice(): 34
- GetMaxLength(): 102
- GetMinLength(): 4
- GetYearAvailable(): 1995
+ IsValidBridge(): false
+ GetName(): (null : 0x00000000)
+ GetMaxSpeed(): -1
+ GetPrice(): -1
+ GetMaxLength(): -1
+ GetMinLength(): -1
Bridge 11
- IsValidBridge(): true
- GetName(): Tubular rail bridge
- GetMaxSpeed(): 512
- GetPrice(): 51
- GetMaxLength(): 102
- GetMinLength(): 4
- GetYearAvailable(): 2005
+ IsValidBridge(): false
+ GetName(): (null : 0x00000000)
+ GetMaxSpeed(): -1
+ GetPrice(): -1
+ GetMaxLength(): -1
+ GetMinLength(): -1
Bridge 12
- IsValidBridge(): true
- GetName(): Tubular rail bridge
- GetMaxSpeed(): 608
- GetPrice(): 69
- GetMaxLength(): 102
- GetMinLength(): 4
- GetYearAvailable(): 2010
+ IsValidBridge(): false
+ GetName(): (null : 0x00000000)
+ GetMaxSpeed(): -1
+ GetPrice(): -1
+ GetMaxLength(): -1
+ GetMinLength(): -1
Bridge 13
IsValidBridge(): false
GetName(): (null : 0x00000000)
@@ -755,8 +741,7 @@
GetPrice(): -1
GetMaxLength(): -1
GetMinLength(): -1
- GetYearAvailable(): -1
- Valid Bridges: 13
+ Valid Bridges: 10
IsBridgeTile(): false
RemoveBridge(): false
GetLastErrorString(): ERR_PRECONDITION_FAILED
@@ -816,17 +801,6 @@
2 => 2
1 => 2
0 => 2
- YearAvailable ListDump:
- 9 => 1930
- 8 => 1930
- 7 => 1930
- 6 => 1930
- 5 => 1930
- 4 => 1930
- 2 => 1930
- 3 => 0
- 1 => 0
- 0 => 0
--BridgeList_Length--
Count(): 3
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);
+ }
+ }
}