mirror of https://github.com/OpenTTD/OpenTTD
(svn r15490) -Change [API CHANGE]: Remove AIBridge::GetYearAvailable. AIBridge::IsValidBridge now only returns true for available bridges.
parent
16954ba378
commit
7d88077add
|
@ -252,7 +252,6 @@ function Regression::Bridge()
|
||||||
print(" GetPrice(): " + AIBridge.GetPrice(i, 5));
|
print(" GetPrice(): " + AIBridge.GetPrice(i, 5));
|
||||||
print(" GetMaxLength(): " + AIBridge.GetMaxLength(i));
|
print(" GetMaxLength(): " + AIBridge.GetMaxLength(i));
|
||||||
print(" GetMinLength(): " + AIBridge.GetMinLength(i));
|
print(" GetMinLength(): " + AIBridge.GetMinLength(i));
|
||||||
print(" GetYearAvailable(): " + AIBridge.GetYearAvailable(i));
|
|
||||||
}
|
}
|
||||||
print(" Valid Bridges: " + j);
|
print(" Valid Bridges: " + j);
|
||||||
|
|
||||||
|
@ -297,11 +296,6 @@ function Regression::BridgeList()
|
||||||
for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
|
for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
|
||||||
print(" " + i + " => " + list.GetValue(i));
|
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);
|
list = AIBridgeList_Length(14);
|
||||||
|
|
||||||
|
|
|
@ -643,7 +643,6 @@
|
||||||
GetPrice(): -1
|
GetPrice(): -1
|
||||||
GetMaxLength(): -1
|
GetMaxLength(): -1
|
||||||
GetMinLength(): -1
|
GetMinLength(): -1
|
||||||
GetYearAvailable(): -1
|
|
||||||
Bridge 0
|
Bridge 0
|
||||||
IsValidBridge(): true
|
IsValidBridge(): true
|
||||||
GetName(): Wooden rail bridge
|
GetName(): Wooden rail bridge
|
||||||
|
@ -651,7 +650,6 @@
|
||||||
GetPrice(): 10
|
GetPrice(): 10
|
||||||
GetMaxLength(): 102
|
GetMaxLength(): 102
|
||||||
GetMinLength(): 2
|
GetMinLength(): 2
|
||||||
GetYearAvailable(): 0
|
|
||||||
Bridge 1
|
Bridge 1
|
||||||
IsValidBridge(): true
|
IsValidBridge(): true
|
||||||
GetName(): Concrete rail bridge
|
GetName(): Concrete rail bridge
|
||||||
|
@ -659,7 +657,6 @@
|
||||||
GetPrice(): 15
|
GetPrice(): 15
|
||||||
GetMaxLength(): 4
|
GetMaxLength(): 4
|
||||||
GetMinLength(): 2
|
GetMinLength(): 2
|
||||||
GetYearAvailable(): 0
|
|
||||||
Bridge 2
|
Bridge 2
|
||||||
IsValidBridge(): true
|
IsValidBridge(): true
|
||||||
GetName(): Steel girder rail bridge
|
GetName(): Steel girder rail bridge
|
||||||
|
@ -667,7 +664,6 @@
|
||||||
GetPrice(): 19
|
GetPrice(): 19
|
||||||
GetMaxLength(): 7
|
GetMaxLength(): 7
|
||||||
GetMinLength(): 2
|
GetMinLength(): 2
|
||||||
GetYearAvailable(): 1930
|
|
||||||
Bridge 3
|
Bridge 3
|
||||||
IsValidBridge(): true
|
IsValidBridge(): true
|
||||||
GetName(): Reinforced concrete suspension rail bridge
|
GetName(): Reinforced concrete suspension rail bridge
|
||||||
|
@ -675,7 +671,6 @@
|
||||||
GetPrice(): 22
|
GetPrice(): 22
|
||||||
GetMaxLength(): 12
|
GetMaxLength(): 12
|
||||||
GetMinLength(): 4
|
GetMinLength(): 4
|
||||||
GetYearAvailable(): 0
|
|
||||||
Bridge 4
|
Bridge 4
|
||||||
IsValidBridge(): true
|
IsValidBridge(): true
|
||||||
GetName(): Steel suspension rail bridge
|
GetName(): Steel suspension rail bridge
|
||||||
|
@ -683,7 +678,6 @@
|
||||||
GetPrice(): 25
|
GetPrice(): 25
|
||||||
GetMaxLength(): 102
|
GetMaxLength(): 102
|
||||||
GetMinLength(): 5
|
GetMinLength(): 5
|
||||||
GetYearAvailable(): 1930
|
|
||||||
Bridge 5
|
Bridge 5
|
||||||
IsValidBridge(): true
|
IsValidBridge(): true
|
||||||
GetName(): Steel suspension rail bridge
|
GetName(): Steel suspension rail bridge
|
||||||
|
@ -691,7 +685,6 @@
|
||||||
GetPrice(): 26
|
GetPrice(): 26
|
||||||
GetMaxLength(): 102
|
GetMaxLength(): 102
|
||||||
GetMinLength(): 5
|
GetMinLength(): 5
|
||||||
GetYearAvailable(): 1930
|
|
||||||
Bridge 6
|
Bridge 6
|
||||||
IsValidBridge(): true
|
IsValidBridge(): true
|
||||||
GetName(): Steel cantilever rail bridge
|
GetName(): Steel cantilever rail bridge
|
||||||
|
@ -699,7 +692,6 @@
|
||||||
GetPrice(): 30
|
GetPrice(): 30
|
||||||
GetMaxLength(): 9
|
GetMaxLength(): 9
|
||||||
GetMinLength(): 5
|
GetMinLength(): 5
|
||||||
GetYearAvailable(): 1930
|
|
||||||
Bridge 7
|
Bridge 7
|
||||||
IsValidBridge(): true
|
IsValidBridge(): true
|
||||||
GetName(): Steel cantilever rail bridge
|
GetName(): Steel cantilever rail bridge
|
||||||
|
@ -707,7 +699,6 @@
|
||||||
GetPrice(): 31
|
GetPrice(): 31
|
||||||
GetMaxLength(): 10
|
GetMaxLength(): 10
|
||||||
GetMinLength(): 5
|
GetMinLength(): 5
|
||||||
GetYearAvailable(): 1930
|
|
||||||
Bridge 8
|
Bridge 8
|
||||||
IsValidBridge(): true
|
IsValidBridge(): true
|
||||||
GetName(): Steel cantilever rail bridge
|
GetName(): Steel cantilever rail bridge
|
||||||
|
@ -715,7 +706,6 @@
|
||||||
GetPrice(): 33
|
GetPrice(): 33
|
||||||
GetMaxLength(): 11
|
GetMaxLength(): 11
|
||||||
GetMinLength(): 5
|
GetMinLength(): 5
|
||||||
GetYearAvailable(): 1930
|
|
||||||
Bridge 9
|
Bridge 9
|
||||||
IsValidBridge(): true
|
IsValidBridge(): true
|
||||||
GetName(): Steel girder rail bridge
|
GetName(): Steel girder rail bridge
|
||||||
|
@ -723,31 +713,27 @@
|
||||||
GetPrice(): 32
|
GetPrice(): 32
|
||||||
GetMaxLength(): 4
|
GetMaxLength(): 4
|
||||||
GetMinLength(): 2
|
GetMinLength(): 2
|
||||||
GetYearAvailable(): 1930
|
|
||||||
Bridge 10
|
Bridge 10
|
||||||
IsValidBridge(): true
|
IsValidBridge(): false
|
||||||
GetName(): Tubular rail bridge
|
GetName(): (null : 0x00000000)
|
||||||
GetMaxSpeed(): 320
|
GetMaxSpeed(): -1
|
||||||
GetPrice(): 34
|
GetPrice(): -1
|
||||||
GetMaxLength(): 102
|
GetMaxLength(): -1
|
||||||
GetMinLength(): 4
|
GetMinLength(): -1
|
||||||
GetYearAvailable(): 1995
|
|
||||||
Bridge 11
|
Bridge 11
|
||||||
IsValidBridge(): true
|
IsValidBridge(): false
|
||||||
GetName(): Tubular rail bridge
|
GetName(): (null : 0x00000000)
|
||||||
GetMaxSpeed(): 512
|
GetMaxSpeed(): -1
|
||||||
GetPrice(): 51
|
GetPrice(): -1
|
||||||
GetMaxLength(): 102
|
GetMaxLength(): -1
|
||||||
GetMinLength(): 4
|
GetMinLength(): -1
|
||||||
GetYearAvailable(): 2005
|
|
||||||
Bridge 12
|
Bridge 12
|
||||||
IsValidBridge(): true
|
IsValidBridge(): false
|
||||||
GetName(): Tubular rail bridge
|
GetName(): (null : 0x00000000)
|
||||||
GetMaxSpeed(): 608
|
GetMaxSpeed(): -1
|
||||||
GetPrice(): 69
|
GetPrice(): -1
|
||||||
GetMaxLength(): 102
|
GetMaxLength(): -1
|
||||||
GetMinLength(): 4
|
GetMinLength(): -1
|
||||||
GetYearAvailable(): 2010
|
|
||||||
Bridge 13
|
Bridge 13
|
||||||
IsValidBridge(): false
|
IsValidBridge(): false
|
||||||
GetName(): (null : 0x00000000)
|
GetName(): (null : 0x00000000)
|
||||||
|
@ -755,8 +741,7 @@
|
||||||
GetPrice(): -1
|
GetPrice(): -1
|
||||||
GetMaxLength(): -1
|
GetMaxLength(): -1
|
||||||
GetMinLength(): -1
|
GetMinLength(): -1
|
||||||
GetYearAvailable(): -1
|
Valid Bridges: 10
|
||||||
Valid Bridges: 13
|
|
||||||
IsBridgeTile(): false
|
IsBridgeTile(): false
|
||||||
RemoveBridge(): false
|
RemoveBridge(): false
|
||||||
GetLastErrorString(): ERR_PRECONDITION_FAILED
|
GetLastErrorString(): ERR_PRECONDITION_FAILED
|
||||||
|
@ -816,17 +801,6 @@
|
||||||
2 => 2
|
2 => 2
|
||||||
1 => 2
|
1 => 2
|
||||||
0 => 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--
|
--BridgeList_Length--
|
||||||
Count(): 3
|
Count(): 3
|
||||||
|
|
|
@ -10,10 +10,11 @@
|
||||||
#include "../../core/alloc_func.hpp"
|
#include "../../core/alloc_func.hpp"
|
||||||
#include "../../economy_func.h"
|
#include "../../economy_func.h"
|
||||||
#include "../../settings_type.h"
|
#include "../../settings_type.h"
|
||||||
|
#include "../../date_func.h"
|
||||||
|
|
||||||
/* static */ bool AIBridge::IsValidBridge(BridgeID bridge_id)
|
/* 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)
|
/* static */ bool AIBridge::IsBridgeTile(TileIndex tile)
|
||||||
|
@ -159,13 +160,6 @@ static void _DoCommandReturnBuildBridge1(class AIInstance *instance)
|
||||||
return ::GetBridgeSpec(bridge_id)->min_length + 2;
|
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)
|
/* static */ TileIndex AIBridge::GetOtherBridgeEnd(TileIndex tile)
|
||||||
{
|
{
|
||||||
if (!::IsValidTile(tile)) return INVALID_TILE;
|
if (!::IsValidTile(tile)) return INVALID_TILE;
|
||||||
|
|
|
@ -95,15 +95,6 @@ public:
|
||||||
*/
|
*/
|
||||||
static int32 GetMinLength(BridgeID bridge_id);
|
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
|
#ifndef DOXYGEN_SKIP
|
||||||
/**
|
/**
|
||||||
* Internal function to help BuildBridge in case of road.
|
* 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::GetPrice, "GetPrice", 3, "?ii");
|
||||||
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetMaxLength, "GetMaxLength", 2, "?i");
|
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetMaxLength, "GetMaxLength", 2, "?i");
|
||||||
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetMinLength, "GetMinLength", 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::BuildBridge, "BuildBridge", 5, "?iiii");
|
||||||
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::RemoveBridge, "RemoveBridge", 2, "?i");
|
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::RemoveBridge, "RemoveBridge", 2, "?i");
|
||||||
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetOtherBridgeEnd, "GetOtherBridgeEnd", 2, "?i");
|
SQAIBridge.DefSQStaticMethod(engine, &AIBridge::GetOtherBridgeEnd, "GetOtherBridgeEnd", 2, "?i");
|
||||||
|
|
|
@ -9,16 +9,16 @@
|
||||||
|
|
||||||
AIBridgeList::AIBridgeList()
|
AIBridgeList::AIBridgeList()
|
||||||
{
|
{
|
||||||
/* Add all bridges, no matter if they are available or not */
|
for (byte j = 0; j < MAX_BRIDGES; j++) {
|
||||||
for (byte j = 0; j < MAX_BRIDGES; j++)
|
if (AIBridge::IsValidBridge(j)) this->AddItem(j);
|
||||||
if (::GetBridgeSpec(j)->avail_year <= _cur_year)
|
}
|
||||||
this->AddItem(j);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AIBridgeList_Length::AIBridgeList_Length(uint length)
|
AIBridgeList_Length::AIBridgeList_Length(uint length)
|
||||||
{
|
{
|
||||||
for (byte j = 0; j < MAX_BRIDGES; j++)
|
for (byte j = 0; j < MAX_BRIDGES; j++) {
|
||||||
if (::GetBridgeSpec(j)->avail_year <= _cur_year)
|
if (AIBridge::IsValidBridge(j)) {
|
||||||
if (length >= (uint)AIBridge::GetMinLength(j) && length <= (uint)AIBridge::GetMaxLength(j))
|
if (length >= (uint)AIBridge::GetMinLength(j) && length <= (uint)AIBridge::GetMaxLength(j)) this->AddItem(j);
|
||||||
this->AddItem(j);
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue