mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-05 22:04:57 +00:00
(svn r15490) -Change [API CHANGE]: Remove AIBridge::GetYearAvailable. AIBridge::IsValidBridge now only returns true for available bridges.
This commit is contained in:
parent
16954ba378
commit
7d88077add
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user